diff --git a/docs/libraries/crafter/flags.md b/docs/libraries/crafter/flags.md new file mode 100644 index 0000000..26205e4 --- /dev/null +++ b/docs/libraries/crafter/flags.md @@ -0,0 +1,61 @@ +# Advanced remove (flags) + +Flags customize the way items are removed in the input while an item is crafted. + + +## Available flags + +| Flag Name | Behavior without flag | Behavior with flag | +| --------- | ---------------- | ------------------ | +| `consume_buckets` | Filled buckets are replaced by empty buckets | Filled buckets are consumed | +| `consume_tools` | Tools durability decrease at every craft | Tools are totally consumed | + + +## Example : + +Flags have to be set when your recipe succeeds, for example in a shapeless recipe : + +```{code-block} mcfunction +:force: +execute + store result score @s smithed.data + if entity @s[scores={smithed.data=0}] + if score count smithed.data matches 2 + if data storage smithed.crafter:input {recipe:} + run function ./give_result: + loot replace block ~ ~ ~ container.16 loot example:my_craft + # Set the flags here, so that the water bucket is consumed, and the diamond axe is consumed too. + data modify storage smithed.crafter:input flags append value "consume_buckets" + data modify storage smithed.crafter:input flags append value "consume_tools" +``` +Where ShapelessRecipe is : +```SNBT +[ + {id:"minecraft:water_bucket",count:1}, + {id:"minecraft:diamond_axe",count:1} +] +``` + + +## Add a custom flag + +To create your own flag, first pick up a unique name for your flag, for example `namespace:my_flag`. And add it to your recipe like the example above. + +### `#smithed.crafter:event/advanced_remove` + +Register a function to this function tag, this function has the following inputs : + +| Input Name | Input Type | Input Source | Input Objective/Path | +| --- | --- | --- | --- | +| 'Item to process' | entity | @s | weapon.mainhand | +| 'Flags list' | storage | smithed.crafter:input | flags | + +And you need to update the following output : + +| Output Name | Output Type | Output Destination | Output Objective/Path | +| --- | --- | --- | --- | +| 'Success of operation' | score | $temp | smithed.data | +| 'Item to replace in the crafter' | entity | @s | weapon.mainhand | + +The default value of 'Success of operation' is 0, which by default just remove one item. This would be the default behavior if your flag is not present. If your flag is present and you want to change the item, set it to 1. + diff --git a/docs/libraries/crafter/function_tag.md b/docs/libraries/crafter/function_tag.md index 2625351..2275a59 100644 --- a/docs/libraries/crafter/function_tag.md +++ b/docs/libraries/crafter/function_tag.md @@ -101,12 +101,24 @@ Where ShapelessRecipe is : ] ``` +## `#smithed.crafter:event/query_tags` + +By default, crafter provides all vanilla items tags, but you can add your own tags to be queried during crafting. + + +| Input Name | Input Type | Input Source | Input Objective/Path | +| --- | --- | --- | --- | +| 'Item to process' | entity | @s | weapon.mainhand | + +### Example : +To add your own tags by adding a line like this : +```{code-block} mcfunction +execute + if items entity @s weapon.mainhand #namespace:tag_name + run data modify storage smithed.crafter:main root.temp.item_tag append value "#namespace:tag_name" +``` ## Advanced uses : A list of advanced uses of the crafter library. -- [Flags](https://github.com/Smithed-MC/Libraries/blob/main/smithed_libraries/packs/crafter/data/smithed.crafter/function/impl/block/table/crafting/output/clear_input/advanced.mcfunction) To register custom flags when crafting to use tools, empty buckets, etc... -- [Item Tags](https://github.com/Smithed-MC/Libraries/blob/main/smithed_libraries/packs/crafter/data/smithed.crafter/function/impl/block/table/crafting/input/query_tags.mcfunction) To register custom items tags - [Custom crafting table](https://github.com/Smithed-MC/Libraries/blob/main/smithed_libraries/packs/crafter/data/smithed.crafter/function/impl/block/table/break/drop_item.mcfunction) To register your own crafting table. - - diff --git a/docs/libraries/crafter/index.md b/docs/libraries/crafter/index.md index 7a3c870..6306f75 100644 --- a/docs/libraries/crafter/index.md +++ b/docs/libraries/crafter/index.md @@ -77,4 +77,5 @@ Documentation for the implementing crafting recipes :hidden: data_types function_tag +flags ```