Improved player onGround collision check

This commit is contained in:
Shoghi Cervantes 2014-08-25 15:48:12 +02:00
parent 456760b334
commit 20e11bd408

View File

@ -1332,13 +1332,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$dy = $newPos->y - $this->y; $dy = $newPos->y - $this->y;
if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){ if(($this->onGround and $dy > 0) or (!$this->onGround and $dy <= 0)){
$isColliding = true; if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){
}else{ $isColliding = true;
$isColliding = false; }else{
$isColliding = false;
}
$this->onGround = ($dy <= 0 and $isColliding);
} }
$this->onGround = ($dy <= 0 and $isColliding);
$this->updateFallState($dy, $this->onGround); $this->updateFallState($dy, $this->onGround);
if(!$this->setPositionAndRotation($newPos, $packet->yaw, $packet->pitch)){ 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->bodyYaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->teleport = true;
$this->directDataPacket($pk); $this->directDataPacket($pk);
} }