Mekanism v8 support

This commit is contained in:
Zixxl committed 2015-07-13 17:34:06 +02:00
1 parent 34a6c92939
commit 3d71e17b66
33 files changed
+1429 -1133

No files matched your search

+3 -1
View File
@@ -16,7 +16,8 @@ import modtweaker2.mods.chisel.commands.ChiselGroupLogger;
import modtweaker2.mods.chisel.commands.ChiselVariationLogger;
import modtweaker2.mods.exnihilo.commands.ExNihiloLogger;
import modtweaker2.mods.factorization.commands.FactorizationLogger;
import modtweaker2.mods.mekanism.gas.GasLogger;
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;
@@ -45,6 +46,7 @@ public class Commands {
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")) {
+2 -1
View File
@@ -16,6 +16,7 @@ import modtweaker2.mods.factorization.Factorization;
import modtweaker2.mods.forestry.Forestry;
import modtweaker2.mods.fsp.Steamcraft;
import modtweaker2.mods.mariculture.Mariculture;
import modtweaker2.mods.mekanism.Mekanism;
import modtweaker2.mods.metallurgy.Metallurgy;
import modtweaker2.mods.pneumaticcraft.PneumaticCraft;
import modtweaker2.mods.railcraft.Railcraft;
@@ -71,7 +72,7 @@ public class ModTweaker2 {
TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class);
TweakerPlugin.register("factorization", Factorization.class);
TweakerPlugin.register("Mariculture", Mariculture.class);
// TweakerPlugin.register("Mekanism", Mekanism.class);
TweakerPlugin.register("Mekanism", Mekanism.class);
TweakerPlugin.register("Metallurgy", Metallurgy.class);
TweakerPlugin.register("PneumaticCraft", PneumaticCraft.class);
TweakerPlugin.register("Railcraft", Railcraft.class);
@@ -3,6 +3,7 @@ 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;
@@ -56,48 +57,15 @@ public class LogHelper {
*/
public static String getStackDescription(Object object) {
if(object instanceof ItemStack) {
ItemStack stack = (ItemStack)object;
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();
return getStackDescription((ItemStack)object);
} else if (object instanceof FluidStack) {
FluidStack stack = (FluidStack)object;
StringBuilder sb = new StringBuilder();
sb.append("<liquid:").append(stack.getFluid().getName()).append('>');
if(stack.amount > 1) {
sb.append(" * ").append(stack.amount);
}
return sb.toString();
return getStackDescription((FluidStack)object);
} else if (object instanceof GasStack) {
return getStackDescription((GasStack)object);
} else if (object instanceof String) {
List<ItemStack> ores = OreDictionary.getOres((String)object);
// Check if string specifies an oredict entry
List<ItemStack> ores = OreDictionary.getOres((String)object);
if(!ores.isEmpty()) {
return "<ore:" + (String)object + ">";
} else {
@@ -110,6 +78,59 @@ public class LogHelper {
}
}
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();
@@ -1,10 +1,14 @@
package modtweaker2.helpers;
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;
@@ -105,4 +109,21 @@ public class StackHelper {
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;
}
}
@@ -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;
}
}
@@ -67,11 +67,11 @@ public abstract class BaseMapAddition<K, V> extends BaseMapModification<K, V> {
@Override
public String describe() {
return String.format("Adding %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo());
return String.format("[ModTweaker2] Adding %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo());
}
@Override
public String describeUndo() {
return String.format("Removing %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo());
return String.format("[ModTweaker2] Removing %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo());
}
}