From 8d4decc548d01b8992cfdcc0015c59dcff3defc5 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 28 May 2015 23:58:29 +0200 Subject: [PATCH] Fixed bad vector initialization --- src/pocketmine/entity/Entity.php | 2 +- src/pocketmine/level/Level.php | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 527de1920..0923942f3 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1291,7 +1291,7 @@ abstract class Entity extends Location implements Metadatable{ $maxY = Math::ceilFloat($this->boundingBox->maxY - 0.001); $maxZ = Math::ceilFloat($this->boundingBox->maxZ - 0.001); - $vector = $this->temporalVector; + $vector = new Vector3(0, 0, 0); $v = new Vector3(0, 0, 0); for($v->z = $minZ; $v->z <= $maxZ; ++$v->z){ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 662f6203d..8dd8961b6 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2042,18 +2042,28 @@ class Level implements ChunkManager, Metadatable{ return; } $index = Level::chunkHash($chunkX, $chunkZ); - if($unload){ - if($this->isChunkLoaded($chunkX, $chunkZ) and ($oldChunk = $this->getChunk($chunkX, $chunkZ, false)) !== false){ - foreach($this->getChunkLoaders($chunkX, $chunkZ) as $loader){ - $loader->onChunkUnloaded($oldChunk); - } - } + $oldChunk = $this->getChunk($chunkX, $chunkZ, false); + if($unload and $oldChunk !== null){ + $this->unloadChunk($chunkX, $chunkZ, false); $this->provider->setChunk($chunkX, $chunkZ, $chunk); $this->chunks[$index] = $chunk; }else{ + $oldEntities = $oldChunk !== null ? $oldChunk->getEntities() : []; + $oldTiles = $oldChunk !== null ? $oldChunk->getTiles() : []; + $this->provider->setChunk($chunkX, $chunkZ, $chunk); $this->chunks[$index] = $chunk; + + foreach($oldEntities as $entity){ + $chunk->addEntity($entity); + $entity->chunk = $chunk; + } + + foreach($oldTiles as $tile){ + $chunk->addTile($tile); + $tile->chunk = $chunk; + } } unset($this->chunkCache[$index]);