From 6ee551c5e1ff5e33dd02a97fbc2709ce15636af0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 1 Jun 2022 21:00:54 +0100 Subject: [PATCH] Remove premature optimisation from World::getCollidingEntities() this is already covered in more fine-grained detail by canCollideWith(). [bc break] --- src/entity/Entity.php | 2 -- src/entity/object/FallingBlock.php | 2 -- src/entity/object/ItemEntity.php | 2 -- src/entity/object/PrimedTNT.php | 2 -- src/world/World.php | 8 +++----- 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 960855661..22c89934d 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -140,8 +140,6 @@ abstract class Entity{ public $lastUpdate; /** @var int */ protected $fireTicks = 0; - /** @var bool */ - public $canCollide = true; /** @var bool */ protected $isStatic = false; diff --git a/src/entity/object/FallingBlock.php b/src/entity/object/FallingBlock.php index 72aca10e0..0dd8daebb 100644 --- a/src/entity/object/FallingBlock.php +++ b/src/entity/object/FallingBlock.php @@ -49,8 +49,6 @@ class FallingBlock extends Entity{ /** @var Block */ protected $block; - public $canCollide = false; - public function __construct(Location $location, Block $block, ?CompoundTag $nbt = null){ $this->block = $block; parent::__construct($location, $nbt); diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php index df5fe4dab..14b66c7d2 100644 --- a/src/entity/object/ItemEntity.php +++ b/src/entity/object/ItemEntity.php @@ -59,8 +59,6 @@ class ItemEntity extends Entity{ /** @var Item */ protected $item; - public $canCollide = false; - /** @var int */ protected $despawnDelay = self::DEFAULT_DESPAWN_DELAY; diff --git a/src/entity/object/PrimedTNT.php b/src/entity/object/PrimedTNT.php index 3303a45db..06dbf4e16 100644 --- a/src/entity/object/PrimedTNT.php +++ b/src/entity/object/PrimedTNT.php @@ -46,8 +46,6 @@ class PrimedTNT extends Entity implements Explosive{ protected bool $worksUnderwater = false; - public $canCollide = false; - protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(0.98, 0.98); } protected function getInitialDragMultiplier() : float{ return 0.02; } diff --git a/src/world/World.php b/src/world/World.php index cd430bba4..196c2729c 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1904,11 +1904,9 @@ class World implements ChunkManager{ public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{ $nearby = []; - if($entity === null || $entity->canCollide){ - foreach($this->getNearbyEntities($bb, $entity) as $ent){ - if($ent->canBeCollidedWith() && ($entity === null || $entity->canCollideWith($ent))){ - $nearby[] = $ent; - } + foreach($this->getNearbyEntities($bb, $entity) as $ent){ + if($ent->canBeCollidedWith() && ($entity === null || $entity->canCollideWith($ent))){ + $nearby[] = $ent; } }