diff --git a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java index 6970986..41f6b65 100644 --- a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java +++ b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java @@ -4,9 +4,7 @@ import java.util.regex.Pattern; 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.v8.ChemicalInfuser; import modtweaker2.mods.mekanism.handlers.ChemicalInjection; import modtweaker2.mods.mekanism.handlers.ChemicalOxidizer; import modtweaker2.mods.mekanism.handlers.ChemicalWasher; @@ -18,6 +16,9 @@ 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; @@ -30,11 +31,12 @@ public class Mekanism extends TweakerPlugin { MineTweakerAPI.registerClass(Compressor.class); MineTweakerAPI.registerClass(Crusher.class); MineTweakerAPI.registerClass(Enrichment.class); -// MineTweakerAPI.registerClass(Infuser.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(ChemicalCrystallizer.class); MineTweakerAPI.registerClass(ChemicalDissolution.class); MineTweakerAPI.registerClass(ChemicalInfuser.class); diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalCrystallizer.java b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalCrystallizer.java new file mode 100644 index 0000000..b8e37e4 --- /dev/null +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalCrystallizer.java @@ -0,0 +1,85 @@ +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 gasesToRemove = new ArrayList(); + for(GasInput stack : (Set)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); + } + } + + } +} diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalDissolution.java b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalDissolution.java new file mode 100644 index 0000000..8981dca --- /dev/null +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalDissolution.java @@ -0,0 +1,85 @@ +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; + + @SuppressWarnings("unused") + 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 toRemove = new ArrayList(); + for (ItemStackInput stack : (Set) 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); + } + } + + } +} diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalInfuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalInfuser.java new file mode 100644 index 0000000..ccdd458 --- /dev/null +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/ChemicalInfuser.java @@ -0,0 +1,89 @@ +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.inputs.InfusionInput; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; +import mekanism.common.recipe.outputs.GasOutput; +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.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 toRemove = new ArrayList(); + for (ChemicalPairInput stack : (Set) 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); + } + } + + } +} diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/v8/Infuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/Infuser.java new file mode 100644 index 0000000..2e11331 --- /dev/null +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/v8/Infuser.java @@ -0,0 +1,91 @@ +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; + + @SuppressWarnings("unused") + 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 toRemove = new ArrayList(); + for (InfusionInput stack : (Set) 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); + } + } + + } +}