2

Check if a player is outside of the world border

ICrashedAServer's Avatar ICrashedAServer3/6/22 1:17 am
2 emeralds 312 1
3/11/2022 3:00 am
sigstop's Avatar sigstop
One of the other plugins I use on the server sets a custom spawn, and it often does that outside of the world border (which is at 100 something for us right now). I am looking to code a datapack that teleports the player to world spawn if they are outside the world border. Can someone tell me how I would go about doing that? Thanks
Posted by ICrashedAServer's Avatar
ICrashedAServer
Level 44 : Master Modder
43

Create an account or sign in to comment.

1

1
03/11/2022 3:00 am
Level 2 : Apprentice Miner
sigstop
sigstop's Avatar
If you are not ever going to change world border size and position, you could just use some @a[dx=1000,dy=500,dz=1000] executed from smallest xyz corner of world. You would just have to every tick assign players a tag outside_border, then remove this tag for all players selected by previous selector, tp all with outside_border to spawn, and then remove outside_border tag.

tag @a give outside_border
execute positioned -100 -100 -100 run tag @a[dx=200,dy=400,dz=200] remove outside_border
teleport @a[tag=outside_border] 1000 2 4444444
tag @a remove outside_border

However I advice you to not combine plugins with normal commands, as normal commands are not suited for complex thingies that plugins can do.

Alternatively you can optimize given commands by negating check for tag, and removing tag taking command

execute positioned -100 -100 -100 run tag @a[dx=200,dy=400,dz=200] remove inside_border
teleport @a[tag=!inside_border] 1000 2 4444444
tag @a remove inside_border
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome