Skip to content

Commit

Permalink
Add PyroTech Oven and Kiln compat (#219)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
shadl7 and WaitingIdly committed Oct 1, 2024
1 parent 7a5602e commit 64d3bfa
Show file tree
Hide file tree
Showing 10 changed files with 614 additions and 22 deletions.
4 changes: 2 additions & 2 deletions examples/postInit/custom/vanilla.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
84 changes: 77 additions & 7 deletions examples/postInit/pyrotech.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'))
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<BrickKilnRecipe> {

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<BrickKilnRecipe> {

@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<ItemStack> 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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<BrickOvenRecipe> {

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<BrickOvenRecipe> {

@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;
}
}
}
Loading

0 comments on commit 64d3bfa

Please sign in to comment.