mojira.dev
MC-122008

custom_potion_effects in arrow entities duplicates with '/execute store' and isn't affected by '/data remove'

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

  1. 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}]}
  2. 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
  3. 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

Attachments

Comments 13

Can confirm for MC 17w46a.

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

Can confirm in 20w48a.

3 more comments

Not fixed in 22w42a, this is still present in 22w46a.

Relates to MC-128225, MC-179815, MC-153392, MC-207605, MC-135044, MC-138100.

This also appears to have the wrong category; the correct category is Commands, not Data Packs.

Can confirm for 1.19.4.

Seeing the recent effect NBT changes (snake_casing), does this still affect 1.20.2?

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.

MukiTanuki

(Unassigned)

Confirmed

Platform

Low

Data Packs

/data-remove, /execute-store, CustomPotionEffects, duplication

Minecraft 17w47a, Minecraft 17w47b, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, ..., 1.19.3, 23w05a, 1.19.4, 1.20.2, 1.20.4

24w09a

Retrieved