knockback tweaks

This commit is contained in:
GameHerobrine 2023-01-23 00:45:01 +03:00
parent b8589c9dd4
commit b6ce6e459c
2 changed files with 12 additions and 5 deletions

View file

@ -11,7 +11,7 @@ class Entity extends Position
public static $updateOnTick, $allowedAI; public static $updateOnTick, $allowedAI;
public $isCollidable; public $isCollidable;
public $canBeAttacked; public $canBeAttacked;
public $moveTime, $lookTime, $idleTime; public $moveTime, $lookTime, $idleTime, $knockbackTime = 0;
public $needsUpdate; public $needsUpdate;
public $speedModifer; public $speedModifer;
public $hasGravity; public $hasGravity;
@ -749,6 +749,10 @@ class Entity extends Position
} }
} }
} }
if($this->knockbackTime > 0){
--$this->knockbackTime;
}
if($this->moveTime > 0){ if($this->moveTime > 0){
-- $this->moveTime; -- $this->moveTime;
} }
@ -1272,9 +1276,9 @@ class Entity extends Position
for ($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (Utils::randomFloat() - Utils::randomFloat()) * 0.01) { for ($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (Utils::randomFloat() - Utils::randomFloat()) * 0.01) {
$d = (Utils::randomFloat() - Utils::randomFloat()) * 0.01; $d = (Utils::randomFloat() - Utils::randomFloat()) * 0.01;
} }
// attackedAtYaw = (float)((Math.atan2($d1, $d) * 180D) / 3.1415927410125732D) > // attackedAtYaw = (float)((Math.atan2($d1, $d) * 180D) / 3.1415927410125732D) >
$this->knockBack($d, $d1); $this->knockBack($d, $d1);
$this->knockbackTime = 10;
$this->sendMotion(); $this->sendMotion();
} }
@ -1342,9 +1346,9 @@ class Entity extends Position
public function moveEntityWithOffset($oX, $oY, $oZ) public function moveEntityWithOffset($oX, $oY, $oZ)
{ {
$oX = $oX === 0 ? $this->speedX : $this->getSpeedModifer() * $oX * $this->getSpeed(); $oX = $oX === 0 ? $this->speedX : ($this->getSpeedModifer() * $oX * $this->getSpeed());
$oY = $oY <= 0 ? $this->speedY : (0.5); $oY = $oY <= 0 ? $this->speedY : (0.5);
$oZ = $oZ === 0 ? $this->speedZ : $this->getSpeedModifer() * $oZ * $this->getSpeed(); $oZ = $oZ === 0 ? $this->speedZ : ($this->getSpeedModifer() * $oZ * $this->getSpeed());
$this->setVelocity($oX, $oY, $oZ); $this->setVelocity($oX, $oY, $oZ);
} }

View file

@ -34,8 +34,11 @@ class MobController
} }
} }
} }
if($this->entity->knockbackTime <= 0){
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
}
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
$this->faceEntity($this->entity->add($ox, $oy, $oz)); $this->faceEntity($this->entity->add($ox, $oy, $oz));
return true; return true;
} }