mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
fixed swimming + some entity movement tweaks
This commit is contained in:
parent
af36fb318a
commit
2342e1e783
4 changed files with 17 additions and 8 deletions
|
|
@ -22,6 +22,7 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
||||||
public function harm($dmg, $cause = "generic", $force = false){
|
public function harm($dmg, $cause = "generic", $force = false){
|
||||||
$ret = parent::harm($dmg, $cause, $force);
|
$ret = parent::harm($dmg, $cause, $force);
|
||||||
$this->inPanic |= ($ret && is_numeric($cause));
|
$this->inPanic |= ($ret && is_numeric($cause));
|
||||||
|
$this->inLove = false;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ abstract class Creature extends Living{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpeedModifer(){
|
public function getSpeedModifer(){
|
||||||
return $this->speedModifer * ($this->inPanic ? 1.0 : 0.7);
|
return $this->speedModifer * ($this->inPanic ? 1.5 : 1.0);
|
||||||
}
|
}
|
||||||
public function getArmorValue(){
|
public function getArmorValue(){
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
||||||
|
|
@ -497,6 +497,7 @@ class Entity extends Position
|
||||||
$this->lastUpdate = $now;
|
$this->lastUpdate = $now;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tdiff = $now - $this->lastUpdate;
|
$tdiff = $now - $this->lastUpdate;
|
||||||
if($this->tickCounter === 0){
|
if($this->tickCounter === 0){
|
||||||
$this->tickCounter = 1;
|
$this->tickCounter = 1;
|
||||||
|
|
@ -583,7 +584,7 @@ class Entity extends Position
|
||||||
for($z = $z0; $z < $z1; ++$z){
|
for($z = $z0; $z < $z1; ++$z){
|
||||||
$pos = new Vector3($x, $y, $z);
|
$pos = new Vector3($x, $y, $z);
|
||||||
$b = $this->level->getBlock($pos);
|
$b = $this->level->getBlock($pos);
|
||||||
if(($b->y == ($y1 - 1) && $b->getID() === WATER) || $b->getID() === STILL_WATER){
|
if($b->y == ($y1 - 1) && ($b->getID() === WATER || $b->getID() === STILL_WATER)){
|
||||||
$water = true;
|
$water = true;
|
||||||
}
|
}
|
||||||
if($b != false && $b->isSolid){
|
if($b != false && $b->isSolid){
|
||||||
|
|
@ -607,6 +608,16 @@ class Entity extends Position
|
||||||
$horizontalMultiplyFactor = $b->slipperiness * 0.91;
|
$horizontalMultiplyFactor = $b->slipperiness * 0.91;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->inWater){
|
||||||
|
$this->speedX *= 0.8;
|
||||||
|
$this->speedY *= 0.8;
|
||||||
|
$this->speedZ *= 0.8;
|
||||||
|
}else{
|
||||||
|
$this->speedX *= $horizontalMultiplyFactor;
|
||||||
|
$this->speedY *= 0.98;
|
||||||
|
$this->speedZ *= $horizontalMultiplyFactor;
|
||||||
|
}
|
||||||
if($this->speedX != 0){
|
if($this->speedX != 0){
|
||||||
$this->x += $this->speedX;
|
$this->x += $this->speedX;
|
||||||
$update = true;
|
$update = true;
|
||||||
|
|
@ -645,7 +656,7 @@ class Entity extends Position
|
||||||
$this->onGround = $support;
|
$this->onGround = $support;
|
||||||
|
|
||||||
if($this->hasGravity){
|
if($this->hasGravity){
|
||||||
$this->speedY -= $this->gravity; // TODO: replace with $gravity
|
$this->speedY -= $this->inWater ? 0.02 : $this->gravity; // TODO: replace with $gravity
|
||||||
$update = true;
|
$update = true;
|
||||||
} elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
} elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
||||||
// $this->speedX = 0;
|
// $this->speedX = 0;
|
||||||
|
|
@ -663,9 +674,6 @@ class Entity extends Position
|
||||||
$this->server->api->handle("entity.motion", $this);
|
$this->server->api->handle("entity.motion", $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->speedX *= $horizontalMultiplyFactor;
|
|
||||||
$this->speedY *= 0.98;
|
|
||||||
$this->speedZ *= $horizontalMultiplyFactor;
|
|
||||||
} elseif($this->player instanceof Player){
|
} elseif($this->player instanceof Player){
|
||||||
if($isFlying === true and ($this->player->gamemode & 0x01) === 0x00){
|
if($isFlying === true and ($this->player->gamemode & 0x01) === 0x00){
|
||||||
if($this->fallY === false or $this->fallStart === false){
|
if($this->fallY === false or $this->fallStart === false){
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class TaskPanic extends TaskBase
|
||||||
protected $randX = 2, $randZ = 2;
|
protected $randX = 2, $randZ = 2;
|
||||||
public function onStart(EntityAI $ai)
|
public function onStart(EntityAI $ai)
|
||||||
{
|
{
|
||||||
$this->selfCounter = mt_rand(60, 120);
|
$this->selfCounter = 60;
|
||||||
$this->regenerateRandXZ();
|
$this->regenerateRandXZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue