generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
7a5602e
commit 64d3bfa
Showing
10 changed files
with
614 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickKiln.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/BrickOven.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.