Mojira Archive
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.

Unresolved

Nicoder

2024-08-08, 05:36 AM

2024-11-26, 05:50 PM

5

4

Community Consensus

Normal

Platform

Commands, Loot tables

command, inconsistency, item-component, loot-table

1.21, 1.21.1, 24w35a

-