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

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

No files matched your search

@@ -0,0 +1,41 @@
package modtweaker2.mods.mekanism;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.gas.GasBracketHandler;
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.util.TweakerPlugin;
public class Mekanism extends TweakerPlugin {
public Mekanism() {
MineTweakerAPI.registerBracketHandler(new GasBracketHandler());
MineTweakerAPI.registerClass(Combiner.class);
MineTweakerAPI.registerClass(Compressor.class);
MineTweakerAPI.registerClass(Crusher.class);
MineTweakerAPI.registerClass(Enrichment.class);
MineTweakerAPI.registerClass(Infuser.class);
MineTweakerAPI.registerClass(Purification.class);
MineTweakerAPI.registerClass(Reaction.class);
MineTweakerAPI.registerClass(Sawmill.class);
MineTweakerAPI.registerClass(Separator.class);
MineTweakerAPI.registerClass(ChemicalCrystallizer.class);
MineTweakerAPI.registerClass(ChemicalDissolution.class);
MineTweakerAPI.registerClass(ChemicalInfuser.class);
MineTweakerAPI.registerClass(ChemicalInjection.class);
MineTweakerAPI.registerClass(ChemicalOxidizer.class);
MineTweakerAPI.registerClass(ChemicalWasher.class);
}
}
@@ -0,0 +1,27 @@
package modtweaker2.mods.mekanism;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import modtweaker2.mods.mekanism.gas.IGasStack;
public class MekanismHelper {
private MekanismHelper() {}
public static GasStack toGas(IGasStack iStack) {
if (iStack == null) {
return null;
} else return new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
}
public static GasStack[] toGases(IIngredient[] input) {
return toGases((IGasStack[]) input);
}
public static GasStack[] toGases(IGasStack[] iStack) {
GasStack[] stack = new GasStack[iStack.length];
for (int i = 0; i < stack.length; i++)
stack[i] = toGas(iStack[i]);
return stack;
}
}
@@ -0,0 +1,85 @@
package modtweaker2.mods.mekanism.gas;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.IBracketHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.BracketHandler;
import minetweaker.api.item.IngredientAny;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.util.ZenPosition;
@BracketHandler(priority = 100)
public class GasBracketHandler implements IBracketHandler {
public static IGasStack getGas(String name) {
Gas gas = GasRegistry.getGas(name);
if (gas != null) {
return new MCGasStack(new GasStack(gas, 1));
} else {
return null;
}
}
private final IZenSymbol symbolAny;
private final IJavaMethod method;
public GasBracketHandler() {
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
method = MineTweakerAPI.getJavaMethod(GasBracketHandler.class, "getGas", String.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
// any symbol
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
return symbolAny;
}
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("gas") && tokens.get(1).getValue().equals(":")) {
return find(environment, tokens, 2, tokens.size());
}
}
return null;
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
valueBuilder.append(token.getValue());
}
Gas gas = GasRegistry.getGas(valueBuilder.toString());
if (gas != null) {
return new GasReferenceSymbol(environment, valueBuilder.toString());
}
return null;
}
private class GasReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
public GasReferenceSymbol(IEnvironmentGlobal environment, String name) {
this.environment = environment;
this.name = name;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
}
}
}
@@ -0,0 +1,38 @@
package modtweaker2.mods.mekanism.gas;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
public class GasLogger implements ICommandFunction {
public static final Comparator<Gas> COMPARATOR = new Compare();
private static class Compare implements Comparator<Gas> {
@Override
public int compare(Gas o1, Gas o2) {
return o1.getName().compareTo(o2.getName());
}
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<Gas> gases = GasRegistry.getRegisteredGasses();
System.out.println("Gases: " + GasRegistry.getRegisteredGasses().size());
Collections.sort(gases, COMPARATOR);
for (Gas gas : gases) {
System.out.println("Gas " + gas.getName());
MineTweakerAPI.logCommand("<" + gas.getName() + "> -- " + gas.getLocalizedName());
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
@@ -0,0 +1,18 @@
package modtweaker2.mods.mekanism.gas;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.gas.IGasDefinition")
public interface IGasDefinition {
@ZenOperator(OperatorType.MUL)
public IGasStack asStack(int millibuckets);
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
}
@@ -0,0 +1,28 @@
package modtweaker2.mods.mekanism.gas;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.gas.IGasStack")
public interface IGasStack {
@ZenGetter("definition")
public IGasDefinition getDefinition();
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
@ZenGetter("amount")
public int getAmount();
@ZenOperator(OperatorType.MUL)
@ZenMethod
public IGasStack withAmount(int amount);
public Object getInternal();
}
@@ -0,0 +1,28 @@
package modtweaker2.mods.mekanism.gas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
public class MCGasDefinition implements IGasDefinition {
private final Gas gas;
public MCGasDefinition(Gas gas) {
this.gas = gas;
}
@Override
public String getName() {
return gas.getName();
}
@Override
public String getDisplayName() {
return gas.getLocalizedName();
}
@Override
public IGasStack asStack(int millibuckets) {
return new MCGasStack(new GasStack(gas, millibuckets));
}
}
@@ -0,0 +1,45 @@
package modtweaker2.mods.mekanism.gas;
import mekanism.api.gas.GasStack;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
public class MCGasStack implements IGasStack {
private final GasStack stack;
public MCGasStack(GasStack stack) {
this.stack = stack;
}
@Override
public IGasDefinition getDefinition() {
return new MCGasDefinition(stack.getGas());
}
@Override
public String getName() {
return stack.getGas().getName();
}
@Override
public String getDisplayName() {
return stack.getGas().getLocalizedName();
}
@Override
public int getAmount() {
return stack.amount;
}
@Override
public IGasStack withAmount(int amount) {
GasStack result = new GasStack(stack.getGas(), amount);
return new MCGasStack(result);
}
@Override
public Object getInternal() {
return stack;
}
}
@@ -0,0 +1,25 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.chemical.Crystallizer")
public class ChemicalCrystallizer {
@ZenMethod
public static void addRecipe(IGasStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toGas(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_CRYSTALLIZER", Recipe.CHEMICAL_CRYSTALLIZER.get(), toStack(output)));
}
}
@@ -0,0 +1,78 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import modtweaker2.helpers.InputHelper;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.*;
@ZenClass("mods.mekanism.chemical.Dissolution")
public class ChemicalDissolution {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toStack(input)));
}
@ZenMethod
public static void removeRecipe(IOreDictEntry input) {
List<ItemStack> stacks = OreDictionary.getOres(InputHelper.toString(input));
for (ItemStack stack : stacks) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), stack));
}
}
@ZenMethod
public static void removeRecipe(IGasStack input) {
MineTweakerAPI.apply(new Remove("CHEMICAL_DISSOLUTION_CHAMBER", Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), toGas(input)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
ItemStack key = (ItemStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof ItemStack && areEqual(key, (ItemStack) this.key)) {
this.key = key;
break;
} else if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,25 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.ChemicalPair;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.chemical.Infuser")
public class ChemicalInfuser {
@ZenMethod
public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) {
ChemicalPair pair = new ChemicalPair(toGas(left), toGas(right));
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output)));
}
}
@@ -0,0 +1,27 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.AdvancedInput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.chemical.Injection")
public class ChemicalInjection {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack gas, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), toGas(gas).getGas());
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INJECTION_CHAMBER", Recipe.CHEMICAL_INJECTION_CHAMBER.get(), toStack(output)));
}
}
@@ -0,0 +1,25 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.chemical.Oxidizer")
public class ChemicalOxidizer {
@ZenMethod
public static void addRecipe(IItemStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toStack(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_OXIDIZER", Recipe.CHEMICAL_OXIDIZER.get(), toGas(output)));
}
}
@@ -0,0 +1,54 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.chemical.Washer")
public class ChemicalWasher {
@ZenMethod
public static void addRecipe(IGasStack input, IGasStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(input), toGas(output)));
}
@ZenMethod
public static void removeRecipe(IGasStack output) {
MineTweakerAPI.apply(new Remove("CHEMICAL_WASHER", Recipe.CHEMICAL_WASHER.get(), toGas(output)));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
GasStack key = (GasStack) pairs.getKey();
GasStack value = (GasStack) pairs.getValue();
if (key != null) {
if (this.key instanceof GasStack && value.isGasEqual((GasStack) this.key)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,26 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Combiner")
public class Combiner {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidStone"));
MineTweakerAPI.apply(new AddMekanismRecipe("COMBINER", Recipe.COMBINER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("COMBINER", Recipe.COMBINER.get(), toStack(output)));
}
}
@@ -0,0 +1,26 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.mods.mekanism.util.RemoveMekanismRecipe;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Compressor")
public class Compressor {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("liquidOsmium"));
MineTweakerAPI.apply(new AddMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("OSMIUM_COMPRESSOR", Recipe.OSMIUM_COMPRESSOR.get(), toStack(output)));
}
}
@@ -0,0 +1,23 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
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.Crusher")
public class Crusher {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("CRUSHER", Recipe.CRUSHER.get(), toStack(output)));
}
}
@@ -0,0 +1,23 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
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.Enrichment")
public class Enrichment {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
MineTweakerAPI.apply(new AddMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input), toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new RemoveMekanismRecipe("ENRICHMENT_CHAMBER", Recipe.ENRICHMENT_CHAMBER.get(), toStack(input)));
}
}
@@ -0,0 +1,59 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfusionInput;
import mekanism.api.infuse.InfusionOutput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import 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) {
InfusionInput infuseIn = new InfusionInput(InfuseRegistry.get(type), infuse, toStack(input));
InfusionOutput infuseOut = new InfusionOutput(infuseIn, toStack(output));
MineTweakerAPI.apply(new AddMekanismRecipe("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), infuseIn, infuseOut));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(output))));
}
private static class Remove extends RemoveMekanismRecipe {
public Remove(String string, Map map, Object key) {
super(string, map, key);
}
@Override
public void apply() {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
InfusionInput key = (InfusionInput) pairs.getKey();
InfusionOutput value = (InfusionOutput) pairs.getValue();
if (key != null) {
if (this.key instanceof InfusionOutput && areEqual(value.resource, ((InfusionOutput) this.key).resource)) {
this.key = key;
break;
}
}
}
recipe = map.get(key);
map.remove(key);
}
}
}
@@ -0,0 +1,50 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.GasRegistry;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Purification")
public class Purification {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output) {
AdvancedInput aInput = new AdvancedInput(toStack(input), GasRegistry.getGas("oxygen"));
MineTweakerAPI.apply(new AddMekanismRecipe("PURIFICATION_CHAMBER", Recipe.PURIFICATION_CHAMBER.get(), aInput, toStack(output)));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Purification Chamber", Recipe.PURIFICATION_CHAMBER.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<AdvancedInput, ItemStack> entry : ((Map<AdvancedInput, ItemStack>) map).entrySet()) {
if (entry.getValue() != null && areEqual(entry.getValue(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,33 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import mekanism.api.PressurizedProducts;
import mekanism.api.PressurizedReactants;
import mekanism.api.PressurizedRecipe;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
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.Reaction")
public class Reaction {
@ZenMethod
public static void addRecipe(IItemStack solid, ILiquidStack liquid, IGasStack gas, IItemStack outItem, IGasStack outGas, double energy, int ticks) {
PressurizedReactants input = new PressurizedReactants(toStack(solid), toFluid(liquid), toGas(gas));
PressurizedRecipe recipe = new PressurizedRecipe(input, energy, new PressurizedProducts(toStack(outItem), toGas(outGas)), ticks);
MineTweakerAPI.apply(new AddMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), input, recipe));
}
@ZenMethod
public static void removeRecipe(IItemStack outItem, IGasStack outGas) {
PressurizedProducts output = new PressurizedProducts(toStack(outItem), toGas(outGas));
MineTweakerAPI.apply(new RemoveMekanismRecipe("PRESSURIZED_REACTION_CHAMBER", Recipe.PRESSURIZED_REACTION_CHAMBER.get(), output));
}
}
@@ -0,0 +1,52 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.util.BaseMapRemoval;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Sawmill")
public class Sawmill {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output1, @Optional IItemStack output2, @Optional double chance) {
ChanceOutput chanceOutput = new ChanceOutput(toStack(output1), toStack(output2), chance);
MineTweakerAPI.apply(new AddMekanismRecipe("PRECISION_SAWMILL", Recipe.PRECISION_SAWMILL.get(), toStack(input), chanceOutput));
Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
}
@ZenMethod
public static void removeRecipe(IItemStack input) {
MineTweakerAPI.apply(new Remove(toStack(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(ItemStack stack) {
super("Precision Sawmill", Recipe.PRECISION_SAWMILL.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<ItemStack, ChanceOutput> entry : ((Map<ItemStack, ChanceOutput>) map).entrySet()) {
if (entry.getKey() != null && areEqual(entry.getKey(), (ItemStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,50 @@
package modtweaker2.mods.mekanism.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.mods.mekanism.MekanismHelper.toGas;
import java.util.Map;
import mekanism.api.ChemicalPair;
import mekanism.common.recipe.RecipeHandler.Recipe;
import minetweaker.MineTweakerAPI;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
import modtweaker2.mods.mekanism.util.AddMekanismRecipe;
import modtweaker2.util.BaseMapRemoval;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.mekanism.Separator")
public class Separator {
@ZenMethod
public static void addRecipe(ILiquidStack input, IGasStack gas1, IGasStack gas2) {
ChemicalPair pair = new ChemicalPair(toGas(gas1), toGas(gas2));
MineTweakerAPI.apply(new AddMekanismRecipe("ELECTROLYTIC_SEPARATOR", Recipe.ELECTROLYTIC_SEPARATOR.get(), toFluid(input), pair));
}
@ZenMethod
public static void removeRecipe(ILiquidStack input) {
MineTweakerAPI.apply(new Remove(toFluid(input)));
}
private static class Remove extends BaseMapRemoval {
public Remove(FluidStack stack) {
super("Electrolytic Separator", Recipe.ELECTROLYTIC_SEPARATOR.get(), stack);
}
//We must search through the recipe entries so that we can assign the correct key for removal
@Override
public void apply() {
for (Map.Entry<FluidStack, ChemicalPair> entry : ((Map<FluidStack, ChemicalPair>) map).entrySet()) {
if (entry.getKey() != null && entry.getKey().isFluidEqual((FluidStack) stack)) {
key = entry.getKey();
break;
}
}
super.apply();
}
}
}
@@ -0,0 +1,42 @@
package modtweaker2.mods.mekanism.util;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.api.ChemicalPair;
import mekanism.api.PressurizedReactants;
import mekanism.api.gas.GasStack;
import mekanism.api.infuse.InfusionOutput;
import modtweaker2.util.BaseMapAddition;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class AddMekanismRecipe extends BaseMapAddition {
public AddMekanismRecipe(String str, Map map, Object key, Object recipe) {
super(str.toLowerCase(), map, key, recipe);
}
@Override
public String describe() {
if (recipe instanceof ItemStack) return "Adding " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName();
else if (recipe instanceof FluidStack) return "Adding " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName();
else if (recipe instanceof ChemicalPair) return "Adding " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName();
else if (recipe instanceof ChanceOutput) return "Adding " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName();
else if (recipe instanceof GasStack) return "Adding " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName();
else if (recipe instanceof PressurizedReactants) return "Adding " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName();
else if (recipe instanceof InfusionOutput) return "Adding " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName();
else return super.getRecipeInfo();
}
@Override
public String describeUndo() {
if (recipe instanceof ItemStack) return "Removing " + description + " Recipe for : " + ((ItemStack) recipe).getDisplayName();
else if (recipe instanceof FluidStack) return "Removing " + description + " Recipe for : " + ((FluidStack) recipe).getFluid().getLocalizedName();
else if (recipe instanceof ChemicalPair) return "Removing " + description + " Recipe for : " + ((ChemicalPair) recipe).leftGas.getGas().getLocalizedName();
else if (recipe instanceof ChanceOutput) return "Removing " + description + " Recipe for : " + ((ChanceOutput) recipe).primaryOutput.getDisplayName();
else if (recipe instanceof GasStack) return "Removing " + description + " Recipe for : " + ((GasStack) recipe).getGas().getLocalizedName();
else if (recipe instanceof PressurizedReactants) return "Removing " + description + " Recipe for : " + ((PressurizedReactants) recipe).getSolid().getDisplayName();
else if (recipe instanceof InfusionOutput) return "Removing " + description + " Recipe for : " + ((InfusionOutput) recipe).resource.getDisplayName();
else return super.getRecipeInfo();
}
}
@@ -0,0 +1,131 @@
package modtweaker2.mods.mekanism.util;
import static modtweaker2.helpers.StackHelper.areEqual;
import java.util.Iterator;
import java.util.Map;
import mekanism.api.ChanceOutput;
import mekanism.api.ChemicalPair;
import mekanism.api.PressurizedProducts;
import mekanism.api.PressurizedReactants;
import mekanism.api.PressurizedRecipe;
import mekanism.api.gas.GasStack;
import mekanism.api.infuse.InfusionOutput;
import modtweaker2.util.BaseMapRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class RemoveMekanismRecipe extends BaseMapRemoval {
private Object tmp;
public RemoveMekanismRecipe(String string, Map map, Object key) {
super(string.toLowerCase().replace('_', ' '), map, key, null);
this.tmp = key;
}
@Override
public void apply() {
try {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
Object value = pairs.getValue();
if (value != null) {
if (tmp instanceof ItemStack && value instanceof ItemStack) {
if (areEqual(((ItemStack) tmp), (ItemStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof FluidStack && value instanceof FluidStack) {
if (((FluidStack) tmp).isFluidEqual((FluidStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof GasStack && value instanceof GasStack) {
if (((GasStack) tmp).isGasEqual((GasStack) value)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ItemStack && value instanceof InfusionOutput) {
if (areEqual(((ItemStack) tmp), ((InfusionOutput) value).resource)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChemicalPair && value instanceof ChemicalPair) {
ChemicalPair par1 = (ChemicalPair) tmp;
ChemicalPair par2 = (ChemicalPair) value;
if (par1.leftGas.isGasEqual(par2.leftGas) && par1.rightGas.isGasEqual(par2.rightGas)) {
key = pairs.getKey();
break;
}
}
if (tmp instanceof ChanceOutput && value instanceof ChanceOutput) {
ChanceOutput par1 = (ChanceOutput) tmp;
ChanceOutput par2 = (ChanceOutput) value;
if (areEqual(par1.primaryOutput, par2.primaryOutput)) {
if (par1.secondaryOutput == null || (par1.secondaryOutput != null && par2.secondaryOutput != null && areEqual(par1.secondaryOutput, par2.secondaryOutput))) {
key = pairs.getKey();
break;
}
}
}
if (tmp instanceof PressurizedProducts && value instanceof PressurizedRecipe) {
PressurizedProducts par1 = (PressurizedProducts) tmp;
PressurizedProducts par2 = ((PressurizedRecipe) value).products;
if (areEqual(par1.getItemOutput(), (par2.getItemOutput()))) {
if (par1.getGasOutput().isGasEqual(par2.getGasOutput())) {
key = pairs.getKey();
break;
}
}
}
}
it.remove();
}
recipe = map.get(key);
} catch (Exception e) {
e.printStackTrace();
}
map.remove(key);
}
@Override
public String describe() {
if (tmp instanceof ItemStack) return "Removing " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack) return "Removing " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPair) return "Removing " + description + " Recipe for : " + ((ChemicalPair) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput) return "Removing " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack) return "Removing " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedReactants) return "Removing " + description + " Recipe for : " + ((PressurizedReactants) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionOutput) return "Removing " + description + " Recipe for : " + ((InfusionOutput) tmp).resource.getDisplayName();
else return super.getRecipeInfo();
}
@Override
public String describeUndo() {
if (tmp instanceof ItemStack) return "Restoring " + description + " Recipe for : " + ((ItemStack) tmp).getDisplayName();
else if (tmp instanceof FluidStack) return "Restoring " + description + " Recipe for : " + ((FluidStack) tmp).getFluid().getLocalizedName();
else if (tmp instanceof ChemicalPair) return "Restoring " + description + " Recipe for : " + ((ChemicalPair) tmp).leftGas.getGas().getLocalizedName();
else if (tmp instanceof ChanceOutput) return "Restoring " + description + " Recipe for : " + ((ChanceOutput) tmp).primaryOutput.getDisplayName();
else if (tmp instanceof GasStack) return "Restoring " + description + " Recipe for : " + ((GasStack) tmp).getGas().getLocalizedName();
else if (tmp instanceof PressurizedReactants) return "Restoring " + description + " Recipe for : " + ((PressurizedReactants) tmp).getSolid().getDisplayName();
else if (tmp instanceof InfusionOutput) return "Restoring " + description + " Recipe for : " + ((InfusionOutput) tmp).resource.getDisplayName();
else return super.getRecipeInfo();
}
}