In 24w09a, the count tag in an item stack is removed when there's only one item in the stack. This is not friendly to command players.
This change may be intentional to reduce the size of level files, but changing the behaviors of commands may be unintentional. So, I report it as a bug.
Before 24w09a, to select chest boats that have any item stack that has only one oak_log:
/execute as @e[type=chest_boat,nbt={Items:[{id:"minecraft:oak_log",Count:1b}]}] run say I have an oak log stack with Count being 1.
Currently, because item stacks with count being 1 have no "count" tag, the following command doesn't work at all:
/execute as @e[type=chest_boat,nbt={Items:[{id:"minecraft:oak_log",count:1}]}] run say I have an oak log stack with count being 1.
The following command also doesn't work. It says the message no matter how many items are in an oak_log item stack.
/execute as @e[type=chest_boat,nbt={Items:[{id:"minecraft:oak_log"}]}] run say I have an oak log stack with count being 1.
This also affects comparing or counting the "count"s of item stacks, storing or modifying the counts of item stacks, etc.
There are workarounds, but complex functions or complex scoreboard operations are needed, making them too complex for most command players. And they may also result in poor performance.
In my opinion, for commands, the count tag in an item stack should always exist to be obtaining by command players.
Comments 4
to check an item with count is 1, by using this
/execute if data entity @s SelectedItem{id:"minecraft:bedrock"} unless data entity @s SelectedItem.count
as the update, an item without count components will be 1 by default.
so you can know thats an item with one count
although we can use the command:
/execute if data entity @s SelectedItem
{id:"minecraft:bedrock"}
to test that item with one count, it isn't intuitive. The command usage efficiency is reduced. I think not everyone likes the roundabout way.
if you want to get an item's count, the new snapshot content will be confused, beacuse you cant directly get the count of an item by /data get entity @s Item.count
to get the count of an item which wont go wrong will need to be
/execute store result score @s 1 run data get entity @s SelectedItem.count
/execute if score @s 1 matches 0 run scoreboard players set @s 1 1
beacuse you cant know that is an item with 1 count in components, so it will be fail, you need to manaly set it to 1, also decreased efficiency
I think there are two important change:
1.if not explicitly specifiy the 'count' field in item, the 'count' field still not exist.
2.the type of 'count' has been changed to 'int'
for 1.
if i want to test an item that 'count' = 1, the selector with nbt arg should be: [nbt={id:"...",count:1}] (format 1) or [nbt={id:"..."}] (format 2). In the format 1, explicitly specifiy the amount of count but it'll not work because there's no 'count' field in the item by default. In the format 2, it means that the match will succeed if the item have any value of 'count' in the old version. but because of the latest change, it only choose the item with 'count' = 1. This creates semantic confusion, and make many command players curious.
for 2.
I think you should use the new type choose item, 'count:1', while not 'count:1b'