Merge pull request #181 from Zixxl/master

Little rework
This commit is contained in:
Jared committed 2015-07-13 22:12:51 +02:00
commit e467dcff94
140 files changed
+7726 -4404

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "0.8.3"
version = "0.9.0"
group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ModTweaker~2"
@@ -4,11 +4,8 @@ import static modtweaker2.helpers.LogHelper.print;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+34 -3
View File
@@ -4,18 +4,26 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.commands.EntityMappingLogger;
import modtweaker2.mods.auracascade.aura.AuraLogger;
import modtweaker2.mods.appeng.commands.AppliedEnergisticsLogger;
import modtweaker2.mods.auracascade.commands.AuraLogger;
import modtweaker2.mods.botania.commands.BotaniaBrewLogger;
import modtweaker2.mods.botania.commands.BotaniaLogger;
import modtweaker2.mods.botania.commands.BotaniaOrechidLogger;
import modtweaker2.mods.botania.lexicon.commands.LexiconCategoryLogger;
import modtweaker2.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
import modtweaker2.mods.botania.lexicon.commands.LexiconPageLogger;
import modtweaker2.mods.chisel.commands.ChiselGroupLogger;
import modtweaker2.mods.chisel.commands.ChiselVariationLogger;
import modtweaker2.mods.mekanism.gas.GasLogger;
import modtweaker2.mods.exnihilo.commands.ExNihiloLogger;
import modtweaker2.mods.factorization.commands.FactorizationLogger;
import modtweaker2.mods.mekanism.commands.GasLogger;
import modtweaker2.mods.mekanism.commands.MekanismLogger;
import modtweaker2.mods.railcraft.commands.RailcraftLogger;
import modtweaker2.mods.tconstruct.MaterialLogger;
import modtweaker2.mods.tconstruct.commands.TConstructLogger;
import modtweaker2.mods.thaumcraft.commands.AspectLogger;
import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger;
import modtweaker2.mods.thermalexpansion.commands.ThermalExpansionLogger;
import modtweaker2.utils.TweakerPlugin;
public class Commands {
@@ -31,9 +39,14 @@ public class Commands {
});
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
if (TweakerPlugin.isLoaded("appliedenergistics2-core")) {
MineTweakerAPI.server.addMineTweakerCommand("ae2", new String[] {"/minetweaker ae2 [FILTER]", " Outputs a list of all Applied Energistics 2 recipes."}, new AppliedEnergisticsLogger());
}
if (TweakerPlugin.isLoaded("Mekanism")) {
MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger());
MineTweakerAPI.server.addMineTweakerCommand("mekanism", new String[] { "/minetweaker mekanism [FILTER]", " Outputs a list of all Mekanism recipes." }, new MekanismLogger());
}
if (TweakerPlugin.isLoaded("Thaumcraft")) {
@@ -43,6 +56,7 @@ public class Commands {
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());
MineTweakerAPI.server.addMineTweakerCommand("tconstruct", new String[]{ "/minetweaker tconstruct [FILTER]", " Outputs a list of all Tinkers Construct recipes."}, new TConstructLogger());
}
if (TweakerPlugin.isLoaded("Botania")) {
@@ -51,17 +65,34 @@ public class Commands {
MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger());
MineTweakerAPI.server.addMineTweakerCommand("botania", new String[] { "/minetweaker botania [FILTER]", " Outputs a list of all Botania recipes." }, new BotaniaLogger());
}
if (TweakerPlugin.isLoaded("chisel")) {
MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger());
MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger());
}
if (TweakerPlugin.isLoaded("aura")) {
MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger());
}
}
if (TweakerPlugin.isLoaded("ThermalExpansion")) {
MineTweakerAPI.server.addMineTweakerCommand("texpansion", new String[] {"/minetweaker texpansion [FILTER]", " Outputs a list of all Thermal Expansion recipes."}, new ThermalExpansionLogger());
}
if (TweakerPlugin.isLoaded("factorization")) {
MineTweakerAPI.server.addMineTweakerCommand("factorization", new String[] {"/minetweaker factorization [FILTER]", " Outputs a list of all Factorization recipes."}, new FactorizationLogger());
}
if (TweakerPlugin.isLoaded("Railcraft")) {
MineTweakerAPI.server.addMineTweakerCommand("railcraft", new String[] {"/minetweaker railcraft [FILTER]", " Outputs a list of all Railcraft recipes."}, new RailcraftLogger());
}
if (TweakerPlugin.isLoaded("exnihilo")) {
MineTweakerAPI.server.addMineTweakerCommand("exnihilo", new String[] {"/minetweaker exnihilo [FILTER]", " Outputs a list of all ExNihilo recipes."}, new ExNihiloLogger());
}
}
}
public static void registerMineTweakerCommand(String commandName, String[] usages, ICommandFunction commandFunction) {
+1 -1
View File
@@ -4,6 +4,6 @@ public class ModProps {
public static final String NAME = "Mod Tweaker 2", name = NAME;
public static final String MODID = "modtweaker2", modid = MODID;
public static final String VERSION = "0.8.3", version = VERSION;
public static final String VERSION = "0.9.0", version = VERSION;
public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES;
}
@@ -2,10 +2,8 @@ package modtweaker2;
import java.io.File;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
import minetweaker.mc1710.MineTweakerMod;
import minetweaker.runtime.providers.ScriptProviderDirectory;
import minetweaker.util.IEventHandler;
import modtweaker2.mods.appeng.AppliedEnergistics;
@@ -14,8 +14,11 @@ public class EntityMappingLogger implements ICommandFunction {
@Override
public void execute(String[] arguments, IPlayer player) {
Set<Integer> keys = EntityList.stringToIDMapping.keySet();
@SuppressWarnings("unchecked")
Set<Integer> keys = EntityList.stringToIDMapping.keySet();
System.out.println("Mob Keys: " + keys.size());
for (Integer key : keys) {
ModTweaker2.logger.info("Mob Key " + EntityList.getStringFromID(key) + " : " + key);
MineTweakerAPI.logCommand("Mob Key " + EntityList.getStringFromID(key) + " : " + key);
@@ -1,11 +1,13 @@
package modtweaker2.helpers;
import java.lang.reflect.Constructor;
import static modtweaker2.helpers.ReflectionHelper.getConstructor;
import static modtweaker2.helpers.ReflectionHelper.getFinalObject;
import static modtweaker2.helpers.ReflectionHelper.getInstance;
import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static modtweaker2.helpers.ReflectionHelper.*;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
@@ -16,7 +18,9 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class ForgeHelper {
@SuppressWarnings("rawtypes")
public static Map translate = null;
@SuppressWarnings("rawtypes")
public static List seeds = null;
public static HashMap<String, ChestGenHooks> loot = null;
@@ -25,23 +29,25 @@ public class ForgeHelper {
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) {}
} catch (Exception e) { }
}
private ForgeHelper() {}
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) {
Object seedEntry = getInstance(getConstructor("net.minecraftforge.common.ForgeHooks$SeedEntry",
ItemStack.class, int.class), stack, weight);
if (seedEntry == null) {
throw new NullPointerException("Failed to instantiate SeedEntry");
}
return seedEntry;
}
public static boolean isLangActive(String lang) {
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null : FMLClientHandler.instance().getCurrentLanguage().equals(lang);
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null
: FMLClientHandler.instance().getCurrentLanguage().equals(lang);
}
}
@@ -1,13 +1,15 @@
package modtweaker2.helpers;
import java.lang.reflect.Array;
import java.util.ArrayList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.entity.IEntity;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.mc1710.item.MCItemStack;
import minetweaker.mc1710.liquid.MCLiquidStack;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@@ -18,12 +20,26 @@ 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");
LogHelper.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 <T> T[][] getMultiDimensionalArray(Class<T> clazz, T[] array, int height, int width) {
@SuppressWarnings("unchecked")
T[][] multiDim = (T[][])Array.newInstance(clazz, new int[] {height, width});
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
multiDim[y][x] = array[x + (y * width)];
}
}
return multiDim;
}
public static IItemStack[] toStacks(IIngredient[] iIngredient) {
ArrayList<IItemStack> stacks = new ArrayList<IItemStack>();
for (IIngredient ing : iIngredient) {
@@ -52,12 +68,39 @@ public class InputHelper {
else {
Object internal = iStack.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.getLogger().logError("Not a valid item stack: " + iStack);
LogHelper.logError("Not a valid item stack: " + iStack);
}
return (ItemStack) internal;
}
}
public static IIngredient toIngredient(ItemStack stack) {
return toIItemStack(stack);
}
public static IIngredient toIngredient(FluidStack stack) {
if(stack == null)
return null;
return new MCLiquidStack(stack);
}
public static IItemStack toIItemStack(ItemStack stack) {
if(stack == null) {
return null;
}
return new MCItemStack(stack);
}
public static ILiquidStack toILiquidStack(FluidStack stack) {
if(stack == null) {
return null;
}
return new MCLiquidStack(stack);
}
public static ItemStack[] toStacks(IItemStack[] iStack) {
if (iStack == null)
@@ -101,7 +144,8 @@ public class InputHelper {
}
}
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
if (ingredients == null)
return null;
else {
@@ -1,8 +1,22 @@
package modtweaker2.helpers;
import java.util.Arrays;
import java.util.List;
import mekanism.api.gas.GasStack;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.mc1710.data.NBTConverter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
public class LogHelper {
public static void logPrinted(IPlayer player) {
@@ -21,4 +35,157 @@ public class LogHelper {
System.out.println(string);
MineTweakerAPI.logCommand(string);
}
public static void logError(String message) {
MineTweakerAPI.logError("[ModTweaker2] " + message);
}
public static void logError(String message, Throwable exception) {
MineTweakerAPI.logError("[ModTweaker2] " + message, exception);
}
public static void logWarning(String message) {
MineTweakerAPI.logWarning("[ModTweaker2] " + message);
}
public static void logInfo(String message) {
MineTweakerAPI.logInfo("[ModTweaker2] " + message);
}
/**
* Returns a string representation of the item which can also be used in scripts
*/
public static String getStackDescription(Object object) {
if(object instanceof ItemStack) {
return getStackDescription((ItemStack)object);
} else if (object instanceof FluidStack) {
return getStackDescription((FluidStack)object);
} else if (object instanceof GasStack) {
return getStackDescription((GasStack)object);
} else if (object instanceof String) {
// Check if string specifies an oredict entry
List<ItemStack> ores = OreDictionary.getOres((String)object);
if(!ores.isEmpty()) {
return "<ore:" + (String)object + ">";
} else {
return "\"" + (String)object + "\"";
}
} else if (object != null) {
return "\"" + object.toString() + "\"";
} else {
return "null";
}
}
public static String getStackDescription(ItemStack stack) {
StringBuilder sb = new StringBuilder();
// Creates a name like <minecraft:piston> or <appliedenergistics2:item.ItemMultiMaterial:156>
sb.append('<');
sb.append(Item.itemRegistry.getNameForObject(stack.getItem()));
if(stack.getItemDamage() == 32767) {
sb.append(":*");
} else if (stack.getItemDamage() > 0) {
sb.append(":").append(stack.getItemDamage());
}
sb.append('>');
// Do we have a tag? (e.g. <Botania:specialFlower>.withTag({}) )
if(stack.getTagCompound() != null)
{
sb.append(".withTag(");
sb.append(NBTConverter.from(stack.getTagCompound(), true));
sb.append(')');
}
// Do we have a stack size > 1?
if(stack.stackSize > 1) {
sb.append(" * ").append(stack.stackSize);
}
return sb.toString();
}
public static String getStackDescription(FluidStack stack) {
StringBuilder sb = new StringBuilder();
sb.append("<liquid:").append(stack.getFluid().getName()).append('>');
if(stack.amount > 1) {
sb.append(" * ").append(stack.amount);
}
return sb.toString();
}
public static String getStackDescription(GasStack stack) {
StringBuilder sb = new StringBuilder();
sb.append("<gas:").append(stack.getGas().getName()).append('>');
if(stack.amount > 1) {
sb.append(" * ").append(stack.amount);
}
return sb.toString();
}
public static String getListDescription(List<?> objects) {
StringBuilder sb = new StringBuilder();
if(objects.isEmpty()) {
sb.append("[]");
} else {
sb.append('[');
for(Object object : objects) {
if(object instanceof List) {
sb.append(getListDescription((List)object)).append(", ");
} else if(object instanceof Object[]) {
sb.append(getListDescription(Arrays.asList((Object[])object))).append(", ");
} else {
sb.append(getStackDescription(object)).append(", ");
}
}
sb.setLength(sb.length() - 2);
sb.append(']');
}
return sb.toString();
}
public static String getCraftingDescription(IRecipe recipe) {
if(recipe instanceof ShapelessOreRecipe)
return LogHelper.getCraftingDescription((ShapelessOreRecipe)recipe);
else if(recipe instanceof ShapedOreRecipe)
return LogHelper.getCraftingDescription((ShapedOreRecipe)recipe);
else if(recipe instanceof ShapelessRecipes)
return LogHelper.getCraftingDescription((ShapelessRecipes)recipe);
else if(recipe instanceof ShapedRecipes)
return LogHelper.getCraftingDescription((ShapedRecipes)recipe);
return recipe.toString();
}
public static String getCraftingDescription(ShapelessOreRecipe recipe) {
return getListDescription(recipe.getInput());
}
public static String getCraftingDescription(ShapelessRecipes recipe) {
return getListDescription(recipe.recipeItems);
}
public static String getCraftingDescription(ShapedOreRecipe recipe) {
int height = ReflectionHelper.<Integer>getObject(recipe, "width");
int width = ReflectionHelper.<Integer>getObject(recipe, "height");
Object[][] recipes = InputHelper.getMultiDimensionalArray(Object.class, recipe.getInput(), height, width);
return getListDescription(Arrays.asList(recipes));
}
public static String getCraftingDescription(ShapedRecipes recipe) {
ItemStack[][] recipes = InputHelper.getMultiDimensionalArray(ItemStack.class, recipe.recipeItems, recipe.recipeHeight, recipe.recipeWidth);
return getListDescription(Arrays.asList(recipes));
}
}
@@ -5,67 +5,156 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class ReflectionHelper {
public static Constructor getConstructor(String string, Class... types) {
/**
* Creates a new instance with the provided constructor and arguments.
* @param constructor The constructor of the class for which a new instance should be created.
* @param arguments Array of objects to be passed as arguments to the constructor call.
* @return A new object created by calling the constructor.
*/
public static <T> T getInstance(Constructor<T> constructor, Object... arguments) {
try {
Class clazz = Class.forName(string);
Constructor constructor = clazz.getDeclaredConstructor(types);
return constructor.newInstance(arguments);
} catch (Exception e) { LogHelper.logError("Exception creating instance of " + constructor.getClass().getName(), e); }
return null;
}
/**
* Obtains the constructor for the named class identified by the parameter types.
* @param className The fully qualified name of the class.
* @param argumentTypes Parameter types to identify the constructor.
* @return Constructor object representing the declared constructor for the parameter types.
*/
public static Constructor<?> getConstructor(final String className, final Class<?>... argumentTypes) {
if(className == null || argumentTypes == null) {
LogHelper.logError("The provided class name or arguments can't be null.");
return null;
}
try {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getDeclaredConstructor(argumentTypes);
constructor.setAccessible(true);
return constructor;
} catch (Exception ex) {}
} catch (Exception ex) { LogHelper.logError("Exception getting constructor of " + className, ex); }
return null;
}
/**
* Obtains the constructor for the class identified by the parameter types.
* @param clazz The Class for which the constructor should be obtained.
* @param argumentTypes Parameter types to identify the constructor.
* @return Constructor object representing the declared constructor for the parameter types.
*/
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... types) {
try {
Constructor<T> constructor = clazz.getDeclaredConstructor(types);
constructor.setAccessible(true);
return constructor;
} catch (Exception ex) { LogHelper.logError("Exception getting constructore of " + clazz.getName(), ex); }
return null;
}
public static <T> T getObject(Object o, String... fieldName) {
Class cls = o.getClass();
for (String field : fieldName) {
/**
* Returns the value of a private field for an object instance.
* @param object An object instance from which the field value is to be extracted.
* @param fieldNames A list of field names for which the value should be extracted.
* The functions returns value of the first field found.
* @return The value of the provided field name.
*/
@SuppressWarnings("unchecked")
public static <T> T getObject(Object object, String... fieldNames) {
Class<?> cls = object.getClass();
for (String field : fieldNames) {
try {
Field result = cls.getDeclaredField(field);
result.setAccessible(true);
return (T) result.get(o);
return (T) result.get(object);
} catch (Exception ex) {}
}
LogHelper.logError("Could not retrieve any object for the provided field names.");
return null;
}
public static <T> T getFinalObject(Object o, String... fieldName) {
Class cls = o.getClass();
for (String field : fieldName) {
/**
* Returns the value of a private final field for an object instance and removes the final modifier.
* @param object An object instance from which the field value is to be extracted.
* @param fieldNames A list of field names for which the value should be extracted.
* The functions returns value of the first field found.
* @return The value of the provided field name.
*/
@SuppressWarnings("unchecked")
public static <T> T getFinalObject(Object object, String... fieldNames) {
Class<?> cls = object.getClass();
for (String field : fieldNames) {
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);
return (T) result.get(object);
} catch (Exception ex) {}
}
LogHelper.logError("Could not retrieve any final object for the provided field names.");
return null;
}
public static <T> T getStaticObject(Class cls, String... fieldName) {
for (String field : fieldName) {
/**
* Returns the value of a private static field for a class.
* @param clazz The class for which the field value is to be extracted.
* @param fieldNames A list of field names for which the value should be extracted.
* @return The value of the provided field name.
*/
@SuppressWarnings("unchecked")
public static <T> T getStaticObject(Class<?> clazz, String... fieldNames) {
for (String field : fieldNames) {
try {
Field result = cls.getDeclaredField(field);
Field result = clazz.getDeclaredField(field);
result.setAccessible(true);
return (T) result.get(null);
} catch (Exception e) {}
}
LogHelper.logError("Could not retrieve any static object for the provided field names.");
return null;
}
/**
* Returns the value of a private static field for a class.
* @param className The fully qualified name of the class.
* @param fieldNames A list of field names for which the value should be extracted.
* @return The value of the provided field name.
*/
public static <T> T getStaticObject(String className, String... fieldNames) {
try {
Class<?> clazz = Class.forName(className);
return getStaticObject(clazz, fieldNames);
} catch (ClassNotFoundException e) { }
LogHelper.logError("Could not retrieve any static object for the provided field names.");
return null;
}
public static void setPrivateValue(Class cls, String field, int var) {
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) {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void setPrivateValue( Class cls, Object o, String field, Object var) {
cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(cls, o, var, field);
}
}
@@ -1,19 +1,129 @@
package modtweaker2.helpers;
//import modtweaker2.mods.botania.Botania;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.botania.Botania;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.TweakerPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
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)
/**
* Compares two ItemStack instances, trying to match the referenced item.
*/
public static boolean areEqual(ItemStack stack1, ItemStack stack2) {
if (stack1 == 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);
} else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack1) && Botania.isSubtile(stack2)) {
return Botania.subtileMatches(stack1, stack2);
} else {
return stack1.isItemEqual(stack2);
}
}
public static boolean areEqual(FluidStack stack1, FluidStack stack2) {
if(stack1 == null || stack2 == null) {
return false;
}
return stack1.isFluidEqual(stack2);
}
/**
* Compares two ItemStack instances if they reference the same object or
* are both null. If false, the method areEqual() is called to check if the
* two instances reference the same item.
*/
public static boolean areEqualOrNull(ItemStack stack1, ItemStack stack2) {
// Check if they reference the same object or are are both null
if(stack1 == stack2) {
return true;
}
return(areEqual(stack1, stack2));
}
public static boolean areEqualOrNull(FluidStack stack1, FluidStack stack2) {
// Check if they reference the same object or are are both null
if(stack1 == stack2) {
return true;
}
return(areEqual(stack1, stack2));
}
/**
* Adds extra check to IIngredient matches() for Botania special flowers
*/
public static boolean matches(IIngredient ingredient, IItemStack itemStack) {
if(ingredient == null) {
return false;
}
if(!ingredient.matches(itemStack)) {
return false;
}
// Check for Botania special flowers
if(ingredient.getItems() != null && Botania.isSubtile(toStack(itemStack))) {
for(IItemStack item : ingredient.getItems()) {
if(areEqual(toStack(item), toStack(itemStack))) {
return true;
}
}
} else {
return true;
}
return false;
}
/**
* This function compares an ingredient with a fluid. MCLiquidStack.matches() function
* is currently broken in MineTweaker3, thus this function is only a workaround.
*/
public static boolean matches(IIngredient ingredient, ILiquidStack liquidStack) {
if(ingredient == null) {
return false;
}
// Do we have a wildcard (<*>) ?
if(ingredient.matches(liquidStack)) {
return true;
}
// Does ingredient reference liquids?
if(ingredient.getLiquids() != null) {
for (ILiquidStack liquid : ingredient.getLiquids()) {
if(InputHelper.toFluid(liquid).isFluidEqual(InputHelper.toFluid(liquidStack))) {
return true;
}
}
}
return false;
}
public static boolean matches(IIngredient ingredient, IGasStack gasStack) {
if(ingredient == null) {
return false;
}
if(ingredient == IngredientAny.INSTANCE) {
return true;
}
if(ingredient instanceof IGasStack) {
return MekanismHelper.toGas((IGasStack)ingredient).isGasEqual(MekanismHelper.toGas(gasStack));
}
return false;
}
}
@@ -0,0 +1,34 @@
package modtweaker2.helpers;
import java.util.List;
import java.util.ListIterator;
public class StringHelper {
public static List<String> toLowerCase(List<String> stringList) {
ListIterator<String> iterator = stringList.listIterator();
while(iterator.hasNext()) {
iterator.set(iterator.next().toLowerCase());
}
return stringList;
}
public static String join(List<String> list, String conjunction) {
StringBuilder sb = new StringBuilder();
if(conjunction == null) {
conjunction = ", ";
}
if(list != null && !list.isEmpty()) {
for(String string : list) {
sb.append(string).append(conjunction);
}
sb.setLength(sb.length() - conjunction.length());
}
return sb.toString();
}
}
@@ -9,7 +9,5 @@ public class AppliedEnergistics {
public AppliedEnergistics() {
MineTweakerAPI.registerClass(Inscriber.class);
MineTweakerAPI.registerClass(Grind.class);
}
}
@@ -0,0 +1,77 @@
package modtweaker2.mods.appeng;
import static modtweaker2.helpers.StackHelper.areEqualOrNull;
import net.minecraft.item.ItemStack;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
public class AppliedEnergisticsHelper {
/**
* Compares two IInscriberRecipe objects, if they are the same or have the same inputs
*/
public static boolean equals(IInscriberRecipe r1, IInscriberRecipe r2) {
if(r1 == r2) {
return true;
}
if (r1 == null || r2 == null) {
return false;
}
if(!areEqualOrNull(r1.getTopOptional().orNull(), r2.getTopOptional().orNull())) {
return false;
}
if(!areEqualOrNull(r1.getBottomOptional().orNull(), r2.getBottomOptional().orNull())) {
return false;
}
if(r1.getInputs() == null && r2.getInputs() != null || r1.getInputs() != null && r2.getInputs() == null) {
return false;
}
if(r1.getInputs() != null && r2.getInputs() != null) {
if(r1.getInputs().size() != r2.getInputs().size()) {
return false;
}
// Check if every item in recipe 1 is in recipe 2
for(ItemStack i1 : r1.getInputs()) {
boolean found = false;
for(ItemStack i2 : r2.getInputs()) {
if(areEqualOrNull(i1, i2)) {
found = true;
}
}
if(!found) {
return false;
}
}
}
return true;
}
/**
* Compares two IGrinderEntry objects, if they are the same or have the same inputs
*/
public static boolean equals(IGrinderEntry r1, IGrinderEntry r2) {
if(r1 == r2) {
return true;
}
if (r1 == null || r2 == null) {
return false;
}
if(!areEqualOrNull(r1.getInput(), r2.getInput())) {
return false;
}
return true;
}
}
@@ -0,0 +1,64 @@
package modtweaker2.mods.appeng.commands;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StringHelper;
import appeng.api.AEApi;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
public class AppliedEnergisticsLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("grinder");
validArguments.add("inscriber");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("grinder")) {
for(IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes()) {
MineTweakerAPI.logCommand(String.format("mods.appeng.Grinder.addRecipe(%s, %s, %d, %s, %s, %s, %s);",
LogHelper.getStackDescription(recipe.getInput()),
LogHelper.getStackDescription(recipe.getOutput()),
recipe.getEnergyCost(),
LogHelper.getStackDescription(recipe.getOptionalOutput()),
recipe.getOptionalChance(),
LogHelper.getStackDescription(recipe.getSecondOptionalOutput()),
recipe.getSecondOptionalChance()));
}
}
if(args.isEmpty() || args.contains("inscriber")) {
for(IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
MineTweakerAPI.logCommand(String.format("mods.appeng.Inscriber.addRecipe(%s, %s, %s, %s, \"%s\");",
LogHelper.getListDescription(recipe.getInputs()),
LogHelper.getStackDescription(recipe.getTopOptional().orNull()),
LogHelper.getStackDescription(recipe.getBottomOptional().orNull()),
LogHelper.getStackDescription(recipe.getOutput()),
recipe.getProcessType().toString()));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,14 +1,20 @@
package modtweaker2.mods.appeng.handlers;
import java.util.ArrayList;
import java.util.List;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.appeng.AppliedEnergisticsHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import appeng.api.AEApi;
@@ -17,49 +23,93 @@ import appeng.core.features.registries.entries.AppEngGrinderRecipe;
@ZenClass("mods.appeng.Grinder")
public class Grind {
protected static final String name = "Applied Energistics 2 Grinder";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
// Create recipe
IGrinderEntry recipe;
if(output2 != null && output3 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), InputHelper.toStack(output3), chance2, chance3, energy);
else if(output2 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), chance2, energy);
else
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy);
// Check if the recipe is already present, we don't want to add duplicates
for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<IGrinderEntry> {
public Add(IGrinderEntry recipe) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo(IGrinderEntry recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
@Override
protected boolean equals(IGrinderEntry recipe, IGrinderEntry otherRecipe) {
return AppliedEnergisticsHelper.equals(recipe, otherRecipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int energy) {
MineTweakerAPI.apply(new Add(new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy)));
public static void removeRecipe(IIngredient output) {
if(output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
// Get list of existing recipes, matching with parameter
LinkedList<IGrinderEntry> result = new LinkedList<IGrinderEntry>();
for(IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, output.toString()));
}
}
private static class Add extends BaseListAddition {
public Add(AppEngGrinderRecipe recipe) {
super(AEApi.instance().registries().grinder().getRecipes(), recipe);
private static class Remove extends BaseListRemoval<IGrinderEntry> {
public Remove(LinkedList<IGrinderEntry> recipes) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes(), recipes);
}
@Override
public void apply() {
AEApi.instance().registries().grinder().getRecipes().add((AppEngGrinderRecipe) recipe);
public String getRecipeInfo(IGrinderEntry recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Applied Energistics 2 Grinder", AEApi.instance().registries().grinder().getRecipes(), stack);
}
@Override
public void apply() {
for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
if (r.getOutput().isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
}
}
@@ -1,77 +1,160 @@
package modtweaker2.mods.appeng.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.appeng.AppliedEnergisticsHelper;
import modtweaker2.utils.ArrayUtils;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import appeng.api.AEApi;
import appeng.api.features.IInscriberRecipe;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;
import appeng.recipes.handlers.Inscribe;
@ZenClass("mods.appeng.Inscriber")
public class Inscriber {
protected static final String name = "Applied Energistics 2 Inscriber";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) {
MineTweakerAPI.apply(new Add(new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type))));
for (IItemStack stack : imprintable) {
AEApi.instance().registries().inscriber().getInputs().add(toStack(stack));
}
if (plateA != null)
AEApi.instance().registries().inscriber().getOptionals().add(toStack(plateA));
if (plateB != null)
AEApi.instance().registries().inscriber().getOptionals().add(toStack(plateB));
if(imprintable == null || out == null || (!type.equals("Press") || !type.equals("Inscribe"))) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name));
return;
}
// Create recipe
IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type));
// Check if the recipe is already present, we don't want to add duplicates
for(IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Inscriber.name, LogHelper.getStackDescription(toStack(out))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
public static class Add extends BaseListAddition {
public static class Add extends BaseListAddition<IInscriberRecipe> {
public Add(IInscriberRecipe recipe) {
super(recipe.toString(), AEApi.instance().registries().inscriber().getRecipes(), recipe);
super(Inscriber.name, AEApi.instance().registries().inscriber().getRecipes());
recipes.add(recipe);
}
@Override
public void apply() {
AEApi.instance().registries().inscriber().addRecipe((IInscriberRecipe) recipe);
}
if(recipes.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : recipes) {
try {
AEApi.instance().registries().inscriber().addRecipe(recipe);
successful.add(recipe);
} catch (Exception ex) { LogHelper.logError("Error adding inscriber recipe.", ex); }
}
}
@Override
public void undo() {
if(successful.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : successful) {
try {
AEApi.instance().registries().inscriber().removeRecipe(recipe);
} catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); }
}
}
@Override
public String getRecipeInfo(IInscriberRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
protected boolean equals(IInscriberRecipe recipe, IInscriberRecipe otherRecipe) {
return AppliedEnergisticsHelper.equals(recipe, otherRecipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
if(output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name));
return;
}
// Get list of existing recipes, matching with parameter
LinkedList<IInscriberRecipe> result = new LinkedList<IInscriberRecipe>();
for(IInscriberRecipe entry : AEApi.instance().registries().inscriber().getRecipes()) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Inscriber.name, output.toString()));
}
}
public static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Applied Energistics 2 Inscriber", AEApi.instance().registries().inscriber().getRecipes(), stack);
}
@Override
public void apply() {
for (IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
if (recipe != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) {
recipes.add(recipe);
}
}
super.apply();
public static class Remove extends BaseListRemoval<IInscriberRecipe> {
public Remove(LinkedList<IInscriberRecipe> recipes) {
super(Inscriber.name, AEApi.instance().registries().inscriber().getRecipes(), recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
@Override
public void apply() {
if(this.recipes.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : recipes) {
try {
AEApi.instance().registries().inscriber().removeRecipe(recipe);
successful.add(recipe);
} catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); }
}
}
@Override
public void undo() {
if(successful.isEmpty()) {
return;
}
for(IInscriberRecipe recipe : successful) {
try {
AEApi.instance().registries().inscriber().addRecipe(recipe);
} catch (Exception ex) { LogHelper.logError("Error restoring inscriber recipe.", ex); }
}
}
@Override
public String getRecipeInfo(IInscriberRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -2,8 +2,6 @@ package modtweaker2.mods.auracascade.aura;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
@@ -56,8 +54,8 @@ public class AuraBracketHandler implements IBracketHandler {
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
// }
//StringBuilder valueBuilder = new StringBuilder();
for (EnumAura a : EnumAura.values()) {
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
@@ -1,14 +1,11 @@
package modtweaker2.mods.auracascade.aura;
package modtweaker2.mods.auracascade.commands;
import java.util.Set;
import pixlepix.auracascade.data.EnumAura;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.ModTweaker2;
import net.minecraft.entity.EntityList;
import pixlepix.auracascade.data.EnumAura;
public class AuraLogger implements ICommandFunction {
@@ -1,16 +1,19 @@
package modtweaker2.mods.auracascade.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.auracascade.AuraCascadeHelper;
import modtweaker2.mods.auracascade.aura.IAuraStack;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import pixlepix.auracascade.data.recipe.PylonRecipe;
import pixlepix.auracascade.data.recipe.PylonRecipeComponent;
import pixlepix.auracascade.data.recipe.PylonRecipeRegistry;
@@ -19,7 +22,11 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.auraCascade.Pylon")
public class Pylon {
protected static final String name = "Aura Cascade Pylon";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) {
addRecipe(ouput, stack, input, stack, input, stack, input, stack, input);
@@ -27,37 +34,53 @@ public class Pylon {
@ZenMethod
public static void addRecipe(IItemStack ouput, IAuraStack aura1, IItemStack input1, IAuraStack aura2, IItemStack input2, IAuraStack aura3, IItemStack input3, IAuraStack aura4, IItemStack input4) {
MineTweakerAPI.apply(new Add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4)))));
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
recipes.add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4))));
MineTweakerAPI.apply(new Add(recipes));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<PylonRecipe> {
public Add(PylonRecipe recipe) {
super(PylonRecipeRegistry.recipes, recipe);
public Add(List<PylonRecipe> recipes) {
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
}
@Override
protected String getRecipeInfo(PylonRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack ouput) {
MineTweakerAPI.apply(new Remove(toStack(ouput)));
public static void removeRecipe(IIngredient output) {
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
if (output.matches(toIItemStack(r.result))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Pylon.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super(PylonRecipeRegistry.recipes, stack);
}
@Override
public void apply() {
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
if (r.result.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<PylonRecipe> {
public Remove(List<PylonRecipe> recipes) {
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
}
@Override
protected String getRecipeInfo(PylonRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
}
@@ -0,0 +1,83 @@
package modtweaker2.mods.botania.commands;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StringHelper;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeElvenTrade;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
public class BotaniaLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("apothecary");
validArguments.add("elventrade");
validArguments.add("manainfusion");
validArguments.add("runealtar");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("apothecary")) {
for(RecipePetals recipe : BotaniaAPI.petalRecipes) {
MineTweakerAPI.logCommand(String.format("mods.botania.Apothecary.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.getOutput()),
LogHelper.getListDescription(recipe.getInputs()) // Need to resolve "petalXXX" to an item
));
}
}
if(args.isEmpty() || args.contains("elventrade")) {
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
MineTweakerAPI.logCommand(String.format("mods.botania.ElvenTrade.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.getOutput()),
LogHelper.getListDescription(recipe.getInputs()
)));
}
}
if(args.isEmpty() || args.contains("manainfusion")) {
for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
MineTweakerAPI.logCommand(String.format("mods.botania.ManaInfusion.add%s(%s, %s, %d);",
recipe.isAlchemy() ? "Alchemy" : recipe.isConjuration() ? "Conjuration" : "Infusion",
LogHelper.getStackDescription(recipe.getOutput()),
LogHelper.getStackDescription(recipe.getInput()),
recipe.getManaToConsume()
));
}
}
if(args.isEmpty() || args.contains("runealtar")) {
for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) {
MineTweakerAPI.logCommand(String.format("mods.botania.RuneAltar.addRecipe(%s, %s, %d);",
LogHelper.getStackDescription(recipe.getOutput()),
LogHelper.getListDescription(recipe.getInputs()),
recipe.getManaUsage()
));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,14 +1,19 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -17,6 +22,11 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
@ZenClass("mods.botania.Apothecary")
public class Apothecary {
protected static final String name = "Botania Petal";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(toStack(output), toObjects(input))));
@@ -24,50 +34,55 @@ public class Apothecary {
@ZenMethod
public static void addRecipe(String output, IIngredient[] input) {
MineTweakerAPI.apply(new Add(new RecipePetals(ItemBlockSpecialFlower.ofType(output), toObjects(input))));
addRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)), input);
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipePetals> {
public Add(RecipePetals recipe) {
super("Botania Petal Recipe", BotaniaAPI.petalRecipes, recipe);
super("Botania Petal", BotaniaAPI.petalRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipePetals) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipePetals recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<RecipePetals> result = new LinkedList<RecipePetals>();
for(RecipePetals entry : BotaniaAPI.petalRecipes) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Apothecary.name, output.toString()));
}
}
@ZenMethod
public static void removeRecipe(String output) {
MineTweakerAPI.apply(new Remove(ItemBlockSpecialFlower.ofType(output)));
removeRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)));
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Petal recipe", BotaniaAPI.petalRecipes, stack);
private static class Remove extends BaseListRemoval<RecipePetals> {
public Remove(List<RecipePetals> recipes) {
super(Apothecary.name, BotaniaAPI.petalRecipes, recipes);
}
@Override
public void apply() {
for (RecipePetals r : BotaniaAPI.petalRecipes) {
if (areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipePetals recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,19 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -16,47 +21,57 @@ import vazkii.botania.api.recipe.RecipeElvenTrade;
@ZenClass("mods.botania.ElvenTrade")
public class ElvenTrade {
protected static final String name = "Botania Eleven Trade";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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 {
private static class Add extends BaseListAddition<RecipeElvenTrade> {
public Add(RecipeElvenTrade recipe) {
super("Botania Eleven Trade", BotaniaAPI.elvenTradeRecipes, recipe);
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeElvenTrade) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeElvenTrade recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
LinkedList<RecipeElvenTrade> recipes = new LinkedList<RecipeElvenTrade>();
for(RecipeElvenTrade entry : BotaniaAPI.elvenTradeRecipes) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
recipes.add(entry);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Elven Trade", BotaniaAPI.elvenTradeRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeElvenTrade> {
public Remove(List<RecipeElvenTrade> recipes) {
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes, recipes);
}
@Override
public void apply() {
for (RecipeElvenTrade r : BotaniaAPI.elvenTradeRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeElvenTrade recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,19 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObject;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -17,6 +22,9 @@ import vazkii.botania.api.recipe.RecipeManaInfusion;
@ZenClass("mods.botania.ManaInfusion")
public class ManaInfusion {
protected static final String name = "Botania Mana Infusion";
@ZenMethod
public static void addInfusion(IItemStack output, IIngredient input, int mana) {
MineTweakerAPI.apply(new Add(new RecipeManaInfusion(toStack(output), toObject(input), mana)));
@@ -36,42 +44,47 @@ public class ManaInfusion {
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeManaInfusion> {
public Add(RecipeManaInfusion recipe) {
super("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, recipe);
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeManaInfusion) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeManaInfusion recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
List<RecipeManaInfusion> recipes = new LinkedList<RecipeManaInfusion>();
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ManaInfusion.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Mana Infusion", BotaniaAPI.manaInfusionRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeManaInfusion> {
public Remove(List<RecipeManaInfusion> recipes) {
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes, recipes);
}
@Override
public void apply() {
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeManaInfusion recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,14 +1,19 @@
package modtweaker2.mods.botania.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@@ -16,47 +21,58 @@ import vazkii.botania.api.recipe.RecipeRuneAltar;
@ZenClass("mods.botania.RuneAltar")
public class RuneAltar {
protected static final String name = "Botania Rune Altar";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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 {
private static class Add extends BaseListAddition<RecipeRuneAltar> {
public Add(RecipeRuneAltar recipe) {
super("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, recipe);
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeRuneAltar) recipe).getOutput().getDisplayName();
public String getRecipeInfo(RecipeRuneAltar recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
// Get list of existing recipes, matching with parameter
List<RecipeRuneAltar> recipes = new LinkedList<RecipeRuneAltar>();
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Botania Rune Altar", BotaniaAPI.runeAltarRecipes, stack);
private static class Remove extends BaseListRemoval<RecipeRuneAltar> {
public Remove(List<RecipeRuneAltar> recipes) {
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes, recipes);
}
@Override
public void apply() {
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
if (r.getOutput() != null && areEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(RecipeRuneAltar recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -0,0 +1,13 @@
package modtweaker2.mods.exnihilo;
import java.util.Map;
import modtweaker2.helpers.ReflectionHelper;
import exnihilo.registries.HeatRegistry;
import exnihilo.utils.ItemInfo;
public class ExNihiloHelper {
public static Map<ItemInfo, Float> getHeatMap() {
return ReflectionHelper.<Map<ItemInfo, Float>>getStaticObject(HeatRegistry.class, "heatmap");
}
}
@@ -0,0 +1,99 @@
package modtweaker2.mods.exnihilo.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StringHelper;
import modtweaker2.mods.exnihilo.ExNihiloHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import exnihilo.registries.CompostRegistry;
import exnihilo.registries.CrucibleRegistry;
import exnihilo.registries.HammerRegistry;
import exnihilo.registries.SieveRegistry;
import exnihilo.registries.helpers.Compostable;
import exnihilo.registries.helpers.Meltable;
import exnihilo.registries.helpers.SiftingResult;
import exnihilo.registries.helpers.Smashable;
import exnihilo.utils.ItemInfo;
public class ExNihiloLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("compost");
validArguments.add("crucible");
validArguments.add("hammer");
validArguments.add("sieve");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("compost")) {
for(Entry<ItemInfo, Compostable> recipe : CompostRegistry.entries.entrySet()) {
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Composting.addRecipe(%s, %s, \"%s\");",
LogHelper.getStackDescription(recipe.getKey().getStack()),
recipe.getValue().value,
Integer.toHexString(recipe.getValue().color.toInt()).substring(2)));
}
}
if(args.isEmpty() || args.contains("crucible")) {
for(Meltable recipe : CrucibleRegistry.entries.values()) {
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addRecipe(%s, %s);",
LogHelper.getStackDescription(new ItemStack(recipe.block, 1, recipe.meta)),
LogHelper.getStackDescription(new FluidStack(recipe.fluid, (int)recipe.fluidVolume))));
}
for(Entry<ItemInfo, Float> recipe : ExNihiloHelper.getHeatMap().entrySet()) {
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addHeatSource(%s, %s);",
LogHelper.getStackDescription(recipe.getKey().getStack()),
recipe.getValue()));
}
}
if(args.isEmpty() || args.contains("hammer")) {
for(Entry<ItemInfo, ArrayList<Smashable>> entry : HammerRegistry.getRewards().entrySet()) {
for(Smashable recipe : entry.getValue()) {
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Hammer.addRecipe(%s, %s, %s, %s);",
LogHelper.getStackDescription(entry.getKey().getStack()),
LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)),
recipe.chance,
recipe.luckMultiplier));
}
}
}
if(args.isEmpty() || args.contains("sieve")) {
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : SieveRegistry.getSiftables().entrySet()) {
for(SiftingResult recipe : entry.getValue()) {
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Sieve.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(entry.getKey().getStack()),
LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)),
recipe.rarity));
}
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,117 +1,92 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
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;
import exnihilo.utils.ItemInfo;
@ZenClass("mods.exnihilo.Composting")
public class Compost {
//Adding a Ex Nihilo Composting recipe
public static final String name = "ExNihilo Composting";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, double value, @Optional String hex) {
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
MineTweakerAPI.apply(new Add(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 implements IUndoableAction
{
private Item item;
private int meta;
private float value;
private Color color;
public Add(Item item, int meta, float value, Color color) {
this.item = item;
this.meta = meta;
this.value = value;
this.color = color;
if(input == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
Map<ItemInfo, Compostable> recipes = new HashMap<ItemInfo, Compostable>();
recipes.put(
new ItemInfo(toStack(input)),
new Compostable(Math.min(1.0F, (float)value), new Color(hex)));
MineTweakerAPI.apply(new Add(recipes));
}
private static class Add extends BaseMapAddition<ItemInfo, Compostable> {
public Add(Map<ItemInfo, Compostable> recipes) {
super(Compost.name, CompostRegistry.entries, recipes);
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, Compostable> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack());
}
@Override
public void apply() {
CompostRegistry.register(item, meta, value, color);
}
@Override
public boolean canUndo() {
return false;
}
@Override
public String describe() {
return "Adding Composting Recipe using " + item.getUnlocalizedName();
}
@Override
public String describeUndo() {
return null;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public void undo() {
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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 implements IUndoableAction
{
private ItemStack stack;
public Remove(ItemStack stack) {
this.stack = stack;
public static void removeRecipe(IIngredient input) {
Map<ItemInfo, Compostable> recipes = new HashMap<ItemInfo, Compostable>();
for(Entry<ItemInfo, Compostable> recipe : CompostRegistry.entries.entrySet()) {
if(matches(input, toIItemStack(recipe.getKey().getStack()))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipes found for %s. Command ignored!", Compost.name, input.toString()));
}
}
private static class Remove extends BaseMapRemoval<ItemInfo, Compostable> {
public Remove(Map<ItemInfo, Compostable> recipes) {
super(Compost.name, CompostRegistry.entries, recipes);
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, Compostable> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack());
}
@Override
public void apply() {
CompostRegistry.unregister(stack.getItem(), stack.getItemDamage());
}
@Override
public boolean canUndo() {
return false;
}
@Override
public String describe() {
return "Removing Composting Recipe using " + stack.getUnlocalizedName();
}
@Override
public String describeUndo() {
return null;
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public void undo() {
}
}
}
@@ -2,44 +2,74 @@ package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.IUndoableAction;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.exnihilo.ExNihiloHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.CrucibleRegistry;
import exnihilo.registries.HeatRegistry;
import exnihilo.registries.helpers.Meltable;
import exnihilo.utils.ItemInfo;
@ZenClass("mods.exnihilo.Crucible")
public class Crucible {
public static final String nameMelting = "ExNihilo Crucible (Melting)";
public static final String nameHeatSource = "ExNihilo Crucible (Heat source)";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/************************************************ 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)));
if(input == null || fluid == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting));
return;
}
if(!isABlock(input)) {
LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting));
return;
}
Map<String, Meltable> recipes = new HashMap<String, Meltable>();
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
recipes.put(
theBlock + ":" + theMeta,
new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock));
MineTweakerAPI.apply(new AddRecipe(recipes));
}
//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);
private static class AddRecipe extends BaseMapAddition<String, Meltable> {
public AddRecipe(Map<String, Meltable> recipes) {
super(nameMelting, CrucibleRegistry.entries, recipes);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((Meltable) recipe).block, 1, ((Meltable) recipe).meta).getDisplayName();
protected String getRecipeInfo(Entry<String, Meltable> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getValue().block, 1, recipe.getValue().meta));
}
}
@@ -47,21 +77,32 @@ public class Crucible {
//Removing a Ex Nihilo Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (isABlock(output)) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
public static void removeRecipe(IIngredient output) {
Map<String, Meltable> recipes = new HashMap<String, Meltable>();
for(Entry<String, Meltable> entry : CrucibleRegistry.entries.entrySet()) {
FluidStack fluid = new FluidStack(entry.getValue().fluid, (int)entry.getValue().fluidVolume);
if(matches(output, toILiquidStack(fluid))) {
recipes.put(entry.getKey(), entry.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveRecipe(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString()));
}
}
//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);
private static class RemoveRecipe extends BaseMapRemoval<String, Meltable> {
public RemoveRecipe(Map<String, Meltable> recipes) {
super(nameMelting, CrucibleRegistry.entries, recipes);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
protected String getRecipeInfo(Entry<String, Meltable> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getValue().block, 1, recipe.getValue().meta));
}
}
@@ -69,92 +110,67 @@ public class Crucible {
//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(theBlock, theMeta, (float) value));
if(input == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting));
return;
}
if(!isABlock(input)) {
LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting));
return;
}
Map<ItemInfo, Float> recipes = new HashMap<ItemInfo, Float>();
recipes.put(new ItemInfo(toStack(input)), (float)value);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new AddHeatSource(recipes));
}
}
//Passes the list to the base map implementation, and adds the recipe
private static class AddHeatSource implements IUndoableAction
private static class AddHeatSource extends BaseMapAddition<ItemInfo, Float>
{
Block source;
int sourceMeta;
float value;
public AddHeatSource(Block source, int sourceMeta, float value) {
this.source = source;
this.sourceMeta = sourceMeta;
this.value = value;
public AddHeatSource(Map<ItemInfo, Float> recipes) {
super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes);
}
public void apply() {
HeatRegistry.register(source, sourceMeta, value);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Adding ExNihilo Heat source of " + source.getLocalizedName();
}
public String describeUndo() {
return null;
}
public Object getOverrideKey() {
return null;
}
public void undo() {
@Override
protected String getRecipeInfo(Entry<ItemInfo, Float> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Ex Nihilo Crucible heat source
@ZenMethod
public static void removeHeatSource(IItemStack output) {
if (isABlock(output)) {
Block block = Block.getBlockFromItem(toStack(output).getItem());
MineTweakerAPI.apply(new RemoveHeatSource(block));
public static void removeHeatSource(IIngredient output) {
Map<ItemInfo, Float> recipes = new HashMap<ItemInfo, Float>();
for(Entry<ItemInfo, Float> entry : ExNihiloHelper.getHeatMap().entrySet()) {
if(matches(output, toIItemStack(entry.getKey().getStack()))) {
recipes.put(entry.getKey(), entry.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveHeatSource(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString()));
}
}
//Removes a recipe, will always remove the key, so all should be good
private static class RemoveHeatSource implements IUndoableAction
private static class RemoveHeatSource extends BaseMapAddition<ItemInfo, Float>
{
Block block;
public RemoveHeatSource(Block block) {
this.block = block;
public RemoveHeatSource(Map<ItemInfo, Float> recipes) {
super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes);
}
public void apply() {
HeatRegistry.unregister(block);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Removing ExNihilo Heat source of " + block.getLocalizedName();
}
public String describeUndo() {
return null;
}
public Object getOverrideKey() {
return null;
}
public void undo() {
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, Float> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack());
}
}
}
@@ -1,16 +1,26 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.HammerRegistry;
@@ -19,106 +29,221 @@ import exnihilo.utils.ItemInfo;
@ZenClass("mods.exnihilo.Hammer")
public class Hammer {
// Adding a Ex Nihilo Hammer recipe
public static final String name = "ExNihilo Hammer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), (float) chance, (float) luck));
}
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
addRecipe(input, new IItemStack[] { output }, new double[] { chance }, new double[] { luck });
}
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack[] output, double[] chance, double[] luck) {
if(input == null || output == null || chance == null || luck == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
if(!isABlock(input)) {
LogHelper.logError(String.format("Input item for %s recipe must be a block.", name));
return;
}
if(output.length == 0 || output.length != chance.length || output.length != luck.length) {
LogHelper.logError(String.format("Number of items in arrays are different or null (%d, %d, %d)", output.length, chance.length, luck.length));
return;
}
Map<ItemInfo, ArrayList<Smashable>> recipes = new HashMap<ItemInfo, ArrayList<Smashable>>();
ArrayList<Smashable> list = new ArrayList<Smashable>();
ItemInfo itemInfo = new ItemInfo(toStack(input));
recipes.put(itemInfo, list);
for(int i = 0; i < output.length; i++) {
ItemStack out = toStack(output[i]);
list.add(new Smashable(Block.getBlockFromItem(itemInfo.getItem()), itemInfo.getMeta(), out.getItem(), out.getItemDamage(), (float)chance[i], (float)luck[i]));
}
MineTweakerAPI.apply(new Add(recipes));
}
// Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction {
Block block;
int blockMeta;
Item output;
int outputMeta;
float chance;
float luck;
public Add(Block block, int blockMeta, Item output, int outputMeta, float chance, float luck) {
this.block = block;
this.blockMeta = blockMeta;
this.output = output;
this.outputMeta = outputMeta;
this.chance = chance;
this.luck = luck;
private static class Add extends BaseMapAddition<ItemInfo, ArrayList<Smashable>> {
public Add(Map<ItemInfo, ArrayList<Smashable>> recipes) {
super(Hammer.name, HammerRegistry.getRewards(), recipes);
}
public void apply() {
HammerRegistry.register(block, blockMeta, output, outputMeta, chance, luck);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Adding ExNihilo Hammer recipe by mining " + block.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public String describeUndo() {
return "";
}
public Object getOverrideKey() {
return null;
for(Entry<ItemInfo, ArrayList<Smashable>> entry : recipes.entrySet()) {
if(!map.containsKey(entry.getKey())) {
// no recipe for input available, add new entry
map.put(entry.getKey(), new ArrayList<Smashable>(entry.getValue()));
} else {
// recipes already available, add to present list
ArrayList<Smashable> list = map.get(entry.getKey());
// store old Smashable objects if present
ArrayList<Smashable> backup = new ArrayList<Smashable>();
for(Smashable recipe : entry.getValue()) {
backup.addAll(removeFromList(list, recipe));
}
if(!backup.isEmpty()) {
LogHelper.logWarning(String.format("Overwritten %d %s recipe outputs for %s.", backup.size(), Hammer.name, LogHelper.getStackDescription(entry.getKey().getStack())));
overwritten.put(entry.getKey(), backup);
}
// add new Smashable objects
list.addAll(entry.getValue());
}
successful.put(entry.getKey(), entry.getValue());
}
}
public void undo() {
// remove all recipes
for(Entry<ItemInfo, ArrayList<Smashable>> entry : successful.entrySet()) {
ArrayList<Smashable> list = map.get(entry.getKey());
for(Smashable recipe : entry.getValue()) {
removeFromList(list, recipe);
}
}
// re-add overwritten recipes
for(Entry<ItemInfo, ArrayList<Smashable>> entry : overwritten.entrySet()) {
map.get(entry.getKey()).addAll(entry.getValue());
}
// remove empty entries
for(Iterator<Entry<ItemInfo, ArrayList<Smashable>>> it = map.entrySet().iterator(); it.hasNext(); ) {
Entry<ItemInfo, ArrayList<Smashable>> entry = it.next();
if(entry.getValue().isEmpty()) {
it.remove();
}
}
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, ArrayList<Smashable>> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)";
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a Ex Nihilo Hammer recipe
@Deprecated
@ZenMethod
public static void removeRecipe(IItemStack inputBlock, int inputBlockMeta, IItemStack outputItem, int outputItemMeta) {
MineTweakerAPI.apply(new Remove(Block.getBlockFromItem(toStack(inputBlock).getItem()), inputBlockMeta, toStack(outputItem).getItem(), outputItemMeta));
removeRecipe(toIItemStack(new ItemStack(toStack(inputBlock).getItem(), 1, inputBlockMeta)), toIItemStack(new ItemStack(toStack(outputItem).getItem(), 1, outputItemMeta)));
}
@ZenMethod
public static void removeRecipe(IIngredient input, @Optional IIngredient output) {
if(input == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
if(output == null) {
output = IngredientAny.INSTANCE;
}
Map<ItemInfo, ArrayList<Smashable>> recipes = new HashMap<ItemInfo, ArrayList<Smashable>>();
for(Entry<ItemInfo, ArrayList<Smashable>> entry : HammerRegistry.getRewards().entrySet()) {
if(input.matches(toIItemStack(entry.getKey().getStack()))) {
ArrayList<Smashable> list = entry.getValue();
ArrayList<Smashable> toRemove = new ArrayList<Smashable>();
for(Smashable recipe : list) {
ItemStack item = new ItemStack(recipe.item, 1, recipe.meta);
if(matches(output, toIItemStack(item))) {
toRemove.add(recipe);
}
}
if(!toRemove.isEmpty()) {
recipes.put(entry.getKey(), toRemove);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipes found for %s and %s. Command ignored!", input.toString(), output.toString()));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove implements IUndoableAction {
Block block;
int inputBlockMeta;
Item output;
int outputItemMeta;
private static class Remove extends BaseMapRemoval<ItemInfo, ArrayList<Smashable>> {
public Remove(Block block, int inputBlockMeta, Item output, int outputItemMeta) {
this.block = block;
this.inputBlockMeta = inputBlockMeta;
this.output = output;
this.outputItemMeta = outputItemMeta;
public Remove(Map<ItemInfo, ArrayList<Smashable>> recipes) {
super(Hammer.name, HammerRegistry.getRewards(), recipes);
}
// Loops through the registry, to find the item that matches, saves that
// recipe then removes it
@Override
public void apply() {
HammerRegistry.remove(block, inputBlockMeta, output, outputItemMeta);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Removing ExNihilo Hammer recipe";
}
public String describeUndo() {
return null;
}
public Object getOverrideKey() {
return null;
for(Entry<ItemInfo, ArrayList<Smashable>> entry : recipes.entrySet()) {
ArrayList<Smashable> list = map.get(entry.getKey());
for(Smashable recipe : entry.getValue()) {
removeFromList(list, recipe);
}
successful.put(entry.getKey(), entry.getValue());
}
// remove empty entries
for(Iterator<Entry<ItemInfo, ArrayList<Smashable>>> it = map.entrySet().iterator(); it.hasNext(); ) {
Entry<ItemInfo, ArrayList<Smashable>> entry = it.next();
if(entry.getValue().isEmpty()) {
it.remove();
}
}
}
@Override
public void undo() {
for(Entry<ItemInfo, ArrayList<Smashable>> entry : successful.entrySet()) {
if(!map.containsKey(entry.getKey())) {
map.put(entry.getKey(), new ArrayList<Smashable>(entry.getValue()));
} else {
map.get(entry.getKey()).addAll(entry.getValue());
}
}
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, ArrayList<Smashable>> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static ArrayList<Smashable> removeFromList(ArrayList<Smashable> list, Smashable s) {
ArrayList<Smashable> removed = new ArrayList<Smashable>();
ItemInfo toRemove = new ItemInfo(s.item, s.meta);
for(Iterator<Smashable> it = list.iterator(); it.hasNext(); ) {
Smashable itS = it.next();
ItemInfo item = new ItemInfo(itS.item, itS.meta);
if(item.equals(toRemove)) {
removed.add(itS);
it.remove();
}
}
return removed;
}
}
@@ -1,224 +1,266 @@
package modtweaker2.mods.exnihilo.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import exnihilo.registries.SieveRegistry;
import exnihilo.registries.helpers.SiftingResult;
import exnihilo.utils.ItemInfo;
@ZenClass("mods.exnihilo.Sieve")
public class Sieve {
public static final String name = "ExNihilo 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(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), rarity));
}
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
addRecipe(input, new IItemStack[] { output }, new int[] { rarity });
}
public static void addRecipe(IItemStack input, IItemStack[] output, int[] rarity) {
if(input == null || output == null || rarity == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
if(!isABlock(input)) {
LogHelper.logError(String.format("Input item for %s recipe must be a block.", name));
return;
}
if(output.length == 0 || output.length != rarity.length) {
LogHelper.logError(String.format("Number of items in arrays are different or null (%d, %d)", output.length, rarity.length));
return;
}
Map<ItemInfo, ArrayList<SiftingResult>> recipes = new HashMap<ItemInfo, ArrayList<SiftingResult>>();
ArrayList<SiftingResult> list = new ArrayList<SiftingResult>();
ItemInfo itemInfo = new ItemInfo(toStack(input));
recipes.put(itemInfo, list);
for(int i = 0; i < output.length; i++) {
ItemStack out = toStack(output[i]);
list.add(new SiftingResult(out.getItem(), out.getItemDamage(), rarity[i]));
}
MineTweakerAPI.apply(new Add(recipes));
}
// Passes the list to the base list implementation, and adds the recipe
private static class Add implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
int outputMeta;
int rarity;
private static class Add extends BaseMapAddition<ItemInfo, ArrayList<SiftingResult>> {
public Add(Block source, int sourceMeta, Item output, int outputMeta, int rarity) {
this.source = source;
this.sourceMeta = sourceMeta;
this.output = output;
this.outputMeta = outputMeta;
this.rarity = rarity;
public Add(Map<ItemInfo, ArrayList<SiftingResult>> recipes) {
super(Sieve.name, SieveRegistry.getSiftables(), recipes);
}
@Override
public void apply() {
SieveRegistry.register(source, sourceMeta, output, outputMeta, rarity);
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : recipes.entrySet()) {
if(!map.containsKey(entry.getKey())) {
// no recipe for input available, add new entry
map.put(entry.getKey(), new ArrayList<SiftingResult>(entry.getValue()));
} else {
// recipes already available, add to present list
ArrayList<SiftingResult> list = map.get(entry.getKey());
// store old SiftingResult objects if present
ArrayList<SiftingResult> backup = new ArrayList<SiftingResult>();
for(SiftingResult recipe : entry.getValue()) {
backup.addAll(removeFromList(list, recipe));
}
if(!backup.isEmpty()) {
LogHelper.logWarning(String.format("Overwritten %d %s recipe outputs for %s.", backup.size(), Hammer.name, LogHelper.getStackDescription(entry.getKey().getStack())));
overwritten.put(entry.getKey(), backup);
}
// add new SiftingResult objects
list.addAll(entry.getValue());
}
successful.put(entry.getKey(), entry.getValue());
}
}
public boolean canUndo() {
return source != null && output != null;
}
public String describe() {
return "Adding ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public String describeUndo() {
return "Removing ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public Object getOverrideKey() {
return null;
}
@Override
public void undo() {
if (this.canUndo())
SieveRegistry.unregisterReward(this.source, this.sourceMeta, this.output, this.outputMeta);
// remove all recipes
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : successful.entrySet()) {
ArrayList<SiftingResult> list = map.get(entry.getKey());
for(SiftingResult recipe : entry.getValue()) {
removeFromList(list, recipe);
}
}
// re-add overwritten recipes
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : overwritten.entrySet()) {
map.get(entry.getKey()).addAll(entry.getValue());
}
// remove empty entries
for(Iterator<Entry<ItemInfo, ArrayList<SiftingResult>>> it = map.entrySet().iterator(); it.hasNext(); ) {
Entry<ItemInfo, ArrayList<SiftingResult>> entry = it.next();
if(entry.getValue().isEmpty()) {
it.remove();
}
}
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, ArrayList<SiftingResult>> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)";
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a Ex Nihilo Sieve recipe
@Deprecated
@ZenMethod
public static void removeRecipe(IItemStack input, IItemStack output) {
if (isABlock(input)) {
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
int theMeta = toStack(input).getItemDamage();
MineTweakerAPI.apply(new Remove(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage()));
}
removeRecipe((IIngredient)input, (IIngredient)output);
}
@Deprecated
@ZenMethod
public static void removeRewardFromAllBlocks(IItemStack output)
{
Item theItem = toStack(output).getItem();
int theMeta = toStack(output).getItemDamage();
MineTweakerAPI.apply(new RemoveRewardFromAllBlocks(theItem, theMeta));
removeRecipe(IngredientAny.INSTANCE, (IIngredient)output);
}
@Deprecated
@ZenMethod
public static void removeAllRewardsFromBlock(IItemStack output)
{
if (isABlock(output)) {
Block theBlock = Block.getBlockFromItem(toStack(output).getItem());
int theMeta = toStack(output).getItemDamage();
MineTweakerAPI.apply(new RemoveAllRewardsFromBlock(theBlock, theMeta));
}
removeRecipe((IIngredient)output, IngredientAny.INSTANCE);
}
@ZenMethod
public static void removeRecipe(IIngredient input, @Optional IIngredient output) {
if(input == null) {
LogHelper.logError(String.format("Required parameters missing for %s recipe.", name));
return;
}
if(output == null) {
output = IngredientAny.INSTANCE;
}
Map<ItemInfo, ArrayList<SiftingResult>> recipes = new HashMap<ItemInfo, ArrayList<SiftingResult>>();
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : SieveRegistry.getSiftables().entrySet()) {
if(input.matches(toIItemStack(entry.getKey().getStack()))) {
ArrayList<SiftingResult> list = entry.getValue();
ArrayList<SiftingResult> toRemove = new ArrayList<SiftingResult>();
for(SiftingResult recipe : list) {
ItemStack item = new ItemStack(recipe.item, 1, recipe.meta);
if(matches(output, toIItemStack(item))) {
toRemove.add(recipe);
}
}
if(!toRemove.isEmpty()) {
recipes.put(entry.getKey(), toRemove);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipes found for %s and %s. Command ignored!", input.toString(), output.toString()));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove implements IUndoableAction {
Block source;
int sourceMeta;
Item output;
int outputMeta;
int rarity;
private static class Remove extends BaseMapRemoval<ItemInfo, ArrayList<SiftingResult>> {
public Remove(Map<ItemInfo, ArrayList<SiftingResult>> recipes) {
super(Sieve.name, SieveRegistry.getSiftables(), recipes);
}
@Override
public void apply() {
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : recipes.entrySet()) {
ArrayList<SiftingResult> list = map.get(entry.getKey());
for(SiftingResult recipe : entry.getValue()) {
removeFromList(list, recipe);
}
successful.put(entry.getKey(), entry.getValue());
}
// remove empty entries
for(Iterator<Entry<ItemInfo, ArrayList<SiftingResult>>> it = map.entrySet().iterator(); it.hasNext(); ) {
Entry<ItemInfo, ArrayList<SiftingResult>> entry = it.next();
if(entry.getValue().isEmpty()) {
it.remove();
}
}
}
public Remove(Block source, int sourceMeta, Item output, int outputMeta) {
this.source = source;
this.sourceMeta = sourceMeta;
this.output = output;
this.outputMeta = outputMeta;
}
public void apply() {
ArrayList<SiftingResult> results = SieveRegistry.getSiftingOutput(this.source, this.sourceMeta);
for (SiftingResult res : results) {
if (res.item.equals(this.source) && res.meta == this.outputMeta)
this.rarity = res.rarity;
}
SieveRegistry.unregisterReward(source, sourceMeta, output, outputMeta);
}
public boolean canUndo() {
return output != null && source != null;
}
public String describe() {
return "Removing ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public String describeUndo() {
return "Restoring ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName();
}
public Object getOverrideKey() {
return null;
}
public void undo() {
if (this.canUndo())
SieveRegistry.register(this.source, this.sourceMeta, this.output, this.outputMeta, rarity);
}
}
private static class RemoveAllRewardsFromBlock implements IUndoableAction {
Block block;
int blockMeta;
public RemoveAllRewardsFromBlock(Block block, int blockMeta) {
this.block = block;
this.blockMeta = blockMeta;
}
public void apply() {
SieveRegistry.unregisterAllRewardsFromBlock(block, blockMeta);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Removing All ExNihilo Sieve rewards from " + block.getLocalizedName();
}
public String describeUndo() {
return "";
}
public Object getOverrideKey() {
return null;
}
public void undo() {
}
}
private static class RemoveRewardFromAllBlocks implements IUndoableAction {
Item reward;
int rewardMeta;
public RemoveRewardFromAllBlocks(Item reward, int rewardMeta) {
this.reward = reward;
this.rewardMeta = rewardMeta;
}
public void apply() {
SieveRegistry.unregisterRewardFromAllBlocks(reward, rewardMeta);
}
public boolean canUndo() {
return false;
}
public String describe() {
return "Removing ExNihilo Sieve reward of " + reward.getUnlocalizedName() + " from all Blocks";
}
public String describeUndo() {
return "";
}
public Object getOverrideKey() {
return null;
}
public void undo() {
}
@Override
public void undo() {
for(Entry<ItemInfo, ArrayList<SiftingResult>> entry : successful.entrySet()) {
if(!map.containsKey(entry.getKey())) {
map.put(entry.getKey(), new ArrayList<SiftingResult>(entry.getValue()));
} else {
map.get(entry.getKey()).addAll(entry.getValue());
}
}
}
@Override
protected String getRecipeInfo(Entry<ItemInfo, ArrayList<SiftingResult>> recipe) {
return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static ArrayList<SiftingResult> removeFromList(ArrayList<SiftingResult> list, SiftingResult s) {
ArrayList<SiftingResult> removed = new ArrayList<SiftingResult>();
ItemInfo toRemove = new ItemInfo(s.item, s.meta);
for(Iterator<SiftingResult> it = list.iterator(); it.hasNext(); ) {
SiftingResult itS = it.next();
ItemInfo item = new ItemInfo(itS.item, itS.meta);
if(item.equals(toRemove)) {
removed.add(itS);
it.remove();
}
}
return removed;
}
}
@@ -2,24 +2,30 @@ package modtweaker2.mods.extendedworkbench.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Arrays;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseCraftingAddition;
import modtweaker2.utils.BaseCraftingRemoval;
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 net.minecraft.item.crafting.IRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.extendedworkbench")
public class ExtendedCrafting {
public static final String name = "Extended Workbench";
@ZenMethod
public static void addShaped(IItemStack output, IItemStack[][] ingredients) {
MineTweakerAPI.apply(new Add(getShapedRecipe(output, ingredients)));
@@ -30,17 +36,10 @@ public class ExtendedCrafting {
MineTweakerAPI.apply(new Add(new ExtendedShapelessRecipes(toStack(output), Arrays.asList(toStacks(ingredients)))));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseCraftingAddition {
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();
super(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList());
recipes.add(recipe);
}
}
@@ -71,32 +70,13 @@ public class ExtendedCrafting {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public static void removeRecipe(IIngredient output) {
List<IRecipe> recipes = BaseCraftingRemoval.getRecipes(ExtendedCraftingManager.getInstance().getRecipeList(), output);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new BaseCraftingRemoval(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList(), recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ExtendedCrafting.name, output));
}
}
}
@@ -2,14 +2,17 @@ package modtweaker2.mods.factorization;
import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
import java.lang.reflect.Constructor;
import java.util.List;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack;
public class FactorizationHelper {
@SuppressWarnings("rawtypes")
public static List lacerator = null;
@SuppressWarnings("rawtypes")
public static List slag = null;
@SuppressWarnings("rawtypes")
public static List crystallizer = null;
static {
@@ -22,36 +25,27 @@ public class FactorizationHelper {
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 getLaceratorRecipe(Object input, ItemStack output, float probability) {
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe", Object.class, ItemStack.class, float.class),
input,
output,
probability);
}
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult", ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class),
input,
chance1,
output1,
chance2,
output2);
}
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe", ItemStack.class, ItemStack.class, float.class, ItemStack.class),
input,
output,
output_count,
solution);
}
}
@@ -0,0 +1,73 @@
package modtweaker2.mods.factorization.commands;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.helpers.StringHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import net.minecraft.item.ItemStack;
public class FactorizationLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("crystallizer");
validArguments.add("lacerator");
validArguments.add("slagfurnace");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("crystallizer")) {
for(Object recipe : FactorizationHelper.crystallizer) {
MineTweakerAPI.logCommand(String.format("mods.factorization.Crystallizer.addRecipe(%s, %s, %s, %s);",
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "input")),
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "output")),
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "solution")),
ReflectionHelper.<Float>getObject(recipe, "output_count")));
}
}
if(args.isEmpty() || args.contains("lacerator")) {
for(Object recipe : FactorizationHelper.lacerator) {
MineTweakerAPI.logCommand(String.format("mods.factorization.Lacerator.addRecipe(%s, %s, %s);",
ReflectionHelper.<String>getObject(recipe, "oreName") != null ?
LogHelper.getStackDescription(ReflectionHelper.<String>getObject(recipe, "oreName")) :
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "itemstack")),
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "output")),
ReflectionHelper.<Float>getObject(recipe, "probability")));
}
}
if(args.isEmpty() || args.contains("slagfurnace")) {
for(Object recipe : FactorizationHelper.slag) {
MineTweakerAPI.logCommand(String.format("mods.factorization.SlagFurnace.addRecipe(%s, %s, %s, %s, %s);",
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "input")),
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "output2")),
ReflectionHelper.<Float>getObject(recipe, "prob2"),
LogHelper.getStackDescription(ReflectionHelper.<ItemStack>getObject(recipe, "output1")),
ReflectionHelper.<Float>getObject(recipe, "prob1")));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,9 +1,16 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
@@ -15,59 +22,61 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Crystallizer")
public class Crystallizer {
public static final String name = "Factorization 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));
MineTweakerAPI.apply(new Add(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;
private static class Add extends BaseListAddition<Object> {
@SuppressWarnings("unchecked")
public Add(Object recipe) {
super(Crystallizer.name, FactorizationHelper.crystallizer);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return output.getDisplayName();
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output"));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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)) {
recipes.add(r);
}
public static void removeRecipe(IIngredient output) {
List<Object> recipes = new LinkedList<Object>();
for (Object r : FactorizationHelper.crystallizer) {
if (r != null) {
ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output");;
if (out != null && matches(output, toIItemStack(out))) {
recipes.add(r);
}
}
super.apply();
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crystallizer.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval<Object> {
@SuppressWarnings("unchecked")
public Remove(List<Object> recipes) {
super(Crystallizer.name, FactorizationHelper.crystallizer, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output"));
}
}
}
@@ -1,9 +1,17 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toObject;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
@@ -14,57 +22,60 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.Lacerator")
public class Lacerator {
public static final String name = "Factorization 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));
public static void addRecipe(IIngredient input, IItemStack output, double probability) {
Object recipe = FactorizationHelper.getLaceratorRecipe(toObject(input), toStack(output), (float) probability);
MineTweakerAPI.apply(new Add(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;
private static class Add extends BaseListAddition<Object> {
@SuppressWarnings("unchecked")
public Add(Object recipe) {
super(Lacerator.name, FactorizationHelper.lacerator);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return output.getDisplayName();
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output"));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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)) {
public static void removeRecipe(IIngredient output) {
List<Object> recipes = new LinkedList<Object>();
for (Object r : FactorizationHelper.lacerator) {
if(r != null) {
ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output");
if (output != null && matches(output, toIItemStack(out))) {
recipes.add(r);
}
}
super.apply();
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Lacerator.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval<Object> {
@SuppressWarnings("unchecked")
public Remove(List<Object> recipes) {
super(Lacerator.name, FactorizationHelper.lacerator, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output"));
}
}
}
@@ -1,74 +1,82 @@
package modtweaker2.mods.factorization.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.factorization.FactorizationHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseMultipleListRemoval;
import modtweaker2.utils.BaseMultipleListRemoval.Position;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.factorization.SlagFurnace")
public class SlagFurnace {
public static final String name = "Factorization Slag Furnace";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output2, double chance2, IItemStack output1, double chance1) {
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;
private static class Add extends BaseListAddition<Object> {
@SuppressWarnings("unchecked")
public Add(ItemStack input, Object recipe) {
super("Slag Furnace", FactorizationHelper.slag, recipe);
this.input = input;
super(SlagFurnace.name, FactorizationHelper.slag);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input"));
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), Position.ALL));
public static void removeRecipe(IIngredient input) {
List<Object> recipes = new LinkedList<Object>();
for(Object r : FactorizationHelper.slag) {
if(r != null) {
ItemStack in = (ItemStack) ReflectionHelper.getObject(r, "input");
if(matches(input, toIItemStack(in))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", SlagFurnace.name, input));
}
}
@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);
private static class Remove extends BaseListRemoval<Object> {
@SuppressWarnings("unchecked")
public Remove(List<Object> recipes) {
super(SlagFurnace.name, FactorizationHelper.slag, recipes);
}
@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();
}
@Override
public String getRecipeInfo(Object recipe) {
return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input"));
}
}
}
@@ -1,51 +1,30 @@
package modtweaker2.mods.forestry;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import forestry.factory.gadgets.MachineCarpenter;
public class ForestryHelper {
@SuppressWarnings("unchecked")
public static void addCarpenterRecipeBox(ItemStack box) {
Class clazz;
try {
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager");
Field field_box = clazz.getDeclaredField("boxes");
field_box.setAccessible(true);
ArrayList<ItemStack> recipeBoxes = (ArrayList<ItemStack>) field_box.get(clazz);
recipeBoxes.add(box);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
ArrayList<ItemStack> recipeBoxes = (ArrayList<ItemStack>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "boxes");
if(recipeBoxes != null) {
recipeBoxes.add(box);
}
}
@SuppressWarnings("unchecked")
public static void addCarpenterRecipeFluids(Fluid newFluid) {
Class clazz;
try {
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager");
Field field_recipeFluids = clazz.getDeclaredField("recipeFluids");
field_recipeFluids.setAccessible(true);
HashSet<Fluid> recipeFluids = (HashSet<Fluid>) field_recipeFluids.get(clazz);
recipeFluids.add(newFluid);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
HashSet<Fluid> recipeFluids = (HashSet<Fluid>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "recipeFluids");
if(recipeFluids != null) {
recipeFluids.add(newFluid);
}
}
}
@@ -1,15 +1,20 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.forestry.ForestryHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -24,7 +29,11 @@ import forestry.factory.gadgets.MachineCarpenter.RecipeManager;
@ZenClass("mods.forestry.Carpenter")
public class Carpenter {
public static final String name = "Forestry Carpenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) {
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
@@ -45,10 +54,11 @@ public class Carpenter {
return null;
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Carpenter", MachineCarpenter.RecipeManager.recipes, recipe);
super(Carpenter.name, MachineCarpenter.RecipeManager.recipes);
recipes.add(recipe);
// The Carpenter has a list of valid Fluids, access them via
// Relfection because of private
@@ -59,37 +69,43 @@ public class Carpenter {
ForestryHelper.addCarpenterRecipeBox(recipe.getBox());
}
}
@Override
public String getRecipeInfo(){
return ((MachineCarpenter.Recipe) recipe).getCraftingResult().getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(MachineCarpenter.RecipeManager.recipes, toStack(output)));
public static void removeRecipe(IIngredient output) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
if(recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List list, ItemStack stack) {
super("Forestry Carpenter", list, stack);
public Remove(List<Recipe> recipes) {
super(Carpenter.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.getCraftingResult() != null && r.getCraftingResult().isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(){
return "Removed recipe for: " + stack.getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -1,12 +1,17 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -19,6 +24,10 @@ import forestry.factory.gadgets.MachineCentrifuge.RecipeManager;
@ZenClass("mods.forestry.Centrifuge")
public class Centrifuge {
public static final String name = "Forestry Centrifuge";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
@@ -31,47 +40,47 @@ public class Centrifuge {
MineTweakerAPI.apply(new Add(new Recipe(timePerItem, toStack(itemInput), products)));
}
@ZenMethod
public static void removeRecipe(IItemStack itemInput) {
MineTweakerAPI.apply(new Remove(RecipeManager.recipes, toStack(itemInput)));
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super(Centrifuge.name, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.resource);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
if(recipe != null && matches(input, toIItemStack(recipe.resource))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
}
}
/*
Implements the actions to add the recipe
*/
private static class Add extends BaseListAddition {
private static class Remove extends BaseListRemoval<Recipe> {
public Add(Recipe recipe) {
super("Forestry Centrifuge", RecipeManager.recipes, recipe);
}
@Override
public String getRecipeInfo() {
return " Input:" + ((Recipe) recipe).resource.getDisplayName();
}
}
/*
Implements the actions to remove the recipe
*/
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack input) {
super("Forestry Centrifuge", RecipeManager.recipes, input);
public Remove(List<Recipe> recipes) {
super(Centrifuge.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.matches(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return " Input:" + stack.getDisplayName();
protected String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.resource);
}
}
}
@@ -1,67 +1,178 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineFermenter;
import forestry.factory.gadgets.MachineFermenter.Recipe;
import forestry.factory.gadgets.MachineFermenter.RecipeManager;
@ZenClass("mods.forestry.Fermenter")
public class Fermenter {
public static final String name = "Forestry Fermenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack resource, ILiquidStack liquid, int fermentationValue, float modifier, ILiquidStack output) {
MineTweakerAPI.apply(new Add(new Recipe(toStack(resource), fermentationValue, modifier, toFluid(output), toFluid(liquid))));
MachineFermenter.RecipeManager.recipeFluidInputs.add(getFluid(liquid));
MachineFermenter.RecipeManager.recipeFluidOutputs.add(getFluid(output));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Fermenter", MachineFermenter.RecipeManager.recipes, recipe);
super(Fermenter.name, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).output.getLocalizedName();
}
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(MachineFermenter.RecipeManager.recipes, toStack(input)));
}
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.resource != null && r.resource.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
// add liquids to valid input / output
for(Recipe recipe : successful) {
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
}
super.apply();
}
@Override
public void undo() {
super.undo();
// Tidy up valid inputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
// Tidy up valid outputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<Recipe> recipes = new LinkedList<Recipe>();
for(Recipe recipe : RecipeManager.recipes) {
// check for input items
if(recipe != null && recipe.resource != null && matches(input, toIItemStack(recipe.resource))) {
recipes.add(recipe);
}
// check for input liquids
if(recipe != null && recipe.resource != null && matches(input, toILiquidStack(recipe.liquid))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString()));
}
}
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Fermenter.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
super.apply();
// Tidy up valid inputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidInputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.liquid != null && recipe.liquid.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
// Tidy up valid outputs
for(Iterator<Fluid> iter = RecipeManager.recipeFluidOutputs.iterator(); iter.hasNext();) {
boolean found = false;
Fluid fluid = iter.next();
for(Recipe recipe : list) {
if(recipe != null && recipe.output != null && recipe.output.getFluid().equals(fluid)) {
found = true;
}
}
if(!found) {
iter.remove();
}
}
}
@Override
public void undo() {
// add liquids to valid input / output
for(Recipe recipe : successful) {
RecipeManager.recipeFluidInputs.add(recipe.liquid.getFluid());
RecipeManager.recipeFluidOutputs.add(recipe.output.getFluid());
}
super.undo();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
}
@@ -1,14 +1,18 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineMoistener;
@@ -17,6 +21,10 @@ import forestry.factory.gadgets.MachineMoistener.RecipeManager;
@ZenClass("mods.forestry.Moistener")
public class Moistener {
public static final String name = "Forestry Moistener";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
@@ -24,37 +32,45 @@ public class Moistener {
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Moistener", MachineMoistener.RecipeManager.recipes, recipe);
super(Moistener.name, MachineMoistener.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).product.getDisplayName();
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.product);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(MachineMoistener.RecipeManager.recipes, toStack(output)));
public static void removeRecipe(IIngredient output) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe recipe : RecipeManager.recipes) {
if (recipe != null && recipe.product != null && matches(output, toIItemStack(recipe.product))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Moistener.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.product != null && r.product.isItemEqual(stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.product);
}
}
}
@@ -2,18 +2,22 @@ package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineSqueezer;
@@ -22,6 +26,10 @@ import forestry.factory.gadgets.MachineSqueezer.RecipeManager;
@ZenClass("mods.forestry.Squeezer")
public class Squeezer {
public static final String name = "Forestry Squeezer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) {
@@ -30,38 +38,53 @@ public class Squeezer {
MachineSqueezer.RecipeManager.recipeInputs.addAll(Arrays.asList(toStacks(resources)));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Squeezer", MachineSqueezer.RecipeManager.recipes, recipe);
super(Squeezer.name, MachineSqueezer.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).liquid.getLocalizedName();
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.liquid);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(ILiquidStack liquid) {
MineTweakerAPI.apply(new Remove(MachineSqueezer.RecipeManager.recipes, toFluid(liquid)));
public static void removeRecipe(IIngredient liquid) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.liquid != null && matches(liquid, toILiquidStack(r.liquid))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, liquid.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, FluidStack liquid) {
super(list, liquid);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Squeezer.name, MachineSqueezer.RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.liquid != null && r.liquid.isFluidEqual(fluid)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.liquid);
}
}
}
@@ -2,14 +2,17 @@ package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.getFluid;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import forestry.factory.gadgets.MachineStill;
@@ -18,6 +21,10 @@ import forestry.factory.gadgets.MachineStill.RecipeManager;
@ZenClass("mods.forestry.Still")
public class Still {
public static final String name = "Forestry Still";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) {
@@ -29,37 +36,46 @@ public class Still {
MachineStill.RecipeManager.recipeFluidOutputs.add(getFluid(output));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<Recipe> {
public Add(Recipe recipe) {
super("Forestry Still", MachineStill.RecipeManager.recipes, recipe);
super("Forestry Still", MachineStill.RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((Recipe) recipe).output.getLocalizedName();
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(ILiquidStack output, ILiquidStack input) {
MineTweakerAPI.apply(new Remove(MachineStill.RecipeManager.recipes, toFluid(input)));
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.output != null && matches(output, toILiquidStack(r.output))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(List list, FluidStack input) {
super(list, input);
private static class Remove extends BaseListRemoval<Recipe> {
public Remove(List<Recipe> recipes) {
super(Still.name, RecipeManager.recipes, recipes);
}
@Override
public void apply() {
for (Recipe r : RecipeManager.recipes) {
if (r.output != null && r.output.isFluidEqual(fluid)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
}
@@ -1,13 +1,18 @@
package modtweaker2.mods.forestry.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -21,18 +26,20 @@ import forestry.factory.gadgets.MachineFabricator.Smelting;
@ZenClass("mods.forestry.ThermionicFabricator")
public class ThermionicFabricator {
public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)";
public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//first production step: smelting item into liquid
@ZenMethod
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
MineTweakerAPI.apply(new Add(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
MineTweakerAPI.apply(new AddSmelting(new Smelting(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
}
@ZenMethod
public static void removeSmelting(IItemStack itemInput) {
MineTweakerAPI.apply(new Remove(toStack(itemInput), RecipeManager.smeltings, RecipeType.Smelting));
}
//second step: casting liquid + objetcs + plan into result
@ZenMethod
@@ -44,86 +51,95 @@ public class ThermionicFabricator {
}
}
MineTweakerAPI.apply(new Add(new Recipe(toStack(plan), toFluid(fluidInput), new ShapedRecipeCustom(3, 3, flatList, toStack(product)))));
}
@ZenMethod
public static void removeCasts(IItemStack product) {
MineTweakerAPI.apply(new Remove(toStack(product), RecipeManager.recipes, RecipeType.Casting));
MineTweakerAPI.apply(new AddCast(new Recipe(toStack(plan), toFluid(fluidInput), new ShapedRecipeCustom(3, 3, flatList, toStack(product)))));
}
/*
Implements the actions to add a recipe
Since the machine has two crafting Steps, this is a constructors for both
*/
private static class Add extends BaseListAddition {
private static class AddSmelting extends BaseListAddition<Smelting> {
public Add(Smelting recipe) {
super("Forestry Thermionic Fabricator (Smelting)", RecipeManager.smeltings, recipe);
public AddSmelting(Smelting recipe) {
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings);
recipes.add(recipe);
}
public Add(Recipe recipe) {
super("Forestry Thermionic Fabricator (Casting)", RecipeManager.recipes, recipe);
@Override
public String getRecipeInfo(Smelting recipe) {
return LogHelper.getStackDescription(recipe.getResource());
}
}
private static class AddCast extends BaseListAddition<Recipe> {
public AddCast(Recipe recipe) {
super(ThermionicFabricator.nameCasting, RecipeManager.recipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getPlan());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeSmelting(IIngredient itemInput) {
List<Smelting> recipes = new LinkedList<Smelting>();
for (Smelting r : RecipeManager.smeltings) {
if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveSmelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString()));
}
}
@ZenMethod
public static void removeCasts(IIngredient product) {
List<Recipe> recipes = new LinkedList<Recipe>();
for (Recipe r : RecipeManager.recipes) {
if (r != null && r.asIRecipe().getRecipeOutput() != null && matches(product, toIItemStack(r.asIRecipe().getRecipeOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveCasts(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString()));
}
}
private static class RemoveSmelting extends BaseListRemoval<Smelting> {
public RemoveSmelting(List<Smelting> recipes) {
super(ThermionicFabricator.nameSmelting, RecipeManager.smeltings, recipes);
}
@Override
public String getRecipeInfo() {
if (recipe instanceof Smelting)
return " Input:" + ((Smelting) recipe).getResource().getDisplayName();
else
return "Output: " + ((Recipe) recipe).asIRecipe().getRecipeOutput().getDisplayName();
public String getRecipeInfo(Smelting recipe) {
return LogHelper.getStackDescription(recipe.getResource());
}
}
private static class RemoveCasts extends BaseListRemoval<Recipe> {
public RemoveCasts(List<Recipe> recipes) {
super(ThermionicFabricator.nameCasting, RecipeManager.recipes, recipes);
}
/*
Implements the actions to remove recipes
*/
private static class Remove extends BaseListRemoval {
private final RecipeType type;
public Remove(ItemStack input, List list, RecipeType type) {
super(String.format("Forestry Thermionic Fabricator (%s)", type.toString()), list, input);
this.type = type;
}
@Override
public void apply() {
switch(type) {
case Smelting:
for (Object r : list) {
if (((Smelting)r).getResource() != null && ((Smelting)r).getResource().isItemEqual(stack)) {
recipes.add(r);
}
}
break;
case Casting:
for (Object r : list) {
if (((Recipe)r).asIRecipe().getRecipeOutput() != null && ((Recipe)r).asIRecipe().getRecipeOutput().isItemEqual(stack)) {
recipes.add(r);
}
}
break;
}
super.apply();
}
@Override
public String getRecipeInfo() {
switch(type) {
case Smelting:
return " Input:" + stack.getDisplayName(); // + " -- Output:" + ((Smelting) recipe).getProduct().getLocalizedName();
case Casting:
return " Output:" + stack.getDisplayName(); // + " -- Output:" + ((Recipe) recipe).asIRecipe().getIngredients()[0].getDisplayName();
}
return stack.getDisplayName();
}
}
public enum RecipeType {
Smelting,
Casting
@Override
public String getRecipeInfo(Recipe recipe) {
return LogHelper.getStackDescription(recipe.getPlan());
}
}
}
@@ -1,12 +1,22 @@
package modtweaker2.mods.fsp.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import static modtweaker2.mods.fsp.FSPHelper.getLiquid;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -20,6 +30,11 @@ import flaxbeard.steamcraft.api.Tuple3;
@ZenClass("mods.fsp.Crucible")
public class Crucible {
public static final String nameLiquid = "FSP Crucible (Liquid)";
public static final String nameMelting = "FSP Crucible (Liquid)";
public static final String nameDunking = "FSP Crucible (Dunking)";
@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)));
@@ -30,14 +45,15 @@ public class Crucible {
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 {
private static class AddLiquid extends BaseListAddition<CrucibleLiquid> {
public AddLiquid(CrucibleLiquid recipe) {
super("FSP Crucible Liquid", SteamcraftRegistry.liquids, recipe);
super(nameLiquid, SteamcraftRegistry.liquids);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((CrucibleLiquid) recipe).name;
public String getRecipeInfo(CrucibleLiquid recipe) {
return recipe.name;
}
}
@@ -50,41 +66,43 @@ public class Crucible {
}
}
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;
private static class AddMelting extends BaseMapAddition<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> {
public AddMelting(ItemStack stack, MutablePair<Item, Integer> key, MutablePair<CrucibleLiquid, Integer> recipe) {
super(nameMelting, SteamcraftRegistry.smeltThings);
map.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@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;
public static void removeMelting(IIngredient input) {
Map<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipes = new HashMap<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>>();
for(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> entry : SteamcraftRegistry.smeltThings.entrySet()) {
if(matches(input, toIItemStack(new ItemStack(entry.getKey().left, 1, entry.getKey().right)))) {
recipes.put(entry.getKey(), entry.getValue());
}
}
public void apply(){
SteamcraftRegistry.smeltThings.remove(stack);
MutablePair<String, Integer> pair;
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s", Crucible.nameMelting, input));
}
}
private static class RemoveMelting extends BaseMapRemoval<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> {
public RemoveMelting(Map<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipes) {
super(nameMelting, SteamcraftRegistry.smeltThings, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<CrucibleLiquid, Integer>> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@@ -93,40 +111,50 @@ public class Crucible {
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))));
MineTweakerAPI.apply(new AddDunking(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;
private static class AddDunking extends BaseMapAddition<Tuple3, MutablePair<Integer, ItemStack>> {
public AddDunking(Tuple3 key, MutablePair<Integer, ItemStack> recipe) {
super(Crucible.nameDunking, SteamcraftRegistry.dunkThings);
recipes.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe) {
return LogHelper.getStackDescription(recipe.getValue().right);
}
}
@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))));
public static void removeDunking(IIngredient input, String liquid) {
Map<Tuple3, MutablePair<Integer, ItemStack>> recipes = new HashMap<Tuple3, MutablePair<Integer, ItemStack>>();
for(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe : SteamcraftRegistry.dunkThings.entrySet()) {
if(recipe.getValue() != null && recipe.getValue().right != null && matches(input, toIItemStack(recipe.getValue().right))) {
if(((CrucibleLiquid)recipe.getKey().third).equals(getLiquid(liquid))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveDunking(recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", Crucible.nameDunking, input.toString(), 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;
private static class RemoveDunking extends BaseMapRemoval<Tuple3, MutablePair<Integer, ItemStack>> {
public RemoveDunking(Map<Tuple3, MutablePair<Integer, ItemStack>> recipes) {
super(Crucible.nameDunking, SteamcraftRegistry.dunkThings, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<Tuple3, MutablePair<Integer, ItemStack>> recipe) {
return LogHelper.getStackDescription(recipe.getValue().right);
}
}
}
@@ -1,10 +1,20 @@
package modtweaker2.mods.fsp.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -15,41 +25,51 @@ import flaxbeard.steamcraft.api.SteamcraftRegistry;
@ZenClass("mods.fsp.Furnace")
public class Furnace {
public static final String name = "FSP Furnace (Steamed Foods)";
@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;
private static class AddSteamFood extends BaseMapAddition<MutablePair<Item, Integer>, MutablePair<Item, Integer>> {
public AddSteamFood(ItemStack stack, MutablePair<Item, Integer> key, MutablePair<Item, Integer> recipe) {
super(Furnace.name, SteamcraftRegistry.steamedFoods);
recipes.put(key, recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
@ZenMethod
public static void removeSteamFood(IItemStack input) {
MineTweakerAPI.apply(new RemoveSteamFood(toStack(input), MutablePair.of(toStack(input).getItem(), toStack(input).getItemDamage())));
public static void removeSteamFood(IIngredient input) {
Map<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipes = new HashMap<MutablePair<Item, Integer>, MutablePair<Item, Integer>>();
for(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe : SteamcraftRegistry.steamedFoods.entrySet()) {
if(matches(input, toIItemStack(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right)))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveSteamFood(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Furnace.name, input.toString()));
}
}
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;
private static class RemoveSteamFood extends BaseMapRemoval<MutablePair<Item, Integer>, MutablePair<Item, Integer>> {
public RemoveSteamFood(Map<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipes) {
super(Furnace.name, SteamcraftRegistry.steamedFoods, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(Entry<MutablePair<Item, Integer>, MutablePair<Item, Integer>> recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getKey().left, 1, recipe.getKey().right));
}
}
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import mariculture.api.core.FuelInfo;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.fishery.Fishing;
import mariculture.api.fishery.Loot;
@@ -15,7 +16,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
public class MaricultureHelper {
public static Map fuels = null;
public static Map<Object, FuelInfo> fuels = null;
public static HashMap<Rarity, ArrayList<Loot>> loot = null;
static {
@@ -27,7 +28,7 @@ public class MaricultureHelper {
private MaricultureHelper() {}
//Helper for getting the key that is used when adding/removing fuels
// 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) {
@@ -1,33 +1,46 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.IAnvilHandler.RecipeAnvil;
import mariculture.api.core.MaricultureHandlers;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.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
public static final String name = "Mariculture Anvil";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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 {
private static class Add extends BaseMapAddition<String, RecipeAnvil> {
public Add(RecipeAnvil recipe) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(recipe.input), recipe);
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes());
recipes.put(MaricultureHelper.getKey(recipe.input), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeAnvil) recipe).output.getDisplayName();
public String getRecipeInfo(Entry<String, RecipeAnvil> recipe) {
return LogHelper.getStackDescription(recipe.getValue().output);
}
}
@@ -35,18 +48,30 @@ public class Anvil {
//Removing a Mariculture Anvil recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
public static void removeRecipe(IIngredient input) {
Map<String, RecipeAnvil> recipes = new HashMap<String, RecipeAnvil>();
for(Entry<String, RecipeAnvil> recipe : MaricultureHandlers.anvil.getRecipes().entrySet()) {
if(recipe != null && recipe.getValue() != null && recipe.getValue().input != null && matches(input, toIItemStack(recipe.getValue().input))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Anvil.name, input.toString()));
}
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(stack), stack);
private static class Remove extends BaseMapRemoval<String, RecipeAnvil> {
public Remove(Map<String, RecipeAnvil> recipes) {
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), recipes);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
public String getRecipeInfo(Entry<String, RecipeAnvil> recipe) {
return LogHelper.getStackDescription(recipe.getValue().output);
}
}
}
@@ -1,26 +1,36 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeCasting;
import mariculture.api.core.RecipeCasting.RecipeNuggetCasting;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.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
public static final String name = "Mariculture Casting";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addNuggetRecipe(ILiquidStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getNuggetRecipes()));
@@ -36,43 +46,63 @@ public class Casting {
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);
private static class Add extends BaseMapAddition<String, RecipeCasting> {
public Add(RecipeCasting recipe, HashMap<String, RecipeCasting> map) {
super(Casting.name, map);
recipes.put(MaricultureHelper.getKey(recipe.fluid), recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeCasting) recipe).output.getDisplayName();
public String getRecipeInfo(Entry<String, RecipeCasting> recipe) {
return LogHelper.getStackDescription(recipe.getValue().output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing Mariculture Casting Recipes
@ZenMethod
public static void removeNuggetRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getNuggetRecipes()));
public static void removeNuggetRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getNuggetRecipes());
}
@ZenMethod
public static void removeIngotRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getIngotRecipes()));
public static void removeIngotRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getIngotRecipes());
}
@ZenMethod
public static void removeBlockRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getBlockRecipes()));
public static void removeBlockRecipe(IIngredient ingredient) {
removeRecipe(ingredient, MaricultureHandlers.casting.getBlockRecipes());
}
public static void removeRecipe(IIngredient ingredient, HashMap<String, RecipeCasting> map) {
Map<String, RecipeCasting> recipes = new HashMap<String, RecipeCasting>();
for(Entry<String, RecipeCasting> recipe : map.entrySet()) {
if(recipe != null && recipe.getValue() != null) {
if(recipe.getValue().fluid != null && matches(ingredient, toILiquidStack(recipe.getValue().fluid))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
if(recipe.getValue().output != null && matches(ingredient, toIItemStack(recipe.getValue().output))) {
recipes.put(recipe.getKey(), recipe.getValue());
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(map, recipes));
}
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack, HashMap map) {
super("Mariculture Casting", map, MaricultureHelper.getKey(stack), stack);
private static class Remove extends BaseMapRemoval<String, RecipeCasting> {
public Remove(Map<String, RecipeCasting> map, Map<String, RecipeCasting> recipes) {
super(Casting.name, map, recipes);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
public String getRecipeInfo(Entry<String, RecipeCasting> recipe) {
return LogHelper.getStackDescription(recipe.getValue().output);
}
}
}
@@ -1,14 +1,24 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mariculture.api.core.FuelInfo;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeSmelter;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -21,6 +31,9 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mariculture.Crucible")
public class Crucible {
public static final String nameSmelting = "Mariculture Crucible (Smelting)";
public static final String nameFuel = "Mariculture Crucible (Fuel)";
/********************************************** Mariculture Crucible Recipes **********************************************/
@@ -32,14 +45,15 @@ public class Crucible {
}
// Passes the list to the base list implementation, and adds the recipe
private static class AddRecipe extends BaseListAddition {
private static class AddRecipe extends BaseListAddition<RecipeSmelter> {
public AddRecipe(RecipeSmelter recipe) {
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), recipe);
super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((RecipeSmelter) recipe).input.getDisplayName();
public String getRecipeInfo(RecipeSmelter recipe) {
return LogHelper.getStackDescription(recipe.input);
}
}
@@ -47,35 +61,34 @@ public class Crucible {
// Removing a Mariculture Crucible recipe
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new RemoveRecipe(toStack(input)));
public static void removeRecipe(IIngredient input) {
List<RecipeSmelter> recipes = new LinkedList<RecipeSmelter>();
for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) {
if (r != null) {
if (r.input != null && matches(input, toIItemStack(r.input))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveRecipe(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Crucible.nameSmelting, input.toString()));
}
}
// 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 != null) {
if (r.input != null && stack != null && areEqual(r.input, stack)) {
recipes.add(r);
}
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
private static class RemoveRecipe extends BaseListRemoval<RecipeSmelter> {
public RemoveRecipe(List<RecipeSmelter> recipes) {
super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes(), recipes);
}
@Override
public String getRecipeInfo(RecipeSmelter recipe) {
return LogHelper.getStackDescription(recipe.input);
}
}
/********************************************** Crucible Fuels **********************************************/
@@ -95,42 +108,58 @@ public class Crucible {
}
// Passes the list to the base map implementation, and adds the recipe
private static class AddFuel extends BaseMapAddition {
private static class AddFuel extends BaseMapAddition<Object, FuelInfo> {
public AddFuel(Object o, FuelInfo info) {
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), info);
super(Crucible.nameFuel, MaricultureHelper.fuels);
recipes.put(MaricultureHelper.getKey(o), info);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
@Override
public String getRecipeInfo(Entry<Object, FuelInfo> recipe) {
return (String) recipe.getKey();
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFuel(IItemStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
@ZenMethod
public static void removeFuel(ILiquidStack fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
@ZenMethod
public static void removeFuel(String fuel) {
MineTweakerAPI.apply(new RemoveFuel(fuel));
removeFuelEntry(fuel);
}
public static void removeFuelEntry(Object o) {
String key = MaricultureHelper.getKey(o);
Map<Object, FuelInfo> recipes = new HashMap<Object, FuelInfo>();
for(Entry<Object, FuelInfo> entry : MaricultureHelper.fuels.entrySet()) {
if(key.matches((String)entry.getKey())) {
recipes.put(key, entry.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveFuel(recipes));
}
}
// 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);
private static class RemoveFuel extends BaseMapRemoval<Object, FuelInfo> {
public RemoveFuel(Map<Object, FuelInfo> recipes) {
super(Crucible.nameFuel, MaricultureHelper.fuels, recipes);
}
@Override
public String getRecipeInfo() {
return (String) key;
}
@Override
public String getRecipeInfo(Entry<Object, FuelInfo> recipe) {
return (String) recipe.getKey();
}
}
}
@@ -14,8 +14,7 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.mariculture.MaricultureHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.BaseUndoable;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
@@ -67,7 +66,7 @@ public class Fishing {
}
}
private static class AddLoot extends BaseDescriptionAddition {
private static class AddLoot extends BaseUndoable {
private final Loot loot;
public AddLoot(Loot loot, String description) {
@@ -80,6 +79,7 @@ public class Fishing {
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
list.add(loot);
MaricultureHelper.loot.put(loot.rarity, list);
success = true;
}
@Override
@@ -103,7 +103,7 @@ public class Fishing {
MineTweakerAPI.apply(new RemoveLoot(toStack(loot)));
}
private static class RemoveLoot extends BaseDescriptionRemoval {
private static class RemoveLoot extends BaseUndoable {
private HashMap<Rarity, Loot> loot;
private final ItemStack stack;
@@ -119,6 +119,7 @@ public class Fishing {
apply(Rarity.JUNK);
apply(Rarity.GOOD);
apply(Rarity.RARE);
success = true;
}
//Performs the apply function on all rarity types
@@ -1,22 +1,33 @@
package modtweaker2.mods.mariculture.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import mariculture.api.core.MaricultureHandlers;
import mariculture.api.core.RecipeVat;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.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 {
public static final String name = "Mariculture Vat";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Adding a Mariculture Vat recipe
@ZenMethod
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) {
@@ -64,74 +75,82 @@ public class Vat {
}
// Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<RecipeVat> {
public Add(RecipeVat recipe) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipe);
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
if (((RecipeVat) recipe).outputItem != null)
return ((RecipeVat) recipe).outputItem.getDisplayName();
else
return ((RecipeVat) recipe).outputFluid.getFluid().getLocalizedName();
public String getRecipeInfo(RecipeVat recipe) {
if(recipe.outputItem != null) {
return LogHelper.getStackDescription(recipe.outputItem);
} else {
return LogHelper.getStackDescription(recipe.outputFluid);
}
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a Mariculture Vat recipe
@ZenMethod
public static void removeRecipe(IItemStack outputItem) {
MineTweakerAPI.apply(new Remove(toStack(outputItem), null));
public static void removeRecipe(IIngredient ingredient) {
List<RecipeVat> recipes = new LinkedList<RecipeVat>();
for(RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if(r != null) {
if(r.outputItem != null && matches(ingredient, toIItemStack(r.outputItem))) {
recipes.add(r);
}
else if(r.outputFluid != null && matches(ingredient, toILiquidStack(r.outputFluid))) {
recipes.add(r);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", Vat.name, ingredient.toString()));
}
}
@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)));
public static void removeRecipe(IIngredient outputItem, IIngredient outputFluid) {
List<RecipeVat> recipes = new LinkedList<RecipeVat>();
for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
if (r != null) {
if (r.outputItem != null && matches(outputItem, toIItemStack(r.outputItem))) {
if (r.outputFluid != null && matches(outputFluid, toILiquidStack(r.outputFluid))) {
recipes.add(r);
}
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s and %s. Command ignored!", Vat.name, outputItem.toString(), outputFluid.toString()));
}
}
// Removes a recipe, apply is never the same for anything, so will always
// need to override it
private static class Remove extends BaseListRemoval {
private FluidStack fluid = null;
public Remove(ItemStack stack, FluidStack fluid) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), stack);
if (fluid != null)
this.fluid = fluid;
private static class Remove extends BaseListRemoval<RecipeVat> {
public Remove(List<RecipeVat> recipes) {
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipes);
}
// 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 != null)
if (r.outputItem != null && stack != null && areEqual(r.outputItem, stack)) {
if (r.outputFluid == null || (fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipes.add(r);
break;
}
}
if ((r.outputFluid != null && fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
recipes.add(r);
break;
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack != null ? stack.getDisplayName() : fluid.getFluid().getLocalizedName();
}
@Override
public String getRecipeInfo(RecipeVat recipe) {
if(recipe.outputItem != null) {
return LogHelper.getStackDescription(recipe.outputItem);
} else {
return LogHelper.getStackDescription(recipe.outputFluid);
}
}
}
}
@@ -1,32 +1,33 @@
package modtweaker2.mods.mekanism;
import java.util.regex.Pattern;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.gas.GasBracketHandler;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalInfuser;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalInjection;
import modtweaker2.mods.mekanism.handlers.ChemicalCrystallizer;
import modtweaker2.mods.mekanism.handlers.ChemicalDissolution;
import modtweaker2.mods.mekanism.handlers.ChemicalInfuser;
import modtweaker2.mods.mekanism.handlers.ChemicalInjection;
import modtweaker2.mods.mekanism.handlers.ChemicalOxidizer;
import modtweaker2.mods.mekanism.handlers.ChemicalWasher;
import modtweaker2.mods.mekanism.handlers.Combiner;
import modtweaker2.mods.mekanism.handlers.Compressor;
import modtweaker2.mods.mekanism.handlers.Crusher;
import modtweaker2.mods.mekanism.handlers.Enrichment;
import modtweaker2.mods.mekanism.handlers.Infuser;
import modtweaker2.mods.mekanism.handlers.Purification;
import modtweaker2.mods.mekanism.handlers.Reaction;
import modtweaker2.mods.mekanism.handlers.Sawmill;
import modtweaker2.mods.mekanism.handlers.Separator;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalCrystallizer;
import modtweaker2.mods.mekanism.handlers.v8.ChemicalDissolution;
import modtweaker2.mods.mekanism.handlers.v8.Infuser;
import modtweaker2.utils.TweakerPlugin;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
public class Mekanism extends TweakerPlugin {
public static final boolean v7 = isV7();
public Mekanism() {
MineTweakerAPI.registerBracketHandler(new GasBracketHandler());
MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
MineTweakerAPI.registerClass(ChemicalDissolution.class);
MineTweakerAPI.registerClass(ChemicalInfuser.class);
MineTweakerAPI.registerClass(ChemicalInjection.class);
MineTweakerAPI.registerClass(ChemicalOxidizer.class);
MineTweakerAPI.registerClass(ChemicalWasher.class);
MineTweakerAPI.registerClass(Combiner.class);
MineTweakerAPI.registerClass(Compressor.class);
MineTweakerAPI.registerClass(Crusher.class);
@@ -36,21 +37,5 @@ public class Mekanism extends TweakerPlugin {
MineTweakerAPI.registerClass(Reaction.class);
MineTweakerAPI.registerClass(Sawmill.class);
MineTweakerAPI.registerClass(Separator.class);
// MineTweakerAPI.registerClass(ChemicalCrystallizer.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);
}
public static boolean isV7(){
Pattern version = Pattern.compile("7.*");
for (ModContainer loadedMod : Loader.instance().getActiveModList())
{
if (loadedMod.getModId().equals("Mekanism") && version.matcher(loadedMod.getVersion()).find()) return true;
}
return false;
}
}
@@ -1,4 +1,4 @@
package modtweaker2.mods.mekanism.gas;
package modtweaker2.mods.mekanism.commands;
import java.util.Collections;
import java.util.Comparator;
@@ -28,7 +28,7 @@ public class GasLogger implements ICommandFunction {
Collections.sort(gases, COMPARATOR);
for (Gas gas : gases) {
System.out.println("Gas " + gas.getName());
MineTweakerAPI.logCommand("<" + gas.getName() + "> -- " + gas.getLocalizedName());
MineTweakerAPI.logCommand("<gas:" + gas.getName() + "> -- " + gas.getLocalizedName());
}
if (player != null) {
@@ -0,0 +1,209 @@
package modtweaker2.mods.mekanism.commands;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mekanism.common.recipe.machines.CombinerRecipe;
import mekanism.common.recipe.machines.CrusherRecipe;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.recipe.machines.EnrichmentRecipe;
import mekanism.common.recipe.machines.InjectionRecipe;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mekanism.common.recipe.machines.OxidationRecipe;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.machines.PurificationRecipe;
import mekanism.common.recipe.machines.SawmillRecipe;
import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.machines.WasherRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StringHelper;
public class MekanismLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("combiner");
validArguments.add("compressor");
validArguments.add("crusher");
validArguments.add("crystallizer");
validArguments.add("dissolution");
validArguments.add("enrichment");
validArguments.add("infuser");
validArguments.add("injection");
validArguments.add("oxidizer");
validArguments.add("purification");
validArguments.add("reaction");
validArguments.add("sawmill");
validArguments.add("separator");
validArguments.add("washer");
}
@SuppressWarnings({ "unchecked" })
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("crystallizer")) {
for(CrystallizerRecipe recipe : (Collection<CrystallizerRecipe>)Recipe.CHEMICAL_CRYSTALLIZER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Crystallizer.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("dissolution")) {
for(DissolutionRecipe recipe : (Collection<DissolutionRecipe>)Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Dissolution.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("infuser")) {
for(ChemicalInfuserRecipe recipe : (Collection<ChemicalInfuserRecipe>)Recipe.CHEMICAL_INFUSER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Infuser.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.leftGas),
LogHelper.getStackDescription(recipe.recipeInput.rightGas),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("injection")) {
for(InjectionRecipe recipe : (Collection<InjectionRecipe>)Recipe.CHEMICAL_INJECTION_CHAMBER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Injection.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.itemStack),
LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("oxidizer")) {
for(OxidationRecipe recipe : (Collection<OxidationRecipe>)Recipe.CHEMICAL_OXIDIZER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Oxidizer.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("washer")) {
for(WasherRecipe recipe : (Collection<WasherRecipe>)Recipe.CHEMICAL_WASHER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Washer.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("combiner")) {
for(CombinerRecipe recipe : (Collection<CombinerRecipe>)Recipe.COMBINER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Combiner.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.itemStack),
LogHelper.getStackDescription(recipe.recipeOutput.output),
LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1))));
}
}
if(args.isEmpty() || args.contains("compressor")) {
for(CombinerRecipe recipe : (Collection<CombinerRecipe>)Recipe.COMBINER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Compressor.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.itemStack),
LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("crusher")) {
for(CrusherRecipe recipe : (Collection<CrusherRecipe>)Recipe.CRUSHER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Crusher.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("enrichment")) {
for(EnrichmentRecipe recipe : (Collection<EnrichmentRecipe>)Recipe.ENRICHMENT_CHAMBER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Enrichment.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("infuser")) {
for(MetallurgicInfuserRecipe recipe : (Collection<MetallurgicInfuserRecipe>)Recipe.METALLURGIC_INFUSER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Infuser.addRecipe(\"%s\", %d, %s, %s);",
recipe.getInput().infuse.type.name,
recipe.getInput().infuse.amount,
LogHelper.getStackDescription(recipe.recipeInput.inputStack),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("purification")) {
for(PurificationRecipe recipe : (Collection<PurificationRecipe>)Recipe.PURIFICATION_CHAMBER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Purification.addRecipe(%s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.itemStack),
LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)),
LogHelper.getStackDescription(recipe.recipeOutput.output)));
}
}
if(args.isEmpty() || args.contains("reaction")) {
for(PressurizedRecipe recipe : (Collection<PressurizedRecipe>)Recipe.PRESSURIZED_REACTION_CHAMBER.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Reaction.addRecipe(%s, %s, %s, %s, %s, %s, %d);",
LogHelper.getStackDescription(recipe.recipeInput.getSolid()),
LogHelper.getStackDescription(recipe.recipeInput.getFluid()),
LogHelper.getStackDescription(recipe.recipeInput.getGas()),
LogHelper.getStackDescription(recipe.recipeOutput.getItemOutput()),
LogHelper.getStackDescription(recipe.recipeOutput.getGasOutput()),
recipe.extraEnergy,
recipe.ticks));
}
}
if(args.isEmpty() || args.contains("sawmill")) {
for(SawmillRecipe recipe : (Collection<SawmillRecipe>)Recipe.PRECISION_SAWMILL.get().values()) {
if(recipe.getOutput().hasSecondary()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Sawmill.addRecipe(%s, %s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput),
LogHelper.getStackDescription(recipe.recipeOutput.secondaryOutput),
recipe.recipeOutput.secondaryChance));
} else {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Sawmill.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput)));
}
}
}
if(args.isEmpty() || args.contains("separator")) {
for(SeparatorRecipe recipe : (Collection<SeparatorRecipe>)Recipe.ELECTROLYTIC_SEPARATOR.get().values()) {
MineTweakerAPI.logCommand(String.format("mods.mekanism.Separator.addRecipe(%s, %s, %s, %s);",
LogHelper.getStackDescription(recipe.recipeInput.ingredient),
recipe.energyUsage,
LogHelper.getStackDescription(recipe.recipeOutput.leftGas),
LogHelper.getStackDescription(recipe.recipeOutput.rightGas)));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,5 +1,6 @@
package modtweaker2.mods.mekanism.gas;
import minetweaker.api.item.IIngredient;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
@@ -7,7 +8,7 @@ import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.gas.IGasStack")
public interface IGasStack {
public interface IGasStack extends IIngredient {
@ZenGetter("definition")
public IGasDefinition getDefinition();
@@ -1,6 +1,14 @@
package modtweaker2.mods.mekanism.gas;
import java.util.List;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemCondition;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IItemTransformer;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.player.IPlayer;
public class MCGasStack implements IGasStack {
@@ -40,4 +48,88 @@ public class MCGasStack implements IGasStack {
public Object getInternal() {
return stack;
}
@Override
public String toString() {
return "<gas:" + stack.getGas().getName() + ">";
}
@Override
public IIngredient amount(int amount) {
return withAmount(amount);
}
@Override
public IItemStack applyTransform(IItemStack arg0, IPlayer arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean contains(IIngredient arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<IItemStack> getItems() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<ILiquidStack> getLiquids() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getMark() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean hasTransformers() {
// TODO Auto-generated method stub
return false;
}
@Override
public IIngredient marked(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean matches(IItemStack arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean matches(ILiquidStack arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public IIngredient only(IItemCondition arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIngredient or(IIngredient arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIngredient transform(IItemTransformer arg0) {
// TODO Auto-generated method stub
return null;
}
}
@@ -2,33 +2,79 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Crystallizer")
public class ChemicalCrystallizer {
public static final String name = "Mekanism Crusher";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IGasStack input, IItemStack output) {
if (Mekanism.v7)
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toGas(input), toStack(output)));
else
{
CrystallizerRecipe recipe = new CrystallizerRecipe(toGas(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe.getInput(), recipe));
public static void addRecipe(IGasStack gasInput, IItemStack itemOutput) {
if(gasInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
CrystallizerRecipe recipe = new CrystallizerRecipe(toGas(gasInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toStack(output)));
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient gasInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<GasInput, CrystallizerRecipe> entry : ((Map<GasInput, CrystallizerRecipe>)Recipe.CHEMICAL_CRYSTALLIZER.get()).entrySet()) {
IGasStack inputGas = new MCGasStack(entry.getKey().ingredient);
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_CRYSTALLIZER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasInput.toString(), itemOutput.toString()));
}
}
}
@@ -1,90 +1,80 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
public static final String name = "Mekanism Dissolution";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
if (Mekanism.v7)
{
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input), toGas(output)));
}
else {
DissolutionRecipe recipe = new DissolutionRecipe(toStack(input), toGas(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) {
if(itemInput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
DissolutionRecipe recipe = new DissolutionRecipe(toStack(itemInput), toGas(gasOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input)));
}
@ZenMethod
public static void removeRecipe(IOreDictEntry input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
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));
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) {
if(gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ItemStackInput, DissolutionRecipe> entry : ((Map<ItemStackInput, DissolutionRecipe>)Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(gasOutput, outputGas)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
@ZenMethod
public static void removeRecipe(IGasStack input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
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);
recipes.put(entry.getKey(), entry.getValue());
}
@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);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), itemInput.toString()));
}
}
}
@@ -1,36 +1,80 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
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) {
if (Mekanism.v7) {
ChemicalPairInput pair = new ChemicalPairInput(toGas(left), toGas(right));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out)));
} else {
ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left), toGas(right), toGas(out));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe));
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
if (!Mekanism.v7)
throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output)));
}
public static final String name = "Mekanism Infuser";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IGasStack leftGasInput, IGasStack rightGasInput, IGasStack gasOutput) {
if(leftGasInput == null || rightGasInput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(leftGasInput), toGas(rightGasInput), toGas(gasOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_INFUSER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) {
if(gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(leftGasInput == null) leftGasInput = IngredientAny.INSTANCE;
if(rightGasInput == null) rightGasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ChemicalPairInput, ChemicalInfuserRecipe> entry : ((Map<ChemicalPairInput, ChemicalInfuserRecipe>)Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()).entrySet()) {
IGasStack inputGasLeft = new MCGasStack(entry.getKey().leftGas);
IGasStack inputGasRight = new MCGasStack(entry.getKey().rightGas);
IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(gasOutput, outputGas)) continue;
if(!StackHelper.matches(leftGasInput, inputGasLeft)) continue;
if(!StackHelper.matches(rightGasInput, inputGasRight)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, gasOutput.toString(), leftGasInput.toString(), rightGasInput.toString()));
}
}
}
@@ -2,37 +2,87 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.InjectionRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Injection")
public class ChemicalInjection {
public static final String name = "Mekanism Injection";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) {
if (Mekanism.v7)
{
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), toGas(gas).getGas());
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), aInput, toStack(output)));
}
else
{
InjectionRecipe recipe = new InjectionRecipe(toStack(input), gas.getName(), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
if(itemInput == null || gasInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas());
ItemStackOutput output = new ItemStackOutput(toStack(itemOutput));
InjectionRecipe recipe = new InjectionRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "rawtypes", "unchecked" })
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), toStack(output)));
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<AdvancedMachineInput, InjectionRecipe> entry : ((Map<AdvancedMachineInput, InjectionRecipe>)Recipe.CHEMICAL_INJECTION_CHAMBER.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1));
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemOutput.toString(), itemInput.toString(), gasInput.toString()));
}
}
}
@@ -2,35 +2,79 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.OxidationRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Oxidizer")
public class ChemicalOxidizer {
public static final String name = "Mekanism Oxidizer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
if (Mekanism.v7)
{
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toStack(input), toGas(output)));
}
else
{
OxidationRecipe recipe = new OxidationRecipe(toStack(input), toGas(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) {
if(itemInput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
OxidationRecipe recipe = new OxidationRecipe(toStack(itemInput), toGas(gasOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_OXIDIZER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IGasStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toGas(output)));
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) {
if(gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ItemStackInput, OxidationRecipe> entry : ((Map<ItemStackInput, OxidationRecipe>)Recipe.CHEMICAL_OXIDIZER.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(gasOutput, outputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_OXIDIZER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), itemInput.toString()));
}
}
}
@@ -2,64 +2,76 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.WasherRecipe;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Washer")
public class ChemicalWasher {
public static final String name = "Mekanism Washer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IGasStack input, IGasStack output) {
if (Mekanism.v7)
{
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(input), toGas(output)));
}
else
{
WasherRecipe recipe = new WasherRecipe(toGas(input), toGas(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), recipe.getInput(), recipe));
public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) {
if(gasInput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
WasherRecipe recipe = new WasherRecipe(toGas(gasInput), toGas(gasOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_WASHER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IGasStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
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);
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient gasInput) {
if(gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
@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);
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<GasInput, WasherRecipe> entry : ((Map<GasInput, WasherRecipe>)Recipe.CHEMICAL_WASHER.get()).entrySet()) {
IGasStack inputGas = new MCGasStack(entry.getKey().ingredient);
IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(gasInput, inputGas)) continue;
if(!StackHelper.matches(gasOutput, outputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_WASHER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), gasInput.toString()));
}
}
}
@@ -1,35 +1,100 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.gas.GasRegistry;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.CombinerRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Combiner")
public class Combiner {
public static final String name = "Mekanism Combiner";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked" })
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidStone"));
if (Mekanism.v7)
MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), aInput, toStack(output)));
else
{
CombinerRecipe recipe = new CombinerRecipe(toStack(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
if(itemInput == null || gasInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas());
ItemStackOutput output = new ItemStackOutput(toStack(itemOutput));
CombinerRecipe recipe = new CombinerRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.COMBINER.get(), recipe));
}
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
CombinerRecipe recipe = new CombinerRecipe(toStack(itemInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.COMBINER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "rawtypes", "unchecked" })
@ZenMethod
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<AdvancedMachineInput, CombinerRecipe> entry : ((Map<AdvancedMachineInput, CombinerRecipe>)Recipe.COMBINER.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1));
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output);
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
if(!StackHelper.matches(itemOutput, outputItem)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.COMBINER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemInput.toString(), gasInput.toString(), itemOutput.toString()));
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("COMBINER", Recipe.COMBINER.get(), toStack(output)));
}
}
@@ -1,35 +1,101 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.gas.GasRegistry;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.OsmiumCompressorRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Compressor")
public class Compressor {
public static final String name = "Mekanism Compressor";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("liquidOsmium"));
if (Mekanism.v7)
MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), aInput, toStack(output)));
else
{
OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(toStack(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(toStack(itemInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipe));
}
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
if(itemInput == null || gasInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas());
ItemStackOutput output = new ItemStackOutput(toStack(itemOutput));
OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<AdvancedMachineInput, OsmiumCompressorRecipe> entry : ((Map<AdvancedMachineInput, OsmiumCompressorRecipe>)Recipe.OSMIUM_COMPRESSOR.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1));
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output);
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
if(!StackHelper.matches(itemOutput, outputItem)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemInput.toString(), gasInput.toString(), itemOutput.toString()));
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), toStack(output)));
}
}
@@ -1,32 +1,77 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.CrusherRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Crusher")
public class Crusher {
public static final String name = "Mekanism Crusher";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
if (Mekanism.v7)
MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(input), toStack(output)));
else
{
CrusherRecipe recipe = new CrusherRecipe(toStack(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
CrusherRecipe recipe = new CrusherRecipe(toStack(itemInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CRUSHER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(output)));
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ItemStackInput, CrusherRecipe> entry : ((Map<ItemStackInput, CrusherRecipe>)Recipe.CRUSHER.get()).entrySet() ) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CRUSHER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString()));
}
}
}
@@ -1,32 +1,78 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.EnrichmentRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Enrichment")
public class Enrichment {
public static final String name = "Mekanism Enrichment";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
if (Mekanism.v7)
MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input), toStack(output)));
else
{
EnrichmentRecipe recipe = new EnrichmentRecipe(toStack(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
EnrichmentRecipe recipe = new EnrichmentRecipe(toStack(itemInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.ENRICHMENT_CHAMBER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) {
if(itemInput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemOutput == null) itemOutput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ItemStackInput, EnrichmentRecipe> entry : ((Map<ItemStackInput, EnrichmentRecipe>)Recipe.ENRICHMENT_CHAMBER.get()).entrySet() ) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.ENRICHMENT_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString()));
}
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new RemoveMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input)));
}
}
@@ -1,87 +1,84 @@
//package modtweaker2.mods.mekanism.handlers;
//
//import static modtweaker2.helpers.InputHelper.toStack;
//import static modtweaker2.helpers.StackHelper.areEqual;
//
//import java.util.ArrayList;
//import java.util.Iterator;
//import java.util.List;
//import java.util.Map;
//
//import mekanism.api.infuse.InfuseRegistry;
//import mekanism.common.recipe.RecipeHandler.Recipe;
//import mekanism.common.recipe.inputs.InfusionInput;
//import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
//import mekanism.common.recipe.outputs.MachineOutput;
//import minetweaker.MineTweakerAPI;
//import minetweaker.api.item.IItemStack;
//import modtweaker2.mods.mekanism.Mekanism;
//import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
//import modtweaker2.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) {
// if (Mekanism.v7)
// {
// 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));
// }
// else
// {
// MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(new mekanism.common.recipe.inputs.InfusionInput(InfuseRegistry.get(type), infuse, toStack(input)), toStack(output));
// MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), recipe.getInput(), recipe));
// }
// }
//
// @ZenMethod
// public static void removeRecipe(IItemStack output) {
// if (Mekanism.v7)
// {
// MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(output))));
// }
// else
// {
// throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
// }
// }
//
// private static class Remove extends RemoveMekanismRecipe {
// public Remove(String string, Map map, Object key) {
// super(string, map, key);
// }
// private List removed = new ArrayList();
// @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;
// removed.add(value);
// it.remove();
// }
// }
// }
// }
//
// @Override
// public void undo()
// {
// for (Object recipe : removed)
// {
// map.put(key, recipe);
// }
// }
// }
//}
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Infuser")
public class Infuser {
public static final String name = "Mekanism Infuser";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(String infuseType, int infuseAmount, IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null || infuseType == null || infuseType.isEmpty()) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
InfusionInput input = new InfusionInput(InfuseRegistry.get(infuseType), infuseAmount, toStack(itemInput));
ItemStackOutput output = new ItemStackOutput(toStack(itemOutput));
MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.METALLURGIC_INFUSER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional String infuseType) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
if(infuseType == null) infuseType = "";
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<InfusionInput, MetallurgicInfuserRecipe> entry : ((Map<InfusionInput, MetallurgicInfuserRecipe>)Recipe.METALLURGIC_INFUSER.get()).entrySet() ) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().inputStack);
String typeInfuse = entry.getKey().infuse.type.name;
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!infuseType.isEmpty() && !infuseType.equalsIgnoreCase(typeInfuse)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.METALLURGIC_INFUSER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString()));
}
}
}
@@ -1,62 +1,101 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.PurificationRecipe;
import mekanism.common.recipe.outputs.MachineOutput;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Purification")
public class Purification {
public static final String name = "Mekanism Purification";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
if (Mekanism.v7)
{
AdvancedMachineInput aInput = new AdvancedMachineInput(toStack(input), GasRegistry.getGas("oxygen"));
MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), aInput, toStack(output)));
}
else
{
PurificationRecipe recipe = new PurificationRecipe(toStack(input), toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
PurificationRecipe recipe = new PurificationRecipe(toStack(itemInput), toStack(itemOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipe));
}
@SuppressWarnings("unchecked")
@ZenMethod
public static void removeRecipe(IItemStack output) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Purification Chamber", Recipe.PURIFICATION_CHAMBER.get(), stack);
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
if(itemInput == null || gasInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<MachineOutput, ItemStack> entry : ((Map<MachineOutput, ItemStack>) map).entrySet()) {
if (entry.getValue() != null && areEqual(entry.getValue(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas());
ItemStackOutput output = new ItemStackOutput(toStack(itemOutput));
PurificationRecipe recipe = new PurificationRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "rawtypes", "unchecked" })
@ZenMethod
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
if(itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<AdvancedMachineInput, PurificationRecipe> entry : ((Map<AdvancedMachineInput, PurificationRecipe>)Recipe.PURIFICATION_CHAMBER.get()).entrySet()) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1));
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemOutput.toString(), itemInput.toString(), gasInput.toString()));
}
}
}
@@ -3,40 +3,93 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.inputs.PressurizedInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.PressurizedOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Reaction")
public class Reaction {
public static final String name = "Mekanism Reaction";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) {
if (Mekanism.v7)
{
PressurizedInput input = new PressurizedInput(toStack(solid), toFluid(liquid), toGas(gas));
PressurizedRecipe recipe = new PressurizedRecipe(input, new PressurizedOutput(toStack(outItem), toGas(outGas)), energy, ticks);
MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), input, recipe));
}
else {
mekanism.common.recipe.machines.PressurizedRecipe recipe = new mekanism.common.recipe.machines.PressurizedRecipe(toStack(solid), toFluid(liquid), toGas(gas), toStack(outItem), toGas(outGas), energy, ticks);
MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, ILiquidStack liquidInput, IGasStack gasInput, IItemStack itemOutput, IGasStack gasOutput, double energy, int duration) {
if(itemInput == null || liquidInput == null || gasInput == null || itemOutput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
PressurizedInput input = new PressurizedInput(toStack(itemInput), toFluid(liquidInput), toGas(gasInput));
PressurizedOutput output = new PressurizedOutput(toStack(itemOutput), toGas(gasOutput));
PressurizedRecipe recipe = new PressurizedRecipe(input, output, energy, duration);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
@ZenMethod
public static void removeRecipe(IItemStack outItem, IGasStack outGas) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
PressurizedOutput output = new PressurizedOutput(toStack(outItem), toGas(outGas));
MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output));
public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, @Optional IIngredient liquidInput, IIngredient gasInput) {
if(itemOutput == null || gasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(itemInput == null) itemInput = IngredientAny.INSTANCE;
if(liquidInput == null) liquidInput = IngredientAny.INSTANCE;
if(gasInput == null) gasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<PressurizedInput, PressurizedRecipe> entry : ((Map<PressurizedInput, PressurizedRecipe>)Recipe.PRESSURIZED_REACTION_CHAMBER.get()).entrySet() ) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().getSolid());
ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().getFluid());
IGasStack inputGas = new MCGasStack(entry.getKey().getGas());
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.getItemOutput());
IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.getGasOutput());
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(liquidInput, inputLiquid)) continue;
if(!StackHelper.matches(gasInput, inputGas)) continue;
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(gasOutput, outputGas)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s, %s, %s and %s. Command ignored!", name, itemOutput.toString(), gasOutput.toString(), itemInput.toString(), liquidInput.toString(), gasInput.toString()));
}
}
}
@@ -1,61 +1,84 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.SawmillRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.Mekanism;
import minetweaker.api.item.IngredientAny;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Sawmill")
public class Sawmill {
public static final String name = "Mekanism Sawmill";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) {
if (Mekanism.v7)
{
ChanceOutput chanceOutput = new ChanceOutput(toStack(output1), toStack(output2), chance);
MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), toStack(input), chanceOutput));
}
else
{
SawmillRecipe recipe = chance>0?new SawmillRecipe(toStack(input), toStack(output1), toStack(output2), chance) : new SawmillRecipe(toStack(input), toStack(output1));
MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), recipe.getInput(), recipe));
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, @Optional double optionalChance) {
if(itemInput == null || itemOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
ItemStackInput input = new ItemStackInput(toStack(itemInput));
ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(toStack(itemOutput)) :
new ChanceOutput(toStack(itemOutput), toStack(optionalItemOutput), optionalChance);
SawmillRecipe recipe = new SawmillRecipe(input, output);
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PRECISION_SAWMILL.get(), recipe));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Precision Sawmill", Recipe.PRECISION_SAWMILL.get(), stack);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, @Optional IIngredient optionalItemOutput) {
if(itemInput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
//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, Object> entry : ((Map<ItemStack, Object>) map).entrySet()) {
if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
if(itemOutput == null) itemOutput = IngredientAny.INSTANCE;
if(optionalItemOutput == null) optionalItemOutput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<ItemStackInput, SawmillRecipe> entry : ((Map<ItemStackInput, SawmillRecipe>)Recipe.PRECISION_SAWMILL.get()).entrySet() ) {
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.primaryOutput);
IItemStack outputItemOptional = InputHelper.toIItemStack(entry.getValue().recipeOutput.secondaryOutput);
if(!StackHelper.matches(itemOutput, outputItem)) continue;
if(!StackHelper.matches(itemInput, inputItem)) continue;
if(!StackHelper.matches(optionalItemOutput, outputItemOptional)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PRECISION_SAWMILL.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString()));
}
}
}
@@ -3,70 +3,81 @@ package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.inputs.FluidInput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IngredientAny;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StackHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.gas.MCGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraftforge.fluids.FluidStack;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Separator")
public class Separator {
public static final String name = "Mekanism Separator";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@ZenMethod
public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) {
if (Mekanism.v7)
{
ChemicalPairInput pair = new ChemicalPairInput(toGas(gas1), toGas(gas2));
MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), toFluid(input), pair));
} else
{
throw new UnsupportedOperationException("Syntax for v8 is: Fluid, Energy, Gas, Gas");
public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, IGasStack rightGasOutput) {
if(liquidInput == null || leftGasOutput == null || rightGasOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
SeparatorRecipe recipe = new SeparatorRecipe(toFluid(liquidInput), energy, toGas(leftGasOutput), toGas(rightGasOutput));
MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.ELECTROLYTIC_SEPARATOR.get(), recipe));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "rawtypes", "unchecked" })
@ZenMethod
public static void addRecipe(ILiquidStack input, double energy, IGasStack gas1, IGasStack gas2) {
if (Mekanism.v7)
{
throw new UnsupportedOperationException("Syntax for v7 is: Fluid, Gas, Gas");
} else
{
SeparatorRecipe recipe = new SeparatorRecipe(toFluid(input), energy, toGas(gas1), toGas(gas2));
MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), recipe.getInput(), recipe));
public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) {
if(liquidInput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
}
@ZenMethod
public static void removeRecipe(ILiquidStack input) {
if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet");
MineTweakerAPI.apply(new Remove(toFluid(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(FluidStack stack) {
super("Electrolytic Separator", Recipe.ELECTROLYTIC_SEPARATOR.get(), stack);
if(leftGasInput == null) leftGasInput = IngredientAny.INSTANCE;
if(rightGasInput == null) leftGasInput = IngredientAny.INSTANCE;
Map<MachineInput, MachineRecipe> recipes = new HashMap<MachineInput, MachineRecipe>();
for(Entry<FluidInput, SeparatorRecipe> entry : ((Map<FluidInput, SeparatorRecipe>)Recipe.ELECTROLYTIC_SEPARATOR.get()).entrySet() ) {
ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().ingredient);
IGasStack outputItemLeft = new MCGasStack(entry.getValue().recipeOutput.leftGas);
IGasStack outputItemRight = new MCGasStack(entry.getValue().recipeOutput.rightGas);
if(!StackHelper.matches(liquidInput, inputLiquid)) continue;
if(!StackHelper.matches(leftGasInput, outputItemLeft)) continue;
if(!StackHelper.matches(rightGasInput, outputItemRight)) continue;
recipes.put(entry.getKey(), entry.getValue());
}
//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, ChemicalPairOutput> entry : ((Map<FluidStack, ChemicalPairOutput>) map).entrySet()) {
if (entry.getKey() != null && entry.getKey().isFluidEqual((FluidStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.ELECTROLYTIC_SEPARATOR.get(), recipes));
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, liquidInput.toString(), leftGasInput.toString(), rightGasInput.toString()));
}
}
}
@@ -1,85 +0,0 @@
package modtweaker2.mods.mekanism.handlers.v8;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.KeySync.KeySet;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Crystallizer")
public class ChemicalCrystallizer {
@ZenMethod
public static void addRecipe(IItemStack output, IGasStack input) {
MineTweakerAPI.apply(new Add(new ChemicalCrystallizerRecipe(toGas(input), InputHelper.toStack(output))));
}
private static class Add extends BaseMapAddition {
public Add(ChemicalCrystallizerRecipe recipe) {
super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe.inputGas, recipe.outputItem);
}
@Override
public void apply() {
RecipeHandler.addChemicalCrystallizerRecipe((GasStack) key, (ItemStack) recipe);
}
}
private static class ChemicalCrystallizerRecipe {
public GasStack inputGas;
public ItemStack outputItem;
public ChemicalCrystallizerRecipe(GasStack inputGas, ItemStack outputItem) {
this.inputGas = inputGas;
this.outputItem = outputItem;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Chemical Crystallizer", Recipe.CHEMICAL_CRYSTALLIZER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<GasInput> gasesToRemove = new ArrayList<GasInput>();
for(GasInput stack : (Set<GasInput>)Recipe.CHEMICAL_CRYSTALLIZER.get().keySet()){
CrystallizerRecipe crystalRecipe= (CrystallizerRecipe)Recipe.CHEMICAL_CRYSTALLIZER.get().get(stack);
if(crystalRecipe.getOutput().output.isItemEqual((ItemStack) this.stack)){
gasesToRemove.add(stack);
}
}
for(GasInput stack : gasesToRemove){
Recipe.CHEMICAL_CRYSTALLIZER.get().remove(stack);
}
}
}
}
@@ -1,84 +0,0 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
@ZenMethod
public static void addRecipe(IGasStack output, IItemStack input) {
MineTweakerAPI.apply(new Add(new DissolutionRecipe(MekanismHelper.toGas(output), InputHelper.toStack(input))));
}
private static class Add extends BaseMapAddition {
public DissolutionRecipe recipe;
public Add(DissolutionRecipe recipe) {
super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe.input, recipe.output);
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalDissolutionChamberRecipe(recipe.input, recipe.output);
}
}
private static class DissolutionRecipe {
public GasStack output;
public ItemStack input;
public DissolutionRecipe(GasStack output, ItemStack input) {
this.output = output;
this.input = input;
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(GasStack stack) {
super("Dissolution Infuser", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<ItemStackInput> toRemove = new ArrayList<ItemStackInput>();
for (ItemStackInput stack : (Set<ItemStackInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
mekanism.common.recipe.machines.DissolutionRecipe recipe = (mekanism.common.recipe.machines.DissolutionRecipe) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
if (recipe.getOutput().output.isGasEqual((GasStack) this.stack)) {
toRemove.add(stack);
}
}
for (ItemStackInput stack : toRemove) {
Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
}
}
}
}
@@ -1,85 +0,0 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mekanism.common.recipe.outputs.GasOutput;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack output, IGasStack inputLeft, IGasStack inputRight) {
MineTweakerAPI.apply(new Add(new InfuserRecipe(MekanismHelper.toGas(output), MekanismHelper.toGas(inputLeft), MekanismHelper.toGas(inputRight))));
}
private static class Add extends BaseMapAddition {
public InfuserRecipe recipe;
public Add(InfuserRecipe recipe) {
super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), new ChemicalPairInput(recipe.inputLeft, recipe.inputRight), new GasOutput(recipe.output));
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalInfuserRecipe(recipe.inputLeft, recipe.inputRight, recipe.output);
}
}
private static class InfuserRecipe {
public GasStack output;
public GasStack inputLeft;
public GasStack inputRight;
public InfuserRecipe(GasStack output, GasStack inputLeft, GasStack inputRight) {
this.output = output;
this.inputLeft = inputLeft;
this.inputRight = inputRight;
}
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove(MekanismHelper.toGas(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(GasStack stack) {
super("Chemical Infuser", Recipe.CHEMICAL_INFUSER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<ChemicalPairInput> toRemove = new ArrayList<ChemicalPairInput>();
for (ChemicalPairInput stack : (Set<ChemicalPairInput>) Recipe.CHEMICAL_INFUSER.get().keySet()) {
ChemicalInfuserRecipe recipe = (ChemicalInfuserRecipe) Recipe.CHEMICAL_INFUSER.get().get(stack);
if (recipe.getOutput().output.isGasEqual((GasStack)this.stack)) {
toRemove.add(stack);
}
}
for (ChemicalPairInput stack : toRemove) {
Recipe.CHEMICAL_INFUSER.get().remove(stack);
}
}
}
}
@@ -1,86 +0,0 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.MekanismHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.chemical.Injection")
public class ChemicalInjection {
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, IGasStack gas) {
MineTweakerAPI.apply(new Add(new InjectionRecipe(InputHelper.toStack(output), InputHelper.toStack(input), MekanismHelper.toGas(gas))));
}
private static class Add extends BaseMapAddition {
public InjectionRecipe recipe;
public Add(InjectionRecipe recipe) {
super("Chemical Injection", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe.input, recipe.output);
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addChemicalInjectionChamberRecipe(recipe.input, recipe.gas.getGas().getLocalizedName(), recipe.output);
}
}
private static class InjectionRecipe {
public ItemStack output;
public ItemStack input;
public GasStack gas;
public InjectionRecipe(ItemStack output, ItemStack input, GasStack gas) {
this.output = output;
this.input = input;
this.gas = gas;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack output) {
super("Chemical Injection", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), output);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<AdvancedMachineInput> toRemove = new ArrayList<AdvancedMachineInput>();
for (AdvancedMachineInput stack : (Set<AdvancedMachineInput>) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().keySet()) {
ItemStackOutput recipe = (ItemStackOutput) Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().get(stack);
if (recipe.output.isItemEqual((ItemStack)this.stack)) {
toRemove.add(stack);
}
}
for (AdvancedMachineInput stack : toRemove) {
Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().remove(stack);
}
}
}
}
@@ -1,90 +0,0 @@
package modtweaker2.mods.mekanism.handlers.v8;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Infuser")
public class Infuser {
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, int amount, String infuseType) {
InfuseType type = InfuseRegistry.get(infuseType);
MineTweakerAPI.apply(new Add(new InfuserRecipe(InputHelper.toStack(output), InputHelper.toStack(input), amount, type)));
}
private static class Add extends BaseMapAddition {
public InfuserRecipe recipe;
public Add(InfuserRecipe recipe) {
super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), new InfusionInput(recipe.type, recipe.amount, recipe.input), new ItemStackOutput(recipe.output));
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addMetallurgicInfuserRecipe(recipe.type, recipe.amount, recipe.input, recipe.output);
}
}
private static class InfuserRecipe {
public ItemStack output;
public ItemStack input;
public int amount;
public InfuseType type;
public InfuserRecipe(ItemStack output, ItemStack input, int amount, InfuseType type) {
this.output = output;
this.input = input;
this.amount = amount;
this.type = type;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(InputHelper.toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Metallurgic Infuser", Recipe.METALLURGIC_INFUSER.get(), stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
List<InfusionInput> toRemove = new ArrayList<InfusionInput>();
for (InfusionInput stack : (Set<InfusionInput>) Recipe.METALLURGIC_INFUSER.get().keySet()) {
MetallurgicInfuserRecipe recipe = (MetallurgicInfuserRecipe) Recipe.METALLURGIC_INFUSER.get().get(stack);
if (recipe.getOutput().output.isItemEqual((ItemStack) this.stack)) {
toRemove.add(stack);
}
}
for (InfusionInput stack : toRemove) {
Recipe.METALLURGIC_INFUSER.get().remove(stack);
}
}
}
}
@@ -1,67 +1,43 @@
package modtweaker2.mods.mekanism.util;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.inputs.ChemicalPairInput;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
import mekanism.common.recipe.outputs.PressurizedOutput;
import modtweaker2.mods.mekanism.Mekanism;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.CombinerRecipe;
import mekanism.common.recipe.machines.CrusherRecipe;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.recipe.outputs.MachineOutput;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.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);
@SuppressWarnings("rawtypes")
public class AddMekanismRecipe extends BaseMapAddition<MachineInput, MachineRecipe> {
public AddMekanismRecipe(String name, Map<MachineInput, MachineRecipe> map, Map<MachineInput, MachineRecipe> recipes) {
super(name, map, recipes);
}
@Override
public String describe() {
if (Mekanism.v7) {
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 ChemicalPairInput)
return "Adding " + description + " Recipe for : " + ((ChemicalPairInput) 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 PressurizedRecipe)
return "Adding " + description + " Recipe for : " + ((PressurizedRecipe) recipe).getOutput().getItemOutput().getDisplayName();
else if (recipe instanceof InfusionInput)
return "Adding " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
return "";
public AddMekanismRecipe(String name, Map<MachineInput, MachineRecipe> map, MachineRecipe recipe) {
super(name, map);
recipes.put(recipe.getInput(), recipe);
}
@Override
public String describeUndo() {
if (Mekanism.isV7()) {
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 ChemicalPairOutput)
return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) 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 PressurizedOutput)
return "Removing " + description + " Recipe for : " + ((PressurizedOutput) recipe).getItemOutput().getDisplayName();
else if (recipe instanceof InfusionInput)
return "Removing " + description + " Recipe for : " + ((InfusionInput) recipe).inputStack.getDisplayName();
else
return super.getRecipeInfo();
}
return "";
protected String getRecipeInfo(Entry<MachineInput, MachineRecipe> recipe) {
MachineRecipe machineRecipe = recipe.getValue();
MachineOutput output = recipe.getValue().recipeOutput;
if(machineRecipe instanceof CombinerRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
} else if (machineRecipe instanceof CrusherRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
} else if (machineRecipe instanceof CrystallizerRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
}
return null;
}
}
@@ -1,150 +1,37 @@
package modtweaker2.mods.mekanism.util;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.inputs.PressurizedInput;
import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import mekanism.common.recipe.outputs.ChemicalPairOutput;
import mekanism.common.recipe.outputs.PressurizedOutput;
import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.CombinerRecipe;
import mekanism.common.recipe.machines.CrusherRecipe;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.recipe.outputs.MachineOutput;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.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();
if (pairs != null) {
Object value = pairs.getValue();
if (value != null && tmp != 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 InfusionInput) {
if (areEqual(((ItemStack) tmp), ((InfusionInput) value).inputStack)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChemicalPairOutput && value instanceof ChemicalPairOutput) {
ChemicalPairOutput par1 = (ChemicalPairOutput) tmp;
ChemicalPairOutput par2 = (ChemicalPairOutput) 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 PressurizedOutput && value instanceof PressurizedRecipe) {
PressurizedOutput par1 = (PressurizedOutput) tmp;
PressurizedOutput par2 = ((PressurizedRecipe) value).recipeOutput;
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 ChemicalPairOutput)
return "Removing " + description + " Recipe for : " + ((ChemicalPairOutput) 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 PressurizedInput)
return "Removing " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionInput)
return "Removing " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.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 ChemicalPairOutput)
return "Restoring " + description + " Recipe for : " + ((ChemicalPairOutput) 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 PressurizedInput)
return "Restoring " + description + " Recipe for : " + ((PressurizedInput) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionInput)
return "Restoring " + description + " Recipe for : " + ((InfusionInput) tmp).inputStack.getDisplayName();
else
return super.getRecipeInfo();
@SuppressWarnings("rawtypes")
public class RemoveMekanismRecipe extends BaseMapRemoval<MachineInput, MachineRecipe> {
public RemoveMekanismRecipe(String name, Map<MachineInput, MachineRecipe> map, Map<MachineInput, MachineRecipe> recipes) {
super(name, map, recipes);
}
@Override
protected String getRecipeInfo(Entry<MachineInput, MachineRecipe> recipe) {
MachineRecipe machineRecipe = recipe.getValue();
MachineOutput output = recipe.getValue().recipeOutput;
if(machineRecipe instanceof CombinerRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
} else if (machineRecipe instanceof CrusherRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
} else if (machineRecipe instanceof CrystallizerRecipe) {
return LogHelper.getStackDescription(((ItemStackOutput)output).output);
}
return null;
}
}
@@ -1,13 +1,19 @@
package modtweaker2.mods.metallurgy.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.metallurgy.MetallurgyHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -15,52 +21,50 @@ import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe;
@ZenClass("mods.metallurgy.Alloyer")
public class Alloyer {
//Adding a Metallurgy Alloyer recipe
public static final String name = "Metallurgy Alloyer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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 {
private static class Add extends BaseListAddition<AlloyRecipe> {
public Add(AlloyRecipe recipe) {
super("Metallurgy Alloyer", MetallurgyHelper.alloyerRecipes, recipe);
super(Alloyer.name, MetallurgyHelper.alloyerRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyRecipe) recipe).getCraftingResult().getDisplayName();
public String getRecipeInfo(AlloyRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a Metallurgy Alloyer recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<AlloyRecipe> recipes = new LinkedList<AlloyRecipe>();
for (AlloyRecipe r : MetallurgyHelper.alloyerRecipes) {
if (r != null && r.getCraftingResult() != null && matches(output, toIItemStack(r.getCraftingResult()))) {
recipes.add(r);
}
}
MineTweakerAPI.apply(new Remove(recipes));
}
//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)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<AlloyRecipe> {
public Remove(List<AlloyRecipe> recipes) {
super(Alloyer.name, MetallurgyHelper.alloyerRecipes, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(AlloyRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
@@ -2,8 +2,12 @@ package modtweaker2.mods.metallurgy.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.metallurgy.MetallurgyHelper;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
@@ -19,24 +23,34 @@ public class Crusher {
MineTweakerAPI.apply(new Add(toStack(input), toStack(output)));
}
private static class Add extends BaseMapAddition {
private static class Add extends BaseMapAddition<String, ItemStack> {
private final ItemStack stack;
public Add(ItemStack input, ItemStack output) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(input), output);
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList);
this.stack = input;
recipes.put(MetallurgyHelper.getCrusherKey(input), output);
}
@Override
public void apply() {
super.apply();
addToInput(stack, (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
addToInput(stack, recipe.getValue());
}
}
@Override
public void undo() {
super.undo();
removeFromInput(stack, (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
removeFromInput(stack, recipe.getValue());
}
}
@Override
protected String getRecipeInfo(Entry<String, ItemStack> recipe) {
return LogHelper.getStackDescription(recipe.getValue());
}
}
@@ -48,26 +62,35 @@ public class Crusher {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
private static class Remove extends BaseMapRemoval<String, ItemStack> {
private ItemStack stack;
public Remove(ItemStack stack) {
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList, MetallurgyHelper.getCrusherKey(stack), stack);
}
@Override
public String getRecipeInfo() {
return ((ItemStack) stack).getDisplayName();
super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList);
map.put(MetallurgyHelper.getCrusherKey(stack), MetallurgyHelper.crusherMetaList.get(MetallurgyHelper.getCrusherKey(stack)));
this.stack = stack;
}
@Override
public void apply() {
super.apply();
removeFromInput(((ItemStack) stack), (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
removeFromInput(stack, recipe.getValue());
}
}
@Override
public void undo() {
super.undo();
addToInput(((ItemStack) stack), (ItemStack) recipe);
for(Entry<String, ItemStack> recipe : successful.entrySet()) {
addToInput(stack, recipe.getValue());
}
}
@Override
protected String getRecipeInfo(Entry<String, ItemStack> recipe) {
return LogHelper.getStackDescription(recipe.getValue());
}
}
@@ -1,12 +1,17 @@
package modtweaker2.mods.pneumaticcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -16,68 +21,97 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Assembly")
public class Assembly {
public static final String name = "PneumaticCraft Assembly";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addDrillRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillRecipes));
addRecipe(input, output, AssemblyRecipe.drillRecipes);
}
@ZenMethod
public static void addLaserRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.laserRecipes));
addRecipe(input, output, AssemblyRecipe.laserRecipes);
}
@ZenMethod
public static void addLaserDrillRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillLaserRecipes));
addRecipe(input, output, AssemblyRecipe.drillLaserRecipes);
}
public static void addRecipe(IItemStack input, IItemStack output, List<AssemblyRecipe> list) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
ItemStack in = toStack(input);
for(AssemblyRecipe recipe : list) {
if(areEqual(recipe.getInput(), in)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(in)));
return;
}
}
MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), list));
}
private static class Add extends BaseListAddition {
public Add(AssemblyRecipe recipe, List list) {
super("Pneumaticraft Assembly", list, recipe);
private static class Add extends BaseListAddition<AssemblyRecipe> {
public Add(AssemblyRecipe recipe, List<AssemblyRecipe> list) {
super(Assembly.name, list);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AssemblyRecipe) recipe).getOutput().getDisplayName();
public String getRecipeInfo(AssemblyRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillRecipes));
public static void removeDrillRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.drillRecipes, output);
}
@ZenMethod
public static void removeLaserRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.laserRecipes));
public static void removeLaserRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.laserRecipes, output);
}
@ZenMethod
public static void removeLaserDrillRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output), AssemblyRecipe.drillLaserRecipes));
public static void removeLaserDrillRecipe(IIngredient output) {
removeRecipe(AssemblyRecipe.drillLaserRecipes, output);
}
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)) {
recipes.add(r);
}
public static void removeRecipe(List<AssemblyRecipe> list, IIngredient output) {
List<AssemblyRecipe> recipes = new LinkedList<AssemblyRecipe>();
for (AssemblyRecipe r : list) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, output.toString()));
}
}
super.apply();
private static class Remove extends BaseListRemoval<AssemblyRecipe> {
public Remove(List<AssemblyRecipe> list, List<AssemblyRecipe> recipes) {
super(Assembly.name, list, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(AssemblyRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,9 +1,16 @@
package modtweaker2.mods.pneumaticcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStacks;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
@@ -13,48 +20,46 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.pneumaticcraft.Pressure")
public class Pressure {
public static final String name = "PneumaticCraft Pressure Chamber";
@ZenMethod
public static void addRecipe(IItemStack[] input, double pressure, IItemStack[] output, boolean asBlock) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
MineTweakerAPI.apply(new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock)));
}
private static class Add extends BaseListAddition {
private ItemStack stack;
private static class Add extends BaseListAddition<PressureChamberRecipe> {
public Add(PressureChamberRecipe recipe) {
super("Pneumaticraft Pressure Chamber", PressureChamberRecipe.chamberRecipes, recipe);
this.stack = recipe.output[0];
super(Pressure.name, PressureChamberRecipe.chamberRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(PressureChamberRecipe recipe) {
return LogHelper.getStackDescription(recipe.output[0]);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@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) {
public static void removeRecipe(IIngredient[] output) {
List<PressureChamberRecipe> recipes = new LinkedList<PressureChamberRecipe>();
for (PressureChamberRecipe r : PressureChamberRecipe.chamberRecipes) {
if(r != null) {
boolean matches = true;
for (int i = 0; i < stacks.length; i++) {
if (!areEqual(stacks[i], r.output[i])) { // possible IndexOutOfBoundsException on r.output[i]
matches = false;
break;
for (IIngredient ingredient : output) {
for(ItemStack stack : r.output) {
if (!matches(ingredient, toIItemStack(stack))) {
matches = false;
break;
}
}
}
@@ -62,12 +67,19 @@ public class Pressure {
recipes.add(r);
}
}
super.apply();
}
MineTweakerAPI.apply(new Remove(recipes));
}
private static class Remove extends BaseListRemoval<PressureChamberRecipe> {
public Remove(List<PressureChamberRecipe> recipes) {
super(Pressure.name, PressureChamberRecipe.chamberRecipes, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(PressureChamberRecipe recipe) {
return LogHelper.getStackDescription(recipe.output[0]);
}
}
}
@@ -1,12 +1,15 @@
package modtweaker2.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 mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager.BlastFurnaceRecipe;
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe;
import mods.railcraft.common.util.crafting.RockCrusherCraftingManager.CrusherRecipe;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fluids.FluidStack;
@@ -28,35 +31,28 @@ public class RailcraftHelper {
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(BlastFurnaceRecipe.class,ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class),
input,
matchDamage,
matchNBT,
cookTime,
output);
}
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CokeOvenRecipe.class, ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class),
input,
matchDamage,
matchNBT,
output,
fluidOutput,
cookTime);
}
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CrusherRecipe.class, ItemStack.class, boolean.class, boolean.class),
stack,
matchDamage,
matchNBT);
}
}
@@ -0,0 +1,110 @@
package modtweaker2.mods.railcraft.commands;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
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 modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.helpers.StringHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
public class RailcraftLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("blastfurnace");
validArguments.add("cokeoven");
validArguments.add("rockcrusher");
validArguments.add("rollingmachine");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("blastfurnace")) {
for(IBlastFurnaceRecipe recipe : RailcraftHelper.furnace) {
MineTweakerAPI.logCommand(String.format("mods.railcraft.BlastFurnace.addRecipe(%s, %s, %s, %d, %s);",
LogHelper.getStackDescription(recipe.getInput()),
ReflectionHelper.<Boolean>getObject(recipe, "matchDamage"),
ReflectionHelper.<Boolean>getObject(recipe, "matchNBT"),
recipe.getCookTime(),
LogHelper.getStackDescription(recipe.getOutput())));
}
}
if(args.isEmpty() || args.contains("cokeoven")) {
for(ICokeOvenRecipe recipe : RailcraftCraftingManager.cokeOven.getRecipes()) {
MineTweakerAPI.logCommand(String.format("mods.railcraft.CokeOven.addRecipe(%s, %s, %s, %s, %s, %d);",
LogHelper.getStackDescription(recipe.getInput()),
ReflectionHelper.<Boolean>getObject(recipe, "matchDamage"),
ReflectionHelper.<Boolean>getObject(recipe, "matchNBT"),
LogHelper.getStackDescription(recipe.getOutput()),
LogHelper.getStackDescription(recipe.getFluidOutput()),
recipe.getCookTime()));
}
}
if(args.isEmpty() || args.contains("rockcrusher")) {
for(IRockCrusherRecipe recipe : RailcraftHelper.crusher) {
MineTweakerAPI.logCommand(String.format("mods.railcraft.RockCrusher.addRecipe(%s, %s, %s, %s);",
LogHelper.getStackDescription(recipe.getInput()),
ReflectionHelper.<Boolean>getObject(recipe, "matchDamage"),
ReflectionHelper.<Boolean>getObject(recipe, "matchNBT"),
getRockCrusherOutputDescription(recipe.getOutputs())));
}
}
if(args.isEmpty() || args.contains("rollingmachine")) {
for(IRecipe recipe : RailcraftHelper.rolling) {
MineTweakerAPI.logCommand(String.format("mods.railcraft.RollingMachine.addRecipe(%s, %s);",
LogHelper.getStackDescription(recipe.getRecipeOutput()),
LogHelper.getCraftingDescription(recipe)));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
private Object getRockCrusherOutputDescription(List<Entry<ItemStack, Float>> outputs) {
if(outputs.isEmpty()) {
return "[], []";
}
StringBuilder sb = new StringBuilder();
sb.append('[');
for(Entry<ItemStack, Float> entry : outputs) {
sb.append(LogHelper.getStackDescription(entry.getKey())).append(", ");
}
sb.setLength(sb.length() - 2);
sb.append("], [");
for(Entry<ItemStack, Float> entry : outputs) {
sb.append(entry.getValue()).append(", ");
}
sb.setLength(sb.length() - 2);
sb.append("]");
return sb.toString();
}
}
@@ -1,62 +1,72 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.BlastFurnace")
public class BlastFurnace {
public static final String name = "Railcraft Blast Furnace";
@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);
private static class Add extends BaseListAddition<IBlastFurnaceRecipe> {
@SuppressWarnings("unchecked")
public Add(IBlastFurnaceRecipe recipe) {
super(BlastFurnace.name, (List<IBlastFurnaceRecipe>)RailcraftHelper.furnace);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((IBlastFurnaceRecipe) recipe).getOutput().getDisplayName();
public String getRecipeInfo(IBlastFurnaceRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<IBlastFurnaceRecipe> recipes = new LinkedList<IBlastFurnaceRecipe>();
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", BlastFurnace.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Blast Furnace", RailcraftHelper.furnace, stack);
private static class Remove extends BaseListRemoval<IBlastFurnaceRecipe> {
@SuppressWarnings("unchecked")
public Remove(List<IBlastFurnaceRecipe> recipes) {
super(BlastFurnace.name, (List<IBlastFurnaceRecipe>)RailcraftHelper.furnace, recipes);
}
@Override
public void apply() {
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
if (r.getOutput() != null && stack.isItemEqual(r.getOutput())) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
}
@Override
public String getRecipeInfo(IBlastFurnaceRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}
@@ -1,18 +1,24 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.mc1710.item.MCItemStack;
import mods.railcraft.api.crafting.ICokeOvenRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -20,6 +26,8 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.CokeOven")
public class CokeOven {
public static final String name = "Railcraft Coke Oven";
/**
* Adds a recipe for the Coke Oven
*
@@ -74,43 +82,49 @@ public class CokeOven {
MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime) ));
}
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<ICokeOvenRecipe> {
public Add(CokeOvenRecipe recipe) {
super("Railcraft CokeOven", RailcraftCraftingManager.cokeOven.getRecipes(), recipe);
@SuppressWarnings("unchecked")
public Add(ICokeOvenRecipe recipe) {
super(CokeOven.name, (List<ICokeOvenRecipe>)RailcraftCraftingManager.cokeOven.getRecipes());
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return " " + new MCItemStack(((ICokeOvenRecipe) recipe).getInput()) + " (Input)";
public String getRecipeInfo(ICokeOvenRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient output) {
List<ICokeOvenRecipe> recipes = new LinkedList<ICokeOvenRecipe>();
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", CokeOven.name, output.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Coke Oven", RailcraftHelper.oven, stack);
}
@SuppressWarnings("unchecked")
@Override
public void apply() {
for (ICokeOvenRecipe r : RailcraftHelper.oven) {
if (r.getOutput() != null && r.getOutput().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(r.getOutput(), stack)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<ICokeOvenRecipe> {
@SuppressWarnings("unchecked")
public Remove(List<ICokeOvenRecipe> recipes) {
super(CokeOven.name, (List<ICokeOvenRecipe>)RailcraftHelper.oven, recipes);
}
@Override
public String getRecipeInfo() {
return " " + new MCItemStack(stack) + " (Input)";
public String getRecipeInfo(ICokeOvenRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}
}
@@ -1,63 +1,82 @@
package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.IRockCrusherRecipe;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.RockCrusher")
public class RockCrusher {
public static final String name = "Railcraft Rock Crusher";
@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++)
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 {
private static class Add extends BaseListAddition<IRockCrusherRecipe> {
@SuppressWarnings("unchecked")
public Add(IRockCrusherRecipe recipe) {
super("Rock Crusher", RailcraftHelper.crusher, recipe);
super(RockCrusher.name, (List<IRockCrusherRecipe>)RailcraftHelper.crusher);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((IRockCrusherRecipe) recipe).getInput().getDisplayName();
public String getRecipeInfo(IRockCrusherRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
public static void removeRecipe(IIngredient input) {
List<IRockCrusherRecipe> recipes = new LinkedList<IRockCrusherRecipe>();
for (IRockCrusherRecipe r : RailcraftHelper.crusher) {
if (r.getInput() != null && matches(input, toIItemStack(r.getInput()))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", RockCrusher.name, input.toString()));
}
}
private static class Remove extends BaseListRemoval {
public Remove(ItemStack stack) {
super("Rock Crusher", RailcraftHelper.crusher, stack);
private static class Remove extends BaseListRemoval<IRockCrusherRecipe> {
@SuppressWarnings("unchecked")
public Remove(List<IRockCrusherRecipe> recipes) {
super("Rock Crusher", (List<IRockCrusherRecipe>)RailcraftHelper.crusher, recipes);
}
@Override
public void apply() {
for (IRockCrusherRecipe r : RailcraftHelper.crusher) {
if (r.getInput() != null && areEqual(r.getInput(), stack)) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
public String getRecipeInfo(IRockCrusherRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}
}
@@ -3,15 +3,17 @@ package modtweaker2.mods.railcraft.handlers;
import static modtweaker2.helpers.InputHelper.toObjects;
import static modtweaker2.helpers.InputHelper.toShapedObjects;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import mods.railcraft.api.crafting.RailcraftCraftingManager;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.railcraft.RailcraftHelper;
import modtweaker2.utils.BaseCraftingAddition;
import modtweaker2.utils.BaseCraftingRemoval;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import stanhebben.zenscript.annotations.ZenClass;
@@ -19,42 +21,42 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.railcraft.Rolling")
public class RollingMachine {
public static final String name = "Railcraft Rolling Machine";
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients))));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
MineTweakerAPI.apply(new Add(new ShapelessOreRecipe(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() {
RailcraftHelper.rolling.add(new ShapedOreRecipe(output, recipe));
}
@Override
public void applyShapeless() {
RailcraftHelper.rolling.add(new ShapelessOreRecipe(output, recipe));
public Add(IRecipe recipe) {
super(RollingMachine.name, RailcraftHelper.rolling);
recipes.add(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
public static void removeRecipe(IIngredient ingredient) {
List<IRecipe> recipes = BaseCraftingRemoval.getRecipes(RailcraftHelper.rolling, ingredient);
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", RollingMachine.name, ingredient.toString()));
}
}
private static class Remove extends BaseCraftingRemoval {
public Remove(ItemStack stack) {
super("Rolling Machine", RailcraftHelper.rolling, stack);
public Remove(List<IRecipe> recipes) {
super(RollingMachine.name, RailcraftHelper.rolling, recipes);
}
}
}
@@ -13,9 +13,9 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.ToolMaterial;
public class MaterialLogger implements ICommandFunction {
private static ArrayList<String> materials = new ArrayList();
private static ArrayList<String> materials = new ArrayList<String>();
static {
materials = new ArrayList();
materials = new ArrayList<String>();
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
materials.add(entry.getKey());
}
@@ -1,14 +1,15 @@
package modtweaker2.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 modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.AlloyMix;
@@ -20,13 +21,14 @@ import tconstruct.library.modifier.ItemModifier;
import tconstruct.library.tools.ToolMaterial;
public class TConstructHelper {
public static HashMap<String, Integer> mappings = new HashMap();
public static HashMap<String, Integer> mappings = new HashMap<String, Integer>();
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 Map<Fluid, Integer[]> fuelList = null;
public static List<ItemModifier> modifiers = null;
public static List<ItemModifier> modifiers_clone = null;
@@ -39,12 +41,13 @@ public class TConstructHelper {
basinCasting = TConstructRegistry.getBasinCasting().getCastingRecipes();
tableCasting = TConstructRegistry.getTableCasting().getCastingRecipes();
modifiers = ModifyBuilder.instance.itemModifiers;
modifiers_clone = new ArrayList(modifiers);
modifiers_clone = new ArrayList<ItemModifier>(modifiers);
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
mappings.put(entry.getValue().materialName, entry.getKey());
}
fuelList = ReflectionHelper.getObject(tconstruct.library.crafting.Smeltery.instance, "smelteryFuels");
} catch (Exception e) {}
}
@@ -58,14 +61,10 @@ public class TConstructHelper {
//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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class),
input,
time,
output);
}
public static String getMaterialFromID(int id) {
@@ -73,13 +72,10 @@ public class TConstructHelper {
}
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");
}
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(ItemKey.class, ItemStack.class, int.class, int.class, String.class),
item,
damage,
value,
material);
}
}
@@ -0,0 +1,103 @@
package modtweaker2.mods.tconstruct.commands;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import mantle.utils.ItemMetaWrapper;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.StringHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.crafting.AlloyMix;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.DryingRackRecipes;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
public class TConstructLogger implements ICommandFunction {
private static final List<String> validArguments = new LinkedList<String>();
static {
validArguments.add("casting");
validArguments.add("drying");
validArguments.add("smeltery");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
} else {
if(args.isEmpty() || args.contains("casting")) {
for(CastingRecipe recipe : TConstructHelper.basinCasting) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);",
LogHelper.getStackDescription(recipe.output),
LogHelper.getStackDescription(recipe.castingMetal),
LogHelper.getStackDescription(recipe.cast),
recipe.consumeCast,
recipe.coolTime));
}
for(CastingRecipe recipe : TConstructHelper.tableCasting) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);",
LogHelper.getStackDescription(recipe.output),
LogHelper.getStackDescription(recipe.castingMetal),
LogHelper.getStackDescription(recipe.cast),
recipe.consumeCast,
recipe.coolTime));
}
}
if(args.isEmpty() || args.contains("drying")) {
for(DryingRecipe recipe : DryingRackRecipes.recipes) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);",
LogHelper.getStackDescription(recipe.input),
LogHelper.getStackDescription(recipe.result),
recipe.time));
}
}
if(args.isEmpty() || args.contains("smeltery")) {
for(Entry<ItemMetaWrapper, FluidStack> recipe : TConstructHelper.smeltingList.entrySet()) {
int temperature = TConstructHelper.temperatureList.get(recipe.getKey());
ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey());
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);",
LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)),
LogHelper.getStackDescription(recipe.getValue()),
temperature,
LogHelper.getStackDescription(renderItem)));
}
for(AlloyMix recipe : TConstructHelper.alloys) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);",
LogHelper.getStackDescription(recipe.result),
LogHelper.getListDescription(recipe.mixers)));
}
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);",
LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)),
fuel.getValue()[0],
fuel.getValue()[1]));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}
@@ -1,21 +1,24 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientAny;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@@ -23,116 +26,108 @@ import tconstruct.library.crafting.CastingRecipe;
@ZenClass("mods.tconstruct.Casting")
public class Casting {
//Adding a TConstruct Casting recipe
protected static final String name = "TConstruct Casting";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
if(metal == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
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) {
if(metal == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
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);
private static class Add extends BaseListAddition<CastingRecipe> {
public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
super(Casting.name, list);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((CastingRecipe) recipe).output.getDisplayName();
protected String getRecipeInfo(CastingRecipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Removing a TConstruct Casting recipe
@ZenMethod
public static void removeBasinRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.basinCasting, RecipeComponent.Output));
}
@ZenMethod
public static void removeTableRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.tableCasting, RecipeComponent.Output));
public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
removeRecipe(output, material, cast, TConstructHelper.tableCasting);
}
@ZenMethod
public static void removeBasinMaterial(ILiquidStack fluid) {
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.basinCasting));
}
public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
@ZenMethod
public static void removeTableMaterial(ILiquidStack fluid) {
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.tableCasting));
removeRecipe(output, material, cast, TConstructHelper.basinCasting);
}
@ZenMethod
public static void removeCastRecipes(IItemStack cast) {
MineTweakerAPI.apply(new Remove((toStack(cast)), TConstructHelper.tableCasting, RecipeComponent.Cast));
public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List<CastingRecipe> list) {
if(output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(material == null) {
material = IngredientAny.INSTANCE;
}
if(cast == null) {
cast = IngredientAny.INSTANCE;
}
List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
for(CastingRecipe recipe : list) {
if(recipe != null) {
if (!matches(output, toIItemStack(recipe.output))) {
continue;
}
if (!matches(material, toILiquidStack(recipe.castingMetal))) {
continue;
}
if(!matches(cast, toIItemStack(recipe.cast))) {
continue;
}
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for output %s, material %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString()));
}
}
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval {
protected final RecipeComponent component;
public Remove(ItemStack item, ArrayList list, RecipeComponent component) {
super("TConstruct Casting", list, item);
this.component = component;
}
public Remove(FluidStack fluid, ArrayList list) {
super("TConstruct Casting", list, fluid);
this.component = RecipeComponent.Material;
}
// Loops through the registry, to find all items that matches, then removes them
@Override
public void apply() {
for (Iterator<CastingRecipe> iterator = ((ArrayList<CastingRecipe>)list).iterator(); iterator.hasNext();) {
CastingRecipe r = iterator.next();
switch(component)
{
case Cast:
if (r.cast != null && areEqual(r.cast, stack)) {
recipes.add(r);
}
break;
case Material:
if (r.castingMetal != null && r.castingMetal.isFluidEqual(fluid)) {
recipes.add(r);
}
break;
case Output:
if (r.output != null && areEqual(r.output, stack)) {
recipes.add(r);
}
break;
}
}
super.apply();
}
private static class Remove extends BaseListRemoval<CastingRecipe> {
public Remove(List<CastingRecipe> list, List<CastingRecipe> recipes) {
super(Casting.name, list, recipes);
}
@Override
public String getRecipeInfo() {
if(component == RecipeComponent.Material)
return fluid.getLocalizedName();
else
return stack.getDisplayName();
protected String getRecipeInfo(CastingRecipe recipe) {
return LogHelper.getStackDescription(recipe.output);
}
}
public enum RecipeComponent {
Output,
Cast,
Material
}
}
@@ -1,16 +1,18 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import tconstruct.library.crafting.DryingRackRecipes;
@@ -18,21 +20,31 @@ import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
@ZenClass("mods.tconstruct.Drying")
public class Drying {
//Adding a TConstruct Drying Rack recipe
protected static final String name = "TConstruct Drying Rack";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int time) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
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 {
private static class Add extends BaseListAddition<DryingRecipe> {
public Add(DryingRecipe recipe) {
super("TConstruct Drying Rack", DryingRackRecipes.recipes, recipe);
super(Drying.name, DryingRackRecipes.recipes);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((DryingRecipe) recipe).result.getDisplayName();
protected String getRecipeInfo(DryingRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
@@ -40,30 +52,31 @@ public class Drying {
//Removing a TConstruct Drying Rack recipe
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove((toStack(output))));
public static void removeRecipe(IIngredient ingredient) {
List<DryingRecipe> recipes = new LinkedList<DryingRecipe>();
for (DryingRecipe recipe : DryingRackRecipes.recipes) {
if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
}
}
//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)) {
recipes.add(r);
}
}
super.apply();
private static class Remove extends BaseListRemoval<DryingRecipe> {
public Remove(List<DryingRecipe> list) {
super(Drying.name, DryingRackRecipes.recipes, list);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(DryingRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
}
@@ -1,8 +1,10 @@
package modtweaker2.mods.tconstruct.handlers;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
@@ -11,28 +13,36 @@ import tconstruct.library.modifier.ItemModifier;
@ZenClass("mods.tconstruct.Modifiers")
public class Modifiers {
protected static final String name = "TConstruct Modifier";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(String mod) {
MineTweakerAPI.apply(new Remove(mod));
List<ItemModifier> recipes = new LinkedList<ItemModifier>();
for (ItemModifier recipe : TConstructHelper.modifiers) {
if (recipe.key.equals(mod)) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, 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;
private static class Remove extends BaseListRemoval<ItemModifier>{
public Remove(List<ItemModifier> recipes) {
super(Modifiers.name, TConstructHelper.modifiers, recipes);
}
@Override
public void apply() {
for (ItemModifier m : (List<ItemModifier>) list) {
if (m.key.equals(check)) {
recipes. add(m);
}
}
super.apply();
protected String getRecipeInfo(ItemModifier recipe) {
return recipe.key;
}
}
}
@@ -3,26 +3,34 @@ package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.isABlock;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toFluids;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mantle.utils.ItemMetaWrapper;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.oredict.IOreDictEntry;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseDescriptionAddition;
import modtweaker2.utils.BaseDescriptionRemoval;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import modtweaker2.utils.BaseMapAddition;
import modtweaker2.utils.BaseMapRemoval;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
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;
@@ -30,24 +38,34 @@ import tconstruct.library.crafting.AlloyMix;
@ZenClass("mods.tconstruct.Smeltery")
public class Smeltery {
public static final String nameFuel = "TConstruct Smeltery - Fuel";
public static final String nameMelting = "TConstruct Smeltery - Melting";
public static final String nameAlloy = "TConstruct Smeltery - Alloy";
/********************************************** TConstruct Alloy Recipes **********************************************/
// Adding a TConstruct Alloy recipe
@ZenMethod
public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy));
return;
}
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 {
private static class AddAlloy extends BaseListAddition<AlloyMix> {
public AddAlloy(AlloyMix recipe) {
super("Smeltery - Alloy", TConstructHelper.alloys, recipe);
super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
this.recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return ((AlloyMix) recipe).result.getFluid().getName();
protected String getRecipeInfo(AlloyMix recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
@@ -55,146 +73,228 @@ public class Smeltery {
// Removing a TConstruct Alloy recipe
@ZenMethod
public static void removeAlloy(ILiquidStack output) {
MineTweakerAPI.apply(new RemoveAlloy((toFluid(output))));
public static void removeAlloy(IIngredient output) {
List<AlloyMix> recipes = new LinkedList<AlloyMix>();
for(AlloyMix r : TConstructHelper.alloys) {
if(r != null && matches(output, toILiquidStack(r.result))) {
recipes.add(r);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveAlloy(recipes));
} else {
LogHelper.logError(String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString()));
}
}
// 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);
private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
public RemoveAlloy(List<AlloyMix> recipes) {
super(nameAlloy, TConstructHelper.alloys, recipes);
}
// 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 && fluid != null && r.result.getFluid() == fluid.getFluid()) {
recipes.add(r);
}
}
super.apply();
}
@Override
public String getRecipeInfo() {
return fluid.getFluid().getName();
}
@Override
protected String getRecipeInfo(AlloyMix recipe) {
return LogHelper.getStackDescription(recipe.result);
}
}
/********************************************** 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)));
}
public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) {
if(input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting));
return;
}
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
for(IItemStack in : input.getItems()) {
if(block == null && !isABlock(toStack(in))) {
LogHelper.logWarning(String.format("Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", in.toString(), nameMelting));
} else {
recipes.add(new MeltingRecipe(toStack(in), toFluid(output), temp, block == null ? toStack(in) : toStack(block)));
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new AddMelting(recipes));
} else {
LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString()));
}
}
@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);
}
}
private static class AddMelting extends BaseListAddition<MeltingRecipe> {
// 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;
public AddMelting(List<MeltingRecipe> recipes) {
super(nameMelting, null, recipes);
}
// 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);
for(MeltingRecipe recipe : recipes) {
tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
successful.add(recipe);
}
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
public void undo() {
for(MeltingRecipe recipe : successful) {
TConstructHelper.smeltingList.remove(recipe.meta);
TConstructHelper.temperatureList.remove(recipe.meta);
TConstructHelper.renderIndex.remove(recipe.meta);
}
}
@Override
public String getRecipeInfo(MeltingRecipe recipe) {
return LogHelper.getStackDescription(recipe.input);
}
}
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Removing a TConstruct Melting recipe
@ZenMethod
public static void removeMelting(IItemStack input) {
MineTweakerAPI.apply(new RemoveMelting((toStack(input))));
public static void removeMelting(IIngredient input) {
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
for(ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) {
ItemStack in = new ItemStack(meta.item, 1, meta.meta);
if(matches(input, toIItemStack(in))) {
recipes.add(new MeltingRecipe(
in,
TConstructHelper.smeltingList.get(meta),
TConstructHelper.temperatureList.get(meta),
TConstructHelper.renderIndex.get(meta)));
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString()));
}
}
@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;
private static class RemoveMelting extends BaseListRemoval<MeltingRecipe> {
public RemoveMelting(List<MeltingRecipe> recipes) {
super(nameMelting, null, recipes);
}
// 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);
for(MeltingRecipe recipe : recipes) {
TConstructHelper.smeltingList.remove(recipe.meta);
TConstructHelper.temperatureList.remove(recipe.meta);
TConstructHelper.renderIndex.remove(recipe.meta);
successful.add(recipe);
}
}
// Reads the Melting recipe
@Override
@Override
public void undo() {
// tconstruct.library.crafting.Smeltery.instance.addMelting(input,
// Block.getBlockFromItem(renderer.getItem()),
// renderer.getItemDamage(), temp, fluid);
for(MeltingRecipe recipe : successful) {
tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
}
}
@Override
public String getRecipeInfo() {
return input.getDisplayName();
public String getRecipeInfo(MeltingRecipe recipe) {
return LogHelper.getStackDescription(recipe.input);
}
}
protected static class MeltingRecipe {
public final ItemMetaWrapper meta;
public final ItemStack input;
public final FluidStack fluid;
public final Integer temperature;
public final ItemStack renderer;
protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) {
this.input = input;
this.fluid = fluid;
this.temperature = temperature;
this.renderer = renderer;
this.meta = new ItemMetaWrapper(input);
}
public Block getRendererBlock() {
return Block.getBlockFromItem(renderer.getItem());
}
public int getRendererMeta() {
return renderer.getItemDamage();
}
}
/********************************************** TConstruct Fuel Recipes **********************************************/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeFuel(IIngredient input) {
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
recipes.put(fuel.getKey(), fuel.getValue());
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveFuel(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
}
}
public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
public RemoveFuel(Map<Fluid, Integer[]> recipes) {
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
}
@Override
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addFuel(ILiquidStack liquid, int power, int duration) {
if(liquid == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel));
return;
}
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
MineTweakerAPI.apply(new AddFuel(recipes));
}
public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
public AddFuel(Map<Fluid, Integer[]> recipes) {
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
}
@Override
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
}
}
}
@@ -1,8 +1,15 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -63,51 +70,49 @@ public class TiCTweaks {
}
// Tweaks for setting repair materials
private static class Add extends BaseListAddition {
private static class Add extends BaseListAddition<ItemKey> {
public Add(ItemKey recipe) {
super("Repair Material", PatternBuilder.instance.materials, recipe);
super("Repair Material", PatternBuilder.instance.materials);
recipes.add(recipe);
}
@Override
public String getRecipeInfo() {
return new ItemStack(((ItemKey) recipe).item, 1, ((ItemKey) recipe).damage).getDisplayName();
protected String getRecipeInfo(ItemKey recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
}
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRepairMaterial(IItemStack output, @Optional String material) {
MineTweakerAPI.apply(new Remove(toStack(output), material));
public static void removeRepairMaterial(IIngredient output, @Optional String material) {
List<ItemKey> recipes = new LinkedList<ItemKey>();
for (ItemKey recipe : PatternBuilder.instance.materials) {
IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage));
if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) {
if (output.matches(clone)) {
recipes.add(recipe);
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
}
}
// 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)) {
recipes.add(r);
}
}
}
super.apply();
private static class Remove extends BaseListRemoval<ItemKey> {
public Remove(List<ItemKey> recipes) {
super("Repair Material", PatternBuilder.instance.materials, recipes);
}
@Override
public String getRecipeInfo() {
return stack.getDisplayName();
protected String getRecipeInfo(ItemKey recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
}
}
}
@@ -1,14 +1,17 @@
package modtweaker2.mods.tfcraft.handlers;
import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.InputHelper.toStack;
import static com.bioxx.tfc.api.Crafting.AnvilReq.getReqFromInt;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
@@ -21,10 +24,15 @@ import com.bioxx.tfc.api.Crafting.AnvilRecipe;
@ZenClass("mods.tfcraft.Anvil")
public class Anvil {
public static final String nameRegular = "TFC Anvil-Regular";
public static final String nameWeld = "TFC Anvil-Weld";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void add(IItemStack input1, IItemStack input2, String plan, int value, boolean flux, int req, IItemStack output){
MineTweakerAPI.apply(new Add(new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output))));
addRecipe(nameRegular, TFCHelper.anvilRecipes, new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output)));
}
/**
@@ -33,60 +41,63 @@ public class Anvil {
*/
@ZenMethod
public static void addWeld(IItemStack input1, IItemStack input2, int req, IItemStack output){
MineTweakerAPI.apply(new AddWeld(new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output))));
addRecipe(nameWeld, TFCHelper.anvilWeldRecipes, new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output)));
}
@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new Remove(toStack(stack)));
}
@ZenMethod
public static void removeWeld(IItemStack stack){
MineTweakerAPI.apply(new RemoveWeld(toStack(stack)));
}
private static class Add extends BaseListAddition{
public Add(AnvilRecipe recipe) {
super("Anvil-Regular", TFCHelper.anvilRecipes, recipe);
}
}
private static class AddWeld extends BaseListAddition{
public AddWeld(AnvilRecipe recipe) {
super("Anvil-Weld", TFCHelper.anvilWeldRecipes, recipe);
}
}
private static class Remove extends BaseListRemoval{
public Remove(ItemStack out){
super("Anvil-Remove-Regular", TFCHelper.anvilRecipes, out);
}
public static void addRecipe(String name, List<AnvilRecipe> list, AnvilRecipe recipe) {
List<AnvilRecipe> recipes = new LinkedList<AnvilRecipe>();
recipes.add(recipe);
MineTweakerAPI.apply(new Add(name, list, recipes));
}
@Override
public void apply() {
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
recipes.add(recipe);
}
}
super.apply();
private static class Add extends BaseListAddition<AnvilRecipe> {
public Add(String name, List<AnvilRecipe> list, List<AnvilRecipe> recipes) {
super(name, list, recipes);
}
@Override
protected String getRecipeInfo(AnvilRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
private static class RemoveWeld extends BaseListRemoval{
public RemoveWeld(ItemStack out){
super("Anvil-Remove-Weld", TFCHelper.anvilWeldRecipes, out);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void remove(IIngredient ingredient) {
removeRecipe(nameRegular, TFCHelper.anvilRecipes, ingredient);
}
@ZenMethod
public static void removeWeld(IIngredient ingredient) {
removeRecipe(nameWeld, TFCHelper.anvilWeldRecipes, ingredient);
}
public static void removeRecipe(String name, List<AnvilRecipe> list, IIngredient ingredient) {
List<AnvilRecipe> recipes = new LinkedList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && matches(ingredient, toIItemStack(recipe.getCraftingResult()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(name, list, recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored.", name, ingredient.toString()));
}
}
private static class Remove extends BaseListRemoval<AnvilRecipe> {
public Remove(String name, List<AnvilRecipe> list, List<AnvilRecipe> recipes){
super(name, list, recipes);
}
@Override
public void apply() {
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && recipe.getCraftingResult() == stack){
recipes.add(recipe);
}
}
super.apply();
protected String getRecipeInfo(AnvilRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingResult());
}
}
}
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff. Show more