mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-21 10:26:38 +00:00
Use squared distance on movement handling
This commit is contained in:
parent
161e7ae7ec
commit
f0d6128282
@ -1146,7 +1146,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
if(!($revert = $ev->isCancelled())){ //Yes, this is intended
|
||||
if($to->distance($ev->getTo()) > 0.1){ //If plugins modify the destination
|
||||
if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination
|
||||
$this->teleport($ev->getTo());
|
||||
}else{
|
||||
$pk = new MovePlayerPacket();
|
||||
@ -1530,7 +1530,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
if($this->forceMovement instanceof Vector3 and ($revert or $newPos->distance($this->forceMovement) > 0.2)){
|
||||
if($this->forceMovement instanceof Vector3 and ($revert or $newPos->distanceSquared($this->forceMovement) > 0.04)){
|
||||
$pk = new MovePlayerPacket();
|
||||
$pk->eid = 0;
|
||||
$pk->x = $this->forceMovement->x;
|
||||
|
@ -119,7 +119,7 @@ abstract class Projectile extends Entity{
|
||||
continue;
|
||||
}
|
||||
|
||||
$distance = $this->distance($ob->hitVector);
|
||||
$distance = $this->distanceSquared($ob->hitVector);
|
||||
|
||||
if($distance < $nearDistance){
|
||||
$nearDistance = $distance;
|
||||
|
Loading…
x
Reference in New Issue
Block a user