Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-271026

Components that set a status effect sometimes lose parts of the data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.20.5 Release Candidate 2
    • None
    • Confirmed
    • Commands, Data Packs, Items
    • Important
    • Platform

      Items with potion_contents, food.effects, etc sometimes lose show_particles:0b and get show_icon:1b added to it. Changing other component data unrelated to the status effect will sometimes cause the data to not get deleted.

       

      To replicate:

      Here are two commands that give different items

      Item1: 

      /give @s glowstone_dust[food={saturation:0,nutrition:0,eat_seconds:0.1,can_always_eat:1,effects:[{effect:{id:glowing,duration:-1,show_particles:0b,show_icon:0b}}]}]

      Item2:

      /give @s glowstone_dust[food={saturation:0,nutrition:0,eat_seconds:0.1,can_always_eat:1,effects:[{effect:{id:glowing,duration:-1,show_icon:1b}}]}]

      Run only the Item1 command and eat the glowstone. There are no particles and no icon, as intended.

      Now drink milk to clear the effect, and throw away the item.

      Run the Item2 command now and eat the glowstone. There are particles and an icon, as expected.

      Now run both commands, and notice that the two items stack together despite having different component data. Whether or not the combined item will have particles and an icon or not depends on the order you got the items, and the second item will now have its data removed permanently.

       

      Other testing

      The problem appears to be how an ItemStack is encoded into an NBT compound. The following commands show some strange behavior for potion items losing the data.

      Item3:

      /give @s potion[potion_contents={custom_color:16777215,custom_effects:[{amplifier:127b,duration:10,id:"minecraft:levitation",show_icon:0b,show_particles:0b}]}]

      Item4:

      /give @s potion[potion_contents={custom_effects:[{amplifier:127b,duration:10,id:"minecraft:levitation",show_icon:0b,show_particles:0b}]}]

      Run both of the commands to get the different items. Item3 gets encoded with show_icon:1b and without show_particles:0b. Item4 gets encoded properly. The only difference between the items are whether it has custom_color or not. Setting the custom_color to a different color or removing amplifier also makes it get encoded properly.

       

            gegy1000 [Mojang] Gegy
            42Richtofen42 42Richtofen42
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: