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.
This commit is contained in:
Dylan K. Taylor 2019-06-17 16:39:46 +01:00
parent 92e81e3298
commit db3305cb16
3 changed files with 4 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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(); });
}
/**