From 20e11bd40811cf7bc1c018539752c630b1178a3b Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Aug 2014 15:48:12 +0200 Subject: [PATCH] Improved player onGround collision check --- src/pocketmine/Player.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6d2cab176..e23518bc0 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1332,13 +1332,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $dy = $newPos->y - $this->y; - if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){ - $isColliding = true; - }else{ - $isColliding = false; + if(($this->onGround and $dy > 0) or (!$this->onGround and $dy <= 0)){ + if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){ + $isColliding = true; + }else{ + $isColliding = false; + } + + $this->onGround = ($dy <= 0 and $isColliding); } - $this->onGround = ($dy <= 0 and $isColliding); $this->updateFallState($dy, $this->onGround); if(!$this->setPositionAndRotation($newPos, $packet->yaw, $packet->pitch)){ @@ -1350,6 +1353,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->bodyYaw = $this->yaw; $pk->pitch = $this->pitch; $pk->yaw = $this->yaw; + $pk->teleport = true; $this->directDataPacket($pk); }