diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java index 90f18b7..d407120 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java @@ -32,7 +32,7 @@ public class Grind { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) { if(input == null || output == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Grind.name)); + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } @@ -49,7 +49,7 @@ public class Grind { // Check if the recipe is already present, we don't want to add duplicates for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Grind.name, InputHelper.getStackDescription(toStack(input)))); + LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(toStack(input)))); return; } } diff --git a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java index ad2ea56..69f826f 100644 --- a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java +++ b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java @@ -2,6 +2,7 @@ package modtweaker2.mods.pneumaticcraft.handlers; import static modtweaker2.helpers.InputHelper.toIItemStack; import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.areEqual; import static modtweaker2.helpers.StackHelper.matches; import java.util.LinkedList; @@ -14,6 +15,7 @@ import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import net.minecraft.item.ItemStack; import pneumaticCraft.api.recipe.AssemblyRecipe; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -23,19 +25,39 @@ public class Assembly { public static final String name = "PneumaticCraft Assembly"; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod public static void addDrillRecipe(IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillRecipes)); + addRecipe(input, output, AssemblyRecipe.drillRecipes); } @ZenMethod public static void addLaserRecipe(IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.laserRecipes)); + addRecipe(input, output, AssemblyRecipe.laserRecipes); } @ZenMethod public static void addLaserDrillRecipe(IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), AssemblyRecipe.drillLaserRecipes)); + addRecipe(input, output, AssemblyRecipe.drillLaserRecipes); + } + + public static void addRecipe(IItemStack input, IItemStack output, List list) { + if(input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + + ItemStack in = toStack(input); + + for(AssemblyRecipe recipe : list) { + if(areEqual(recipe.getInput(), in)) { + LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, InputHelper.getStackDescription(in))); + return; + } + } + + MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), list)); } private static class Add extends BaseListAddition { @@ -79,7 +101,7 @@ public class Assembly { if(!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(list, recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Assembly.name, output.toString())); + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, output.toString())); } } diff --git a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java index d2f62e4..e5209f8 100644 --- a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java +++ b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java @@ -11,6 +11,7 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; +import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import net.minecraft.item.ItemStack; @@ -25,6 +26,11 @@ public class Pressure { @ZenMethod public static void addRecipe(IItemStack[] input, double pressure, IItemStack[] output, boolean asBlock) { + if(input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + MineTweakerAPI.apply(new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock))); }