From 2e9b2d4aae470021457846d78eda025e2ec702cb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 Nov 2020 17:41:58 +0000 Subject: [PATCH] World: fixed false unload events firing on chunk replacement when tiles and entities are deleted --- src/world/World.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/world/World.php b/src/world/World.php index 4ac97246f..cc9ff5bc3 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -2023,16 +2023,18 @@ class World implements ChunkManager{ $oldChunk = $this->getOrLoadChunk($chunkX, $chunkZ, false); if($oldChunk !== null and $oldChunk !== $chunk){ if($deleteEntitiesAndTiles){ - foreach($oldChunk->getEntities() as $player){ - if(!($player instanceof Player)){ - continue; + foreach($oldChunk->getEntities() as $entity){ + if($entity instanceof Player){ + $chunk->addEntity($entity); + $oldChunk->removeEntity($entity); + $entity->chunk = $chunk; + }else{ + $entity->close(); } - $chunk->addEntity($player); - $oldChunk->removeEntity($player); - $player->chunk = $chunk; } - //TODO: this causes chunkloaders to receive false "unloaded" notifications - $this->unloadChunk($chunkX, $chunkZ, false, false); + foreach($oldChunk->getTiles() as $tile){ + $tile->close(); + } }else{ foreach($oldChunk->getEntities() as $entity){ $chunk->addEntity($entity);