Player: removed redundant isFirst check for movement

Since the addition of resetLastMovements(), this code is useless.

Additionally, it doesn't make sense to ignore the first movement, because the first movement still _moves the player_ from point A to point B.
This commit is contained in:
Dylan K. Taylor 2018-03-24 10:40:30 +00:00
parent 9a099d3f5d
commit 611f5d684b

View File

@ -1594,9 +1594,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch); $deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch);
if(!$revert and ($delta > 0.0001 or $deltaAngle > 1.0)){ if(!$revert and ($delta > 0.0001 or $deltaAngle > 1.0)){
$isFirst = ($this->lastX === null or $this->lastY === null or $this->lastZ === null);
$this->lastX = $to->x; $this->lastX = $to->x;
$this->lastY = $to->y; $this->lastY = $to->y;
$this->lastZ = $to->z; $this->lastZ = $to->z;
@ -1604,24 +1601,22 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->lastYaw = $to->yaw; $this->lastYaw = $to->yaw;
$this->lastPitch = $to->pitch; $this->lastPitch = $to->pitch;
if(!$isFirst){ $ev = new PlayerMoveEvent($this, $from, $to);
$ev = new PlayerMoveEvent($this, $from, $to);
$this->server->getPluginManager()->callEvent($ev); $this->server->getPluginManager()->callEvent($ev);
if(!($revert = $ev->isCancelled())){ //Yes, this is intended if(!($revert = $ev->isCancelled())){ //Yes, this is intended
if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination
$this->teleport($ev->getTo()); $this->teleport($ev->getTo());
}else{
$this->broadcastMovement();
$distance = $from->distance($to);
//TODO: check swimming (adds 0.015 exhaustion in MCPE)
if($this->isSprinting()){
$this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);
}else{ }else{
$this->broadcastMovement(); $this->exhaust(0.01 * $distance, PlayerExhaustEvent::CAUSE_WALKING);
$distance = $from->distance($to);
//TODO: check swimming (adds 0.015 exhaustion in MCPE)
if($this->isSprinting()){
$this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);
}else{
$this->exhaust(0.01 * $distance, PlayerExhaustEvent::CAUSE_WALKING);
}
} }
} }
} }