This commit is contained in:
2024-12-12 13:00:57 +00:00
commit 1f861cba2b
11 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
scoreboard players set @s CustomModel 0
scoreboard players enable @s CustomModel

View File

@@ -0,0 +1,5 @@
scoreboard objectives add CustomModel trigger
scoreboard players set @a CustomModel 0
scoreboard players enable @a CustomModel
function custom_item_model_data:second

View File

@@ -0,0 +1,9 @@
item modify entity @s weapon.mainhand \
{\
function:set_components, \
components: {\
"!minecraft:custom_model_data": {} \
}\
}
title @s actionbar [{"text": "Custom Model Data ", "color": "green"},{"text": "removed", "color": "red"}]
execute at @s run playsound minecraft:entity.villager.work_cartographer player @s ~ ~ ~ 0.6 0.6

View File

@@ -0,0 +1,7 @@
schedule function custom_item_model_data:second 1s
execute as @a[scores={CustomModel=1}] if items entity @s weapon.mainhand * run function custom_item_model_data:trigger
execute as @a[scores={CustomModel=2..}] if items entity @s weapon.mainhand * run function custom_item_model_data:remove_model
# resets trigger
execute as @a run function custom_item_model_data:enable

View File

@@ -0,0 +1,9 @@
$item modify entity @s weapon.mainhand \
{\
function:set_components, \
components: {\
"minecraft:custom_model_data": { "strings": [ $(Model) ] } \
}\
}
$title @s actionbar [{"text": "Set Custom Model Data to ", "color": "green"},{"text": "$(Model)", "color": "aqua"}]
execute at @s run playsound minecraft:entity.villager.work_cartographer player @s ~ ~ ~ 0.6 0.6

View File

@@ -0,0 +1,7 @@
execute as @s run data remove storage custom_item_model_data:item_model Model
execute as @s run data modify storage custom_item_model_data:item_model Model set from entity @s Inventory[{Slot:-106b}].components.minecraft:writable_book_content.pages[0].raw
execute as @s run function custom_item_model_data:set_model with storage custom_item_model_data:item_model {}
execute as @s run scoreboard players reset @s CustomModel
scoreboard players set @s CustomModel 0
scoreboard players enable @a CustomModel

View File

@@ -0,0 +1,5 @@
{
"values": [
"custom_item_model_data:init"
]
}