Minecraft – Can destroy command to destroy a certain type of block

minecraft-commandsminecraft-java-edition

Is there a way to destroy a certain type of block (ie. Oak wood planks)
The command I've got so far is:

/blockdata ~-1 ~ ~ {Items:[{id:wooden_axe,Damage:#,Count:1,tag:{CanDestroy:["minecraft:planks 0"],display:{Name:"Axe"}},Slot:13}]}

I am using the blockdata command to get a wooden axe in the middle of the chest that can only break oak wood planks. With this command the wooden axe shows 'missingno' under it.

Best Answer

Unfortunately there is not currently a way to limit the CanDestroy or CanPlace NBT Tags to the Damage Value of a block.

For example: "minecraft:planks" for all wooden planks works, but Minecraft sees the string "minecraft:planks 0" as an error. This is what is causing the "missigno" error. If there is an error in the formatting of a datatag, i.e. string instead of an integer, capital where there should be a lowercase, symbol for an integer, Minecraft will usually skip that tag, and move on to the next. However, for the CanDestroy tag it seems to try to find the block instead of skipping it. When it can't find the block, it returns with "missngno", rather than nothing at all.

For the CanDestroy tag, you can only use a block id:

/blockdata ~-1 ~ ~ {Items:[{id:wooden_axe,Damage:0,Count:1,tag:{CanDestroy:["minecraft:planks"],display:{Name:"Axe"}},Slot:13}]}

You would also get the "missingno" error if you used an empty string, i.e. ""

It also happens that in your command, the Damage tag is being skipped as well. This is because you have the symbol # instead of an integer there. Minecraft sees this as a error and ignores the tag, leaving the default value, 0 damage, in its place. You could just as well leave the Damage tag off if you didn't want the axe to have any damage on it.

Sources:

In-game testing

http://minecraft.gamepedia.com/Tutorials/Command_NBT_tags