World: make the second parameter for getCollidingEntities() mandatory and non-nullable

the only reason to use getCollidingEntities() instead of getNearbyEntities() is if you have an entity that may or may not be collidable depending on certain conditions.
Really, I don't think this logic belongs in World at all, but for now it has to stay, because some other stuff depends on it.
This commit is contained in:
Dylan K. Taylor 2021-09-05 15:22:12 +01:00
parent 2fc33d3bff
commit e1b7bf31bb
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1804,7 +1804,7 @@ class World implements ChunkManager{
foreach($tx->getBlocks() as [$x, $y, $z, $block]){
$block->position($this, $x, $y, $z);
foreach($block->getCollisionBoxes() as $collisionBox){
if(count($this->getCollidingEntities($collisionBox)) > 0){
if(count($this->getNearbyEntities($collisionBox)) > 0){
return false; //Entity in block
}
}
@ -1878,12 +1878,12 @@ class World implements ChunkManager{
*
* @return Entity[]
*/
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity) : array{
$nearby = [];
if($entity === null or $entity->canCollide){
if($entity->canCollide){
foreach($this->getNearbyEntities($bb, $entity) as $ent){
if($ent->canBeCollidedWith() and ($entity === null or $entity->canCollideWith($ent))){
if($ent->canBeCollidedWith() and $entity->canCollideWith($ent)){
$nearby[] = $ent;
}
}