I want to make a forcefield kind of that blocks anyone from getting in if they do not have permission>> PHP: onPlayerMoveEvent$x = $player->getX();$y = $player->getY();$z = $player->getZ();if($player->hasPermission("Forfild"){if(($x > 120) && ($y > 50) && ($z > 150)){// push player like 2 block far}}
you can do set canceled but i prefer something like knocking back from directional vector i think it has been done before i read it somewhere but cant remember it off my heads you can also just knock player + x then +z till they are out of it irrelevant to stopping players reaching that point
See how WorldGuard does it, but it's not an ideal solution. https://github.com/Muqsit/WorldGuard/blob/rewrite/src/worldguard/EventListener.php#L43-#L52
Something like this should work. PHP: $force = 3.5;$d = $e->getTo()->subtract($e->getFrom())->normalize()->multiply($force);$player->knockback($player, 0, $d->x, $d->z);