Recoded MT support

This commit is contained in:
Modmuss50 2015-11-15 20:51:47 +00:00
parent 16f1a8de17
commit 78a7bcf4bc
8 changed files with 40 additions and 899 deletions

View file

@ -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<BlastFurnaceRecipe> removedRecipes = new ArrayList<BlastFurnaceRecipe>();
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;
}
}

View file

@ -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<CentrifugeRecipe> removedRecipes = new ArrayList<CentrifugeRecipe>();
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<CentrifugeRecipe> removedRecipes = new ArrayList<CentrifugeRecipe>();
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;
}
}

View file

@ -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<ChemicalReactorRecipe> removedRecipes = new ArrayList<ChemicalReactorRecipe>();
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;
}
}

View file

@ -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<GrinderRecipe> removedRecipes = new ArrayList<GrinderRecipe>();
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;
}
}

View file

@ -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<ImplosionCompressorRecipe> removedRecipes = new ArrayList<ImplosionCompressorRecipe>();
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;
}
}

View file

@ -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<IndustrialElectrolyzerRecipe> removedRecipes = new ArrayList<IndustrialElectrolyzerRecipe>();
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;
}
}

View file

@ -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<IndustrialSawmillRecipe> removedRecipes = new ArrayList<IndustrialSawmillRecipe>();
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;
}
}

View file

@ -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<PlateCuttingMachineRecipe> removedRecipes = new ArrayList<PlateCuttingMachineRecipe>();
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;
}
}