The bug
When using the /execute store
command on a tipped arrow with custom potion effects, rather than replacing the respective NBT, it will duplicate the field first, THEN replace the respective NBT in the new field.
How to reproduce
Summon an arrow with
custom_potion_effects
NBT data:/summon arrow ~ ~ ~ {custom_potion_effects:[{ambient:0b,show_particles:1b,duration:1200,id:"minecraft:luck",amplifier:1b}]}
Run an example
execute store
command:/execute store success entity @e[limit=1,type=arrow] custom_potion_effects[0].duration int 1 run say store
Using
/data get
on the entity results in duplicate entries:/data get entity @e[type=arrow,limit=1] custom_potion_effects
Result
Arrow has the following entity data: [{duration: 1200, show_icon: 1b, amplifier: 1b, ambient: 0b, id: "minecraft:luck", show_particles: 1b}, {duration: 1, show_icon: 1b, amplifier: 1b, ambient: 0b, id: "minecraft:luck", show_particles: 1b}]
Using /data remove
doesn't seem to modify the custom_potion_effects
tag at all.
/data remove entity @e[limit=1,type=arrow] custom_potion_effects[0]
using this and then /data get
gives the same results as listed above.
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
relates to 4
Attachments
Comments 13
In 18w31a the last command (/data remove entity @e[limit=1,type=arrow] CustomPotionEffects[0]
) gives me an error: {color:#d04437}Can't access element 0, either doesn't exist or parent isn't a list{color}
.
Can confirm this is still a bug in 1.16.4 pre-release 2. It has the same behaviour with the /data modify command too
In 1.16.4, I can remove the tag. However, the data doesn't update until 600 ticks after I run the command!
If the life was 0 when I ran the command (i.e. the arrow just landed), it updates at life:600
If I set the life to 100 when I run the command, the arrow updates at life:700
I am only partially able to reproduce this in 1.20.2, but I don't know if it's because of any error in my commands. The effect does not get duplicated, but I am not able to remove it using /data remove
either. I am using the following commands:
/summon arrow ~ ~ ~ {custom_potion_effects:[{ambient:0b,show_particles:1b,duration:1200,id:"minecraft:luck",amplifier:1b}]}
/execute store success entity @e[limit=1,type=arrow] custom_potion_effects[0].id byte 1 run say store
/data remove entity @e[limit=1,type=arrow] custom_potion_effects[0]
That could be an issue with the /execute store
command because id is no longer a byte, but a string; however, I am not very familiar with these commands, so I am not sure what the correct alternative would be. Regardless, I still can't use /data remove
, so I will add 1.20.2 as an affected version.
Update: the effect doesn't get duplicated when you use id
, but it does when you use duration
. So this hasn't been fixed. I will update the description accordingly.
Can confirm for MC 17w46a.