From 385c8a1bc073fa4c2a4152b23641932378d69642 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 31 Aug 2023 04:09:08 +0300 Subject: [PATCH] fixes from npe 0.9 test --- src/Player.php | 13 ++++++++++--- src/entity/Entity.php | 4 ++-- src/network/protocol/packet/MovePlayerPacket.php | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Player.php b/src/Player.php index d9c14a5d..bbb39358 100755 --- a/src/Player.php +++ b/src/Player.php @@ -470,7 +470,7 @@ class Player{ } } } - $this->stopUsingChunk($X, $Z); //just in case + //$this->stopUsingChunk($X, $Z); //just in case $pk = new FullChunkDataPacket; $pk->chunkX = $X; $pk->chunkZ = $Z; @@ -480,13 +480,16 @@ class Player{ return false; } } - + public $chunkTicker = 0; public function entityTick(){ //ConsoleAPI::debug("{$this->username}, cl: ".count($this->chunksLoaded).", oc: ".count($this->chunksOrder)); if(count($this->chunksOrder) <= 0 && $this->level->generatorType != 0){ $this->orderChunks(); } - $this->getNextChunk($this->level); + if($this->chunkTicker++ > 5){ + $this->getNextChunk($this->level); + $this->chunkTicker = 0; + } } public function getNextChunk($world){ @@ -1533,6 +1536,7 @@ class Player{ $this->spawned = true; $this->server->handle("player.spawn", $this); $this->server->api->chat->broadcast($this->username." joined the game"); + //console("Current position: {$this->entity}"); $this->server->api->player->spawnAllPlayers($this); $this->server->api->player->spawnToAllPlayers($this); } @@ -1543,15 +1547,18 @@ class Player{ if($this->forceMovement->distance($newPos) <= 0.7){ $this->forceMovement = false; }else{ + //console("force"); $this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false); } } $speed = $this->entity->getSpeedMeasure(); if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){ if($this->lastCorrect instanceof Vector3){ + //console("last"); $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); } }else{ + //console("New Pos: $newPos"); $this->entity->setPosition($newPos, $packet->yaw, $packet->pitch); } $this->entity->updateAABB(); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index c8e0b93b..6d930601 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -766,12 +766,12 @@ class Entity extends Position $this->updateLast(); $players = $this->server->api->player->getAll($this->level); if($this->player instanceof Player){ - console("gujnbguib"); + //console("gujnbguib"); unset($players[$this->player->CID]); $pk = new MovePlayerPacket(); $pk->eid = $this->eid; $pk->x = $this->x; - $pk->y = $this->y + $this->getEyeHeight(); + $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; diff --git a/src/network/protocol/packet/MovePlayerPacket.php b/src/network/protocol/packet/MovePlayerPacket.php index 6b3d361d..45c8229c 100644 --- a/src/network/protocol/packet/MovePlayerPacket.php +++ b/src/network/protocol/packet/MovePlayerPacket.php @@ -19,8 +19,8 @@ class MovePlayerPacket extends RakNetDataPacket{ $this->y = $this->getFloat(); $this->z = $this->getFloat(); $this->yaw = $this->getFloat(); - $this->bodyYaw = $this->getFloat(); $this->pitch = $this->getFloat(); + $this->bodyYaw = $this->getFloat(); $this->teleport = ($this->getByte() & 0x80) > 0; } @@ -36,4 +36,4 @@ class MovePlayerPacket extends RakNetDataPacket{ $this->putByte($this->teleport ? 0x80 : 0x00); } -} \ No newline at end of file +}