I've been playing Minecraft for a long time, and one thing i've always wanted to be able to do was make teleports. ever since i found Single Player Commands, actually. it had this nifty code you could use to teleport to specific locations, and even name them so you didnt have to remember a bunch of numbers. it was convenient! but it was also a mod, and didnt work on servers. Then, Minecraft added the function themselves! you could teleport via code to any location, even other players.

But... you couldn't save waypoints. and while typing in a player's name was easy, remembering where you parked your house was not... further, you had to have the ability to use server commands. ie, be in creative mode, or an OP. This meant that if you played on a survival world, or if you ran a server where players where survival, they could not teleport around. sometimes a good thing! but often inconvenient.

Does this mean that we crafters are unable to zip around at a whim? nay! For one more addition was brought to Minecraft. Command Blocks! command blocks are a surprisingly unknown device to many who've never dabbled with them, but they are powerful and incredibly useful. The idea is that it's a block that will execute a line of code once, when it receives a redstone signal. lever, button, even a redstone torch. combining this with redstone circuits allows you to create automatic dispensers, mob killers, mob spawners, Time settings, gamemode changes, change the very rules of the game, such as if explosions destroy things or not...and my favorite, teleport the player to a location!

a word of caution if you're a server operator. these things can be dangerous. only an op can use them, but if you get an op with something up their- ahem. if you choose to activate these on your server, be sure your ops are trusted! they can even be used to revoke YOUR op rights. (though nothing can trump direct control over the server program itself.)

so let's talk about the setup shall we?

Step 1: Getting Ready for Instant Transmission.

so, the things you'll need!

  • a command block. these are so powerful that you cannot even get these from the creative mode window. the /only/ way to get one is to spawn one in using console commands. use this code:

    /give player minecraft:command_block , where player is the player you wish to give it to's name, and amount is the amount. so '/give notch minecraft:command_block 1' gives the player notch 1 command block. you can also forgo a name, and it will give the item to you.

  • a location to teleport to! this is expressed in a Vector, a three number variable (X,Y,Z). you can find the location you want to teleport to by going there and pressing F3 on your keyboard, which brings up a statistics window, including your location. copy down the three numbers (decimal places dont matter) and hit f3 again to make it go away
  • you'll also need some way to trigger the block. the best methods are those that reset. buttons, pressure plates, and tripwires all work well. however, even levers and redstone torches work. i'll be using a pressure plate

right, ready? got a place you want to go? are you playing on a server world? then you missed something!

servers have command blocks disabled by default as a protection against devious ops! you'll have to go into your server properties file and change the enable-command-block setting to 'true'!

right then! we're ready for warp speed!

Step 2: The Setup!

actually USING a command block is honestly, cake. first slap one down, then you can use your sneak command (default to shift) to place the plate on top of the command block. tada!

of course... it's not very subtle. you can see the wooden outline around the command block if you bury it in with your floor. how do you fix this? using some basic redstone logic. whenever a button or a lever or a pressure plate or what-have-you is activated, the block it is mounted to becomes energized. this means that it passes power to any block it's touching. you can, then, use a block of anything, pretty much, to activate a command block!

there are unfortunately a lack of stealthy pressure plates in the game, since there are only four total. but at least you can keep your floor material a little more unmarred...

Step 3: It's All in the Numbers.

you might be wondering what now? well now, you have to program your command block. dont worry, it's not that hard! all codes in minecraft are short little burbs, with fill in the blanks. easy peasy!

for command blocks, you'll want this:

/tp [target player] x=X y=Y z=Z y-rot=YROT x-rot=XROT

i'll just copy some bits from the official minecraft commands wiki to explain this bit.

Arguments target player (optional) Specifies the targets to be teleported. Must be either a player name or a target selector (@e is permitted to target entities other than players). If not specified, defaults to the command's user. Not optional in command blocks.

destination player Specifies the targets to teleport the target player to. Must be either a player name or a target selector (@e is permitted to target entities other than players).

x y z Specifies the coordinates to teleport the targets to. x and z must fall within the range -30,000,000 to 30,000,000 (exclusive, without the commas), and y must be at least 0. May use tilde notation to specify a position relative to the target's current position.

y-rot (optional) Specifies the horizontal rotation (-180.0 for due north, -90.0 for due east, 0.0 for due south, 90.0 for due west, to 179.9 for just west of north, before wrapping back around to -180.0). Tilde notation can be used to specify a rotation relative to the target's previous rotation.

