Make Flux Modifier use 2 modifiers

This commit is contained in:
Bernhard Bonigl committed 2014-08-07 12:54:39 +02:00
1 parent 9f4681b52a
commit 7b0b2be763
4 files changed
+62 -3

No files matched your search

@@ -43,8 +43,6 @@ public class IguanaHarvestLevelTweaks {
@Handler
public void preInit(FMLPreInitializationEvent event)
{
// remove tinkers messages
TinkerTools.supressMissingToolLogs = true;
TinkerMaterialTweaks.modifyToolMaterials();
}
@@ -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 **/
@@ -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<ItemModifier> mods = ModifyBuilder.instance.itemModifiers;
for(ListIterator<ItemModifier> 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");
}
}
}
}
@@ -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<ItemStack> 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);
}
}