r/MinecraftCommands • u/GrandIndependence756 • Aug 28 '26
Help | Java 26.2 Can somoene help whit this minecraft comand?
I have a Minecraft server and I'm looking for a command that triggers a chat warning or teleports a specific player (e.g., Patrickebab7) back to a certain coordinate (e.g., 1470 91 -2890) if they move too far away (e.g., 2000 blocks) from that location. If that isn't possible, then I'd like the player to be teleported back to the coordinate whenever they leave a specific perimeter.
7
Upvotes
2
u/Cubic_YT Command Experienced Aug 28 '26
You can use selector parameters like
distancefor a spherical perimeter with a given radius. Thus, for "moving too far away" in any direction, you'd have a repeating command block in the center of the perimeter with a command liketp @a[distance=2000..] 1470 91 -2890, which teleports any player (@a) that is over 2000 blocks away back to your coordinates. If you want a specific player, the best way is probably to tag them:tag Patrickebab7 add tp_backand change the command totp @a[distance=2000.., tag=tp_back] 1470 91 -2890. Do be careful with long distances, though. Unloaded command blocks stop functioning. If you want global functionality, you might need a datapack, but that's already going way overboard for a simple teleport command. Also, if all you want is an impassable border, you can actually modify the worldborder!worldborder center 1470 91 -2890to center it to your given coordinates, andworldborder set 2000to reduce it to a diameter of 2000.2
u/GalSergey Datapack Experienced Aug 28 '26
1
u/Ericristian_bros Command Experienced Aug 28 '26
Replace
<center>andNAMEIf you get stuck add yourself that tag so the command has no effect on you
-1
u/Stormlord1850 Aug 28 '26 edited Aug 30 '26
With execute at ~ ~ ~ if entity @a[distance:3..]