diff --git a/src/iguanaman/iguanatweakstconstruct/IguanaConfig.java b/src/iguanaman/iguanatweakstconstruct/IguanaConfig.java index c0f2b9c..936e19a 100644 --- a/src/iguanaman/iguanatweakstconstruct/IguanaConfig.java +++ b/src/iguanaman/iguanatweakstconstruct/IguanaConfig.java @@ -485,7 +485,7 @@ public class IguanaConfig { partTooltips = partTooltipsProperty.getBoolean(true); Property partReplacementProperty = config.get("other", "partReplacement", true); - partReplacementProperty.comment = "Can you replace parts of existing tools? (If true, paper/thaumium doesn't give extra modifiers)"; + partReplacementProperty.comment = "Can you replace parts of existing tools?"; partReplacement = partReplacementProperty.getBoolean(true); Property removeFlintDropProperty = config.get("other", "removeFlintDrop", true); diff --git a/src/iguanaman/iguanatweakstconstruct/items/IguanaToolPart.java b/src/iguanaman/iguanatweakstconstruct/items/IguanaToolPart.java index 44719c9..5b5ee16 100644 --- a/src/iguanaman/iguanatweakstconstruct/items/IguanaToolPart.java +++ b/src/iguanaman/iguanatweakstconstruct/items/IguanaToolPart.java @@ -26,11 +26,16 @@ public class IguanaToolPart extends ToolPart { ToolMaterial material = TConstructRegistry.getMaterial(par1ItemStack.getItemDamage()); if (!IguanaConfig.allowStoneTools && material.materialName.equals("Stone")) { - par3List.add("Can only be used to make casts,"); - par3List.add("you cannot make a tool with this"); + par3List.add("\u00a74Can only be used to make casts,"); + par3List.add("\u00a74cannot be used to make a tool"); } else { + if (IguanaConfig.partReplacement && (material.ability.equals("Writable") || material.ability.equals("Thaumic"))) + { + par3List.add("\u00a74Cannot be replaced once added to a tool"); + } + if (!material.ability.equals("")) { par3List.add("Ability: " + material.ability); diff --git a/src/iguanaman/iguanatweakstconstruct/modifiers/IguanaModUpgrade.java b/src/iguanaman/iguanatweakstconstruct/modifiers/IguanaModUpgrade.java index 79f3162..083a9c4 100644 --- a/src/iguanaman/iguanatweakstconstruct/modifiers/IguanaModUpgrade.java +++ b/src/iguanaman/iguanatweakstconstruct/modifiers/IguanaModUpgrade.java @@ -76,14 +76,50 @@ public class IguanaModUpgrade extends ToolMod { @Override protected boolean canModify (ItemStack tool, ItemStack[] input) { + // basic checks + if (tool == null || tool.getItem() == null || !(tool.getItem() instanceof ToolCore)) return false; NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); - if (tags.getInteger("Damage") > 0) - return false; + if (tags.getInteger("Damage") > 0) return false; - if (tool.getItem() instanceof ToolCore) - return true; + + // check which parts are changable + String headAbility = TConstructRegistry.getMaterial(tags.getInteger("Head")).ability; + boolean headChangable = headAbility.equals("Writable") || headAbility.equals("Thaumic") ? false : true; + String handleAbility = TConstructRegistry.getMaterial(tags.getInteger("Handle")).ability; + boolean handleChangable = handleAbility.equals("Writable") || headAbility.equals("Thaumic") ? false : true; - return false; + boolean accessoryChangable = true; + if (tags.hasKey("Accessory")) + { + String accessoryAbility = TConstructRegistry.getMaterial(tags.getInteger("Accessory")).ability; + if (accessoryAbility.equals("Writable") || accessoryAbility.equals("Thaumic")) accessoryChangable = false; + } + + boolean extraChangable = true; + if (tags.hasKey("Extra")) + { + String extraAbility = TConstructRegistry.getMaterial(tags.getInteger("Extra")).ability; + if (extraAbility.equals("Writable") || extraAbility.equals("Thaumic")) extraChangable = false; + } + + ToolRecipe toolRecipe = GetRecipe((ToolCore)tool.getItem()); + if (toolRecipe == null) return false; + + // check if trying to replace irreplacable parts + for (ItemStack inputStack : input) + { + if (inputStack != null) + { + if ( + (toolRecipe.validHead(inputStack.getItem()) && headChangable == false) + || (toolRecipe.validHandle(inputStack.getItem()) && handleChangable == false) + || (toolRecipe.validAccessory(inputStack.getItem()) && accessoryChangable == false) + || (toolRecipe.validExtra(inputStack.getItem()) && extraChangable == false) + ) return false; + } + } + + return true; } @Override diff --git a/src/iguanaman/iguanatweakstconstruct/util/IguanaEventHandler.java b/src/iguanaman/iguanatweakstconstruct/util/IguanaEventHandler.java index b3c6712..e1df2c4 100644 --- a/src/iguanaman/iguanatweakstconstruct/util/IguanaEventHandler.java +++ b/src/iguanaman/iguanatweakstconstruct/util/IguanaEventHandler.java @@ -420,14 +420,7 @@ public class IguanaEventHandler { } } - if (IguanaConfig.partReplacement) - { - if (IguanaConfig.toolLeveling && IguanaConfig.toolLevelingExtraModifiers) - toolTag.setInteger("Modifiers", 0); - else - toolTag.setInteger("Modifiers", 3); - } - else if (IguanaConfig.toolLeveling && IguanaConfig.toolLevelingExtraModifiers) + if (IguanaConfig.toolLeveling && IguanaConfig.toolLevelingExtraModifiers) toolTag.setInteger("Modifiers", Math.max(toolTag.getInteger("Modifiers") - 3, 0)); }