I have tried a few ways and tried many commands but I just don't seem to get it right.

What I'm trying to do :

I have a Minecraft realm with a town center where each player can press a button, which triggers a command block, giving them one pickaxe with a unique identifier (not sure what or how). Would be nice if the pickaxe could be named after the player who pressed the button like "Minecraftuser12312 Pickaxe" but not important,

If they press the button again I need to make sure they do not have the item and if the item is also not just thrown out to pick another one up from the command block.

Any help would be appreciated <3

Things to know :

I am the realm owner and command blocks are enabled in the world.

  • 2
    It is impossible to avoid duplicates. Players can always leave them at chests or ender chests, and chests are stupidly hard to clear. You can clear items from ground or check if it is from a certain player. What is the reason you are trying to avoid duplicates if they are free and infinite items?
    – BunnyMerz
    Commented Oct 25, 2021 at 12:32

2 Answers 2


Your definition of the unique item is a little ambiguous. Do you mean that the item would have the name of the player who clicked the button?


My solution is to basically remove all this special item and then give them a new one. If they don't have the item, good nothing happens. If they click it twice the first unique item gets removed before the second one comes into their hand.

Make it a datapack or put it into a chain command block sequence:

  1. When they press the button -- execute as @p run item remove pickaxe{nbt={idk},Count:1b}
  2. Secondly --- give @p whatever pickaxe{nbt={idk}}

Hopefully this helps


A simpler solution would be to prevent any player from ever having two "unique" pickaxes in their inventory.

Give the pickaxe

You can give it a unique identifier with a custom NBT tag:

give @p stone_pickaxe{unique:1b} 1

Optionally, you can give it some lore so the player knows it is a unique pickaxe:

give @p stone_pickaxe{display:{Lore:['{"text":"One per person"}']},unique:1b} 1

(It is likely possible to use some /item and sign parsing magic to put the player's name onto the item but that's not the main focus of this question.)


scoreboard objectives add unique_pickaxes dummy


Clear duplicates from their inventory

execute as @a store result score @s unique_pickaxes run clear @s stone_pickaxe{unique:1b} 0
execute as @a if score @s unique_pickaxes matches 2.. run clear @s stone_pickaxe{unique:1b} 1

You must log in to answer this question.

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