diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java index 86b7f05..8f1664a 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java @@ -63,6 +63,8 @@ public class Config { public static boolean moreExpensiveSilkyCloth; public static boolean moreExpensiveSilkyJewel; public static boolean moreModifiersForFlux; + public static int maxToolRepairs; + //public static float repairAmountMultiplier; // debug public static boolean showDebugXP; @@ -167,8 +169,12 @@ public class Config { moreExpensiveSilkyJewel = configfile.getBoolean("moreExpensiveSilkyJewel", CATEGORY_Tweaks, false, "Silky Jewel needs an emerald block, instead of one emerald"); moreModifiersForFlux = configfile.getBoolean("moreModifiersForFlux", CATEGORY_Tweaks, true, "Flux modifier requires 2 Modifiers. Because that stuff is broken."); + // repair + maxToolRepairs = configfile.getInt("repairsLimit", CATEGORY_Tweaks, -1, -1, 999, "Limits the amount how often a tool can be repaired. -1 means unlimited repairs, like normally."); + //repairAmountMultiplier = configfile.getFloat("repairAmountMultiplier", CATEGORY_Tweaks, 1.0f, 0.01f, 9.99f, "A factor that is multiplied onto the amount a tool is repaired. (0.5 = half durability restored per repair, 2.0 = twice as much durability restored per repair)"); - /** Debug **/ + + /** Debug **/ configfile.setCategoryComment(CATEGORY_Debug, "Stuff to give you/me more information"); showDebugXP = configfile.getBoolean("showDebugXP", CATEGORY_Debug, false, "Current Tool/Pick XP is shown as debug (F3) text"); diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java index 8d4e335..202f57a 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java @@ -2,13 +2,13 @@ package iguanaman.iguanatweakstconstruct.tweaks; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; -import iguanaman.iguanatweakstconstruct.leveling.modifiers.ModXpAwareRedstone; import iguanaman.iguanatweakstconstruct.reference.Config; import iguanaman.iguanatweakstconstruct.reference.Reference; import iguanaman.iguanatweakstconstruct.tweaks.handlers.FlintHandler; -import iguanaman.iguanatweakstconstruct.restriction.PartRestrictionHandler; import iguanaman.iguanatweakstconstruct.tweaks.handlers.StoneToolHandler; import iguanaman.iguanatweakstconstruct.tweaks.handlers.VanillaToolNerfHandler; +import iguanaman.iguanatweakstconstruct.tweaks.modifiers.ModFluxExpensive; +import iguanaman.iguanatweakstconstruct.tweaks.modifiers.ModLimitedToolRepair; import iguanaman.iguanatweakstconstruct.util.Log; import iguanaman.iguanatweakstconstruct.util.RecipeRemover; import mantle.pulsar.pulse.Handler; @@ -23,11 +23,10 @@ import tconstruct.library.TConstructRegistry; import tconstruct.library.crafting.CastingRecipe; import tconstruct.library.crafting.ModifyBuilder; import tconstruct.library.crafting.PatternBuilder; -import tconstruct.library.crafting.ToolBuilder; import tconstruct.library.modifier.ItemModifier; import tconstruct.library.util.IPattern; import tconstruct.modifiers.tools.ModFlux; -import tconstruct.modifiers.tools.ModRedstone; +import tconstruct.modifiers.tools.ModToolRepair; import tconstruct.smeltery.TinkerSmeltery; import tconstruct.tools.TinkerTools; import tconstruct.world.TinkerWorld; @@ -50,9 +49,6 @@ public class IguanaTweaks { // flint recipes n stuff flintTweaks(); - if(Config.easyToolRepair) - GameRegistry.addRecipe(new RepairCraftingRecipe()); - if(Config.castsBurnMaterial) castCreatingConsumesPart(); @@ -92,6 +88,13 @@ public class IguanaTweaks { if(Config.moreModifiersForFlux) exchangeFluxModifier(); + + if(Config.maxToolRepairs > -1) + limitToolRepair(); + + // has to be added after exchanging the repair modifier, to obtain the correct cache + if(Config.easyToolRepair) + GameRegistry.addRecipe(new RepairCraftingRecipe()); } private void flintTweaks() @@ -165,4 +168,19 @@ public class IguanaTweaks { } } } + + private void limitToolRepair() + { + + List mods = ModifyBuilder.instance.itemModifiers; + for(ListIterator iter = mods.listIterator(); iter.hasNext();) + { + ItemModifier mod = iter.next(); + // flux mod + if(mod instanceof ModToolRepair) { + iter.set(new ModLimitedToolRepair()); + Log.trace("Replaced Tool Repair Modifier to limit the maximum amount of repairs"); + } + } + } } diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModFluxExpensive.java similarity index 94% rename from src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java rename to src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModFluxExpensive.java index f302a7c..b2f9073 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModFluxExpensive.java @@ -1,4 +1,4 @@ -package iguanaman.iguanatweakstconstruct.tweaks; +package iguanaman.iguanatweakstconstruct.tweaks.modifiers; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModLimitedToolRepair.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModLimitedToolRepair.java new file mode 100644 index 0000000..547fac7 --- /dev/null +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/modifiers/ModLimitedToolRepair.java @@ -0,0 +1,20 @@ +package iguanaman.iguanatweakstconstruct.tweaks.modifiers; + +import iguanaman.iguanatweakstconstruct.reference.Config; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import tconstruct.modifiers.tools.ModToolRepair; + +public class ModLimitedToolRepair extends ModToolRepair { + @Override + protected boolean canModify(ItemStack tool, ItemStack[] input) { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + int repairCount = tags.getInteger("RepairCount"); + if(repairCount >= Config.maxToolRepairs) + return false; + + return super.canModify(tool, input); + } + + +}