mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 23:45:34 +00:00
Improved player onGround collision check
This commit is contained in:
parent
456760b334
commit
20e11bd408
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user