From c66790b6a69da5ed2aa3bcb653f7864d2e52c93f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 28 Oct 2021 23:42:28 +0100 Subject: [PATCH] World: never delete entities in setChunk() entities exist completely independently from chunks now, so there is no need to interact with them whatsoever. As I wrote in #4520, there's no sense in deleting entities here, since a chunk replacement is essentially just a mass block update. On that theme, it might be a good idea to call Entity->onNearbyBlockChange() for all entities in the target and adjacent chunks when replacing a chunk, to ensure that they get the proper movement updates. --- src/world/World.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/world/World.php b/src/world/World.php index 148363254..ae3837b06 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -2125,18 +2125,13 @@ class World implements ChunkManager{ } /** - * @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one + * @param bool $deleteTiles Whether to delete tiles on the old chunk, or transfer them to the new one */ - public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk, bool $deleteEntitiesAndTiles = true) : void{ + public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk, bool $deleteTiles = true) : void{ $chunkHash = World::chunkHash($chunkX, $chunkZ); $oldChunk = $this->loadChunk($chunkX, $chunkZ); if($oldChunk !== null and $oldChunk !== $chunk){ - if($deleteEntitiesAndTiles){ - foreach($this->getChunkEntities($chunkX, $chunkZ) as $entity){ - if(!($entity instanceof Player)){ - $entity->close(); - } - } + if($deleteTiles){ foreach($oldChunk->getTiles() as $tile){ $tile->close(); }