The /setblock Command in Minecraft: Place a Block Facing the Right Way, Filled Chests and Redstone
/setblock puts one exact block at exact coordinates: a barrier at spawn, a redstone block that powers a circuit from far away, a chest with the prizes already inside or a command block already written. It's the little brother of /fill (which fills areas) and the one used most inside other commands. Here's how it's written today, how to choose which way the block faces and what each error means.
Who can use it
/setblock is an operator command (level 2), like /fill and /clone. In a single-player world you need cheats turned on; on a server, being op: in the console type op YourName (how to give op).
This guide is for Minecraft Java, the one servers with Paper run. Bedrock has it too, but block states are written differently, with quotes.
Rather not set it up yourself? Minecraft servers from €6 a month, no contract and a full refund within 72 hours. Or create a free Minecraft server, no card needed.
How it's written
The shape is /setblock <x y z> <block> [mode]. For example, /setblock 100 64 -200 diamond_block puts a diamond block at those coordinates, and /setblock ~ ~-1 ~ gold_block turns the block under your feet into gold.
You see the coordinates with F3 (the “Block” line, or “Targeted Block” on the right if you're looking at a block). Relative ones work too: ~ ~ ~ is where you are, ~ ~1 ~ one block higher and ^ ^ ^2 two blocks in front of where you're looking.
The block goes by its ID (stone, oak_planks, redstone_block), with or without minecraft: in front. Press Tab while you type and the chat shows you the list. To remove a block, you place air: /setblock 100 64 -200 air.
The modes: replace, destroy, keep and strict
At the end you can choose what happens to the block that was already there. If you leave it out, it's replace:
replace: just swap it
Removes whatever was there and puts the new block, without dropping anything. It's the normal one.
destroy: break it as if you mined it
/setblock ~ ~ ~1 air destroybreaks the block in front of you with its sound and particles and drops what it would drop when mined (a chest, also what it had inside). Careful in a repeating command block: it drops items every time and ends up covering the floor.keep: only if it's empty
/setblock ~ ~ ~ torch keepplaces the torch only if there's air in that spot. If there's something else, it doesn't touch anything and tells you it couldn't. Useful for repeating command blocks that shouldn't overwrite what someone builds.strict: without touching what's around
Since 1.21.5,
strictplaces the block without the game updating the ones next to it: no torch falls off, no nearby redstone turns on, no water flows. Use it only if the block comes out different from what you wanted.
Which way it faces: block states
Many blocks have options: which way a staircase faces, whether a door is open, whether a log is lying down. They go in square brackets, right after the name and separated by commas: /setblock ~ ~ ~ oak_stairs[facing=north,half=top] places an upside-down staircase facing north.
Anything you leave out stays as it comes by default. To find out which options a block has, look at it with F3 open: on the right, under its name, its states show up exactly as they're written (facing: north, half: bottom…). In the chat, when you open the bracket, Tab shows you the ones that exist.
Stairs and blocks that face a side
facing=north,south,eastorwest. For furnaces, chests, dispensers:/setblock ~ ~ ~ furnace[facing=east].Sideways logs
/setblock ~ ~ ~ oak_log[axis=x]:axisisx,y(upright) orz.Slabs
/setblock ~ ~ ~ stone_slab[type=top]:topon top,bottomat the bottom anddoublethe full block.Doors and beds: two halves
A door is two blocks:
/setblock ~ ~ ~ oak_door[half=lower,facing=north]and/setblock ~ ~1 ~ oak_door[half=upper,facing=north]. Beds work the same, withpart=footandpart=headside by side. If you place only one half, it breaks instantly.
Blocks with contents: chests and command blocks
After the brackets (or after the name, if there are none) you can put the block's data in curly braces. It's the same data the game would save, so the block comes out already filled or already written.
A chest with items inside
/setblock ~ ~ ~1 chest[facing=south]{Items:[{Slot:0b,id:"minecraft:diamond",count:5},{Slot:1b,id:"minecraft:golden_apple",count:3}]}puts a chest in front of you with 5 diamonds and 3 golden apples. Since 1.20.5 the amount is lowercase (count); old videos withCount:5bno longer work. The slots (Slot) go from 0 to 26.A command block already written
/setblock ~ ~ ~1 command_block{Command:"say Welcome to the server"}. Withrepeating_command_block{Command:"…",auto:1b}it repeats and stays “Always Active”. For them to work, thecommand_blocks_workrule has to be true (more in the command block guide (in Spanish)).Power a circuit from far away
/setblock 120 60 -40 redstone_blockpowers whatever is wired to that spot;/setblock 120 60 -40 airturns it off. It's the classic trick to open doors, launch fireworks or start a minigame from a command or from the console.
Ideas for your server
An invisible barrier where you don't want anyone to go: /setblock 0 70 5 barrier (you only see it with a barrier in your hand). A prize chest that reappears at an event, with setblock … chest{Items:[…]} every time it starts. A redstone block that opens the spawn door when the countdown ends. Or getting rid of the water someone poured: /setblock ~ ~ ~ air on the source.
For more than one block, /fill is better, filling a whole box at once; to copy something that already exists, /clone; and to place a whole saved structure, /place (in Spanish).
The errors and what they mean
“Could not set the block”: the command was fine, but nothing changed. It happens when that exact block (with the same states) is already in that spot, or with keep when the spot isn't empty.
“Unknown block type”: the name is wrong or not the ID. It's in English with underscores: oak_planks, not oak planks. Press Tab.
“Block … does not have property …” or “Block … does not accept … for … property”: a state that block doesn't have (a slab has no facing) or a value that doesn't exist (facing=up on a staircase). Check it with F3 on a block of the same kind.
“Expected closing ] for block state properties”: the closing bracket is missing or there's a space inside. It all goes together: [facing=north,half=top].
“That position is not loaded”: the coordinates fall in chunks nobody has loaded. /setblock only works near a player or in areas kept loaded with forceload.
“That position is out of this world!”: the height is out of range. In the overworld you build from -64 to 319; in the Nether and the End, from 0 to 255.
“Tags aren't allowed here; only actual blocks are”: you wrote something like #minecraft:logs. Tags are for searching (in /fill … replace or /clone … filtered), not for placing: use a specific block.
“Unexpected trailing data” or “Expected key”: something's wrong in the curly braces, an extra comma, an unclosed quote or a space between the name and the brace.
From the server console
In the console it goes without the slash and with fixed coordinates: setblock 120 60 -40 redstone_block. The console isn't anywhere, so ~ ~ ~ is the world spawn point. To place it where a player is: execute at Ana run setblock ~ ~-1 ~ gold_block.
For another dimension, execute in minecraft:the_nether run setblock 10 70 10 glowstone places it in the Nether, even if you're in the overworld (the area has to be loaded).
On NapNodes
Minecraft servers run Paper on the latest version, so everything in this guide works, strict and the new chest format included. Commands are typed in the panel's “Console”, without the slash, and that's where you make yourself op with op YourName to use them from the chat.
The command block rule can also be changed without commands, in “Settings” → “Game rules” → “Enable Command Blocks”, with the server running. If you're going to fill large areas, the /fill and /clone generator writes the command and splits it into chunks. And if you don't have a server yet, the free one is good for trying out commands with your friends, no card needed.
Frequently asked questions
How do you use the /setblock command in Minecraft?
With the coordinates and the block: /setblock 100 64 -200 stone. With ~ ~-1 ~ it changes the block under you. You need to be op or have cheats turned on.
How do I remove a block with a command?
By placing air in its spot: /setblock x y z air. If you want it to drop the block as if mined, add destroy at the end.
How do I place stairs or a furnace facing one way?
With the state in square brackets: /setblock ~ ~ ~ oak_stairs[facing=north]. F3 on a block shows you which states it has and how they're written.
How do I place a chest with items inside?
With the data in curly braces: /setblock ~ ~ ~1 chest{Items:[{Slot:0b,id:"minecraft:diamond",count:5}]}. Since 1.20.5 the amount is count in lowercase.
What's the difference between /setblock and /fill?
/setblock places a single block in an exact spot; /fill fills a whole box between two corners.
What does “Could not set the block” mean?
That nothing changed: that same block was already in that spot, or you used keep and the spot wasn't empty.
Shall we set it up for you?
Minecraft servers from €6 a month, never oversold: your RAM is yours alone. And if you'd rather start without paying, there's a free Minecraft server, no card needed.
Your server doesn't show up in the game? Check it in a second with “Is my Minecraft server online?”: players, version and MOTD, free. Need a player's UUID for the whitelist or permissions? Look it up here. Handing out enchanted items? Build the command with the /give generator.
Free tool: /fill and /clone generator. Two corners and a block, and out comes the /fill or /clone. Over 32768 blocks, it splits it into commands that fit and do the same.
Keep reading
- The /give Command in Minecraft: Items With a Custom Name, Enchantments and Lore
How to use /give in today's Minecraft: the component syntax, items with a coloured name, enchantments and lore, the usual errors and the server console.
- The /kill Command in Minecraft: Clear Dropped Items, Mobs and Entities Without Breaking Anything
How to use /kill in Minecraft to clear dropped items, mobs or arrows without killing pets or villagers, with a radius, from the console, and the errors.
- The /clone Command in Minecraft: Copy, Move and Duplicate Builds
How to use /clone in Minecraft Java: copy or move a build, without the air, between dimensions, how to rotate it and the block limit and overlap errors.