Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Turkey 2015-04-26 21:49:53 -04:00
commit 45da0643bd
29 changed files with 1405 additions and 1237 deletions

View file

@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "0.7.5"
version = "0.8.2"
group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ModTweaker 2"

0
gradlew vendored Normal file → Executable file
View file

View file

@ -21,42 +21,45 @@ import modtweaker2.utils.TweakerPlugin;
public class Commands {
public static void registerCommands() {
MineTweakerAPI.server.addMineTweakerCommand("tooltips", new String[] { "/minetweaker tooltips", " Adds tooltips to all items ingame with their mt script name, press ctrl on an item to print to the log" }, new ICommandFunction() {
@Override
public void execute(String[] arguments, IPlayer player) {
ClientEvents.active = !ClientEvents.active;
if (MineTweakerAPI.server != null) {
MineTweakerAPI.server.addMineTweakerCommand("tooltips", new String[] { "/minetweaker tooltips", " Adds tooltips to all items ingame with their mt script name, press ctrl on an item to print to the log" }, new ICommandFunction() {
@Override
public void execute(String[] arguments, IPlayer player) {
ClientEvents.active = !ClientEvents.active;
}
});
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
if (TweakerPlugin.isLoaded("Mekanism")) {
MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger());
}
});
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
if (TweakerPlugin.isLoaded("Thaumcraft")) {
MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger());
MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger());
}
if (TweakerPlugin.isLoaded("Mekanism")) {
MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger());
}
if (TweakerPlugin.isLoaded("TConstruct")) {
MineTweakerAPI.server.addMineTweakerCommand("materials", new String[] { "/minetweaker materials", " Outputs a list of all Tinker's Construct material names in the game to the minetweaker log" }, new MaterialLogger());
}
if (TweakerPlugin.isLoaded("Thaumcraft")) {
MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger());
MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger());
}
if (TweakerPlugin.isLoaded("Botania")) {
MineTweakerAPI.server.addMineTweakerCommand("lexiconCategories", new String[] { "/minetweaker lexiconCategories", " Outputs a list of lexicon categories" }, new LexiconCategoryLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger());
}
if (TweakerPlugin.isLoaded("TConstruct")) {
MineTweakerAPI.server.addMineTweakerCommand("materials", new String[] { "/minetweaker materials", " Outputs a list of all Tinker's Construct material names in the game to the minetweaker log" }, new MaterialLogger());
}
if (TweakerPlugin.isLoaded("Botania")) {
MineTweakerAPI.server.addMineTweakerCommand("lexiconCategories", new String[] { "/minetweaker lexiconCategories", " Outputs a list of lexicon categories" }, new LexiconCategoryLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger());
}
if (TweakerPlugin.isLoaded("chisel")) {
MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger());
MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger());
}
if (TweakerPlugin.isLoaded("aura")) {
MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger());
if (TweakerPlugin.isLoaded("chisel")) {
MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger());
MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger());
}
if (TweakerPlugin.isLoaded("aura")) {
MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger());
}
}
}

View file

@ -4,6 +4,6 @@ public class ModProps {
public static final String NAME = "Mod Tweaker 2", name = NAME;
public static final String MODID = "modtweaker2", modid = MODID;
public static final String VERSION = "0.7", version = VERSION;
public static final String VERSION = "0.8.2", version = VERSION;
public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES;
}

View file

@ -1,5 +1,12 @@
package modtweaker2;
import java.util.Iterator;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
import minetweaker.runtime.IScriptIterator;
import minetweaker.runtime.IScriptProvider;
import minetweaker.util.IEventHandler;
import modtweaker2.mods.appeng.AppliedEnergistics;
import modtweaker2.mods.auracascade.AuraCascade;
import modtweaker2.mods.botania.Botania;
@ -9,7 +16,6 @@ import modtweaker2.mods.extendedworkbench.ExtendedWorkbench;
import modtweaker2.mods.factorization.Factorization;
import modtweaker2.mods.forestry.Forestry;
import modtweaker2.mods.fsp.Steamcraft;
import modtweaker2.mods.hee.HardcoreEnderExpansion;
import modtweaker2.mods.mariculture.Mariculture;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.mods.metallurgy.Metallurgy;
@ -19,6 +25,7 @@ import modtweaker2.mods.tconstruct.TConstruct;
import modtweaker2.mods.tfcraft.TerraFirmaCraft;
import modtweaker2.mods.thaumcraft.Thaumcraft;
import modtweaker2.mods.thermalexpansion.ThermalExpansion;
import modtweaker2.proxy.CommonProxy;
import modtweaker2.utils.TweakerPlugin;
import net.minecraftforge.common.MinecraftForge;
@ -29,10 +36,12 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
@Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies)
@ -47,7 +56,10 @@ public class ModTweaker2 {
public void preInit(FMLPreInitializationEvent event) {
logger.info("Starting PreInitialization for " + ModProps.modid);
}
@SidedProxy(clientSide = "modtweaker2.proxy.ClientProxy", serverSide = "modtweaker2.proxy.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void init(FMLInitializationEvent event) {
logger.info("Starting Initialization for " + ModProps.modid);
@ -56,7 +68,6 @@ public class ModTweaker2 {
TweakerPlugin.register("exnihilo", ExNihilo.class);
TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class);
TweakerPlugin.register("factorization", Factorization.class);
TweakerPlugin.register("HardcoreEnderExpansion", HardcoreEnderExpansion.class);
TweakerPlugin.register("Mariculture", Mariculture.class);
TweakerPlugin.register("Mekanism", Mekanism.class);
TweakerPlugin.register("Metallurgy", Metallurgy.class);
@ -74,14 +85,18 @@ public class ModTweaker2 {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
// MineTweakerImplementationAPI.onReloadEvent(new IEventHandler<MineTweakerImplementationAPI.ReloadEvent>() {
//
// @Override
// public void handle(ReloadEvent event) {
// Commands.registerCommands();
// }
// });
MineTweakerImplementationAPI.onReloadEvent(new IEventHandler<MineTweakerImplementationAPI.ReloadEvent>() {
@Override
public void handle(ReloadEvent event) {
proxy.registerCommands();
}
});
TweakerPlugin.hasInit = true;
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
@ -92,7 +107,7 @@ public class ModTweaker2 {
@EventHandler
public void serverStart(FMLServerStartingEvent event) {
logger.info("Starting ServerStart for " + ModProps.modid);
Commands.registerCommands();
proxy.registerCommands();
}
}

View file

@ -17,20 +17,18 @@ import exnihilo.registries.helpers.SiftingResult;
@ZenClass("mods.exnihilo.Sieve")
public class Sieve {
//Adding a Ex Nihilo Sieve recipe
// Adding a Ex Nihilo Sieve recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int rarity) {
if (isABlock(input))
{
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), rarity));
}
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction
{
// Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
@ -47,14 +45,16 @@ public class Sieve {
public void apply() {
SieveRegistry.register(source, sourceMeta, output, outputMeta, rarity);
}
public boolean canUndo() {
return false;
return source != null && output != null;
}
public String describe() {
return "Adding ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public String describeUndo() {
@ -66,44 +66,43 @@ public class Sieve {
}
public void undo() {
if (this.canUndo())
SieveRegistry.unregisterReward(this.source, this.sourceMeta, this.output, this.outputMeta);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Sieve recipe
// Removing a Ex Nihilo Sieve recipe
@ZenMethod
public static void removeRecipe(IItemStack input, IItemStack output) {
if (isABlock(input))
{
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Remove(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage()));
}
}
//TODO: Add other 2 remove methods that exNihilo provided
/*@ZenMethod
public static void removeFirst(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST));
}
// TODO: Add other 2 remove methods that exNihilo provided
@ZenMethod
public static void removeLast(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST));
}*/
/*
* @ZenMethod public static void removeFirst(IItemStack output) {
* MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST)); }
*
* @ZenMethod public static void removeLast(IItemStack output) {
* MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST)); }
*/
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove implements IUndoableAction
{
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
int outputMeta;
int rarity;
public Remove(Block source, int sourceMeta, Item output, int outputMeta) {
this.source = source;
this.sourceMeta = sourceMeta;
@ -113,22 +112,22 @@ public class Sieve {
public void apply() {
ArrayList<SiftingResult> results = SieveRegistry.getSiftingOutput(this.source, this.sourceMeta);
for(SiftingResult res: results)
{
if(res.item.equals(this.source) && res.meta == this.outputMeta)
for (SiftingResult res : results) {
if (res.item.equals(this.source) && res.meta == this.outputMeta)
this.rarity = res.rarity;
}
SieveRegistry.unregisterReward(source, sourceMeta, output, outputMeta);
}
public boolean canUndo() {
return true;
return output != null && source != null;
}
public String describe() {
return "Removing ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public String describeUndo() {
@ -140,7 +139,7 @@ public class Sieve {
}
public void undo() {
if(this.canUndo())
if (this.canUndo())
SieveRegistry.register(this.source, this.sourceMeta, this.output, this.outputMeta, rarity);
}
}

View file

@ -1,10 +0,0 @@
package modtweaker2.mods.hee;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.hee.handlers.EssenceAltar;
public class HardcoreEnderExpansion {
public HardcoreEnderExpansion() {
MineTweakerAPI.registerClass(EssenceAltar.class);
}
}

View file

@ -1,76 +0,0 @@
package modtweaker2.mods.hee.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import chylex.hee.mechanics.essence.handler.DragonEssenceHandler;
import chylex.hee.mechanics.essence.handler.dragon.AltarItemRecipe;
@ZenClass("mods.hee.EssenceAltar")
public class EssenceAltar {
@ZenMethod
public static void addRecipe(IItemStack source, IItemStack result, int cost) {
MineTweakerAPI.apply(new Add(toStack(result), new AltarItemRecipe(toStack(source), toStack(result), cost)));
}
private static class Add extends BaseListAddition {
private final ItemStack result;
public Add(ItemStack result, AltarItemRecipe recipe) {
super("Essence Altar", DragonEssenceHandler.recipes, recipe);
this.result = result;
}
@Override
public String getRecipeInfo() {
return result.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Essence Altar", DragonEssenceHandler.recipes, stack);
}
//Returns the output ItemStack
private ItemStack getOutput(Object o) {
return (ItemStack) ReflectionHelper.getObject(o, "result");
}
@Override
public void apply() {
for (AltarItemRecipe r : (List<AltarItemRecipe>) list) {
ItemStack output = getOutput(r);
if (output != null && areEqual(output, stack)) {
recipe = r;
break;
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}

View file

@ -14,23 +14,23 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
if (Mekanism.v7)
{
ChemicalPairInput pair = new ChemicalPairInput(toGas(left), toGas(right));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out)));
}
else
{
ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left),toGas(right), toGas(out));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe));
}
}
@ZenMethod
public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
if (Mekanism.v7) {
ChemicalPairInput pair = new ChemicalPairInput(toGas(left), toGas(right));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out)));
} else {
ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left), toGas(right), toGas(out));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe));
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
if (!Mekanism.v7)
throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output)));
}
}

