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

This reverts commit e1b7bf31bbbf8a0c679bdf238cf7594881d0842b.

fixes #4447
This commit is contained in:
Dylan K. Taylor 2021-09-10 16:06:08 +01:00
parent cf762d345d
commit 9d5a86fe53
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1836,7 +1836,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->getNearbyEntities($collisionBox)) > 0){
if(count($this->getCollidingEntities($collisionBox)) > 0){
return false; //Entity in block
}
}
@ -1910,12 +1910,12 @@ class World implements ChunkManager{
*
* @return Entity[]
*/
public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity) : array{
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
$nearby = [];
if($entity->canCollide){
if($entity === null or $entity->canCollide){
foreach($this->getNearbyEntities($bb, $entity) as $ent){
if($ent->canBeCollidedWith() and $entity->canCollideWith($ent)){
if($ent->canBeCollidedWith() and ($entity === null or $entity->canCollideWith($ent))){
$nearby[] = $ent;
}
}