From 64d3bfa5577aaf9da8f4001153e63052a268b8c7 Mon Sep 17 00:00:00 2001 From: Shadl7 <36076907+shadl7@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:27:40 +0700 Subject: [PATCH] Add PyroTech Oven and Kiln compat (#219) * Add PyroTech Stone and RefractoryKiln * Fix name of kiln errors * Add Pyrotech Oven compat * Fix crash cause by an empty ore('ingotIron') * fix kiln and oven descriptions and examples fix recipes duplicates * Rename errors at Pyrotech Brick Oven * Rename pit kiln * Change warning in Stone and Brick Ovens * Revert ore('dye') to ore('ingotIron') Comment remove of ore('ingotIron') and clean of ore('plankWood') * Change pyrotech admonition level * Fix oven validate errors msg * Improve oven note * Change description of campfire, stone and refractory oven Update examples * Rename pit kiln lang keys * and rename pit kiln itself * update examples --------- Co-authored-by: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> --- examples/postInit/custom/vanilla.groovy | 4 +- examples/postInit/pyrotech.groovy | 84 ++++++++++- .../compat/mods/pyrotech/Anvil.java | 2 +- .../compat/mods/pyrotech/BrickKiln.java | 138 ++++++++++++++++++ .../compat/mods/pyrotech/BrickOven.java | 108 ++++++++++++++ .../mods/pyrotech/{Kiln.java => PitKiln.java} | 9 +- .../compat/mods/pyrotech/PyroTech.java | 6 +- .../compat/mods/pyrotech/StoneKiln.java | 138 ++++++++++++++++++ .../compat/mods/pyrotech/StoneOven.java | 107 ++++++++++++++ .../assets/groovyscript/lang/en_us.lang | 40 ++++- 10 files changed, 614 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickKiln.java create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickOven.java rename src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/{Kiln.java => PitKiln.java} (94%) create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneKiln.java create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneOven.java diff --git a/examples/postInit/custom/vanilla.groovy b/examples/postInit/custom/vanilla.groovy index 280621fce..faf097b30 100644 --- a/examples/postInit/custom/vanilla.groovy +++ b/examples/postInit/custom/vanilla.groovy @@ -203,8 +203,8 @@ oredict.add('ingotGold', item('minecraft:nether_star')) oredict.add('netherStar', item('minecraft:gold_ingot')) oredict.remove('netherStar', item('minecraft:nether_star')) -oredict.clear('plankWood') // Note that any recipes using this oredict will silently die -oredict.removeAll('ingotIron') +//oredict.clear('plankWood') // Note that any recipes using this oredict will silently die +//oredict.removeAll('ingotIron') //oredict.removeAll() diff --git a/examples/postInit/pyrotech.groovy b/examples/postInit/pyrotech.groovy index c2a304e19..bccda9577 100644 --- a/examples/postInit/pyrotech.groovy +++ b/examples/postInit/pyrotech.groovy @@ -38,7 +38,7 @@ mods.pyrotech.anvil.recipeBuilder() .register() -mods.pyrotech.anvil.add('iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9, 'granite', 'hammer') +mods.pyrotech.anvil.add('iron_to_clay', ore('ingotIron'), item('minecraft:clay_ball'), 9, 'granite', 'hammer') // Barrel: // Over time converts a fluid with four items into a new fluid. @@ -57,8 +57,43 @@ mods.pyrotech.barrel.recipeBuilder() mods.pyrotech.barrel.add('iron_dirt_water_to_lava', ore('ingotIron'), ore('ingotIron'), item('minecraft:dirt'), item('minecraft:dirt'), fluid('water'), fluid('lava'), 1000) +// Refractory Kiln: +// Converts an item into a new one by burning it. Has a chance to fail. + +mods.pyrotech.brick_kiln.removeByOutput(item('pyrotech:bucket_clay')) +// mods.pyrotech.brick_kiln.removeAll() + +mods.pyrotech.brick_kiln.recipeBuilder() + .input(item('minecraft:iron_ingot')) + .output(item('minecraft:gold_ingot')) + .burnTime(400) + .failureChance(1f) + .failureOutput(item('minecraft:wheat'), item('minecraft:carrot'), item('minecraft:sponge')) + .name('iron_to_gold_kiln_with_failure_items_brick') + .register() + + +mods.pyrotech.brick_kiln.add('clay_to_iron_brick', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, item('minecraft:dirt'), item('minecraft:cobblestone')) + +// Refractory Oven: +// When powered by burning fuel can convert items. + +mods.pyrotech.brick_oven.removeByInput(item('minecraft:porkchop')) +mods.pyrotech.brick_oven.removeByOutput(item('minecraft:cooked_porkchop')) +// mods.pyrotech.brick_oven.removeAll() + +mods.pyrotech.brick_oven.recipeBuilder() + .input(item('minecraft:diamond')) + .output(item('minecraft:emerald')) + .duration(400) + .name('diamond_campfire_to_emerald_brick') + .register() + + +mods.pyrotech.brick_oven.add('apple_to_dirt_brick', item('minecraft:apple'), item('minecraft:dirt'), 1000) + // Campfire: -// Can cook food. +// When powered by burning logs can convert items. mods.pyrotech.campfire.removeByInput(item('minecraft:porkchop')) mods.pyrotech.campfire.removeByOutput(item('minecraft:cooked_porkchop')) @@ -157,13 +192,13 @@ mods.pyrotech.drying_rack.recipeBuilder() mods.pyrotech.drying_rack.add('apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200) -// Kiln: +// Pit Kiln: // Converts an item into a new one by burning it. Has a chance to fail. -mods.pyrotech.kiln.removeByOutput(item('pyrotech:bucket_clay')) -// mods.pyrotech.kiln.removeAll() +mods.pyrotech.pit_kiln.removeByOutput(item('pyrotech:bucket_clay')) +// mods.pyrotech.pit_kiln.removeAll() -mods.pyrotech.kiln.recipeBuilder() +mods.pyrotech.pit_kiln.recipeBuilder() .input(item('minecraft:iron_ingot')) .output(item('minecraft:gold_ingot')) .burnTime(400) @@ -173,7 +208,7 @@ mods.pyrotech.kiln.recipeBuilder() .register() -mods.pyrotech.kiln.add('clay_to_iron', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, [item('minecraft:dirt'), item('minecraft:cobblestone')]) +mods.pyrotech.pit_kiln.add('clay_to_iron', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, [item('minecraft:dirt'), item('minecraft:cobblestone')]) // Soaking Pot: // Converts an item into a new one by soaking it in a liquid. Can require a campfire. @@ -193,6 +228,41 @@ mods.pyrotech.soaking_pot.recipeBuilder() mods.pyrotech.soaking_pot.add('dirt_to_apple', item('minecraft:dirt'), fluid('water'), item('minecraft:apple'), 1200) +// Stone Kiln: +// Converts an item into a new one by burning it. Has a chance to fail. + +mods.pyrotech.stone_kiln.removeByOutput(item('pyrotech:bucket_clay')) +// mods.pyrotech.stone_kiln.removeAll() + +mods.pyrotech.stone_kiln.recipeBuilder() + .input(item('minecraft:iron_ingot')) + .output(item('minecraft:gold_ingot')) + .burnTime(400) + .failureChance(1f) + .failureOutput(item('minecraft:wheat'), item('minecraft:carrot'), item('minecraft:sponge')) + .name('iron_to_gold_kiln_with_failure_items_stone') + .register() + + +mods.pyrotech.stone_kiln.add('clay_to_iron_stone', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, item('minecraft:dirt'), item('minecraft:cobblestone')) + +// Stone Oven: +// When powered by burning fuel can convert items. + +mods.pyrotech.stone_oven.removeByInput(item('minecraft:porkchop')) +mods.pyrotech.stone_oven.removeByOutput(item('minecraft:cooked_porkchop')) +// mods.pyrotech.stone_oven.removeAll() + +mods.pyrotech.stone_oven.recipeBuilder() + .input(item('minecraft:diamond')) + .output(item('minecraft:emerald')) + .duration(400) + .name('diamond_campfire_to_emerald_stone') + .register() + + +mods.pyrotech.stone_oven.add('apple_to_dirt_stone', item('minecraft:apple'), item('minecraft:dirt'), 1000) + // Tanning Rack: // Converts an item over time into a new one. diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java index ee7973268..bd3b51d8a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java @@ -30,7 +30,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9, 'granite', 'hammer'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_to_clay', ore('ingotIron'), item('minecraft:clay_ball'), 9, 'granite', 'hammer'")) public AnvilRecipe add(String name, IIngredient input, ItemStack output, int hits, String tier, String type) { AnvilRecipe.EnumTier enumTier = EnumHelper.valueOfNullable(AnvilRecipe.EnumTier.class, tier, false); AnvilRecipe.EnumType enumType = EnumHelper.valueOfNullable(AnvilRecipe.EnumType.class, type, false); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickKiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickKiln.java new file mode 100644 index 000000000..e6ba1adb6 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickKiln.java @@ -0,0 +1,138 @@ +package com.cleanroommc.groovyscript.compat.mods.pyrotech; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.codetaylor.mc.pyrotech.modules.tech.machine.ModuleTechMachine; +import com.codetaylor.mc.pyrotech.modules.tech.machine.recipe.BrickKilnRecipe; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class BrickKiln extends ForgeRegistryWrapper { + + public BrickKiln() { + super(ModuleTechMachine.Registries.BRICK_KILN_RECIPES); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:gold_ingot')).burnTime(400).failureChance(1f).failureOutput(item('minecraft:wheat'), item('minecraft:carrot'), item('minecraft:sponge')).name('iron_to_gold_kiln_with_failure_items_brick')")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'clay_to_iron_brick', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, item('minecraft:dirt'), item('minecraft:cobblestone')")) + public BrickKilnRecipe add(String name, IIngredient input, ItemStack output, int burnTime, float failureChance, ItemStack... failureOutput) { + return recipeBuilder() + .burnTime(burnTime) + .failureChance(failureChance) + .failureOutput(failureOutput) + .name(name) + .input(input) + .output(output) + .register(); + } + + @MethodDescription + public void removeByInput(ItemStack input) { + if (GroovyLog.msg("Error removing refractory oven recipe") + .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (BrickKilnRecipe recipe : getRegistry()) { + if (recipe.getInput().test(input)) { + remove(recipe); + } + } + } + + @MethodDescription(example = @Example("item('pyrotech:bucket_clay')")) + public void removeByOutput(IIngredient output) { + if (GroovyLog.msg("Error removing refractory oven recipe") + .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (BrickKilnRecipe recipe : getRegistry()) { + if (output.test(recipe.getOutput())) { + remove(recipe); + } + } + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property + private final ItemStackList failureOutput = new ItemStackList(); + @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) + private int burnTime; + @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) + private float failureChance; + + @RecipeBuilderMethodDescription + public RecipeBuilder burnTime(int time) { + this.burnTime = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureChance(float chance) { + this.failureChance = chance; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(ItemStack failureOutputs) { + this.failureOutput.add(failureOutputs); + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(ItemStack... failureOutputs) { + for (ItemStack itemStack : failureOutputs) { + failureOutput(itemStack); + } + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(Iterable failureOutputs) { + for (ItemStack itemStack : failureOutputs) failureOutput(itemStack); + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Pyrotech Refractory Kiln Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + this.failureOutput.trim(); + validateCustom(msg, failureOutput, 1, 100, "failure output"); + msg.add(burnTime < 0, "burnTime must be a non negative integer, yet it was {}", burnTime); + msg.add(failureChance < 0, "failureChance must be a non negative float, yet it was {}", failureChance); + msg.add(super.name == null, "name cannot be null."); + msg.add(ModuleTechMachine.Registries.BRICK_KILN_RECIPES.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable BrickKilnRecipe register() { + if (!validate()) return null; + BrickKilnRecipe recipe = new BrickKilnRecipe(output.get(0), input.get(0).toMcIngredient(), burnTime, failureChance, failureOutput.toArray(new ItemStack[0])).setRegistryName(super.name); + PyroTech.brickKiln.add(recipe); + return recipe; + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickOven.java new file mode 100644 index 000000000..19212ad43 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickOven.java @@ -0,0 +1,108 @@ +package com.cleanroommc.groovyscript.compat.mods.pyrotech; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; +import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CampfireRecipe; +import com.codetaylor.mc.pyrotech.modules.tech.machine.ModuleTechMachine; +import com.codetaylor.mc.pyrotech.modules.tech.machine.recipe.BrickOvenRecipe; +import com.codetaylor.mc.pyrotech.modules.tech.machine.recipe.StoneOvenRecipe; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.pyrotech.oven.note0", + type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD, + hasTitle = true)) +public class BrickOven extends ForgeRegistryWrapper { + + public BrickOven() { + super(ModuleTechMachine.Registries.BRICK_OVEN_RECIPES); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:emerald')).duration(400).name('diamond_campfire_to_emerald_brick')")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt_brick', item('minecraft:apple'), item('minecraft:dirt'), 1000")) + public BrickOvenRecipe add(String name, IIngredient input, ItemStack output, int duration) { + return recipeBuilder() + .duration(duration) + .name(name) + .input(input) + .output(output) + .register(); + } + + @MethodDescription(example = @Example("item('minecraft:porkchop')")) + public void removeByInput(ItemStack input) { + if (GroovyLog.msg("Error removing brick oven recipe") + .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (BrickOvenRecipe recipe : getRegistry()) { + if (recipe.getInput().test(input)) { + remove(recipe); + } + } + } + + @MethodDescription(example = @Example("item('minecraft:cooked_porkchop')")) + public void removeByOutput(IIngredient output) { + if (GroovyLog.msg("Error removing brick oven recipe") + .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (BrickOvenRecipe recipe : getRegistry()) { + if (output.test(recipe.getOutput())) { + remove(recipe); + } + } + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) + private int duration; + + @RecipeBuilderMethodDescription + public RecipeBuilder duration(int time) { + this.duration = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Pyrotech Brick Oven Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); + msg.add(super.name == null, "name cannot be null."); + msg.add(ModuleTechMachine.Registries.BRICK_OVEN_RECIPES.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable BrickOvenRecipe register() { + if (!validate()) return null; + BrickOvenRecipe recipe = new BrickOvenRecipe(output.get(0), input.get(0).toMcIngredient(), duration).setRegistryName(super.name); + PyroTech.brickOven.add(recipe); + return recipe; + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PitKiln.java similarity index 94% rename from src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java rename to src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PitKiln.java index 6fe0e7586..f3f5440b7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PitKiln.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; @@ -13,10 +14,10 @@ import org.jetbrains.annotations.Nullable; @RegistryDescription -public class Kiln extends ForgeRegistryWrapper { +public class PitKiln extends ForgeRegistryWrapper { - public Kiln() { - super(ModuleTechBasic.Registries.KILN_PIT_RECIPE); + public PitKiln() { + super(ModuleTechBasic.Registries.KILN_PIT_RECIPE, Alias.generateOfClass(PitKiln.class).andGenerate("Kiln")); } @RecipeBuilderDescription(example = @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:gold_ingot')).burnTime(400).failureChance(1f).failureOutput(item('minecraft:wheat'), item('minecraft:carrot'), item('minecraft:sponge')).name('iron_to_gold_kiln_with_failure_items')")) @@ -131,7 +132,7 @@ public void validate(GroovyLog.Msg msg) { public @Nullable KilnPitRecipe register() { if (!validate()) return null; KilnPitRecipe recipe = new KilnPitRecipe(output.get(0), input.get(0).toMcIngredient(), burnTime, failureChance, failureOutput.toArray(new ItemStack[0])).setRegistryName(super.name); - PyroTech.kiln.add(recipe); + PyroTech.pitKiln.add(recipe); return recipe; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PyroTech.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PyroTech.java index 5a23c7f3c..70d58d806 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PyroTech.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/PyroTech.java @@ -6,12 +6,16 @@ public class PyroTech extends GroovyPropertyContainer { public static final Barrel barrel = new Barrel(); public static final Campfire campfire = new Campfire(); + public static final StoneOven stoneOven = new StoneOven(); + public static final BrickOven brickOven = new BrickOven(); public static final ChoppingBlock choppingBlock = new ChoppingBlock(); public static final CompactingBin compactingBin = new CompactingBin(); public static final CompostBin compostBin = new CompostBin(); public static final CrudeDryingRack crudeDryingRack = new CrudeDryingRack(); public static final DryingRack dryingRack = new DryingRack(); - public static final Kiln kiln = new Kiln(); + public static final PitKiln pitKiln = new PitKiln(); + public static final StoneKiln stoneKiln = new StoneKiln(); + public static final BrickKiln brickKiln = new BrickKiln(); public static final Anvil anvil = new Anvil(); public static final SoakingPot soakingPot = new SoakingPot(); public static final TanningRack tanningRack = new TanningRack(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneKiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneKiln.java new file mode 100644 index 000000000..935c022ec --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneKiln.java @@ -0,0 +1,138 @@ +package com.cleanroommc.groovyscript.compat.mods.pyrotech; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.codetaylor.mc.pyrotech.modules.tech.machine.ModuleTechMachine; +import com.codetaylor.mc.pyrotech.modules.tech.machine.recipe.StoneKilnRecipe; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class StoneKiln extends ForgeRegistryWrapper { + + public StoneKiln() { + super(ModuleTechMachine.Registries.STONE_KILN_RECIPES); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:gold_ingot')).burnTime(400).failureChance(1f).failureOutput(item('minecraft:wheat'), item('minecraft:carrot'), item('minecraft:sponge')).name('iron_to_gold_kiln_with_failure_items_stone')")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'clay_to_iron_stone', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, item('minecraft:dirt'), item('minecraft:cobblestone')")) + public StoneKilnRecipe add(String name, IIngredient input, ItemStack output, int burnTime, float failureChance, ItemStack... failureOutput) { + return recipeBuilder() + .burnTime(burnTime) + .failureChance(failureChance) + .failureOutput(failureOutput) + .name(name) + .input(input) + .output(output) + .register(); + } + + @MethodDescription + public void removeByInput(ItemStack input) { + if (GroovyLog.msg("Error removing stone kiln recipe") + .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (StoneKilnRecipe recipe : getRegistry()) { + if (recipe.getInput().test(input)) { + remove(recipe); + } + } + } + + @MethodDescription(example = @Example("item('pyrotech:bucket_clay')")) + public void removeByOutput(IIngredient output) { + if (GroovyLog.msg("Error removing stone iln recipe") + .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (StoneKilnRecipe recipe : getRegistry()) { + if (output.test(recipe.getOutput())) { + remove(recipe); + } + } + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property + private final ItemStackList failureOutput = new ItemStackList(); + @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) + private int burnTime; + @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) + private float failureChance; + + @RecipeBuilderMethodDescription + public RecipeBuilder burnTime(int time) { + this.burnTime = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureChance(float chance) { + this.failureChance = chance; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(ItemStack failureOutputs) { + this.failureOutput.add(failureOutputs); + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(ItemStack... failureOutputs) { + for (ItemStack itemStack : failureOutputs) { + failureOutput(itemStack); + } + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder failureOutput(Iterable failureOutputs) { + for (ItemStack itemStack : failureOutputs) failureOutput(itemStack); + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Pyrotech Stone Kiln Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + this.failureOutput.trim(); + validateCustom(msg, failureOutput, 1, 100, "failure output"); + msg.add(burnTime < 0, "burnTime must be a non negative integer, yet it was {}", burnTime); + msg.add(failureChance < 0, "failureChance must be a non negative float, yet it was {}", failureChance); + msg.add(super.name == null, "name cannot be null."); + msg.add(ModuleTechMachine.Registries.STONE_KILN_RECIPES.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable StoneKilnRecipe register() { + if (!validate()) return null; + StoneKilnRecipe recipe = new StoneKilnRecipe(output.get(0), input.get(0).toMcIngredient(), burnTime, failureChance, failureOutput.toArray(new ItemStack[0])).setRegistryName(super.name); + PyroTech.stoneKiln.add(recipe); + return recipe; + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneOven.java new file mode 100644 index 000000000..99c6db71d --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/StoneOven.java @@ -0,0 +1,107 @@ +package com.cleanroommc.groovyscript.compat.mods.pyrotech; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; +import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CampfireRecipe; +import com.codetaylor.mc.pyrotech.modules.tech.machine.ModuleTechMachine; +import com.codetaylor.mc.pyrotech.modules.tech.machine.recipe.StoneOvenRecipe; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.pyrotech.oven.note0", + type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD, + hasTitle = true)) +public class StoneOven extends ForgeRegistryWrapper { + + public StoneOven() { + super(ModuleTechMachine.Registries.STONE_OVEN_RECIPES); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:emerald')).duration(400).name('diamond_campfire_to_emerald_stone')")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt_stone', item('minecraft:apple'), item('minecraft:dirt'), 1000")) + public StoneOvenRecipe add(String name, IIngredient input, ItemStack output, int duration) { + return recipeBuilder() + .duration(duration) + .name(name) + .input(input) + .output(output) + .register(); + } + + @MethodDescription(example = @Example("item('minecraft:porkchop')")) + public void removeByInput(ItemStack input) { + if (GroovyLog.msg("Error removing stone oven recipe") + .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (StoneOvenRecipe recipe : getRegistry()) { + if (recipe.getInput().test(input)) { + remove(recipe); + } + } + } + + @MethodDescription(example = @Example("item('minecraft:cooked_porkchop')")) + public void removeByOutput(IIngredient output) { + if (GroovyLog.msg("Error removing stone oven recipe") + .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") + .error() + .postIfNotEmpty()) { + return; + } + for (StoneOvenRecipe recipe : getRegistry()) { + if (output.test(recipe.getOutput())) { + remove(recipe); + } + } + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) + private int duration; + + @RecipeBuilderMethodDescription + public RecipeBuilder duration(int time) { + this.duration = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Pyrotech Stone Oven Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); + msg.add(super.name == null, "name cannot be null."); + msg.add(ModuleTechMachine.Registries.STONE_OVEN_RECIPES.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable StoneOvenRecipe register() { + if (!validate()) return null; + StoneOvenRecipe recipe = new StoneOvenRecipe(output.get(0), input.get(0).toMcIngredient(), duration).setRegistryName(super.name); + PyroTech.stoneOven.add(recipe); + return recipe; + } + } +} diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 6ff631740..b3e49445a 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -1611,8 +1611,20 @@ groovyscript.wiki.pyrotech.barrel.description=Over time converts a fluid with fo groovyscript.wiki.pyrotech.barrel.duration.value=Sets the time required for the recipe to complete groovyscript.wiki.pyrotech.barrel.add=Adds recipes in the format `name`, `input1`, `input2`, `input3`, `input4`, `fluidInput`, `fluidOutput`, `duration` +groovyscript.wiki.pyrotech.brick_kiln.title=Refractory Kiln +groovyscript.wiki.pyrotech.brick_kiln.description=Converts an item into a new one by burning it. Has a chance to fail +groovyscript.wiki.pyrotech.brick_kiln.burnTime.value=Sets the time required for the recipe to complete +groovyscript.wiki.pyrotech.brick_kiln.failureChance.value=Sets the chance to fail the recipe +groovyscript.wiki.pyrotech.brick_kiln.failureOutput.value=Sets the output when the recipe failed +groovyscript.wiki.pyrotech.brick_kiln.add=Adds recipes in the format `name`, `input`, `output`, `burnTime`, `failureChance`, `failureOutput` + +groovyscript.wiki.pyrotech.brick_oven.title=Refractory Oven +groovyscript.wiki.pyrotech.brick_oven.description=When powered by burning fuel can convert items +groovyscript.wiki.pyrotech.brick_oven.duration.value=Sets the time required for the recipe to complete +groovyscript.wiki.pyrotech.brick_oven.add=Adds recipes in the format `name`, `input`, `output`, `duration` + groovyscript.wiki.pyrotech.campfire.title=Campfire -groovyscript.wiki.pyrotech.campfire.description=Can cook food +groovyscript.wiki.pyrotech.campfire.description=When powered by burning logs can convert items groovyscript.wiki.pyrotech.campfire.duration.value=Sets the time required for the recipe to complete groovyscript.wiki.pyrotech.campfire.add=Adds recipes in the format `name`, `input`, `output`, `duration` @@ -1641,12 +1653,26 @@ groovyscript.wiki.pyrotech.drying_rack.description=Converts an item over time in groovyscript.wiki.pyrotech.drying_rack.dryTime.value=Sets the time required for the recipe to complete groovyscript.wiki.pyrotech.drying_rack.add=Adds recipes in the format `name`, `input`, `output`, `dryTime` -groovyscript.wiki.pyrotech.kiln.title=Kiln -groovyscript.wiki.pyrotech.kiln.description=Converts an item into a new one by burning it. Has a chance to fail -groovyscript.wiki.pyrotech.kiln.burnTime.value=Sets the time required for the recipe to complete -groovyscript.wiki.pyrotech.kiln.failureChance.value=Sets the chance to fail the recipe -groovyscript.wiki.pyrotech.kiln.failureOutput.value=Sets the output when the recipe failed -groovyscript.wiki.pyrotech.kiln.add=Adds recipes in the format `name`, `input`, `output`, `burnTime`, `failureChance`, `failureOutput` +groovyscript.wiki.pyrotech.pit_kiln.title=Pit Kiln +groovyscript.wiki.pyrotech.pit_kiln.description=Converts an item into a new one by burning it. Has a chance to fail +groovyscript.wiki.pyrotech.pit_kiln.burnTime.value=Sets the time required for the recipe to complete +groovyscript.wiki.pyrotech.pit_kiln.failureChance.value=Sets the chance to fail the recipe +groovyscript.wiki.pyrotech.pit_kiln.failureOutput.value=Sets the output when the recipe failed +groovyscript.wiki.pyrotech.pit_kiln.add=Adds recipes in the format `name`, `input`, `output`, `burnTime`, `failureChance`, `failureOutput` + +groovyscript.wiki.pyrotech.oven.note0=Stone and Refractory Oven includes some recipes from the Furnace Registry that can't be removed here, you have to use `furnace.add` or `furnace.remove` to manipulate those recipes directly + +groovyscript.wiki.pyrotech.stone_kiln.title=Stone Kiln +groovyscript.wiki.pyrotech.stone_kiln.description=Converts an item into a new one by burning it. Has a chance to fail +groovyscript.wiki.pyrotech.stone_kiln.burnTime.value=Sets the time required for the recipe to complete +groovyscript.wiki.pyrotech.stone_kiln.failureChance.value=Sets the chance to fail the recipe +groovyscript.wiki.pyrotech.stone_kiln.failureOutput.value=Sets the output when the recipe failed +groovyscript.wiki.pyrotech.stone_kiln.add=Adds recipes in the format `name`, `input`, `output`, `burnTime`, `failureChance`, `failureOutput` + +groovyscript.wiki.pyrotech.stone_oven.title=Stone Oven +groovyscript.wiki.pyrotech.stone_oven.description=When powered by burning fuel can convert items +groovyscript.wiki.pyrotech.stone_oven.duration.value=Sets the time required for the recipe to complete +groovyscript.wiki.pyrotech.stone_oven.add=Adds recipes in the format `name`, `input`, `output`, `duration` groovyscript.wiki.pyrotech.soaking_pot.title=Soaking Pot groovyscript.wiki.pyrotech.soaking_pot.description=Converts an item into a new one by soaking it in a liquid. Can require a campfire