x-rot (optional) Specifies the vertical rotation (-90.0 for straight up to 90.0 for straight down). Tilde notation can be used to specify a rotation relative to the target's previous rotation.

still confused? figures. why is reading explanations about code always so formal and stuffy? alright, in plain english!

your variables are 'target player' 'location' and 'rotation'. rotation is completely optional. if left out the player will be facing the direction they where when they tp'd. location is that value we dug up earlier when we where gathering supplies. it would be put in the code like so '50 93 -2001'. you CAN say x=50 y=93 z=-2001, but it's not necessary here. as for target player, that one has some special rules. you CAN make it work with a player's name, but then the teleporter only works for the named player! that's not any good, right? if this is to be a community teleporter, there's got to be a better way. and there is!

in minecraft commands there's things called 'target selectors' which are broad 'types'. the one we're interested in is '@p' which means 'the nearest player'. this will plug the nearest player's name into the code, which will always be the player who stepped on the plate, unless someone's mining under your command block.

so, let's grab that location and plug it in! in my case, the code is /tp @p 813 11 -405

see? simple. ^.^

Step 4: Flaws.....

what's this? that horse just stepped on your trigger plate and sent you whisking across the sky? yeah that happens sometimes. i suppose you'll just have to deal with sudden impromptu vacations so long as your portal is operational.

kidding! before i explain how to fix this, let's talk about why it's happened. our code, "

/tp @p 813 11 -405" says this. "when the command block receives a signal, teleport the nearest player to this destination". what this means is that if the block is randomly triggered by a passing hoofed non-player entity (or /any/ entity... including items if those work for your particular plate.) the game finds the nearest player to the block, and teleports them to the landing zone, even if that player is two thousand blocks away. (which is technically impossible, because if the nearest player is 2000 blocks away, then the plate and the command block are not being rendered, and cant be triggered in the first place :P)

we could try changing the target selector to @e, which makes it select every entity in the code, including players, cows, creepers, unruly horses with steppy hooves, and arrows. yes arrows. they're entities too!

this means that the trigger-er gets targeted... but it means that you do too! progress this is not... well, we can restrict the selector to a certain number. maybe that will fix this mess.

"/tp @e[c=1] 813 11 -405"

well, this does indeed fix the problem! now only the naughty horse gets teleported! but ... erm... did you really want to dump a pony in your mages' study?

what to do now.... we need it to teleport players, but we cant use the count argument, because @p already selects only the closest. what we need is some way to shorten the teleporter's reach so it's not yanking you out of your obsidian bathtub.

this is where the radius argument comes in handy! this tells the block to only pull results from within a set distance. perfect, right? our code now looks like this:

"/tp @p[r=2] 813 11 -415

we set the radius to two because the command block wont be able to detect you at a radius of 1 if you've chosen to hide it underground. now only the closest player will get teleported to the location, and it will only work if a player triggered it, or was very very close when it was triggered.

welp looks like that's all, i hope yo- wait. why's there a next button down there? there's MORE? D:

Step 5: Tick Tock Tick Tock

"but wait!" you say, "if you can just tell it to pick a radius, why the pressure plate? cant we just trigger the portal over and over, and walk into the range?"

you would be correct! at this point, pressure plates are superfluous because their only real function was localizing the portal. which we did with code. so you could get rid of it, if you could trigger the block some other way.

with a clock circuit, for instance. this is a simple (or deviously complex) bit of redstone wiring that creates a never ending, equally spaced pulse. this can be used to make flashing lights, to trigger dispensers full of arrows, or in our case, trigger the block to check for people to teleport over and over.

the simplest clock i've ever seen was two repeaters (set to the same wait period) feeding each other end to end, with a line leading off one of the ends to power your dohickies. you may have tried just this, and found it incredibly frustrating, because it should work but it just doesn't! the trick, however, is setting it off. usually one would slap a redstone torch or a lever or something next to this and hope it turns on. and it does. but it stays on, and doesn't pulse. this DOES mean you have recreated a redstone torch! infinite power. six times the space requirements. efficiency!

to turn your clock on, you need to build a simple setup next to it. find a block touching, but not under, the redstone wire used to connect the two repeaters. now move another block away and dig. one more, so you've a channel dug out that's pointed towards your clock circuit. now, place a piece of dust in the hole closest to your circuit, and a redstone torch in the other. what you've just done is power a block next to your circuit. the final piece to this puzzle is one last torch, placed on your powered block. the torch will shoot your clock full of power before being snuffed out by the block underneath.

if everything goes to plan, your clock should be pumping along at a crazy pace (speed can be adjusted with the four tick controls of the repeaters, allowing almost a full second of waiting at it's longest setting. you can extend this with extra paired repeaters!)

all that's left is to connect this source to your command block, and boldly step into the new, invisible, teleport area.

Step 6: Now Where Did I Put That Portal....

aha! now what could be better than that eh? i think that cove- what? still not good enough? alright, alright. i still have some tricks i can show. well, tell about. this instruct able is proving to be rather picture less eh? :P

ok, so you've got your portal, you've made it automatic, it's completely silent. but now you have a huge (comparatively) circuit and a block that requires the floor be three blocks thick to hide the command block if you're using this on a second story room.

how about a way to move the portal away from the block. can we do that? yep!

easy as another vector, you can tell the command block to check for the nearest player from a specific point. and best of all, the radius argument still works with it! effectively the portal has been moved whole hog to another location, which can be anywhere in render distance. (it CAN be further, but it wont do anything if it's not loaded into the game, now will it? :P)

the new code looks like this:

/tp @p[x=790,y=4,z=-587,r=2] 813 11 405

an important note! you cannot CANNOT have spaces inside the arguments [ ] box. it fails every time without explaining why. which is quite frustrating!

edit: i realized i should have specified, remote teleportions like this only work if the command block is in a loaded chunk. either it has to be close to the world spawn, which is always loaded (http://www.minecraftforum.net/forums/mapping-and-modding/maps/1537579-function-1-8-perma-loaded-spawn-chunks-void-world), or you must have the block within render distance of the player. (they dont necessarily have to be able to see it, the game just has to load it.)

Step 7: You Can Do MORE With Portals? O..O

but, you cry, 'i dont want my portal to be round! i made this really awesome dirt portal door, but if when i went and changed your code so that the radius was bigger, people get poofed before they even go THROUGH it! T-T!!"

alright, we can fix that. you can also define portals by volume instead of radius. this means you can select any square shape as your poofin' area. but keep in mind, the volume arguments are additions to your portal's location! this means you can never use negative arguments. the portal's location will always have the lowest numbers. (this is important, especially, if you're not changing the location of the portal in code. because that means your command block has to be at this lowest vector location. so, if your two points are 400, 4, 80, and 400,10, 85, the commandblock/co-ordinates have to be 400,4,80, and the volume argument has to be how much more from that point it is. (i always put at least a 1, if it's zero) so, the volume for those points would be 'dx=1,dy=6,dz=5'

the code without numbers looks like this now:

/tp @p[x=X,y=Y,z=Z,dx=DX,dy=DY,dz=DZ] X Y Z

ok, so i've built a super amazing dirt portal! what code should i use....

/tp @p[x=762,y=4,z=-586,dx=4,dy=5,dz=1] 813 11 -405

tada! you now have a flat portal. or a cube portal, if you choose! and you can even move it away from command blocks like the step before this. notice that we no longer have an r= radius argument. this is because radius and volume are two different kinds of the same thing, and dont work together.

Step 8: It's Mine, Not Yours!

well, ok, how about restricting it's use to a someone who has the key? you dont want just ANYONE to sneak into your secret lab!!

we can do this too! this requires a different setup, however. you're going to need two command blocks! go to your clock circuit, and add a new tool called a 'comparator' leading away from the command block. a comparator is like a repeater, but it does some math with redstone. however, with commandblocks, it outputs a signal if the comandblock succeeds. stick another on the other end and you're set. . and copy your teleport code over to the new block. you're also going to need a dragon egg! why a dragon egg? because it's an item that very few players can get their hands on, and this means that they cant cheat. the system we're going to put in place checks for an item type, and it's name. so if you used a mythical golden hoe of 'superkey', players could just go and get a hoe and rename it on an anvil, and have their very own key. (though they'd still have to guess what the key's name is. XP)

now we could use a new code, called 'testfor'. this is an incredibly complicated, and powerful, bit of code. it's complicated because unlike most of the commands in minecraft, it has a LOT of things you can plug into it. but... despite being made for just this, it doesn't seem to actually WORK. i mean, it does, obviously, but i cant figure it out, and finding documentation is difficult. luckily there's a much simpler code we can use! /clear. in the past, clear would remove an item (or everything..) from a player's inventory, which isnt what we want... (unless you want a ticket system! in this case, change the second zero to however many tickets you want use to cost). however, now you can set the number of objects to clear away to 0, and it will just check for the item named in the player's inventory.

/clear @p[x=762,y=4,z=-586,dx=4,dy=5,dz=1] dragon_egg 0 0 {display:{Name:"Stargate Code"}}

now, go and rename your dragon_egg to 'Stargate Code', and step into the void. poof!

Step 9: Devious Diversions

what else is there that you can do with this? well, you could make a portal system that takes you to multiple places dependent on the key you hold, with the same portal. or you could make people pay items to use the portal system. or even experience. or you could make a mob grinder that teleports all the mob drops above a waiting hopper.

how about a portal that teleports you to your destination, but anyone else who tries to use it gets teleported to a waiting dungeon?

this is actually pretty easy! it just needs a rework of our last system! what we're going to do, is make the portal teleport everyone to the dungeon. and then we'll make a second teleporter and have that one disable the first if it detects the proper key, using comparators.

first set up a portal as we did earlier, and have it point at your dungeon. you want the first command block to have a command that can fail, otherwise the comparator will stay on forever, and wont trigger a teleport. the simplest solution is to have this command block use a testfor command to see if there's any player inside your portal.

/tp @p[x=762,y=4,z=-586,dx=4,dy=5,dz=1]

stick a comparator out a side, and then pipe it to another comparator, and then finally hook that to another command block. this block will hold your /tp code. make sure to use the same parameters as your testfor code or else something screwy could happen, like getting teleported when you're not inside the portal, or the portal being smaller than the check radius.

the second set of cubes, make another teleport system. this one will be identical to the one we made last step. with one addition. add another comparator to another side of the first command block in this system, and pipe its output into the side of the second comparator of the first set. this will make it so that when the two teleport circuits execute (at the same time, since they're running on the same clock) the second circuit will disable the first if it's requirements are met (having the correct key in your inventory!)

Step 10: The Boundless World of Portals! (.. Is Yours to Figure Out..)

well, i think that should give you a good grasp on how to teleport everywhere. there's tons of things you could do with these, and different ways to use them, including things i've not discussed yet. but by now you've probably played around with them yourself, and discovered the fun of making new code combos. so i'm going to let YOU create the next one.

hope that you had fun and learned something too!

as a final help, i've loaded the save world i used to make this tutorial, so you can go in and look at things if you need to.

<p>Or you could do /give (and than press tab and ur name appears) command tab! try it! it works. If you dont get it, leave a comment!</p>
<p>i dont know</p>
<p>yea </p>
<p>they have updated some the commands so in order to get a command block you type /give [player_name] minecraft:command_block</p>
<p>it is soooooooooo coooooooooooooooooooolllllllllllll!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
you can use the /testfor like thus e.g type /tesfor xXhydra_Xx in a comnand block add a comparitor facing out of it tgan add a repeter going towards the tp cmd block and it will test for the player xXhydra_Xx and tp him in other words me
<p>What i was thinking was putting tripwires hitched to command blocks that have the /tp @p command, but then again its hard to place string cause its so unpredictable when you try to hitch it... still, buncha words, buncha bigger ideas :D (btw that supposed to be compliment if u dont understand... :P) </p>
That was the best ible I've ever read! It was not lacking in anything in the least! Great job. Spammed the vote button for ya. ;p
<p>thank you. ^.^ i hope i didnt leave anything lacking...</p>
<p>i did indeed.... edited step six to show that the command block must be 'loaded' to function. </p>
uhhhhh there no portals but the ender nether and over world...:-D
<p>lol. well, what is a portal but a doorway that takes you somewhere else? sure, you cant SEE it, but it still takes you from one place to another. and with proper building, you could certainly make it LOOK like it'd taken you somewhere entirely diferent, like the nether or the end....:P</p>

About This Instructable




Bio: i'm a maker at heart. which means inside i want to make things but outside i'm too lazy. :P. i am an ameture ... More »
More by badideasrus:Hoberman Sphere MineCraft Portals! (with no mods!) 
Add instructable to: