diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/GTRecipeTypes.java index f2f814c8e0..96d350ee6f 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/GTRecipeTypes.java @@ -152,6 +152,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 f5584cb941..c0da904ba2 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 @@ -17,11 +17,10 @@ import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.ingredient.IntCircuitIngredient; import com.gregtechceu.gtceu.api.recipe.ingredient.IntProviderIngredient; -import com.gregtechceu.gtceu.api.recipe.ingredient.SizedIngredient; -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.recipe.condition.*; +import com.gregtechceu.gtceu.api.tag.TagPrefix; +import com.gregtechceu.gtceu.api.tag.TagUtil; +import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; +import com.gregtechceu.gtceu.common.recipe.*; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.GTRecipeTypes; import com.gregtechceu.gtceu.utils.ResearchManager; @@ -166,12 +165,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()); @@ -179,12 +188,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()); @@ -192,12 +211,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()); @@ -205,12 +234,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()); @@ -227,6 +266,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) { @@ -249,6 +291,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) { @@ -292,7 +337,7 @@ public GTRecipeBuilder inputItems(Object input) { return inputItems(machine); } else { GTCEu.LOGGER.error( - "gt recipe {} input item is not one of: Item, Supplier, ItemStack, SizedIngredient, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -317,7 +362,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, SizedIngredient, Ingredient, UnificationEntry, TagKey, MachineDefinition", + "Input item is not one of: Item, Supplier, ItemStack, Ingredient, UnificationEntry, TagKey, MachineDefinition, id: {}", id); return this; } @@ -342,7 +387,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); } if (input.getComponentsPatch().isEmpty()) { return input(ItemRecipeCapability.CAP, SizedIngredient.of(input.getItem(), input.getCount())); @@ -355,7 +400,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, Arrays.stream(inputs).map(stack -> { @@ -368,6 +413,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.of(tag, amount)); } @@ -396,17 +444,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); } @@ -432,7 +492,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; } @@ -451,7 +511,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; } @@ -463,7 +523,7 @@ public GTRecipeBuilder outputItems(SizedIngredient... 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, new SizedIngredient(DataComponentIngredient.of(true, output), output.getCount())); @@ -472,7 +532,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, @@ -502,14 +562,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); } @@ -535,7 +606,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) { @@ -604,6 +680,9 @@ public GTRecipeBuilder notConsumableFluid(SizedFluidIngredient 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(new SizedIngredient(IntCircuitIngredient.circuitInput(configuration).toVanilla(), 1)); } 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 970e09f14a..f6c0f0c938 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 @@ -812,12 +812,6 @@ private static void redstoneRecipes(RecipeOutput 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 dd1b2e6cc4..e75a7e6f59 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 @@ -141,7 +141,6 @@ public static void init(RecipeOutput 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 258a7a6847..bb9c977be5 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 @@ -140,7 +140,7 @@ public static void init(RecipeOutput 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 0912adbe19..afc12fdce2 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 @@ -16,6 +16,7 @@ import com.gregtechceu.gtceu.api.recipe.ingredient.*; import com.gregtechceu.gtceu.api.tag.TagPrefix; import com.gregtechceu.gtceu.common.recipe.*; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; import com.gregtechceu.gtceu.integration.kjs.recipe.components.CapabilityMap; @@ -100,6 +101,13 @@ public GTKubeRecipe 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)); } } @@ -118,6 +126,13 @@ public GTKubeRecipe 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)); } } @@ -132,7 +147,7 @@ public GTKubeRecipe addCondition(RecipeCondition condition) { return this; } - public GTRecipeJS category(GTRecipeCategory category) { + public GTKubeRecipe category(GTRecipeCategory category) { setValue(CATEGORY, category.registryKey); save(); return this; @@ -143,6 +158,9 @@ public GTKubeRecipe inputEU(long eu) { } public GTKubeRecipe EUt(long eu) { + if (eu == 0) { + throw new IllegalArgumentException(String.format("EUt can't be explicitly set to 0, id: %s", id)); + } var lastPerTick = perTick; perTick = true; if (eu > 0) { @@ -163,6 +181,9 @@ public GTKubeRecipe inputCWU(int cwu) { } public GTKubeRecipe CWUt(int cwu) { + if (cwu == 0) { + throw new IllegalArgumentException(String.format("CWUt can't be explicitly set to 0, id: %s", id)); + } var lastPerTick = perTick; perTick = true; if (cwu > 0) { @@ -239,9 +260,9 @@ public GTKubeRecipe circuit(int configuration) { public GTKubeRecipe chancedInput(SizedIngredient 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 IllegalArgumentException( + 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; @@ -256,9 +277,9 @@ public GTKubeRecipe chancedInput(SizedIngredient stack, int chance, int tierChan @HideFromJS public GTKubeRecipe chancedOutput(SizedIngredient 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; @@ -273,9 +294,9 @@ public GTKubeRecipe chancedOutput(SizedIngredient stack, int chance, int tierCha public GTKubeRecipe chancedFluidInput(SizedFluidIngredient 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; @@ -304,10 +325,9 @@ public GTKubeRecipe chancedOutput(SizedIngredient 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; @@ -317,10 +337,9 @@ public GTKubeRecipe chancedOutput(SizedIngredient 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 chancedOutput(stack, chance, tierChanceBoost); } @@ -328,21 +347,20 @@ public GTKubeRecipe chancedOutput(SizedIngredient 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, 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); @@ -375,9 +393,9 @@ public GTKubeRecipe chancedOutput(TagPrefix prefix, Material material, String fr public GTKubeRecipe chancedFluidOutput(SizedFluidIngredient 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; @@ -400,10 +418,9 @@ public GTKubeRecipe chancedFluidOutput(SizedFluidIngredient stack, String fracti 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; @@ -413,10 +430,9 @@ public GTKubeRecipe chancedFluidOutput(SizedFluidIngredient stack, String fracti 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); } @@ -425,21 +441,20 @@ public GTKubeRecipe chancedFluidOutput(SizedFluidIngredient stack, String fracti 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); @@ -679,14 +694,13 @@ public GTKubeRecipe 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, List.of());