View file

@ -7,15 +7,17 @@ import modtweaker2.mods.thaumcraft.handlers.Crucible;
import modtweaker2.mods.thaumcraft.handlers.Infusion;
import modtweaker2.mods.thaumcraft.handlers.Research;
import modtweaker2.mods.thaumcraft.handlers.Warp;
import modtweaker2.mods.thaumcraft.handlers.Loot;
public class Thaumcraft {
public Thaumcraft() {
MineTweakerAPI.registerClass(Arcane.class);
MineTweakerAPI.registerClass(Aspects.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Infusion.class);
MineTweakerAPI.registerClass(Research.class);
MineTweakerAPI.registerClass(Warp.class);
public Thaumcraft() {
MineTweakerAPI.registerClass(Arcane.class);
MineTweakerAPI.registerClass(Aspects.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Infusion.class);
MineTweakerAPI.registerClass(Research.class);
MineTweakerAPI.registerClass(Warp.class);
MineTweakerAPI.registerClass(Loot.class);
}
}
}

View file

@ -12,6 +12,7 @@ import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -24,12 +25,14 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe;
public class Arcane {
@ZenMethod
public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
}
@ZenMethod
public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
}
private static class Add extends BaseListAddition {
@ -51,7 +54,8 @@ public class Arcane {
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {

View file

@ -9,6 +9,7 @@ import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.entity.EntityList;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
@ -19,204 +20,212 @@ import thaumcraft.api.aspects.AspectList;
@ZenClass("mods.thaumcraft.Aspects")
public class Aspects {
/** Add/Remove/Set Aspects for items **/
@ZenMethod
public static void add(IItemStack stack, String aspects) {
MineTweakerAPI.apply(new Add(toStack(stack), aspects, false));
}
/** Add/Remove/Set Aspects for items **/
@ZenMethod
public static void add(IItemStack stack, String aspects) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(toStack(stack), aspects, false));
}
@ZenMethod
public static void set(IItemStack stack, String aspects) {
MineTweakerAPI.apply(new Add(toStack(stack), aspects, true));
}
@ZenMethod
public static void set(IItemStack stack, String aspects) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(toStack(stack), aspects, true));
}
//Adds or sets Aspects
private static class Add extends BaseDescriptionAddition {
private final ItemStack stack;
private final String aspects;
private final boolean replace;
private AspectList oldList;
private AspectList newList;
// Adds or sets Aspects
private static class Add extends BaseDescriptionAddition {
private final ItemStack stack;
private final String aspects;
private final boolean replace;
private AspectList oldList;
private AspectList newList;
public Add(ItemStack stack, String aspects, boolean replace) {
super("Aspects");
this.stack = stack;
this.aspects = aspects;
this.replace = replace;
}
public Add(ItemStack stack, String aspects, boolean replace) {
super("Aspects");
this.stack = stack;
this.aspects = aspects;
this.replace = replace;
}
@Override
public void apply() {
oldList = ThaumcraftApiHelper.getObjectAspects(stack);
if (!replace) newList = ThaumcraftHelper.parseAspects(oldList, aspects);
else newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
}
@Override
public void apply() {
oldList = ThaumcraftApiHelper.getObjectAspects(stack);
if (!replace)
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
else
newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
}
@Override
public void undo() {
if (oldList == null) {
ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage()));
} else ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
}
@Override
public void undo() {
if (oldList == null) {
ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage()));
} else
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
//////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IItemStack stack, String aspects) {
MineTweakerAPI.apply(new Remove(toStack(stack), aspects));
}
@ZenMethod
public static void remove(IItemStack stack, String aspects) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(stack), aspects));
}
private static class Remove extends BaseDescriptionRemoval {
private final ItemStack stack;
private final String aspects;
private AspectList oldList;
private AspectList newList;
private static class Remove extends BaseDescriptionRemoval {
private final ItemStack stack;
private final String aspects;
private AspectList oldList;
private AspectList newList;
public Remove(ItemStack stack, String aspects) {
super("Aspects");
this.stack = stack;
this.aspects = aspects;
}
public Remove(ItemStack stack, String aspects) {
super("Aspects");
this.stack = stack;
this.aspects = aspects;
}
@Override
public void apply() {
oldList = ThaumcraftApiHelper.getObjectAspects(stack);
if (oldList != null) {
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
}
}
@Override
public void apply() {
oldList = ThaumcraftApiHelper.getObjectAspects(stack);
if (oldList != null) {
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
}
}
@Override
public boolean canUndo() {
return oldList != null;
}
@Override
public boolean canUndo() {
return oldList != null;
}
@Override
public void undo() {
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
}
@Override
public void undo() {
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
/** Add/Remove/Set Aspects for entities **/
@ZenMethod
public static void addEntity(String entityName, String aspects) {
if(!EntityList.stringToClassMapping.containsKey(entityName))
{
MineTweakerAPI.getLogger().logError("No such entity "+entityName);
return;
}
MineTweakerAPI.apply(new AddEntity(entityName, aspects, false));
}
/** Add/Remove/Set Aspects for entities **/
@ZenMethod
public static void addEntity(String entityName, String aspects) {
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
return;
}
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddEntity(entityName, aspects, false));
}
@ZenMethod
public static void setEntity(String entityName, String aspects) {
if(!EntityList.stringToClassMapping.containsKey(entityName))
{
MineTweakerAPI.getLogger().logError("No such entity "+entityName);
return;
}
MineTweakerAPI.apply(new AddEntity(entityName, aspects, true));
}
@ZenMethod
public static void setEntity(String entityName, String aspects) {
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
return;
}
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddEntity(entityName, aspects, true));
}
//Adds or sets Aspects
private static class AddEntity extends BaseDescriptionAddition {
private final String entityName;
private final String aspects;
private final boolean replace;
private AspectList oldList;
private AspectList newList;
// Adds or sets Aspects
private static class AddEntity extends BaseDescriptionAddition {
private final String entityName;
private final String aspects;
private final boolean replace;
private AspectList oldList;
private AspectList newList;
public AddEntity(String entityName, String aspects, boolean replace) {
super("Aspects");
this.entityName = entityName;
this.aspects = aspects;
this.replace = replace;
}
public AddEntity(String entityName, String aspects, boolean replace) {
super("Aspects");
this.entityName = entityName;
this.aspects = aspects;
this.replace = replace;
}
@Override
public void apply() {
oldList = ThaumcraftHelper.getEntityAspects(entityName);
if (!replace) newList = ThaumcraftHelper.parseAspects(oldList, aspects);
else newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
}
@Override
public void apply() {
oldList = ThaumcraftHelper.getEntityAspects(entityName);
if (!replace)
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
else
newList = ThaumcraftHelper.parseAspects(aspects);
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
}
@Override
public void undo() {
ThaumcraftHelper.removeEntityAspects(entityName);
if (oldList != null)
ThaumcraftApi.registerEntityTag(entityName, oldList);
}
@Override
public void undo() {
ThaumcraftHelper.removeEntityAspects(entityName);
if (oldList != null)
ThaumcraftApi.registerEntityTag(entityName, oldList);
}
@Override
public String getRecipeInfo() {
return entityName;
}
}
@Override
public String getRecipeInfo() {
return entityName;
}
}
//////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeEntity(String entityName, String aspects) {
if(!EntityList.stringToClassMapping.containsKey(entityName))
{
MineTweakerAPI.getLogger().logError("No such entity "+entityName);
return;
}
MineTweakerAPI.apply(new RemoveEntity(entityName, aspects));
}
@ZenMethod
public static void removeEntity(String entityName, String aspects) {
if (!EntityList.stringToClassMapping.containsKey(entityName)) {
MineTweakerAPI.getLogger().logError("No such entity " + entityName);
return;
}
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new RemoveEntity(entityName, aspects));
}
private static class RemoveEntity extends BaseDescriptionRemoval {
private final String entityName;
private final String aspects;
private AspectList oldList;
private AspectList newList;
private static class RemoveEntity extends BaseDescriptionRemoval {
private final String entityName;
private final String aspects;
private AspectList oldList;
private AspectList newList;
public RemoveEntity(String entityName, String aspects) {
super("Aspects");
this.entityName = entityName;
this.aspects = aspects;
}
public RemoveEntity(String entityName, String aspects) {
super("Aspects");
this.entityName = entityName;
this.aspects = aspects;
}
@Override
public void apply() {
oldList = ThaumcraftHelper.getEntityAspects(entityName);
if (oldList != null) {
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
}
}
@Override
public void apply() {
oldList = ThaumcraftHelper.getEntityAspects(entityName);
if (oldList != null) {
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, newList);
}
}
@Override
public boolean canUndo() {
return oldList != null;
}
@Override
public boolean canUndo() {
return oldList != null;
}
@Override
public void undo() {
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, oldList);
}
@Override
public void undo() {
ThaumcraftHelper.removeEntityAspects(entityName);
ThaumcraftApi.registerEntityTag(entityName, oldList);
}
@Override
public String getRecipeInfo() {
return entityName;
}
}
@Override
public String getRecipeInfo() {
return entityName;
}
}
}

