Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Add a repair-limit option that allows to restrict the amount how ofte…
Browse files Browse the repository at this point in the history
…n a tool can be repaired for jaded and other evil people.
  • Loading branch information
bonii-xx committed Aug 8, 2014
1 parent ddcfecb commit ae9de9b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -167,8 +169,12 @@ public void sync()
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");
Expand Down
Expand Up @@ -2,13 +2,13 @@

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;
Expand All @@ -23,11 +23,10 @@
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;
Expand All @@ -50,9 +49,6 @@ public void postInit(FMLPostInitializationEvent event)
// flint recipes n stuff
flintTweaks();

if(Config.easyToolRepair)
GameRegistry.addRecipe(new RepairCraftingRecipe());

if(Config.castsBurnMaterial)
castCreatingConsumesPart();

Expand Down Expand Up @@ -92,6 +88,13 @@ public void postInit(FMLPostInitializationEvent event)

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()
Expand Down Expand Up @@ -165,4 +168,19 @@ private void exchangeFluxModifier()
}
}
}

private void limitToolRepair()
{

List<ItemModifier> mods = ModifyBuilder.instance.itemModifiers;
for(ListIterator<ItemModifier> 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");
}
}
}
}
@@ -1,4 +1,4 @@
package iguanaman.iguanatweakstconstruct.tweaks;
package iguanaman.iguanatweakstconstruct.tweaks.modifiers;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down
@@ -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);
}


}

0 comments on commit ae9de9b

Please sign in to comment.