mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
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:
parent
054c06fab9
commit
419962d3a2
@ -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);
|
||||
|
@ -148,6 +148,8 @@ abstract class Timings{
|
||||
/** @var TimingsHandler */
|
||||
public static $broadcastPackets;
|
||||
|
||||
public static TimingsHandler $playerMove;
|
||||
|
||||
public static function init() : void{
|
||||
if(self::$initialized){
|
||||
return;
|
||||
@ -175,6 +177,7 @@ abstract class Timings{
|
||||
|
||||
self::$broadcastPackets = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Broadcast Packets", self::$playerNetworkSend);
|
||||
|
||||
self::$playerMove = new TimingsHandler("Player Movement");
|
||||
self::$playerChunkOrder = new TimingsHandler("Player Order Chunks");
|
||||
self::$playerChunkSend = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Chunks", self::$playerNetworkSend);
|
||||
self::$scheduler = new TimingsHandler("Scheduler");
|
||||
|
Loading…
x
Reference in New Issue
Block a user