5

Java Edition has the CanPlaceOn and CanDestroy NBT tags, which are used to restrict the blocks an item can be placed on and destroy respectively (in adventure mode). For example, the following commands give the player a stone block that can only be placed on grass and dirt, and a netherite axe that can only destroy pumpkins:

give @s stone{CanPlaceOn:["minecraft:grass","minecraft:dirt"]}
give @s netherite_axe{CanDestroy:["minecraft:pumpkin"]}

How can I do this in Bedrock Edition?


Browse more workarounds for getting/setting NBT in Bedrock Edition

1 Answer 1

6

The BE equivalents of these tags are minecraft:can_place_on and minecraft:can_destroy respectively. You can use these in the /give and /replaceitem commands using the final [components: json] argument. For example, the syntax of /give is:

give <player: target> <itemName: Item> [amount: int] [data: int] [components: json]

Note that unlike Java Edition, block names go inside an array named blocks that goes inside minecraft:can_place_on and minecraft:can_destroy. Like so:

give @s stone 1 0 {"minecraft:can_place_on":{"blocks":["grass","dirt"]}}
give @s netherite_axe 1 0 {"minecraft:can_destroy":{"blocks":["pumpkin"]}}

You can also combine both minecraft:can_place_on and minecraft:can_destroy:

give @s iron_block 1 0 {"minecraft:can_place_on":{"blocks":["iron_block"]},"minecraft:can_destroy":{"blocks":["grass","dirt"]}}

N.B. The namespace ID (minecraft:) is optional before the words can_place_on or can_destroy, and can be omitted. However, concerning block IDs, the namespace ID is forbidden and must not be present.

Unfortunately, these components only go as specfic as the block IDs, which can be limiting as some blocks rely on data values for variants or positioning. For example, it is impossible to specify a specific color of concrete, as the block ID concrete is used by all concrete colors. This is unlike Java Edition, where data values have been abolished in favour of separate block IDs for each variant.


This syntax is called JavaScript Object Notation (JSON), which is a format similar to the NBT used in JE commands (technically SNBT). Objects are surrounded by braces ({ and }), have keys and values separated by colons (:), and have key-value pairs separated by commas (,). Keys and strings are surrounded by double quotes ("); arrays are surrounded by brackets ([ and ]) and contain items delimited by commas (,).

2
  • While this answer is correct, note that can_place_on is far less flexible in Bedrock than in Java because of the way blocks are described. All the concrete colors have a block type of concrete, with different data values. So while in Java you can give a player a candle than can only be placed on a certain color of concrete, in Bedrock this is not possible. There is a Mojang bug on this.
    – Nick K9
    Mar 1, 2023 at 21:57
  • 1
    @NickK9 Now that you mention it, I'm surprised that the note on data values wasn't mentioned in the answer. I was in part responsible for organizing the information on this regard along with several others, and that must have slipped my mind. I've edited the answer accordingly to include that as I think it is important to note.
    – One 2 Many
    Sep 3, 2023 at 0:44

You must log in to answer this question.

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