Reduced deltas for player movement, significantly smoother player movement and rotation (#883)

Send movement to viewers if the player moved more than 0.01 blocks in a tick or rotated more than 1 degree in any direction.
This commit is contained in:
Dylan K. Taylor 2017-05-05 11:23:06 +01:00 committed by GitHub
parent 11f35d28c2
commit 76ceddf266

View File

@ -1544,7 +1544,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$delta = pow($this->lastX - $to->x, 2) + pow($this->lastY - $to->y, 2) + pow($this->lastZ - $to->z, 2);
$deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch);
if(!$revert and ($delta > (1 / 16) or $deltaAngle > 10)){
if(!$revert and ($delta > 0.0001 or $deltaAngle > 1.0)){
$isFirst = ($this->lastX === null or $this->lastY === null or $this->lastZ === null);
@ -1567,7 +1567,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->level->addEntityMovement($this->x >> 4, $this->z >> 4, $this->getId(), $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw);
$distance = $from->distance($to);
//TODO: check swimming (adds 0.015 exhaustion in MCPE)
if($this->isSprinting()){
$this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);