View file

@ -9,6 +9,7 @@ import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -17,52 +18,54 @@ import thaumcraft.api.crafting.CrucibleRecipe;
@ZenClass("mods.thaumcraft.Crucible")
public class Crucible {
@ZenMethod
public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) {
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
}
@ZenMethod
public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
}
private static class Add extends BaseListAddition {
public Add(CrucibleRecipe recipe) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
}
private static class Add extends BaseListAddition {
public Add(CrucibleRecipe recipe) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
}
@Override
public String getRecipeInfo() {
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof CrucibleRecipe) {
CrucibleRecipe r = (CrucibleRecipe) o;
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof CrucibleRecipe) {
CrucibleRecipe r = (CrucibleRecipe) o;
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}

View file

@ -10,6 +10,7 @@ import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
@ -20,156 +21,163 @@ import thaumcraft.api.crafting.InfusionRecipe;
@ZenClass("mods.thaumcraft.Infusion")
public class Infusion {
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) {
MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe))));
}
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe))));
}
//A version that allows you to specify whether the detection should be fuzzy or not
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
}
// A version that allows you to specify whether the detection should be
// fuzzy or not
@ZenMethod
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
}
@ZenMethod
public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) {
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
}
@ZenMethod
public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
}
private static class Add extends BaseListAddition {
public Add(InfusionRecipe recipe) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe);
}
private static class Add extends BaseListAddition {
public Add(InfusionRecipe recipe) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else return super.getRecipeInfo();
}
}
@Override
public String getRecipeInfo() {
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else
return super.getRecipeInfo();
}
}
private static class AddEnchant implements IUndoableAction {
InfusionEnchantmentRecipe recipe;
private static class AddEnchant implements IUndoableAction {
InfusionEnchantmentRecipe recipe;
public AddEnchant(InfusionEnchantmentRecipe inp) {
recipe = inp;
}
public AddEnchant(InfusionEnchantmentRecipe inp) {
recipe = inp;
}
@Override
public void apply() {
ThaumcraftApi.getCraftingRecipes().add(recipe);
}
@Override
public void apply() {
ThaumcraftApi.getCraftingRecipes().add(recipe);
}
@Override
public String describe() {
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public String describe() {
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public boolean canUndo() {
return recipe != null;
}
@Override
public boolean canUndo() {
return recipe != null;
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String describeUndo() {
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public String describeUndo() {
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public String getOverrideKey() {
return null;
}
}
@Override
public String getOverrideKey() {
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@ZenMethod
public static void removeEnchant(int id) {
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
}
@ZenMethod
public static void removeEnchant(int id) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack);
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack);
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof InfusionRecipe) {
InfusionRecipe r = (InfusionRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
@Override
public void apply() {
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
if (o instanceof InfusionRecipe) {
InfusionRecipe r = (InfusionRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
private static class RemoveEnchant implements IUndoableAction {
Enchantment enchant;
InfusionEnchantmentRecipe removed;
private static class RemoveEnchant implements IUndoableAction {
Enchantment enchant;
InfusionEnchantmentRecipe removed;
public RemoveEnchant(Enchantment ench) {
enchant = ench;
}
public RemoveEnchant(Enchantment ench) {
enchant = ench;
}
@Override
public void apply() {
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
if (recipe instanceof InfusionEnchantmentRecipe) {
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
if (enchRecipe.getEnchantment() == enchant) {
removed = enchRecipe;
ThaumcraftApi.getCraftingRecipes().remove(enchRecipe);
}
}
}
}
@Override
public void apply() {
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
if (recipe instanceof InfusionEnchantmentRecipe) {
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
if (enchRecipe.getEnchantment() == enchant) {
removed = enchRecipe;
ThaumcraftApi.getCraftingRecipes().remove(enchRecipe);
}
}
}
}
@Override
public String describe() {
return "Removing Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public String describe() {
return "Removing Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public boolean canUndo() {
return removed != null;
}
@Override
public boolean canUndo() {
return removed != null;
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().add(removed);
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().add(removed);
}
@Override
public String describeUndo() {
return "Restoring Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public String describeUndo() {
return "Restoring Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public String getOverrideKey() {
return null;
}
}
@Override
public String getOverrideKey() {
return null;
}
}
}

View file

@ -0,0 +1,75 @@
package modtweaker2.mods.thaumcraft.handlers;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.internal.WeightedRandomLoot;
@ZenClass("mods.thaumcraft.Loot")
public class Loot {
@ZenMethod
public static void addCommonLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
@ZenMethod
public static void addUncommonLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagUncommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
@ZenMethod
public static void addRareLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
public static class Add extends BaseListAddition {
public Add(List list, WeightedRandomLoot recipe) {
super(list, recipe);
}
}
@ZenMethod
public static void removeCommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagCommon, InputHelper.toStack(stack)));
}
@ZenMethod
public static void removeUncommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagUncommon, InputHelper.toStack(stack)));
}
@ZenMethod
public static void removeRareLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagRare, InputHelper.toStack(stack)));
}
public static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
}
@Override
public void apply() {
List<WeightedRandomLoot> loot = (List<WeightedRandomLoot>) list;
WeightedRandomLoot remove = null;
for (WeightedRandomLoot stack : loot) {
if (stack.item.isItemEqual(this.stack)) {
remove = stack;
break;
}
}
loot.remove(remove);
}
}
}

