mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-28 07:55:58 +00:00
Mek v8
This commit is contained in:
1 parent
cf3ce11fc8
commit
2cc4aff86b
21 files changed
+285
-73
No files matched your search
@@ -5,14 +5,18 @@ 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.api.infuse.InfusionInput;
|
||||
import mekanism.api.infuse.InfusionOutput;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
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;
|
||||
@@ -22,42 +26,62 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
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));
|
||||
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) {
|
||||
MineTweakerAPI.apply(new Remove("METALLURGIC_INFUSER", Recipe.METALLURGIC_INFUSER.get(), new InfusionOutput(null, toStack(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() {
|
||||
ArrayList<InfusionInput> recipesToRemove = new ArrayList<InfusionInput>();
|
||||
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;
|
||||
recipesToRemove.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (InfusionInput r : recipesToRemove) {
|
||||
map.remove(r);
|
||||
}
|
||||
recipe = map.get(key);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
for (Object recipe : removed)
|
||||
{
|
||||
map.put(key, recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user