mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
Merge commit 'd9bbab54f4608954a8ac0fffa88c2f32c07669f1'
This commit is contained in:
commit
7762b73647
@ -827,21 +827,25 @@ abstract class Entity{
|
||||
}
|
||||
|
||||
protected function updateMovement(bool $teleport = false) : void{
|
||||
//TODO: hack for client-side AI interference: prevent client sided movement when motion is 0
|
||||
$this->setImmobile($this->motion->x == 0 and $this->motion->y == 0 and $this->motion->z == 0);
|
||||
|
||||
$diffPosition = $this->location->distanceSquared($this->lastLocation);
|
||||
$diffRotation = ($this->location->yaw - $this->lastLocation->yaw) ** 2 + ($this->location->pitch - $this->lastLocation->pitch) ** 2;
|
||||
|
||||
$diffMotion = $this->motion->subtract($this->lastMotion)->lengthSquared();
|
||||
|
||||
if($teleport or $diffPosition > 0.0001 or $diffRotation > 1.0){
|
||||
$still = $this->motion->lengthSquared() == 0.0;
|
||||
$wasStill = $this->lastMotion->lengthSquared() == 0.0;
|
||||
if($wasStill !== $still){
|
||||
//TODO: hack for client-side AI interference: prevent client sided movement when motion is 0
|
||||
$this->setImmobile($still);
|
||||
}
|
||||
|
||||
if($teleport or $diffPosition > 0.0001 or $diffRotation > 1.0 or (!$wasStill and $still)){
|
||||
$this->lastLocation = $this->location->asLocation();
|
||||
|
||||
$this->broadcastMovement($teleport);
|
||||
}
|
||||
|
||||
if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->motion->lengthSquared() <= 0.0001)){ //0.05 ** 2
|
||||
if($diffMotion > 0.0025 or $wasStill !== $still){ //0.05 ** 2
|
||||
$this->lastMotion = clone $this->motion;
|
||||
|
||||
$this->broadcastMotion();
|
||||
|
Loading…
x
Reference in New Issue
Block a user