mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 02:21:46 +00:00
Improved suboptimal code in Player::handleMovement()
This commit is contained in:
parent
c26631d06d
commit
608c6ed6db
@ -1180,7 +1180,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldPos = $this->getLocation();
|
$oldPos = $this->location;
|
||||||
$distanceSquared = $newPos->distanceSquared($oldPos);
|
$distanceSquared = $newPos->distanceSquared($oldPos);
|
||||||
|
|
||||||
$revert = false;
|
$revert = false;
|
||||||
@ -1198,7 +1198,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
* asking for help if you suffer the consequences of messing with this.
|
* asking for help if you suffer the consequences of messing with this.
|
||||||
*/
|
*/
|
||||||
$this->logger->debug("Moved too fast, reverting movement");
|
$this->logger->debug("Moved too fast, reverting movement");
|
||||||
$this->logger->debug("Old position: " . $this->location->asVector3() . ", new position: " . $newPos);
|
$this->logger->debug("Old position: " . $oldPos->asVector3() . ", new position: " . $newPos);
|
||||||
$revert = true;
|
$revert = true;
|
||||||
}elseif(!$this->getWorld()->isInLoadedTerrain($newPos)){
|
}elseif(!$this->getWorld()->isInLoadedTerrain($newPos)){
|
||||||
$revert = true;
|
$revert = true;
|
||||||
@ -1206,9 +1206,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$revert && $distanceSquared != 0){
|
if(!$revert && $distanceSquared != 0){
|
||||||
$dx = $newPos->x - $this->location->x;
|
$dx = $newPos->x - $oldPos->x;
|
||||||
$dy = $newPos->y - $this->location->y;
|
$dy = $newPos->y - $oldPos->y;
|
||||||
$dz = $newPos->z - $this->location->z;
|
$dz = $newPos->z - $oldPos->z;
|
||||||
|
|
||||||
$this->move($dx, $dy, $dz);
|
$this->move($dx, $dy, $dz);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user