mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
Duplicate & input check for PneumaticCraft
This commit is contained in:
1 parent
6bf0797054
commit
3990a81390
3 files changed
+34
-6
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AssemblyRecipe> 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<AssemblyRecipe> {
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user