From 05dbf7b47f87222ec2bcd9c2a9eb678f77c45b17 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 4 Jun 2015 15:46:57 +0200 Subject: [PATCH] Fixed some corrupted states, probably fixed most invisible players cases --- src/pocketmine/Player.php | 2 +- src/pocketmine/entity/Entity.php | 7 +++---- src/pocketmine/level/Level.php | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 0c2c297d5..6a426a71c 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1750,7 +1750,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); } - $this->teleportPosition = $this->getPosition(); + $this->forceMovement = $this->teleportPosition = $this->getPosition(); $this->orderChunks(); $this->sendNextChunk(); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index a91476b3c..08744c5c6 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1334,16 +1334,15 @@ abstract class Entity extends Location implements Metadatable{ if($this->chunk !== null){ $this->chunk->removeEntity($this); } - $this->level->loadChunk($this->x >> 4, $this->z >> 4); $this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true); if(!$this->justCreated){ $newChunk = $this->level->getChunkPlayers($this->x >> 4, $this->z >> 4); foreach($this->hasSpawned as $player){ - if(!isset($newChunk[$player->getId()])){ + if(!isset($newChunk[$player->getLoaderId()])){ $this->despawnFrom($player); }else{ - unset($newChunk[$player->getId()]); + unset($newChunk[$player->getLoaderId()]); } } foreach($newChunk as $player){ @@ -1473,7 +1472,7 @@ abstract class Entity extends Location implements Metadatable{ return; } foreach($this->level->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){ - if($player->loggedIn === true){ + if($player->isOnline()){ $this->spawnTo($player); } } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f4df36a49..7b93a3ce2 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1716,9 +1716,9 @@ class Level implements ChunkManager, Metadatable{ $nearby = []; $minX = Math::floorFloat(($bb->minX - 2) / 16); - $maxX = Math::ceilFloat(($bb->maxX + 2) / 16 + 1); + $maxX = Math::ceilFloat(($bb->maxX + 2) / 16); $minZ = Math::floorFloat(($bb->minZ - 2) / 16); - $maxZ = Math::ceilFloat(($bb->maxZ + 2) / 16 + 1); + $maxZ = Math::ceilFloat(($bb->maxZ + 2) / 16); for($x = $minX; $x <= $maxX; ++$x){ for($z = $minZ; $z <= $maxZ; ++$z){