diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java index 03531d49a..863133d74 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java @@ -5,7 +5,6 @@ import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.IResourceStack; import com.cleanroommc.groovyscript.api.documentation.annotations.Comp; import com.cleanroommc.groovyscript.api.documentation.annotations.Property; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderMethodDescription; @@ -20,6 +19,7 @@ import it.unimi.dsi.fastutil.chars.CharOpenHashSet; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.registry.ForgeRegistries; import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.Nullable; @@ -31,13 +31,20 @@ public abstract class AbstractCraftingRecipeBuilder { - @Property(value = "groovyscript.wiki.craftingrecipe.output.value", comp = @Comp(not = "null"), priority = 700, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.output.value", + comp = @Comp(not = "null"), + priority = 700, + hierarchy = 20) protected ItemStack output; @Property(value = "groovyscript.wiki.name.value", priority = 100, hierarchy = 20) protected ResourceLocation name; - @Property(value = "groovyscript.wiki.craftingrecipe.recipeFunction.value", priority = 1500, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.recipeFunction.value", + priority = 1500, + hierarchy = 20) protected Closure recipeFunction; - @Property(value = "groovyscript.wiki.craftingrecipe.recipeAction.value", priority = 1550, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.recipeAction.value", + priority = 1550, + hierarchy = 20) protected Closure recipeAction; @Property(value = "groovyscript.wiki.craftingrecipe.replace.value", needsOverride = true, hierarchy = 20) protected byte replace; @@ -113,9 +120,7 @@ protected void handleReplace() { } else if (replace == 2) { if (name == null) { GroovyLog.msg("Error replacing Minecraft Crafting recipe") - .add("Name must not be null when replacing by name") - .error() - .post(); + .add("Name must not be null when replacing by name").error().post(); return; } ReloadableRegistryManager.removeRegistryEntry(ForgeRegistries.RECIPES, name); @@ -136,7 +141,8 @@ public void validateName() { @GroovyBlacklist @Nullable - protected T validateShape(GroovyLog.Msg msg, List errors, String[] keyBasedMatrix, Char2ObjectOpenHashMap keyMap, IRecipeCreator recipeCreator) { + protected T validateShape(GroovyLog.Msg msg, List errors, String[] keyBasedMatrix, + Char2ObjectOpenHashMap keyMap, IRecipeCreator recipeCreator) { List ingredients = new ArrayList<>(); if (keyBasedMatrix.length > height) { msg.add("Defined matrix has %d rows, but should only have %d rows", keyBasedMatrix.length, height); @@ -187,7 +193,9 @@ protected T validateShape(GroovyLog.Msg msg, List errors, String[] k protected void checkStackSizes(GroovyLog.Msg msg, Collection ingredients) { if (GroovyScriptConfig.compat.checkInputStackCounts) { for (IIngredient ingredient : ingredients) { - msg.add(IngredientHelper.overMaxSize(ingredient, 1), "Expected stack size 1 for {}, got {}", ingredient.toString(), ingredient.getAmount()); + if (!(ingredient instanceof FluidStack)) { + msg.add(IngredientHelper.overMaxSize(ingredient, 1), "Expected stack size 1 for {}, got {}", ingredient.toString(), ingredient.getAmount()); + } } } } @@ -226,14 +234,22 @@ public interface IRecipeCreator { public abstract static class AbstractShaped extends AbstractCraftingRecipeBuilder { - @Property(value = "groovyscript.wiki.craftingrecipe.keyMap.value", defaultValue = "' ' = IIngredient.EMPTY", priority = 210, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.keyMap.value", + defaultValue = "' ' = IIngredient.EMPTY", + priority = 210, + hierarchy = 20) protected final Char2ObjectOpenHashMap keyMap = new Char2ObjectOpenHashMap<>(); protected final List errors = new ArrayList<>(); - @Property(value = "groovyscript.wiki.craftingrecipe.mirrored.value", hierarchy = 20) - protected boolean mirrored; - @Property(value = "groovyscript.wiki.craftingrecipe.keyBasedMatrix.value", comp = @Comp(unique = "groovyscript.wiki.craftingrecipe.matrix.required"), priority = 200, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.mirrored.value", hierarchy = 20) protected boolean mirrored; + @Property(value = "groovyscript.wiki.craftingrecipe.keyBasedMatrix.value", + comp = @Comp(unique = "groovyscript.wiki.craftingrecipe.matrix.required"), + priority = 200, + hierarchy = 20) protected String[] keyBasedMatrix; - @Property(value = "groovyscript.wiki.craftingrecipe.ingredientMatrix.value", comp = @Comp(gte = 1, lte = 9, unique = "groovyscript.wiki.craftingrecipe.matrix.required"), priority = 200, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.ingredientMatrix.value", + comp = @Comp(gte = 1, lte = 9, unique = "groovyscript.wiki.craftingrecipe.matrix.required"), + priority = 200, + hierarchy = 20) protected List> ingredientMatrix; public AbstractShaped(int width, int height) { @@ -315,7 +331,9 @@ public AbstractShaped shape(List> matrix) { public abstract static class AbstractShapeless extends AbstractCraftingRecipeBuilder { @Property(value = "groovyscript.wiki.craftingrecipe.ingredients.value", - comp = @Comp(gte = 1, lte = 9), priority = 250, hierarchy = 20) + comp = @Comp(gte = 1, lte = 9), + priority = 250, + hierarchy = 20) protected final List ingredients = new ArrayList<>(); public AbstractShapeless(int width, int height) { @@ -330,17 +348,21 @@ public AbstractShapeless input(IIngredient ingredient) { @RecipeBuilderMethodDescription(field = "ingredients") public AbstractShapeless input(IIngredient... ingredients) { - if (ingredients != null) - for (IIngredient ingredient : ingredients) + if (ingredients != null) { + for (IIngredient ingredient : ingredients) { input(ingredient); + } + } return this; } @RecipeBuilderMethodDescription(field = "ingredients") public AbstractShapeless input(Collection ingredients) { - if (ingredients != null && !ingredients.isEmpty()) - for (IIngredient ingredient : ingredients) + if (ingredients != null && !ingredients.isEmpty()) { + for (IIngredient ingredient : ingredients) { input(ingredient); + } + } return this; } }