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

`minecraft:custom_data` behaves unpredictably if item came from a loot table

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21, 1.21.1, 24w35a
    • 2022 M2 MacBook Air running Sonoma 14.4.1

      Java 21.0.3 LTS
    • Community Consensus
    • Commands, Loot tables
    • Normal
    • Platform

      There seems to be an issue with how the game runs checks for lists and int arrays inside the `minecraft:custom_data` component. This issue may also affect other components, but so far I have only tested with this specific component

      Steps to Reproduce:
      Run either

      /give @s stone[minecraft:custom_data={key:[1, 1]}]
      

      or

      /give @s stone[minecraft:custom_data={key:[I; 1, 1]}]
      

      , then switch to holding that stone block. You'll notice that both of the following commands succeed in chat:

      /execute if items entity @s weapon.mainhand *[minecraft:custom_data~{key:[1, 1]}]
      /execute if items entity @s weapon.mainhand *[minecraft:custom_data~{key:[I; 1, 1]}]
      

      Now, use a loot table to give the item. It can be either a loot table file, or an inline loot table like the following command:

      /loot replace entity @s weapon.mainhand loot {"pools":[{"rolls":1,"entries":[{"type":"minecraft:item","name":"minecraft:stone","functions":[{"function":"minecraft:set_custom_data","tag":"{key:[1, 1]}"}]}]}]}
      

      This time around, both these conditions

      /execute if items entity @s weapon.mainhand *[minecraft:custom_data~{key:[1, 1]}]
      /execute if items entity @s weapon.mainhand *[minecraft:custom_data~{key:[I; 1, 1]}]
      

      inexplicably fail.

      Expected Behavior:
      The condition checks should behave consistently and intuitively across both situations.

            Unassigned Unassigned
            Nicoder Nicoder
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              CHK: