diff --git a/src/main/java/com/fouristhenumber/utilitiesinexcess/compat/tinkers/TinkersCompat.java b/src/main/java/com/fouristhenumber/utilitiesinexcess/compat/tinkers/TinkersCompat.java index b1be26f3b..24f4810fc 100644 --- a/src/main/java/com/fouristhenumber/utilitiesinexcess/compat/tinkers/TinkersCompat.java +++ b/src/main/java/com/fouristhenumber/utilitiesinexcess/compat/tinkers/TinkersCompat.java @@ -1,13 +1,24 @@ package com.fouristhenumber.utilitiesinexcess.compat.tinkers; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; +import org.jetbrains.annotations.NotNull; + import com.fouristhenumber.utilitiesinexcess.config.OtherConfig; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import tconstruct.library.TConstructRegistry; import tconstruct.library.event.ToolCraftEvent; +import tconstruct.library.tools.ToolCore; +import tconstruct.weaponry.ammo.ArrowAmmo; +import tconstruct.weaponry.ammo.BoltAmmo; +import tconstruct.weaponry.weapons.Crossbow; +import tconstruct.weaponry.weapons.LongBow; +import tconstruct.weaponry.weapons.ShortBow; public class TinkersCompat { @@ -21,13 +32,13 @@ public static void init() { @SuppressWarnings("unused") public static class Events { - private static final String[] components = new String[] { "Head", "Handle", "Accessory", "Extra" }; - @SubscribeEvent public void craftTool(ToolCraftEvent.NormalTool event) { NBTTagCompound toolTag = event.toolTag.getCompoundTag("InfiTool"); - for (String component : components) { + List componentNames = getComponentNames(event.tool); + + for (String component : componentNames) { if (toolTag.getInteger(component) == OtherConfig.bedrockiumTinkersID) { toolTag.setBoolean("Heavy", true); break; @@ -35,7 +46,7 @@ public void craftTool(ToolCraftEvent.NormalTool event) { } boolean allInverted = true; - for (String component : components) { + for (String component : componentNames) { if (toolTag.hasKey(component) && toolTag.getInteger(component) != OtherConfig.invertedTinkersID) { allInverted = false; break; @@ -44,16 +55,43 @@ public void craftTool(ToolCraftEvent.NormalTool event) { if (allInverted) toolTag.setInteger("Unbreaking", 10); boolean allMagicWood = true; - for (String component : components) { - if (toolTag.hasKey(component) && toolTag.getInteger(component) != OtherConfig.magicalWoodTinkersID) { - allMagicWood = false; - break; + int bonusMods = 0; + for (String component : componentNames) { + if (toolTag.hasKey(component)) { + if (toolTag.getInteger(component) != OtherConfig.magicalWoodTinkersID) { + allMagicWood = false; + } else bonusMods++; } } if (allMagicWood) { toolTag.setInteger("Modifiers", toolTag.getInteger("Modifiers") + 8); toolTag.setBoolean("MagicallyModifiable", true); + } else { + toolTag.setInteger("Modifiers", toolTag.getInteger("Modifiers") + bonusMods); + } + } + } + + // This hardcoded nonsense accounts for the way tools work in ticon. We need to not check the Accessory + // or Handle for arrows, because those can never be made from our materials. We need to not check Accessory + // for Crossbows (that's the bowstring) for the same reason, and Handle for Long and Short Bows (their + // bowstrings). Lastly, we have to not check the Head or Accessory for Crossbow Bolts. Tinker's API doesn't expose + // the information needed to do this more cleanly. + private static @NotNull List getComponentNames(ToolCore tool) { + List componentNames = new ArrayList<>(); + + componentNames.add("Extra"); + if (!(tool instanceof BoltAmmo)) { + componentNames.add("Head"); + } + if (!(tool instanceof ArrowAmmo)) { + if (!(tool instanceof Crossbow) && !(tool instanceof BoltAmmo)) { + componentNames.add("Accessory"); + } + if (!(tool instanceof LongBow) && !(tool instanceof ShortBow)) { + componentNames.add("Handle"); } } + return componentNames; } } diff --git a/src/main/resources/assets/utilitiesinexcess/lang/en_US.lang b/src/main/resources/assets/utilitiesinexcess/lang/en_US.lang index 10917e9d2..23defd5ef 100644 --- a/src/main/resources/assets/utilitiesinexcess/lang/en_US.lang +++ b/src/main/resources/assets/utilitiesinexcess/lang/en_US.lang @@ -118,7 +118,7 @@ uie.nei.infopage.chandelier.1=A torch that prevents natural mob spawning in rang uie.nei.infopage.giga_torch.1=A torch that prevents natural mob spawning in range. Spawners are not affected. uie.nei.infopage.trading_post.1=This block allows you to trade with every villager in 32 block area all in one place! Simply click on a trade from the list to trade. uie.nei.infopage.ticon_inverted=If a Tinker's Construct tool is made using entirely inverted parts, it becomes unbreakable. -uie.nei.infopage.ticon_magic_wood=If a Tinker's Construct tool is made using entirely magical wooden parts, it gains 8 additional modifiers. +uie.nei.infopage.ticon_magic_wood=Tinker's Construct tools made using magical wooden parts gain an extra modifier per part. If the entire tool is made using magical wooden parts, it gains a flat 8 modifiers instead! uie.nei.infopage.ticon_bedrockium=Tinker's Construct tools made with a bedrockium part are heavy and slow the wielder down while held. uie.nei.infopage.true_greenscreen.0=When you take a screenshot of this block (with [§bF2§0]), it will appear completely transparent in the image, allowing you to take pictures of things without needing to remove the background later. uie.nei.infopage.true_greenscreen.1=You may need to disable your HUD (with [§bF1§0] by default) before taking a screenshot.\nThis block is a tile entity with intrusive rendering, please remove it when you're done using it.