From 0cfc1e95873195924da405d6fa94e0862bdb4c2d Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Thu, 9 May 2024 19:39:49 +0300 Subject: [PATCH] fixed a rare warning in console --- src/entity/Entity.php | 4 ++++ src/entity/Living.php | 9 +++++++-- src/entity/object/Minecart.php | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index f35ad749..17e15d6b 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -219,6 +219,10 @@ class Entity extends Position $this->speedZ += $vZ; } + public function isPushable(){ + return false; + } + public function applyCollision(Entity $collided){ if(!($this->isPlayer() && $collided->isPlayer()) && $this->eid != $collided->eid){ $diffX = $collided->x - $this->x; diff --git a/src/entity/Living.php b/src/entity/Living.php index e4cc7f10..48ac144a 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -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); } } diff --git a/src/entity/object/Minecart.php b/src/entity/object/Minecart.php index 8fc8156c..97ae7e26 100644 --- a/src/entity/object/Minecart.php +++ b/src/entity/object/Minecart.php @@ -78,6 +78,10 @@ class Minecart extends Vehicle{ ]; } + public function isPushable(){ + return false; //TODO replace with true + } + public function spawn($player){ $pk = new AddEntityPacket; $pk->eid = $this->eid;