[GH-ISSUE #7724] NBT item counts above 99 retain an invalid oversized count #3341

Open
opened 2026-11-03 04:07:39 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @TheMrZZ on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7724

Originally assigned to: @TheMrZZ on GitHub.

🤖 Filed by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally.

NBT item stacks with count above 99 retain the oversized count in Horizon. Java Edition 26.3 decodes an invalid count as the field's default, 1. This affects equipment loaded through entity data and items loaded into block containers.

With ticks frozen, a loaded area and an armor stand tagged h085, clear its main hand and run:

data modify entity @e[type=minecraft:armor_stand,tag=h085,limit=1] equipment.mainhand set value {id:"minecraft:diamond_sword",count:100}
data get entity @e[type=minecraft:armor_stand,tag=h085,limit=1] equipment.mainhand.count

Java returns 1; Horizon returns 100. Counts 255, 256 and 2147483647 also default to 1 in Java. Count 99 remains valid even for a diamond sword. The same difference appears for stone in a chest's Items list.

Official 26.3 ItemStack's codec builds the count field with ExtraCodecs.intRange(1,99) and optionalAlwaysPresentFieldOf("count",1). Current main 6ed5b17a6's horizon-items/src/item_nbt.rs::item_from_nbt only applies a lower bound. The fix belongs in NBT decoding; item default components, normal item stack limits and arbitrary runtime counts are separate concerns from this codec field.

Originally created by @TheMrZZ on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7724 Originally assigned to: @TheMrZZ on GitHub. > 🤖 Filed by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally. NBT item stacks with `count` above 99 retain the oversized count in Horizon. Java Edition 26.3 decodes an invalid count as the field's default, 1. This affects equipment loaded through entity data and items loaded into block containers. With ticks frozen, a loaded area and an armor stand tagged `h085`, clear its main hand and run: ```mcfunction data modify entity @e[type=minecraft:armor_stand,tag=h085,limit=1] equipment.mainhand set value {id:"minecraft:diamond_sword",count:100} data get entity @e[type=minecraft:armor_stand,tag=h085,limit=1] equipment.mainhand.count ``` Java returns 1; Horizon returns 100. Counts 255, 256 and 2147483647 also default to 1 in Java. Count 99 remains valid even for a diamond sword. The same difference appears for stone in a chest's `Items` list. Official 26.3 `ItemStack`'s codec builds the count field with `ExtraCodecs.intRange(1,99)` and `optionalAlwaysPresentFieldOf("count",1)`. Current main `6ed5b17a6`'s `horizon-items/src/item_nbt.rs::item_from_nbt` only applies a lower bound. The fix belongs in NBT decoding; item default components, normal item stack limits and arbitrary runtime counts are separate concerns from this codec field.
Author
Owner

@TheMrZZ commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6587165361 --> @TheMrZZ commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3341
No description provided.