mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
swimming tweaks, fall damage tweaks
This commit is contained in:
parent
6b68b88572
commit
db8b221c02
5 changed files with 34 additions and 4 deletions
|
|
@ -568,6 +568,10 @@ class Entity extends Position
|
||||||
$y1 = ceil($aABB->maxY);
|
$y1 = ceil($aABB->maxY);
|
||||||
$z0 = floor($aABB->minZ);
|
$z0 = floor($aABB->minZ);
|
||||||
$z1 = ceil($aABB->maxZ);
|
$z1 = ceil($aABB->maxZ);
|
||||||
|
|
||||||
|
$ywMin = floor($aABB->minY + 0.4);
|
||||||
|
$ywMax = ceil($aABB->maxY - 0.4);
|
||||||
|
|
||||||
$x0 = $x0 < 0 ? 0 : $x0;
|
$x0 = $x0 < 0 ? 0 : $x0;
|
||||||
$y0 = $y0 < 0 ? 0 : $y0;
|
$y0 = $y0 < 0 ? 0 : $y0;
|
||||||
$z0 = $z0 < 0 ? 0 : $z0;
|
$z0 = $z0 < 0 ? 0 : $z0;
|
||||||
|
|
@ -579,8 +583,9 @@ 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->getID() === WATER || $b->getID() === STILL_WATER)){
|
||||||
$water = true;
|
$water = $b->y == ($y1 - 1);
|
||||||
|
$this->fallDistance = 0;
|
||||||
}
|
}
|
||||||
if($b != false && $b->isSolid){
|
if($b != false && $b->isSolid){
|
||||||
$this->speedY = $b->boundingBox->calculateYOffset($this->boundingBox, $this->speedY);
|
$this->speedY = $b->boundingBox->calculateYOffset($this->boundingBox, $this->speedY);
|
||||||
|
|
@ -729,7 +734,6 @@ class Entity extends Position
|
||||||
$this->needsUpdate = $hasUpdate;
|
$this->needsUpdate = $hasUpdate;
|
||||||
$this->lastUpdate = $now;
|
$this->lastUpdate = $now;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fall(){}
|
public function fall(){}
|
||||||
|
|
||||||
public function updateFallState($fallTick){
|
public function updateFallState($fallTick){
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
||||||
$this->ai->updateTasks();
|
$this->ai->updateTasks();
|
||||||
}
|
}
|
||||||
$this->ai->mobController->rotateTick();
|
$this->ai->mobController->rotateTick();
|
||||||
|
$this->ai->mobController->movementTick();
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
//if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){
|
//if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){
|
||||||
// $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10);
|
// $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10);
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,21 @@ class MobController
|
||||||
|
|
||||||
public $finalYaw, $finalPitch, $finalHeadYaw;
|
public $finalYaw, $finalPitch, $finalHeadYaw;
|
||||||
|
|
||||||
|
protected $jumping;
|
||||||
|
protected $jumpTimeout;
|
||||||
|
|
||||||
public function __construct($e){
|
public function __construct($e){
|
||||||
$this->entity = $e;
|
$this->entity = $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isJumping(){
|
||||||
|
return $this->jumping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setJumping($b){
|
||||||
|
$this->jumping = $b;
|
||||||
|
}
|
||||||
|
|
||||||
public function moveNonInstant($x, $y, $z){
|
public function moveNonInstant($x, $y, $z){
|
||||||
if($x == 0 && $y == 0 && $z == 0){
|
if($x == 0 && $y == 0 && $z == 0){
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -47,6 +57,15 @@ class MobController
|
||||||
return true;
|
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
|
public function rotateTick(){ //TODO handle more rotation
|
||||||
$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
||||||
$w180min = min(abs($w180), 20)*Utils::getSign($w180);
|
$w180min = min(abs($w180), 20)*Utils::getSign($w180);
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,12 @@ class TaskSwimming extends TaskBase
|
||||||
{
|
{
|
||||||
if(!$ai->entity->inWater){
|
if(!$ai->entity->inWater){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
$ai->mobController->setJumping(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Utils::randomFloat() < 0.8){ #1.5.2 method
|
if(Utils::randomFloat() < 0.8){ #1.5.2 method
|
||||||
$ai->entity->speedY = 0.42;
|
$ai->mobController->setJumping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,8 @@ class LiquidBlock extends TransparentBlock{
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLiquidHeight(){ //TODO lava,water meta
|
||||||
|
return (($this->meta >= 8 ? 0 : $this->meta)+1) / 9;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue