Currently, there are two ways I know of to set an item's durability for the /item command. Below are two examples of item modifiers to illustrate my point:
1. "minecraft:set_durability " (Percentage-based but allows objects):
# "damage" can take floats or objects but is 0% - 100% of max durability
{
"function": "minecraft:set_damage",
"damage": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "@s"
},
"score": "board_name",
"scale": 1
},
"add": true,
"conditions": []
}
Although you can use a scoreboard object, the problem with the function above is that it is percentage-based and will scale differently depending on the max durability of the item in question. So you cannot reliably reduce the durability by 1.
2. "minecraft:set_components" (int only):
# "minecraft:damage" can only take ints.
{
"function": "minecraft:set_components",
"components": {
"minecraft:damage": 1
}
}
The above works to damage the item by 1. However, it can only take an int, unlike "minecraft:set_damage", which can set the value from a scoreboard or a float value.
Request: Updating "minecraft_setcomponents" to allow someone to specify an object for "minecraft:damage" would give datapack developers easier control over setting an item's durability by a reliable amount, regardless of the max durability of the item.
Please sign in to leave a comment.
0 Comments