TransWikia.com

Tp command block proximity

Arqade Asked by Kittenonsmack on December 8, 2020

I’m trying to make a portal hub to head N,S,E,W directions and a portal back again from each point back to world spawn near the hub.

My first portal keeps teleporting and I cant get near it without commandblocksenabled false. I’ve approached from afar and realised its teleporting me from a good 20 blocks away. It’s meant to only work if I stand on the designated coordinates.
I’ve got
Testfor @p[x=#,y=#,z=#,r=1] (repeat, unconditional, always active)
and above that
Tp @p x y z (chain, unconditional, always active)

Annoyingly this is exactly as I’ve copied from online and works fine for them.

2 Answers

Your /tp command block should be conditional. Right now, it's just tp'ing the nearest player whenever the block is loaded.

Answered by AMJ on December 8, 2020

One way to do this would be to set the block to repeat, always active, and unconditional. Then, you could type the following command:

/tp @a[x={x coord},y={y coord},z={z coord},r={radius}] {x target} {y target} {z target}

The coordinates in the brackets are the coordinates you wish to teleport the player from, while the target coords are where you wish to teleport the player to. The radius is how far away the player can be before they are teleported. This should always be at least 2, but can be larger if necessary. Note that this will also include space above and below the target, which is why it must be at least 2.

Also, make sure you use proper spacing, and do not include the curly brackets { } in the command.

This works very well, but having a repeating command block that is always active can cause some lag, and can flood the chat, so dont go crazy with the teleporters. Also, this particular command can sometimes be a little bit buggy, especially if you have it in an unloaded chunk and then suddenly load the chunk, so it may be a good idea to either keep a player in that chunk at all times, use a ticking area (which I have not actually figured out how to work, so, no help there), or have a chunk loader of some sort.

This command will automatically teleport any player who gets within r blocks of the intended teleport point. Alternatively, you could use @e instead of @a, if your intention is to teleport all entities instead of all players.

You could also set it up to send a message to the player being teleported, either before or after the teleportation. I can explain this in more detail later, if you would like.

Please be aware that this command may have a slight delay between teleports, because the command block is unable to teleport multiple times per second. However, it can teleport multiple players at once. You can also set it to have a delay before activating, but that's a little more complex and would likely cause a great deal of lag.

Answered by ZachTalonGamesYT on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP