From 6ed8d31af0f23f3b119eb832363ad6f67a72ffa6 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 3 Sep 2022 13:33:53 -0700 Subject: [PATCH] Allow configuring max amount of firework ingredients - Replace boolean allowBiggerFireworksInCrafter config with int maxFireworkIngredientsInCrafter config --- .../components/crafter/RecipeGridHandler.java | 15 +++++++++------ .../create/foundation/config/CRecipes.java | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java index 8f6be9a34..8f6d69715 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.IntStream; import org.apache.commons.lang3.tuple.Pair; @@ -159,12 +158,16 @@ public class RecipeGridHandler { } public static boolean isRecipeAllowed(CraftingRecipe recipe, CraftingContainer inventory) { - if (!AllConfigs.SERVER.recipes.allowBiggerFireworksInCrafter.get() && recipe instanceof FireworkRocketRecipe) { - int numItems = IntStream.range(0, inventory.getContainerSize()) - .map(i -> inventory.getItem(i).isEmpty() ? 0 : 1) - .sum(); - if (numItems > 9) + if (recipe instanceof FireworkRocketRecipe) { + int numItems = 0; + for (int i = 0; i < inventory.getContainerSize(); i++) { + if (!inventory.getItem(i).isEmpty()) { + numItems++; + } + } + if (numItems > AllConfigs.SERVER.recipes.maxFireworkIngredientsInCrafter.get()) { return false; + } } if (AllRecipeTypes.shouldIgnoreInAutomation(recipe)) return false; diff --git a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java index ec35f974f..18b0a54fe 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java +++ b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java @@ -8,8 +8,8 @@ public class CRecipes extends ConfigBase { public final ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress); public final ConfigBool allowRegularCraftingInCrafter = b(true, "allowRegularCraftingInCrafter", Comments.allowRegularCraftingInCrafter); - public final ConfigBool allowBiggerFireworksInCrafter = - b(false, "allowBiggerFireworksInCrafter", Comments.allowBiggerFireworksInCrafter); + public final ConfigInt maxFireworkIngredientsInCrafter = + i(9, 1, "maxFireworkIngredientsInCrafter", Comments.maxFireworkIngredientsInCrafter); public final ConfigBool allowStonecuttingOnSaw = b(true, "allowStonecuttingOnSaw", Comments.allowStonecuttingOnSaw); public final ConfigBool allowWoodcuttingOnSaw = b(true, "allowWoodcuttingOnSaw", Comments.allowWoodcuttingOnSaw); public final ConfigBool allowCastingBySpout = b(true, "allowCastingBySpout", Comments.allowCastingBySpout); @@ -34,8 +34,8 @@ public class CRecipes extends ConfigBase { "Allow any single-ingredient 2x2 or 3x3 crafting recipes to be processed by a Mechanical Press + Basin."; static String allowRegularCraftingInCrafter = "Allow any standard crafting recipes to be processed by Mechanical Crafters."; - static String allowBiggerFireworksInCrafter = - "Allow Firework Rockets with more than 9 ingredients to be crafted using Mechanical Crafters."; + static String maxFireworkIngredientsInCrafter = + "The Maximum amount of ingredients that can be used to craft Firework Rockets using Mechanical Crafters."; static String allowStonecuttingOnSaw = "Allow any stonecutting recipes to be processed by a Mechanical Saw."; static String allowWoodcuttingOnSaw =