diff --git a/src/Player.php b/src/Player.php index 88913782..b24ca053 100755 --- a/src/Player.php +++ b/src/Player.php @@ -160,9 +160,9 @@ class Player{ return false; } - foreach($this->server->api->entity->getAll($this->level) as $e){ + foreach($this->level->entities as $e){ if($e !== $this->entity){ - if($e->player instanceof Player){ + if($e->isPlayer()){ $pk = new MoveEntityPacket_PosRot; $pk->eid = $this->entity->eid; $pk->x = -256; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index e5bfa456..4ac442ac 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -71,7 +71,7 @@ class Entity extends Position public $radius; public $inAction = false; public $hasKnockback; - + public $hasJumped; public $onGround, $inWater; function __construct(Level $level, $eid, $class, $type = 0, $data = array()) diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index 70eff8eb..6b673809 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -6,7 +6,6 @@ class MobController * @var Entity */ public $entity; - public function __construct($e){ $this->entity = $e; } @@ -19,6 +18,23 @@ class MobController $ox = ($x > 0 ? 1 : ($x < 0 ? -1 : 0)); $oy = ($y > 0 ? 1 : ($y < 0 ? -1 : 0)); $oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0)); + $xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed()); + $zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed()); + $bs = [ //TODO simplify(somehow) + $this->entity->level->getBlockWithoutVector(ceil($xf), $this->entity->y, ceil($zf)), + $this->entity->level->getBlockWithoutVector(ceil($xf), $this->entity->y, $zf), + $this->entity->level->getBlockWithoutVector($xf, $this->entity->y, ceil($zf)), + $this->entity->level->getBlockWithoutVector($xf, $this->entity->y, $zf) + ]; + foreach($bs as $b){ + if($b->isSolid){ + if(!$this->entity->level->getBlock($b->getSide(1))->isSolid){ + $oy = 1; + break; + } + } + } + $this->entity->moveEntityWithOffset($ox, $oy, $oz); $this->faceEntity($this->entity->add($ox, $oy, $oz)); return true;