swimming tweaks, fall damage tweaks

This commit is contained in:
GameHerobrine 2023-02-23 20:07:02 +03:00
parent 6b68b88572
commit db8b221c02
5 changed files with 34 additions and 4 deletions

View file

@ -9,11 +9,21 @@ class MobController
public $finalYaw, $finalPitch, $finalHeadYaw;
protected $jumping;
protected $jumpTimeout;
public function __construct($e){
$this->entity = $e;
}
public function isJumping(){
return $this->jumping;
}
public function setJumping($b){
$this->jumping = $b;
}
public function moveNonInstant($x, $y, $z){
if($x == 0 && $y == 0 && $z == 0){
return false;
@ -47,6 +57,15 @@ class MobController
return true;
}
public function movementTick(){
if($this->isJumping() && $this->jumpTimeout <= 0){
$this->jumpTimeout = 10;
$this->entity->speedY = 0.42;
}
if($this->jumpTimeout > 0) --$this->jumpTimeout;
}
public function rotateTick(){ //TODO handle more rotation
$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
$w180min = min(abs($w180), 20)*Utils::getSign($w180);

View file

@ -16,10 +16,12 @@ class TaskSwimming extends TaskBase
{
if(!$ai->entity->inWater){
$this->reset();
$ai->mobController->setJumping(false);
return;
}
if(Utils::randomFloat() < 0.8){ #1.5.2 method
$ai->entity->speedY = 0.42;
$ai->mobController->setJumping(true);
}