3

Are you looking for how to get a block with preset data into your inventory? See this post.


I have made a system where, when a button is pressed, a chest appears next to the player with some items. The problem is, /setblock only can set an empty chest next to the player, not one with items inside. In Java Edition, this command would have worked:

setblock ~ ~ ~ chest{Items:[{Slot:0b,id:"minecraft:dirt"}]}

How can I set a chest with items next to the player?

This can also apply to signs with text, command blocks with settings, and other container blocks with items such as dispensers, droppers, hoppers, etc.


Browse more workarounds for using NBT in Bedrock Edition

1 Answer 1

3

It's actually quite simple to do. The solution I present works in Bedrock and Java edition, and could actually be simpler if you're setting a block with lots of items!

  1. Place the block you want to set in a template location.

  2. Use /clone to copy it to the target location. Example command:

    clone Tx Ty Tz Tx Ty Tz Rx Ry Rz
    

    Tx, Ty, Tz: Template location, X, Y, and Z respectively.
    R: Same but for target location.
    You need to specify the template location twice, to say that only that one block should be cloned.

This works for any block you want to copy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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