Minecraft – How to make a secret room using command blocks

minecraft-commandsminecraft-java-edition

I'm very new to Minecraft commands and redstone, but I want to make a secret room by using the setblock command. This is what I have so far but it won't work for me. Can someone make or teach me how to use this command?

/setblock 272.302 62.60809 303.300 oak_wood_plank

Should this work? I also want another command block to replace the planks with air and I think I know how to do that, but I'm not so sure but if someone could help me out it would be very appreciated!

Best Answer

You wouldn't want to use setblock.

A command block can only hold one command, so it can /setblock in only one place. Take this command:

/setblock -124 45 -246 minecraft:stone

That command would take up one whole command block, and only place one block at the position (-124, 45, -246). The better option would to be the /fill command. Consider this:

/fill -124 45 -246 -150 50 -246 minecraft:stone

This command would fill stone blocks from the point of (-124, 45, -246) to (-150, 50, -246), effectively generating a stone wall. You'd need 12 command blocks (one for each wall, the roof and the floor to generate the walls, and 6 more to fill them with whatever block surrounds the room) plus one for each other block you have in the room, but it's a far cry from the 500+ you'd need if you were using the /setblock command.

Approaching the problem

We know what commands we're going to use now, so let's get the coordinates of the walls. Go to where you plan your first wall to start and click F3, or FN + F3 if you're on a laptop.

enter image description here

Find the circled line on your computer and write down the numbers after Block:. These are the coordinates you will use first. Now fly up to where you want the end of your wall to be and write down those coordinates too.

Place down a command block where you want your secret room entrance to be and put the following command inside:

/fill (Coordinates 1) (Coordinates 2) minecraft:planks 0 replace

Place down another command block after it, possibly using a repeater:

/fill (Coordinates 1) (Coordinates 2) minecraft:air replace

Now repeat the steps from the beginning of this section for each of the walls, roof and floor. Once you've done that, you've finished! Here's a bird's eye view of how the command blocks should look:

enter image description here

All the bottom ones are the /fill wood planks and the top ones /fill air.