Fun with Command Blocks

Noah Petherbridge
kirsle
Posted by Noah Petherbridge on Tuesday, April 09 2013 @ 10:25:00 PM
It's high time for my first Minecraft mini tutorial!

I tend to prefer playing vanilla Minecraft and try to get away with it as much as I can, and as such I've been electing not to run Bukkit or any other custom servers ever since about Minecraft 1.4 came out.

Minecraft has Command Blocks nowadays, and you can do a lot of creative things with them to replicate the behavior you could get by using Bukkit plugins. I recently started a new "Swampcore" server... the name is borrowed from a popular server on Reddit when they set up a swamp superflat temporarily while they waited for Bukkit plugins to get updated for the latest version of Minecraft.

Their version of Swampcore had you spawn in a small enclosed room, lined with pressure plates by the walls which would teleport you to an unpredictable location within a large radius on the overworld. The idea was to evenly distribute the players, so that people wouldn't build too close to the spawn point and therefore be open to griefing by newly joining players. Also, Swampcore had a 24/7 thunderstorm, which prevents mobs from burning up during the day and even allowed them to spawn in the middle of the day. I've managed to more or less copy all of this behavior using nothing more than the vanilla server, and here's how I did it:

First, the superflat preset I'm using is this:

2;0,49,1,2x7,3,2;6;biome_1,decoration,lake,lava_lake
Put simply, from the bottom up you have: 1 layer of air, 1 layer of obsidian, 1 layer of stone, 2 layers of bedrock, 1 layer of dirt, and 1 layer of grass. It's set in a swamp biome, with lakes and lava lakes, and sometimes the stone blocks (around lava lakes for example, or in the stone layer) might spawn ores.

So, go into creative mode and find the world's spawn point (give yourself a compass and go to where the needle points to, until you get to the point where the needle flips the opposite direction when you cross onto the next block). This is the center of the spawn point.

The server's spawn protection radius should be reasonably large (16 blocks should do). The protection radius basically prevents any users who aren't the operator from being able to change any blocks (destroy or place any). It also prevents them from activating any redstone devices except for pressure plates. They couldn't even open wooden doors in the protection zone.

Build a bunker out of bedrock. Here's what mine looked like:

Screenshot
(Click this and other screenshots for full size versions)

I put an iron door on my bunker and have a stone button that opens it. The button couldn't be activated by a non-operator, and as you'll see shortly, it should be unreasonably difficult for a non-operator to grief your bunker by having a creeper explode next to it.

Screenshot

Inside the bunker, build a redstone circuit designed to run on an infinite loop. I put a bunch of repeaters around, all set to the longest delay (right click 3 times), to keep the loop from bunching up on itself. When you're ready (not yet!), you'll place a redstone torch on the raised bedrock block and then immediately destroy it, so that it's only there long enough to give a quick pulse to the circuit and get it started.

Pro Tip: the 5x5 chunk radius surrounding the spawn point is always loaded in memory. Any redstone circuit that runs there will never be unloaded from memory even if all the players wander far away, so it's a good place to put your infinitely looping circuits that enforce "rules" on your server. The spawn protection radius is icing on the cake as well, as it automatically protects your circuit from being interfered with by other players (note that creepers and TNT launched from outside the protected zone can still damage the protected blocks).

Screenshot

In part of the circuit, make sure the redstone runs over the top of a command block. Use /give <your name> 137 to give yourself a command block to place. You'll definitely need to be an operator and in creative mode to set the command on the block. Hint: you can place redstone on top of the block by holding down the Shift key while you place the redstone.

Screenshot

The command I have here is this:

/tp @a[m=0,r=36] -336 202 179
This command will teleport all Survival Mode players (m=0), within a radius of 36 blocks from this command block, up to the coordinates -336, 202, 179. These coordinates in my case are, the spawn point, 202 blocks up into the sky.

The radius is set to 36 to make sure it fully encompasses the entire spawn region of the server. So anybody who joins the server or dies without a bed, they'll spawn on the surface (probably) within this radius and be immediately sniped up to the teleport spot. Players in Creative Mode are not affected, so that the operator can still get into the bedrock bunker to restart the redstone circuit in case it fails for any reason, or whatever.

Up in the sky above the spawn point, I built this floating room:

Screenshot

The floor of this room is at Y=200... I set the command block on the surface to teleport players to Y=202 just to have them off the floor a little bit. YMMV.

This room is a lot like their Swampcore server. It's a radially symmetrical room (looks the same on all 4 sides) with command blocks surrounding the perimeter. This is so that when you die and respawn and come back to this room, it won't be easy to know which pressure plate you used the last time. Even if you remember you "used the one in the middle", you still only have a 25% chance of guessing the same exact one as last time. The pressure plates are all rigged to command blocks to teleport players to a spot within a large radius, to evenly distribute them across the overworld.

Screenshot

Here is a view of this floating room from above. I put a roof area and a hole to drop down into the room just in case a user happens to spawn on top of the roof, instead of somewhere on the surface near the bedrock bunker. Hey, it happens. Note that since this room is still within the spawn protection zone, the blocks can't be destroyed or altered by the players unless they're operators. And since the room is so high in the air, the odds of getting a creeper up here, or launching TNT into the spawn region from outside to damage the room are extremely low.

Screenshot

Just like with the bedrock bunker, I have an iron door with a stone button for maintenance work (if needed) for the server operator. Even if a survival mode player spawns on the roof and drops down to this door, they can't get inside because of the protection radius.

Screenshot

This is a view from inside the maintenance room, directly below the main spawn room. These are all the command blocks that are positioned underneath the pressure plates above. I placed wooden signs under each command block that tells me the coordinates that the block will teleport you to. I also placed stone buttons on the side of the block (hint: hold down Shift to place the buttons), for testing purposes. Both the button and the pressure plate above will activate the command block.

The commands I used on these blocks are along these lines:

/tp @p 500 7 -1000
This teleports them to Y=7 (the level of the surface in my world), at the X/Y coordinates that are mentioned on the wooden signs below the command block. The @p targets the nearest player, which will usually be the one standing on the pressure plate above.

And that's all there is to it. If players find their way back to the spawn region, they can't get anywhere near the bunker without being teleported back up to the welcome room. The only way they could attack the bunker would be to somehow fling TNT over 36 blocks towards the bunker (an amazing feat in itself), but it being made of bedrock they wouldn't be able to do a whole lot of damage to it. The only way they could attack the welcome room would be to build up a super large tower to the top of the world, build a bridge as close as they're allowed to (within what the spawn protection radius will allow), and then fling TNT from all the way over there. If you set your radius high enough, even this will be highly impractical.

As for the 24-hour thunder storm... you could use another command block down in the bedrock bunker that does /weather thunder to make sure the weather stays tempestuous. Personally, I have a cron job that runs my make-it-rain script every 2 minutes. This is my cron entry for anyone interested:

*/2 * * * * /home/minecraft/bin/make-it-rain swampcore thunder 9000

Categories:

[ Blog ]

Comments

There are 23 comments on this page.

guest
guest
Posted on Thursday, August 08 2013 @ 01:14:35 PM by knight81234.

awesome guide dude.

guest
guest
Posted on Tuesday, September 03 2013 @ 09:57:10 AM by winwil.

how to make a working space rocket with command block

guest
guest
Posted on Sunday, November 10 2013 @ 04:40:24 PM by Bodhi.

What texturepack?

guest
guest
Posted on Thursday, February 13 2014 @ 10:33:40 AM by Dwight Reed.

cool, it works well-not gettin' greifed no more

Avatar
kirsle
Posted on Thursday, February 13 2014 @ 01:09:03 PM by Noah Petherbridge.

The texture pack is Sphax PureBDCraft. http://bdcraft.net/

guest
guest
Posted on Wednesday, March 12 2014 @ 07:53:14 PM by Anonymous.

yolo swag

Avatar
guest
Posted on Saturday, May 24 2014 @ 06:34:21 PM by Justin.

Hi i am working on a OP only room on a game i am making. to make it so only if you are in creative mode you get tpd into the room, do i basically use the same code? the coords for the space before the door is -1543 63 355. just so you can use my coords if you answer with the correct formatting. i want to tp into the room but only if in creative mode

Avatar
guest
Posted on Wednesday, August 27 2014 @ 07:20:53 AM by Mr.Slinky.

Hey, I love the blog. I've read most of your stuff. I was wondering if you could show a tutorial on how to make a vanilla command block store. I used to know how to make one and now for some reason I can't find it anywhere. All I remember is you had to have two command blocks the first saying something like xp -(number of xp levels) @p(and then the mininmum level) and then the second command block gave you the item @p(minimum level). Could you please help refresh my memory?

guest
guest
Posted on Tuesday, November 04 2014 @ 12:56:15 AM by 21stReviews.

Well, you can read more here http://minecrafters.info/overworld-survival-pack-2-75-minecraft-mini-fully-articulated-action-figure-pack-review/

guest
guest
Posted on Tuesday, November 04 2014 @ 12:08:07 PM by Doopy.

Cool stuffz

guest
guest
Posted on Tuesday, November 25 2014 @ 07:09:21 AM by guest.

last command doesn't work for me

Avatar
guest
Posted on Wednesday, December 10 2014 @ 11:09:52 AM by colby m.

