From 5fffabe05b5aa9307d50fe3b82eea5c6dbf33eb7 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 2 Jan 2015 01:22:33 +0100 Subject: [PATCH] Fixed players not calculating onGround correctly --- src/pocketmine/Player.php | 28 ++++++++++++++++++---------- src/pocketmine/entity/Entity.php | 11 +++-------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 404c57be7af..88ad82499c5 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1103,17 +1103,25 @@ protected function processMovement($currentTick){ $diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2; - if(!$revert and !$this->isSleeping() and $this->isSurvival()){ - if($diff > 0.0625){ - $revert = true; - //$this->server->getLogger()->warning($this->getName()." moved wrongly!"); - }elseif($diff > 0){ - $this->x = $this->newPosition->x; - $this->y = $this->newPosition->y; - $this->z = $this->newPosition->z; - $radius = $this->width / 2; - $this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius); + if($this->isSurvival()){ + if(!$revert and !$this->isSleeping()){ + if($diff > 0.0625){ + $revert = true; + $this->server->getLogger()->warning($this->getName()." moved wrongly!"); + }elseif($diff > 0){ + $this->x = $this->newPosition->x; + $this->y = $this->newPosition->y; + $this->z = $this->newPosition->z; + $radius = $this->width / 2; + $this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius); + } } + }elseif($diff > 0){ + $this->x = $this->newPosition->x; + $this->y = $this->newPosition->y; + $this->z = $this->newPosition->z; + $radius = $this->width / 2; + $this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index d089ebeb949..f50b496a805 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -931,18 +931,13 @@ public function move($dx, $dy, $dz){ $this->boundingBox->setBB($axisalignedbb); - $list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($movX, $dy, $movZ), false); + $list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz), false); foreach($list as $bb){ $dy = $bb->calculateYOffset($this->boundingBox, $dy); } $this->boundingBox->offset(0, $dy, 0); - if($movY != $dy){ - $dx = 0; - $dy = 0; - $dz = 0; - } foreach($list as $bb){ $dx = $bb->calculateXOffset($this->boundingBox, $dx); @@ -966,7 +961,7 @@ public function move($dx, $dy, $dz){ $dz = 0; } - if($movY != $dy){ + if($dy == 0){ $dx = 0; $dy = 0; $dz = 0; @@ -1009,7 +1004,7 @@ public function move($dx, $dy, $dz){ if($this instanceof Player){ if(!$this->onGround or $movY != 0){ $bb = clone $this->boundingBox; - $bb->maxY = $bb->minY + 1; + $bb->minY -= 1; if(count($this->level->getCollisionBlocks($bb->expand(0.01, 0.01, 0.01))) > 0){ $this->onGround = true; }else{