From 78a7bcf4bca9ab68668a0216d77c3eb760d83f33 Mon Sep 17 00:00:00 2001 From: Modmuss50 Date: Sun, 15 Nov 2015 20:51:47 +0000 Subject: [PATCH] Recoded MT support --- .../compat/minetweaker/MTBlastFurnace.java | 110 +----------- .../compat/minetweaker/MTCentrifuge.java | 169 +----------------- .../compat/minetweaker/MTChemicalReactor.java | 110 +----------- .../compat/minetweaker/MTGrinder.java | 110 +----------- .../minetweaker/MTImplosionCompressor.java | 110 +----------- .../minetweaker/MTIndustrialElectrolyzer.java | 110 +----------- .../minetweaker/MTIndustrialSawmill.java | 110 +----------- .../minetweaker/MTPlateCuttingMachine.java | 110 +----------- 8 files changed, 40 insertions(+), 899 deletions(-) diff --git a/src/main/java/techreborn/compat/minetweaker/MTBlastFurnace.java b/src/main/java/techreborn/compat/minetweaker/MTBlastFurnace.java index fa32a8213..822a032a8 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTBlastFurnace.java +++ b/src/main/java/techreborn/compat/minetweaker/MTBlastFurnace.java @@ -1,23 +1,15 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.BlastFurnaceRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.blastFurnace") -public class MTBlastFurnace { +public class MTBlastFurnace extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IIngredient input1, IIngredient input2, int ticktime, int euTick, int neededHeat) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1); @@ -25,103 +17,11 @@ public class MTBlastFurnace { BlastFurnaceRecipe r = new BlastFurnaceRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), ticktime, euTick, neededHeat); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final BlastFurnaceRecipe recipe; - - public Add(BlastFurnaceRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Blast Furnace Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Blast Furnace Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.blastFurnaceRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((BlastFurnaceRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (BlastFurnaceRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Blast Furnace Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Blast Furnace Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.blastFurnaceRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTCentrifuge.java b/src/main/java/techreborn/compat/minetweaker/MTCentrifuge.java index b109bc614..84eedd24b 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTCentrifuge.java +++ b/src/main/java/techreborn/compat/minetweaker/MTCentrifuge.java @@ -1,23 +1,15 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.CentrifugeRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.centrifuge") -public class MTCentrifuge { +public class MTCentrifuge extends MTGeneric{ @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1); @@ -25,162 +17,11 @@ public class MTCentrifuge { CentrifugeRecipe r = new CentrifugeRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), MinetweakerCompat.toStack(output3), MinetweakerCompat.toStack(output4), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final CentrifugeRecipe recipe; - - public Add(CentrifugeRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Centrifuge Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Centrifuge Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - @ZenMethod - public static void removeInputRecipe(IItemStack output) { - MineTweakerAPI.apply(new RemoveInput(MinetweakerCompat.toStack(output))); - } - - private static class RemoveInput implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public RemoveInput(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.centrifugeRecipe)) { - for (ItemStack stack : recipeType.getInputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((CentrifugeRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (CentrifugeRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Centrifuge Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Centrifuge Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.centrifugeRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((CentrifugeRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (CentrifugeRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Centrifuge Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Centrifuge Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.centrifugeRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTChemicalReactor.java b/src/main/java/techreborn/compat/minetweaker/MTChemicalReactor.java index 9f005d1fc..81284e002 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTChemicalReactor.java +++ b/src/main/java/techreborn/compat/minetweaker/MTChemicalReactor.java @@ -1,23 +1,15 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.ChemicalReactorRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.chemicalReactorRecipe") -public class MTChemicalReactor { +public class MTChemicalReactor extends MTGeneric{ @ZenMethod public static void addRecipe(IItemStack output1, IIngredient input1, IIngredient input2, int ticktime, int euTick) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1); @@ -25,103 +17,11 @@ public class MTChemicalReactor { ChemicalReactorRecipe r = new ChemicalReactorRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output1), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final ChemicalReactorRecipe recipe; - - public Add(ChemicalReactorRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Chemical Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Chemical Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.chemicalReactorRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((ChemicalReactorRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (ChemicalReactorRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Chemical Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Chemical Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.chemicalReactorRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTGrinder.java b/src/main/java/techreborn/compat/minetweaker/MTGrinder.java index 058cc6691..f7cca066c 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTGrinder.java +++ b/src/main/java/techreborn/compat/minetweaker/MTGrinder.java @@ -1,25 +1,17 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.GrinderRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.grinder") -public class MTGrinder { +public class MTGrinder extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) { addRecipe(output1, output2, output3, output4, input1, input2, null, ticktime, euTick); @@ -38,103 +30,11 @@ public class MTGrinder { GrinderRecipe r = new GrinderRecipe(oInput1, oInput2, fluidStack, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), MinetweakerCompat.toStack(output3), MinetweakerCompat.toStack(output4), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final GrinderRecipe recipe; - - public Add(GrinderRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Grinder Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Grinder Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.grinderRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((GrinderRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (GrinderRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Grinder Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Grinder Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.grinderRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTImplosionCompressor.java b/src/main/java/techreborn/compat/minetweaker/MTImplosionCompressor.java index ea90d028d..443aca7df 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTImplosionCompressor.java +++ b/src/main/java/techreborn/compat/minetweaker/MTImplosionCompressor.java @@ -1,23 +1,15 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.ImplosionCompressorRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.implosionCompressor") -public class MTImplosionCompressor { +public class MTImplosionCompressor extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IIngredient input1, IIngredient input2, int ticktime, int euTick) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1); @@ -26,103 +18,11 @@ public class MTImplosionCompressor { ImplosionCompressorRecipe r = new ImplosionCompressorRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final ImplosionCompressorRecipe recipe; - - public Add(ImplosionCompressorRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Implosion Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Implosion Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.implosionCompressorRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((ImplosionCompressorRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (ImplosionCompressorRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Implosion Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Implosion Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.implosionCompressorRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTIndustrialElectrolyzer.java b/src/main/java/techreborn/compat/minetweaker/MTIndustrialElectrolyzer.java index 037e9a531..c211118d5 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/compat/minetweaker/MTIndustrialElectrolyzer.java @@ -1,23 +1,15 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.industrialElectrolyzer") -public class MTIndustrialElectrolyzer { +public class MTIndustrialElectrolyzer extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient cells, IIngredient input2, int ticktime, int euTick) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(cells); @@ -25,103 +17,11 @@ public class MTIndustrialElectrolyzer { IndustrialElectrolyzerRecipe r = new IndustrialElectrolyzerRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), MinetweakerCompat.toStack(output3), MinetweakerCompat.toStack(output4), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final IndustrialElectrolyzerRecipe recipe; - - public Add(IndustrialElectrolyzerRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding IndustrialElectrolyzerRecipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing IndustrialElectrolyzerRecipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.industrialElectrolyzerRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((IndustrialElectrolyzerRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (IndustrialElectrolyzerRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing IndustrialElectrolyzerRecipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding IndustrialElectrolyzerRecipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.industrialElectrolyzerRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTIndustrialSawmill.java b/src/main/java/techreborn/compat/minetweaker/MTIndustrialSawmill.java index c58f686a2..6258833ae 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTIndustrialSawmill.java +++ b/src/main/java/techreborn/compat/minetweaker/MTIndustrialSawmill.java @@ -1,25 +1,17 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.IndustrialSawmillRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.industrialSawmill") -public class MTIndustrialSawmill { +public class MTIndustrialSawmill extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IIngredient input1, IIngredient input2, ILiquidStack fluid, int ticktime, int euTick) { @@ -49,103 +41,11 @@ public class MTIndustrialSawmill { IndustrialSawmillRecipe r = new IndustrialSawmillRecipe(oInput1, oInput2, fluidStack, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), MinetweakerCompat.toStack(output3), ticktime, euTick, useOreDic); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final IndustrialSawmillRecipe recipe; - - public Add(IndustrialSawmillRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding Sawmill Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing Sawmill Recipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.industrialSawmillRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((IndustrialSawmillRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (IndustrialSawmillRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing Sawmill Recipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding Sawmill Recipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.industrialSawmillRecipe; } } diff --git a/src/main/java/techreborn/compat/minetweaker/MTPlateCuttingMachine.java b/src/main/java/techreborn/compat/minetweaker/MTPlateCuttingMachine.java index 7d83d37a2..ed21714c3 100644 --- a/src/main/java/techreborn/compat/minetweaker/MTPlateCuttingMachine.java +++ b/src/main/java/techreborn/compat/minetweaker/MTPlateCuttingMachine.java @@ -1,126 +1,26 @@ package techreborn.compat.minetweaker; -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import net.minecraft.item.ItemStack; -import reborncore.common.util.ItemUtils; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import techreborn.api.recipe.IBaseRecipeType; -import techreborn.api.recipe.RecipeHandler; import techreborn.api.recipe.machines.PlateCuttingMachineRecipe; import techreborn.lib.Reference; -import java.util.ArrayList; -import java.util.List; - @ZenClass("mods.techreborn.plateCuttingMachine") -public class MTPlateCuttingMachine { +public class MTPlateCuttingMachine extends MTGeneric { @ZenMethod public static void addRecipe(IItemStack output, IIngredient input1, int ticktime, int euTick) { ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1); PlateCuttingMachineRecipe r = new PlateCuttingMachineRecipe(oInput1, MinetweakerCompat.toStack(output), ticktime, euTick); - MineTweakerAPI.apply(new Add(r)); + addRecipe(r); } - private static class Add implements IUndoableAction { - private final PlateCuttingMachineRecipe recipe; - - public Add(PlateCuttingMachineRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void apply() { - RecipeHandler.addRecipe(recipe); - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - RecipeHandler.recipeList.remove(recipe); - } - - @Override - public String describe() { - return "Adding PlateCuttingMachineRecipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public String describeUndo() { - return "Removing PlateCuttingMachineRecipe for " + recipe.getOutput(0).getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output))); - } - - private static class Remove implements IUndoableAction { - private final ItemStack output; - List removedRecipes = new ArrayList(); - - public Remove(ItemStack output) { - this.output = output; - } - - @Override - public void apply() { - for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.plateCuttingMachineRecipe)) { - for (ItemStack stack : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(stack, output, true, false)) { - removedRecipes.add((PlateCuttingMachineRecipe) recipeType); - RecipeHandler.recipeList.remove(recipeType); - break; - } - } - } - } - - @Override - public void undo() { - if (removedRecipes != null) { - for (PlateCuttingMachineRecipe recipe : removedRecipes) { - if (recipe != null) { - RecipeHandler.addRecipe(recipe); - } - } - } - - } - - @Override - public String describe() { - return "Removing PlateCuttingMachineRecipe for " + output.getDisplayName(); - } - - @Override - public String describeUndo() { - return "Re-Adding PlateCuttingMachineRecipe for " + output.getDisplayName(); - } - - @Override - public Object getOverrideKey() { - return null; - } - - @Override - public boolean canUndo() { - return true; - } + @Override + public String getMachineName() { + return Reference.plateCuttingMachineRecipe; } }