diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 243466864..03e14ad42 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1601,10 +1601,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $dy = $newPos->y - $this->y; $dz = $newPos->z - $this->z; + //the client likes to clip into blocks like stairs, but we do full server-side prediction of that without + //help from the client's position changes, so we deduct the expected clip height from the moved distance. + $expectedClipDistance = $this->ySize * (1 - self::STEP_CLIP_MULTIPLIER); + $dy -= $expectedClipDistance; $this->move($dx, $dy, $dz); $diff = $this->distanceSquared($newPos); + //TODO: Explore lowering this threshold now that stairs work properly. if($this->isSurvival() and $diff > 0.0625){ $ev = new PlayerIllegalMoveEvent($this, $newPos, new Vector3($this->lastX, $this->lastY, $this->lastZ)); $ev->setCancelled($this->allowMovementCheats); @@ -1614,7 +1619,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if(!$ev->isCancelled()){ $revert = true; $this->server->getLogger()->debug($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()])); - $this->server->getLogger()->debug("Old position: " . $this->asVector3() . ", new position: " . $newPos); + $this->server->getLogger()->debug("Old position: " . $this->asVector3() . ", new position: " . $newPos . ", expected clip distance: $expectedClipDistance"); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 1eca4b6ae..4ba1c369c 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -94,6 +94,7 @@ use const M_PI_2; abstract class Entity extends Location implements Metadatable, EntityIds{ public const MOTION_THRESHOLD = 0.00001; + protected const STEP_CLIP_MULTIPLIER = 0.4; public const NETWORK_ID = -1; @@ -1538,7 +1539,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ if($this->keepMovement){ $this->boundingBox->offset($dx, $dy, $dz); }else{ - $this->ySize *= 0.4; + $this->ySize *= self::STEP_CLIP_MULTIPLIER; /* if($this->isColliding){ //With cobweb? @@ -1605,7 +1606,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->boundingBox->offset(0, 0, $dz); - if($this->stepHeight > 0 and $fallingFlag and $this->ySize < 0.05 and ($movX != $dx or $movZ != $dz)){ + if($this->stepHeight > 0 and $fallingFlag and ($movX != $dx or $movZ != $dz)){ $cx = $dx; $cy = $dy; $cz = $dz;