From 3d6074670e3723c19736909e924b4719c6ffbf6f Mon Sep 17 00:00:00 2001 From: YoungOnion <39562198+YoungOnionMC@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:41:28 -0700 Subject: [PATCH] Various Recipe Builder Logging (#2497) --- .../gtceu/common/data/GTRecipeTypes.java | 1 + .../data/recipe/builder/GTRecipeBuilder.java | 105 ++++++++++++-- .../recipe/misc/VanillaStandardRecipes.java | 6 - .../chemistry/ChemistryRecipes.java | 1 - .../serialized/chemistry/ReactorRecipes.java | 2 +- .../kjs/recipe/GTRecipeSchema.java | 130 ++++++++++-------- 6 files changed, 170 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index d22b9b37a9..843bbb39ed 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -147,6 +147,7 @@ public class GTRecipeTypes { public final static GTRecipeType MACERATOR_RECIPES = register("macerator", ELECTRIC).setMaxIOSize(1, 4, 0, 0) .setEUIO(IO.IN) + .prepareBuilder(recipeBuilder -> recipeBuilder.duration(150).EUt(2)) .setSlotOverlay(false, false, GuiTextures.CRUSHED_ORE_OVERLAY) .setSlotOverlay(true, false, GuiTextures.DUST_OVERLAY) .setProgressBar(GuiTextures.PROGRESS_BAR_MACERATE, LEFT_TO_RIGHT) diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java index 867fd8528b..ce83274cdd 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java @@ -22,6 +22,7 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeCategories; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour; import com.gregtechceu.gtceu.common.recipe.condition.*; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.utils.ResearchManager; @@ -171,12 +172,22 @@ public GTRecipeBuilder copyFrom(GTRecipeBuilder builder) { } public GTRecipeBuilder input(RecipeCapability capability, T obj) { - (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()) + var t = (perTick ? tickInput : input); + if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxInputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability)); + } + t.computeIfAbsent(capability, c -> new ArrayList<>()) .add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName)); return this; } public GTRecipeBuilder input(RecipeCapability capability, T... obj) { + var t = (perTick ? tickInput : input); + if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxInputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability)); + } (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) .map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList()); @@ -184,12 +195,22 @@ public GTRecipeBuilder input(RecipeCapability capability, T... obj) { } public GTRecipeBuilder output(RecipeCapability capability, T obj) { + var t = (perTick ? tickOutput : output); + if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxOutputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability)); + } (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()) .add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName)); return this; } public GTRecipeBuilder output(RecipeCapability capability, T... obj) { + var t = (perTick ? tickOutput : output); + if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxOutputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability)); + } (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) .map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList()); @@ -197,12 +218,22 @@ public GTRecipeBuilder output(RecipeCapability capability, T... obj) { } public GTRecipeBuilder inputs(RecipeCapability capability, Object obj) { + var t = (perTick ? tickInput : input); + if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxInputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability)); + } (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()) .add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName)); return this; } public GTRecipeBuilder inputs(RecipeCapability capability, Object... obj) { + var t = (perTick ? tickInput : input); + if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxInputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more inputs than RecipeType can support, id: {}, Max {}{}Inputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability)); + } (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) .map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList()); @@ -210,12 +241,22 @@ public GTRecipeBuilder inputs(RecipeCapability capability, Object... obj) } public GTRecipeBuilder outputs(RecipeCapability capability, Object obj) { + var t = (perTick ? tickOutput : output); + if (t.get(capability) != null && t.get(capability).size() >= recipeType.getMaxOutputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability)); + } (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()) .add(new Content(capability.of(obj), chance, maxChance, tierChanceBoost, slotName, uiName)); return this; } public GTRecipeBuilder outputs(RecipeCapability capability, Object... obj) { + var t = (perTick ? tickOutput : output); + if (t.get(capability) != null && t.get(capability).size() + obj.length > recipeType.getMaxOutputs(capability)) { + GTCEu.LOGGER.warn("Trying to add more outputs than RecipeType can support, id: {}, Max {}{}Outputs: {}", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability)); + } (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) .map(o -> new Content(o, chance, maxChance, tierChanceBoost, slotName, uiName)).toList()); @@ -232,6 +273,9 @@ public GTRecipeBuilder inputEU(long eu) { } public GTRecipeBuilder EUt(long eu) { + if (eu == 0) { + GTCEu.LOGGER.error("EUt can't be explicitly set to 0, id: {}", id); + } var lastPerTick = perTick; perTick = true; if (eu > 0) { @@ -254,6 +298,9 @@ public GTRecipeBuilder inputCWU(int cwu) { } public GTRecipeBuilder CWUt(int cwu) { + if (cwu == 0) { + GTCEu.LOGGER.error("CWUt can't be explicitly set to 0, id: {}", id); + } var lastPerTick = perTick; perTick = true; if (cwu > 0) { @@ -295,7 +342,7 @@ public GTRecipeBuilder inputItems(Object input) { return inputItems(machine); } else { GTCEu.LOGGER.error( - "gt recipe {} input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -318,7 +365,7 @@ public GTRecipeBuilder inputItems(Object input, int count) { return inputItems(machine, count); } else { GTCEu.LOGGER.error( - "gt recipe {} input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -334,7 +381,7 @@ public GTRecipeBuilder inputItems(Ingredient... inputs) { public GTRecipeBuilder inputItems(ItemStack input) { if (input.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} input items is empty", id); + GTCEu.LOGGER.error("Input items is empty, id: {}", id); } return input(ItemRecipeCapability.CAP, SizedIngredient.create(input)); } @@ -342,7 +389,7 @@ public GTRecipeBuilder inputItems(ItemStack input) { public GTRecipeBuilder inputItems(ItemStack... inputs) { for (ItemStack itemStack : inputs) { if (itemStack.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} input items is empty", id); + GTCEu.LOGGER.error("Input item is empty, id: {}", id); } } return input(ItemRecipeCapability.CAP, @@ -350,6 +397,9 @@ public GTRecipeBuilder inputItems(ItemStack... inputs) { } public GTRecipeBuilder inputItems(TagKey tag, int amount) { + if (amount == 0) { + GTCEu.LOGGER.error("Item Count is 0, id: {}", id); + } return inputItems(SizedIngredient.create(tag, amount)); } @@ -378,17 +428,29 @@ public GTRecipeBuilder inputItems(TagPrefix orePrefix, Material material) { } public GTRecipeBuilder inputItems(UnificationEntry input) { + if (input.material == null) { + GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, input.tagPrefix); + } return inputItems(input.tagPrefix, input.material, 1); } public GTRecipeBuilder inputItems(UnificationEntry input, int count) { + if (input.material == null) { + GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, input.tagPrefix); + } return inputItems(input.tagPrefix, input.material, count); } public GTRecipeBuilder inputItems(TagPrefix orePrefix, Material material, int count) { TagKey tag = ChemicalHelper.getTag(orePrefix, material); if (tag == null) { - return inputItems(ChemicalHelper.get(orePrefix, material, count)); + var item = ChemicalHelper.get(orePrefix, material, count); + if (item.isEmpty()) { + GTCEu.LOGGER.error( + "Tried to set input item stack that doesn't exist, id: {}, TagPrefix: {}, Material: {}, Count: {}", + id, orePrefix, material, count); + } + return inputItems(item); } return inputItems(tag, count); } @@ -414,7 +476,7 @@ public GTRecipeBuilder outputItems(Object input) { return outputItems(machine); } else { GTCEu.LOGGER.error( - "gt recipe {} output item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Output item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -433,7 +495,7 @@ public GTRecipeBuilder outputItems(Object input, int count) { return outputItems(machine, count); } else { GTCEu.LOGGER.error( - "gt recipe {} output item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Output item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -445,7 +507,7 @@ public GTRecipeBuilder outputItems(Ingredient... inputs) { public GTRecipeBuilder outputItems(ItemStack output) { if (output.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} output items is empty", id); + GTCEu.LOGGER.error("Output items is empty, id: {}", id); } return output(ItemRecipeCapability.CAP, SizedIngredient.create(output)); } @@ -453,7 +515,7 @@ public GTRecipeBuilder outputItems(ItemStack output) { public GTRecipeBuilder outputItems(ItemStack... outputs) { for (ItemStack itemStack : outputs) { if (itemStack.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} output items is empty", id); + GTCEu.LOGGER.error("Output items is empty, id: {}", id); } } return output(ItemRecipeCapability.CAP, @@ -481,14 +543,25 @@ public GTRecipeBuilder outputItems(TagPrefix orePrefix, Material material) { } public GTRecipeBuilder outputItems(TagPrefix orePrefix, Material material, int count) { - return outputItems(ChemicalHelper.get(orePrefix, material, count)); + var item = ChemicalHelper.get(orePrefix, material, count); + if (item.isEmpty()) { + GTCEu.LOGGER.error("Tried to set output item stack that doesn't exist, TagPrefix: {}, Material: {}", + orePrefix, material); + } + return outputItems(item); } public GTRecipeBuilder outputItems(UnificationEntry entry) { + if (entry.material == null) { + GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, entry.tagPrefix); + } return outputItems(entry.tagPrefix, entry.material); } public GTRecipeBuilder outputItems(UnificationEntry entry, int count) { + if (entry.material == null) { + GTCEu.LOGGER.error("Unification Entry material is null, id: {}, TagPrefix: {}", id, entry.tagPrefix); + } return outputItems(entry.tagPrefix, entry.material, count); } @@ -513,7 +586,12 @@ public GTRecipeBuilder outputItemsRanged(Supplier output, In } public GTRecipeBuilder outputItemsRanged(TagPrefix orePrefix, Material material, IntProvider intProvider) { - return outputItemsRanged(ChemicalHelper.get(orePrefix, material, 1), intProvider); + var item = ChemicalHelper.get(orePrefix, material, 1); + if (item.isEmpty()) { + GTCEu.LOGGER.error("Tried to set output ranged item stack that doesn't exist, TagPrefix: {}, Material: {}", + orePrefix, material); + } + return outputItemsRanged(item, intProvider); } public GTRecipeBuilder outputItemsRanged(MachineDefinition machine, IntProvider intProvider) { @@ -582,6 +660,9 @@ public GTRecipeBuilder notConsumableFluid(FluidIngredient ingredient) { } public GTRecipeBuilder circuitMeta(int configuration) { + if (configuration < 0 || configuration > IntCircuitBehaviour.CIRCUIT_MAX) { + GTCEu.LOGGER.error("Circuit configuration must be in the bounds 0 - 32"); + } return notConsumable(IntCircuitIngredient.circuitInput(configuration)); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/VanillaStandardRecipes.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/VanillaStandardRecipes.java index 6847d309ea..3a802f0fb2 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/VanillaStandardRecipes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/VanillaStandardRecipes.java @@ -794,12 +794,6 @@ private static void redstoneRecipes(Consumer provider) { .inputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_SLAB)) .outputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, 8)) .duration(250).EUt(VA[ULV]).save(provider); - - CUTTER_RECIPES.recipeBuilder("polished_blackstone_pressure_plate") - .inputItems(plate, Iron) - .outputItems(new ItemStack(Blocks.POLISHED_BLACKSTONE_PRESSURE_PLATE, 8)) - .circuitMeta(10) - .duration(250).EUt(VA[ULV]).save(provider); } } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ChemistryRecipes.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ChemistryRecipes.java index 701b29ead6..5834d5b650 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ChemistryRecipes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ChemistryRecipes.java @@ -143,7 +143,6 @@ public static void init(Consumer provider) { .inputItems(dust, Charcoal) .inputFluids(Nitrogen.getFluid(2000)) .outputItems(dust, ActivatedCarbon) - .chancedOutput(dust, Ash, 2000, 0) .duration(640).EUt(64) .save(provider); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ReactorRecipes.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ReactorRecipes.java index 4a3df055c8..a417008297 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ReactorRecipes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/serialized/chemistry/ReactorRecipes.java @@ -142,7 +142,7 @@ public static void init(Consumer provider) { .duration(400).EUt(VA[LV]) .save(provider); - CHEMICAL_RECIPES.recipeBuilder("iron_2_chloride") + LARGE_CHEMICAL_RECIPES.recipeBuilder("iron_2_chloride") .inputFluids(Iron3Chloride.getFluid(2000)) .inputFluids(Chlorobenzene.getFluid(1000)) .outputFluids(Iron2Chloride.getFluid(2000)) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java index cca92957b9..f92c72f707 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java @@ -17,6 +17,8 @@ import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.ingredient.*; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour; import com.gregtechceu.gtceu.common.recipe.condition.*; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; @@ -41,11 +43,13 @@ import dev.latvian.mods.kubejs.fluid.InputFluid; import dev.latvian.mods.kubejs.item.InputItem; import dev.latvian.mods.kubejs.item.OutputItem; +import dev.latvian.mods.kubejs.recipe.RecipeExceptionJS; import dev.latvian.mods.kubejs.recipe.RecipeJS; import dev.latvian.mods.kubejs.recipe.RecipeKey; import dev.latvian.mods.kubejs.recipe.component.BooleanComponent; import dev.latvian.mods.kubejs.recipe.component.TimeComponent; import dev.latvian.mods.kubejs.recipe.schema.RecipeSchema; +import dev.latvian.mods.kubejs.util.ConsoleJS; import dev.latvian.mods.rhino.util.HideFromJS; import lombok.Getter; import lombok.Setter; @@ -105,6 +109,13 @@ public GTRecipeJS input(RecipeCapability capability, Object... obj) { } if (map != null) { for (Object object : obj) { + var recipeType = GTRegistries.RECIPE_TYPES.get(this.type.id); + if (map.get(capability) != null && + map.get(capability).length >= recipeType.getMaxInputs(capability)) { + ConsoleJS.SERVER.warn(String.format( + "Trying to add more inputs than RecipeType can support, id: %s, Max %s%sInputs: %s", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxInputs(capability))); + } map.add(capability, new Content(object, chance, maxChance, tierChanceBoost, null, null)); } } @@ -123,6 +134,13 @@ public GTRecipeJS output(RecipeCapability capability, Object... obj) { } if (map != null) { for (Object object : obj) { + var recipeType = GTRegistries.RECIPE_TYPES.get(this.type.id); + if (map.get(capability) != null && + map.get(capability).length >= recipeType.getMaxOutputs(capability)) { + ConsoleJS.SERVER.warn(String.format( + "Trying to add more outputs than RecipeType can support, id: %s, Max %s%sOutputs: %s", + id, (perTick ? "Tick " : ""), capability.name, recipeType.getMaxOutputs(capability))); + } map.add(capability, new Content(object, chance, maxChance, tierChanceBoost, null, null)); } } @@ -147,6 +165,9 @@ public GTRecipeJS inputEU(long eu) { } public GTRecipeJS EUt(long eu) { + if (eu == 0) { + throw new RecipeExceptionJS(String.format("EUt can't be explicitly set to 0, id: %s", id)); + } var lastPerTick = perTick; perTick = true; if (eu > 0) { @@ -167,6 +188,9 @@ public GTRecipeJS inputCWU(int cwu) { } public GTRecipeJS CWUt(int cwu) { + if (cwu == 0) { + throw new RecipeExceptionJS(String.format("CWUt can't be explicitly set to 0, id: %s", id)); + } var lastPerTick = perTick; perTick = true; if (cwu > 0) { @@ -208,7 +232,7 @@ public GTRecipeJS inputItems(InputItem... inputs) { public GTRecipeJS inputItems(ItemStack... inputs) { for (ItemStack itemStack : inputs) { if (itemStack.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} input items is empty", id); + GTCEu.LOGGER.error("Input items is empty, id: %s", id); } } return input(ItemRecipeCapability.CAP, @@ -278,7 +302,7 @@ public GTRecipeJS itemOutput(UnificationEntry unificationEntry, int count) { public GTRecipeJS outputItems(ExtendedOutputItem... outputs) { for (ExtendedOutputItem itemStack : outputs) { if (itemStack.isEmpty()) { - GTCEu.LOGGER.error("gt recipe {} output items is empty", id); + throw new RecipeExceptionJS(String.format("Output items is empty, id: %s", id)); } } return output(ItemRecipeCapability.CAP, (Object[]) outputs); @@ -349,14 +373,17 @@ public GTRecipeJS notConsumableFluid(GTRecipeComponents.FluidIngredientJS fluid) } public GTRecipeJS circuit(int configuration) { + if (configuration < 0 || configuration > IntCircuitBehaviour.CIRCUIT_MAX) { + throw new RecipeExceptionJS(String.format("Circuit configuration must be in the bounds 0 - 32")); + } return notConsumable(InputItem.of(IntCircuitIngredient.circuitInput(configuration), 1)); } public GTRecipeJS chancedInput(InputItem stack, int chance, int tierChanceBoost) { if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } int lastChance = this.chance; int lastTierChanceBoost = this.tierChanceBoost; @@ -371,9 +398,9 @@ public GTRecipeJS chancedInput(InputItem stack, int chance, int tierChanceBoost) public GTRecipeJS chancedFluidInput(GTRecipeComponents.FluidIngredientJS stack, int chance, int tierChanceBoost) { if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } int lastChance = this.chance; int lastTierChanceBoost = this.tierChanceBoost; @@ -387,9 +414,9 @@ public GTRecipeJS chancedFluidInput(GTRecipeComponents.FluidIngredientJS stack, public GTRecipeJS chancedOutput(ExtendedOutputItem stack, int chance, int tierChanceBoost) { if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } int lastChance = this.chance; int lastTierChanceBoost = this.tierChanceBoost; @@ -416,10 +443,9 @@ public GTRecipeJS chancedOutput(ExtendedOutputItem stack, String fraction, int t String[] split = fraction.split("/"); if (split.length > 2) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, new Throwable())); } int chance; @@ -429,10 +455,9 @@ public GTRecipeJS chancedOutput(ExtendedOutputItem stack, String fraction, int t try { chance = (int) Double.parseDouble(split[0]); } catch (NumberFormatException e) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, new Throwable())); } return chancedOutput(stack, chance, tierChanceBoost); } @@ -440,21 +465,20 @@ public GTRecipeJS chancedOutput(ExtendedOutputItem stack, String fraction, int t chance = Integer.parseInt(split[0]); maxChance = Integer.parseInt(split[1]); } catch (NumberFormatException e) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, new Throwable())); } if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } if (chance >= maxChance || maxChance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Max Chance cannot be less or equal to Chance or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), maxChance, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Max Chance cannot be less or equal to Chance or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), maxChance, id, new Throwable())); } int scalar = Math.floorDiv(ChanceLogic.getMaxChancedValue(), maxChance); @@ -487,9 +511,9 @@ public GTRecipeJS chancedOutput(TagPrefix prefix, Material material, String frac public GTRecipeJS chancedFluidOutput(FluidStackJS stack, int chance, int tierChanceBoost) { if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } int lastChance = this.chance; int lastTierChanceBoost = this.tierChanceBoost; @@ -508,10 +532,9 @@ public GTRecipeJS chancedFluidOutput(FluidStackJS stack, String fraction, int ti String[] split = fraction.split("/"); if (split.length > 2) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, new Throwable())); } int chance; @@ -521,10 +544,9 @@ public GTRecipeJS chancedFluidOutput(FluidStackJS stack, String fraction, int ti try { chance = (int) Double.parseDouble(split[0]); } catch (NumberFormatException e) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, new Throwable())); } return chancedFluidOutput(stack, chance, tierChanceBoost); } @@ -533,21 +555,20 @@ public GTRecipeJS chancedFluidOutput(FluidStackJS stack, String fraction, int ti chance = Integer.parseInt(split[0]); maxChance = Integer.parseInt(split[1]); } catch (NumberFormatException e) { - GTCEu.LOGGER.error( - "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"{}\".", - fraction, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Fraction or number was not parsed correctly! Expected format is \"1/3\" or \"1000\". Actual: \"%s\".", + fraction, e)); } if (0 >= chance || chance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Chance cannot be less or equal to 0 or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), chance, new Throwable()); - return this; + throw new RecipeExceptionJS( + String.format("Chance cannot be less or equal to 0 or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), chance, id, new Throwable())); } if (chance >= maxChance || maxChance > ChanceLogic.getMaxChancedValue()) { - GTCEu.LOGGER.error("Max Chance cannot be less or equal to Chance or more than {}. Actual: {}.", - ChanceLogic.getMaxChancedValue(), maxChance, new Throwable()); - return this; + throw new RecipeExceptionJS(String.format( + "Max Chance cannot be less or equal to Chance or more than %s, Actual: %s, id: %s", + ChanceLogic.getMaxChancedValue(), maxChance, id, new Throwable())); } int scalar = Math.floorDiv(ChanceLogic.getMaxChancedValue(), maxChance); @@ -786,14 +807,13 @@ public GTRecipeJS environmentalHazard(MedicalCondition condition) { private boolean applyResearchProperty(ResearchData.ResearchEntry researchEntry) { if (!ConfigHolder.INSTANCE.machines.enableResearch) return false; if (researchEntry == null) { - GTCEu.LOGGER.error("Assembly Line Research Entry cannot be empty.", new IllegalArgumentException()); - return false; + throw new RecipeExceptionJS( + String.format("Assembly Line Research Entry cannot be empty.", new IllegalArgumentException())); } if (!generatingRecipes) { - GTCEu.LOGGER.error("Cannot generate recipes when using researchWithoutRecipe()", - new IllegalArgumentException()); - return false; + throw new RecipeExceptionJS(String.format("Cannot generate recipes when using researchWithoutRecipe()", + new IllegalArgumentException())); } if (getValue(CONDITIONS) == null) setValue(CONDITIONS, new RecipeCondition[0]);