mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
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:
parent
2fc33d3bff
commit
e1b7bf31bb
@ -1804,7 +1804,7 @@ class World implements ChunkManager{
|
|||||||
foreach($tx->getBlocks() as [$x, $y, $z, $block]){
|
foreach($tx->getBlocks() as [$x, $y, $z, $block]){
|
||||||
$block->position($this, $x, $y, $z);
|
$block->position($this, $x, $y, $z);
|
||||||
foreach($block->getCollisionBoxes() as $collisionBox){
|
foreach($block->getCollisionBoxes() as $collisionBox){
|
||||||
if(count($this->getCollidingEntities($collisionBox)) > 0){
|
if(count($this->getNearbyEntities($collisionBox)) > 0){
|
||||||
return false; //Entity in block
|
return false; //Entity in block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1878,12 +1878,12 @@ class World implements ChunkManager{
|
|||||||
*
|
*
|
||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
*/
|
*/
|
||||||
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity) : array{
|
||||||
$nearby = [];
|
$nearby = [];
|
||||||
|
|
||||||
if($entity === null or $entity->canCollide){
|
if($entity->canCollide){
|
||||||
foreach($this->getNearbyEntities($bb, $entity) as $ent){
|
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;
|
$nearby[] = $ent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user