Minecraft – How do i make a tool like a diamond pickaxe only be able to break a certain block and be unbreakable in minecraft java edition 1.15

minecraft-java-edition

Answer me in any way on this website please and in the way i can copy-paste it all. I have already tried doing /give @p minecraft:diamond_pickaxe 1 0 {CanDestroy:["minecraft:stone","minecraft:stonebrick"]} but it doesn't work in java, latest release and snapshot.

Best Answer

That command only works in Minecraft versions lower than 1.13. This is the command for 1.13+:

/give @p minecraft:diamond_pickaxe{CanDestroy:["minecraft:stone", "minecraft:stone_bricks"], Unbreakable:true}

1.13 changed many of the technical aspects of Minecraft. This was called "The Flattening". For more information see https://minecraft.gamepedia.com/Java_Edition_1.13/Flattening.