Ejemplo n.º 1
0
 public function distance($x = 0, $y = 0, $z = 0)
 {
     if ($x instanceof Position and $x->level !== $this->level) {
         return PHP_INT_MAX;
     }
     return parent::distance($x, $y, $z);
 }
 public function PlayerInteractHandler($data, $event)
 {
     if (!isset($data["target"])) {
         return false;
     }
     $target = $this->api->entity->get($data["target"]);
     if (!isset($target)) {
         return false;
     }
     $t = new Vector3($target->x, $target->y, $target->z);
     $s = new Vector3($this->server->spawn->x, $this->server->spawn->y, $this->server->spawn->z);
     $distance = $t->distance($s);
     if ($distance <= $this->server->api->getProperty("spawn-protection")) {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 public function CheckNearby()
 {
     $py = $this->api->player->online();
     $copy = $py;
     if (count($py) > 1) {
         //at least 2 players in server
         for ($i = 0; $i < count($py); $i++) {
             if ($i == count($py) - 1) {
                 break;
             }
             $p1 = $this->api->player->get($py[$i]);
             array_shift($copy);
             //remove the $p1 from the second array
             for ($e = 0; $e < count($copy); $e++) {
                 $p2 = $this->api->player->get($copy[$e]);
                 $p1vec = new Vector3($p1->entity->x, $p1->entity->y, $p1->entity->z);
                 $p2vec = new Vector3($p2->entity->x, $p2->entity->y, $p2->entity->z);
                 $range = round($p1vec->distance($p2vec));
                 //the number of blocks away from each other
                 $this->FindNearbyPlayers($p1->username, $p2->username);
                 $this->FindNearbyPlayers($p2->username, $p1->username);
                 //guys, my mind messed up here, help me see if im dong the correc tthings here -Junyi00
             }
         }
         $copy = $py;
     }
 }