View file

@ -21,6 +21,7 @@ import modtweaker2.mods.thaumcraft.research.RemoveResearch;
import modtweaker2.mods.thaumcraft.research.RemoveTab;
import modtweaker2.mods.thaumcraft.research.SetAspects;
import modtweaker2.mods.thaumcraft.research.SetResearch;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.Optional;
@ -32,167 +33,199 @@ import thaumcraft.api.research.ResearchPage.PageType;
@ZenClass("mods.thaumcraft.Research")
public class Research {
private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png");
private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png");
@ZenMethod
public static void addTab(String key, String iconDomain, String iconPath) {
addTab(key, iconDomain, iconPath, null, null);
}
@ZenMethod
public static void addTab(String key, String iconDomain, String iconPath) {
addTab(key, iconDomain, iconPath, null, null);
}
@ZenMethod
public static void addTab(String key, String iconDomain, String iconPath, String backDomain, String backPath) {
ResourceLocation icon = new ResourceLocation(iconDomain, iconPath);
ResourceLocation background;
if (backPath == null) background = defaultBackground;
else background = new ResourceLocation(backDomain, backPath);
addTab(key, icon, background);
}
@ZenMethod
public static void addTab(String key, String iconDomain, String iconPath, String backDomain, String backPath) {
ResourceLocation icon = new ResourceLocation(iconDomain, iconPath);
ResourceLocation background;
if (backPath == null)
background = defaultBackground;
else
background = new ResourceLocation(backDomain, backPath);
addTab(key, icon, background);
}
private static void addTab(String key, ResourceLocation icon, ResourceLocation background) {
MineTweakerAPI.apply(new AddTab(key, icon, background));
}
private static void addTab(String key, ResourceLocation icon, ResourceLocation background) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddTab(key, icon, background));
}
@ZenMethod
public static void removeTab(String tab) {
MineTweakerAPI.apply(new RemoveTab(tab));
}
@ZenMethod
public static void removeTab(String tab) {
@ZenMethod
public static void removeResearch(String research) {
MineTweakerAPI.apply(new RemoveResearch(research));
}
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new RemoveTab(tab));
}
@ZenMethod
public static void orphanResearch(String research) {
MineTweakerAPI.apply(new OrphanResearch(research));
}
@ZenMethod
public static void removeResearch(String research) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new RemoveResearch(research));
}
@ZenMethod
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) {
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path))));
}
@ZenMethod
public static void orphanResearch(String research) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new OrphanResearch(research));
}
@ZenMethod
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) {
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item))));
}
@ZenMethod
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path))));
}
@ZenMethod
public static void addPage(String key, String unlocalized) {
MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized));
}
@ZenMethod
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item))));
}
@ZenMethod
public static void addCraftingPage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addPage(String key, String unlocalized) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized));
}
@ZenMethod
public static void addCruciblePage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addCraftingPage(String key, IItemStack item) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addArcanePage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addCruciblePage(String key, IItemStack item) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addInfusionPage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addArcanePage(String key, IItemStack item) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addEnchantmentPage(String key, int i) {
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i]));
}
@ZenMethod
public static void addInfusionPage(String key, IItemStack item) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item)));
}
@ZenMethod
public static void clearPages(String key) {
MineTweakerAPI.apply(new ClearPages(key));
}
@ZenMethod
public static void addEnchantmentPage(String key, int i) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i]));
}
@ZenMethod
public static void addPrereq(String key, String req, @Optional boolean hidden) {
MineTweakerAPI.apply(new AddPrereq(key, req, hidden));
}
@ZenMethod
public static void clearPages(String key) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new ClearPages(key));
}
@ZenMethod
public static void clearPrereqs(String key) {
MineTweakerAPI.apply(new ClearPrereqs(key));
}
@ZenMethod
public static void addPrereq(String key, String req, @Optional boolean hidden) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddPrereq(key, req, hidden));
}
@ZenMethod
public static void addSibling(String key, String sibling) {
MineTweakerAPI.apply(new AddSibling(key, sibling));
}
@ZenMethod
public static void clearPrereqs(String key) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new ClearPrereqs(key));
}
@ZenMethod
public static void clearSiblings(String key) {
MineTweakerAPI.apply(new ClearSiblings(key));
}
@ZenMethod
public static void addSibling(String key, String sibling) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new AddSibling(key, sibling));
}
@ZenMethod
public static void setRound(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND));
}
@ZenMethod
public static void clearSiblings(String key) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new ClearSiblings(key));
}
@ZenMethod
public static void setSpikey(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE));
}
@ZenMethod
public static void setRound(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND));
}
@ZenMethod
public static void setStub(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB));
}
@ZenMethod
public static void setSpikey(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE));
}
@ZenMethod
public static void setSecondary(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY));
}
@ZenMethod
public static void setStub(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB));
}
@ZenMethod
public static void setVirtual(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL));
}
@ZenMethod
public static void setSecondary(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY));
}
@ZenMethod
public static void setAutoUnlock(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO));
}
@ZenMethod
public static void setVirtual(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL));
}
@ZenMethod
public static void setConcealed(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL));
}
@ZenMethod
public static void setAutoUnlock(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO));
}
@ZenMethod
public static void setAspects(String key, String aspects) {
MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects)));
}
@ZenMethod
public static void setConcealed(String key, boolean flag) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL));
}
@ZenMethod
public static void setComplexity(String key, int complexity) {
MineTweakerAPI.apply(new Difficulty(key, complexity));
}
@ZenMethod
public static void setAspects(String key, String aspects) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects)));
}
@ZenMethod
public static void refreshResearchRecipe(String key) {
MineTweakerAPI.apply(new RefreshResearch(key));
}
@ZenMethod
public static void setComplexity(String key, int complexity) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Difficulty(key, complexity));
}
@ZenMethod
public static void refreshResearchRecipe(String key) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new RefreshResearch(key));
}
@ZenMethod
public static void moveResearch(String key, String destination, int x, int y) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new MoveResearch(key, destination, x, y));
}
@ZenMethod
public static void moveResearch(String key, String destination, int x, int y) {
MineTweakerAPI.apply(new MoveResearch(key, destination, x, y));
}
@ZenMethod
public static boolean hasResearched(IPlayer player, String key) {
return ThaumcraftApiHelper.isResearchComplete(player.getName(), key);
}
public static enum SetType {
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL
}
public static enum SetType {
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL
}
}

View file

@ -10,6 +10,7 @@ import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -18,192 +19,221 @@ import thaumcraft.api.ThaumcraftApi;
@ZenClass("mods.thaumcraft.Warp")
public class Warp {
@ZenMethod
public static void addToResearch(String key, int warp) {
MineTweakerAPI.apply(new Add(key, warp));
}
@ZenMethod
public static void addToResearch(String key, int warp) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(key, warp));
}
@ZenMethod
public static void addToItem(IItemStack stack, int warp) {
MineTweakerAPI.apply(new Add(toStack(stack), warp));
}
@ZenMethod
public static void addToItem(IItemStack stack, int warp) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(toStack(stack), warp));
}
private static class Add implements IUndoableAction {
Object target;
int warp;
private static class Add implements IUndoableAction {
Object target;
int warp;
public Add(Object targ, int amount) {
target = targ;
warp = amount;
}
public Add(Object targ, int amount) {
target = targ;
warp = amount;
}
public void apply() {
if (target instanceof String) ThaumcraftApi.addWarpToResearch((String) target, warp);
else if (target instanceof ItemStack) ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
}
public void apply() {
if (target instanceof String)
ThaumcraftApi.addWarpToResearch((String) target, warp);
else if (target instanceof ItemStack)
ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
}
public boolean canUndo() {
return ThaumcraftApi.getWarp(target) > 0;
}
public boolean canUndo() {
return ThaumcraftApi.getWarp(target) > 0;
}
public String describe() {
String desc = "Adding " + warp + " warp to ";
if (target instanceof String) desc += (String) target;
else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName();
return desc;
}
public String describe() {
String desc = "Adding " + warp + " warp to ";
if (target instanceof String)
desc += (String) target;
else if (target instanceof ItemStack)
desc += ((ItemStack) target).getDisplayName();
return desc;
}
public void undo() {
if (target instanceof String) ThaumcraftHelper.warpList.remove(target);
else if (target instanceof ItemStack) ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
}
public void undo() {
if (target instanceof String)
ThaumcraftHelper.warpList.remove(target);
else if (target instanceof ItemStack)
ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
}
public String describeUndo() {
String desc = "Removing warp from ";
if (target instanceof String) desc += (String) target;
else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName();
return desc;
}
public String describeUndo() {
String desc = "Removing warp from ";
if (target instanceof String)
desc += (String) target;
else if (target instanceof ItemStack)
desc += ((ItemStack) target).getDisplayName();
return desc;
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFromResearch(String key) {
MineTweakerAPI.apply(new Remove(key));
}
@ZenMethod
public static void removeFromResearch(String key) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(key));
}
@ZenMethod
public static void removeFromItem(IItemStack stack) {
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeFromItem(IItemStack stack) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeAll() {
MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH));
}
@ZenMethod
public static void removeAll() {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH));
}
@ZenMethod
public static void removeAllResearch() {
MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH));
}
@ZenMethod
public static void removeAllResearch() {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH));
}
@ZenMethod
public static void removeAllItems() {
MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS));
}
@ZenMethod
public static void removeAllItems() {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS));
}
private static class Remove implements IUndoableAction {
Object target;
int warp;
private static class Remove implements IUndoableAction {
Object target;
int warp;
public Remove(Object targ) {
target = targ;
}
public Remove(Object targ) {
target = targ;
}
public void apply() {
if (target instanceof String) warp = ThaumcraftHelper.warpList.remove(target);
else if (target instanceof ItemStack) warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
}
public void apply() {
if (target instanceof String)
warp = ThaumcraftHelper.warpList.remove(target);
else if (target instanceof ItemStack)
warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage()));
}
public boolean canUndo() {
return warp > 0;
}
public boolean canUndo() {
return warp > 0;
}
public String describe() {
String desc = "Removing warp from ";
if (target instanceof String) desc += (String) target;
else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName();
return desc;
}
public String describe() {
String desc = "Removing warp from ";
if (target instanceof String)
desc += (String) target;
else if (target instanceof ItemStack)
desc += ((ItemStack) target).getDisplayName();
return desc;
}
public void undo() {
if (target instanceof String) ThaumcraftApi.addWarpToResearch((String) target, warp);
else if (target instanceof ItemStack) ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
}
public void undo() {
if (target instanceof String)
ThaumcraftApi.addWarpToResearch((String) target, warp);
else if (target instanceof ItemStack)
ThaumcraftApi.addWarpToItem((ItemStack) target, warp);
}
public String describeUndo() {
String desc = "Restoring " + warp + " warp to ";
if (target instanceof String) desc += (String) target;
else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName();
return desc;
}
public String describeUndo() {
String desc = "Restoring " + warp + " warp to ";
if (target instanceof String)
desc += (String) target;
else if (target instanceof ItemStack)
desc += ((ItemStack) target).getDisplayName();
return desc;
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
public static enum RemoveType {
RESEARCH, ITEMS, BOTH
}
public static enum RemoveType {
RESEARCH, ITEMS, BOTH
}
private static class MassRemove implements IUndoableAction {
HashMap<Object, Integer> oldMap = new HashMap<Object, Integer>();
RemoveType type;
private static class MassRemove implements IUndoableAction {
HashMap<Object, Integer> oldMap = new HashMap<Object, Integer>();
RemoveType type;
public MassRemove(RemoveType typ) {
type = typ;
}
public MassRemove(RemoveType typ) {
type = typ;
}
public void apply() {
if (type == RemoveType.BOTH) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
ThaumcraftHelper.warpList.clear();
} else if (type == RemoveType.ITEMS) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
if (key instanceof List) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
}
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.remove(key);
}
} else if (type == RemoveType.RESEARCH) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
if (key instanceof String) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
}
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.remove(key);
}
}
}
public void apply() {
if (type == RemoveType.BOTH) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
ThaumcraftHelper.warpList.clear();
} else if (type == RemoveType.ITEMS) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
if (key instanceof List) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
}
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.remove(key);
}
} else if (type == RemoveType.RESEARCH) {
for (Object key : ThaumcraftHelper.warpList.keySet()) {
if (key instanceof String) {
oldMap.put(key, ThaumcraftHelper.warpList.get(key));
}
}
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.remove(key);
}
}
}
public boolean canUndo() {
return oldMap.size() > 0;
}
public boolean canUndo() {
return oldMap.size() > 0;
}
public String describe() {
if (type == RemoveType.RESEARCH) return "Clearing All Research Warp";
else if (type == RemoveType.ITEMS) return "Clearing All Item Warp";
else return "Clearing All Warp";
}
public String describe() {
if (type == RemoveType.RESEARCH)
return "Clearing All Research Warp";
else if (type == RemoveType.ITEMS)
return "Clearing All Item Warp";
else
return "Clearing All Warp";
}
public void undo() {
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.put(key, oldMap.get(key));
}
}
public void undo() {
for (Object key : oldMap.keySet()) {
ThaumcraftHelper.warpList.put(key, oldMap.get(key));
}
}
public String describeUndo() {
if (type == RemoveType.RESEARCH) return "Restoring All Research Warp";
else if (type == RemoveType.ITEMS) return "Restoring All Item Warp";
else return "Restoring All Warp";
}
public String describeUndo() {
if (type == RemoveType.RESEARCH)
return "Restoring All Research Warp";
else if (type == RemoveType.ITEMS)
return "Restoring All Item Warp";
else
return "Restoring All Warp";
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
}

View file

@ -1,6 +1,5 @@
package modtweaker2.mods.thaumcraft.research;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import net.minecraft.enchantment.Enchantment;
@ -15,6 +14,8 @@ import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchPage;
import thaumcraft.api.research.ResearchPage.PageType;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
public class AddPage implements IUndoableAction {
String key;

View file

@ -1,6 +1,5 @@
package modtweaker2.mods.thaumcraft.research;
import static modtweaker2.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
import net.minecraft.item.ItemStack;
@ -13,6 +12,8 @@ import thaumcraft.api.crafting.InfusionRecipe;
import thaumcraft.api.research.ResearchCategories;
import thaumcraft.api.research.ResearchItem;
import thaumcraft.api.research.ResearchPage;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
public class RefreshResearch implements IUndoableAction {
String research;

View file

@ -7,6 +7,7 @@ import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
@ -16,89 +17,91 @@ import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible;
@ZenClass("mods.thermalexpansion.Crucible")
public class Crucible {
@ZenMethod
public static void addRecipe(int energy, IItemStack input, ILiquidStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output)));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, ILiquidStack output) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output)));
}
private static class Add implements IUndoableAction {
ItemStack input;
FluidStack output;
int energy;
boolean applied = false;
private static class Add implements IUndoableAction {
ItemStack input;
FluidStack output;
int energy;
boolean applied = false;
public Add(int rf, ItemStack inp, FluidStack out) {
energy = rf;
input = inp;
output = out;
}
public Add(int rf, ItemStack inp, FluidStack out) {
energy = rf;
input = inp;
output = out;
}
public void apply() {
applied = CrucibleManager.addRecipe(energy, input, output);
}
public void apply() {
applied = CrucibleManager.addRecipe(energy, input, output);
}
public boolean canUndo() {
return input != null && applied;
}
public boolean canUndo() {
return input != null && applied;
}
public String describe() {
return "Adding TE Magma Crucible Recipe using " + input.getDisplayName();
}
public String describe() {
return "Adding TE Magma Crucible Recipe using " + input.getDisplayName();
}
public void undo() {
removeCrucibleRecipe(input);
}
public void undo() {
removeCrucibleRecipe(input);
}
public String describeUndo() {
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeCrucible removed;
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeCrucible removed;
public Remove(ItemStack inp) {
input = inp;
}
public Remove(ItemStack inp) {
input = inp;
}
public void apply() {
removed = CrucibleManager.getRecipe(input);
removeCrucibleRecipe(input);
}
public void apply() {
removed = CrucibleManager.getRecipe(input);
removeCrucibleRecipe(input);
}
public boolean canUndo() {
return removed != null;
}
public boolean canUndo() {
return removed != null;
}
public String describe() {
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
}
public String describe() {
return "Removing TE Magma Crucible Recipe using " + input.getDisplayName();
}
public void undo() {
CrucibleManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput());
}
public void undo() {
CrucibleManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput());
}
public String describeUndo() {
return "Restoring TE Magma Crucible Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Restoring TE Magma Crucible Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
}

View file

@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -12,121 +13,125 @@ import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace;
@ZenClass("mods.thermalexpansion.Furnace")
public class Furnace {
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output)));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output)));
}
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
int energy;
boolean applied = false;
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
int energy;
boolean applied = false;
public Add(int rf, ItemStack inp, ItemStack out) {
energy = rf;
input = inp;
output = out;
}
public Add(int rf, ItemStack inp, ItemStack out) {
energy = rf;
input = inp;
output = out;
}
public void apply() {
FurnaceManager.addRecipe(energy, input, output, false);
}
public void apply() {
FurnaceManager.addRecipe(energy, input, output, false);
}
public boolean canUndo() {
return input != null;
}
public boolean canUndo() {
return input != null;
}
public String describe() {
return "Adding Redstone Furnace Recipe using " + input.getDisplayName();
}
public String describe() {
return "Adding Redstone Furnace Recipe using " + input.getDisplayName();
}
public void undo() {
FurnaceManager.removeRecipe(input);
}
public void undo() {
FurnaceManager.removeRecipe(input);
}
public String describeUndo() {
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeFurnace removed;
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeFurnace removed;
public Remove(ItemStack inp) {
input = inp;
}
public void apply() {
removed = FurnaceManager.getRecipe(input);
FurnaceManager.removeRecipe(input);
}
public Remove(ItemStack inp) {
input = inp;
}
public boolean canUndo() {
return removed != null;
}
public void apply() {
removed = FurnaceManager.getRecipe(input);
FurnaceManager.removeRecipe(input);
}
public String describe() {
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
}
public boolean canUndo() {
return removed != null;
}
public void undo() {
FurnaceManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput(), false);
}
public String describe() {
return "Removing Redstone Furnace Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Restoring Redstone Furnace Recipe using " + input.getDisplayName();
}
public void undo() {
FurnaceManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput(), false);
}
public Object getOverrideKey() {
return null;
}
public String describeUndo() {
return "Restoring Redstone Furnace Recipe using " + input.getDisplayName();
}
}
public Object getOverrideKey() {
return null;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
@ZenMethod
public static void refreshRecipes() {
MineTweakerAPI.apply(new Refresh());
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private static class Refresh implements IUndoableAction {
@ZenMethod
public static void refreshRecipes() {
MineTweakerAPI.apply(new Refresh());
}
public void apply() {
FurnaceManager.loadRecipes();
}
private static class Refresh implements IUndoableAction {
public boolean canUndo() {
return false;
}
public void apply() {
FurnaceManager.loadRecipes();
}
public String describe() {
return "Refreshing Redstone Furnace Recipes";
}
public boolean canUndo() {
return false;
}
public void undo() {}
public String describe() {
return "Refreshing Redstone Furnace Recipes";
}
public String describeUndo() {
return "Can't Undo Redstone Furnace Refresh";
}
public void undo() {
}
public Object getOverrideKey() {
return null;
}
public String describeUndo() {
return "Can't Undo Redstone Furnace Refresh";
}
}
public Object getOverrideKey() {
return null;
}
}
}

View file

@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -12,98 +13,101 @@ import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer;
@ZenClass("mods.thermalexpansion.Pulverizer")
public class Pulverizer {
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
}
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
ItemStack secondary;
int secondaryChance;
int energy;
boolean applied = false;
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
ItemStack secondary;
int secondaryChance;
int energy;
boolean applied = false;
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
energy = rf;
input = inp;
output = out;
secondary = sec;
secondaryChance = chance;
}
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
energy = rf;
input = inp;
output = out;
secondary = sec;
secondaryChance = chance;
}
public void apply() {
applied = PulverizerManager.addRecipe(energy, input, output, secondary, secondaryChance);
}
public void apply() {
applied = PulverizerManager.addRecipe(energy, input, output, secondary, secondaryChance);
}
public boolean canUndo() {
return input != null && applied;
}
public boolean canUndo() {
return input != null && applied;
}
public String describe() {
return "Adding Pulverizer Recipe using " + input.getDisplayName();
}
public String describe() {
return "Adding Pulverizer Recipe using " + input.getDisplayName();
}
public void undo() {
PulverizerManager.removeRecipe(input);
}
public void undo() {
PulverizerManager.removeRecipe(input);
}
public String describeUndo() {
return "Removing Pulverizer Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Removing Pulverizer Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove implements IUndoableAction {
ItemStack input;
RecipePulverizer removed;
private static class Remove implements IUndoableAction {
ItemStack input;
RecipePulverizer removed;
public Remove(ItemStack inp) {
input = inp;
}
public Remove(ItemStack inp) {
input = inp;
}
public void apply() {
removed = PulverizerManager.getRecipe(input);
PulverizerManager.removeRecipe(input);
}
public void apply() {
removed = PulverizerManager.getRecipe(input);
PulverizerManager.removeRecipe(input);
}
public boolean canUndo() {
return removed != null;
}
public boolean canUndo() {
return removed != null;
}
public String describe() {
return "Removing Pulverizer Recipe using " + input.getDisplayName();
}
public String describe() {
return "Removing Pulverizer Recipe using " + input.getDisplayName();
}
public void undo() {
PulverizerManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
}
public void undo() {
PulverizerManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
}
public String describeUndo() {
return "Restoring Pulverizer Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Restoring Pulverizer Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
}

View file

@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -12,98 +13,99 @@ import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill;
@ZenClass("mods.thermalexpansion.Sawmill")
public class Sawmill {
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) {
MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance));
}
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
ItemStack secondary;
int secondaryChance;
int energy;
boolean applied = false;
private static class Add implements IUndoableAction {
ItemStack input;
ItemStack output;
ItemStack secondary;
int secondaryChance;
int energy;
boolean applied = false;
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
energy = rf;
input = inp;
output = out;
secondary = sec;
secondaryChance = chance;
}
public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) {
energy = rf;
input = inp;
output = out;
secondary = sec;
secondaryChance = chance;
}
public void apply() {
applied = SawmillManager.addRecipe(energy, input, output, secondary, secondaryChance);
}
public void apply() {
applied = SawmillManager.addRecipe(energy, input, output, secondary, secondaryChance);
}
public boolean canUndo() {
return input != null && applied;
}
public boolean canUndo() {
return input != null && applied;
}
public String describe() {
return "Adding Sawmill Recipe using " + input.getDisplayName();
}
public String describe() {
return "Adding Sawmill Recipe using " + input.getDisplayName();
}
public void undo() {
SawmillManager.removeRecipe(input);
}
public void undo() {
SawmillManager.removeRecipe(input);
}
public String describeUndo() {
return "Removing Sawmill Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Removing Sawmill Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeSawmill removed;
private static class Remove implements IUndoableAction {
ItemStack input;
RecipeSawmill removed;
public Remove(ItemStack inp) {
input = inp;
}
public Remove(ItemStack inp) {
input = inp;
}
public void apply() {
removed = SawmillManager.getRecipe(input);
SawmillManager.removeRecipe(input);
}
public void apply() {
removed = SawmillManager.getRecipe(input);
SawmillManager.removeRecipe(input);
}
public boolean canUndo() {
return removed != null;
}
public boolean canUndo() {
return removed != null;
}
public String describe() {
return "Removing Sawmill Recipe using " + input.getDisplayName();
}
public String describe() {
return "Removing Sawmill Recipe using " + input.getDisplayName();
}
public void undo() {
SawmillManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
}
public void undo() {
SawmillManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance());
}
public String describeUndo() {
return "Restoring Sawmill Recipe using " + input.getDisplayName();
}
public String describeUndo() {
return "Restoring Sawmill Recipe using " + input.getDisplayName();
}
public Object getOverrideKey() {
return null;
}
public Object getOverrideKey() {
return null;
}
}
}
}

