changed min speed to 1/8000 (setentitymotion packet limit)

This commit is contained in:
GameHerobrine 2023-11-23 10:24:37 +03:00
parent c7167f3137
commit 0a31a1e3c9
2 changed files with 7 additions and 7 deletions

View file

@ -48,7 +48,7 @@ class EntityAPI{
} }
if(is_int($args[0])) $type = $args[0]; if(is_int($args[0])) $type = $args[0];
else $type = $mob[strtolower($args[0])]; else $type = $mob[strtolower($args[0])] ?? 0;
if($type < 10 || $type > 36){ if($type < 10 || $type > 36){
return "Unknown mob."; return "Unknown mob.";
} }

View file

@ -5,7 +5,7 @@ class Entity extends Position
const TYPE = - 1; const TYPE = - 1;
const CLASS_TYPE = - 1; const CLASS_TYPE = - 1;
const MIN_POSSIBLE_SPEED = 1/8000; //anything below will send 0 to player
public $counter = 0; public $counter = 0;
public $fallDistance = 0; public $fallDistance = 0;
public static $updateOnTick, $allowedAI; public static $updateOnTick, $allowedAI;
@ -192,11 +192,11 @@ class Entity extends Position
public function isMovingHorizontally() public function isMovingHorizontally()
{ {
return ($this->speedX > 0.01 || $this->speedX < - 0.01) || ($this->speedZ > 0.01 || $this->speedZ < - 0.01); return ($this->speedX >= self::MIN_POSSIBLE_SPEED || $this->speedX <= -self::MIN_POSSIBLE_SPEED) || ($this->speedZ >= self::MIN_POSSIBLE_SPEED || $this->speedZ <= -self::MIN_POSSIBLE_SPEED);
} }
public function isMoving() public function isMoving()
{ {
return $this->isMovingHorizontally() || ($this->speedY > 0.007 || $this->speedY < - 0.007); return $this->isMovingHorizontally() || ($this->speedY > self::MIN_POSSIBLE_SPEED || $this->speedY < -self::MIN_POSSIBLE_SPEED);
} }
public function setVelocity($vX, $vY = 0, $vZ = 0) public function setVelocity($vX, $vY = 0, $vZ = 0)
@ -536,13 +536,13 @@ class Entity extends Position
if(!$this->isPlayer()){ if(!$this->isPlayer()){
$this->updateLast(); $this->updateLast();
$update = false; $update = false;
if($this->speedX >= -0.001 && $this->speedX <= 0.001){ if($this->speedX > -self::MIN_POSSIBLE_SPEED && $this->speedX < self::MIN_POSSIBLE_SPEED){
$this->speedX = 0; $this->speedX = 0;
} }
if($this->speedZ >= -0.001 && $this->speedZ <= 0.001){ if($this->speedZ > -self::MIN_POSSIBLE_SPEED && $this->speedZ < self::MIN_POSSIBLE_SPEED){
$this->speedZ = 0; $this->speedZ = 0;
} }
if($this->speedY >= -0.001 && $this->speedY <= 0.001){ if($this->speedY > -self::MIN_POSSIBLE_SPEED && $this->speedY < self::MIN_POSSIBLE_SPEED){
$this->speedY = 0; $this->speedY = 0;
} }