Minecraft 1.19 Datapack aiming at limiting the stack size of players inventory to 1 item per slot
See this tutorial for installing the datapack to your minecraft world.
Use
/function unstackable_slots:config/enable
And
/function unstackable_slots:config/disable
To respectively enable or disable the datapack, one will need to put every modified item on the ground after disabling the datapack for them to be reset.
Every tick, the datapack modifies all item entities with NBT Item:{Count:1b}
, those items are given an id in the tag Item:{USSid}
, and this id a unique integer that ranges from
When a player inventory changes (detected using the minecraft:inventory_changed
advancement trigger) all its slots are checked, and if the number of item in a given slot is 2 or more, then it is set back to 1 and a recursive function is called to give to the player the same amount of item, where each of them is modified to have their unique id.