From 16ba158d5aebc6552275e35b310db7eccd90b459 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Thu, 18 Jun 2020 23:31:16 +0200 Subject: [PATCH] rebalancing, silk touch and fortune abilities properly implemented --- assets/hbm/lang/de_DE.lang | 2 + assets/hbm/lang/en_US.lang | 2 + assets/hbm/textures/blocks/ash.png | Bin 0 -> 718 bytes .../hbm/textures/items/ingot_schraranium.png | Bin 0 -> 424 bytes com/hbm/handler/ToolAbility.java | 57 +++++++++++++++--- com/hbm/inventory/MachineRecipes.java | 25 ++++---- com/hbm/items/ModItems.java | 3 + com/hbm/items/tool/ItemToolAbility.java | 4 ++ com/hbm/main/CraftingManager.java | 2 +- com/hbm/util/EnchantmentUtil.java | 26 ++++++++ 10 files changed, 99 insertions(+), 22 deletions(-) create mode 100644 assets/hbm/textures/blocks/ash.png create mode 100644 assets/hbm/textures/items/ingot_schraranium.png create mode 100644 com/hbm/util/EnchantmentUtil.java diff --git a/assets/hbm/lang/de_DE.lang b/assets/hbm/lang/de_DE.lang index 2a4037e0b..506ed743a 100644 --- a/assets/hbm/lang/de_DE.lang +++ b/assets/hbm/lang/de_DE.lang @@ -71,6 +71,7 @@ potion.hbm_phosphorus=Phosphorverbrennung tool.ability.recursion=Erzadern-Miner tool.ability.hammer=AoE tool.ability.silktouch=Präzisionswerkzeug +tool.ability.fortune=Erz-Extraktor tool.ability.smelter=Auto-Ofen tool.ability.shredder=Auto-Brecher tool.ability.cnetrifuge=Auto-Zentrifuge @@ -655,6 +656,7 @@ item.ingot_steel.name=Stahlbarren item.plate_steel.name=Stahlplatte item.ingot_beryllium.name=Berylliumbarren item.plate_schrabidium.name=Schrabidiumplatte +item.ingot_schraranium.name=Schraraniumbarren item.ingot_schrabidium.name=Schrabidiumbarren item.nugget_schrabidium.name=Schrabidiumnugget item.plate_copper.name=Kupferplatte diff --git a/assets/hbm/lang/en_US.lang b/assets/hbm/lang/en_US.lang index c1e6b7a71..cc948c46d 100644 --- a/assets/hbm/lang/en_US.lang +++ b/assets/hbm/lang/en_US.lang @@ -71,6 +71,7 @@ potion.hbm_phosphorus=Phosphorus Burns tool.ability.recursion=Vein Miner tool.ability.hammer=AoE tool.ability.silktouch=Precision Miner +tool.ability.fortune=Ore Extractor tool.ability.smelter=Auto-Smelter tool.ability.shredder=Auto-Shredder tool.ability.centrifuge=Auto-Centrifuge @@ -655,6 +656,7 @@ item.ingot_steel.name=Steel Ingot item.plate_steel.name=Steel Plate item.ingot_beryllium.name=Beryllium Ingot item.plate_schrabidium.name=Schrabidium Plate +item.ingot_schraranium.name=Schraranium Ingot item.ingot_schrabidium.name=Schrabidium Ingot item.nugget_schrabidium.name=Schrabidium Nugget item.plate_copper.name=Copper Plate diff --git a/assets/hbm/textures/blocks/ash.png b/assets/hbm/textures/blocks/ash.png new file mode 100644 index 0000000000000000000000000000000000000000..a1631562859cbd126c312e4da1bd3181a141c4ab GIT binary patch literal 718 zcmV;<0x|uGP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizW@LZzX3P}QzQTY0%J);K~y+T4U)-j z8%G#~yZ_#%XXlWTNX4<800#V)IrtU)W(IsQd=L^-l0|a%nch2t0_s?(`cU}G*MHuh zK3cUZvLb{U*jaC^#;aZ_KoC)abjHgvTl&E;1ApGX3tC}0y80 zu$>NuF@AZyal^62WtvxqqPtx${c9o8j2DJ_7;G2n(7tp=s2pW&-*26))d7~KmK*B9vZ&Cjn}zdZv7Q#CU0mk z+S%x{rX-Xe=<)sGT}X6-^J&pPE>GW|zEKJpl}%CsUU8yiaohz%^Q6|%DzDDZzqbu` zH+Q-v5uFYvupl8NY(ouXw3BOHckO;n=dGplb|b^29A0L>>Lx9-tjg=Mg{z+;#OQ$I zK!V8lsXT&*1SA8tF1q5?{lnv8^*D92>tetP=?#3pV~xmpP*~yRhT4BOb(bvV6pQ6H zItZ3It>9Rk6qPtk@<$_jQNaU|mZ0ViF2QiIQkmjD0&07*qoM6N<$f^+3a AO#lD@ literal 0 HcmV?d00001 diff --git a/assets/hbm/textures/items/ingot_schraranium.png b/assets/hbm/textures/items/ingot_schraranium.png new file mode 100644 index 0000000000000000000000000000000000000000..664d11e738a4ace91de9f8aa9f5f18ffd7ea8dac GIT binary patch literal 424 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sEXgD|57Yp@DXgRQ5FV~B-+@}K|z?U_{@IK3wGc90?0KfKWU^>B-0aHXh<7lUa`b>g=!}C0e*BYV zzQMrwKcVgW)2%%7&DOAbAIf23tTZmx;9kVZ;vltuMYi#tsLgX4Syc}Fe5A>&?y;$! z?S??itb_;q7YIyY6=C1maNbVUC8JR>pVX=Oy3CTQL+ec6<)?5z;CA zf5ecjPGR=*XQ2l2EDmN(PZELpPu-O6(Mj)%P59!?@%uclNP{F(5C@aN@ML~s PLzltR)z4*}Q$iB}N>QD0 literal 0 HcmV?d00001 diff --git a/com/hbm/handler/ToolAbility.java b/com/hbm/handler/ToolAbility.java index 113f2f33b..749f602d4 100644 --- a/com/hbm/handler/ToolAbility.java +++ b/com/hbm/handler/ToolAbility.java @@ -11,9 +11,12 @@ import com.hbm.inventory.ShredderRecipes; import com.hbm.items.ModItems; import com.hbm.items.tool.ItemToolAbility; import com.hbm.main.MainRegistry; +import com.hbm.util.EnchantmentUtil; import net.minecraft.block.Block; import net.minecraft.client.resources.I18n; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -167,16 +170,18 @@ public abstract class ToolAbility { @Override public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, ItemToolAbility tool) { - //a band-aid on a gaping wound - if(block == Blocks.lit_redstone_ore) - block = Blocks.redstone_ore; + //if the tool is already enchanted, do nothing + if(EnchantmentHelper.getSilkTouchModifier(player) || player.getHeldItem() == null) + return; - ItemStack stack = new ItemStack(block, 1, meta); + //add enchantment + ItemStack stack = player.getHeldItem(); - if(stack.getItem() != null) { - world.setBlockToAir(x, y, z); - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack)); - } + EnchantmentUtil.addEnchantment(stack, Enchantment.silkTouch, 1); + block.harvestBlock(world, player, x, y, z, meta); + EnchantmentUtil.removeEnchantment(stack, Enchantment.silkTouch); + + world.setBlockToAir(x, y, z); } @Override @@ -190,6 +195,42 @@ public abstract class ToolAbility { } } + public static class LuckAbility extends ToolAbility { + + int luck; + + public LuckAbility(int luck) { + this.luck = luck; + } + + @Override + public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, ItemToolAbility tool) { + + //if the tool is already enchanted, do nothing + if(EnchantmentHelper.getFortuneModifier(player) > 0 || player.getHeldItem() == null) + return; + + //add enchantment + ItemStack stack = player.getHeldItem(); + + EnchantmentUtil.addEnchantment(stack, Enchantment.fortune, luck); + block.harvestBlock(world, player, x, y, z, meta); + EnchantmentUtil.removeEnchantment(stack, Enchantment.fortune); + + world.setBlockToAir(x, y, z); + } + + @Override + public String getName() { + return "tool.ability.luck"; + } + + @Override + public String getFullName() { + return I18n.format(getName()) + " (" + luck + ")"; + } + } + public static class SmelterAbility extends ToolAbility { @Override diff --git a/com/hbm/inventory/MachineRecipes.java b/com/hbm/inventory/MachineRecipes.java index fa6ab9009..d05221cbe 100644 --- a/com/hbm/inventory/MachineRecipes.java +++ b/com/hbm/inventory/MachineRecipes.java @@ -141,10 +141,10 @@ public class MachineRecipes { list.add(new GasCentOutput(1, new ItemStack(ModItems.fluorite), 4)); return list; case WATZ: - list.add(new GasCentOutput(1, new ItemStack(ModItems.nugget_schrabidium), 1)); - list.add(new GasCentOutput(3, new ItemStack(ModItems.nugget_uranium), 2)); - list.add(new GasCentOutput(3, new ItemStack(ModItems.powder_iron), 3)); - list.add(new GasCentOutput(3, new ItemStack(ModItems.powder_copper), 4)); + list.add(new GasCentOutput(1, new ItemStack(ModItems.nugget_solinium), 1)); + list.add(new GasCentOutput(1, new ItemStack(ModItems.nugget_uranium), 1)); + list.add(new GasCentOutput(5, new ItemStack(ModItems.powder_lead), 1)); + list.add(new GasCentOutput(10, new ItemStack(ModItems.dust), 1)); return list; case SAS3: list.add(new GasCentOutput(4, new ItemStack(ModItems.nugget_schrabidium), 1)); @@ -200,7 +200,7 @@ public class MachineRecipes { case PUF6: return 100; case WATZ: - return 100; + return 1000; case SAS3: return 100; case COOLANT: @@ -2854,28 +2854,27 @@ public class MachineRecipes { break; case LW_ELEMENT: list.add(new ItemStack(ModItems.ingot_tungsten, 4)); - list.add(new ItemStack(ModItems.plate_advanced_alloy, 6)); - list.add(new ItemStack(ModItems.rod_empty, 4)); + list.add(new ItemStack(ModItems.plate_advanced_alloy, 4)); + list.add(new ItemStack(ModItems.rod_empty, 2)); list.add(new ItemStack(ModItems.wire_magnetized_tungsten, 2)); - list.add(new ItemStack(ModItems.circuit_red_copper, 1)); + list.add(new ItemStack(ModItems.wire_advanced_alloy, 4)); break; case LW_CONTROL: list.add(new ItemStack(ModItems.ingot_tungsten, 4)); list.add(new ItemStack(ModItems.ingot_advanced_alloy, 4)); list.add(new ItemStack(ModItems.ingot_lead, 2)); list.add(new ItemStack(ModItems.wire_magnetized_tungsten, 4)); - list.add(new ItemStack(ModItems.circuit_copper, 2)); + list.add(new ItemStack(ModItems.wire_advanced_alloy, 2)); break; case LW_COOLER: list.add(new ItemStack(ModItems.ingot_tungsten, 2)); list.add(new ItemStack(ModItems.ingot_steel, 2)); - list.add(new ItemStack(ModItems.niter, 6)); - list.add(new ItemStack(ModItems.powder_quartz, 4)); + list.add(new ItemStack(ModItems.niter, 4)); break; case LW_STRUTURE: list.add(new ItemStack(ModItems.ingot_tungsten, 2)); list.add(new ItemStack(ModItems.ingot_lead, 2)); - list.add(new ItemStack(ModItems.ingot_steel, 5)); + list.add(new ItemStack(ModItems.ingot_steel, 3)); break; case LW_HATCH: list.add(new ItemStack(ModBlocks.reinforced_brick, 1)); @@ -2891,7 +2890,7 @@ public class MachineRecipes { break; case LW_CORE: list.add(new ItemStack(ModBlocks.block_meteor, 1)); - list.add(new ItemStack(ModItems.circuit_gold, 8)); + list.add(new ItemStack(ModItems.circuit_gold, 5)); list.add(new ItemStack(ModItems.circuit_schrabidium, 2)); list.add(new ItemStack(ModItems.wire_magnetized_tungsten, 12)); break; diff --git a/com/hbm/items/ModItems.java b/com/hbm/items/ModItems.java index 45b545d4d..144d68334 100644 --- a/com/hbm/items/ModItems.java +++ b/com/hbm/items/ModItems.java @@ -113,6 +113,7 @@ public class ModItems { public static Item ingot_aluminium; public static Item fluorite; public static Item ingot_beryllium; + public static Item ingot_schraranium; public static Item ingot_schrabidium; public static Item ingot_plutonium_fuel; public static Item ingot_uranium_fuel; @@ -1987,6 +1988,7 @@ public class ModItems { plate_iron = new Item().setUnlocalizedName("plate_iron").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":plate_iron"); ingot_lead = new Item().setUnlocalizedName("ingot_lead").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_lead"); plate_lead = new Item().setUnlocalizedName("plate_lead").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":plate_lead"); + ingot_schraranium = new ItemRadioactive(2.5F, false, true).setUnlocalizedName("ingot_schraranium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_schraranium"); ingot_schrabidium = new ItemRadioactive(7.5F, false, true).setUnlocalizedName("ingot_schrabidium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_schrabidium"); plate_schrabidium = new ItemRadioactive(7.5F, false, true).setUnlocalizedName("plate_schrabidium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":plate_schrabidium"); plate_copper = new Item().setUnlocalizedName("plate_copper").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":plate_copper"); @@ -3898,6 +3900,7 @@ public class ModItems { GameRegistry.registerItem(ingot_cobalt, ingot_cobalt.getUnlocalizedName()); GameRegistry.registerItem(ingot_dura_steel, ingot_dura_steel.getUnlocalizedName()); GameRegistry.registerItem(ingot_polymer, ingot_polymer.getUnlocalizedName()); + GameRegistry.registerItem(ingot_schraranium, ingot_schraranium.getUnlocalizedName()); GameRegistry.registerItem(ingot_schrabidium, ingot_schrabidium.getUnlocalizedName()); GameRegistry.registerItem(ingot_magnetized_tungsten, ingot_magnetized_tungsten.getUnlocalizedName()); GameRegistry.registerItem(ingot_combine_steel, ingot_combine_steel.getUnlocalizedName()); diff --git a/com/hbm/items/tool/ItemToolAbility.java b/com/hbm/items/tool/ItemToolAbility.java index 11a9eed3e..9aa3b33a9 100644 --- a/com/hbm/items/tool/ItemToolAbility.java +++ b/com/hbm/items/tool/ItemToolAbility.java @@ -9,6 +9,7 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import com.hbm.handler.ToolAbility; +import com.hbm.handler.ToolAbility.SilkAbility; import com.hbm.handler.WeaponAbility; import cpw.mods.fml.relauncher.Side; @@ -158,6 +159,9 @@ public class ItemToolAbility extends ItemTool { if(!canOperate(stack)) return false; + if(this.getCurrentAbility(stack) instanceof SilkAbility) + return true; + return getDigSpeed(stack, block, 0) > 1; } diff --git a/com/hbm/main/CraftingManager.java b/com/hbm/main/CraftingManager.java index f832777e8..cd6e3ee09 100644 --- a/com/hbm/main/CraftingManager.java +++ b/com/hbm/main/CraftingManager.java @@ -458,7 +458,7 @@ public class CraftingManager { GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.deco_titanium), new Object[] { "ingotTitanium", ModBlocks.steel_scaffold })); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.deco_tungsten), new Object[] { "ingotTungsten", ModBlocks.steel_scaffold })); - GameRegistry.addRecipe(new ItemStack(ModItems.nugget_euphemium, 1), new Object[] { "###", "###", "###", '#', ModItems.rod_quad_euphemium }); + GameRegistry.addRecipe(new ItemStack(ModItems.nugget_euphemium, 1), new Object[] { "##", "##", '#', ModItems.rod_quad_euphemium }); GameRegistry.addRecipe(new ItemStack(ModItems.ingot_euphemium, 1), new Object[] { "###", "###", "###", '#', ModItems.nugget_euphemium }); GameRegistry.addRecipe(new ItemStack(ModItems.nugget_euphemium, 9), new Object[] { "#", '#', ModItems.ingot_euphemium }); diff --git a/com/hbm/util/EnchantmentUtil.java b/com/hbm/util/EnchantmentUtil.java new file mode 100644 index 000000000..8a7131475 --- /dev/null +++ b/com/hbm/util/EnchantmentUtil.java @@ -0,0 +1,26 @@ +package com.hbm.util; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.ItemStack; + +public class EnchantmentUtil { + + public static void addEnchantment(ItemStack stack, Enchantment enchantment, int level) { + + stack.addEnchantment(enchantment, level); + } + + public static void removeEnchantment(ItemStack stack, Enchantment enchantment) { + + int i = 0; + for( ; i < stack.getEnchantmentTagList().tagCount(); i++) { + if(stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == enchantment.effectId) + break; + } + + stack.getEnchantmentTagList().removeTag(i); + + if(stack.getEnchantmentTagList().tagCount() == 0) + stack.getTagCompound().removeTag("ench"); + } +}