A chest with dungeon loot
/setblock ~ ~ ~2 minecraft:chest{LootTable:"minecraft:chests/simple_dungeon"}Places a chest two blocks away that fills with dungeon loot the first time it opens.

/setblock places one block at a position, with exact block states and block entity data. Use it to set a chest that holds loot, an oriented stair or a ready-made command block, or to delete a single block by setting air.
/setblock <pos> <block> [destroy|keep|replace|strict]| Argument | Expects | What it does |
|---|---|---|
| pos | Block coordinates (x y z) | Position of the block, absolute like 10 64 10 or relative like ~ ~-1 ~ for the block under you. |
| block | Block with states | Block ID with optional states in brackets and data in braces, such as minecraft:chest{LootTable:"..."}. |
/setblock ~ ~ ~2 minecraft:chest{LootTable:"minecraft:chests/simple_dungeon"}Places a chest two blocks away that fills with dungeon loot the first time it opens.
/setblock ~ ~-1 ~ minecraft:air destroyDestroys the block below your feet and drops it as an item.
/setblock 10 64 10 minecraft:oak_stairs[facing=east,half=top]Places Oak Stairs upside down at 10 64 10, facing east.
/setblock ~ ~1 ~ minecraft:torch keepPlaces a Torch above you, but only if that space is air.
Fill in the fields, then copy the command.
Command generatorreplace (default): overwrites the block in place.destroy: breaks the old block first, with particles and drops.keep: only places the block if the position is air.strict: places the block without triggering block updates."Could not set the block" usually means the block is already identical, or keep found something other than air.
States go in brackets: minecraft:oak_stairs[facing=east,half=top] places an upside-down Oak Stairs block facing east. Data goes in braces: minecraft:chest{LootTable:"minecraft:chests/simple_dungeon"} sets a Chest that fills with dungeon loot when opened, the same tables as /loot. A Command Block takes its command in {Command:"..."}. A misspelled ID returns "Unknown block type 'minecraft:oak_stair'".
~ ~-1 ~ targets the block under you. Relative coordinates start from where the command runs, so in a command block they start from the block itself. For many blocks at once, use /fill; to copy an existing build, /clone.
✓ Checked in Java Edition 26.3 · updated 2 November 2026
The block at that position is already exactly the same, or you used keep and the position was not air.
Set it to minecraft:air. Add destroy if you want the old block to drop as an item.
Type it in the chat with cheats on: /setblock <pos> <block> [destroy|keep|replace|strict].
Cheats on, or operator level 2.