The if slots sub-command is intended to return all slots selected by the slot source, regardless of if they are empty or not. The changelog specifies “minecraft:contents is no longer restricted to only selecting non-empty slots” so it is expected for it to return the maximum number of slots in the container.
Typically this means the same number will be returned by if slots as would be filled by item fill using the same slot source, since the same slots are targetted in both cases.
However, there is an inconsistency between the two in the case of filling a minecraft:container component on an item…
This command will only return the number of slots up until the last filled slot in the container in your mainhand:
execute if slots entity @s {type:"minecraft:contents",slot_source:{type:"minecraft:slot_range",source:"this",slots:"weapon.mainhand"},component:"minecraft:container"}e.g. If you hold an empty chest, it will return 0
e.g. If you hold chest[container=[{slot:9,item:{id:stone}}]], it will return 10
(This behaviour is not mentioned anywhere in the changelog)
Whereas this command, which uses the same slot source, targets all 256 slots in the container component:
item fill entity @s {type:"minecraft:contents",slot_source:{type:"minecraft:slot_range",source:"this",slots:"weapon.mainhand"},component:"minecraft:container"} with stoneFurthermore these are both inconsistent with the number of slots returned by a chest block entity, but seeing as there’s no context for the container item component to be restricted to 27 for chest items or 9 for dropper items etc., that’s not the focus of this report.
As this slot source should in fact target all 256 slots inside the minecraft:container component, as shown by the second command and as is described by the changelog, I would expect it to consistently return 256 slots in if slots and all other cases.
Comments 0
No comments.