mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
readded useless loop, fixed falling
This commit is contained in:
parent
4f7ebf4471
commit
2cdf3ca8da
3 changed files with 49 additions and 24 deletions
|
|
@ -25,26 +25,20 @@ abstract class Creature extends Living{
|
|||
}
|
||||
|
||||
public function update(){
|
||||
/*if($this->path === null && $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(-7, 7), $this->y, $this->z + mt_rand(-7, 7), $this->level));
|
||||
if($this->onGround){
|
||||
/*if($this->path === null && $this->pathFinder instanceof ITileNavigator && mt_rand(0, 120) === 0){
|
||||
$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, $this->z + mt_rand(-10, 10), $this->level));
|
||||
}
|
||||
if($this->path != null && (is_array($this->path) && count($this->path) <= 0 || $this->currentIndex >= count($this->path))){
|
||||
$this->path = null;
|
||||
$this->currentIndex = 0;
|
||||
$this->currentNode = false;
|
||||
}elseif($this->path != null && ($this->currentNode == false || $this->ai->mobController->moveTo($this->currentNode->x, $this->currentNode->y, $this->currentNode->z) === false)){
|
||||
$this->currentNode = $this->path[$this->currentIndex++];
|
||||
}*/
|
||||
}
|
||||
if(is_array($this->path) && count($this->path) <= 0 || $this->currentIndex >= count($this->path)){
|
||||
$this->path = null;
|
||||
$this->currentIndex = 0;
|
||||
$this->currentNode = false;
|
||||
}elseif($this->currentNode == false || $this->ai->mobController->moveTo($this->currentNode->x, $this->currentNode->y, $this->currentNode->z) === false){
|
||||
console("this");
|
||||
$this->currentNode = $this->path[$this->currentIndex++];
|
||||
}*/
|
||||
|
||||
|
||||
/*if($this->path === false || count($this->path) <= 0){
|
||||
}
|
||||
$state = $this->pathNavigator->followPath($this->path);
|
||||
if($state === PathNavigator::PATH_COMPLETED){
|
||||
$this->path = false;
|
||||
}*/
|
||||
parent::update();
|
||||
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
|
|
|
|||
|
|
@ -69,7 +69,9 @@ class Entity extends Position
|
|||
public $radius;
|
||||
public $inAction = false;
|
||||
public $hasKnockback;
|
||||
|
||||
|
||||
public $onGround;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||
{
|
||||
$this->random = new Random();
|
||||
|
|
@ -635,6 +637,36 @@ class Entity extends Position
|
|||
}
|
||||
|
||||
}
|
||||
if(!$support){
|
||||
for($z = $startZ; $z <= $endZ; ++ $z){
|
||||
for($x = $startX; $x <= $endX; ++ $x){
|
||||
$v = new Vector3($x, $y, $z);
|
||||
$v1 = new Vector3($x, $yC, $z);
|
||||
if($this->isSupport($v, $this->width)){
|
||||
$b = $this->level->getBlock($v);
|
||||
if($b->isSolid === true){
|
||||
$support = true;
|
||||
$isFlying = false;
|
||||
break;
|
||||
} elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){
|
||||
$isFlying = false;
|
||||
}
|
||||
} elseif($this->isSupport($v1, $this->width)){
|
||||
$b = $this->level->getBlock($v1);
|
||||
if($b->isSolid === true){
|
||||
$support = true;
|
||||
$isFlying = false;
|
||||
break;
|
||||
} elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){
|
||||
$isFlying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($support === true){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($this->speedX != 0){
|
||||
$this->x += $this->speedX;
|
||||
$this->speedX -= $this->speedX * $drag;
|
||||
|
|
@ -677,10 +709,9 @@ class Entity extends Position
|
|||
$this->speedY -= $this->speedY * $drag;
|
||||
$update = true;
|
||||
}
|
||||
if($this->speedY == 0){
|
||||
$support = true;
|
||||
}
|
||||
|
||||
$this->onGround = $support;
|
||||
|
||||
if($this->hasGravity && $support === false){
|
||||
$this->speedY -= ($this->class === ENTITY_FALLING) ? 0.04 : ($this->class === ENTITY_ITEM ? 0.06 : 0.08); // TODO: replace with $gravity
|
||||
$update = true;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ abstract class Living extends Entity implements Damageable{
|
|||
$this->ai = new EntityAI($this);
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->canBeAttacked = true;
|
||||
$this->hasGravity = true;
|
||||
$this->hasKnockback = true;
|
||||
$this->hasGravity = true;
|
||||
$this->hasKnockback = true;
|
||||
}
|
||||
|
||||
public function update(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue