-
Bug
-
Resolution: Won't Fix
-
None
-
24w12a
-
None
-
Community Consensus
-
(Unassigned)
Description:
In the current version of the game, when max_stack_size and max_damage, are combined for an item (e.g., a diamond sword), using the item affects the durability of the entire stack. When the items in the stack are then distributed across different inventory slots or dropped, all items reflect the durability loss.
Expected Behavior:
An exception must be made.
-Only one item should exhibit a loss in durability.
For example, if a player has a stack of 10 diamond swords with a custom max_stack_size and max_damage, uses the sword, and then distributes the swords across their inventory, only the used sword should show any sign of durability loss. The remaining 9 swords should remain intact, with full durability.-
Steps to Reproduce:
- Use the command to give a player an item with both custom components, for example:
give @s minecraft:diamond_sword[minecraft:max_stack_size=64,minecraft:max_damage=10]
- Use the item to strike an entity or mine a block, to reduce durability.
- In the inventory, split the stack of items across different slots.
- Observe that all items in the newly distributed stack show the same amount of durability loss.
Proposal for a fix :
In the "Item" class in the Components verification method, There's already an Exeption for that, but it's incomplete. To fix the bug, I guess you just need to add MAX_DAMAGE.
Current code :
DataComponentMap buildAndValidateComponents() { DataComponentMap dataComponentMap = this.buildComponents(); if (dataComponentMap.has(DataComponents.DAMAGE) && dataComponentMap.getOrDefault(DataComponents.MAX_STACK_SIZE, 1) > 1) { throw new IllegalStateException("Item cannot have both durability and be stackable"); } else { return dataComponentMap; } }
Fix :
if ((dataComponentMap.has(DataComponents.DAMAGE) || dataComponentMap.has(DataComponents.MAX_DAMAGE)) && dataComponentMap.getOrDefault(DataComponents.MAX_STACK_SIZE, 1) > 1)
.
- relates to
-
MC-269789 Durability on item stacks don't work as expected
- Resolved