Fixed some corrupted states, probably fixed most invisible players cases

This commit is contained in:
Shoghi Cervantes 2015-06-04 15:46:57 +02:00
parent 14ff537e71
commit 05dbf7b47f
3 changed files with 6 additions and 7 deletions

View File

@ -1750,7 +1750,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
} }
$this->teleportPosition = $this->getPosition(); $this->forceMovement = $this->teleportPosition = $this->getPosition();
$this->orderChunks(); $this->orderChunks();
$this->sendNextChunk(); $this->sendNextChunk();

View File

@ -1334,16 +1334,15 @@ abstract class Entity extends Location implements Metadatable{
if($this->chunk !== null){ if($this->chunk !== null){
$this->chunk->removeEntity($this); $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); $this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true);
if(!$this->justCreated){ if(!$this->justCreated){
$newChunk = $this->level->getChunkPlayers($this->x >> 4, $this->z >> 4); $newChunk = $this->level->getChunkPlayers($this->x >> 4, $this->z >> 4);
foreach($this->hasSpawned as $player){ foreach($this->hasSpawned as $player){
if(!isset($newChunk[$player->getId()])){ if(!isset($newChunk[$player->getLoaderId()])){
$this->despawnFrom($player); $this->despawnFrom($player);
}else{ }else{
unset($newChunk[$player->getId()]); unset($newChunk[$player->getLoaderId()]);
} }
} }
foreach($newChunk as $player){ foreach($newChunk as $player){
@ -1473,7 +1472,7 @@ abstract class Entity extends Location implements Metadatable{
return; return;
} }
foreach($this->level->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){ foreach($this->level->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){
if($player->loggedIn === true){ if($player->isOnline()){
$this->spawnTo($player); $this->spawnTo($player);
} }
} }

View File

@ -1716,9 +1716,9 @@ class Level implements ChunkManager, Metadatable{
$nearby = []; $nearby = [];
$minX = Math::floorFloat(($bb->minX - 2) / 16); $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); $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($x = $minX; $x <= $maxX; ++$x){
for($z = $minZ; $z <= $maxZ; ++$z){ for($z = $minZ; $z <= $maxZ; ++$z){