small fixes

This commit is contained in:
GameHerobrine 2022-10-19 19:02:59 +03:00
parent 7b66cd0250
commit ae8c541452
5 changed files with 23 additions and 11 deletions

View file

@ -5,12 +5,13 @@ move methods
*/
abstract class Creature extends Living{
const CLASS_TYPE = ENTITY_MOB;
public $moveTime;
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:1, "generic");
$this->update();
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
$this->width = 1;
$this->moveTime = 0;
}
public function spawn($player){

View file

@ -1,10 +1,12 @@
<?php
class Monster extends Creature{
public function environmentUpdate(){
parent::environmentUpdate();
$upd = parent::environmentUpdate();
if($this->server->api->getProperty("spawn-mobs") !== true){
$this->close();
return false;
}
return $upd;
}
}

View file

@ -1,9 +1,10 @@
<?php
class Pig extends Animal{
const TYPE = MOB_PIG;
public $pathFinder, $path, $server;
public $pathFinder, $pathFound, $path, $server;
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
$this->pathFinder = new AStar($this); //make it before everything else as entity class constructor sends update
$this->pathFound = false;
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
$this->server = ServerAPI::request();
@ -22,10 +23,18 @@ class Pig extends Animal{
}
public function update(){
//$start = new MinecraftNode(round($this->x), round($this->y), round($this->z));
//$stop = $start->add(5,0,5);
//$path = $this->pathFinder->findPath($start, $stop); //allows diagonals, path should be ~5 blocks
//var_dump($path);
if($this->pathFound && $this->path !== false and count($this->path) > 0){
}else{
//$start = new MinecraftNode(round($this->x), round($this->y), round($this->z));
//$stop = $start->add(5,0,5);
//$this->path = $this->pathFinder->findPath($start, $stop); //allows diagonals, path should be ~5 blocks
//var_dump($this->path);
$this->pathFound = true;
}
parent::update();
}
}

View file

@ -6,7 +6,7 @@ class Zombie extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
$this->setName('Zombie');
$this->setSize(0.6, 1.95);
$this->setSize(0.6, 1.85);
$this->update();
}

View file

@ -36,11 +36,11 @@ class Level{
public function getCubes(AxisAlignedBB $aABB) {
$aABBs = [];
$x0 = floor($aABB->minX);
$x1 = ceil($aABB->maxX + 1.0);
$x1 = ceil($aABB->maxX);
$y0 = floor($aABB->minY);
$y1 = ceil($aABB->maxY + 1.0);
$y1 = ceil($aABB->maxY);
$z0 = floor($aABB->minZ);
$z1 = ceil($aABB->maxZ + 1.0);
$z1 = ceil($aABB->maxZ);
$x0 = $x0 < 0 ? 0 : $x0;
$y0 = $y0 < 0 ? 0 : $y0;
$z0 = $z0 < 0 ? 0 : $z0;