mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Player: check that horizontal distance travelled is > 0 before adding exhaustion, or triggering a new chunk order
closes #4548
This commit is contained in:
parent
5107d0df4e
commit
0989c77037
@ -1186,18 +1186,20 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
$this->lastLocation = $to;
|
$this->lastLocation = $to;
|
||||||
$this->broadcastMovement();
|
$this->broadcastMovement();
|
||||||
|
|
||||||
$distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2));
|
$horizontalDistanceTravelled = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2));
|
||||||
|
if($horizontalDistanceTravelled > 0){
|
||||||
//TODO: check swimming (adds 0.015 exhaustion in MCPE)
|
//TODO: check swimming (adds 0.015 exhaustion in MCPE)
|
||||||
if($this->isSprinting()){
|
if($this->isSprinting()){
|
||||||
$this->hungerManager->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);
|
$this->hungerManager->exhaust(0.1 * $horizontalDistanceTravelled, PlayerExhaustEvent::CAUSE_SPRINTING);
|
||||||
}else{
|
}else{
|
||||||
$this->hungerManager->exhaust(0.01 * $distance, PlayerExhaustEvent::CAUSE_WALKING);
|
$this->hungerManager->exhaust(0.01 * $horizontalDistanceTravelled, PlayerExhaustEvent::CAUSE_WALKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->nextChunkOrderRun > 20){
|
if($this->nextChunkOrderRun > 20){
|
||||||
$this->nextChunkOrderRun = 20;
|
$this->nextChunkOrderRun = 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($exceededRateLimit){ //client and server positions will be out of sync if this happens
|
if($exceededRateLimit){ //client and server positions will be out of sync if this happens
|
||||||
$this->logger->debug("Exceeded movement rate limit, forcing to last accepted position");
|
$this->logger->debug("Exceeded movement rate limit, forcing to last accepted position");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user