This closes #17 and closes #58, I tested and it worked using the script given

Also changes like all packages
inb4 "jared changes a package name in ModTweaker2 breaking compatability
with everything" drama tweet.
This commit is contained in:
jaredlll08 committed 2015-02-20 23:57:32 +02:00
1 parent 4fd2551072
commit ec562b62ea
187 files changed
+977 -991

No files matched your search

@@ -0,0 +1,131 @@
package modtweaker2.mods.tconstruct.handlers;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseListRemoval;
import modtweaker2.util.BaseSetVar;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.crafting.PatternBuilder.ItemKey;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
@ZenClass("mods.tconstruct.Tweaks")
public class TiCTweaks {
// Set the maximum RF
@ZenMethod
public static void setRFCapacity(String tool, int capacity) {
MineTweakerAPI.apply(new AdjustRF(tool, capacity));
}
private static class AdjustRF extends BaseSetVar {
public AdjustRF(String tool, int newValue) {
super("RF Maximum for Tinkers Tools", ToolCore.class, ReflectionHelper.getStaticObject(TinkerTools.class, tool), "capacity", 400000, newValue);
}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** Disabling for 0.5, will do this properly for 0.6 **/
// Tweaks for enabling / disabling Patterns
/*
* @ZenMethod public static void removePattern(IItemStack stack) {
* MineTweakerAPI.apply(new DisablePattern(toStack(stack))); }
*
* private static class DisablePattern implements IUndoableAction { private
* String key; private MaterialSet set; private List list; private ItemStack
* stack; private final ItemStack disable;
*
* public DisablePattern(ItemStack disable) { this.disable = disable; }
*
* //Loops through the pattern mappings to find an entry with the same
* material name
*
* @Override public void apply() { for (Entry<List, ItemStack> entry :
* TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check =
* entry.getValue(); if (check.isItemEqual(disable)) { list =
* entry.getKey(); stack = entry.getValue(); break; } }
*
* TConstructRegistry.patternPartMapping.remove(list); }
*
* @Override public boolean canUndo() { return true; }
*
* @Override public void undo() {
* TConstructRegistry.patternPartMapping.put(list, stack); }
*
* @Override public String describe() { return
* "Disabling creation of the pattern for: " + disable.getDisplayName(); }
*
* @Override public String describeUndo() { return
* "Enabling creation of the pattern for: " + disable.getDisplayName(); }
*
* @Override public Object getOverrideKey() { return null; } }
*/
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRepairMaterial(IItemStack stack, String material, int value) {
ItemStack input = toStack(stack);
MineTweakerAPI.apply(new Add(TConstructHelper.getItemKey(input.getItem(), input.getItemDamage(), value, material)));
}
// Tweaks for setting repair materials
private static class Add extends BaseListAddition {
public Add(ItemKey recipe) {
super("Repair Material", PatternBuilder.instance.materials, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((ItemKey) recipe).item, 1, ((ItemKey) recipe).damage).getDisplayName();
}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRepairMaterial(IItemStack output, @Optional String material) {
MineTweakerAPI.apply(new Remove(toStack(output), material));
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove extends BaseListRemoval {
private final String material;
public Remove(ItemStack stack, String material) {
super("Repair Material", PatternBuilder.instance.materials, stack);
this.material = material;
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
for (ItemKey r : PatternBuilder.instance.materials) {
ItemStack clone = new ItemStack(r.item, 1, r.damage);
if ((material != null && material.equalsIgnoreCase(r.key)) || (material == null)) {
if (clone.isItemEqual(stack)) {
recipe = r;
break;
}
}
}
PatternBuilder.instance.materials.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}