0

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.

2
  • Just asking, why couldn't you just name the items? (That would technically make it unstackable against it's own kind)
    – AlexJaynMF
    Nov 8, 2021 at 21:03
  • It would make it unstackable against items with different names, but not against same name'd items.
    – BunnyMerz
    Nov 8, 2021 at 23:33

1 Answer 1

3

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .