Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions examples/postInit/thebetweenlands.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class Animator extends StandardListRegistry<IAnimatorRecipe> {
@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();
Expand Down Expand Up @@ -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<IAnimatorRecipe> {

@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<? extends Entity> entity;
@Property
private ResourceLocation render;
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/groovyscript/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down