mojira.dev
MC-275018

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

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.

Environment

2022 M2 MacBook Air running Sonoma 14.4.1

Java 21.0.3 LTS

Attachments

Comments 4

Can confirm, there is some strange behaviour with the two items obtained from

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

and

/loot give @s loot {"pools":[{"rolls":1,"entries":[{"type":"minecraft:item","name":"minecraft:stone","functions":[{"function":"minecraft:set_custom_data","tag":"{key:[1, 1]}"}]}]}]}
  • They don't seem to stack together when given

  • They behave differently with if items

however

  • You can manually drag and drop them together and they stack

  • and using /data get entity @s SelectedItem whilst holding either of them shows the same data. They both show as having an integer array [I;0,0] despite being defined with a list.

Issue persists in latest pre-release. In fact, the issue is even worse now as the items refuse to manually stack.

Could not confirm this in 26.2

Nicoder

(Unassigned)

Community Consensus

Platform

Normal

Commands, Loot tables

command, inconsistency, item-component, loot-table

1.21, 1.21.1, 24w35a

Retrieved