mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
small fixes
This commit is contained in:
parent
7b66cd0250
commit
ae8c541452
5 changed files with 23 additions and 11 deletions
|
|
@ -5,12 +5,13 @@ move methods
|
||||||
*/
|
*/
|
||||||
abstract class Creature extends Living{
|
abstract class Creature extends Living{
|
||||||
const CLASS_TYPE = ENTITY_MOB;
|
const CLASS_TYPE = ENTITY_MOB;
|
||||||
|
public $moveTime;
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:1, "generic");
|
$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->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
|
||||||
$this->width = 1;
|
$this->width = 1;
|
||||||
|
$this->moveTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawn($player){
|
public function spawn($player){
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
class Monster extends Creature{
|
class Monster extends Creature{
|
||||||
public function environmentUpdate(){
|
public function environmentUpdate(){
|
||||||
parent::environmentUpdate();
|
$upd = parent::environmentUpdate();
|
||||||
if($this->server->api->getProperty("spawn-mobs") !== true){
|
if($this->server->api->getProperty("spawn-mobs") !== true){
|
||||||
$this->close();
|
$this->close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $upd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
class Pig extends Animal{
|
class Pig extends Animal{
|
||||||
const TYPE = MOB_PIG;
|
const TYPE = MOB_PIG;
|
||||||
public $pathFinder, $path, $server;
|
public $pathFinder, $pathFound, $path, $server;
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
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->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);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
|
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
|
|
@ -22,10 +23,18 @@ class Pig extends Animal{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(){
|
public function update(){
|
||||||
//$start = new MinecraftNode(round($this->x), round($this->y), round($this->z));
|
if($this->pathFound && $this->path !== false and count($this->path) > 0){
|
||||||
//$stop = $start->add(5,0,5);
|
|
||||||
//$path = $this->pathFinder->findPath($start, $stop); //allows diagonals, path should be ~5 blocks
|
}else{
|
||||||
//var_dump($path);
|
//$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();
|
parent::update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class Zombie extends Monster{
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
||||||
$this->setName('Zombie');
|
$this->setName('Zombie');
|
||||||
$this->setSize(0.6, 1.95);
|
$this->setSize(0.6, 1.85);
|
||||||
$this->update();
|
$this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ class Level{
|
||||||
public function getCubes(AxisAlignedBB $aABB) {
|
public function getCubes(AxisAlignedBB $aABB) {
|
||||||
$aABBs = [];
|
$aABBs = [];
|
||||||
$x0 = floor($aABB->minX);
|
$x0 = floor($aABB->minX);
|
||||||
$x1 = ceil($aABB->maxX + 1.0);
|
$x1 = ceil($aABB->maxX);
|
||||||
$y0 = floor($aABB->minY);
|
$y0 = floor($aABB->minY);
|
||||||
$y1 = ceil($aABB->maxY + 1.0);
|
$y1 = ceil($aABB->maxY);
|
||||||
$z0 = floor($aABB->minZ);
|
$z0 = floor($aABB->minZ);
|
||||||
$z1 = ceil($aABB->maxZ + 1.0);
|
$z1 = ceil($aABB->maxZ);
|
||||||
$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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue