diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index eab95691..e71ed9cb 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -120,6 +120,7 @@ class ServerAPI{ "allow-flight" => false, "spawn-animals" => true, "spawn-mobs" => true, + "mobs-amount" => 50, "gamemode" => SURVIVAL, "hardcore" => false, "pvp" => true, @@ -135,7 +136,7 @@ class ServerAPI{ ]); $this->parseProperties(); - + MobSpawner::$MOB_LIMIT = $this->getProperty("mobs-amount", 50); //Load advanced properties define("DEBUG", $this->getProperty("debug", 1)); define("ADVANCED_CACHE", $this->getProperty("enable-advanced-cache", false)); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index db838b85..2ae0ee6a 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -574,9 +574,9 @@ class Entity extends Position $y1 = $y1 > 128 ? 128 : $y1; $z1 = $z1 > 256 ? 256 : $z1; $waterDone = false; - for($x = $x0; $x < $x1; ++$x){ + for($x = $x0; $x <= $x1; ++$x){ for($y = $y0; $y < $y1; ++$y){ - for($z = $z0; $z < $z1; ++$z){ + for($z = $z0; $z <= $z1; ++$z){ $pos = new Vector3($x, $y, $z); $b = $this->level->getBlock($pos); switch($b->getID()) { @@ -1531,7 +1531,8 @@ class Entity extends Position { throw new Exception("Use getHeightOf or getWidthOf method instead of this."); } - + + /** * * @deprecated Use {@link getHeight} or {@link getWidth} instead diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php index c45d051d..0294bef7 100644 --- a/src/entity/animal/Chicken.php +++ b/src/entity/animal/Chicken.php @@ -5,7 +5,7 @@ class Chicken extends Animal{ public $timeUntilEgg; function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->timeUntilEgg = mt_rand(0,6000) + 6000; - $this->setSize($this->isBaby() ? 0.2 : 0.3, $this->isBaby() ? 0.35 : 0.4); + $this->setSize($this->isBaby() ? 0.2 : 0.4, $this->isBaby() ? 0.35 : 0.7); parent::__construct($level, $eid, $class, $type, $data); $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic"); $this->setName('Chicken'); diff --git a/src/material/item/generic/BucketItem.php b/src/material/item/generic/BucketItem.php index 7988bd44..78feb784 100644 --- a/src/material/item/generic/BucketItem.php +++ b/src/material/item/generic/BucketItem.php @@ -28,7 +28,7 @@ class BucketItem extends Item{ if($block->getID() === AIR || ( $block instanceof WaterBlock && ($block->getMetadata() & 0x07) != 0x00 ) ){ $water = new WaterBlock(); $level->setBlock($block, $water, true, false, true); - $water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz); + $water->place($this, $player, $block, $target, $face, $fx, $fy, $fz); if(($player->gamemode & 0x01) === 0){ $this->meta = 0; } diff --git a/src/world/MobSpawner.php b/src/world/MobSpawner.php index 890264a7..19e666c4 100644 --- a/src/world/MobSpawner.php +++ b/src/world/MobSpawner.php @@ -4,7 +4,7 @@ class MobSpawner{ public static $spawnAnimals = false, $spawnMobs = false; private $server; public $level; - const MOB_LIMIT = 50; //constant for now + public static $MOB_LIMIT = 50; public function __construct(Level $level){ $this->server = ServerAPI::request(); $this->level = $level; @@ -19,7 +19,7 @@ class MobSpawner{ } public function handle(){ - if($this->countEntities() > self::MOB_LIMIT || count($this->level->players) <= 0){ + if($this->countEntities() > self::$MOB_LIMIT || count($this->level->players) <= 0){ return false; //not spawning } return $this->spawnMobs(); @@ -40,11 +40,11 @@ class MobSpawner{ } $x = mt_rand(0,255); $z = mt_rand(0,255); - $y = $this->getSafeY($x, $z, $grassOnly); + $y = $this->getSafeY($x, $z, $grassOnly, $type >= 32 && $type <= 36 && $type != 35); if(!$y || $y < 0){ return false; } - $data = $this->genPosData($x, $y + 1, $z); + $data = $this->genPosData($x, $y + 0.5, $z); if($baby != 2) $data["IsBaby"] = $baby; $e = $this->server->api->entity->add($this->level, 2, $type, $data); @@ -64,12 +64,13 @@ class MobSpawner{ ]; } - protected function getSafeY($x, $z, $grassOnly = false){ //first safe block + protected function getSafeY($x, $z, $grassOnly = false, $highMob = false){ //first safe block //TODO check boundingbox $allowed = []; for($y = 0; $y < 128; ++$y){ $b = $this->level->getBlockWithoutVector($x, $y, $z); + $b2 = $this->level->getBlockWithoutVector($x, $y + 1, $z); $b1 = $this->level->getBlockWithoutVector($x, $y - 1, $z); - if(!$b->isSolid && ($b1->isSolid && ($grassOnly ? $b1->getID() === GRASS : true))){ + if(!$b->isSolid && !$b->isLiquid && ($b1->isSolid && ($grassOnly ? $b1->getID() === GRASS : true) && ($highMob ? !$b2->isSolid && !$b2->isLiquid : true))){ $allowed[] = $y; } }