Initial Comment

This commit is contained in:
jaredlll08 committed 2015-01-11 21:59:45 +02:00
commit 419ac849d0
276 files changed
+17939

No files matched your search

@@ -0,0 +1,35 @@
package modtweaker;
import static modtweaker.helpers.LogHelper.print;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientEvents {
public static int cooldown;
public static boolean active;
@SubscribeEvent
public void onDrawTooltip(ItemTooltipEvent event) {
if (active) {
IPlayer player = MineTweakerMC.getIPlayer(event.entityPlayer);
if (player != null) {
IItemStack hand = MineTweakerMC.getIItemStack(event.itemStack);
if (hand != null) {
String print = hand.toString();
event.toolTip.add(print);
if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) {
if (cooldown <= 0) {
cooldown = 30;
print(print + " -- " + hand.getDisplayName());
} else cooldown--;
} else cooldown--;
}
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
package modtweaker;
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.0.1", version = VERSION;
public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES;
}
+78
View File
@@ -0,0 +1,78 @@
package modtweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker.mods.bloodmagic.BloodMagic;
import modtweaker.mods.botania.Botania;
import modtweaker.mods.exnihilo.ExNihilo;
import modtweaker.mods.extendedworkbench.ExtendedWorkbench;
import modtweaker.mods.factorization.Factorization;
import modtweaker.mods.fsp.Steamcraft;
import modtweaker.mods.hee.HardcoreEnderExpansion;
import modtweaker.mods.mariculture.Mariculture;
import modtweaker.mods.mekanism.Mekanism;
import modtweaker.mods.mekanism.gas.GasLogger;
import modtweaker.mods.metallurgy.Metallurgy;
import modtweaker.mods.pneumaticcraft.PneumaticCraft;
import modtweaker.mods.railcraft.Railcraft;
import modtweaker.mods.tconstruct.MaterialLogger;
import modtweaker.mods.tconstruct.TConstruct;
import modtweaker.mods.thaumcraft.Thaumcraft;
import modtweaker.mods.thaumcraft.research.ResearchLogger;
import modtweaker.mods.thermalexpansion.ThermalExpansion;
import modtweaker.util.TweakerPlugin;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.relauncher.Side;
@Mod(modid = ModProps.modid, name = ModProps.name, dependencies = ModProps.dependencies)
public class ModTweaker {
@EventHandler
public void init(FMLInitializationEvent event) {
TweakerPlugin.register("AWWayofTime", BloodMagic.class);
TweakerPlugin.register("Botania", Botania.class);
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);
TweakerPlugin.register("PneumaticCraft", PneumaticCraft.class);
TweakerPlugin.register("Railcraft", Railcraft.class);
TweakerPlugin.register("Steamcraft", Steamcraft.class);
TweakerPlugin.register("TConstruct", TConstruct.class);
TweakerPlugin.register("Thaumcraft", Thaumcraft.class);
TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class);
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
}
@EventHandler
public void onServerStart(FMLServerStartingEvent event) {
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 (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("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());
}
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());
}
}
}
@@ -0,0 +1,48 @@
package modtweaker.helpers;
import static modtweaker.helpers.ReflectionHelper.getFinalObject;
import static modtweaker.helpers.ReflectionHelper.getStaticObject;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.ForgeHooks;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class ForgeHelper {
public static Map translate = null;
public static List seeds = null;
public static HashMap<String, ChestGenHooks> loot = null;
static {
try {
seeds = getStaticObject(ForgeHooks.class, "seedList");
loot = getStaticObject(ChestGenHooks.class, "chestInfo");
translate = getFinalObject(getStaticObject(StatCollector.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c");
} catch (Exception e) {}
}
private ForgeHelper() {}
public static Object getSeedEntry(ItemStack stack, int weight) {
try {
Class clazz = Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, int.class);
constructor.setAccessible(true);
return constructor.newInstance(stack, weight);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate SeedEntry");
}
}
public static boolean isLangActive(String lang) {
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null : FMLClientHandler.instance().getCurrentLanguage().equals(lang);
}
}
@@ -0,0 +1,118 @@
package modtweaker.helpers;
import java.util.ArrayList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.oredict.IOreDictEntry;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class InputHelper {
public static boolean isABlock(IItemStack block) {
if (!(isABlock(toStack(block)))) {
MineTweakerAPI.getLogger().logError("Item must be a block, or you must specify a block to render as when adding a TConstruct Melting recipe");
return false;
} else return true;
}
public static boolean isABlock(ItemStack block) {
return block.getItem() instanceof ItemBlock;
}
public static ItemStack toStack(IItemStack iStack) {
if (iStack == null) return null;
else {
Object internal = iStack.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.getLogger().logError("Not a valid item stack: " + iStack);
}
return (ItemStack) internal;
}
}
public static ItemStack[] toStacks(IItemStack[] iStack) {
if (iStack == null) return null;
else {
ItemStack[] output = new ItemStack[iStack.length];
for (int i = 0; i < iStack.length; i++) {
output[i] = toStack(iStack[i]);
}
return output;
}
}
public static Object toObject(IIngredient iStack) {
if (iStack == null) return null;
else {
if (iStack instanceof IOreDictEntry) {
return toString((IOreDictEntry) iStack);
} else if (iStack instanceof IItemStack) {
return toStack((IItemStack) iStack);
} else return null;
}
}
public static Object[] toObjects(IIngredient[] ingredient) {
if (ingredient == null) return null;
else {
Object[] output = new Object[ingredient.length];
for (int i = 0; i < ingredient.length; i++) {
if (ingredient[i] != null) {
output[i] = toObject(ingredient[i]);
} else output[i] = "";
}
return output;
}
}
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
if (ingredients == null) return null;
else {
ArrayList prep = new ArrayList();
prep.add("abc");
prep.add("def");
prep.add("ghi");
char[][] map = new char[][] { { 'a', 'b', 'c' }, { 'd', 'e', 'f' }, { 'g', 'h', 'i' } };
for (int x = 0; x < ingredients.length; x++) {
if (ingredients[x] != null) {
for (int y = 0; y < ingredients[x].length; y++) {
if (ingredients[x][y] != null && x < map.length && y < map[x].length) {
prep.add(map[x][y]);
prep.add(toObject(ingredients[x][y]));
}
}
}
}
return prep.toArray();
}
}
public static String toString(IOreDictEntry entry) {
return ((IOreDictEntry) entry).getName();
}
public static FluidStack toFluid(ILiquidStack iStack) {
if (iStack == null) {
return null;
} else return FluidRegistry.getFluidStack(iStack.getName(), iStack.getAmount());
}
public static FluidStack[] toFluids(IIngredient[] input) {
return toFluids((IItemStack[]) input);
}
public static FluidStack[] toFluids(ILiquidStack[] iStack) {
FluidStack[] stack = new FluidStack[iStack.length];
for (int i = 0; i < stack.length; i++)
stack[i] = toFluid(iStack[i]);
return stack;
}
}
@@ -0,0 +1,24 @@
package modtweaker.helpers;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
public class LogHelper {
public static void logPrinted(IPlayer player) {
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
public static void log(IPlayer player, String message) {
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage(message));
}
}
public static void print(String string) {
System.out.println(string);
MineTweakerAPI.logCommand(string);
}
}
@@ -0,0 +1,71 @@
package modtweaker.helpers;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class ReflectionHelper {
public static Constructor getConstructor(String string, Class... types) {
try {
Class clazz = Class.forName(string);
Constructor constructor = clazz.getDeclaredConstructor(types);
constructor.setAccessible(true);
return constructor;
} catch (Exception ex) {}
return null;
}
public static <T> T getObject(Object o, String... fieldName) {
Class cls = o.getClass();
for (String field : fieldName) {
try {
Field result = cls.getDeclaredField(field);
result.setAccessible(true);
return (T) result.get(o);
} catch (Exception ex) {}
}
return null;
}
public static <T> T getFinalObject(Object o, String... fieldName) {
Class cls = o.getClass();
for (String field : fieldName) {
try {
Field result = cls.getDeclaredField(field);
result.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(result, result.getModifiers() & ~Modifier.FINAL);
return (T) result.get(o);
} catch (Exception ex) {}
}
return null;
}
public static <T> T getStaticObject(Class cls, String... fieldName) {
for (String field : fieldName) {
try {
Field result = cls.getDeclaredField(field);
result.setAccessible(true);
return (T) result.get(null);
} catch (Exception e) {}
}
return null;
}
public static void setPrivateValue(Class cls, String field, int var) {
try {
Field f = cls.getDeclaredField(field);
f.setAccessible(true);
f.setInt(null, var);
} catch (Exception e) {}
}
public static void setPrivateValue(Class cls, Object o, String field, Object var) {
cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(cls, o, var, field);
}
}
@@ -0,0 +1,15 @@
package modtweaker.helpers;
import modtweaker.mods.botania.Botania;
import modtweaker.util.TweakerPlugin;
import net.minecraft.item.ItemStack;
public class StackHelper {
//Stack is the stack that is part of a recipe, stack2 is the one input trying to match
public static boolean areEqual(ItemStack stack, ItemStack stack2) {
if (stack == null || stack2 == null) return false;
else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack) && Botania.isSubtile(stack2)) {
return Botania.subtileMatches(stack, stack2);
} else return stack.isItemEqual(stack2);
}
}
@@ -0,0 +1,16 @@
package modtweaker.mods.bloodmagic;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.bloodmagic.handlers.Alchemy;
import modtweaker.mods.bloodmagic.handlers.Binding;
import modtweaker.mods.bloodmagic.handlers.BloodAltar;
import modtweaker.mods.bloodmagic.handlers.BloodOrb;
public class BloodMagic {
public BloodMagic() {
MineTweakerAPI.registerClass(Alchemy.class);
MineTweakerAPI.registerClass(Binding.class);
MineTweakerAPI.registerClass(BloodAltar.class);
MineTweakerAPI.registerClass(BloodOrb.class);
}
}
@@ -0,0 +1,68 @@
package modtweaker.mods.bloodmagic.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.InputHelper.toStacks;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipe;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
@ZenClass("mods.bloodmagic.Alchemy")
public class Alchemy {
//Adding a Blood Magic Alchemical Chemistry Set recipe
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack[] input, int tier, int lp) {
MineTweakerAPI.apply(new Add(new AlchemyRecipe(toStack(output), (int) (((double) lp) / 100), toStacks(input), tier)));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(AlchemyRecipe recipe) {
super("Alchemical Chemistry Set", AlchemyRecipeRegistry.recipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((AlchemyRecipe) recipe).getResult().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Blood Magic Alchemical Chemistry Set recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Alchemical Chemistry Set", AlchemyRecipeRegistry.recipes, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (AlchemyRecipe r : AlchemyRecipeRegistry.recipes) {
if (r.getResult() != null && areEqual(r.getResult(), stack)) {
recipe = r;
break;
}
}
AlchemyRecipeRegistry.recipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,67 @@
package modtweaker.mods.bloodmagic.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRecipe;
import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRegistry;
@ZenClass("mods.bloodmagic.Binding")
public class Binding {
//Adding a Blood Magic Binding recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new BindingRecipe(toStack(output), toStack(input))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(BindingRecipe recipe) {
super("Binding", BindingRegistry.bindingRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((BindingRecipe) recipe).getResult().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Blood Magic Binding recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Binding", BindingRegistry.bindingRecipes, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (BindingRecipe r : BindingRegistry.bindingRecipes) {
if (r.getResult() != null && areEqual(r.getResult(), stack)) {
recipe = r;
break;
}
}
BindingRegistry.bindingRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,71 @@
package modtweaker.mods.bloodmagic.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipe;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry;
@ZenClass("mods.bloodmagic.Altar")
public class BloodAltar {
//Adding a Blood Magic Altar recipe
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int tier, int lp, @Optional int consume, @Optional int drain) {
consume = consume > 0 ? consume : 20;
drain = drain > 0 ? drain : 20;
MineTweakerAPI.apply(new Add(new AltarRecipe(toStack(output), toStack(input), tier, lp, consume, drain, false)));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(AltarRecipe recipe) {
super("Blood Altar", AltarRecipeRegistry.altarRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((AltarRecipe) recipe).getResult().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Blood Magic Altar recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Blood Altar", AltarRecipeRegistry.altarRecipes, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (AltarRecipe r : AltarRecipeRegistry.altarRecipes) {
if (r.getResult() != null && areEqual(r.getResult(), stack)) {
recipe = r;
break;
}
}
AltarRecipeRegistry.altarRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,58 @@
package modtweaker.mods.bloodmagic.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toShapedObjects;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseCraftingAddition;
import modtweaker.util.BaseCraftingRemoval;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
@ZenClass("mods.bloodmagic.BloodOrb")
public class BloodOrb {
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
}
private static class Add extends BaseCraftingAddition {
public Add(boolean shapeless, ItemStack output, Object... recipe) {
super("Blood Orb", shapeless, CraftingManager.getInstance().getRecipeList(), output, recipe);
}
@Override
public void applyShaped() {
list.add(new ShapedBloodOrbRecipe(output, recipe));
}
@Override
public void applyShapeless() {
list.add(new ShapelessBloodOrbRecipe(output, recipe));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseCraftingRemoval {
public Remove(ItemStack stack) {
super("Blood Orb", CraftingManager.getInstance().getRecipeList(), stack);
}
}
}
@@ -0,0 +1,28 @@
package modtweaker.mods.botania;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.botania.handlers.Apothecary;
import modtweaker.mods.botania.handlers.ElvenTrade;
import modtweaker.mods.botania.handlers.ManaInfusion;
import modtweaker.mods.botania.handlers.Orechid;
import modtweaker.mods.botania.handlers.RuneAltar;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
public class Botania {
public Botania() {
MineTweakerAPI.registerClass(Apothecary.class);
MineTweakerAPI.registerClass(ElvenTrade.class);
MineTweakerAPI.registerClass(ManaInfusion.class);
MineTweakerAPI.registerClass(Orechid.class);
MineTweakerAPI.registerClass(RuneAltar.class);
}
public static boolean isSubtile(ItemStack stack) {
return stack.getItem() instanceof ItemBlockSpecialFlower;
}
public static boolean subtileMatches(ItemStack stack, ItemStack stack2) {
return (ItemBlockSpecialFlower.getType(stack2).equals(ItemBlockSpecialFlower.getType(stack)));
}
}
@@ -0,0 +1,75 @@
package modtweaker.mods.botania.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
@ZenClass("mods.botania.Apothecary")
public class Apothecary {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(toStack(output), toObjects(input))));
}
@ZenMethod
public static void addRecipe(String output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(ItemBlockSpecialFlower.ofType(output), toObjects(input))));
}
private static class Add extends BaseListAddition {
public Add(RecipePetals recipe) {
super("Botania Petal Recipe", BotaniaAPI.petalRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipePetals) recipe).getOutput().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@ZenMethod
public static void removeRecipe(String output) {
MineTweakerAPI.apply(new Remove(ItemBlockSpecialFlower.ofType(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Petal recipe", BotaniaAPI.petalRecipes, stack);
}
@Override
public void apply() {
for (RecipePetals r : BotaniaAPI.petalRecipes) {
if (areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
BotaniaAPI.petalRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,64 @@
package modtweaker.mods.botania.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeElvenTrade;
@ZenClass("mods.botania.ElvenTrade")
public class ElvenTrade {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipeElvenTrade(toStack(output), toObjects(input))));
}
private static class Add extends BaseListAddition {
public Add(RecipeElvenTrade recipe) {
super("Botania Eleven Trade", BotaniaAPI.elvenTradeRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeElvenTrade) recipe).getOutput().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("Botania Elven Trade", BotaniaAPI.elvenTradeRecipes, stack);
}
@Override
public void apply() {
for (RecipeElvenTrade r : BotaniaAPI.elvenTradeRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
BotaniaAPI.elvenTradeRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,78 @@
package modtweaker.mods.botania.handlers;
import static modtweaker.helpers.InputHelper.toObject;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeManaInfusion;
@ZenClass("mods.botania.ManaInfusion")
public class ManaInfusion {
@ZenMethod
public static void addInfusion(IItemStack output, IIngredient input, int mana) {
MineTweakerAPI.apply(new Add(new RecipeManaInfusion(toStack(output), toObject(input), mana)));
}
@ZenMethod
public static void addAlchemy(IItemStack output, IIngredient input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(toStack(output), toObject(input), mana);
recipe.setAlchemy(true);
MineTweakerAPI.apply(new Add(recipe));
}
@ZenMethod
public static void addConjuration(IItemStack output, IIngredient input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(toStack(output), toObject(input), mana);
recipe.setConjuration(true);
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
public Add(RecipeManaInfusion recipe) {
super("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeManaInfusion) recipe).getOutput().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("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, stack);
}
@Override
public void apply() {
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
BotaniaAPI.manaInfusionRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,114 @@
package modtweaker.mods.botania.handlers;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.oredict.IOreDictEntry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@ZenClass("mods.botania.Orechid")
public class Orechid {
@ZenMethod
public static void addOre(IOreDictEntry oreDict, int weight) {
MineTweakerAPI.apply(new Add(oreDict.getName(), weight));
}
@ZenMethod
public static void addOre(String oreDict, int weight) {
MineTweakerAPI.apply(new Add(oreDict, weight));
}
private static class Add implements IUndoableAction {
String oreDict;
int weight;
public Add(String ore, int prop) {
oreDict = ore;
weight = prop;
}
@Override
public void apply() {
BotaniaAPI.addOreWeight(oreDict, weight);
}
@Override
public String describe() {
return "Adding Orechid Ore Weight: " + oreDict + ":" + weight;
}
@Override
public boolean canUndo() {
return oreDict != null;
}
@Override
public void undo() {
BotaniaAPI.oreWeights.remove(oreDict);
}
@Override
public String describeUndo() {
return "Removing Orechid Ore: " + oreDict;
}
@Override
public String getOverrideKey() {
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeOre(IOreDictEntry oreDict) {
MineTweakerAPI.apply(new Remove(oreDict.getName()));
}
@ZenMethod
public static void removeOre(String oreDict) {
MineTweakerAPI.apply(new Remove(oreDict));
}
private static class Remove implements IUndoableAction {
String oreDict;
int weight;
public Remove(String ore) {
oreDict = ore;
}
@Override
public void apply() {
weight = BotaniaAPI.getOreWeight(oreDict);
BotaniaAPI.oreWeights.remove(oreDict);
}
@Override
public String describe() {
return "Removing Orechid Ore: " + oreDict;
}
@Override
public boolean canUndo() {
return weight > 0;
}
@Override
public void undo() {
BotaniaAPI.addOreWeight(oreDict, weight);
}
@Override
public String describeUndo() {
return "Restoring Orechid Ore Weight: " + oreDict + ":" + weight;
}
@Override
public String getOverrideKey() {
return null;
}
}
}
@@ -0,0 +1,64 @@
package modtweaker.mods.botania.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeRuneAltar;
@ZenClass("mods.botania.RuneAltar")
public class RuneAltar {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input, int mana) {
MineTweakerAPI.apply(new Add(new RecipeRuneAltar(toStack(output), mana, toObjects(input))));
}
private static class Add extends BaseListAddition {
public Add(RecipeRuneAltar recipe) {
super("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeRuneAltar) recipe).getOutput().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("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, stack);
}
@Override
public void apply() {
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
BotaniaAPI.runeAltarRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,16 @@
package modtweaker.mods.exnihilo;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.exnihilo.handlers.Compost;
import modtweaker.mods.exnihilo.handlers.Crucible;
import modtweaker.mods.exnihilo.handlers.Hammer;
import modtweaker.mods.exnihilo.handlers.Sieve;
public class ExNihilo {
public ExNihilo() {
MineTweakerAPI.registerClass(Compost.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Hammer.class);
MineTweakerAPI.registerClass(Sieve.class);
}
}
@@ -0,0 +1,56 @@
package modtweaker.mods.exnihilo.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.CompostRegistry;
import exnihilo.registries.helpers.Color;
import exnihilo.registries.helpers.Compostable;
@ZenClass("mods.exnihilo.Composting")
public class Compost {
//Adding a Ex Nihilo Composting recipe
@ZenMethod
public static void addRecipe(IItemStack input, double value, @Optional String hex) {
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
MineTweakerAPI.apply(new Add(new Compostable(toStack(input).getItem(), toStack(input).getItemDamage(), Math.min(1.0F, (float) value), new Color(hex))));
}
//Passes the list to the map list implementation, and adds the recipe
private static class Add extends BaseMapAddition {
public Add(Compostable recipe) {
super("ExNihilo Composting", CompostRegistry.entries, recipe.item + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Compostable) recipe).item, 1, ((Compostable) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Composting recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
//Removes a recipe, will always remove the key, so all should be good
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("ExNihilo Composting", CompostRegistry.entries, stack.getItem() + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,112 @@
package modtweaker.mods.exnihilo.handlers;
import static modtweaker.helpers.InputHelper.isABlock;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.CrucibleRegistry;
import exnihilo.registries.HeatRegistry;
import exnihilo.registries.helpers.HeatSource;
import exnihilo.registries.helpers.Meltable;
@ZenClass("mods.exnihilo.Crucible")
public class Crucible {
/************************************************ Crucible Melting ************************************************/
//Adding a Ex Nihilo Crucible recipe
@ZenMethod
public static void addRecipe(IItemStack input, ILiquidStack fluid) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new AddRecipe(new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock)));
}
}
//Passes the list to the map list implementation, and adds the recipe
private static class AddRecipe extends BaseMapAddition {
public AddRecipe(Meltable recipe) {
super("ExNihilo Crucible", CrucibleRegistry.entries, recipe.block + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Meltable) recipe).block, 1, ((Meltable) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (isABlock(output)) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
}
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveRecipe extends BaseMapRemoval {
public RemoveRecipe(ItemStack stack) {
super("ExNihilo Crucible", CrucibleRegistry.entries, Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
/********************************************** Crucible Heat Sources **********************************************/
//Adding a Ex Nihilo Crucible heat source
@ZenMethod
public static void addHeatSource(IItemStack input, double value) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new AddHeatSource(new HeatSource(theBlock, theMeta, (float) value)));
}
}
//Passes the list to the base map implementation, and adds the recipe
private static class AddHeatSource extends BaseMapAddition {
public AddHeatSource(HeatSource recipe) {
super("ExNihilo Crucible - Heat Source", HeatRegistry.entries, recipe.block + ":" + recipe.meta, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((HeatSource) recipe).block, 1, ((HeatSource) recipe).meta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Crucible heat source
@ZenMethod
public static void removeHeatSource(IItemStack output) {
if (isABlock(output)) {
MineTweakerAPI.apply(new RemoveHeatSource(toStack(output)));
}
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveHeatSource extends BaseMapRemoval {
public RemoveHeatSource(ItemStack stack) {
super("ExNihilo Crucible - Heat Source", HeatRegistry.entries, Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage(), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,74 @@
package modtweaker.mods.exnihilo.handlers;
import static modtweaker.helpers.InputHelper.isABlock;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.HammerRegistry;
import exnihilo.registries.helpers.Smashable;
@ZenClass("mods.exnihilo.Hammer")
public class Hammer {
//Adding a Ex Nihilo Hammer recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, double chance, double luck) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(new Smashable(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), (float) chance, (float) luck)));
}
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(Smashable recipe) {
super("ExNihilo Hammer", HammerRegistry.rewards, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Smashable) recipe).source, 1, ((Smashable) recipe).sourceMeta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Hammer recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("ExNihilo Hammer", HammerRegistry.rewards, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (Smashable r : HammerRegistry.rewards) {
ItemStack check = new ItemStack(r.item, 1, r.meta);
if (check != null && areEqual(check, stack)) {
recipe = r;
break;
}
}
HammerRegistry.rewards.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,80 @@
package modtweaker.mods.exnihilo.handlers;
import static modtweaker.helpers.InputHelper.isABlock;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseMultipleListRemoval;
import modtweaker.util.BaseMultipleListRemoval.Position;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.SieveRegistry;
import exnihilo.registries.helpers.SiftReward;
@ZenClass("mods.exnihilo.Sieve")
public class Sieve {
//Adding a Ex Nihilo Sieve recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int rarity) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Add(new SiftReward(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 extends BaseListAddition {
public Add(SiftReward recipe) {
super("ExNihilo Sieve", SieveRegistry.rewards, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((SiftReward) recipe).source, 1, ((SiftReward) recipe).sourceMeta).getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Sieve recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), Position.ALL));
}
@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 extends BaseMultipleListRemoval {
public Remove(ItemStack stack, Position pos) {
super("ExNihilo Sieve", SieveRegistry.rewards, stack, pos);
}
@Override
protected boolean isEqual(Object recipe, Object search) {
SiftReward r = (SiftReward) recipe;
ItemStack c = new ItemStack(r.item, 1, r.meta);
if (c != null && areEqual(c, (ItemStack) search)) {
return true;
} else return false;
}
@Override
public String getRecipeInfo() {
return ((ItemStack) search).getDisplayName();
}
}
}
@@ -0,0 +1,10 @@
package modtweaker.mods.extendedworkbench;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.extendedworkbench.handlers.ExtendedCrafting;
public class ExtendedWorkbench {
public ExtendedWorkbench() {
MineTweakerAPI.registerClass(ExtendedCrafting.class);
}
}
@@ -0,0 +1,104 @@
package modtweaker.mods.extendedworkbench.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.InputHelper.toStacks;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import naruto1310.extendedWorkbench.crafting.ExtendedCraftingManager;
import naruto1310.extendedWorkbench.crafting.ExtendedShapedRecipes;
import naruto1310.extendedWorkbench.crafting.ExtendedShapelessRecipes;
import naruto1310.extendedWorkbench.crafting.IExtendedRecipe;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.extendedworkbench")
public class ExtendedCrafting {
@ZenMethod
public static void addShaped(IItemStack output, IItemStack[][] ingredients) {
MineTweakerAPI.apply(new Add(getShapedRecipe(output, ingredients)));
}
@ZenMethod
public static void addShapeless(IItemStack output, IItemStack[] ingredients) {
MineTweakerAPI.apply(new Add(new ExtendedShapelessRecipes(toStack(output), Arrays.asList(toStacks(ingredients)))));
}
private static class Add extends BaseListAddition {
public Add(IExtendedRecipe recipe) {
super("Extended Workbench", ExtendedCraftingManager.getInstance().getRecipeList(), recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((IExtendedRecipe) recipe).getRecipeOutput();
if (out != null) {
return ((ItemStack) out).getDisplayName();
} else return super.getRecipeInfo();
}
}
private static IExtendedRecipe getShapedRecipe(IItemStack out, IItemStack[][] ingredients) {
int width = 0;
int height = ingredients.length;
ItemStack[] recipe;
for (int x = 0; x < ingredients.length; x++) {
if (ingredients[x] != null && ingredients[x].length > width) width = ingredients[x].length;
}
recipe = new ItemStack[width * height];
int counter = 0;
for (int x = 0; x < ingredients.length; x++) {
if (ingredients[x] != null) {
for (int y = 0; y < ingredients[x].length; y++) {
recipe[counter++] = toStack(ingredients[x][y]);
}
}
}
return new ExtendedShapedRecipes(width, height, recipe, toStack(out));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Extended Workbench", ExtendedCraftingManager.getInstance().getRecipeList(), stack);
}
@Override
public void apply() {
for (Object o : ExtendedCraftingManager.getInstance().getRecipeList()) {
if (o instanceof IExtendedRecipe) {
IExtendedRecipe r = (IExtendedRecipe) o;
if (r.getRecipeOutput() != null && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
ExtendedCraftingManager.getInstance().getRecipeList().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,14 @@
package modtweaker.mods.factorization;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.factorization.handlers.Crystallizer;
import modtweaker.mods.factorization.handlers.Lacerator;
import modtweaker.mods.factorization.handlers.SlagFurnace;
public class Factorization {
public Factorization() {
MineTweakerAPI.registerClass(Crystallizer.class);
MineTweakerAPI.registerClass(Lacerator.class);
MineTweakerAPI.registerClass(SlagFurnace.class);
}
}
@@ -0,0 +1,57 @@
package modtweaker.mods.factorization;
import static modtweaker.helpers.ReflectionHelper.getStaticObject;
import java.lang.reflect.Constructor;
import java.util.List;
import net.minecraft.item.ItemStack;
public class FactorizationHelper {
public static List lacerator = null;
public static List slag = null;
public static List crystallizer = null;
static {
try {
lacerator = getStaticObject(Class.forName("factorization.oreprocessing.TileEntityGrinder"), "recipes");
slag = getStaticObject(Class.forName("factorization.oreprocessing.TileEntitySlagFurnace$SlagRecipes"), "smeltingResults");
crystallizer = getStaticObject(Class.forName("factorization.oreprocessing.TileEntityCrystallizer"), "recipes");
} catch (Exception e) {}
}
private FactorizationHelper() {}
public static Object getLaceratorRecipe(ItemStack input, ItemStack output, float probability) {
try {
Class clazz = Class.forName("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe");
Constructor constructor = clazz.getDeclaredConstructor(Object.class, ItemStack.class, float.class);
constructor.setAccessible(true);
return constructor.newInstance(input, output, probability);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate Lacerator Recipe");
}
}
public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, ItemStack output2) {
try {
Class clazz = Class.forName("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class);
constructor.setAccessible(true);
return constructor.newInstance(input, chance1, output1, chance2, output2);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate SmeltingResult");
}
}
public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, float output_count) {
try {
Class clazz = Class.forName("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, ItemStack.class, float.class, ItemStack.class);
constructor.setAccessible(true);
return constructor.newInstance(input, output, output_count, solution);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate CrystalRecipe");
}
}
}
@@ -0,0 +1,74 @@
package modtweaker.mods.factorization.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.factorization.FactorizationHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Crystallizer")
public class Crystallizer {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, IItemStack solution, double output_count) {
Object recipe = FactorizationHelper.getCrystallizerRecipe(toStack(input), toStack(output), toStack(solution), (float) output_count);
MineTweakerAPI.apply(new Add(toStack(input), recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack output;
public Add(ItemStack output, Object recipe) {
super("Crystallizer", FactorizationHelper.crystallizer, recipe);
this.output = output;
}
@Override
public String getRecipeInfo() {
return output.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("Crystallizer", FactorizationHelper.crystallizer, stack);
}
//Returns the output ItemStack
private ItemStack getOutput(Object o) {
return (ItemStack) ReflectionHelper.getObject(o, "output");
}
@Override
public void apply() {
for (Object r : list) {
if (r != null) {
ItemStack output = getOutput(r);
if (output != null && areEqual(output, stack)) {
recipe = r;
break;
}
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,72 @@
package modtweaker.mods.factorization.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.factorization.FactorizationHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Lacerator")
public class Lacerator {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, double probability) {
Object recipe = FactorizationHelper.getLaceratorRecipe(toStack(input), toStack(output), (float) probability);
MineTweakerAPI.apply(new Add(toStack(input), recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack output;
public Add(ItemStack output, Object recipe) {
super("Lacerator", FactorizationHelper.lacerator, recipe);
this.output = output;
}
@Override
public String getRecipeInfo() {
return output.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("Lacerator", FactorizationHelper.lacerator, stack);
}
//Returns the output ItemStack
private ItemStack getOutput(Object o) {
return (ItemStack) ReflectionHelper.getObject(o, "output");
}
@Override
public void apply() {
for (Object r : list) {
ItemStack output = getOutput(r);
if (output != null && areEqual(output, stack)) {
recipe = r;
break;
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,73 @@
package modtweaker.mods.factorization.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.factorization.FactorizationHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseMultipleListRemoval;
import modtweaker.util.BaseMultipleListRemoval.Position;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.SlagFurnace")
public class SlagFurnace {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output1, double chance1, IItemStack output2, double chance2) {
Object recipe = FactorizationHelper.getSlagFurnaceRecipe(toStack(input), (float) chance1, toStack(output1), (float) chance2, toStack(output2));
MineTweakerAPI.apply(new Add(toStack(input), recipe));
}
private static class Add extends BaseListAddition {
private final ItemStack input;
public Add(ItemStack input, Object recipe) {
super("Slag Furnace", FactorizationHelper.slag, recipe);
this.input = input;
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), Position.ALL));
}
@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));
}
private static class Remove extends BaseMultipleListRemoval {
public Remove(ItemStack stack, Position pos) {
super("Slag Furnace", FactorizationHelper.slag, stack, pos);
}
@Override
protected boolean isEqual(Object recipe, Object search) {
ItemStack input = (ItemStack) ReflectionHelper.getObject(recipe, "input");
if (input != null && areEqual(input, (ItemStack) search)) {
return true;
} else return false;
}
@Override
public String getRecipeInfo() {
return ((ItemStack) search).getDisplayName();
}
}
}
@@ -0,0 +1,16 @@
package modtweaker.mods.fsp;
import flaxbeard.steamcraft.api.CrucibleLiquid;
import flaxbeard.steamcraft.api.SteamcraftRegistry;
public class FSPHelper {
public static CrucibleLiquid getLiquid(String name) {
for (CrucibleLiquid l : SteamcraftRegistry.liquids) {
if (l.name.equals(name)) {
return l;
}
}
return null;
}
}
@@ -0,0 +1,12 @@
package modtweaker.mods.fsp;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.fsp.handlers.Crucible;
import modtweaker.mods.fsp.handlers.Furnace;
public class Steamcraft {
public Steamcraft() {
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Furnace.class);
}
}
@@ -0,0 +1,127 @@
package modtweaker.mods.fsp.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.mods.fsp.FSPHelper.getLiquid;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import flaxbeard.steamcraft.api.CrucibleFormula;
import flaxbeard.steamcraft.api.CrucibleLiquid;
import flaxbeard.steamcraft.api.SteamcraftRegistry;
import flaxbeard.steamcraft.api.Tuple3;
@ZenClass("mods.fsp.Crucible")
public class Crucible {
@ZenMethod
public static void addLiquid(String name, IItemStack ingot, IItemStack plate, IItemStack nugget, int r, int g, int b) {
MineTweakerAPI.apply(new AddLiquid(new CrucibleLiquid(name, toStack(ingot), toStack(plate), toStack(nugget), null, r, g, b)));
}
@ZenMethod
public static void addLiquid(String name, IItemStack ingot, IItemStack plate, IItemStack nugget, int r, int g, int b, String l1, int n1, String l2, int n2, int n3) {
MineTweakerAPI.apply(new AddLiquid(new CrucibleLiquid(name, toStack(ingot), toStack(plate), toStack(nugget), new CrucibleFormula(getLiquid(l1), n1, getLiquid(l2), n2, n3), r, g, b)));
}
private static class AddLiquid extends BaseListAddition {
public AddLiquid(CrucibleLiquid recipe) {
super("FSP Crucible Liquid", SteamcraftRegistry.liquids, recipe);
}
@Override
public String getRecipeInfo() {
return ((CrucibleLiquid) recipe).name;
}
}
@ZenMethod
public static void addMelting(IItemStack input, String liquid, int volume) {
ItemStack stack = toStack(input);
CrucibleLiquid fluid = getLiquid(liquid);
if (fluid != null) {
MineTweakerAPI.apply(new AddMelting(stack, MutablePair.of(stack.getItem(), stack.getItemDamage()), MutablePair.of(fluid, volume)));
}
}
private static class AddMelting extends BaseMapAddition {
private final ItemStack stack;
public AddMelting(ItemStack stack, Object key, Object recipe) {
super("FSP Crucible Melting", SteamcraftRegistry.smeltThings, key, recipe);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@ZenMethod
public static void removeMelting(IItemStack input) {
MineTweakerAPI.apply(new RemoveMelting(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage())));
}
private static class RemoveMelting extends BaseMapRemoval {
private final ItemStack stack;
public RemoveMelting(ItemStack stack, Object key) {
super("FSP Crucible Melting", SteamcraftRegistry.smeltThings, key);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@ZenMethod
public static void addDunking(IItemStack input, String liquid, int volume, IItemStack output) {
ItemStack stack = toStack(input);
CrucibleLiquid fluid = getLiquid(liquid);
if (fluid != null) {
MineTweakerAPI.apply(new AddDunking(toStack(input), new Tuple3(stack.getItem(), stack.getItemDamage(), fluid), MutablePair.of(volume, toStack(output))));
}
}
private static class AddDunking extends BaseMapAddition {
private final ItemStack stack;
public AddDunking(ItemStack stack, Object key, Object recipe) {
super("FSP Crucible Dunking", SteamcraftRegistry.dunkThings, key, recipe);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@ZenMethod
public static void removeDunking(IItemStack input, String liquid) {
MineTweakerAPI.apply(new RemoveDunking(toStack(input), new Tuple3(toStack(input).getItem(), toStack(input).getItemDamage(), getLiquid(liquid))));
}
private static class RemoveDunking extends BaseMapRemoval {
private final ItemStack stack;
public RemoveDunking(ItemStack stack, Object key) {
super("FSP Crucible Dunking", SteamcraftRegistry.dunkThings, key);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,55 @@
package modtweaker.mods.fsp.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import flaxbeard.steamcraft.api.SteamcraftRegistry;
@ZenClass("mods.fsp.Furnace")
public class Furnace {
@ZenMethod
public static void addSteamFood(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddSteamFood(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage()), MutablePair.of(toStack(output).getItem(), toStack(output).getItemDamage())));
}
private static class AddSteamFood extends BaseMapAddition {
private final ItemStack stack;
public AddSteamFood(ItemStack stack, MutablePair key, MutablePair recipe) {
super("FSP Furnace - Steam Food", SteamcraftRegistry.steamedFoods, key, recipe);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
@ZenMethod
public static void removeSteamFood(IItemStack input) {
MineTweakerAPI.apply(new RemoveSteamFood(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage())));
}
private static class RemoveSteamFood extends BaseMapRemoval {
private final ItemStack stack;
public RemoveSteamFood(ItemStack stack, MutablePair key) {
super("FSP Furnace - Steam Food", SteamcraftRegistry.steamedFoods, key);
this.stack = stack;
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,10 @@
package modtweaker.mods.hee;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.hee.handlers.EssenceAltar;
public class HardcoreEnderExpansion {
public HardcoreEnderExpansion() {
MineTweakerAPI.registerClass(EssenceAltar.class);
}
}
@@ -0,0 +1,76 @@
package modtweaker.mods.hee.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.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();
}
}
}
@@ -0,0 +1,18 @@
package modtweaker.mods.mariculture;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.mariculture.handlers.Anvil;
import modtweaker.mods.mariculture.handlers.Casting;
import modtweaker.mods.mariculture.handlers.Crucible;
import modtweaker.mods.mariculture.handlers.Fishing;
import modtweaker.mods.mariculture.handlers.Vat;
public class Mariculture {
public Mariculture() {
MineTweakerAPI.registerClass(Anvil.class);
MineTweakerAPI.registerClass(Casting.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Fishing.class);
MineTweakerAPI.registerClass(Vat.class);
}
}
@@ -0,0 +1,49 @@
package modtweaker.mods.mariculture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.fishery.Fishing;
import mariculture.api.fishery.Loot;
import mariculture.api.fishery.Loot.Rarity;
import modtweaker.helpers.ReflectionHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
public class MaricultureHelper {
public static Map fuels = null;
public static HashMap<Rarity, ArrayList<Loot>> loot = null;
static {
try {
fuels = ReflectionHelper.getFinalObject(MaricultureHandlers.crucible, "fuels");
loot = ReflectionHelper.getFinalObject(Fishing.fishing, "fishing_loot");
} catch (Exception e) {}
}
private MaricultureHelper() {}
//Helper for getting the key that is used when adding/removing fuels
public static String getKey(Object o) {
if (o instanceof String) return (String) o;
else if (o instanceof ItemStack) {
String name = "";
ItemStack stack = (ItemStack) o;
if (OreDictionary.getOreIDs(stack).length > 0) {
name = OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[0]);
} else if (stack.isItemStackDamageable()) {
name = Item.itemRegistry.getNameForObject(stack.getItem()) + "|ignore";
} else {
name = Item.itemRegistry.getNameForObject(stack.getItem()) + "|" + stack.getItemDamage();
}
return name;
} else if (o instanceof FluidStack) {
return ((FluidStack) o).getFluid().getName();
} else return null;
}
}
@@ -0,0 +1,52 @@
package modtweaker.mods.mariculture.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import mariculture.api.core.IAnvilHandler.RecipeAnvil;
import mariculture.api.core.MaricultureHandlers;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mariculture.MaricultureHelper;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Anvil")
public class Anvil {
//Adding a Mariculture Anvil recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int hits) {
MineTweakerAPI.apply(new Add(new RecipeAnvil(toStack(input), toStack(output), hits)));
}
private static class Add extends BaseMapAddition {
public Add(RecipeAnvil recipe) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(recipe.input), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeAnvil) recipe).output.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Mariculture Anvil recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(stack), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,78 @@
package modtweaker.mods.mariculture.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import java.util.HashMap;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeCasting;
import mariculture.api.core.RecipeCasting.RecipeNuggetCasting;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.mods.mariculture.MaricultureHelper;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Casting")
public class Casting {
//Adding Mariculture Casting Recipes
@ZenMethod
public static void addNuggetRecipe(ILiquidStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getNuggetRecipes()));
}
@ZenMethod
public static void addIngotRecipe(ILiquidStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getIngotRecipes()));
}
@ZenMethod
public static void addBlockRecipe(ILiquidStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getBlockRecipes()));
}
private static class Add extends BaseMapAddition {
public Add(RecipeCasting recipe, HashMap map) {
super("Mariculture Casting", map, MaricultureHelper.getKey(recipe.fluid), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeCasting) recipe).output.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing Mariculture Casting Recipes
@ZenMethod
public static void removeNuggetRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getNuggetRecipes()));
}
@ZenMethod
public static void removeIngotRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getIngotRecipes()));
}
@ZenMethod
public static void removeBlockRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getBlockRecipes()));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack, HashMap map) {
super("Mariculture Casting", map, MaricultureHelper.getKey(stack), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
}
}
@@ -0,0 +1,134 @@
package modtweaker.mods.mariculture.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import mariculture.api.core.FuelInfo;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeSmelter;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.mods.mariculture.MaricultureHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Crucible")
public class Crucible {
/********************************************** Mariculture Crucible Recipes **********************************************/
//Adding a Mariculture Crucible recipe
@ZenMethod
public static void addRecipe(int temp, IItemStack input, ILiquidStack fluid, @Optional IItemStack output, @Optional int chance) {
ItemStack out = output != null ? toStack(output) : null;
MineTweakerAPI.apply(new AddRecipe(new RecipeSmelter(toStack(input), null, temp, toFluid(fluid), out, chance)));
}
//Passes the list to the base list implementation, and adds the recipe
private static class AddRecipe extends BaseListAddition {
public AddRecipe(RecipeSmelter recipe) {
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeSmelter) recipe).input.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Mariculture Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(input)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class RemoveRecipe extends BaseListRemoval {
public RemoveRecipe(ItemStack stack) {
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) {
if (r.input != null && areEqual(r.input, stack)) {
recipe = r;
break;
}
}
MaricultureHandlers.crucible.getRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
/********************************************** Crucible Fuels **********************************************/
@ZenMethod
public static void addFuel(IItemStack input, int max, int per, int time) {
MineTweakerAPI.apply(new AddFuel(toStack(input), new FuelInfo(max, per, time)));
}
@ZenMethod
public static void addFuel(ILiquidStack input, int max, int per, int time) {
MineTweakerAPI.apply(new AddFuel(toFluid(input), new FuelInfo(max, per, time)));
}
@ZenMethod
public static void addFuel(String input, int max, int per, int time) {
MineTweakerAPI.apply(new AddFuel(input, new FuelInfo(max, per, time)));
}
//Passes the list to the base map implementation, and adds the recipe
private static class AddFuel extends BaseMapAddition {
public AddFuel(Object o, FuelInfo info) {
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), info);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFuel(IItemStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
}
@ZenMethod
public static void removeFuel(ILiquidStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
}
@ZenMethod
public static void removeFuel(String fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveFuel extends BaseMapRemoval {
public RemoveFuel(Object o) {
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), null);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
}
}
@@ -0,0 +1,159 @@
package modtweaker.mods.mariculture.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import mariculture.api.fishery.Loot;
import mariculture.api.fishery.Loot.Rarity;
import mariculture.api.fishery.RodType;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.mariculture.MaricultureHelper;
import modtweaker.util.BaseDescriptionAddition;
import modtweaker.util.BaseDescriptionRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import cpw.mods.fml.common.Loader;
@ZenClass("mods.mariculture.Fishing")
public class Fishing {
//HashMap Helper for converting strings to rodtypes, (will personally add a registry to mariculture eventually...)
public static HashMap<String, RodType> rodTypes = new HashMap();
static {
rodTypes.put("net", RodType.NET);
rodTypes.put("old", RodType.OLD);
rodTypes.put("good", RodType.GOOD);
rodTypes.put("dire", RodType.DIRE);
rodTypes.put("super", RodType.SUPER);
rodTypes.put("flux", RodType.FLUX);
if (Loader.isModLoaded("AWWayofTime")) {
try {
rodTypes.put("blood", (RodType) ReflectionHelper.getStaticObject(Class.forName("mariculture.plugins.PluginBloodMagic"), "BLOOD"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
//Adding Fishing Loot
@ZenMethod
public static void addJunk(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.JUNK);
}
@ZenMethod
public static void addGood(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.GOOD);
}
@ZenMethod
public static void addRare(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.RARE);
}
private static void addLoot(ItemStack stack, double chance, String type, boolean exact, int[] dimension, Rarity rarity) {
if (dimension == null || dimension.length == 0) dimension = new int[] { Short.MAX_VALUE };
if (type == null) type = "dire";
for (int dim : dimension) {
MineTweakerAPI.apply(new AddLoot(new Loot(stack, chance, rarity, dim, rodTypes.get(type), exact), rarity.name()));
}
}
private static class AddLoot extends BaseDescriptionAddition {
private final Loot loot;
public AddLoot(Loot loot, String description) {
super("Fishing Loot - " + description);
this.loot = loot;
}
@Override
public void apply() {
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
list.add(loot);
MaricultureHelper.loot.put(loot.rarity, list);
}
@Override
public void undo() {
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
list.remove(loot);
MaricultureHelper.loot.put(loot.rarity, list);
}
@Override
public String getRecipeInfo() {
return loot.loot.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing Fishing Loot, will remove it from every single list
@ZenMethod
public static void removeLoot(IItemStack loot) {
MineTweakerAPI.apply(new RemoveLoot(toStack(loot)));
}
private static class RemoveLoot extends BaseDescriptionRemoval {
private HashMap<Rarity, Loot> loot;
private final ItemStack stack;
public RemoveLoot(ItemStack stack) {
super("Fishing Loot");
this.loot = new HashMap();
this.stack = stack;
}
@Override
public void apply() {
loot.clear();
apply(Rarity.JUNK);
apply(Rarity.GOOD);
apply(Rarity.RARE);
}
//Performs the apply function on all rarity types
public void apply(Rarity rarity) {
ArrayList<Loot> list = MaricultureHelper.loot.get(rarity);
int preSize = list.size();
for (Loot l : list) {
if (areEqual(l.loot, stack)) {
loot.put(rarity, l);
break;
}
}
list.remove(loot);
if (list.size() != preSize) MaricultureHelper.loot.put(rarity, list);
}
@Override
public void undo() {
for (Map.Entry<Rarity, Loot> entry : loot.entrySet()) {
undo(entry.getKey(), entry.getValue());
}
}
//Undoes the action on the applicable rarities
public void undo(Rarity rarity, Loot l) {
ArrayList<Loot> list = MaricultureHelper.loot.get(rarity);
list.add(l);
MaricultureHelper.loot.put(rarity, list);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,131 @@
package modtweaker.mods.mariculture.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeVat;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Vat")
public class Vat {
//Adding a Mariculture Vat recipe
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) {
addRecipe(fluid1, fluid2, null, outputFluid, null, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack outputItem, int time) {
addRecipe(fluid1, fluid2, null, null, outputItem, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, IItemStack outputItem, int time) {
addRecipe(fluid1, fluid2, null, outputFluid, outputItem, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, int time) {
addRecipe(fluid1, null, input, outputFluid, null, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, IItemStack input, IItemStack outputItem, int time) {
addRecipe(fluid1, null, input, null, outputItem, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) {
addRecipe(fluid1, null, input, outputFluid, outputItem, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, int time) {
addRecipe(fluid1, fluid2, input, outputFluid, null, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, IItemStack outputItem, int time) {
addRecipe(fluid1, fluid2, input, null, outputItem, time);
}
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) {
MineTweakerAPI.apply(new Add(new RecipeVat(toStack(input), toFluid(fluid1), toFluid(fluid2), toFluid(outputFluid), toStack(outputItem), time)));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(RecipeVat recipe) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipe);
}
@Override
public String getRecipeInfo() {
if (((RecipeVat) recipe).outputItem != null) return ((RecipeVat) recipe).outputItem.getDisplayName();
else return ((RecipeVat) recipe).outputFluid.getFluid().getLocalizedName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Mariculture Vat recipe
@ZenMethod
public static void removeRecipe(IItemStack outputItem) {
MineTweakerAPI.apply(new Remove(toStack(outputItem), null));
}
@ZenMethod
public static void removeRecipe(ILiquidStack outputFluid) {
MineTweakerAPI.apply(new Remove(null, toFluid(outputFluid)));
}
@ZenMethod
public static void removeRecipe(IItemStack outputItem, ILiquidStack outputFluid) {
MineTweakerAPI.apply(new Remove(toStack(outputItem), toFluid(outputFluid)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
private final FluidStack fluid;
public Remove(ItemStack stack, FluidStack fluid) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), stack);
this.fluid = fluid;
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if (r.outputItem != null && stack != null && areEqual(r.outputItem, stack)) {
if (r.outputFluid == null || (fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipe = r;
break;
}
}
if ((r.outputFluid != null && fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipe = r;
break;
}
}
MaricultureHandlers.vat.getRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack != null ? stack.getDisplayName() : fluid.getFluid().getLocalizedName();
}
}
}
@@ -0,0 +1,41 @@
package modtweaker.mods.mekanism;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.mekanism.gas.GasBracketHandler;
import modtweaker.mods.mekanism.handlers.ChemicalCrystallizer;
import modtweaker.mods.mekanism.handlers.ChemicalDissolution;
import modtweaker.mods.mekanism.handlers.ChemicalInfuser;
import modtweaker.mods.mekanism.handlers.ChemicalInjection;
import modtweaker.mods.mekanism.handlers.ChemicalOxidizer;
import modtweaker.mods.mekanism.handlers.ChemicalWasher;
import modtweaker.mods.mekanism.handlers.Combiner;
import modtweaker.mods.mekanism.handlers.Compressor;
import modtweaker.mods.mekanism.handlers.Crusher;
import modtweaker.mods.mekanism.handlers.Enrichment;
import modtweaker.mods.mekanism.handlers.Infuser;
import modtweaker.mods.mekanism.handlers.Purification;
import modtweaker.mods.mekanism.handlers.Reaction;
import modtweaker.mods.mekanism.handlers.Sawmill;
import modtweaker.mods.mekanism.handlers.Separator;
import modtweaker.util.TweakerPlugin;
public class Mekanism extends TweakerPlugin {
public Mekanism() {
MineTweakerAPI.registerBracketHandler(new GasBracketHandler());
MineTweakerAPI.registerClass(Combiner.class);
MineTweakerAPI.registerClass(Compressor.class);
MineTweakerAPI.registerClass(Crusher.class);
MineTweakerAPI.registerClass(Enrichment.class);
MineTweakerAPI.registerClass(Infuser.class);
MineTweakerAPI.registerClass(Purification.class);
MineTweakerAPI.registerClass(Reaction.class);
MineTweakerAPI.registerClass(Sawmill.class);
MineTweakerAPI.registerClass(Separator.class);
MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
MineTweakerAPI.registerClass(ChemicalDissolution.class);
MineTweakerAPI.registerClass(ChemicalInfuser.class);
MineTweakerAPI.registerClass(ChemicalInjection.class);
MineTweakerAPI.registerClass(ChemicalOxidizer.class);
MineTweakerAPI.registerClass(ChemicalWasher.class);
}
}
@@ -0,0 +1,27 @@
package modtweaker.mods.mekanism;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import modtweaker.mods.mekanism.gas.IGasStack;
public class MekanismHelper {
private MekanismHelper() {}
public static GasStack toGas(IGasStack iStack) {
if (iStack == null) {
return null;
} else return new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
}
public static GasStack[] toGases(IIngredient[] input) {
return toGases((IGasStack[]) input);
}
public static GasStack[] toGases(IGasStack[] iStack) {
GasStack[] stack = new GasStack[iStack.length];
for (int i = 0; i < stack.length; i++)
stack[i] = toGas(iStack[i]);
return stack;
}
}
@@ -0,0 +1,85 @@
package modtweaker.mods.mekanism.gas;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
import minetweaker.api.item.IngredientAny;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.util.ZenPosition;
@BracketHandler(priority = 100)
public class GasBracketHandler implements IBracketHandler {
public static IGasStack getGas(String name) {
Gas gas = GasRegistry.getGas(name);
if (gas != null) {
return new MCGasStack(new GasStack(gas, 1));
} else {
return null;
}
}
private final IZenSymbol symbolAny;
private final IJavaMethod method;
public GasBracketHandler() {
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
method = MineTweakerAPI.getJavaMethod(GasBracketHandler.class, "getGas", String.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
// any symbol
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
return symbolAny;
}
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("gas") && tokens.get(1).getValue().equals(":")) {
return find(environment, tokens, 2, tokens.size());
}
}
return null;
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
valueBuilder.append(token.getValue());
}
Gas gas = GasRegistry.getGas(valueBuilder.toString());
if (gas != null) {
return new GasReferenceSymbol(environment, valueBuilder.toString());
}
return null;
}
private class GasReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
public GasReferenceSymbol(IEnvironmentGlobal environment, String name) {
this.environment = environment;
this.name = name;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
}
}
}
@@ -0,0 +1,38 @@
package modtweaker.mods.mekanism.gas;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
public class GasLogger implements ICommandFunction {
public static final Comparator<Gas> COMPARATOR = new Compare();
private static class Compare implements Comparator<Gas> {
@Override
public int compare(Gas o1, Gas o2) {
return o1.getName().compareTo(o2.getName());
}
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<Gas> gases = GasRegistry.getRegisteredGasses();
System.out.println("Gases: " + GasRegistry.getRegisteredGasses().size());
Collections.sort(gases, COMPARATOR);
for (Gas gas : gases) {
System.out.println("Gas " + gas.getName());
MineTweakerAPI.logCommand("<" + gas.getName() + "> -- " + gas.getLocalizedName());
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
@@ -0,0 +1,18 @@
package modtweaker.mods.mekanism.gas;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.gas.IGasDefinition")
public interface IGasDefinition {
@ZenOperator(OperatorType.MUL)
public IGasStack asStack(int millibuckets);
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
}
@@ -0,0 +1,28 @@
package modtweaker.mods.mekanism.gas;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.gas.IGasStack")
public interface IGasStack {
@ZenGetter("definition")
public IGasDefinition getDefinition();
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
@ZenGetter("amount")
public int getAmount();
@ZenOperator(OperatorType.MUL)
@ZenMethod
public IGasStack withAmount(int amount);
public Object getInternal();
}
@@ -0,0 +1,27 @@
package modtweaker.mods.mekanism.gas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
public class MCGasDefinition implements IGasDefinition {
private final Gas gas;
public MCGasDefinition(Gas gas) {
this.gas = gas;
}
@Override
public String getName() {
return gas.getName();
}
@Override
public String getDisplayName() {
return gas.getLocalizedName();
}
@Override
public IGasStack asStack(int millibuckets) {
return new MCGasStack(new GasStack(gas, millibuckets));
}
}
@@ -0,0 +1,42 @@
package modtweaker.mods.mekanism.gas;
import mekanism.api.gas.GasStack;
public class MCGasStack implements IGasStack {
private final GasStack stack;
public MCGasStack(GasStack stack) {
this.stack = stack;
}
@Override
public IGasDefinition getDefinition() {
return new MCGasDefinition(stack.getGas());
}
@Override
public String getName() {
return stack.getGas().getName();
}
@Override
public String getDisplayName() {
return stack.getGas().getLocalizedName();
}
@Override
public int getAmount() {
return stack.amount;
}
@Override
public IGasStack withAmount(int amount) {
GasStack result = new GasStack(stack.getGas(), amount);
return new MCGasStack(result);
}
@Override
public Object getInternal() {
return stack;
}
}
@@ -0,0 +1,25 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Crystallizer")
public class ChemicalCrystallizer {
@ZenMethod
public static void addRecipe(IGasStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toGas(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toStack(output)));
}
}
@@ -0,0 +1,78 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import modtweaker.helpers.InputHelper;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input)));
}
@ZenMethod
public static void removeRecipe(IOreDictEntry input) {
List<ItemStack> stacks = OreDictionary.getOres(InputHelper.toString(input));
for (ItemStack stack : stacks) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack));
}
}
@ZenMethod
public static void removeRecipe(IGasStack input) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toGas(input)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
ItemStack key = (ItemStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof ItemStack && areEqual(key, (ItemStack) this.key)) {
this.key = key;
break;
} else if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,25 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.ChemicalPair;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
ChemicalPair pair = new ChemicalPair(toGas(left), toGas(right));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output)));
}
}
@@ -0,0 +1,27 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.AdvancedInput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Injection")
public class ChemicalInjection {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), toGas(gas).getGas());
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), toStack(output)));
}
}
@@ -0,0 +1,25 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Oxidizer")
public class ChemicalOxidizer {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toStack(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toGas(output)));
}
}
@@ -0,0 +1,54 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Washer")
public class ChemicalWasher {
@ZenMethod
public static void addRecipe(IGasStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(output)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
GasStack key = (GasStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,26 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Combiner")
public class Combiner {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidStone"));
MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("COMBINER", Recipe.COMBINER.get(), toStack(output)));
}
}
@@ -0,0 +1,26 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Compressor")
public class Compressor {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidOsmium"));
MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), toStack(output)));
}
}
@@ -0,0 +1,23 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Crusher")
public class Crusher {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(output)));
}
}
@@ -0,0 +1,23 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Enrichment")
public class Enrichment {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input)));
}
}
@@ -0,0 +1,59 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfusionInput;
import mekanism.api.infuse.InfusionOutput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Infuser")
public class Infuser {
@ZenMethod
public static void addRecipe(String type, int infuse, IItemStack input, IItemStack output) {
InfusionInput infuseIn = new InfusionInput(InfuseRegistry.get(type), infuse, toStack(input));
InfusionOutput infuseOut = new InfusionOutput(infuseIn, toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), infuseIn, infuseOut));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(output))));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
InfusionInput key = (InfusionInput) pairs.getKey();
InfusionOutput value = (InfusionOutput) pairs.getValue();
if (key != null) {
if (this.key instanceof InfusionOutput && areEqual(value.resource, ((InfusionOutput) this.key).resource)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,50 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Purification")
public class Purification {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("oxygen"));
MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Purification Chamber", Recipe.PURIFICATION_CHAMBER.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<AdvancedInput, ItemStack> entry : ((Map<AdvancedInput, ItemStack>) map).entrySet()) {
if (entry.getValue() != null && areEqual(entry.getValue(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,33 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.PressurizedProducts;
import mekanism.api.PressurizedReactants;
import mekanism.api.PressurizedRecipe;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Reaction")
public class Reaction {
@ZenMethod
public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) {
PressurizedReactants input = new PressurizedReactants(toStack(solid), toFluid(liquid), toGas(gas));
PressurizedRecipe recipe = new PressurizedRecipe(input, energy, new PressurizedProducts(toStack(outItem), toGas(outGas)), ticks);
MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), input, recipe));
}
@ZenMethod
public static void removeRecipe(IItemStack outItem, IGasStack outGas) {
PressurizedProducts output = new PressurizedProducts(toStack(outItem), toGas(outGas));
MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output));
}
}
@@ -0,0 +1,50 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Sawmill")
public class Sawmill {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) {
ChanceOutput chanceOutput = new ChanceOutput(toStack(output1), toStack(output2), chance);
MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), toStack(input), chanceOutput));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Precision Sawmill", Recipe.PRECISION_SAWMILL.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<ItemStack, ChanceOutput> entry : ((Map<ItemStack, ChanceOutput>) map).entrySet()) {
if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,50 @@
package modtweaker.mods.mekanism.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.mods.mekanism.MekanismHelper.toGas;
import java.util.Map;
import mekanism.api.ChemicalPair;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.mods.mekanism.gas.IGasStack;
import modtweaker.mods.mekanism.util.AddMekanismRecipe;
import modtweaker.util.BaseMapRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Separator")
public class Separator {
@ZenMethod
public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) {
ChemicalPair pair = new ChemicalPair(toGas(gas1), toGas(gas2));
MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), toFluid(input), pair));
}
@ZenMethod
public static void removeRecipe(ILiquidStack input) {
MineTweakerAPI.apply(new Remove(toFluid(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(FluidStack stack) {
super("Electrolytic Separator", Recipe.ELECTROLYTIC_SEPARATOR.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<FluidStack, ChemicalPair> entry : ((Map<FluidStack, ChemicalPair>) map).entrySet()) {
if (entry.getKey() != null && entry.getKey().isFluidEqual((FluidStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,42 @@
package modtweaker.mods.mekanism.util;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.api.ChemicalPair;
import mekanism.api.PressurizedReactants;
import mekanism.api.gas.GasStack;
import mekanism.api.infuse.InfusionOutput;
import modtweaker.util.BaseMapAddition;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class AddMekanismRecipe extends BaseMapAddition {
public AddMekanismRecipe(String str, Map map, Object key, Object recipe) {
super(str.toLowerCase(), map, key, recipe);
}
@Override
public String describe() {
if (recipe instanceof ItemStack) return "Adding " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName();
else if (recipe instanceof FluidStack) return "Adding " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName();
else if (recipe instanceof ChemicalPair) return "Adding " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName();
else if (recipe instanceof ChanceOutput) return "Adding " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName();
else if (recipe instanceof GasStack) return "Adding " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName();
else if (recipe instanceof PressurizedReactants) return "Adding " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName();
else if (recipe instanceof InfusionOutput) return "Adding " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName();
else return super.getRecipeInfo();
}
@Override
public String describeUndo() {
if (recipe instanceof ItemStack) return "Removing " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName();
else if (recipe instanceof FluidStack) return "Removing " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName();
else if (recipe instanceof ChemicalPair) return "Removing " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName();
else if (recipe instanceof ChanceOutput) return "Removing " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName();
else if (recipe instanceof GasStack) return "Removing " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName();
else if (recipe instanceof PressurizedReactants) return "Removing " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName();
else if (recipe instanceof InfusionOutput) return "Removing " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName();
else return super.getRecipeInfo();
}
}
@@ -0,0 +1,131 @@
package modtweaker.mods.mekanism.util;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.api.ChemicalPair;
import mekanism.api.PressurizedProducts;
import mekanism.api.PressurizedReactants;
import mekanism.api.PressurizedRecipe;
import mekanism.api.gas.GasStack;
import mekanism.api.infuse.InfusionOutput;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class RemoveMekanismRecipe extends BaseMapRemoval {
private Object tmp;
public RemoveMekanismRecipe(String string, Map map, Object key) {
super(string.toLowerCase().replace('_', ' '), map, key, null);
this.tmp = key;
}
@Override
public void apply() {
try {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
Object value = pairs.getValue();
if (value != null) {
if (tmp instanceof ItemStack && value instanceof ItemStack) {
if (areEqual(((ItemStack) tmp), (ItemStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof FluidStack && value instanceof FluidStack) {
if (((FluidStack) tmp).isFluidEqual((FluidStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof GasStack && value instanceof GasStack) {
if (((GasStack) tmp).isGasEqual((GasStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ItemStack && value instanceof InfusionOutput) {
if (areEqual(((ItemStack) tmp), ((InfusionOutput) value).resource)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChemicalPair && value instanceof ChemicalPair) {
ChemicalPair par1 = (ChemicalPair) tmp;
ChemicalPair par2 = (ChemicalPair) value;
if (par1.leftGas.isGasEqual(par2.leftGas) && par1.rightGas.isGasEqual(par2.rightGas)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChanceOutput && value instanceof ChanceOutput) {
ChanceOutput par1 = (ChanceOutput) tmp;
ChanceOutput par2 = (ChanceOutput) value;
if (areEqual(par1.primaryOutput, par2.primaryOutput)) {
if (par1.secondaryOutput == null || (par1.secondaryOutput != null && par2.secondaryOutput != null && areEqual(par1.secondaryOutput, par2.secondaryOutput))) {
key = pairs.getKey();
break;
}
}
}
if (tmp instanceof PressurizedProducts && value instanceof PressurizedRecipe) {
PressurizedProducts par1 = (PressurizedProducts) tmp;
PressurizedProducts par2 = ((PressurizedRecipe) value).products;
if (areEqual(par1.getItemOutput(), (par2.getItemOutput()))) {
if (par1.getGasOutput().isGasEqual(par2.getGasOutput())) {
key = pairs.getKey();
break;
}
}
}
}
it.remove();
}
recipe = map.get(key);
} catch (Exception e) {
e.printStackTrace();
}
map.remove(key);
}
@Override
public String describe() {
if (tmp instanceof ItemStack) return "Removing " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack) return "Removing " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPair) return "Removing " + description + " Recipe for : " + ((ChemicalPair) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput) return "Removing " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack) return "Removing " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedReactants) return "Removing " + description + " Recipe for : " + ((PressurizedReactants) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionOutput) return "Removing " + description + " Recipe for : " + ((InfusionOutput) tmp).resource.getDisplayName();
else return super.getRecipeInfo();
}
@Override
public String describeUndo() {
if (tmp instanceof ItemStack) return "Restoring " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack) return "Restoring " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPair) return "Restoring " + description + " Recipe for : " + ((ChemicalPair) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput) return "Restoring " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack) return "Restoring " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedReactants) return "Restoring " + description + " Recipe for : " + ((PressurizedReactants) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionOutput) return "Restoring " + description + " Recipe for : " + ((InfusionOutput) tmp).resource.getDisplayName();
else return super.getRecipeInfo();
}
}
@@ -0,0 +1,12 @@
package modtweaker.mods.metallurgy;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.metallurgy.handlers.Alloyer;
import modtweaker.mods.metallurgy.handlers.Crusher;
public class Metallurgy {
public Metallurgy() {
MineTweakerAPI.registerClass(Alloyer.class);
MineTweakerAPI.registerClass(Crusher.class);
}
}
@@ -0,0 +1,44 @@
package modtweaker.mods.metallurgy;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import modtweaker.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack;
import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes;
import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe;
import com.teammetallurgy.metallurgy.recipes.CrusherRecipes;
public class MetallurgyHelper {
public static ArrayList<AlloyRecipe> alloyerRecipes = null;
public static HashMap<String, ItemStack> crusherMetaList = null;
public static HashMap<String, ItemStack[]> crusherInputList = null;
static {
try {
alloyerRecipes = ReflectionHelper.getFinalObject(AlloyerRecipes.getInstance(), "recipes");
crusherMetaList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "metaList");
crusherInputList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "inputList");
} catch (Exception e) {}
}
private MetallurgyHelper() {}
public static String getCrusherKey(ItemStack input) {
return input.getUnlocalizedName();
}
//Returns a Drying Recipe, using reflection as the constructor is not visible
public static AlloyRecipe getAlloyRecipe(ItemStack first, ItemStack base, ItemStack result) {
try {
Constructor constructor = AlloyRecipe.class.getDeclaredConstructor(ItemStack.class, ItemStack.class, ItemStack.class);
constructor.setAccessible(true);
return (AlloyRecipe) constructor.newInstance(first, base, result);
} catch (Exception e) {
e.printStackTrace();
throw new NullPointerException("Failed to instantiate AlloyRecipe");
}
}
}
@@ -0,0 +1,68 @@
package modtweaker.mods.metallurgy.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.metallurgy.MetallurgyHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe;
@ZenClass("mods.metallurgy.Alloyer")
public class Alloyer {
//Adding a Metallurgy Alloyer recipe
@ZenMethod
public static void addRecipe(IItemStack first, IItemStack base, IItemStack result) {
MineTweakerAPI.apply(new Add(MetallurgyHelper.getAlloyRecipe(toStack(first), toStack(base), toStack(result))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(AlloyRecipe recipe) {
super("Metallurgy Alloyer", MetallurgyHelper.alloyerRecipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyRecipe) recipe).getCraftingResult().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Metallurgy Alloyer recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Metallurgy Alloyer", MetallurgyHelper.alloyerRecipes, stack);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (AlloyRecipe r : MetallurgyHelper.alloyerRecipes) {
if (r.getCraftingResult() != null && areEqual(r.getCraftingResult(), stack)) {
recipe = r;
break;
}
}
MetallurgyHelper.alloyerRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,114 @@
package modtweaker.mods.metallurgy.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.metallurgy.MetallurgyHelper;
import modtweaker.util.BaseMapAddition;
import modtweaker.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.metallurgy.Crusher")
public class Crusher {
//Adding a Metallurgy Crusher Recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(toStack(input), toStack(output)));
}
private static class Add extends BaseMapAddition {
private final ItemStack stack;
public Add(ItemStack input, ItemStack output) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(input), output);
this.stack = input;
}
@Override
public void apply() {
super.apply();
addToInput(stack, (ItemStack) recipe);
}
@Override
public void undo() {
super.undo();
removeFromInput(stack, (ItemStack) recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Metallurgy Crusher recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(stack), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
}
@Override
public void apply() {
super.apply();
removeFromInput(((ItemStack) stack), (ItemStack) recipe);
}
@Override
public void undo() {
super.undo();
addToInput(((ItemStack) stack), (ItemStack) recipe);
}
}
//Helper Methods
private static void addToInput(ItemStack input, ItemStack output) {
ItemStack[] inputList = MetallurgyHelper.crusherInputList.get(output.getUnlocalizedName());
if (inputList == null) {
inputList = new ItemStack[1];
inputList[0] = input;
} else {
ItemStack[] newList = new ItemStack[inputList.length + 1];
for (int i = 0; i < inputList.length; i++) {
newList[i] = inputList[i];
}
newList[inputList.length] = input;
inputList = newList;
}
MetallurgyHelper.crusherInputList.put(output.getUnlocalizedName(), inputList);
}
private static void removeFromInput(ItemStack input, ItemStack output) {
boolean switched = false;
ItemStack[] inputList = MetallurgyHelper.crusherInputList.get(output.getUnlocalizedName());
ItemStack[] newList = new ItemStack[inputList.length - 1];
if (newList.length >= 1) {
for (int i = 0; i < inputList.length; i++) {
if (switched || (areEqual(inputList[i], input))) {
switched = true;
newList[i] = inputList[i + 1];
} else newList[i] = inputList[i];
}
} else newList = null;
inputList = newList;
if (inputList == null || inputList.length <= 0) {
MetallurgyHelper.crusherInputList.remove(output.getUnlocalizedName());
} else {
MetallurgyHelper.crusherInputList.put(output.getUnlocalizedName(), inputList);
}
}
}
@@ -0,0 +1,12 @@
package modtweaker.mods.pneumaticcraft;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.pneumaticcraft.handlers.Assembly;
import modtweaker.mods.pneumaticcraft.handlers.Pressure;
public class PneumaticCraft {
public PneumaticCraft() {
MineTweakerAPI.registerClass(Assembly.class);
MineTweakerAPI.registerClass(Pressure.class);
}
}
@@ -0,0 +1,84 @@
package modtweaker.mods.pneumaticcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import pneumaticCraft.api.recipe.AssemblyRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Assembly")
public class Assembly {
@ZenMethod
public static void addDrillRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillRecipes));
}
@ZenMethod
public static void addLaserRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.laserRecipes));
}
@ZenMethod
public static void addLaserDrillRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillLaserRecipes));
}
private static class Add extends BaseListAddition {
public Add(AssemblyRecipe recipe, List list) {
super("Pneumaticraft Assembly", list, recipe);
}
@Override
public String getRecipeInfo() {
return ((AssemblyRecipe) recipe).getOutput().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillRecipes));
}
@ZenMethod
public static void removeLaserRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.laserRecipes));
}
@ZenMethod
public static void removeLaserDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillLaserRecipes));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack, List list) {
super("Pneumaticraft Assembly", list, stack);
}
@Override
public void apply() {
for (AssemblyRecipe r : (List<AssemblyRecipe>) list) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,75 @@
package modtweaker.mods.pneumaticcraft.handlers;
import static modtweaker.helpers.InputHelper.toStacks;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import pneumaticCraft.api.recipe.PressureChamberRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Pressure")
public class Pressure {
@ZenMethod
public static void addRecipe(IItemStack[] input, double pressure, IItemStack[] output, boolean asBlock) {
MineTweakerAPI.apply(new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock)));
}
private static class Add extends BaseListAddition {
private ItemStack stack;
public Add(PressureChamberRecipe recipe) {
super("Pneumaticraft Pressure Chamber", PressureChamberRecipe.chamberRecipes, recipe);
this.stack = recipe.output[0];
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack[] output) {
MineTweakerAPI.apply(new Remove(toStacks(output)));
}
private static class Remove extends BaseListRemoval {
private final ItemStack[] stacks;
public Remove(ItemStack[] stacks) {
super("Pneumaticraft Pressure Chamber", PressureChamberRecipe.chamberRecipes, stacks[0]);
this.stacks = stacks;
}
@Override
public void apply() {
for (PressureChamberRecipe r : PressureChamberRecipe.chamberRecipes) {
boolean matches = true;
for (int i = 0; i < stacks.length; i++) {
if (!areEqual(stacks[i], r.output[i])) {
matches = false;
break;
}
}
if (matches) {
recipe = r;
break;
}
}
PressureChamberRecipe.chamberRecipes.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,16 @@
package modtweaker.mods.railcraft;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.railcraft.handlers.BlastFurnace;
import modtweaker.mods.railcraft.handlers.CokeOven;
import modtweaker.mods.railcraft.handlers.RockCrusher;
import modtweaker.mods.railcraft.handlers.RollingMachine;
public class Railcraft {
public Railcraft() {
MineTweakerAPI.registerClass(BlastFurnace.class);
MineTweakerAPI.registerClass(CokeOven.class);
MineTweakerAPI.registerClass(RockCrusher.class);
MineTweakerAPI.registerClass(RollingMachine.class);
}
}
@@ -0,0 +1,62 @@
package modtweaker.mods.railcraft;
import java.lang.reflect.Constructor;
import java.util.List;
import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
import mods.railcraft.api.crafting.ICokeOvenRecipe;
import mods.railcraft.api.crafting.IRockCrusherRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fluids.FluidStack;
public class RailcraftHelper {
public static List<? extends IBlastFurnaceRecipe> furnace = null;
public static List<? extends ICokeOvenRecipe> oven = null;
public static List<? extends IRockCrusherRecipe> crusher = null;
public static List<IRecipe> rolling = null;
static {
try {
furnace = RailcraftCraftingManager.blastFurnace.getRecipes();
oven = RailcraftCraftingManager.cokeOven.getRecipes();
crusher = RailcraftCraftingManager.rockCrusher.getRecipes();
rolling = RailcraftCraftingManager.rollingMachine.getRecipeList();
} catch (Exception e) {}
}
private RailcraftHelper() {}
public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output) {
try {
Class clazz = Class.forName("mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager$BlastFurnaceRecipe");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class);
constructor.setAccessible(true);
return (IBlastFurnaceRecipe) constructor.newInstance(input, matchDamage, matchNBT, cookTime, output);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate BlastFurnaceRecipe");
}
}
public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack fluidOutput, int cookTime) {
try {
Class clazz = Class.forName("mods.railcraft.common.util.crafting.CokeOvenCraftingManager$CokeOvenRecipe");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class);
constructor.setAccessible(true);
return (ICokeOvenRecipe) constructor.newInstance(input, matchDamage, matchNBT, output, fluidOutput, cookTime);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate CokeOvenRecipe");
}
}
public static IRockCrusherRecipe getRockCrusherRecipe(ItemStack stack, boolean matchDamage, boolean matchNBT) {
try {
Class clazz = Class.forName("mods.railcraft.common.util.crafting.RockCrusherCraftingManager$CrusherRecipe");
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class);
constructor.setAccessible(true);
return (IRockCrusherRecipe) constructor.newInstance(stack, matchDamage, matchNBT);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate CrusherRecipe");
}
}
}
@@ -0,0 +1,64 @@
package modtweaker.mods.railcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
import modtweaker.mods.railcraft.RailcraftHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.BlastFurnace")
public class BlastFurnace {
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, IItemStack output) {
MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), matchDamage, matchNBT, cookTime, toStack(output))));
}
private static class Add extends BaseListAddition {
public Add(IBlastFurnaceRecipe recipe) {
super("Blast Furnace", RailcraftHelper.furnace, recipe);
}
@Override
public String getRecipeInfo() {
return ((IBlastFurnaceRecipe) recipe).getOutput().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("Blast Furnace", RailcraftHelper.furnace, stack);
}
@Override
public void apply() {
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
if (r != null) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
}
RailcraftHelper.furnace.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,64 @@
package modtweaker.mods.railcraft.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import mods.railcraft.api.crafting.ICokeOvenRecipe;
import modtweaker.mods.railcraft.RailcraftHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.CokeOven")
public class CokeOven {
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) {
MineTweakerAPI.apply(new Add(RailcraftHelper.getCokeOvenRecipe(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime)));
}
private static class Add extends BaseListAddition {
public Add(ICokeOvenRecipe recipe) {
super("Coke Oven", RailcraftHelper.oven, recipe);
}
@Override
public String getRecipeInfo() {
return ((ICokeOvenRecipe) recipe).getOutput().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("Coke Oven", RailcraftHelper.oven, stack);
}
@Override
public void apply() {
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipe = r;
break;
}
}
RailcraftHelper.oven.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,65 @@
package modtweaker.mods.railcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IRockCrusherRecipe;
import modtweaker.mods.railcraft.RailcraftHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.RockCrusher")
public class RockCrusher {
@ZenMethod
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, double[] chances) {
IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT);
for (int i = 0; i < output.length; i++)
recipe.addOutput(toStack(output[i]), (float) chances[i]);
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
public Add(IRockCrusherRecipe recipe) {
super("Rock Crusher", RailcraftHelper.crusher, recipe);
}
@Override
public String getRecipeInfo() {
return ((IRockCrusherRecipe) recipe).getInput().getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Rock Crusher", RailcraftHelper.crusher, stack);
}
@Override
public void apply() {
for (IRockCrusherRecipe r : RailcraftHelper.crusher) {
if (r.getInput() != null && areEqual(r.getInput(), stack)) {
recipe = r;
break;
}
}
RailcraftHelper.crusher.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,57 @@
package modtweaker.mods.railcraft.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toShapedObjects;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import modtweaker.mods.railcraft.RailcraftHelper;
import modtweaker.util.BaseCraftingAddition;
import modtweaker.util.BaseCraftingRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.Rolling")
public class RollingMachine {
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
}
private static class Add extends BaseCraftingAddition {
public Add(boolean shapeless, ItemStack output, Object... recipe) {
super("Rolling Machine", shapeless, RailcraftHelper.rolling, output, recipe);
}
@Override
public void applyShaped() {
RailcraftCraftingManager.rollingMachine.addRecipe(output, recipe);
}
@Override
public void applyShapeless() {
RailcraftCraftingManager.rollingMachine.addShapelessRecipe(output, recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseCraftingRemoval {
public Remove(ItemStack stack) {
super("Rolling Machine", RailcraftHelper.rolling, stack);
}
}
}
@@ -0,0 +1,36 @@
package modtweaker.mods.tconstruct;
import static modtweaker.helpers.LogHelper.logPrinted;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import minetweaker.MineTweakerAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.ToolMaterial;
public class MaterialLogger implements ICommandFunction {
private static ArrayList<String> materials = new ArrayList();
static {
materials = new ArrayList();
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
materials.add(entry.getKey());
}
Collections.sort(materials);
}
@Override
public void execute(String[] arguments, IPlayer player) {
System.out.println("Materials: " + materials.size());
for (String s : materials) {
System.out.println("Material " + s);
MineTweakerAPI.logCommand("<" + s + "> -- ");
}
logPrinted(player);
}
}
@@ -0,0 +1,18 @@
package modtweaker.mods.tconstruct;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.tconstruct.handlers.Casting;
import modtweaker.mods.tconstruct.handlers.Drying;
import modtweaker.mods.tconstruct.handlers.Smeltery;
import modtweaker.mods.tconstruct.handlers.TiCTweaks;
import modtweaker.mods.tconstruct.handlers.ToolStats;
public class TConstruct {
public TConstruct() {
MineTweakerAPI.registerClass(Casting.class);
MineTweakerAPI.registerClass(Drying.class);
MineTweakerAPI.registerClass(Smeltery.class);
MineTweakerAPI.registerClass(TiCTweaks.class);
MineTweakerAPI.registerClass(ToolStats.class);
}
}
@@ -0,0 +1,85 @@
package modtweaker.mods.tconstruct;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mantle.utils.ItemMetaWrapper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.AlloyMix;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.library.crafting.PatternBuilder.ItemKey;
import tconstruct.library.modifier.ItemModifier;
import tconstruct.library.tools.ToolMaterial;
public class TConstructHelper {
public static HashMap<String, Integer> mappings = new HashMap();
public static List<AlloyMix> alloys = null;
public static ArrayList<CastingRecipe> basinCasting = null;
public static ArrayList<CastingRecipe> tableCasting = null;
public static Map<ItemMetaWrapper, FluidStack> smeltingList = null;
public static Map<ItemMetaWrapper, Integer> temperatureList = null;
public static Map<ItemMetaWrapper, ItemStack> renderIndex = null;
public static List<ItemModifier> modifiers = null;
public static List<ItemModifier> modifiers_clone = null;
static {
try {
alloys = tconstruct.library.crafting.Smeltery.getAlloyList();
smeltingList = tconstruct.library.crafting.Smeltery.getSmeltingList();
temperatureList = tconstruct.library.crafting.Smeltery.getTemperatureList();
renderIndex = tconstruct.library.crafting.Smeltery.getRenderIndex();
basinCasting = TConstructRegistry.getBasinCasting().getCastingRecipes();
tableCasting = TConstructRegistry.getTableCasting().getCastingRecipes();
modifiers = ModifyBuilder.instance.itemModifiers;
modifiers_clone = new ArrayList(modifiers);
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
mappings.put(entry.getValue().materialName, entry.getKey());
}
} catch (Exception e) {}
}
private TConstructHelper() {}
public static int getIDFromString(String material) {
if (!mappings.containsKey(material)) {
return -1;
} else return mappings.get(material);
}
//Returns a Drying Recipe, using reflection as the constructor is not visible
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
try {
Constructor constructor = DryingRecipe.class.getDeclaredConstructor(ItemStack.class, int.class, ItemStack.class);
constructor.setAccessible(true);
return (DryingRecipe) constructor.newInstance(input, time, output);
} catch (Exception e) {
e.printStackTrace();
throw new NullPointerException("Failed to instantiate DryingRecipe");
}
}
public static String getMaterialFromID(int id) {
return TConstructRegistry.toolMaterials.get(id).materialName;
}
public static ItemKey getItemKey(Item item, int damage, int value, String material) {
try {
Constructor constructor = ItemKey.class.getDeclaredConstructor(ItemStack.class, int.class, int.class, String.class);
constructor.setAccessible(true);
return (ItemKey) constructor.newInstance(item, damage, value, material);
} catch (Exception e) {
e.printStackTrace();
throw new NullPointerException("Failed to instantiate ItemKey");
}
}
}
@@ -0,0 +1,83 @@
package modtweaker.mods.tconstruct.handlers;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker.mods.tconstruct.TConstructHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.CastingRecipe;
@ZenClass("mods.tconstruct.Casting")
public class Casting {
//Adding a TConstruct Casting recipe
@ZenMethod
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
}
@ZenMethod
public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(CastingRecipe recipe, ArrayList list) {
super("TConstruct Casting", list, recipe);
}
@Override
public String getRecipeInfo() {
return ((CastingRecipe) recipe).output.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Casting recipe
@ZenMethod
public static void removeBasinRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.basinCasting));
}
@ZenMethod
public static void removeTableRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.tableCasting));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack output, ArrayList list) {
super("TConstruct Casting", list, output);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (CastingRecipe r : (ArrayList<CastingRecipe>) list) {
if (r.output != null && areEqual(r.output, stack)) {
recipe = r;
break;
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,71 @@
package modtweaker.mods.tconstruct.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.tconstruct.TConstructHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.DryingRackRecipes;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
@ZenClass("mods.tconstruct.Drying")
public class Drying {
//Adding a TConstruct Drying Rack recipe
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int time) {
MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
public Add(DryingRecipe recipe) {
super("TConstruct Drying Rack", DryingRackRecipes.recipes, recipe);
}
@Override
public String getRecipeInfo() {
return ((DryingRecipe) recipe).result.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Drying Rack recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output))));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
public Remove(ItemStack output) {
super("TConstruct Drying Rack", DryingRackRecipes.recipes, output);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (DryingRecipe r : (ArrayList<DryingRecipe>) list) {
if (r.result != null && areEqual(r.result, stack)) {
recipe = r;
break;
}
}
list.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,40 @@
package modtweaker.mods.tconstruct.handlers;
import java.util.List;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.tconstruct.TConstructHelper;
import modtweaker.util.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.modifier.ItemModifier;
@ZenClass("mods.tconstruct.Modifiers")
public class Modifiers {
@ZenMethod
public static void remove(String mod) {
MineTweakerAPI.apply(new Remove(mod));
}
//Searches through the modifiers and removes the first valid entry
private static class Remove extends BaseListRemoval {
private final String check;
public Remove(String check) {
super("Modifier", TConstructHelper.modifiers);
this.check = check;
}
@Override
public void apply() {
for (ItemModifier m : (List<ItemModifier>) list) {
if (m.key.equals(check)) {
recipe = m;
break;
}
}
list.remove(recipe);
}
}
}
@@ -0,0 +1,195 @@
package modtweaker.mods.tconstruct.handlers;
import static modtweaker.helpers.InputHelper.isABlock;
import static modtweaker.helpers.InputHelper.toFluid;
import static modtweaker.helpers.InputHelper.toFluids;
import static modtweaker.helpers.InputHelper.toStack;
import java.util.ArrayList;
import java.util.Arrays;
import mantle.utils.ItemMetaWrapper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.oredict.IOreDictEntry;
import modtweaker.mods.tconstruct.TConstructHelper;
import modtweaker.util.BaseDescriptionAddition;
import modtweaker.util.BaseDescriptionRemoval;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.AlloyMix;
@ZenClass("mods.tconstruct.Smeltery")
public class Smeltery {
/********************************************** TConstruct Alloy Recipes **********************************************/
//Adding a TConstruct Alloy recipe
@ZenMethod
public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList<FluidStack>(Arrays.asList(toFluids(input))))));
}
//Passes the list to the base list implementation, and adds the recipe
private static class AddAlloy extends BaseListAddition {
public AddAlloy(AlloyMix recipe) {
super("Smeltery - Alloy", TConstructHelper.alloys, recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyMix) recipe).result.getFluid().getName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Alloy recipe
@ZenMethod
public static void removeAlloy(ILiquidStack output) {
MineTweakerAPI.apply(new RemoveAlloy((toFluid(output))));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class RemoveAlloy extends BaseListRemoval {
public RemoveAlloy(FluidStack output) {
super("Smeltery - Alloy", TConstructHelper.alloys, output);
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (AlloyMix r : TConstructHelper.alloys) {
if (r.result != null && r.result.isFluidStackIdentical(fluid)) {
recipe = r;
break;
}
}
TConstructHelper.alloys.remove(recipe);
}
@Override
public String getRecipeInfo() {
return fluid.getFluid().getName();
}
}
/********************************************** TConstruct Melting Recipes **********************************************/
//Adding a TConstruct Melting recipe
@ZenMethod
public static void addMelting(IItemStack input, ILiquidStack output, int temp, @Optional IItemStack block) {
if (block == null) block = input;
if (isABlock(block)) {
Block theBlock = Block.getBlockFromItem(toStack(block).getItem());
int theMeta = toStack(block).getItemDamage();
MineTweakerAPI.apply(new AddMelting(toStack(input), theBlock, theMeta, temp, toFluid(output)));
}
}
@ZenMethod
public static void addMelting(IOreDictEntry input, ILiquidStack output, int temp, @Optional IItemStack block) {
for (ItemStack stack : OreDictionary.getOres(input.getName())) {
addMelting(MineTweakerMC.getIItemStack(stack), output, temp, block);
}
}
//Takes all the variables and saves them in place
private static class AddMelting extends BaseDescriptionAddition {
private final ItemStack input;
private final Block block;
private final int meta;
private final int temp;
private final FluidStack output;
public AddMelting(ItemStack input, Block block, int meta, int temp, FluidStack output) {
super("Smeltery - Melting");
this.input = input;
this.block = block;
this.meta = meta;
this.temp = temp;
this.output = output;
}
//Adds the Melting recipe
@Override
public void apply() {
tconstruct.library.crafting.Smeltery.instance.addMelting(input, block, meta, temp, output);
}
//Removes the Melting recipe from the hashmaps
@Override
public void undo() {
ItemMetaWrapper in = new ItemMetaWrapper(input);
TConstructHelper.smeltingList.remove(in);
TConstructHelper.temperatureList.remove(in);
TConstructHelper.renderIndex.remove(in);
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Melting recipe
@ZenMethod
public static void removeMelting(IItemStack input) {
MineTweakerAPI.apply(new RemoveMelting((toStack(input))));
}
@ZenMethod
public static void removeMelting(IOreDictEntry input) {
for (ItemStack stack : OreDictionary.getOres(input.getName())) {
removeMelting(MineTweakerMC.getIItemStack(stack));
}
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class RemoveMelting extends BaseDescriptionRemoval {
private final ItemStack input;
private FluidStack fluid;
private Integer temp;
private ItemStack renderer;
public RemoveMelting(ItemStack input) {
super("Smeltery - Melting");
this.input = input;
}
//Gets the current values, and saves, them removes them from the hashmaps
@Override
public void apply() {
ItemMetaWrapper in = new ItemMetaWrapper(input);
fluid = TConstructHelper.smeltingList.get(in);
temp = TConstructHelper.temperatureList.get(in);
renderer = TConstructHelper.renderIndex.get(in);
TConstructHelper.smeltingList.remove(in);
TConstructHelper.temperatureList.remove(in);
TConstructHelper.renderIndex.remove(in);
}
//Readds the Melting recipe
@Override
public void undo() {
tconstruct.library.crafting.Smeltery.instance.addMelting(input, Block.getBlockFromItem(renderer.getItem()), renderer.getItemDamage(), temp, fluid);
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
}
}
}
@@ -0,0 +1,151 @@
package modtweaker.mods.tconstruct.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.tconstruct.TConstructHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import modtweaker.util.BaseSetVar;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.crafting.PatternBuilder.ItemKey;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;
@ZenClass("mods.tconstruct.Tweaks")
public class TiCTweaks {
//Set the maximum RF
@ZenMethod
public static void setRFCapacity(String tool, int capacity) {
MineTweakerAPI.apply(new AdjustRF(tool, capacity));
}
private static class AdjustRF extends BaseSetVar {
public AdjustRF(String tool, int newValue) {
super("RF Maximum for Tinkers Tools", ToolCore.class, ReflectionHelper.getStaticObject(TinkerTools.class, tool), "capacity", 400000, newValue);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** Disabling for 0.5, will do this properly for 0.6 **/
//Tweaks for enabling / disabling Patterns
/* @ZenMethod
public static void removePattern(IItemStack stack) {
MineTweakerAPI.apply(new DisablePattern(toStack(stack)));
}
private static class DisablePattern implements IUndoableAction {
private String key;
private MaterialSet set;
private List list;
private ItemStack stack;
private final ItemStack disable;
public DisablePattern(ItemStack disable) {
this.disable = disable;
}
//Loops through the pattern mappings to find an entry with the same material name
@Override
public void apply() {
for (Entry<List, ItemStack> entry : TConstructRegistry.patternPartMapping.entrySet()) {
ItemStack check = entry.getValue();
if (check.isItemEqual(disable)) {
list = entry.getKey();
stack = entry.getValue();
break;
}
}
TConstructRegistry.patternPartMapping.remove(list);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
TConstructRegistry.patternPartMapping.put(list, stack);
}
@Override
public String describe() {
return "Disabling creation of the pattern for: " + disable.getDisplayName();
}
@Override
public String describeUndo() {
return "Enabling creation of the pattern for: " + disable.getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
} */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRepairMaterial(IItemStack stack, String material, int value) {
ItemStack input = toStack(stack);
MineTweakerAPI.apply(new Add(TConstructHelper.getItemKey(input.getItem(), input.getItemDamage(), value, material)));
}
//Tweaks for setting repair materials
private static class Add extends BaseListAddition {
public Add(ItemKey recipe) {
super("Repair Material", PatternBuilder.instance.materials, recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((ItemKey) recipe).item, 1, ((ItemKey) recipe).damage).getDisplayName();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRepairMaterial(IItemStack output, @Optional String material) {
MineTweakerAPI.apply(new Remove(toStack(output), material));
}
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
private final String material;
public Remove(ItemStack stack, String material) {
super("Repair Material", PatternBuilder.instance.materials, stack);
this.material = material;
}
//Loops through the registry, to find the item that matches, saves that recipe then removes it
@Override
public void apply() {
for (ItemKey r : PatternBuilder.instance.materials) {
ItemStack clone = new ItemStack(r.item, 1, r.damage);
if ((material != null && material.equalsIgnoreCase(r.key)) || (material == null)) {
if (clone.isItemEqual(stack)) {
recipe = r;
break;
}
}
}
PatternBuilder.instance.materials.remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,246 @@
package modtweaker.mods.tconstruct.handlers;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import modtweaker.helpers.ReflectionHelper;
import modtweaker.mods.tconstruct.TConstructHelper;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.ArrowMaterial;
import tconstruct.library.tools.BowMaterial;
import tconstruct.library.tools.ToolMaterial;
@ZenClass("mods.tconstruct.ToolStats")
public class ToolStats {
@ZenMethod
public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, String ability) {
if (name == null) name = material + " ";
MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, ability)));
}
@ZenMethod
public static void setDisplayName(String material, String name) {
MineTweakerAPI.apply(new SetToolStats(material, "displayName", name));
}
@ZenMethod
public static void setHarvestLevel(String material, int value) {
MineTweakerAPI.apply(new SetToolStats(material, "harvestLevel", value));
}
@ZenMethod
public static void setDurability(String material, int value) {
MineTweakerAPI.apply(new SetToolStats(material, "durability", value));
}
@ZenMethod
public static void setSpeed(String material, int value) {
MineTweakerAPI.apply(new SetToolStats(material, "miningspeed", value));
}
@ZenMethod
public static void setDamage(String material, int value) {
MineTweakerAPI.apply(new SetToolStats(material, "attack", value));
}
@ZenMethod
public static void setHandleModifier(String material, double value) {
MineTweakerAPI.apply(new SetToolStats(material, "handleModifier", (float) value));
}
@ZenMethod
public static void setReinforcedLevel(String material, int value) {
MineTweakerAPI.apply(new SetToolStats(material, "reinforced", value));
}
@ZenMethod
public static void setStoneboundLevel(String material, double value) {
MineTweakerAPI.apply(new SetToolStats(material, "stonebound", (float) value));
}
@ZenMethod
public static void setStyle(String material, String name) {
MineTweakerAPI.apply(new SetToolStats(material, "tipStyle", name));
}
@ZenMethod
public static void setAbility(String material, String name) {
MineTweakerAPI.apply(new SetToolStats(material, "ability", name));
}
//Sets various variables with reflection, making my life partially easier :D
private static class SetToolStats implements IUndoableAction {
protected int id;
protected Object old;
protected Object fresh;
protected final String material;
protected final String field;
protected final Object value;
public SetToolStats(String material, String field, Object value) {
this.material = material;
this.field = field;
this.value = value;
}
@Override
public void apply() {
old = TConstructRegistry.toolMaterialStrings.get(material);
id = TConstructHelper.getIDFromString(material);
if (id != -1 && old != null) {
if (value instanceof ToolMaterial) {
fresh = (ToolMaterial) value;
} else {
ToolMaterial t = (ToolMaterial) old;
fresh = new ToolMaterial(t.materialName, t.displayName, t.harvestLevel, t.durability, t.miningspeed, t.attack, t.handleModifier, t.reinforced, t.stonebound, t.tipStyle, t.ability);
ReflectionHelper.setPrivateValue(ToolMaterial.class, fresh, field, value);
}
TConstructRegistry.toolMaterials.put(id, (ToolMaterial) fresh);
TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) fresh);
}
}
@Override
public boolean canUndo() {
return TConstructRegistry.toolMaterialStrings != null && id != -1 && old != null;
}
@Override
public void undo() {
TConstructRegistry.toolMaterials.put(id, (ToolMaterial) old);
TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) old);
}
@Override
public String describe() {
return "Changing material stats field : + " + field + " for " + material;
}
@Override
public String describeUndo() {
return "Undoing change of material stats field : + " + field + " for " + material;
}
@Override
public Object getOverrideKey() {
return null;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//Bow Stats
@ZenMethod
public static void setBowStats(String material, int durability, int drawspeed, double flightspeed) {
MineTweakerAPI.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed)));
}
@ZenMethod
public static void setBowDurability(String material, int value) {
MineTweakerAPI.apply(new SetBowStats(material, "durability", value));
}
@ZenMethod
public static void setBowDrawspeed(String material, int value) {
MineTweakerAPI.apply(new SetBowStats(material, "drawspeed", value));
}
@ZenMethod
public static void setBowFlightSpeed(String material, double value) {
MineTweakerAPI.apply(new SetBowStats(material, "flightSpeedMax", (float) value));
}
// Bow Stats
private static class SetBowStats extends SetToolStats {
public SetBowStats(String material, String field, Object value) {
super(material, field, value);
}
@Override
public void apply() {
id = TConstructHelper.getIDFromString(material);
old = TConstructRegistry.bowMaterials.get(id);
if (id != -1 && old != null) {
if (value instanceof BowMaterial) {
fresh = (BowMaterial) value;
} else {
BowMaterial b = (BowMaterial) old;
fresh = new BowMaterial(b.durability, b.drawspeed, b.flightSpeedMax);
ReflectionHelper.setPrivateValue(BowMaterial.class, fresh, field, value);
}
TConstructRegistry.bowMaterials.put(id, (BowMaterial) fresh);
}
}
@Override
public boolean canUndo() {
return TConstructRegistry.bowMaterials != null && id != -1 && old != null;
}
@Override
public void undo() {
TConstructRegistry.bowMaterials.put(id, (BowMaterial) old);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//Arrow Stats
@ZenMethod
public static void setArrowStats(String material, double mass, double breakChance, double accuracy) {
MineTweakerAPI.apply(new SetArrowStats(material, "", new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy)));
}
@ZenMethod
public static void setArrowMass(String material, double value) {
MineTweakerAPI.apply(new SetArrowStats(material, "mass", (float) value));
}
@ZenMethod
public static void setArrowBreakChance(String material, double value) {
MineTweakerAPI.apply(new SetArrowStats(material, "breakChance", (float) value));
}
@ZenMethod
public static void setArrowAccuracy(String material, double value) {
MineTweakerAPI.apply(new SetArrowStats(material, "accuracy", (float) value));
}
// Bow Stats
private static class SetArrowStats extends SetToolStats {
public SetArrowStats(String material, String field, Object value) {
super(material, field, value);
}
@Override
public void apply() {
id = TConstructHelper.getIDFromString(material);
old = TConstructRegistry.arrowMaterials.get(id);
if (id != -1 && old != null) {
if (value instanceof ArrowMaterial) {
fresh = (ArrowMaterial) value;
} else {
ArrowMaterial a = (ArrowMaterial) old;
fresh = new ArrowMaterial(a.mass, a.breakChance, a.accuracy);
ReflectionHelper.setPrivateValue(ArrowMaterial.class, fresh, field, value);
}
TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) fresh);
}
}
@Override
public boolean canUndo() {
return TConstructRegistry.arrowMaterials != null && id != -1 && old != null;
}
@Override
public void undo() {
TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) old);
}
}
}
@@ -0,0 +1,21 @@
package modtweaker.mods.thaumcraft;
import minetweaker.MineTweakerAPI;
import modtweaker.mods.thaumcraft.handlers.Arcane;
import modtweaker.mods.thaumcraft.handlers.Aspects;
import modtweaker.mods.thaumcraft.handlers.Crucible;
import modtweaker.mods.thaumcraft.handlers.Infusion;
import modtweaker.mods.thaumcraft.handlers.Research;
import modtweaker.mods.thaumcraft.handlers.Warp;
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);
}
}
@@ -0,0 +1,63 @@
package modtweaker.mods.thaumcraft;
import java.util.ArrayList;
import java.util.HashMap;
import modtweaker.helpers.ReflectionHelper;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchCategories;
public class ThaumcraftHelper {
public static ArrayList recipes = null;
public static HashMap<Object, Integer> warpList;
static {
try {
recipes = ReflectionHelper.getStaticObject(ThaumcraftApi.class, "recipes");
warpList = ReflectionHelper.getStaticObject(ThaumcraftApi.class, "warpMap");
} catch (Exception e) {}
}
private ThaumcraftHelper() {}
public static AspectList parseAspects(String aspects) {
return parseAspects(new AspectList(), aspects);
}
public static AspectList parseAspects(AspectList list, String str) {
if (list == null) list = new AspectList();
if (str == null || str.equals("")) return list;
String[] aspects = str.split(",");
for (String aspect : aspects) {
if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", "");
String[] aspct = aspect.split("\\s+");
if (aspct.length == 2) list.add(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1]));
}
return list;
}
public static AspectList removeAspects(AspectList list, String str) {
String[] aspects = str.split(",");
for (String aspect : aspects) {
if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", "");
String[] aspct = aspect.split("\\s+");
if (aspct.length == 2) {
list.remove(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1]));
}
}
return list;
}
public static String getResearchTab(String key) {
for (String tab : ResearchCategories.researchCategories.keySet()) {
for (String research : ResearchCategories.researchCategories.get(tab).research.keySet()) {
if (research.equals(key)) return tab;
}
}
return null;
}
}
@@ -0,0 +1,79 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toObjects;
import static modtweaker.helpers.InputHelper.toShapedObjects;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.crafting.IArcaneRecipe;
import thaumcraft.api.crafting.ShapedArcaneRecipe;
import thaumcraft.api.crafting.ShapelessArcaneRecipe;
@ZenClass("mods.thaumcraft.Arcane")
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))));
}
@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))));
}
private static class Add extends BaseListAddition {
public Add(IArcaneRecipe recipe) {
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), recipe);
}
@Override
public String getRecipeInfo() {
Object out = ((IArcaneRecipe) recipe).getRecipeOutput();
if (out instanceof ItemStack) {
return ((ItemStack) out).getDisplayName();
} else return super.getRecipeInfo();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
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 IArcaneRecipe) {
IArcaneRecipe r = (IArcaneRecipe) o;
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
recipe = r;
break;
}
}
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,111 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import java.util.Arrays;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import modtweaker.util.BaseDescriptionAddition;
import modtweaker.util.BaseDescriptionRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.ThaumcraftApiHelper;
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));
}
@ZenMethod
public static void set(IItemStack stack, String aspects) {
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;
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 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();
}
}
//////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IItemStack stack, String aspects) {
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;
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 boolean canUndo() {
return oldList != null;
}
@Override
public void undo() {
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,68 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toObject;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
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))));
}
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();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
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;
}
}
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -0,0 +1,175 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import static modtweaker.helpers.InputHelper.toStacks;
import static modtweaker.helpers.StackHelper.areEqual;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import modtweaker.mods.thaumcraft.recipe.MTInfusionRecipe;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.crafting.InfusionEnchantmentRecipe;
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))));
}
//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)));
}
@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))));
}
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();
}
}
private static class AddEnchant implements IUndoableAction {
InfusionEnchantmentRecipe recipe;
public AddEnchant(InfusionEnchantmentRecipe inp) {
recipe = inp;
}
@Override
public void apply() {
ThaumcraftApi.getCraftingRecipes().add(recipe);
}
@Override
public String describe() {
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public boolean canUndo() {
return recipe != null;
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String describeUndo() {
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
}
@Override
public String getOverrideKey() {
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
@ZenMethod
public static void removeEnchant(int id) {
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
}
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;
}
}
}
ThaumcraftApi.getCraftingRecipes().remove(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
private static class RemoveEnchant implements IUndoableAction {
Enchantment enchant;
InfusionEnchantmentRecipe removed;
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 String describe() {
return "Removing Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public boolean canUndo() {
return removed != null;
}
@Override
public void undo() {
ThaumcraftApi.getCraftingRecipes().add(removed);
}
@Override
public String describeUndo() {
return "Restoring Infusion Enchantment Recipe: " + enchant.getName();
}
@Override
public String getOverrideKey() {
return null;
}
}
}
@@ -0,0 +1,199 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.player.IPlayer;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import modtweaker.mods.thaumcraft.research.AddPage;
import modtweaker.mods.thaumcraft.research.AddPrereq;
import modtweaker.mods.thaumcraft.research.AddResearch;
import modtweaker.mods.thaumcraft.research.AddSibling;
import modtweaker.mods.thaumcraft.research.AddTab;
import modtweaker.mods.thaumcraft.research.ClearPages;
import modtweaker.mods.thaumcraft.research.ClearPrereqs;
import modtweaker.mods.thaumcraft.research.ClearSiblings;
import modtweaker.mods.thaumcraft.research.Difficulty;
import modtweaker.mods.thaumcraft.research.MoveResearch;
import modtweaker.mods.thaumcraft.research.OrphanResearch;
import modtweaker.mods.thaumcraft.research.RefreshResearch;
import modtweaker.mods.thaumcraft.research.RemoveResearch;
import modtweaker.mods.thaumcraft.research.RemoveTab;
import modtweaker.mods.thaumcraft.research.SetAspects;
import modtweaker.mods.thaumcraft.research.SetResearch;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.api.research.ResearchItem;
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");
@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);
}
private static void addTab(String key, ResourceLocation icon, ResourceLocation background) {
MineTweakerAPI.apply(new AddTab(key, icon, background));
}
@ZenMethod
public static void removeTab(String tab) {
MineTweakerAPI.apply(new RemoveTab(tab));
}
@ZenMethod
public static void removeResearch(String research) {
MineTweakerAPI.apply(new RemoveResearch(research));
}
@ZenMethod
public static void orphanResearch(String research) {
MineTweakerAPI.apply(new OrphanResearch(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 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 addPage(String key, String unlocalized) {
MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized));
}
@ZenMethod
public static void addCraftingPage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item)));
}
@ZenMethod
public static void addCruciblePage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_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 addInfusionPage(String key, IItemStack item) {
MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_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 clearPages(String key) {
MineTweakerAPI.apply(new ClearPages(key));
}
@ZenMethod
public static void addPrereq(String key, String req, @Optional boolean hidden) {
MineTweakerAPI.apply(new AddPrereq(key, req, hidden));
}
@ZenMethod
public static void clearPrereqs(String key) {
MineTweakerAPI.apply(new ClearPrereqs(key));
}
@ZenMethod
public static void addSibling(String key, String sibling) {
MineTweakerAPI.apply(new AddSibling(key, sibling));
}
@ZenMethod
public static void clearSiblings(String key) {
MineTweakerAPI.apply(new ClearSiblings(key));
}
@ZenMethod
public static void setRound(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND));
}
@ZenMethod
public static void setSpikey(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE));
}
@ZenMethod
public static void setStub(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB));
}
@ZenMethod
public static void setSecondary(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY));
}
@ZenMethod
public static void setVirtual(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL));
}
@ZenMethod
public static void setAutoUnlock(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO));
}
@ZenMethod
public static void setConcealed(String key, boolean flag) {
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL));
}
@ZenMethod
public static void setAspects(String key, String aspects) {
MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects)));
}
@ZenMethod
public static void setComplexity(String key, int complexity) {
MineTweakerAPI.apply(new Difficulty(key, complexity));
}
@ZenMethod
public static void refreshResearchRecipe(String key) {
MineTweakerAPI.apply(new RefreshResearch(key));
}
@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
}
}
@@ -0,0 +1,209 @@
package modtweaker.mods.thaumcraft.handlers;
import static modtweaker.helpers.InputHelper.toStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker.mods.thaumcraft.ThaumcraftHelper;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
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 addToItem(IItemStack stack, int warp) {
MineTweakerAPI.apply(new Add(toStack(stack), warp));
}
private static class Add implements IUndoableAction {
Object target;
int warp;
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 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 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 Object getOverrideKey() {
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFromResearch(String key) {
MineTweakerAPI.apply(new Remove(key));
}
@ZenMethod
public static void removeFromItem(IItemStack stack) {
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeAll() {
MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH));
}
@ZenMethod
public static void removeAllResearch() {
MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH));
}
@ZenMethod
public static void removeAllItems() {
MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS));
}
private static class Remove implements IUndoableAction {
Object target;
int warp;
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 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 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 Object getOverrideKey() {
return null;
}
}
public static enum RemoveType {
RESEARCH, ITEMS, BOTH
}
private static class MassRemove implements IUndoableAction {
HashMap<Object, Integer> oldMap = new HashMap<Object, Integer>();
RemoveType type;
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 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 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 Object getOverrideKey() {
return null;
}
}
}
@@ -0,0 +1,63 @@
package modtweaker.mods.thaumcraft.recipe;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.crafting.InfusionRecipe;
public class MTInfusionRecipe extends InfusionRecipe {
private final boolean fuzzyCentre;
private final boolean[] fuzzyRecipe;
public MTInfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, ItemStack[] recipe, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
super(research, output, inst, aspects2, input, recipe);
this.fuzzyCentre = fuzzyCentre;
this.fuzzyRecipe = fuzzyRecipe;
}
@Override
public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) {
if (getRecipeInput() == null) return false;
if (research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
return false;
}
ItemStack i2 = central.copy();
if (getRecipeInput().getItemDamage() == OreDictionary.WILDCARD_VALUE) {
i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
}
if (!areItemStacksEqual(i2, getRecipeInput(), fuzzyCentre)) return false;
ArrayList<ItemStack> ii = new ArrayList<ItemStack>();
for (ItemStack is : input) {
ii.add(is.copy());
}
for (int j = 0; j < getComponents().length; j++) {
ItemStack comp = getComponents()[j];
boolean b = false;
for (int a = 0; a < ii.size(); a++) {
i2 = ii.get(a).copy();
if (comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
}
if (areItemStacksEqual(i2, comp, fuzzyRecipe[j])) {
ii.remove(a);
b = true;
break;
}
}
if (!b) return false;
}
return ii.size() == 0 ? true : false;
}
}
Loaded 100 of 276 files, more files were not shown because too many files have changed in this diff. Show more