Added timer for player-specific movement code

players use an entirely different pathway for movement processing, which could be costly.
This commit is contained in:
Dylan K. Taylor
2023-03-19 16:12:47 +00:00
parent 054c06fab9
commit 419962d3a2
2 changed files with 14 additions and 0 deletions

View File

@ -1212,6 +1212,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
* @param Vector3 $newPos Coordinates of the player's feet, centered horizontally at the base of their bounding box.
*/
public function handleMovement(Vector3 $newPos) : void{
Timings::$playerMove->startTiming();
try{
$this->actuallyHandleMovement($newPos);
}finally{
Timings::$playerMove->stopTiming();
}
}
private function actuallyHandleMovement(Vector3 $newPos) : void{
$this->moveRateLimit--;
if($this->moveRateLimit < 0){
return;
@ -1365,6 +1374,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->timings->startTiming();
if($this->spawned){
Timings::$playerMove->startTiming();
$this->processMostRecentMovements();
$this->motion = new Vector3(0, 0, 0); //TODO: HACK! (Fixes player knockback being messed up)
if($this->onGround){
@ -1372,6 +1382,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
}else{
$this->inAirTicks += $tickDiff;
}
Timings::$playerMove->stopTiming();
Timings::$entityBaseTick->startTiming();
$this->entityBaseTick($tickDiff);