I am making a singleplayer adventure map. I would like the player to be able to craft tools, and have them instantly replaced by tools with the CanDestroy tag, so that they can use the tools in the map. In 1.12, a solution like this works:
However, in 1.13 damage values are now an NBT tag, this means I cannot specify in the first command block that the pick has a damage value of 0. For example, the following does not work, because a brand new pickaxe has no damage tag.
/clear @p stone_pickaxe{Damage:0} 1
The only solution I can think of is to replace the tool with a different item (e.g. you craft a stone pickaxe and are given an iron pickaxe), but I would really much rather give the player the same tool.
Yes, unfortunately that solution has the same problem. A standard pickaxe doesn't have a CanDestroy tag, so even an empty CanDestroy tag is considered different. This command would not clear a normal pick from the player's inventory
Could you select it by name, and then give the new pickaxe a different name? Whether it's just a slight adjustment, or a different colour, or something that a default stone pickaxe doesn't have?
The Meaning of Life, the Universe, and Everything.
Join Date:
1/7/2019
Posts:
48
Minecraft:
JohnTempest
Member Details
So this can actually be done by a single repeating command block running the following command:
execute at @a[nbt={SelectedItem:{id:"minecraft:stone_pickaxe"},Damage:0}] run replaceitem entity @p weapon.mainhand minecraft:stone_pickaxe{CanDestroy:["minecraft:iron_ore"]} 1
After testing, it does appear that the damage tag is still recognized, I can't say exactly why you were having difficulty, but in any case, this should do what you're looking for. Hope this helps!
I am making a singleplayer adventure map. I would like the player to be able to craft tools, and have them instantly replaced by tools with the CanDestroy tag, so that they can use the tools in the map. In 1.12, a solution like this works:
Repeat Command Block: /clear @p stone_pickaxe 1 0
Conditional Command Block: /give @p stone_pickaxe 1 1 {CanDestroy["iron_ore"]}
However, in 1.13 damage values are now an NBT tag, this means I cannot specify in the first command block that the pick has a damage value of 0. For example, the following does not work, because a brand new pickaxe has no damage tag.
/clear @p stone_pickaxe{Damage:0} 1
The only solution I can think of is to replace the tool with a different item (e.g. you craft a stone pickaxe and are given an iron pickaxe), but I would really much rather give the player the same tool.

Any help or advice would be much appreciated
Note: This issue is very similar to one laid out in this thread: https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/2576411-can-you-clear-an-item-without-nbt-data-but-not but the given solution does not work in Minecraft 1.13
Have you tried doing /clear @s stone_pickaxe{CanDestroy:[""]}
Yes, unfortunately that solution has the same problem. A standard pickaxe doesn't have a CanDestroy tag, so even an empty CanDestroy tag is considered different. This command would not clear a normal pick from the player's inventory
Could you select it by name, and then give the new pickaxe a different name? Whether it's just a slight adjustment, or a different colour, or something that a default stone pickaxe doesn't have?
Please, everyone, if your post is solved, edit the name and mark it [SOLVED]. Period.
So this can actually be done by a single repeating command block running the following command:
After testing, it does appear that the damage tag is still recognized, I can't say exactly why you were having difficulty, but in any case, this should do what you're looking for. Hope this helps!
-John