View file

@ -11,6 +11,7 @@ import minetweaker.api.item.IItemStack;
import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -47,7 +48,8 @@ public class Smelter {
ItemStack out1 = toStack(output);
ItemStack out2 = toStack(output2);
RecipeSmelter recipe = (RecipeSmelter) ThermalHelper.getTERecipe(ThermalHelper.smelterRecipe, in1, in2, out1, out2, chance, energy);
MineTweakerAPI.apply(new Add(in1, in2, recipe));
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(in1, in2, recipe));
}
private static class Add extends BaseDescriptionAddition {
@ -93,7 +95,8 @@ public class Smelter {
@ZenMethod
public static void removeRecipe(IItemStack input, IItemStack input2) {
MineTweakerAPI.apply(new Remove(toStack(input), toStack(input2)));
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input), toStack(input2)));
}
private static class Remove extends BaseDescriptionRemoval {

View file

@ -13,6 +13,7 @@ import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
@ -22,158 +23,162 @@ import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer;
@ZenClass("mods.thermalexpansion.Transposer")
public class Transposer {
private static boolean removeValidated(ComparableItemStackSafe stack) {
//Check if there is a recipe that requires this in the validation set for filling
for (Map.Entry entry : ThermalHelper.getFillMap().entrySet()) {
RecipeTransposer recipe = (RecipeTransposer) entry.getValue();
if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) {
return false;
}
}
private static boolean removeValidated(ComparableItemStackSafe stack) {
// Check if there is a recipe that requires this in the validation set
// for filling
for (Map.Entry entry : ThermalHelper.getFillMap().entrySet()) {
RecipeTransposer recipe = (RecipeTransposer) entry.getValue();
if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) {
return false;
}
}
//Check if there is a recipe that requires this in the validation set for extracting
for (Map.Entry entry : ThermalHelper.getExtractMap().entrySet()) {
RecipeTransposer recipe = (RecipeTransposer) entry.getValue();
if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) {
return false;
}
}
// Check if there is a recipe that requires this in the validation set
// for extracting
for (Map.Entry entry : ThermalHelper.getExtractMap().entrySet()) {
RecipeTransposer recipe = (RecipeTransposer) entry.getValue();
if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) {
return false;
}
}
return ThermalHelper.transposerValid.remove(stack);
}
return ThermalHelper.transposerValid.remove(stack);
}
@ZenMethod
public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) {
addRecipe(energy, input, output, liquid, 100, true);
}
@ZenMethod
public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) {
addRecipe(energy, input, output, liquid, 100, true);
}
@ZenMethod
public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) {
addRecipe(energy, input, output, liquid, chance, false);
}
@ZenMethod
public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) {
addRecipe(energy, input, output, liquid, chance, false);
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance, boolean isFillRecipe) {
ItemStack in = toStack(input);
ItemStack out = toStack(output);
FluidStack fluid = toFluid(liquid);
RecipeTransposer recipe = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, chance);
MineTweakerAPI.apply(new Add(in, fluid, recipe, isFillRecipe));
}
@ZenMethod
public static void addRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance, boolean isFillRecipe) {
ItemStack in = toStack(input);
ItemStack out = toStack(output);
FluidStack fluid = toFluid(liquid);
RecipeTransposer recipe = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, chance);
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Add(in, fluid, recipe, isFillRecipe));
}
private static class Add extends BaseDescriptionAddition {
private List key;
private boolean isFillRecipe;
private final ComparableItemStackSafe input;
private final RecipeTransposer recipe;
private static class Add extends BaseDescriptionAddition {
private List key;
private boolean isFillRecipe;
private final ComparableItemStackSafe input;
private final RecipeTransposer recipe;
public Add(ItemStack input, FluidStack fluid, RecipeTransposer recipe, boolean isFillRecipe) {
super("Transposer");
this.isFillRecipe = isFillRecipe;
this.input = new ComparableItemStackSafe(input);
public Add(ItemStack input, FluidStack fluid, RecipeTransposer recipe, boolean isFillRecipe) {
super("Transposer");
this.isFillRecipe = isFillRecipe;
this.input = new ComparableItemStackSafe(input);
this.recipe = recipe;
if (this.isFillRecipe) {
this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) });
}
}
this.recipe = recipe;
if (this.isFillRecipe) {
this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) });
}
}
@Override
public void apply() {
if (isFillRecipe) {
ThermalHelper.getFillMap().put(key, recipe);
} else {
ThermalHelper.getExtractMap().put(input, recipe);
}
@Override
public void apply() {
if (isFillRecipe) {
ThermalHelper.getFillMap().put(key, recipe);
} else {
ThermalHelper.getExtractMap().put(input, recipe);
}
ThermalHelper.transposerValid.add(input);
}
ThermalHelper.transposerValid.add(input);
}
@Override
public boolean canUndo() {
return input != null;
}
@Override
public boolean canUndo() {
return input != null;
}
@Override
public void undo() {
if (isFillRecipe) {
ThermalHelper.getFillMap().remove(key);
} else {
ThermalHelper.getExtractMap().remove(input);
}
@Override
public void undo() {
if (isFillRecipe) {
ThermalHelper.getFillMap().remove(key);
} else {
ThermalHelper.getExtractMap().remove(input);
}
removeValidated(input);
}
removeValidated(input);
}
@Override
public String getRecipeInfo() {
return ((RecipeTransposer) recipe).getOutput().getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return ((RecipeTransposer) recipe).getOutput().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFillRecipe(IItemStack input, ILiquidStack liquid) {
removeRecipe(input, liquid, true);
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFillRecipe(IItemStack input, ILiquidStack liquid) {
removeRecipe(input, liquid, true);
}
@ZenMethod
public static void removeExtractRecipe(IItemStack input) {
removeRecipe(input, null, false);
}
@ZenMethod
public static void removeExtractRecipe(IItemStack input) {
removeRecipe(input, null, false);
}
@ZenMethod
public static void removeRecipe(IItemStack input, ILiquidStack liquid, boolean isFillRecipe) {
MineTweakerAPI.apply(new Remove(toStack(input), toFluid(liquid), isFillRecipe));
}
@ZenMethod
public static void removeRecipe(IItemStack input, ILiquidStack liquid, boolean isFillRecipe) {
if (!TweakerPlugin.hasInit())
MineTweakerAPI.apply(new Remove(toStack(input), toFluid(liquid), isFillRecipe));
}
private static class Remove extends BaseDescriptionRemoval {
private final boolean isFillRecipe;
private final ComparableItemStackSafe input;
private List key;
private RecipeTransposer recipe;
private static class Remove extends BaseDescriptionRemoval {
private final boolean isFillRecipe;
private final ComparableItemStackSafe input;
private List key;
private RecipeTransposer recipe;
public Remove(ItemStack input, FluidStack fluid, boolean isFillRecipe) {
super("Transposer");
this.isFillRecipe = isFillRecipe;
this.input = new ComparableItemStackSafe(input);
if (this.isFillRecipe) {
this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) });
}
}
public Remove(ItemStack input, FluidStack fluid, boolean isFillRecipe) {
super("Transposer");
this.isFillRecipe = isFillRecipe;
this.input = new ComparableItemStackSafe(input);
if (this.isFillRecipe) {
this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) });
}
}
@Override
public void apply() {
if (isFillRecipe) {
recipe = ThermalHelper.getFillMap().get(key);
ThermalHelper.getFillMap().remove(key);
} else {
recipe = ThermalHelper.getExtractMap().get(input);
ThermalHelper.getExtractMap().remove(input);
}
@Override
public void apply() {
if (isFillRecipe) {
recipe = ThermalHelper.getFillMap().get(key);
ThermalHelper.getFillMap().remove(key);
} else {
recipe = ThermalHelper.getExtractMap().get(input);
ThermalHelper.getExtractMap().remove(input);
}
removeValidated(input);
}
removeValidated(input);
}
@Override
public boolean canUndo() {
return input != null;
}
@Override
public boolean canUndo() {
return input != null;
}
@Override
public void undo() {
if (isFillRecipe) {
ThermalHelper.getFillMap().put(key, recipe);
} else {
ThermalHelper.getExtractMap().put(input, recipe);
}
@Override
public void undo() {
if (isFillRecipe) {
ThermalHelper.getFillMap().put(key, recipe);
} else {
ThermalHelper.getExtractMap().put(input, recipe);
}
ThermalHelper.transposerValid.add(input);
}
ThermalHelper.transposerValid.add(input);
}
@Override
public String getRecipeInfo() {
return input.toItemStack().getDisplayName();
}
}
@Override
public String getRecipeInfo() {
return input.toItemStack().getDisplayName();
}
}
}

View file

@ -0,0 +1,12 @@
package modtweaker2.proxy;
import modtweaker2.Commands;
public class ClientProxy extends CommonProxy{
@Override
public void registerCommands() {
Commands.registerCommands();
}
}

View file

@ -0,0 +1,11 @@
package modtweaker2.proxy;
import modtweaker2.Commands;
public class CommonProxy {
public void registerCommands(){
Commands.registerCommands();
}
}

View file

@ -6,6 +6,8 @@ import cpw.mods.fml.common.Loader;
public class TweakerPlugin {
private static ArrayList<String> isLoaded = new ArrayList();
public static boolean hasInit = false;
public static void register(String mod, Class clazz) {
if (Loader.isModLoaded(mod)) {
@ -25,4 +27,8 @@ public class TweakerPlugin {
public static boolean isLoaded(String string) {
return isLoaded.contains(string);
}
public static boolean hasInit(){
return hasInit;
}
}

View file

@ -0,0 +1,20 @@
public net.minecraft.world.gen.ChunkProviderGenerate field_147430_m
public net.minecraft.world.gen.ChunkProviderGenerate field_73220_k
public net.minecraft.world.gen.ChunkProviderGenerate field_73230_p
public net.minecraft.world.gen.ChunkProviderGenerate func_147423_a(III)V
public net.minecraft.world.gen.ChunkProviderGenerate field_147434_q
public net.minecraft.world.WorldType <init>(ILjava/lang/String;)V
public-f net.minecraft.world.WorldType field_77137_b #Default WorldType
public-f net.minecraft.world.WorldType field_77138_c #Flat WorldType
public-f net.minecraft.world.WorldType field_77135_d #LargeBiomes WorldType
public-f net.minecraft.world.WorldType field_151360_e #Amplified WorldType
protected net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet.minecraft.inventory.Slot;)V
public-f net.minecraft.init.Items field_151058_ca #Items.lead
public-f net.minecraft.init.Items field_151031_f #Items.bow
public net.minecraft.entity.player.EntityPlayer field_71076_b #sleepTimer
public-f net.minecraft.init.Blocks field_150431_aC #snow_layer
public net.minecraft.client.gui.inventory.GuiContainer func_146975_c(II)Lnet/minecraft/inventory/Slot; #getSlotAtPosition
public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft
public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop
public net.minecraft.block.BlockDynamicLiquid func_149807_p(Lnet/minecraft/world/World;III)Z #displaceBlocks
public net.minecraft.entity.passive.EntityHorse field_110296_bG #horseChest