diff --git a/examples/postInit/thebetweenlands.groovy b/examples/postInit/thebetweenlands.groovy index c910efbfd..683d94951 100644 --- a/examples/postInit/thebetweenlands.groovy +++ b/examples/postInit/thebetweenlands.groovy @@ -6,7 +6,7 @@ log.info 'mod \'thebetweenlands\' detected, running script' // Animator: // Converts an input item, Life amount from Life Crystals, and Fuel from Sulfur into an output itemstack, summoning an -// entity, a random item from a loottable, or summoning an entity and outputting an itemstack. +// entity, or a random item from a loottable. mods.thebetweenlands.animator.removeByEntity(entity('thebetweenlands:sporeling')) mods.thebetweenlands.animator.removeByInput(item('thebetweenlands:bone_leggings')) @@ -35,14 +35,6 @@ mods.thebetweenlands.animator.recipeBuilder() .fuel(5) .register() -mods.thebetweenlands.animator.recipeBuilder() - .input(item('minecraft:diamond')) - .entity(entity('minecraft:enderman')) - .output(item('minecraft:clay')) - .life(3) - .fuel(10) - .register() - // Compost: // Converts an input itemstack into an amount of compost. diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betweenlands/Animator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betweenlands/Animator.java index 62a5e9e90..3bf92dc2e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betweenlands/Animator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betweenlands/Animator.java @@ -31,7 +31,6 @@ public class Animator extends StandardListRegistry { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).life(1).fuel(1)"), @Example(".input(item('minecraft:gold_ingot')).lootTable(resource('minecraft:entities/zombie')).life(5).fuel(1)"), @Example(".input(item('minecraft:gold_block')).entity(entity('minecraft:zombie').getEntityClass()).life(1).fuel(5)"), - @Example(".input(item('minecraft:diamond')).entity(entity('minecraft:enderman')).output(item('minecraft:clay')).life(3).fuel(10)"), }) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); @@ -68,16 +67,16 @@ public boolean removeByEntity(EntityEntry entity) { } @Property(property = "input", comp = @Comp(eq = 1)) - @Property(property = "output", comp = @Comp(eq = 1)) + @Property(property = "output", comp = @Comp(gte = 0, lte = 1, unique = "groovyscript.wiki.thebetweenlands.animator.pick_one.required")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(comp = @Comp(gte = 0)) private int life; @Property(comp = @Comp(gte = 0)) private int fuel; - @Property + @Property(comp = @Comp(unique = "groovyscript.wiki.thebetweenlands.animator.pick_one.required")) private ResourceLocation lootTable; - @Property + @Property(comp = @Comp(unique = "groovyscript.wiki.thebetweenlands.animator.pick_one.required")) private Class entity; @Property private ResourceLocation render; @@ -135,10 +134,10 @@ public void validate(GroovyLog.Msg msg) { msg.add(life < 0, "life must be a positive integer greater than 0, yet it was {}", life); msg.add(fuel < 0, "fuel must be a positive integer greater than 0, yet it was {}", fuel); if (lootTable != null) { - validateCustom(msg, output, 0, 0, "item output"); msg.add(entity != null, "entity was defined even though lootTable was defined"); msg.add(!output.isEmpty(), "output was defined even though lootTable was defined"); } + msg.add(!output.isEmpty() && entity != null, "both entity and output were defined, yet only one can be"); msg.add(output.isEmpty() && lootTable == null && entity == null, "output, lootTable, and entity were all not defined. one of them should be defined to properly create the recipe"); } @@ -168,21 +167,17 @@ public void validate(GroovyLog.Msg msg) { ModSupport.BETWEENLANDS.get().animator.add(recipe); } } else if (entity != null) { - if (output.isEmpty()) { - for (var stack : input.get(0).getMatchingStacks()) { - recipe = new AnimatorRecipe(stack, fuel, life, entity); - recipe.setRenderEntity(render); - ModSupport.BETWEENLANDS.get().animator.add(recipe); - } - } else { - for (var stack : input.get(0).getMatchingStacks()) { - recipe = new AnimatorRecipe(stack, fuel, life, output.get(0), entity); - recipe.setRenderEntity(render); - ModSupport.BETWEENLANDS.get().animator.add(recipe); - } + for (var stack : input.get(0).getMatchingStacks()) { + recipe = new AnimatorRecipe(stack, fuel, life, entity); + recipe.setRenderEntity(render); + ModSupport.BETWEENLANDS.get().animator.add(recipe); + } + } else { + for (var stack : input.get(0).getMatchingStacks()) { + recipe = new AnimatorRecipe(stack, fuel, life, output.get(0)); + ModSupport.BETWEENLANDS.get().animator.add(recipe); } } - ModSupport.BETWEENLANDS.get().animator.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 04dc80b7e..982c4e8d3 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -776,12 +776,13 @@ groovyscript.wiki.betterwithmods.turntable.outputBlock.value=Sets the blockstate # The Betweenlands groovyscript.wiki.thebetweenlands.animator.title=Animator -groovyscript.wiki.thebetweenlands.animator.description=Converts an input item, Life amount from Life Crystals, and Fuel from Sulfur into an output itemstack, summoning an entity, a random item from a loottable, or summoning an entity and outputting an itemstack. +groovyscript.wiki.thebetweenlands.animator.description=Converts an input item, Life amount from Life Crystals, and Fuel from Sulfur into an output itemstack, summoning an entity, or a random item from a loottable. groovyscript.wiki.thebetweenlands.animator.fuel.value=Sets the fuel consumed groovyscript.wiki.thebetweenlands.animator.life.value=Sets the life consumed from the life crystal groovyscript.wiki.thebetweenlands.animator.entity.value=Sets the entity being spawned groovyscript.wiki.thebetweenlands.animator.render.value=Sets the entity to render, typically the same as the entity to be spawned groovyscript.wiki.thebetweenlands.animator.lootTable.value=Sets the LootTable used to generate outputs +groovyscript.wiki.thebetweenlands.animator.pick_one.required=Only one of output, entity, or lootTable can be set groovyscript.wiki.thebetweenlands.animator.removeByEntity=Removes all entries that match the given entity groovyscript.wiki.thebetweenlands.animator.removeByLootTable=Removes all entries that output the given Loot Table