You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an ItemStack is constructed, the default components of the item are copied into the item stack's components map. This detail is normally not an issue, since stacks are usually created after item registration has completed and the DefaultItemComponentEvents.MODIFY event is invoked.
However, one notable exception is the 'using converts to' stack of the minecraft:food component, introduced in Minecraft snapshot 24w19a. Since this item stack is part of an item's components, it exists before item registration completes. As a result, any component modifications will not affect this item stack.
Reproduction Steps
As a minimal example, this code modifies bowls to be resistant to fire:
Notice that these bowls do not stack, and only the latter bowl is resistant to fire. However, running /data get entity @s Inventory reveals that they have the same NBT representation, and reloading the world correctly makes the first bowl resistant to fire.
If you are having trouble reproducing this issue, note that interacting with the first bowl in creative mode can cause the item stack to be recreated (CreativeInventoryActionC2SPacket). Since networking recreates item stacks, default components appear correct for the client.
Proposed Solutions
A fix for this issue would have to consider whether other instances of item stacks in components, such as in component types added by mods, should be resolved automatically as well.
The following mixin fixes this specific issue in Minecraft snapshot 24w20a, though it may not be the ideal solution:
When an
ItemStack
is constructed, the default components of the item are copied into the item stack's components map. This detail is normally not an issue, since stacks are usually created after item registration has completed and theDefaultItemComponentEvents.MODIFY
event is invoked.However, one notable exception is the 'using converts to' stack of the
minecraft:food
component, introduced in Minecraft snapshot 24w19a. Since this item stack is part of an item's components, it exists before item registration completes. As a result, any component modifications will not affect this item stack.Reproduction Steps
As a minimal example, this code modifies bowls to be resistant to fire:
Obtain two bowls to demonstrate the issue:
/give
Notice that these bowls do not stack, and only the latter bowl is resistant to fire. However, running
/data get entity @s Inventory
reveals that they have the same NBT representation, and reloading the world correctly makes the first bowl resistant to fire.If you are having trouble reproducing this issue, note that interacting with the first bowl in creative mode can cause the item stack to be recreated (
CreativeInventoryActionC2SPacket
). Since networking recreates item stacks, default components appear correct for the client.Proposed Solutions
A fix for this issue would have to consider whether other instances of item stacks in components, such as in component types added by mods, should be resolved automatically as well.
The following mixin fixes this specific issue in Minecraft snapshot 24w20a, though it may not be the ideal solution:
The text was updated successfully, but these errors were encountered: