From 9628bbba4fa588479b3d22ca2336b40f16c144b0 Mon Sep 17 00:00:00 2001 From: Aksiome <54895777+aksiome@users.noreply.github.com> Date: Sat, 25 May 2024 16:37:23 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Add=20new=20painter=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advancements/use_brush.json | 39 +++++++++++++++++++ .../functions/__load__.mcfunction | 2 + .../functions/__tick__.mcfunction | 16 ++++++++ .../functions/__unload__.mcfunction | 2 + .../functions/replace_block.mcfunction | 18 +++++++++ .../functions/replace_items.mcfunction | 22 +++++++++++ .../functions/use_brush.mcfunction | 5 +++ .../tags/functions/load.json | 5 +++ .../tags/functions/start.json | 5 +++ .../tags/functions/tick.json | 5 +++ .../tags/functions/unload.json | 5 +++ .../data/minecraft/tags/functions/load.json | 8 ++++ .../data/minecraft/tags/functions/tick.json | 8 ++++ 13 files changed, 140 insertions(+) create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json create mode 100644 datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json create mode 100644 datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json b/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json new file mode 100644 index 0000000000..3481137af8 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json @@ -0,0 +1,39 @@ +{ + "criteria": { + "color": { + "trigger": "minecraft:using_item", + "conditions": { + "item": { + "items": "minecraft:brush", + "components": { + "minecraft:custom_data": { + "bs.example:color_brush": true + } + } + } + } + }, + "magic": { + "trigger": "minecraft:using_item", + "conditions": { + "item": { + "items": "minecraft:brush", + "components": { + "minecraft:custom_data": { + "bs.example:magic_brush": true + } + } + } + } + } + }, + "requirements": [ + [ + "color", + "magic" + ] + ], + "rewards": { + "function": "bs.example.painter:use_brush" + } +} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction new file mode 100644 index 0000000000..8d5abea450 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction @@ -0,0 +1,2 @@ +# Adds a scoreboard objective to track when a player uses a brush item +scoreboard objectives add bs.example.painter.use_brush minecraft.used:minecraft.brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction new file mode 100644 index 0000000000..b0dc51fa43 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction @@ -0,0 +1,16 @@ +# We use both an advancement and an objective for educational purposes and to handle potential limitations: +# - Advancements allow continuous usage but may fail with certain blocks like signs. +# - Scores work universally but cannot be used continuously. + +# Grants the use_brush (color) advancement if the color brush is used. +execute as @a[scores={bs.example.painter.use_brush=1..}] \ + if items entity @s weapon minecraft:brush[minecraft:custom_data={"bs.example:color_brush":true}] \ + run advancement grant @s only bs.example.painter:use_brush color + +# Grants the use_brush (magic) advancement if the magic brush is used. +execute as @a[scores={bs.example.painter.use_brush=1..}] \ + if items entity @s weapon minecraft:brush[minecraft:custom_data={"bs.example:magic_brush":true}] \ + run advancement grant @s only bs.example.painter:use_brush magic + +# Resets the brush use score for all players who have used a brush. +scoreboard players reset @a[scores={bs.example.painter.use_brush=1..}] bs.example.painter.use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction new file mode 100644 index 0000000000..195645b899 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction @@ -0,0 +1,2 @@ +# Removes the scoreboard objective when the datapack is unloaded +scoreboard objectives remove bs.example.painter.use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction new file mode 100644 index 0000000000..26a95d0f72 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction @@ -0,0 +1,18 @@ +# Determines the mapping set used for block conversion based on the player's active advancement. +execute if entity @s[advancements={bs.example.painter:use_brush={color=true}}] run data modify storage bs:example painter set value { mapping_set: "bs.colors" } +execute if entity @s[advancements={bs.example.painter:use_brush={magic=true}}] run data modify storage bs:example painter set value { mapping_set: "bs.shapes" } + +# Gets the ID of the item in the player's offhand, assuming it matches a block ID. If no ID is found, return early. +execute store success score #success bs.data run data modify storage bs:example painter.type set from entity @s Inventory[{Slot:-106b}].id +execute if score #success bs.data matches 0 run return fail + +# Gets all data related to the block at the current location, including its state and NBTs. +function #bs.block:get_block + +# Replaces the block type with the mapped type from the mapping_set. For example, if the mapping_set is "color", +# the item is "orange_wool", and the block in the world is "white_carpet", the resulting block will be "orange_carpet". +function #bs.block:replace_mapped_type with storage bs:example painter + +# Sets the newly replaced block into the world at the current location. +data modify storage bs:in block.set_block set from storage bs:out block +function #bs.block:set_block diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction new file mode 100644 index 0000000000..173ef54611 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction @@ -0,0 +1,22 @@ +# Clears the player's inventory. +clear @s + +# Replaces the first hotbar slot with the color brush item. +item replace entity @s hotbar.0 with minecraft:brush[ \ + minecraft:custom_data={ "bs.example:color_brush": true }, \ + minecraft:item_name='["",{"text":"PAINT BRUSH","color":"gold","bold":true,"italic":true},{"text":" - Right click to use","color":"gray"}]', \ + minecraft:lore=['{"text":"A brushstroke of imagination.","color":"dark_gray","italic":false}','""','{"text":"Imbue the aimed block with the color","color":"gray","italic":false}','{"text":"of the block held in your offhand.","color":"gray","italic":false}'], \ +] + +# Replaces the second hotbar slot with the magic brush item. +item replace entity @s hotbar.1 with minecraft:brush[ \ + minecraft:custom_data={ "bs.example:magic_brush": true }, \ + minecraft:item_name='["",{"text":"MAGIC BRUSH","color":"light_purple","bold":true,"italic":true},{"text":" - Right click to use","color":"gray"}]', \ + minecraft:lore=['{"text":"A brushstroke of creation.","color":"dark_gray","italic":false}','""','{"text":"Imbue the aimed block with the properties","color":"gray","italic":false}','{"text":"of the block held in your offhand.","color":"gray","italic":false}'], \ +] + +# Replaces additional hotbar slots with various blocks to use in the offhand. +item replace entity @s hotbar.5 with minecraft:birch_planks +item replace entity @s hotbar.6 with minecraft:spruce_planks +item replace entity @s hotbar.7 with minecraft:cyan_wool +item replace entity @s hotbar.8 with minecraft:orange_wool diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction new file mode 100644 index 0000000000..6d022e0244 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction @@ -0,0 +1,5 @@ +# Executes a function to replace the block the player is aiming at, within a maximum distance of 5 blocks. +function #bs.view:at_aimed_block { run: "function bs.example.painter:replace_block", with: { max_distance: 5 }} + +# Revokes the brush use advancement. This must be done after everything else to keep track of which brush was used. +advancement revoke @s only bs.example.painter:use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json new file mode 100644 index 0000000000..5a85e2f2a8 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json @@ -0,0 +1,5 @@ +{ + "values": [ + "bs.example.painter:__load__" + ] +} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json new file mode 100644 index 0000000000..a8dd78023f --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json @@ -0,0 +1,5 @@ +{ + "values": [ + "bs.example.painter:replace_items" + ] +} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json new file mode 100644 index 0000000000..cc877e4e43 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json @@ -0,0 +1,5 @@ +{ + "values": [ + "bs.example.painter:__tick__" + ] +} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json new file mode 100644 index 0000000000..7c3e1cce76 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json @@ -0,0 +1,5 @@ +{ + "values": [ + "bs.example.painter:__unload__" + ] +} diff --git a/datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json b/datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json new file mode 100644 index 0000000000..c29f4a6968 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json @@ -0,0 +1,8 @@ +{ + "values": [ + { + "id": "#bs.example.painter:load", + "required": false + } + ] +} diff --git a/datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json b/datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json new file mode 100644 index 0000000000..3d13e2baf9 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json @@ -0,0 +1,8 @@ +{ + "values": [ + { + "id": "#bs.example.painter:tick", + "required": false + } + ] +} From 905d3af3f7e9ccf287dec97df59ab58064f0985e Mon Sep 17 00:00:00 2001 From: Aksiome <54895777+aksiome@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:33:17 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Update=20painter=20exa?= =?UTF-8?q?mple=20for=20the=202.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advancement/use_brush.json | 18 +++++++++ .../advancements/use_brush.json | 39 ------------------- .../__load__.mcfunction | 0 .../function/__tick__.mcfunction | 6 +++ .../__unload__.mcfunction | 0 .../replace_block.mcfunction | 9 +++-- .../replace_items.mcfunction | 4 +- .../use_brush.mcfunction | 3 +- .../functions/__tick__.mcfunction | 16 -------- .../tags/{functions => function}/load.json | 0 .../tags/{functions => function}/start.json | 0 .../tags/{functions => function}/tick.json | 0 .../tags/{functions => function}/unload.json | 0 .../tags/{functions => function}/load.json | 0 .../tags/{functions => function}/tick.json | 0 15 files changed, 33 insertions(+), 62 deletions(-) create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/advancement/use_brush.json delete mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json rename datapacks/Bookshelf Examples/data/bs.example.painter/{functions => function}/__load__.mcfunction (100%) create mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/function/__tick__.mcfunction rename datapacks/Bookshelf Examples/data/bs.example.painter/{functions => function}/__unload__.mcfunction (100%) rename datapacks/Bookshelf Examples/data/bs.example.painter/{functions => function}/replace_block.mcfunction (54%) rename datapacks/Bookshelf Examples/data/bs.example.painter/{functions => function}/replace_items.mcfunction (87%) rename datapacks/Bookshelf Examples/data/bs.example.painter/{functions => function}/use_brush.mcfunction (70%) delete mode 100644 datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction rename datapacks/Bookshelf Examples/data/bs.example.painter/tags/{functions => function}/load.json (100%) rename datapacks/Bookshelf Examples/data/bs.example.painter/tags/{functions => function}/start.json (100%) rename datapacks/Bookshelf Examples/data/bs.example.painter/tags/{functions => function}/tick.json (100%) rename datapacks/Bookshelf Examples/data/bs.example.painter/tags/{functions => function}/unload.json (100%) rename datapacks/Bookshelf Examples/data/minecraft/tags/{functions => function}/load.json (100%) rename datapacks/Bookshelf Examples/data/minecraft/tags/{functions => function}/tick.json (100%) diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/advancement/use_brush.json b/datapacks/Bookshelf Examples/data/bs.example.painter/advancement/use_brush.json new file mode 100644 index 0000000000..7ccc97effe --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/advancement/use_brush.json @@ -0,0 +1,18 @@ +{ + "criteria": { + "requirement": { + "trigger": "minecraft:using_item", + "conditions": { + "item": { + "items": "minecraft:brush", + "predicates": { + "minecraft:custom_data": "{\"bs.example.painter:brush\":true}" + } + } + } + } + }, + "rewards": { + "function": "bs.example.painter:use_brush" + } +} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json b/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json deleted file mode 100644 index 3481137af8..0000000000 --- a/datapacks/Bookshelf Examples/data/bs.example.painter/advancements/use_brush.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "criteria": { - "color": { - "trigger": "minecraft:using_item", - "conditions": { - "item": { - "items": "minecraft:brush", - "components": { - "minecraft:custom_data": { - "bs.example:color_brush": true - } - } - } - } - }, - "magic": { - "trigger": "minecraft:using_item", - "conditions": { - "item": { - "items": "minecraft:brush", - "components": { - "minecraft:custom_data": { - "bs.example:magic_brush": true - } - } - } - } - } - }, - "requirements": [ - [ - "color", - "magic" - ] - ], - "rewards": { - "function": "bs.example.painter:use_brush" - } -} diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/__load__.mcfunction similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/functions/__load__.mcfunction rename to datapacks/Bookshelf Examples/data/bs.example.painter/function/__load__.mcfunction diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/function/__tick__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/__tick__.mcfunction new file mode 100644 index 0000000000..6db5d02072 --- /dev/null +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/function/__tick__.mcfunction @@ -0,0 +1,6 @@ +# We use both an advancement and an objective for educational purposes and to handle potential limitations: +# - Advancements allow continuous usage but may fail with certain blocks like signs. +# - Scores work universally but cannot be used continuously. + +# Run the use_brush function if the brush is used. +execute as @a[scores={bs.example.painter.use_brush=1..}] run function bs.example.painter:use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/__unload__.mcfunction similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/functions/__unload__.mcfunction rename to datapacks/Bookshelf Examples/data/bs.example.painter/function/__unload__.mcfunction diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_block.mcfunction similarity index 54% rename from datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction rename to datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_block.mcfunction index 26a95d0f72..74ad008594 100644 --- a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_block.mcfunction +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_block.mcfunction @@ -1,6 +1,6 @@ # Determines the mapping set used for block conversion based on the player's active advancement. -execute if entity @s[advancements={bs.example.painter:use_brush={color=true}}] run data modify storage bs:example painter set value { mapping_set: "bs.colors" } -execute if entity @s[advancements={bs.example.painter:use_brush={magic=true}}] run data modify storage bs:example painter set value { mapping_set: "bs.shapes" } +execute if items entity @s weapon minecraft:brush[minecraft:custom_data~{"bs.example.painter:brush_type":"color"}] run data modify storage bs:example painter set value { mapping_registry: "bs.colors" } +execute if items entity @s weapon minecraft:brush[minecraft:custom_data~{"bs.example.painter:brush_type":"magic"}] run data modify storage bs:example painter set value { mapping_registry: "bs.shapes" } # Gets the ID of the item in the player's offhand, assuming it matches a block ID. If no ID is found, return early. execute store success score #success bs.data run data modify storage bs:example painter.type set from entity @s Inventory[{Slot:-106b}].id @@ -9,9 +9,10 @@ execute if score #success bs.data matches 0 run return fail # Gets all data related to the block at the current location, including its state and NBTs. function #bs.block:get_block -# Replaces the block type with the mapped type from the mapping_set. For example, if the mapping_set is "color", +# Replaces the block type with the mapped type from the mapping_registry. For example, if the mapping_registry is "color", # the item is "orange_wool", and the block in the world is "white_carpet", the resulting block will be "orange_carpet". -function #bs.block:replace_mapped_type with storage bs:example painter +execute if data storage bs:example painter{mapping_registry:"bs.colors"} run function #bs.block:map_type with storage bs:example painter +execute if data storage bs:example painter{mapping_registry:"bs.shapes"} run function #bs.block:mix_type with storage bs:example painter # Sets the newly replaced block into the world at the current location. data modify storage bs:in block.set_block set from storage bs:out block diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_items.mcfunction similarity index 87% rename from datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction rename to datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_items.mcfunction index 173ef54611..c1e860eb13 100644 --- a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/replace_items.mcfunction +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/function/replace_items.mcfunction @@ -3,14 +3,14 @@ clear @s # Replaces the first hotbar slot with the color brush item. item replace entity @s hotbar.0 with minecraft:brush[ \ - minecraft:custom_data={ "bs.example:color_brush": true }, \ + minecraft:custom_data={ "bs.example.painter:brush": true, "bs.example.painter:brush_type": "color" }, \ minecraft:item_name='["",{"text":"PAINT BRUSH","color":"gold","bold":true,"italic":true},{"text":" - Right click to use","color":"gray"}]', \ minecraft:lore=['{"text":"A brushstroke of imagination.","color":"dark_gray","italic":false}','""','{"text":"Imbue the aimed block with the color","color":"gray","italic":false}','{"text":"of the block held in your offhand.","color":"gray","italic":false}'], \ ] # Replaces the second hotbar slot with the magic brush item. item replace entity @s hotbar.1 with minecraft:brush[ \ - minecraft:custom_data={ "bs.example:magic_brush": true }, \ + minecraft:custom_data={ "bs.example.painter:brush": true, "bs.example.painter:brush_type": "magic" }, \ minecraft:item_name='["",{"text":"MAGIC BRUSH","color":"light_purple","bold":true,"italic":true},{"text":" - Right click to use","color":"gray"}]', \ minecraft:lore=['{"text":"A brushstroke of creation.","color":"dark_gray","italic":false}','""','{"text":"Imbue the aimed block with the properties","color":"gray","italic":false}','{"text":"of the block held in your offhand.","color":"gray","italic":false}'], \ ] diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/function/use_brush.mcfunction similarity index 70% rename from datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction rename to datapacks/Bookshelf Examples/data/bs.example.painter/function/use_brush.mcfunction index 6d022e0244..8f6b6b108e 100644 --- a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/use_brush.mcfunction +++ b/datapacks/Bookshelf Examples/data/bs.example.painter/function/use_brush.mcfunction @@ -1,5 +1,6 @@ # Executes a function to replace the block the player is aiming at, within a maximum distance of 5 blocks. function #bs.view:at_aimed_block { run: "function bs.example.painter:replace_block", with: { max_distance: 5 }} -# Revokes the brush use advancement. This must be done after everything else to keep track of which brush was used. +# Resets the brush use score and revokes the advancement. +scoreboard players reset @s bs.example.painter.use_brush advancement revoke @s only bs.example.painter:use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction b/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction deleted file mode 100644 index b0dc51fa43..0000000000 --- a/datapacks/Bookshelf Examples/data/bs.example.painter/functions/__tick__.mcfunction +++ /dev/null @@ -1,16 +0,0 @@ -# We use both an advancement and an objective for educational purposes and to handle potential limitations: -# - Advancements allow continuous usage but may fail with certain blocks like signs. -# - Scores work universally but cannot be used continuously. - -# Grants the use_brush (color) advancement if the color brush is used. -execute as @a[scores={bs.example.painter.use_brush=1..}] \ - if items entity @s weapon minecraft:brush[minecraft:custom_data={"bs.example:color_brush":true}] \ - run advancement grant @s only bs.example.painter:use_brush color - -# Grants the use_brush (magic) advancement if the magic brush is used. -execute as @a[scores={bs.example.painter.use_brush=1..}] \ - if items entity @s weapon minecraft:brush[minecraft:custom_data={"bs.example:magic_brush":true}] \ - run advancement grant @s only bs.example.painter:use_brush magic - -# Resets the brush use score for all players who have used a brush. -scoreboard players reset @a[scores={bs.example.painter.use_brush=1..}] bs.example.painter.use_brush diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/load.json similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/load.json rename to datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/load.json diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/start.json similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/start.json rename to datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/start.json diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/tick.json similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/tick.json rename to datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/tick.json diff --git a/datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json b/datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/unload.json similarity index 100% rename from datapacks/Bookshelf Examples/data/bs.example.painter/tags/functions/unload.json rename to datapacks/Bookshelf Examples/data/bs.example.painter/tags/function/unload.json diff --git a/datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json b/datapacks/Bookshelf Examples/data/minecraft/tags/function/load.json similarity index 100% rename from datapacks/Bookshelf Examples/data/minecraft/tags/functions/load.json rename to datapacks/Bookshelf Examples/data/minecraft/tags/function/load.json diff --git a/datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json b/datapacks/Bookshelf Examples/data/minecraft/tags/function/tick.json similarity index 100% rename from datapacks/Bookshelf Examples/data/minecraft/tags/functions/tick.json rename to datapacks/Bookshelf Examples/data/minecraft/tags/function/tick.json