From 218b5a0f2603d94db4842070c1fccca84f35b9a8 Mon Sep 17 00:00:00 2001 From: Soreth Date: Sun, 3 Apr 2022 10:44:04 +0200 Subject: [PATCH 1/6] add french translation --- .../assets/mininggadgets/lang/fr_fr.json | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/main/resources/assets/mininggadgets/lang/fr_fr.json diff --git a/src/main/resources/assets/mininggadgets/lang/fr_fr.json b/src/main/resources/assets/mininggadgets/lang/fr_fr.json new file mode 100644 index 00000000..d1868519 --- /dev/null +++ b/src/main/resources/assets/mininggadgets/lang/fr_fr.json @@ -0,0 +1,81 @@ +{ + "block.mininggadgets.minerslight": "Lumière de mineur", + "block.mininggadgets.modificationtable": "Tableau des modifications", + "block.mininggadgets.renderblock": "Bloc de rendu (ne pas utiliser)", + "block.mininggadgets.renderblock.name": "Peu importe ce qu'il veut être !", + "item.mininggadgets.mininggadget": "Gadget minier MK3", + "item.mininggadgets.mininggadget_fancy": "Gadget minier MK2", + "item.mininggadgets.mininggadget_simple": "Gadget minier MK1", + "item.mininggadgets.upgrade_battery_1": "Mise à niveau : Batterie, Niveau 1", + "item.mininggadgets.upgrade_battery_2": "Mise à niveau : Batterie, Niveau 2", + "item.mininggadgets.upgrade_battery_3": "Mise à niveau : Batterie, Niveau 3", + "item.mininggadgets.upgrade_efficiency_1": "Mise à niveau : Efficacité, Niveau 1", + "item.mininggadgets.upgrade_efficiency_2": "Mise à niveau : Efficacité, Niveau 2", + "item.mininggadgets.upgrade_efficiency_3": "Mise à niveau : Efficacité, Niveau 3", + "item.mininggadgets.upgrade_efficiency_4": "Mise à niveau : Efficacité, Niveau 4", + "item.mininggadgets.upgrade_efficiency_5": "Mise à niveau : Efficacité, Niveau 5", + "item.mininggadgets.upgrade_empty": "Module de mise à niveau vierge", + "item.mininggadgets.upgrade_fortune_1": "Mise à niveau : Fortune, Niveau 1", + "item.mininggadgets.upgrade_fortune_2": "Mise à niveau : Fortune, Niveau 2", + "item.mininggadgets.upgrade_fortune_3": "Mise à niveau : Fortune, Niveau 3", + "item.mininggadgets.upgrade_freezing": "Mise à niveau : Geler", + "item.mininggadgets.upgrade_light_placer": "Mise à niveau : Placeur de lumière", + "item.mininggadgets.upgrade_magnet": "Mise à niveau : Aimant", + "item.mininggadgets.upgrade_range_1": "Mise à niveau : Portée, Niveau 1", + "item.mininggadgets.upgrade_range_2": "Mise à niveau : Portée, Niveau 2", + "item.mininggadgets.upgrade_range_3": "Mise à niveau : Portée, Niveau 3", + "item.mininggadgets.upgrade_silk": "Mise à niveau : Toucher de soie", + "item.mininggadgets.upgrade_three_by_three": "Mise à niveau : 3x3", + "item.mininggadgets.upgrade_void_junk": "Mise à niveau : Poubelle du vide", + "itemGroup.mininggadgets": "Gadgets miniers", + "mininggadgets.gadget.energy": "Énergie : %d/%d", + "mininggadgets.gadget.range_change": "Changement de portée: %1$d x %1$d", + "mininggadgets.text.empty_table_helper": "Maj-cliquez pour insérer à partir de vos emplacements\nou déposez la mise à niveau sur cet écran.\on\onCliquez sur la mise à niveau pour supprimer.", + "mininggadgets.text.modification_table": "Tableau des modifications", + "mininggadgets.text.open_gui": "Ouvrir les paramètres du gadget minier", + "mininggadgets.tooltip.item.battery_boost": "Boost de batterie : %1$d", + "mininggadgets.tooltip.item.break_cost": "Coût par bloc : %1$d", + "mininggadgets.tooltip.item.show_upgrades": "Maintenez Maj pour afficher les mises à niveau", + "mininggadgets.tooltip.item.upgrade_cost": "Coût de mise à niveau : %1$d", + "mininggadgets.tooltip.item.upgrades": "Mises à niveau actuelles :", + "mininggadgets.tooltip.item.use_cost": "+%1$d FE par utilisation", + "mininggadgets.tooltip.screen.beam_preview": "Aperçu du faisceau", + "mininggadgets.tooltip.screen.blacklist": "Liste noire active", + "mininggadgets.tooltip.screen.block_break_style": "Style de rupture", + "mininggadgets.tooltip.screen.blue": "Bleu", + "mininggadgets.tooltip.screen.delay_explain": "Contrôle la fréquence à laquelle une particule de gel est générée\npar défaut, il s'agit d'une particule à chaque tick, pour réduire\nla quantité de particules, ajouter plus de retard.", + "mininggadgets.tooltip.screen.edit_filters": "Modifier les filtres", + "mininggadgets.tooltip.screen.fade": "Fondu du bloc", + "mininggadgets.tooltip.screen.freeze_delay": "Délai de gel", + "mininggadgets.tooltip.screen.green": "Vert", + "mininggadgets.tooltip.screen.inner_color": "Couleur du faisceau intérieur", + "mininggadgets.tooltip.screen.mining_gadget": "Paramètres des gadgets", + "mininggadgets.tooltip.screen.no_upgrades": "Aucune mise à niveau disponible", + "mininggadgets.tooltip.screen.outer_color": "Couleur de lueur extérieure", + "mininggadgets.tooltip.screen.precision_mode": "Mode Précision : %1$d", + "mininggadgets.tooltip.screen.range": "Portée ", + "mininggadgets.tooltip.screen.red": "Rouge", + "mininggadgets.tooltip.screen.shrink": "Réduit les blocs", + "mininggadgets.tooltip.screen.size": "Taille : %1$d x %1$d", + "mininggadgets.tooltip.screen.ticks": "ticks", + "mininggadgets.tooltip.screen.toggle_upgrades": "Basculer les mises à niveau", + "mininggadgets.tooltip.screen.visual_settings": "Paramètres visuels", + "mininggadgets.tooltip.screen.visuals_menu": "Modifier les visuels", + "mininggadgets.tooltip.screen.volume": "Volume", + "mininggadgets.tooltip.screen.whitelist": "Liste blanche active", + "mininggadgets.tooltip.single.filters": "Filtres", + "mininggadgets.tooltip.single.insert": "Insérer", + "mininggadgets.upgrade.replacement": "Mise à niveau : ", + "tooltop.mininggadgets.battery": "Améliore les condensateurs internes", + "tooltop.mininggadgets.efficiency": "Applique efficacité au gadget minier", + "tooltop.mininggadgets.empty": "Utilisé pour fabriquer d'autres améliorations", + "tooltop.mininggadgets.fortune": "Applique fortune au gadget minier", + "tooltop.mininggadgets.freezing": "Gèle l'eau et arrête la lave place !", + "tooltop.mininggadgets.light_placer": "Place des torches chaque fois que le niveau d'éclairage environnant est inférieur à 8", + "tooltop.mininggadgets.magnet": "Déconstruit les blocs directement dans votre inventaire", + "tooltop.mininggadgets.paver": "Crée un chemin pour vous pendant que vous minez", + "tooltop.mininggadgets.range": "Prolonge votre portée de 5 fois avec chaque niveau", + "tooltop.mininggadgets.silk": "Applique l'enchantement toucher soie au gadget minier", + "tooltop.mininggadgets.three_by_three": "Permet un rayon minier de 3x3", + "tooltop.mininggadgets.void_junk": "Désintègre les blocs ! (ajoute également un filtrage)" +} \ No newline at end of file From 871428a6019e605892d649fdc397213869bcadc9 Mon Sep 17 00:00:00 2001 From: David-John Miller Date: Sat, 17 Dec 2022 12:01:15 +0200 Subject: [PATCH 2/6] Implemented a Creative Battery upgrade, mostly to help with Development. Creative Battery gives MAX_INT battery capacity and on use the Gadget each block will cost 0 energy, but also the Gadget will give itself MAX_INT power while being used. Updated CapabilityEnergy.ENERGY (deprecated) to ForgeCapabilities.ENERGY --- .../CapabilityEnergyProvider.java | 4 +-- .../containers/ModificationTableCommands.java | 6 ++-- .../common/data/GeneratorLanguage.java | 1 + .../common/items/MiningGadget.java | 34 +++++++++++++----- .../mininggadgets/common/items/ModItems.java | 1 + .../common/items/upgrade/Upgrade.java | 1 + .../items/upgrade/UpgradeBatteryLevels.java | 3 +- .../common/tiles/RenderBlockTileEntity.java | 6 ++-- .../item/upgrade_battery_creative.png | Bin 0 -> 3536 bytes 9 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/assets/mininggadgets/textures/item/upgrade_battery_creative.png diff --git a/src/main/java/com/direwolf20/mininggadgets/common/capabilities/CapabilityEnergyProvider.java b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/CapabilityEnergyProvider.java index 1abbb079..93f477ca 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/capabilities/CapabilityEnergyProvider.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/capabilities/CapabilityEnergyProvider.java @@ -4,9 +4,9 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import javax.annotation.Nonnull; @@ -25,6 +25,6 @@ public CapabilityEnergyProvider(ItemStack stack, int energyCapacity) { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - return cap == CapabilityEnergy.ENERGY ? capability.cast() : LazyOptional.empty(); + return cap == ForgeCapabilities.ENERGY ? capability.cast() : LazyOptional.empty(); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java index be4054c1..7c2577e7 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java @@ -11,7 +11,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import java.util.List; @@ -51,7 +51,7 @@ public static boolean insertButton(ModificationTableContainer container, ItemSta // Did we just insert a battery upgrade? if(card.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) { UpgradeBatteryLevels.getBatteryByLevel(card.getTier()).ifPresent(power -> { - laser.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(power.getPower())); + laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(power.getPower())); }); } @@ -92,7 +92,7 @@ public static void extractButton(ModificationTableContainer container, ServerPla } if (upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) - laser.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower())); + laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower())); }); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java index 75bb0380..abecf8e5 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java @@ -45,6 +45,7 @@ protected void addTranslations() { addItem(ModItems.BATTERY_1, "Upgrade: Battery, Tier 1"); addItem(ModItems.BATTERY_2, "Upgrade: Battery, Tier 2"); addItem(ModItems.BATTERY_3, "Upgrade: Battery, Tier 3"); + addItem(ModItems.BATTERY_CREATIVE, "Upgrade: Creative Battery"); // Upgrade tooltips :D add("tooltop.mininggadgets.empty", "Used to craft other upgrades"); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java index f73bbc69..6ab78f76 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java @@ -52,8 +52,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.event.level.BlockEvent; @@ -88,7 +88,10 @@ public int getMaxDamage(ItemStack stack) { @Override public boolean isBarVisible(ItemStack stack) { - IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null); + if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) + return false; + + IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null); return (energy.getEnergyStored() < energy.getMaxEnergyStored()); } @@ -100,14 +103,14 @@ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundT @Override public int getBarWidth(ItemStack stack) { - return stack.getCapability(CapabilityEnergy.ENERGY, null) + return stack.getCapability(ForgeCapabilities.ENERGY, null) .map(e -> Math.min(13 * e.getEnergyStored() / e.getMaxEnergyStored(), 13)) .orElse(0); } @Override public int getBarColor(ItemStack stack) { - return stack.getCapability(CapabilityEnergy.ENERGY) + return stack.getCapability(ForgeCapabilities.ENERGY) .map(e -> Mth.hsvToRgb(Math.max(0.0F, (float) e.getEnergyStored() / (float) e.getMaxEnergyStored()) / 3.0F, 1.0F, 1.0F)) .orElse(super.getBarColor(stack)); } @@ -142,7 +145,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List { MutableComponent energyText = !sneakPressed ? Component.translatable("mininggadgets.gadget.energy", MagicHelpers.tidyValue(energy.getEnergyStored()), MagicHelpers.tidyValue(energy.getMaxEnergyStored())) @@ -170,7 +173,10 @@ public static void changeRange(ItemStack tool) { } public static boolean canMine(ItemStack tool) { - IEnergyStorage energy = tool.getCapability(CapabilityEnergy.ENERGY, null).orElse(null); + if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(tool), Upgrade.BATTERY_CREATIVE)) + return true; + + IEnergyStorage energy = tool.getCapability(ForgeCapabilities.ENERGY, null).orElse(null); int cost = getEnergyCost(tool); if (MiningProperties.getRange(tool) == 3) @@ -338,6 +344,10 @@ public void onUsingTick(ItemStack stack, LivingEntity player, int count) { Level world = player.level; if (world.isClientSide) { this.playLoopSound(player, stack); + } else { + if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) { + stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false)); + } } if (!MiningProperties.getCanMine(stack)) @@ -443,7 +453,7 @@ else if (g > 0 && b == 1) else*/ durability = durability - 1; if (durability <= 0) { - stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(getEnergyCost(stack) * -1, false)); + stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(getEnergyCost(stack) * -1, false)); if (MiningProperties.getPrecisionMode(stack)) { MiningProperties.setCanMine(stack, false); player.stopUsingItem(); @@ -472,16 +482,19 @@ else if (g > 0 && b == 1) pos = lookingAt.getBlockPos().relative(side).relative(right); if (world.getMaxLocalRawBrightness(pos) <= 7 && world.getBlockState(pos).getMaterial() == Material.AIR) { - int energy = stack.getCapability(CapabilityEnergy.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0); + int energy = stack.getCapability(ForgeCapabilities.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0); if (energy > Config.UPGRADECOST_LIGHT.get()) { world.setBlockAndUpdate(pos, ModBlocks.MINERS_LIGHT.get().defaultBlockState()); - stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy((Config.UPGRADECOST_LIGHT.get() * -1), false)); + stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy((Config.UPGRADECOST_LIGHT.get() * -1), false)); } } } } public static int getEnergyCost(ItemStack stack) { + if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) + return 0; + int cost = Config.MININGGADGET_BASECOST.get(); List upgrades = UpgradeTools.getActiveUpgrades(stack); if (upgrades.isEmpty()) @@ -533,6 +546,9 @@ public static void applyUpgrade(ItemStack tool, UpgradeCard upgradeCard) { return; UpgradeTools.setUpgrade(tool, upgradeCard); + if (upgradeCard.getUpgrade() == Upgrade.BATTERY_CREATIVE) { + tool.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false)); + } } @Override diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java b/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java index 34b77e24..0e81570d 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java @@ -46,6 +46,7 @@ public class ModItems { public static final RegistryObject BATTERY_1 = UPGRADE_ITEMS.register("upgrade_battery_1", () -> new UpgradeCard(Upgrade.BATTERY_1)); public static final RegistryObject BATTERY_2 = UPGRADE_ITEMS.register("upgrade_battery_2", () -> new UpgradeCard(Upgrade.BATTERY_2)); public static final RegistryObject BATTERY_3 = UPGRADE_ITEMS.register("upgrade_battery_3", () -> new UpgradeCard(Upgrade.BATTERY_3)); + public static final RegistryObject BATTERY_CREATIVE = UPGRADE_ITEMS.register("upgrade_battery_creative", () -> new UpgradeCard(Upgrade.BATTERY_CREATIVE)); public static final RegistryObject EFFICIENCY_1 = UPGRADE_ITEMS.register("upgrade_efficiency_1", () -> new UpgradeCard(Upgrade.EFFICIENCY_1)); public static final RegistryObject EFFICIENCY_2 = UPGRADE_ITEMS.register("upgrade_efficiency_2", () -> new UpgradeCard(Upgrade.EFFICIENCY_2)); public static final RegistryObject EFFICIENCY_3 = UPGRADE_ITEMS.register("upgrade_efficiency_3", () -> new UpgradeCard(Upgrade.EFFICIENCY_3)); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/Upgrade.java b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/Upgrade.java index d018497d..1d3effe2 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/Upgrade.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/Upgrade.java @@ -40,6 +40,7 @@ public enum Upgrade { BATTERY_1("battery_1", ModItems.BATTERY_1, 1, () -> 0), BATTERY_2("battery_2", ModItems.BATTERY_2, 2, () -> 0), BATTERY_3("battery_3", ModItems.BATTERY_3, 3, () -> 0), + BATTERY_CREATIVE("battery_CREATIVE", ModItems.BATTERY_CREATIVE, 4, () -> 0), RANGE_1("range_1", ModItems.RANGE_1, 1, () -> 0), RANGE_2("range_2", ModItems.RANGE_2, 2, () -> 0), diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeBatteryLevels.java b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeBatteryLevels.java index d20335d1..4ed57c20 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeBatteryLevels.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/upgrade/UpgradeBatteryLevels.java @@ -15,7 +15,8 @@ public enum UpgradeBatteryLevels { BATTERY(0, Config.MININGGADGET_MAXPOWER.get()), BATTERY_1(1, Config.UPGRADECOST_BATTERY1.get()), BATTERY_2(2, Config.UPGRADECOST_BATTERY2.get()), - BATTERY_3(3, Config.UPGRADECOST_BATTERY3.get()); + BATTERY_3(3, Config.UPGRADECOST_BATTERY3.get()), + BATTERY_CREATIVE(4, Integer.MAX_VALUE); private int level; private int power; diff --git a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java index e4fc6bc4..0f854dd8 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java @@ -32,7 +32,7 @@ import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.level.BlockEvent; @@ -195,7 +195,7 @@ public void setDurability(int dur, ItemStack stack) { private void freeze(ItemStack stack) { int freezeCost = Config.UPGRADECOST_FREEZE.get() * -1; - int energy = stack.getCapability(CapabilityEnergy.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0); + int energy = stack.getCapability(ForgeCapabilities.ENERGY).map(IEnergyStorage::getEnergyStored).orElse(0); if (energy == 0) { return; @@ -220,7 +220,7 @@ private int replaceBlockWithAlternative(Level world, BlockPos pos, BlockState st return 0; } - stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(costOfOperation, false)); + stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(costOfOperation, false)); // If the block is just water logged, remove the fluid BlockState blockState = world.getBlockState(pos); diff --git a/src/main/resources/assets/mininggadgets/textures/item/upgrade_battery_creative.png b/src/main/resources/assets/mininggadgets/textures/item/upgrade_battery_creative.png new file mode 100644 index 0000000000000000000000000000000000000000..0787001ce8fb69fc9796c05672958a955fc39608 GIT binary patch literal 3536 zcmcgvTWAzl7+zZiFSQ0OMT*5?d{NS~bD!NAca=38&4Qbz$%;u^q-V~Y*-YJ?+0IO| zn^3_93rY)ODMiGG-X5e-p_bBzwg`PF_)=);LqL5g6dHsEr7s0r`_IhoWW~fRRyt&N zGw1x*?|kPwGiOGI4{hG~+{RQYwYfA@9EIP$@U#9&_}-1SjKR+ufAr9S)a4&{EWpj$ zYN1?6rM@`3=`LOe_u9ze%AlesJ9qA!o161IZ+?FM+O=y}KY#b1KYzb<^Si}ge?E5X z*scD>zsa42Pyf1f=@OsbF+QAWIY+_!mAmV{}9ImxkXE%kbm!VdK~q&EriG~7a#=4qet;c9OT|13y{2v3)OjPT5<|3*DM8(Z5i5!I zqGy9x;97UouqqQGDw0JYcLph#P$coPh73)^$WTlpqiEFPWr!2fLWeL=5)L90oKL`w)%-tTWk*CYS&PEux9V;z{Q)gN~8>rM2RTKlEX#J zW>sWmEQ*O>ilUXxaiL6sQ>cWUD^kR+K)v9;OrUtEyUHBbOM5wJ0C+iMhh5KfRTkAX zM&IZfO1fqujnXlRSC@o4oSJNV*j|R?y>!*_Z%$I+(L;8AoZWY=pou+Nr~>&`R~D|9 zMqFo_dR?tFu!rFoq@JH=Ezhkpi6St8%iu<%W|N5b+_Yo1kC+5?mgyy@kEb6F9aXTw zo1%&gLy}Ndkh91j6jX(3no0y-$y%9*K_|$%q;*8|k)Vs6$Ru{E6rL#HqeWK5ZVYF|sO4Rv|{norFlefoW3D z?&3)|FOzbZh@p=^_o@u-?Es6xPB!=dxR9|nc57LVTVD3sYFLcXJ{a!!=y^(CPSbkj zFFauBa7wRoZp*5wibREtKrlrn4~MsA2?i1gkyTmIcvXqEc^J+8&*ye$1IN&GJxNC@ z8IQtaI@|$Nop*%rE_u(O4oHCqZxLMo>=k$eF-yflW%t;Lvp;P;+1EEXv8VLjy?gV2 z48FAG`7d9seo**rOW$Xo?0Nt6_NPC7=lp4U^ZS?ga_2AbH}-yQ+&=Ol*@PFLIK%!h zfA-r`cY|N{u3Z>fc=J@@^=Cf1Z7fclWN*E7=lZ#eT=VS>&n~Y0>U#LfQyLsDUOw>J F+`n2wVl@B& literal 0 HcmV?d00001 From 59042aefb3a2e3a53d73b7cf081ee56e8f63b75c Mon Sep 17 00:00:00 2001 From: David-John Miller Date: Sat, 17 Dec 2022 12:05:42 +0200 Subject: [PATCH 3/6] Forgot the model --- .../mininggadgets/models/item/upgrade_battery_creative.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/generated/resources/assets/mininggadgets/models/item/upgrade_battery_creative.json diff --git a/src/generated/resources/assets/mininggadgets/models/item/upgrade_battery_creative.json b/src/generated/resources/assets/mininggadgets/models/item/upgrade_battery_creative.json new file mode 100644 index 00000000..8575c113 --- /dev/null +++ b/src/generated/resources/assets/mininggadgets/models/item/upgrade_battery_creative.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "mininggadgets:item/upgrade_battery_creative" + } +} \ No newline at end of file From 9d8d07111554939317e0d728b8af24d5f7c9defb Mon Sep 17 00:00:00 2001 From: David-John Miller Date: Sat, 17 Dec 2022 12:09:12 +0200 Subject: [PATCH 4/6] Add in the translation strings --- src/generated/resources/assets/mininggadgets/lang/en_us.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generated/resources/assets/mininggadgets/lang/en_us.json b/src/generated/resources/assets/mininggadgets/lang/en_us.json index e0ccd72c..ecad1d27 100644 --- a/src/generated/resources/assets/mininggadgets/lang/en_us.json +++ b/src/generated/resources/assets/mininggadgets/lang/en_us.json @@ -9,6 +9,7 @@ "item.mininggadgets.upgrade_battery_1": "Upgrade: Battery, Tier 1", "item.mininggadgets.upgrade_battery_2": "Upgrade: Battery, Tier 2", "item.mininggadgets.upgrade_battery_3": "Upgrade: Battery, Tier 3", + "item.mininggadgets.upgrade_battery_creative": "Upgrade: Battery, Creative", "item.mininggadgets.upgrade_efficiency_1": "Upgrade: Efficiency, Tier 1", "item.mininggadgets.upgrade_efficiency_2": "Upgrade: Efficiency, Tier 2", "item.mininggadgets.upgrade_efficiency_3": "Upgrade: Efficiency, Tier 3", From 83d1275d749f586cfc14f169f1c4096992b93ff8 Mon Sep 17 00:00:00 2001 From: David-John Miller Date: Tue, 20 Dec 2022 17:19:17 +0200 Subject: [PATCH 5/6] Creative battery now sets a tier tag, and this is evaluated when trying to see if it's in creative mode --- .../containers/ModificationTableCommands.java | 12 ++++++++++-- .../common/items/EnergisedItem.java | 1 + .../common/items/MiningGadget.java | 19 +++++++++---------- .../common/items/gadget/MiningProperties.java | 11 +++++++++++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java index 7c2577e7..7cefd894 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/containers/ModificationTableCommands.java @@ -51,8 +51,14 @@ public static boolean insertButton(ModificationTableContainer container, ItemSta // Did we just insert a battery upgrade? if(card.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) { UpgradeBatteryLevels.getBatteryByLevel(card.getTier()).ifPresent(power -> { - laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(power.getPower())); + laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> { + ((EnergisedItem) e).updatedMaxEnergy(power.getPower()); + if (card.getTier() == Upgrade.BATTERY_CREATIVE.getTier()) { + e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false); + } + }); }); + MiningProperties.setBatteryTier(laser, card.getTier()); } return true; @@ -91,8 +97,10 @@ public static void extractButton(ModificationTableContainer container, ServerPla MiningProperties.setBeamMaxRange(laser, UpgradeTools.getMaxBeamRange(0)); } - if (upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) + if (upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) { + MiningProperties.setBatteryTier(laser, 0); laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower())); + } }); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/EnergisedItem.java b/src/main/java/com/direwolf20/mininggadgets/common/items/EnergisedItem.java index 9be74bfd..7761ee1b 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/EnergisedItem.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/EnergisedItem.java @@ -23,6 +23,7 @@ private static int getMaxCapacity(ItemStack stack, int capacity) { public void updatedMaxEnergy(int max) { stack.getOrCreateTag().putInt("max_energy", max); this.capacity = max; + this.energy = Math.min(max, this.energy); // Ensure the current stored energy is up to date with the new max. this.receiveEnergy(1, false); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java index 6ab78f76..8604cced 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java @@ -88,7 +88,7 @@ public int getMaxDamage(ItemStack stack) { @Override public boolean isBarVisible(ItemStack stack) { - if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) + if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier()) return false; IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null); @@ -103,6 +103,9 @@ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundT @Override public int getBarWidth(ItemStack stack) { + if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier()) + return 13; + return stack.getCapability(ForgeCapabilities.ENERGY, null) .map(e -> Math.min(13 * e.getEnergyStored() / e.getMaxEnergyStored(), 13)) .orElse(0); @@ -110,6 +113,9 @@ public int getBarWidth(ItemStack stack) { @Override public int getBarColor(ItemStack stack) { + if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier()) + return Mth.color(0, 1, 0); + return stack.getCapability(ForgeCapabilities.ENERGY) .map(e -> Mth.hsvToRgb(Math.max(0.0F, (float) e.getEnergyStored() / (float) e.getMaxEnergyStored()) / 3.0F, 1.0F, 1.0F)) .orElse(super.getBarColor(stack)); @@ -173,7 +179,7 @@ public static void changeRange(ItemStack tool) { } public static boolean canMine(ItemStack tool) { - if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(tool), Upgrade.BATTERY_CREATIVE)) + if (MiningProperties.getBatteryTier(tool) == Upgrade.BATTERY_CREATIVE.getTier()) return true; IEnergyStorage energy = tool.getCapability(ForgeCapabilities.ENERGY, null).orElse(null); @@ -344,10 +350,6 @@ public void onUsingTick(ItemStack stack, LivingEntity player, int count) { Level world = player.level; if (world.isClientSide) { this.playLoopSound(player, stack); - } else { - if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) { - stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false)); - } } if (!MiningProperties.getCanMine(stack)) @@ -492,7 +494,7 @@ else if (g > 0 && b == 1) } public static int getEnergyCost(ItemStack stack) { - if (UpgradeTools.containsActiveUpgradeFromList(UpgradeTools.getUpgrades(stack), Upgrade.BATTERY_CREATIVE)) + if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier()) return 0; int cost = Config.MININGGADGET_BASECOST.get(); @@ -546,9 +548,6 @@ public static void applyUpgrade(ItemStack tool, UpgradeCard upgradeCard) { return; UpgradeTools.setUpgrade(tool, upgradeCard); - if (upgradeCard.getUpgrade() == Upgrade.BATTERY_CREATIVE) { - tool.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false)); - } } @Override diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java b/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java index 92340c55..a53667b0 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/gadget/MiningProperties.java @@ -29,6 +29,7 @@ private MiningProperties() {} private static final String PRECISION_MODE = "precisionMode"; private static final String VOLUME = "volume"; private static final String FREEZE_PARTICLE_DELAY = "freeze_particle_delay"; + private static final String KEY_BATTERY_TIER = "battery_tier"; public static final String KEY_FILTERS = "filters"; public static final String COLOR_RED = "colorRed"; @@ -169,6 +170,16 @@ public static int getFreezeDelay(ItemStack gadget) { return !compound.contains(FREEZE_PARTICLE_DELAY) ? setFreezeDelay(gadget, 0) : compound.getInt(FREEZE_PARTICLE_DELAY); } + public static int setBatteryTier(ItemStack gadget, int tier) { + gadget.getOrCreateTag().putInt(KEY_BATTERY_TIER, tier); + return tier; + } + + public static int getBatteryTier(ItemStack gadget) { + CompoundTag compound = gadget.getOrCreateTag(); + return !compound.contains(KEY_BATTERY_TIER) ? setBatteryTier(gadget, 0) : compound.getInt(KEY_BATTERY_TIER); + } + /** * So this is a bit fun, because we only need the items in our list we're ditching half the data * that the `Items` actually contains. From bbaf056e5fb093e79a9126e324fdfe95e1a04d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Augusto?= Date: Wed, 22 Mar 2023 18:04:58 -0300 Subject: [PATCH 6/6] Add portuguese brazilian language --- .../assets/mininggadgets/lang/pt_br.json | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/main/resources/assets/mininggadgets/lang/pt_br.json diff --git a/src/main/resources/assets/mininggadgets/lang/pt_br.json b/src/main/resources/assets/mininggadgets/lang/pt_br.json new file mode 100644 index 00000000..4210589d --- /dev/null +++ b/src/main/resources/assets/mininggadgets/lang/pt_br.json @@ -0,0 +1,81 @@ +{ + "block.mininggadgets.minerslight": "Luz de mineração", + "block.mininggadgets.modificationtable": "Bancada de modificação", + "block.mininggadgets.renderblock": "Bloco de renderização (não use)", + "block.mininggadgets.renderblock.name": "O que quer que isso seja!", + "item.mininggadgets.mininggadget": "Dispositivo de mineração MK3", + "item.mininggadgets.mininggadget_fancy": "Dispositivo de mineração MK2", + "item.mininggadgets.mininggadget_simple": "Dispositivo de mineração MK1", + "item.mininggadgets.upgrade_battery_1": "Atualização: Bateria, nível 1", + "item.mininggadgets.upgrade_battery_2": "Atualização: Bateria, nível 2", + "item.mininggadgets.upgrade_battery_3": "Atualização: Bateria, nível 3", + "item.mininggadgets.upgrade_efficiency_1": "Atualização: Eficiência, nível 1", + "item.mininggadgets.upgrade_efficiency_2": "Atualização: Eficiência, nível 2", + "item.mininggadgets.upgrade_efficiency_3": "Atualização: Eficiência, nível 3", + "item.mininggadgets.upgrade_efficiency_4": "Atualização: Eficiência, nível 4", + "item.mininggadgets.upgrade_efficiency_5": "Atualização: Eficiência, nível 5", + "item.mininggadgets.upgrade_empty": "Módulo de atualização em branco", + "item.mininggadgets.upgrade_fortune_1": "Atualização: Fortuna, nível 1", + "item.mininggadgets.upgrade_fortune_2": "Atualização: Fortuna, nível 2", + "item.mininggadgets.upgrade_fortune_3": "Atualização: Fortuna, nível 3", + "item.mininggadgets.upgrade_freezing": "Atualização: Congelamento", + "item.mininggadgets.upgrade_light_placer": "Atualização: Colocador de luz", + "item.mininggadgets.upgrade_magnet": "Atualização: Ímã", + "item.mininggadgets.upgrade_range_1": "Atualização: Alcance, nível 1", + "item.mininggadgets.upgrade_range_2": "Atualização: Alcance, nível 2", + "item.mininggadgets.upgrade_range_3": "Atualização: Alcance, nível 3", + "item.mininggadgets.upgrade_silk": "Atualização: Toque suave", + "item.mininggadgets.upgrade_three_by_three": "Atualização: 3x3", + "item.mininggadgets.upgrade_void_junk": "Atualização: Lixeira", + "itemGroup.mininggadgets": "Dispositivos de mineração", + "mininggadgets.gadget.energy": "Energia: %d/%d", + "mininggadgets.gadget.range_change": "Alteração do alcance: %1$d x %1$d", + "mininggadgets.text.empty_table_helper": "Shift clique para inserir do\nseu inventário ou solte a\natualização nesta tela.\n\nClique na atualização\npara remover.", + "mininggadgets.text.modification_table": "Bancada de modificação", + "mininggadgets.text.open_gui": "Abrir configurações do dispositivo de mineração", + "mininggadgets.tooltip.item.battery_boost": "Aumento de bateria: %1$d", + "mininggadgets.tooltip.item.break_cost": "Custo por bloco: %1$d", + "mininggadgets.tooltip.item.show_upgrades": "Segure SHIFT para mais informações", + "mininggadgets.tooltip.item.upgrade_cost": "Custo de atualização: %1$d", + "mininggadgets.tooltip.item.upgrades": "Atualizações instaladas:", + "mininggadgets.tooltip.item.use_cost": "+%1$d FE por uso", + "mininggadgets.tooltip.screen.beam_preview": "Visualização do raio", + "mininggadgets.tooltip.screen.blacklist": "Lista de bloqueio ativa", + "mininggadgets.tooltip.screen.block_break_style": "Estilo de quebra de bloco", + "mininggadgets.tooltip.screen.blue": "Azul", + "mininggadgets.tooltip.screen.delay_explain": "Controla a frequência em que uma partícula de gelo é gerada\nPor padrão, é uma partícula a cada tick, para reduzir a\nquantidade de partículas aumente o atraso", + "mininggadgets.tooltip.screen.edit_filters": "Editar filtros", + "mininggadgets.tooltip.screen.fade": "Esmaecer blocos", + "mininggadgets.tooltip.screen.freeze_delay": "Atraso", + "mininggadgets.tooltip.screen.green": "Verde", + "mininggadgets.tooltip.screen.inner_color": "Cor do raio interno", + "mininggadgets.tooltip.screen.mining_gadget": "Configurações", + "mininggadgets.tooltip.screen.no_upgrades": "Nenhuma atualização instalada", + "mininggadgets.tooltip.screen.outer_color": "Cor do brilho externo", + "mininggadgets.tooltip.screen.precision_mode": "Modo preciso: %1$d", + "mininggadgets.tooltip.screen.range": "Alcance", + "mininggadgets.tooltip.screen.red": "Vermelho", + "mininggadgets.tooltip.screen.shrink": "Encolher blocos", + "mininggadgets.tooltip.screen.size": "Tamanho: %1$d x %1$d", + "mininggadgets.tooltip.screen.ticks": "ticks", + "mininggadgets.tooltip.screen.toggle_upgrades": "Alternar atualizações", + "mininggadgets.tooltip.screen.visual_settings": "Configurações visuais", + "mininggadgets.tooltip.screen.visuals_menu": "Editar visual", + "mininggadgets.tooltip.screen.volume": "Volume", + "mininggadgets.tooltip.screen.whitelist": "Lista de permissão ativa", + "mininggadgets.tooltip.single.filters": "Filtros", + "mininggadgets.tooltip.single.insert": "Inserir", + "mininggadgets.upgrade.replacement": "Atualização: ", + "tooltop.mininggadgets.battery": "Atualiza os capacitores internos", + "tooltop.mininggadgets.efficiency": "Aplica eficiência ao dispositivo de mineração", + "tooltop.mininggadgets.empty": "Usado para criar outras atualizações", + "tooltop.mininggadgets.fortune": "Aplica fortuna ao dispositivo de mineração", + "tooltop.mininggadgets.freezing": "Congela a água e para a lava no lugar!", + "tooltop.mininggadgets.light_placer": "Coloca tochas sempre que o nível de luz do ambiente for inferior a 8", + "tooltop.mininggadgets.magnet": "Desconstrói blocos direto para o seu inventário", + "tooltop.mininggadgets.paver": "Cria um caminho para você enquanto minera", + "tooltop.mininggadgets.range": "Estende seu alcance em 5 vezes para cada nível", + "tooltop.mininggadgets.silk": "Aplica toque suave ao dispositivo de mineração", + "tooltop.mininggadgets.three_by_three": "Permite um raio de mineração de 3x3", + "tooltop.mininggadgets.void_junk": "Elimina blocos! (também adiciona filtragem)" +} \ No newline at end of file