How to make items not stackable
I made item frames with items that keep replacing themselves, so I can get the items infinitely by clicking on it, but I don't want these items to stack.
I know I can make items unstackable with tags, but I don't know how I will put a different tag for each item.
I thought about scoreboards that would increase when I pick up these items and then, based on the score, add a tag to the nearest dropped item of that type, but that would not work in multiplayer.
Create a scoreboard called ItemId
as dummy
. Set the player $Id
score's to 1
/scoreboard objectives add ItemId dummy
/scoreboard players set $Id ItemId 1
Now execute as every item you want (adding a generic tag to every item this rule applies should be nice for optimization):
- Store their nbt (one we created. In this case i'm using Item.tag.Unique) into the score. If doesn't exist, it stores 0.
- Test if it is 0, if so then set it to
$Id
's score. - Add
$Id
's score to one.
And these re their versions as commands.
/execute as <item target> store result score @s ItemId run data get entity @s Item.tag.Unique
/execute as <item taget>[scores={ItemId=0},limit=1] store result entity @s Item.tag.Unique int 1 run scoreboard players get $Id ItemId
/execute if entity <item target>[scores={ItemId=0}] run scoreboard players add $Id ItemId 1