From db3305cb1604de547b98951bc467f07b71979db5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 17 Jun 2019 16:39:46 +0100 Subject: [PATCH] Remove Entity->isClosed() checks from places where they don't make sense in all of these cases, this is just potentially concealing bugs. Closed entities should never appear at these points. --- src/pocketmine/Player.php | 2 +- src/pocketmine/world/World.php | 3 ++- src/pocketmine/world/format/Chunk.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 76fa81d6c..a6f1af679 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -894,7 +894,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void{ foreach($this->world->getChunkEntities($chunkX, $chunkZ) as $entity){ - if($entity !== $this and !$entity->isClosed() and !$entity->isFlaggedForDespawn()){ + if($entity !== $this and !$entity->isFlaggedForDespawn()){ $entity->spawnTo($this); } } diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index 4dd4088a2..4b9d57e7c 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -46,6 +46,7 @@ use pocketmine\event\world\ChunkPopulateEvent; use pocketmine\event\world\ChunkUnloadEvent; use pocketmine\event\world\SpawnChangeEvent; use pocketmine\event\world\WorldSaveEvent; +use pocketmine\GameMode; use pocketmine\item\Item; use pocketmine\item\ItemFactory; use pocketmine\item\ItemUseResult; @@ -1958,7 +1959,7 @@ class World implements ChunkManager, Metadatable{ for($x = $minX; $x <= $maxX; ++$x){ for($z = $minZ; $z <= $maxZ; ++$z){ foreach($this->getChunkEntities($x, $z) as $entity){ - if(!($entity instanceof $entityType) or $entity->isClosed() or $entity->isFlaggedForDespawn() or (!$includeDead and !$entity->isAlive())){ + if(!($entity instanceof $entityType) or $entity->isFlaggedForDespawn() or (!$includeDead and !$entity->isAlive())){ continue; } $distSq = $entity->distanceSquared($pos); diff --git a/src/pocketmine/world/format/Chunk.php b/src/pocketmine/world/format/Chunk.php index 4a88fd261..e6906a6c1 100644 --- a/src/pocketmine/world/format/Chunk.php +++ b/src/pocketmine/world/format/Chunk.php @@ -505,7 +505,7 @@ class Chunk{ * @return Entity[] */ public function getSavableEntities() : array{ - return array_filter($this->entities, function(Entity $entity) : bool{ return $entity->canSaveWithChunk() and !$entity->isClosed(); }); + return array_filter($this->entities, function(Entity $entity) : bool{ return $entity->canSaveWithChunk(); }); } /**