From ae8c54145279f13baf53fab49ea2dcebbc16d7e5 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Wed, 19 Oct 2022 19:02:59 +0300 Subject: [PATCH] small fixes --- src/entity/Creature.php | 3 ++- src/entity/Monster.php | 4 +++- src/entity/animal/Pig.php | 19 ++++++++++++++----- src/entity/monster/Zombie.php | 2 +- src/world/Level.php | 6 +++--- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/entity/Creature.php b/src/entity/Creature.php index 8e008074..bcb0be92 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -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){ diff --git a/src/entity/Monster.php b/src/entity/Monster.php index 1651661a..67e5bab2 100644 --- a/src/entity/Monster.php +++ b/src/entity/Monster.php @@ -1,10 +1,12 @@ server->api->getProperty("spawn-mobs") !== true){ $this->close(); return false; } + + return $upd; } } \ No newline at end of file diff --git a/src/entity/animal/Pig.php b/src/entity/animal/Pig.php index e26d4e86..4b0ec6c9 100644 --- a/src/entity/animal/Pig.php +++ b/src/entity/animal/Pig.php @@ -1,9 +1,10 @@ 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(); } } diff --git a/src/entity/monster/Zombie.php b/src/entity/monster/Zombie.php index 8691a1fd..f21a0111 100644 --- a/src/entity/monster/Zombie.php +++ b/src/entity/monster/Zombie.php @@ -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(); } diff --git a/src/world/Level.php b/src/world/Level.php index 7f0d1cd1..79bd57e8 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -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;