Remove premature optimisation from World::getCollidingEntities()

this is already covered in more fine-grained detail by canCollideWith().

[bc break]
This commit is contained in:
Dylan K. Taylor 2022-06-01 21:00:54 +01:00
parent b7e2b3e94a
commit 6ee551c5e1
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
5 changed files with 3 additions and 13 deletions

View File

@ -140,8 +140,6 @@ abstract class Entity{
public $lastUpdate;
/** @var int */
protected $fireTicks = 0;
/** @var bool */
public $canCollide = true;
/** @var bool */
protected $isStatic = false;

View File

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

View File

@ -59,8 +59,6 @@ class ItemEntity extends Entity{
/** @var Item */
protected $item;
public $canCollide = false;
/** @var int */
protected $despawnDelay = self::DEFAULT_DESPAWN_DELAY;

View File

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

View File

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