how do you set coordinates for a block (like tnt) to spawn, i just can figure it out

do you have to do like

summon minecraft:TNT ~(coordinates)

or

summon minecraft: TNT ~(x) ~(y) ~(z)

or what?

Avatar
kirsle
Posted on Wednesday, December 10 2014 @ 11:25:15 AM by Noah Petherbridge.

Commands

/summon <EntityName> [x] [y] [z] [dataTag]

So to summon at a specific coordinate, say X=123, Y=80, Z=456:

/summon PrimedTnt 123 80 456

Or you can prefix any coordinate with a ~ to make it a relative coordinate (relative to the player, if you typed the command directly into chat, or relative to the command block if it was run from a command block). For example, to summon something directly above the command block, 20 blocks up:

/summon PrimedTnt ~ ~20 ~

The ~ value for X and Z means to use the exact same X/Z coordinates as the command block (or player if typed into chat), and the ~20 for Y means +20 coordinates higher than the command block/player. ~-20 would mean -20 (or, 20 blocks lower than the command block/player).

minecraft:tnt isn't an entity name, it's a block name. You can't /summon blocks. What you wanted was probably PrimedTnt which is an entity (it will be a TNT block that's already been activated and is going to explode soon). Use /setblock if you want to place blocks.

/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag]

/setblock 123 60 456 minecraft:tnt 0 replace

guest
guest
Posted on Sunday, January 25 2015 @ 09:52:39 AM by Evan.

do the commands affect ops in survival?

guest
guest
Posted on Sunday, February 15 2015 @ 08:14:58 AM by kyle.

/tellraw @a {"text":"","extra":[{"text":"Spectator.","clickEvent":{"action":"run_command","value":"/gamemode 3"}},{"text":"Adventure.","clickEvent":{"action":"run_command","value":"/gamemode 2"}},{"text":"Survival.","clickEvent":{"action":"run_command","value":"/gamemode 0"}},{"text":"Creative","clickEvent":{"action":"run_command","value":"/gamemode 1"}}]} is a command that can let u change your game mode. NOTE: this is only on 1.8

Avatar
guest
Posted on Thursday, March 05 2015 @ 07:55:30 PM by KingSupernova.

What is the purpose of having blocks below the bedrock?

Avatar
kirsle
Posted on Thursday, March 05 2015 @ 08:14:08 PM by Noah Petherbridge.

Some of the lava lakes are pretty deep and will actually "puncture" through the bedrock layer (e.g. the deepest lakes will have parts of the lava that are 4 blocks deep). The terrain generator in Minecraft spawns "structures" such as lava lakes after the first pass of terrain generation, so it overrides the bedrock from the superflat preset.

So this makes it possible to find such a lava lake and therefore find a way beneath the bedrock. I have layers of obsidian and stone down there as a sort of risky (and time consuming) reward for those who get below the bedrock, as they have a higher chance to find ores now, but being at the bottom of the world they have no room to build safe platforms.

Villages and other structures also override the bedrock rule. There was a "Nightcore" server I played on which was something along the lines of: bedrock, few layers of netherrack, some 40 layers of air, then about 11 layers of bedrock, some dirt and snow, and village generation was on. It worked out so that players would spawn on the surface (the snow) with the villages, and village wells were exactly deep enough to puncture ALL the way through the bedrock layers and allow access to the "underworld" below.

I don't remember the exact thickness of the bedrock from that preset but you could probably figure it out after checking how deep a village well goes.

Similarly, the treasure room of desert temples will puncture bedrock too.

guest
guest
Posted on Thursday, March 12 2015 @ 04:12:22 PM by meow_guy.

did you know: cat squared is banana?

guest
guest
Posted on Monday, May 04 2015 @ 05:07:23 PM by I'm not putting my name in .

What was the command

Avatar
guest
Posted on Monday, August 17 2015 @ 03:57:01 PM by DJsundae.

How do you make armour stands move

guest
guest
Posted on Thursday, November 05 2015 @ 04:46:09 AM by :))))))).

nice dudeeeeeeeee

Avatar
guest
Posted on Tuesday, December 27 2016 @ 11:03:15 AM by mark.

whats the code for the command block !!!???

Avatar
kirsle
Posted on Wednesday, December 28 2016 @ 12:35:53 PM by Noah Petherbridge.

@mark:

To give yourself a command block, you should be the server operator and run this command:

/give @p minecraft:command_block

The @p means "the closest player", which will usually be yourself. If you want to give the command block to another player, or just be very specific, use a player's name in its place, like:

/give kirsle minecraft:command_block

Add a Comment

Your name:
Your Email:
Message:
Comments can be formatted with Markdown, and you can use
emoticons in your comment.

If you can see this, don't touch the following fields.