Anvil Crafting (Better With Mods)
Description
Similar to a normal crafting table, but 4x4 instead.
Identifier
Refer to this via any of the following:
mods.betterwithmods.anvil_crafting/* Used as page default */
mods.betterwithmods.anvilcrafting
mods.betterwithmods.anvilCrafting
mods.betterwithmods.AnvilCrafting
mods.betterwithmods.soulforged_steel_anvil
mods.betterwithmods.soulforgedsteelanvil
mods.betterwithmods.soulforgedSteelAnvil
mods.betterwithmods.SoulforgedSteelAnvil
Adding Recipes
Add the given recipe to the recipe list:
groovymods.betterwithmods.anvil_crafting.add(IRecipe)
Recipe Builder
Just like other recipe types, the Anvil Crafting also uses a recipe builder.
Don't know what a builder is? Check the builder info page out.
mods.betterwithmods.anvil_crafting.shapedBuilder()
ResourceLocation
. Sets the Resource Location of the recipe.groovyname(String) name(ResourceLocation)
String[]
. Sets the items required in each slot of the grid as char. Requires either the key-based matrix or the ingredient-based matrix can be defined, not both.groovyrow(String) shape(String...) matrix(String...)
List<List<IIngredient>>
. Sets the items required in each slot in the grid as IIngredients. Requires greater than or equal to 1, less than or equal to 16, and either the key-based matrix or the ingredient-based matrix can be defined, not both.groovyshape(List<List<IIngredient>>) matrix(List<List<IIngredient>>)
Char2ObjectOpenHashMap<IIngredient>
. Sets the item the given char corresponds to. (Default' ' = IIngredient.EMPTY
).groovykey(char, IIngredient) key(String, IIngredient) key(Map<String, IIngredient>)
ItemStack
. Sets the item output. Requires not null.groovyoutput(ItemStack)
boolean
. Sets if the recipe is horizontally mirrored. (Defaultfalse
).groovymirrored() mirrored(boolean)
Closure<ItemStack>
. Sets an operation that modifies the input items or output item.groovyrecipeFunction(Closure<ItemStack>)
Closure<Void>
. Sets an operation that happens when the recipe is crafted.groovyrecipeAction(Closure<Void>)
First validates the builder, returning
null
and outputting errors to the log file if the validation failed, then registers the builder and returns the registered object. (returnsnull
ornet.minecraft.item.crafting.IRecipe
).groovyregister()
Example
mods.betterwithmods.anvil_crafting.shapedBuilder()
.output(item('minecraft:diamond') * 32)
.matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[null,null,null,item('minecraft:gold_ingot').transform({ _ -> item('minecraft:diamond') })]])
.register()
mods.betterwithmods.anvil_crafting.shapedBuilder()
.output(item('minecraft:diamond'))
.matrix('BXXX')
.mirrored()
.key('B', item('minecraft:stone'))
.key('X', item('minecraft:gold_ingot'))
.register()
mods.betterwithmods.anvil_crafting.shapelessBuilder()
ResourceLocation
. Sets the Resource Location of the recipe.groovyname(String) name(ResourceLocation)
List<IIngredient>
. Sets the items required for the recipe. Requires greater than or equal to 1 and less than or equal to 16.groovyinput(IIngredient) input(IIngredient...) input(Collection<IIngredient>)
ItemStack
. Sets the item output. Requires not null.groovyoutput(ItemStack)
Closure<ItemStack>
. Sets an operation that modifies the input items or output item.groovyrecipeFunction(Closure<ItemStack>)
Closure<Void>
. Sets an operation that happens when the recipe is crafted.groovyrecipeAction(Closure<Void>)
First validates the builder, returning
null
and outputting errors to the log file if the validation failed, then registers the builder and returns the registered object. (returnsnull
ornet.minecraft.item.crafting.IRecipe
).groovyregister()
Example
mods.betterwithmods.anvil_crafting.shapelessBuilder()
.name(resource('example:anvil_clay'))
.output(item('minecraft:clay'))
.input([item('minecraft:cobblestone'), item('minecraft:gold_ingot')])
.register()
Removing Recipes
Removes the given recipe from the recipe list:
groovymods.betterwithmods.anvil_crafting.remove(IRecipe)
Removes all recipes that match the given input:
groovymods.betterwithmods.anvil_crafting.removeByInput(IIngredient)
Removes all recipes that match the given output:
groovymods.betterwithmods.anvil_crafting.removeByOutput(IIngredient)
Removes all registered recipes:
groovymods.betterwithmods.anvil_crafting.removeAll()
Example
mods.betterwithmods.anvil_crafting.removeByInput(item('minecraft:redstone'))
mods.betterwithmods.anvil_crafting.removeByOutput(item('betterwithmods:steel_block'))
mods.betterwithmods.anvil_crafting.removeAll()
Getting the value of recipes
Iterates through every entry in the registry, with the ability to call remove on any element to remove it:
groovymods.betterwithmods.anvil_crafting.streamRecipes()