2

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?

2

The BE equivalents of these tags are can_place_on and 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]

The BE equivalents of the JE commands in the question are:

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

You can also combine both can_place_on and can_destroy:

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

This syntax is called 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 (,).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.