From 7b0b2be76367b1a4662a8be021a9f7cd3a56f009 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 7 Aug 2014 12:54:39 +0200 Subject: [PATCH] Make Flux Modifier use 2 modifiers --- .../IguanaHarvestLevelTweaks.java | 2 -- .../reference/Config.java | 4 ++- .../tweaks/IguanaTweaks.java | 27 ++++++++++++++++ .../tweaks/ModFluxExpensive.java | 32 +++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/IguanaHarvestLevelTweaks.java b/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/IguanaHarvestLevelTweaks.java index c015357..7e45b53 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/IguanaHarvestLevelTweaks.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/IguanaHarvestLevelTweaks.java @@ -43,8 +43,6 @@ public class IguanaHarvestLevelTweaks { @Handler public void preInit(FMLPreInitializationEvent event) { - // remove tinkers messages - TinkerTools.supressMissingToolLogs = true; TinkerMaterialTweaks.modifyToolMaterials(); } diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java index 4f76026..86b7f05 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java @@ -62,6 +62,7 @@ public class Config { public static boolean removeStoneTorchRecipe; public static boolean moreExpensiveSilkyCloth; public static boolean moreExpensiveSilkyJewel; + public static boolean moreModifiersForFlux; // debug public static boolean showDebugXP; @@ -161,9 +162,10 @@ public class Config { allowPartReuse = configfile.getBoolean("allowPartReuse", CATEGORY_Tweaks, true, "Allows toolparts to be used as material in the Part Builder. Like, turn a Pick head into a Shovel head.!"); // stuff - removeStoneTorchRecipe = configfile.getBoolean("removeStoneTorchRecipe", CATEGORY_Tweaks, false, "Removes the recipe for Tinker's Construct's stone torch"); + removeStoneTorchRecipe = configfile.getBoolean("removeStoneTorchRecipe", CATEGORY_Tweaks, false, "Removes the recipe for Tinker's Construct's stone torch"); moreExpensiveSilkyCloth = configfile.getBoolean("moreExpensiveSilkyCloth", CATEGORY_Tweaks, true, "Silky Cloth needs gold ingots, instead of nuggets"); 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."); /** Debug **/ diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java index 55a56e5..851ef48 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java @@ -2,6 +2,7 @@ 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; @@ -20,15 +21,20 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.ShapedOreRecipe; 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.smeltery.TinkerSmeltery; import tconstruct.tools.TinkerTools; import tconstruct.world.TinkerWorld; import java.lang.reflect.Field; import java.util.List; +import java.util.ListIterator; import java.util.Map; /** @@ -41,6 +47,9 @@ public class IguanaTweaks { @Handler public void postInit(FMLPostInitializationEvent event) { + // remove tinkers messages + TinkerTools.supressMissingToolLogs = true; + // flint recipes n stuff flintTweaks(); @@ -83,6 +92,9 @@ public class IguanaTweaks { RecipeRemover.removeAnyRecipe(new ItemStack(TinkerTools.materials, 1, 26)); GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 26), " c ", "cec", " c ", 'c', new ItemStack(TinkerTools.materials, 1, 25), 'e', new ItemStack(Item.getItemFromBlock(Blocks.emerald_block))); } + + if(Config.moreModifiersForFlux) + exchangeFluxModifier(); } private void flintTweaks() @@ -141,4 +153,19 @@ public class IguanaTweaks { PatternBuilder.instance.registerMaterial(toolPart, cost, TConstructRegistry.getMaterial(matID).materialName); } } + + private void exchangeFluxModifier() + { + + List mods = ModifyBuilder.instance.itemModifiers; + for(ListIterator iter = mods.listIterator(); iter.hasNext();) + { + ItemModifier mod = iter.next(); + // flux mod + if(mod instanceof ModFlux) { + iter.set(new ModFluxExpensive(((ModFlux) mod).batteries)); + Log.trace("Replaced Flux Modifier to make it more expensive"); + } + } + } } diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java new file mode 100644 index 0000000..f302a7c --- /dev/null +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/ModFluxExpensive.java @@ -0,0 +1,32 @@ +package iguanaman.iguanatweakstconstruct.tweaks; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import tconstruct.modifiers.tools.ModFlux; + +import java.util.ArrayList; + +public class ModFluxExpensive extends ModFlux { + + public ModFluxExpensive(ArrayList batteries) { + this.batteries = batteries; + } + + // needs 2 modifiers + @Override + protected boolean canModify(ItemStack tool, ItemStack[] input) { + NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); + return tags.getInteger("Modifiers") > 1 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist + } + + @Override + public void modify(ItemStack[] input, ItemStack tool) { + super.modify(input, tool); + + // substract additional modifier + NBTTagCompound tags = tool.getTagCompound(); + int modifiers = tags.getCompoundTag("InfiTool").getInteger("Modifiers"); + modifiers -= 1; + tags.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers); + } +}