PLEASE KEEP IN MIND THAT THE DATAPACK IS PURELY FOR DEMINSTRATION PURPOSES AND IS NOT WHAT I AM REPORTING. PLEASE READ MY REPORT IN FULL TO GRASP A COMPLETE UNDERSTANDING.
I have the following data:
[ { "function": "minecraft:set_damage", "damage": { "type": "minecraft:score", "target": "this", "score": "itp_balanced_transport.elytra.extra_damage", "scale": 0.01 }, "add": true }]
If the score is equal to zero, I should expect there to be no extra damage to the item. However, the item just doesn't take damage at all. The "add" property should allow the item to take extra damage on top of the damage already provided. I know this is to change the damage precisely, so I propose adding another property called "ignore_damage_requests" to tell Minecraft if it should ignore default damage requests or allow them to come threw.
THE STEPS BELOW ASSUME THAT YOU HAVE INSTALLED THE DATAPACK
Steps to Reproduce:
Equip an elytra
Change gamemode to survival
Fly with elytra until expected durability to decrease
Expected Result: The elytra durability should decrease.
Observed Behavior: The elytra durability is constant/unchanging.
Attachments
Comments 13
Thank you for attaching the datapack! However, its still not very clear how to reproduce the issue. Could you update the report to follow this format?:
h3. Steps to Reproduce:
1.
2.
3.
h3. Expected Result:
h3. Observed Behavior:
Another thing I just discovered is that the item modifier does not work consistently. For example:
{
"function": "minecraft:set_components",
"components": {
"minecraft:max_damage": 1000,
"minecraft:custom_data": {tag:"datapack_example.elytra"}
}
}
Let's say that this is in a file called "set_durability.json". Then to use it, we we call the command:
/item modify entity @s armor.chest datapack_example:set_durability
This however throws an error because Minecraft failed to parse the file. But if instead of storing the item modifier in a file, we store it in the command, we get a different result:
/item modify entity @s armor.chest { "function": "minecraft:set_components", "components": { "minecraft:max_damage": 1000, "minecraft:custom_data": {tag:"datapack_example.elytra"} }}
This works, but for some reason, the file does not.
Please don't use the bug tracker to ask for help with your data pack. When using JSON files, you need to quote all keys
I don't know what you're referring to by "damage applied by the game by default." The durability damage incurred by using tools and armor cannot be customized at this time. If the score is zero, I would expect the item modifier to do absolutely nothing (which it appears to). Any suggestions for additional properties are out of scope for the bug tracker.
Hi, I encountered exactly same problem in 1.21, this is my datapack with the item modifier I use to modify the carrot on a stick.
[media]this is the item modifier inside: (I know it's not necessary to add brackets, and still work without it)
[
{
"function": "minecraft:set_damage",
"damage": -0.1,
"add": true
}
]
How to reproduce the bug:
1. Use a command below to get the carrot in a stick with max_damage = 100:
/give @p minecraft:carrot_on_a_stick[minecraft:max_damage=100]
2. Use the item modifier provided in the datapack mentioned above when hold the item mentioned in step1.
/item modify entity @p weapon.mainhand test_modifier:set_damage
3. Repeat step 2 exactly 8 times, the damage of the stick being set to 79 instead of 80 (meanwhile durability showed on item became 21 instead of 20).
If you track on the damage value, this is the pattern you might see:
damage: 10 20 30 40 50 60 70 79 89 99 100
durability: 90 80 70 60 50 40 30 21 11 1 0
Hope this help to spot the bug!
Can confirm the issue as Leo Xiang described above, where a precision issue is causing the wrong amount of damage to be applied when using set_damage. That also breaks future relative-mode set_damage calls from working at all.
My test where I encountered it:
1. Gave myself an item with the max_damage component and damage component both set to 100:
/give @s minecraft:clock[minecraft:max_damage=100,minecraft:damage=100,minecraft:max_stack_size=1]
2. Set up two repeating command blocks, requiring redstone, with similar commands to add and remove 0.01 damage – which should be 1 damage per tick:
item modify entity @p hotbar.0 {function: "set_damage", damage: 0.01, add: true}
item modify entity @p hotbar.0 {function: "set_damage", damage: -0.01, add: true}
3. Use a stone button for repeated 1-second runs of each. It works at first, going from 100 damage to 80, then 60... but then the precision error happens and it drops to 39 instead of 40. After that point, the command to subtract damage no longer works on it.
Seems like a precision error to me, but it breaks the intended use cases of that item modifier function, and should be fixed.
Perhaps this is a different issue than the original ticket, and a separate ticket should be opened? If it's the same issue, then this one should be re-opened.
Please provide any functional data-packs (packaged as a zip file) required for this issue, and clear steps to reproduce it consistently.
This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.