mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
Fixed players not calculating onGround correctly
This commit is contained in:
parent
3128ae9736
commit
5fffabe05b
@ -1103,17 +1103,25 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
|
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
|
||||||
|
|
||||||
if(!$revert and !$this->isSleeping() and $this->isSurvival()){
|
if($this->isSurvival()){
|
||||||
if($diff > 0.0625){
|
if(!$revert and !$this->isSleeping()){
|
||||||
$revert = true;
|
if($diff > 0.0625){
|
||||||
//$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
$revert = true;
|
||||||
}elseif($diff > 0){
|
$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
||||||
$this->x = $this->newPosition->x;
|
}elseif($diff > 0){
|
||||||
$this->y = $this->newPosition->y;
|
$this->x = $this->newPosition->x;
|
||||||
$this->z = $this->newPosition->z;
|
$this->y = $this->newPosition->y;
|
||||||
$radius = $this->width / 2;
|
$this->z = $this->newPosition->z;
|
||||||
$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);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,18 +931,13 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
|
|
||||||
$this->boundingBox->setBB($axisalignedbb);
|
$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){
|
foreach($list as $bb){
|
||||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->boundingBox->offset(0, $dy, 0);
|
$this->boundingBox->offset(0, $dy, 0);
|
||||||
if($movY != $dy){
|
|
||||||
$dx = 0;
|
|
||||||
$dy = 0;
|
|
||||||
$dz = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($list as $bb){
|
foreach($list as $bb){
|
||||||
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
||||||
@ -966,7 +961,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
$dz = 0;
|
$dz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($movY != $dy){
|
if($dy == 0){
|
||||||
$dx = 0;
|
$dx = 0;
|
||||||
$dy = 0;
|
$dy = 0;
|
||||||
$dz = 0;
|
$dz = 0;
|
||||||
@ -1009,7 +1004,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
if($this instanceof Player){
|
if($this instanceof Player){
|
||||||
if(!$this->onGround or $movY != 0){
|
if(!$this->onGround or $movY != 0){
|
||||||
$bb = clone $this->boundingBox;
|
$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){
|
if(count($this->level->getCollisionBlocks($bb->expand(0.01, 0.01, 0.01))) > 0){
|
||||||
$this->onGround = true;
|
$this->onGround = true;
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user