fixed a rare warning in console

This commit is contained in:
GameHerobrine 2024-05-09 19:39:49 +03:00
parent eb8a11739a
commit 0cfc1e9587
3 changed files with 15 additions and 2 deletions

View file

@ -80,6 +80,11 @@ abstract class Living extends Entity implements Pathfindable{
public function canBeShot(){
return true;
}
public function isPushable(){
return !$this->dead;
}
public function collideHandler(){
$bb = $this->boundingBox->expand(0.2, 0, 0.2);
$minChunkX = ((int)($bb->minX)) >> 4;
@ -92,8 +97,8 @@ abstract class Living extends Entity implements Pathfindable{
for($chunkZ = $minChunkZ; $chunkZ <= $maxChunkZ; ++$chunkZ){
$ind = "$chunkX $chunkZ";
foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){
if($this->level->entityList[$entid] instanceof Entity){
if($bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){
if(($this->level->entityList[$entid] ?? null) instanceof Entity){
if($this->level->entityList[$entid]->isPushable() && $bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){
$this->level->entityList[$entid]->applyCollision($this);
}
}