Fixing a bad formatting

This commit is contained in:
Adsooi 2017-04-29 11:59:44 +02:00
parent 36956495ee
commit 2d6bb2c679
32 changed files with 1403 additions and 1264 deletions

View file

@ -20,51 +20,51 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
class BetterDesert extends SandyBiome implements Mountainable { class BetterDesert extends SandyBiome implements Mountainable {
public function __construct() { public function __construct() {
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount ( 1 ); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount ( 2 ); $deadBush->setRandomAmount(2);
$cactus = new CactusPopulator (); $cactus = new CactusPopulator ();
$cactus->setBaseAmount ( 1 ); $cactus->setBaseAmount(1);
$cactus->setRandomAmount ( 2 ); $cactus->setRandomAmount(2);
$sugarCane = new SugarCanePopulator (); $sugarCane = new SugarCanePopulator ();
$sugarCane->setRandomAmount ( 20 ); $sugarCane->setRandomAmount(20);
$sugarCane->setBaseAmount ( 3 ); $sugarCane->setBaseAmount(3);
$temple = new TemplePopulator (); $temple = new TemplePopulator ();
$well = new WellPopulator (); $well = new WellPopulator ();
$this->addPopulator ( $cactus ); $this->addPopulator($cactus);
$this->addPopulator ( $deadBush ); $this->addPopulator($deadBush);
$this->addPopulator ( $sugarCane ); $this->addPopulator($sugarCane);
$this->addPopulator ( $temple ); $this->addPopulator($temple);
$this->addPopulator ( $well ); $this->addPopulator($well);
$this->setElevation ( 63, 70 ); $this->setElevation(63, 70);
// $this->setElevation(66, 70); // $this->setElevation(66, 70);
$this->temperature = 0.5; $this->temperature = 0.5;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover ( [ $this->setGroundCover([
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ) Block::get(Block::SANDSTONE, 0 )
] ); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Desert"; return "Better Desert";

View file

@ -27,24 +27,24 @@ class BetterForest extends ForestBiome implements Mountainable {
Main::SAKURA_FOREST Main::SAKURA_FOREST
]; ];
public function __construct($type = 0, array $infos = [0.6, 0.5]) { public function __construct($type = 0, array $infos = [0.6, 0.5]) {
parent::__construct ( $type ); parent::__construct($type);
$this->clearPopulators (); $this->clearPopulators ();
$this->type = $type; $this->type = $type;
$bush = new BushPopulator ( $type ); $bush = new BushPopulator($type);
$bush->setBaseAmount ( 10 ); $bush->setBaseAmount(10);
$this->addPopulator ( $bush ); $this->addPopulator($bush);
$trees = new TreePopulator ( $type ); $trees = new TreePopulator($type);
$trees->setBaseAmount ( (null !== @constant ( TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant ( TreePopulator::$types [$type] . "::maxPerChunk" ) : 5 ); $trees->setBaseAmount((null !== @constant(TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant(TreePopulator::$types [$type] . "::maxPerChunk" ) : 5);
$this->addPopulator ( $trees ); $this->addPopulator($trees);
$tallGrass = new TallGrass (); $tallGrass = new TallGrass ();
$tallGrass->setBaseAmount ( 3 ); $tallGrass->setBaseAmount(3);
$this->addPopulator ( $tallGrass ); $this->addPopulator($tallGrass);
$this->setElevation ( 63, 81 ); $this->setElevation(63, 81);
$this->temperature = $infos [0]; $this->temperature = $infos [0];
$this->rainfall = $infos [1]; $this->rainfall = $infos [1];
@ -68,9 +68,9 @@ class BetterForest extends ForestBiome implements Mountainable {
* @return bool * @return bool
*/ */
public static function registerForest(string $name, string $treeClass, array $infos): bool { public static function registerForest(string $name, string $treeClass, array $infos): bool {
self::$types [] = str_ireplace ( "tree", "", explode ( "\\", $treeClass ) [count ( explode ( "\\", $treeClass ) )] ) . " Forest"; self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest";
TreePopulator::$types [] = $treeClass; TreePopulator::$types [] = $treeClass;
self::$ids [] = Main::SAKURA_FOREST + (count ( self::$types ) - 2); self::$ids [] = Main::SAKURA_FOREST + (count(self::$types ) - 2);
Main::register ( Main::SAKURA_FOREST + (count ( self::$types ) - 2), new BetterForest ( count ( self::$types ) - 1, $infos ) ); Main::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos ));
} }
} }

View file

@ -18,21 +18,21 @@ use Ad5001\BetterGen\populator\IglooPopulator;
class BetterIcePlains extends SnowyBiome implements Mountainable { class BetterIcePlains extends SnowyBiome implements Mountainable {
public function __construct() { public function __construct() {
parent::__construct (); parent::__construct ();
$this->setGroundCover ( [ $this->setGroundCover([
Block::get ( Block::SNOW, 0 ), Block::get(Block::SNOW, 0 ),
Block::get ( Block::GRASS, 0 ), Block::get(Block::GRASS, 0 ),
Block::get ( Block::DIRT, 0 ), Block::get(Block::DIRT, 0 ),
Block::get ( Block::DIRT, 0 ), Block::get(Block::DIRT, 0 ),
Block::get ( Block::DIRT, 0 ) Block::get(Block::DIRT, 0 )
] ); ]);
$this->addPopulator ( new IglooPopulator () ); $this->addPopulator(new IglooPopulator ());
$tallGrass = new TallGrass (); $tallGrass = new TallGrass ();
$tallGrass->setBaseAmount ( 3 ); $tallGrass->setBaseAmount(3);
$this->addPopulator ( $tallGrass ); $this->addPopulator($tallGrass);
$this->setElevation ( 63, 74 ); $this->setElevation(63, 74);
$this->temperature = 0.05; $this->temperature = 0.05;
$this->rainfall = 0.8; $this->rainfall = 0.8;

View file

@ -23,82 +23,82 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
class BetterMesa extends SandyBiome { class BetterMesa extends SandyBiome {
public function __construct() { public function __construct() {
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount ( 1 ); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount ( 2 ); $deadBush->setRandomAmount(2);
$cactus = new CactusPopulator (); $cactus = new CactusPopulator ();
$cactus->setBaseAmount ( 1 ); $cactus->setBaseAmount(1);
$cactus->setRandomAmount ( 2 ); $cactus->setRandomAmount(2);
$sugarCane = new SugarCanePopulator (); $sugarCane = new SugarCanePopulator ();
$sugarCane->setRandomAmount ( 20 ); $sugarCane->setRandomAmount(20);
$sugarCane->setBaseAmount ( 3 ); $sugarCane->setBaseAmount(3);
$sugarCane = new TreePopulator (); $sugarCane = new TreePopulator ();
$sugarCane->setRandomAmount ( 2 ); $sugarCane->setRandomAmount(2);
$sugarCane->setBaseAmount ( 0 ); $sugarCane->setBaseAmount(0);
$ores = new Ore (); $ores = new Ore ();
$ores->setOreTypes ( [ $ores->setOreTypes([
new OreType ( new GoldOre (), 2, 8, 0, 32 ) new OreType(new GoldOre (), 2, 8, 0, 32 )
] ); ]);
$this->addPopulator ( $cactus ); $this->addPopulator($cactus);
$this->addPopulator ( $deadBush ); $this->addPopulator($deadBush);
$this->addPopulator ( $sugarCane ); $this->addPopulator($sugarCane);
$this->addPopulator ( $ores ); $this->addPopulator($ores);
$this->setElevation ( 80, 83 ); $this->setElevation(80, 83);
// $this->setElevation(66, 70); // $this->setElevation(66, 70);
$this->temperature = 0.8; $this->temperature = 0.8;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover ( [ $this->setGroundCover([
Block::get ( Block::DIRT, 0 ), Block::get(Block::DIRT, 0 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 4 ), Block::get(Block::STAINED_HARDENED_CLAY, 4 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 0 ), Block::get(Block::STAINED_HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ) Block::get(Block::RED_SANDSTONE, 0 )
] ); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Mesa"; return "Better Mesa";

View file

@ -21,79 +21,79 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
class BetterMesaPlains extends SandyBiome { class BetterMesaPlains extends SandyBiome {
public function __construct() { public function __construct() {
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount ( 1 ); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount ( 2 ); $deadBush->setRandomAmount(2);
$cactus = new CactusPopulator (); $cactus = new CactusPopulator ();
$cactus->setBaseAmount ( 1 ); $cactus->setBaseAmount(1);
$cactus->setRandomAmount ( 2 ); $cactus->setRandomAmount(2);
$sugarCane = new SugarCanePopulator (); $sugarCane = new SugarCanePopulator ();
$sugarCane->setRandomAmount ( 20 ); $sugarCane->setRandomAmount(20);
$sugarCane->setBaseAmount ( 3 ); $sugarCane->setBaseAmount(3);
$ores = new Ore (); $ores = new Ore ();
$ores->setOreTypes ( [ $ores->setOreTypes([
new OreType ( new GoldOre (), 20, 8, 0, 32 ) new OreType(new GoldOre (), 20, 8, 0, 32 )
] ); ]);
$this->addPopulator ( $cactus ); $this->addPopulator($cactus);
$this->addPopulator ( $deadBush ); $this->addPopulator($deadBush);
$this->addPopulator ( $sugarCane ); $this->addPopulator($sugarCane);
$this->addPopulator ( $ores ); $this->addPopulator($ores);
$this->setElevation ( 62, 67 ); $this->setElevation(62, 67);
// $this->setElevation(66, 70); // $this->setElevation(66, 70);
$this->temperature = 0.6; $this->temperature = 0.6;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover ( [ $this->setGroundCover([
Block::get ( Block::SAND, 1 ), Block::get(Block::SAND, 1 ),
Block::get ( Block::SAND, 1 ), Block::get(Block::SAND, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 4 ), Block::get(Block::STAINED_HARDENED_CLAY, 4 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 0 ), Block::get(Block::STAINED_HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0 ),
Block::get ( Block::RED_SANDSTONE, 0 ) Block::get(Block::RED_SANDSTONE, 0 )
] ); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Mesa Plains"; return "Better Mesa Plains";

View file

@ -16,21 +16,21 @@ class BetterRiver extends Biome {
public function __construct() { public function __construct() {
$this->clearPopulators (); $this->clearPopulators ();
$this->setGroundCover ( [ $this->setGroundCover([
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SAND, 0 ), Block::get(Block::SAND, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0 ),
Block::get ( Block::SANDSTONE, 0 ) Block::get(Block::SANDSTONE, 0 )
] ); ]);
$this->setElevation ( 60, 60 ); $this->setElevation(60, 60);
$this->temperature = 0.5; $this->temperature = 0.5;
$this->rainfall = 0.7; $this->rainfall = 0.7;

View file

@ -30,8 +30,8 @@ class BetterBiomeSelector extends BiomeSelector {
public function __construct(Random $random, callable $lookup, Biome $fallback) { public function __construct(Random $random, callable $lookup, Biome $fallback) {
$this->fallback = $fallback; $this->fallback = $fallback;
$this->lookup = $lookup; $this->lookup = $lookup;
$this->temperature = new Simplex ( $random, 2, 1 / 16, 1 / 512 ); $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512);
$this->rainfall = new Simplex ( $random, 2, 1 / 16, 1 / 512 ); $this->rainfall = new Simplex($random, 2, 1 / 16, 1 / 512);
} }
public function recalculate() { public function recalculate() {
} // Using our own system, No need for that } // Using our own system, No need for that
@ -39,10 +39,10 @@ class BetterBiomeSelector extends BiomeSelector {
$this->biomes [$biome->getId ()] = $biome; $this->biomes [$biome->getId ()] = $biome;
} }
public function getTemperature($x, $z) { public function getTemperature($x, $z) {
return ($this->temperature->noise2D ( $x, $z, true ) + 1) / 2; return ($this->temperature->noise2D($x, $z, true ) + 1) / 2;
} }
public function getRainfall($x, $z) { public function getRainfall($x, $z) {
return ($this->rainfall->noise2D ( $x, $z, true ) + 1) / 2; return ($this->rainfall->noise2D($x, $z, true ) + 1) / 2;
} }
/** /**
@ -55,10 +55,10 @@ class BetterBiomeSelector extends BiomeSelector {
* @return Biome * @return Biome
*/ */
public function pickBiome($x, $z) { public function pickBiome($x, $z) {
$temperature = ($this->getTemperature ( $x, $z )); $temperature = ($this->getTemperature($x, $z ));
$rainfall = ($this->getRainfall ( $x, $z )); $rainfall = ($this->getRainfall($x, $z ));
$biomeId = BetterNormal::getBiome ( $temperature, $rainfall ); $biomeId = BetterNormal::getBiome($temperature, $rainfall);
// $biomeId = new \Ad5001\BetterGen\biome\BetterDesert(); // $biomeId = new \Ad5001\BetterGen\biome\BetterDesert();
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback)); $b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback));
return $b; return $b;

View file

@ -83,10 +83,10 @@ class BetterNormal extends Generator {
$zNoise = 1; $zNoise = 1;
} }
$b = $this->selector->pickBiome ( $x + $xNoise - 1, $z + $zNoise - 1 ); $b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
if ($b instanceof Mountainable && $this->random->nextBoundedInt ( 1000 ) < 3) { if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000 ) < 3) {
$b = clone $b; $b = clone $b;
$b->setElevation ( $b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100) ); $b->setElevation($b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100));
} }
return $b; return $b;
} }
@ -96,40 +96,40 @@ class BetterNormal extends Generator {
self::$levels [] = $level; self::$levels [] = $level;
$this->random->setSeed ( $this->level->getSeed () ); $this->random->setSeed($this->level->getSeed ());
$this->noiseBase = new Simplex ( $this->random, 4, 1 / 4, 1 / 32 ); $this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
$this->random->setSeed ( $this->level->getSeed () ); $this->random->setSeed($this->level->getSeed ());
$this->registerBiome ( Biome::getBiome ( Biome::OCEAN ) ); $this->registerBiome(Biome::getBiome(Biome::OCEAN ));
$this->registerBiome ( Biome::getBiome ( Biome::PLAINS ) ); $this->registerBiome(Biome::getBiome(Biome::PLAINS ));
$this->registerBiome ( new BetterDesert () ); $this->registerBiome(new BetterDesert ());
$this->registerBiome ( new BetterMesa () ); $this->registerBiome(new BetterMesa ());
$this->registerBiome ( new BetterMesaPlains () ); $this->registerBiome(new BetterMesaPlains ());
$this->registerBiome ( Biome::getBiome ( Biome::TAIGA ) ); $this->registerBiome(Biome::getBiome(Biome::TAIGA ));
$this->registerBiome ( Biome::getBiome ( Biome::SWAMP ) ); $this->registerBiome(Biome::getBiome(Biome::SWAMP ));
$this->registerBiome ( new BetterRiver () ); $this->registerBiome(new BetterRiver ());
$this->registerBiome ( new BetterIcePlains () ); $this->registerBiome(new BetterIcePlains ());
$this->registerBiome ( new BetterForest ( 0, [ $this->registerBiome(new BetterForest(0, [
0.6, 0.6,
0.5 0.5
] ) ); ] ));
$this->registerBiome ( new BetterForest ( 1, [ $this->registerBiome(new BetterForest(1, [
0.7, 0.7,
0.8 0.8
] ) ); ] ));
$this->registerBiome ( new BetterForest ( 2, [ $this->registerBiome(new BetterForest(2, [
0.6, 0.6,
0.4 0.4
] ) ); ] ));
$this->selector = new BetterBiomeSelector ( $random, [ $this->selector = new BetterBiomeSelector($random, [
self::class, self::class,
"getBiome" "getBiome"
], self::getBiome ( 0, 0 ) ); ], self::getBiome(0, 0 ));
foreach ( self::$biomes as $rain ) { foreach(self::$biomes as $rain ) {
foreach ( $rain as $biome ) { foreach($rain as $biome ) {
$this->selector->addBiome ( $biome ); $this->selector->addBiome($biome);
} }
} }
@ -139,41 +139,41 @@ class BetterNormal extends Generator {
$this->generationPopulators [] = $cover; $this->generationPopulators [] = $cover;
$cave = new CavePopulator (); $cave = new CavePopulator ();
$cave->setBaseAmount ( 0 ); $cave->setBaseAmount(0);
$cave->setRandomAmount ( 2 ); $cave->setRandomAmount(2);
$this->populators [] = $cave; $this->populators [] = $cave;
$ravine = new RavinePopulator (); $ravine = new RavinePopulator ();
$ravine->setBaseAmount ( 0 ); $ravine->setBaseAmount(0);
$ravine->setRandomAmount ( 51 ); $ravine->setRandomAmount(51);
$this->populators [] = $ravine; $this->populators [] = $ravine;
$mineshaft = new MineshaftPopulator (); $mineshaft = new MineshaftPopulator ();
$mineshaft->setBaseAmount ( 0 ); $mineshaft->setBaseAmount(0);
$mineshaft->setRandomAmount ( 102 ); $mineshaft->setRandomAmount(102);
$this->populators [] = $mineshaft; $this->populators [] = $mineshaft;
$lake = new LakePopulator (); $lake = new LakePopulator ();
$lake->setBaseAmount ( 0 ); $lake->setBaseAmount(0);
$lake->setRandomAmount ( 1 ); $lake->setRandomAmount(1);
$this->generationPopulators [] = $lake; $this->generationPopulators [] = $lake;
$fisl = new FloatingIslandPopulator(); $fisl = new FloatingIslandPopulator();
$fisl->setBaseAmount ( 0 ); $fisl->setBaseAmount(0);
$fisl->setRandomAmount ( 132 ); $fisl->setRandomAmount(132);
$this->populators [] = $fisl; $this->populators [] = $fisl;
$ores = new Ore (); $ores = new Ore ();
$ores->setOreTypes ( [ $ores->setOreTypes([
new OreType ( new CoalOre (), 20, 16, 0, 128 ), new OreType(new CoalOre (), 20, 16, 0, 128 ),
new OreType ( new IronOre (), 20, 8, 0, 64 ), new OreType(new IronOre (), 20, 8, 0, 64 ),
new OreType ( new RedstoneOre (), 8, 7, 0, 16 ), new OreType(new RedstoneOre (), 8, 7, 0, 16 ),
new OreType ( new LapisOre (), 1, 6, 0, 32 ), new OreType(new LapisOre (), 1, 6, 0, 32 ),
new OreType ( new GoldOre (), 2, 8, 0, 32 ), new OreType(new GoldOre (), 2, 8, 0, 32 ),
new OreType ( new DiamondOre (), 1, 7, 0, 16 ), new OreType(new DiamondOre (), 1, 7, 0, 16 ),
new OreType ( new Dirt (), 20, 32, 0, 128 ), new OreType(new Dirt (), 20, 32, 0, 128 ),
new OreType ( new Gravel (), 10, 16, 0, 128 ) new OreType(new Gravel (), 10, 16, 0, 128 )
] ); ]);
$this->populators [] = $ores; $this->populators [] = $ores;
} }
@ -183,14 +183,14 @@ class BetterNormal extends Generator {
* @return bool * @return bool
*/ */
public static function registerBiome(Biome $biome): bool { public static function registerBiome(Biome $biome): bool {
foreach ( self::$levels as $lvl ) foreach(self::$levels as $lvl )
if (isset ( $lvl->selector )) if (isset($lvl->selector ))
$lvl->selector->addBiome ( $biome ); // If no selector created, it would cause errors. These will be added when selectoes $lvl->selector->addBiome($biome); // If no selector created, it would cause errors. These will be added when selectoes
if (! isset ( self::$biomes [( string ) $biome->getRainfall ()] )) if (! isset(self::$biomes [( string ) $biome->getRainfall ()] ))
self::$biomes [( string ) $biome->getRainfall ()] = [ ]; self::$biomes [( string ) $biome->getRainfall ()] = [ ];
self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome; self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome;
ksort ( self::$biomes [( string ) $biome->getRainfall ()] ); ksort(self::$biomes [( string ) $biome->getRainfall ()]);
ksort ( self::$biomes ); ksort(self::$biomes);
self::$biomeById[$biome->getId()] = $biome; self::$biomeById[$biome->getId()] = $biome;
return true; return true;
} }
@ -201,26 +201,26 @@ class BetterNormal extends Generator {
* @param $rainfall float * @param $rainfall float
*/ */
public static function getBiome($temperature, $rainfall) { public static function getBiome($temperature, $rainfall) {
if (! isset ( self::$biomes [( string ) round ( $rainfall, 1 )] )) { if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) {
while ( ! isset ( self::$biomes [( string ) round ( $rainfall, 1 )] ) ) { while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) {
if (abs ( $rainfall - round ( $rainfall, 1 ) ) >= 0.05) if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05)
$rainfall += 0.1; $rainfall += 0.1;
if (abs ( $rainfall - round ( $rainfall, 1 ) ) < 0.05) if (abs($rainfall - round($rainfall, 1 ) ) < 0.05)
$rainfall -= 0.1; $rainfall -= 0.1;
if (round ( $rainfall, 1 ) < 0) if (round($rainfall, 1 ) < 0)
$rainfall = 0; $rainfall = 0;
if (round ( $rainfall, 1 ) >= 0.9) if (round($rainfall, 1 ) >= 0.9)
$rainfall = 0.9; $rainfall = 0.9;
} }
} }
$b = self::$biomes [( string ) round ( $rainfall, 1 )]; $b = self::$biomes [( string ) round($rainfall, 1 )];
foreach ( $b as $t => $biome ) { foreach($b as $t => $biome ) {
if ($temperature <= ( float ) $t) { if ($temperature <=(float ) $t) {
$ret = $biome; $ret = $biome;
break; break;
} }
} }
if (is_string ( $ret )) { if (is_string($ret )) {
$ret = new $ret (); $ret = new $ret ();
} else { } else {
return $ret; return $ret;
@ -245,36 +245,36 @@ class BetterNormal extends Generator {
public function generateChunk($chunkX, $chunkZ) { public function generateChunk($chunkX, $chunkZ) {
$this->reRegisterBiomes (); $this->reRegisterBiomes ();
$this->random->setSeed ( 0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed () ); $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
$noise = Generator::getFastNoise3D ( $this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16 ); $noise = Generator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
$chunk = $this->level->getChunk ( $chunkX, $chunkZ ); $chunk = $this->level->getChunk($chunkX, $chunkZ);
$biomeCache = [ ]; $biomeCache = [ ];
for($x = 0; $x < 16; ++ $x) { for($x = 0; $x < 16; $x++) {
for($z = 0; $z < 16; ++ $z) { for($z = 0; $z < 16; $z++) {
$minSum = 0; $minSum = 0;
$maxSum = 0; $maxSum = 0;
$weightSum = 0; $weightSum = 0;
$biome = $this->pickBiome ( $chunkX * 16 + $x, $chunkZ * 16 + $z ); $biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
$chunk->setBiomeId ( $x, $z, $biome->getId () ); $chunk->setBiomeId($x, $z, $biome->getId ());
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; ++ $sx) { for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++ $sz) { for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
$weight = self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE]; $weight = self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
if ($sx === 0 and $sz === 0) { if ($sx === 0 and $sz === 0) {
$adjacent = $biome; $adjacent = $biome;
} else { } else {
$index = Level::chunkHash ( $chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz ); $index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
if (isset ( $biomeCache [$index] )) { if (isset($biomeCache [$index] )) {
$adjacent = $biomeCache [$index]; $adjacent = $biomeCache [$index];
} else { } else {
$biomeCache [$index] = $adjacent = $this->pickBiome ( $chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz ); $biomeCache [$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
} }
} }
$minSum += ($adjacent->getMinElevation () - 1) * $weight; $minSum += ($adjacent->getMinElevation () - 1) * $weight;
@ -289,24 +289,24 @@ class BetterNormal extends Generator {
$smoothHeight = ($maxSum - $minSum) / 2; $smoothHeight = ($maxSum - $minSum) / 2;
for($y = 0; $y < 128; ++ $y) { for($y = 0; $y < 128; $y++) {
if ($y < 3 || ($y < 5 && $this->random->nextBoolean ())) { if ($y < 3 || ($y < 5 && $this->random->nextBoolean ())) {
$chunk->setBlockId ( $x, $y, $z, Block::BEDROCK ); $chunk->setBlockId($x, $y, $z, Block::BEDROCK);
continue; continue;
} }
$noiseValue = $noise [$x] [$z] [$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum); $noiseValue = $noise [$x] [$z] [$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum);
if ($noiseValue > 0) { if ($noiseValue > 0) {
$chunk->setBlockId ( $x, $y, $z, Block::STONE ); $chunk->setBlockId($x, $y, $z, Block::STONE);
} elseif ($y <= $this->waterHeight) { } elseif ($y <= $this->waterHeight) {
$chunk->setBlockId ( $x, $y, $z, Block::STILL_WATER ); $chunk->setBlockId($x, $y, $z, Block::STILL_WATER);
} }
} }
} }
} }
foreach ( $this->generationPopulators as $populator ) { foreach($this->generationPopulators as $populator ) {
$populator->populate ( $this->level, $chunkX, $chunkZ, $this->random ); $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
} }
} }
@ -316,22 +316,22 @@ class BetterNormal extends Generator {
* @param $chunk2 int * @param $chunk2 int
*/ */
public function populateChunk($chunkX, $chunkZ) { public function populateChunk($chunkX, $chunkZ) {
$this->random->setSeed ( 0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed () ); $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
foreach ( $this->populators as $populator ) { foreach($this->populators as $populator ) {
$populator->populate ( $this->level, $chunkX, $chunkZ, $this->random ); $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
} }
// Filling lava (lakes & rivers underground)... // Filling lava (lakes & rivers underground)...
for($x = $chunkX; $x < $chunkX + 16; $x ++) for($x = $chunkX; $x < $chunkX + 16; $x ++)
for($z = $chunkZ; $z < $chunkZ + 16; $z ++) for($z = $chunkZ; $z < $chunkZ + 16; $z ++)
for($y = 1; $y < 11; $y ++) { for($y = 1; $y < 11; $y ++) {
if (! in_array ( $this->level->getBlockIdAt ( $x, $y, $z ), self::NOT_OVERWRITABLE )) if (! in_array($this->level->getBlockIdAt($x, $y, $z ), self::NOT_OVERWRITABLE ))
$this->level->setBlockIdAt ( $x, $y, $z, Block::LAVA ); $this->level->setBlockIdAt($x, $y, $z, Block::LAVA);
} }
$chunk = $this->level->getChunk ( $chunkX, $chunkZ ); $chunk = $this->level->getChunk($chunkX, $chunkZ);
$biome = Biome::getBiome ( $chunk->getBiomeId ( 7, 7 ) ); $biome = Biome::getBiome($chunk->getBiomeId(7, 7 ));
$biome->populateChunk ( $this->level, $chunkX, $chunkZ, $this->random ); $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
} }
/* /*
@ -353,13 +353,13 @@ class BetterNormal extends Generator {
$bellSize = 1 / self::$SMOOTH_SIZE; $bellSize = 1 / self::$SMOOTH_SIZE;
$bellHeight = 2 * self::$SMOOTH_SIZE; $bellHeight = 2 * self::$SMOOTH_SIZE;
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; ++ $sx) { for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] = [ ]; self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] = [ ];
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++ $sz) { for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
$bx = $bellSize * $sx; $bx = $bellSize * $sx;
$bz = $bellSize * $sz; $bz = $bellSize * $sz;
self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp ( - ($bx * $bx + $bz * $bz) / 2 ); self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp(- ($bx * $bx + $bz * $bz) / 2);
} }
} }
} }
@ -377,14 +377,14 @@ class BetterNormal extends Generator {
return [ ]; return [ ];
} }
public function getSpawn() { public function getSpawn() {
return new Vector3 ( 127.5, 128, 127.5 ); return new Vector3(127.5, 128, 127.5);
} }
/* /*
* Returns a safe spawn location * Returns a safe spawn location
*/ */
public function getSafeSpawn() { public function getSafeSpawn() {
return new Vector3 ( 127.5, $this->getHighestWorkableBlock ( 127, 127 ), 127.5 ); return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127 ), 127.5);
} }
/* /*
@ -394,7 +394,7 @@ class BetterNormal extends Generator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -402,19 +402,19 @@ class BetterNormal extends Generator {
} }
} }
return ++ $y; return $y++;
} }
/* /*
* Re registers all biomes for async * Re registers all biomes for async
*/ */
public function reRegisterBiomes() { public function reRegisterBiomes() {
$reflection = new \ReflectionClass ( 'pocketmine\\level\\generator\\biome\\Biome' ); $reflection = new \ReflectionClass('pocketmine\\level\\generator\\biome\\Biome');
$register = $reflection->getMethod ( 'register' ); $register = $reflection->getMethod('register');
$register->setAccessible ( true ); $register->setAccessible(true);
foreach ( self::$biomes as $rainfall => $arr ) { foreach(self::$biomes as $rainfall => $arr ) {
foreach ( $arr as $tmp => $biome ) { foreach($arr as $tmp => $biome ) {
$register->invoke ( null, $biome->getId (), $biome ); $register->invoke(null, $biome->getId (), $biome);
} }
} }
} }

View file

@ -41,7 +41,7 @@ abstract class AmountPopulator extends Populator {
* @param $random Random * @param $random Random
*/ */
public function getAmount(Random $random) { public function getAmount(Random $random) {
return $this->baseAmount + $random->nextRange ( 0, $this->randomAmount + 1 ); return $this->baseAmount + $random->nextRange(0, $this->randomAmount + 1);
} }
/* /*

View file

@ -36,17 +36,17 @@ class BushPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($y === - 1) { if ($y === -1) {
continue; continue;
} }
$tree = new TreePopulator::$types [$this->type] (); $tree = new TreePopulator::$types [$this->type] ();
$bush = new Bush ( $tree->leafBlock, $tree->leafType ?? $tree->type); $bush = new Bush($tree->leafBlock, $tree->leafType ?? $tree->type);
$bush->placeObject ( $level, $x, $y, $z, $random ); $bush->placeObject($level, $x, $y, $z, $random);
} }
} }
@ -57,7 +57,7 @@ class BushPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -65,6 +65,6 @@ class BushPopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -21,8 +21,8 @@ class CactusPopulator extends AmountPopulator {
* Constructs the class * Constructs the class
*/ */
public function __construct() { public function __construct() {
$this->setBaseAmount ( 1 ); $this->setBaseAmount(1);
$this->setRandomAmount ( 2 ); $this->setRandomAmount(2);
} }
/* /*
@ -34,14 +34,14 @@ class CactusPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
$cactus = new Cactus (); $cactus = new Cactus ();
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX * 16, $chunkX * 16 + 15 ); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange ( $chunkZ * 16, $chunkZ * 16 + 15 ); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== - 1 and $cactus->canPlaceObject ( $level, $x, $y, $z, $random )) { if ($y !== -1 and $cactus->canPlaceObject($level, $x, $y, $z, $random )) {
$cactus->placeObject ( $level, $x, $y, $z ); $cactus->placeObject($level, $x, $y, $z);
} }
} }
} }
@ -53,11 +53,11 @@ class CactusPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) { for($y = 127; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;
} }
} }
return $y === 0 ? - 1 : ++ $y; return $y === 0 ? - 1 : $y++;
} }
} }

View file

@ -29,25 +29,25 @@ class CavePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange ( 10, $this->getHighestWorkableBlock ( $x, $z ) ); $y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z ));
// echo "Generating cave at $x, $y, $z." . PHP_EOL; // echo "Generating cave at $x, $y, $z." . PHP_EOL;
$this->generateCave ( $x, $y, $z, $random ); $this->generateCave($x, $y, $z, $random);
} }
// echo "Finished Populating chunk $chunkX, $chunkZ !" . PHP_EOL; // echo "Finished Populating chunk $chunkX, $chunkZ !" . PHP_EOL;
// Filling water & lava sources randomly // Filling water & lava sources randomly
for($i = 0; $i < $random->nextBoundedInt ( 10 ) + 15; $i ++) { for($i = 0; $i < $random->nextBoundedInt(10 ) + 15; $i ++) {
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange ( 10, $this->getHighestWorkableBlock ( $x, $z ) ); $y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z ));
if ($level->getBlockIdAt ( $x, $y, $z ) == Block::STONE && ($level->getBlockIdAt ( $x + 1, $y, $z ) == Block::AIR || $level->getBlockIdAt ( $x - 1, $y, $z ) == Block::AIR || $level->getBlockIdAt ( $x, $y, $z + 1 ) == Block::AIR || $level->getBlockIdAt ( $x, $y, $z - 1 ) == Block::AIR) && $level->getBlockIdAt ( $x, $y - 1, $z ) !== Block::AIR && $level->getBlockIdAt ( $x, $y + 1, $z ) !== Block::AIR) { if ($level->getBlockIdAt($x, $y, $z ) == Block::STONE && ($level->getBlockIdAt($x + 1, $y, $z ) == Block::AIR || $level->getBlockIdAt($x - 1, $y, $z ) == Block::AIR || $level->getBlockIdAt($x, $y, $z + 1 ) == Block::AIR || $level->getBlockIdAt($x, $y, $z - 1 ) == Block::AIR) && $level->getBlockIdAt($x, $y - 1, $z ) !== Block::AIR && $level->getBlockIdAt($x, $y + 1, $z ) !== Block::AIR) {
if ($y < 40 && $random->nextBoolean ()) { if ($y < 40 && $random->nextBoolean ()) {
$level->setBlockIdAt ( $x, $y, $z, Block::LAVA ); $level->setBlockIdAt($x, $y, $z, Block::LAVA);
} else { } else {
$level->setBlockIdAt ( $x, $y, $z, Block::WATER ); $level->setBlockIdAt($x, $y, $z, Block::WATER);
} }
} }
} }
@ -60,7 +60,7 @@ class CavePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
@ -68,7 +68,7 @@ class CavePopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
/* /*
@ -80,18 +80,17 @@ class CavePopulator extends AmountPopulator {
* @return void * @return void
*/ */
public function generateCave($x, $y, $z, Random $random) { public function generateCave($x, $y, $z, Random $random) {
$generatedBranches = $random->nextBoundedInt ( 10 ) + 1; $generatedBranches = $random->nextBoundedInt(10 ) + 1;
// echo "Num of branch left => " . $generatedBranches . PHP_EOL; // echo "Num of branch left => " . $generatedBranches . PHP_EOL;
foreach ( $gen = $this->generateBranch ( $x, $y, $z, 5, 3, 5, $random ) as $v3 ) { foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) {
$generatedBranches --; $generatedBranches --;
if ($generatedBranches <= 0) { if ($generatedBranches <= 0) {
$gen->send ( self::STOP ); $gen->send(self::STOP);
} else { } else {
$gen->send ( self::CONTINUE ); $gen->send(self::CONTINUE);
} }
} }
} }
/* /*
* Generates a cave branch. * Generates a cave branch.
* @param $x int * @param $x int
@ -105,35 +104,35 @@ class CavePopulator extends AmountPopulator {
* @return void * @return void
*/ */
public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) { public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) {
if (! (yield new Vector3 ( $x, $y, $z ))) { if (! (yield new Vector3($x, $y, $z ))) {
for($i = 0; $i <= 4; $i ++) { for($i = 0; $i <= 4; $i ++) {
BuildingUtils::buildRandom ( $this->level, new Vector3 ( $x, $y, $z ), new Vector3 ( $length - $i, $height - $i, $depth - $i ), $random, Block::get ( Block::AIR ) ); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3($length - $i, $height - $i, $depth - $i ), $random, Block::get(Block::AIR ));
$x += round ( ($random->nextBoundedInt ( round ( 30 * ($length / 10) ) + 1 ) / 10 - 2) ); $x += round(($random->nextBoundedInt(round(30 * ($length / 10) ) + 1 ) / 10 - 2));
$yP = $random->nextRange ( - 14, 14 ); $yP = $random->nextRange(- 14, 14);
if ($yP > 12) { if ($yP > 12) {
$y ++; $y ++;
} elseif ($yP < - 12) { } elseif ($yP < - 12) {
$y --; $y --;
} }
$z += round ( ($random->nextBoundedInt ( round ( 30 * ($depth / 10) ) + 1 ) / 10 - 1) ); $z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1));
return [ ]; return [ ];
} }
} }
$repeat = $random->nextBoundedInt ( 25 ) + 15; $repeat = $random->nextBoundedInt(25 ) + 15;
while ( $repeat -- > 0 ) { while($repeat -- > 0 ) {
// echo "Y => $y; H => $height; L => $length; D => $depth; R => $repeat" . PHP_EOL; // echo "Y => $y; H => $height; L => $length; D => $depth; R => $repeat" . PHP_EOL;
BuildingUtils::buildRandom ( $this->level, new Vector3 ( $x, $y, $z ), new Vector3 ( $length, $height, $depth ), $random, Block::get ( Block::AIR ) ); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3($length, $height, $depth ), $random, Block::get(Block::AIR ));
$x += round ( ($random->nextBoundedInt ( round ( 30 * ($length / 10) ) + 1 ) / 10 - 2) ); $x += round(($random->nextBoundedInt(round(30 * ($length / 10) ) + 1 ) / 10 - 2));
$yP = $random->nextRange ( - 14, 14 ); $yP = $random->nextRange(- 14, 14);
if ($yP > 12) { if ($yP > 12) {
$y ++; $y ++;
} elseif ($yP < - 12) { } elseif ($yP < - 12) {
$y --; $y --;
} }
$z += round ( ($random->nextBoundedInt ( round ( 30 * ($depth / 10) ) + 1 ) / 10 - 1) ); $z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1));
$height += $random->nextBoundedInt ( 3 ) - 1; $height += $random->nextBoundedInt(3 ) - 1;
$length += $random->nextBoundedInt ( 3 ) - 1; $length += $random->nextBoundedInt(3 ) - 1;
$depth += $random->nextBoundedInt ( 3 ) - 1; $depth += $random->nextBoundedInt(3 ) - 1;
if ($height < 3) if ($height < 3)
$height = 3; $height = 3;
if ($length < 3) if ($length < 3)
@ -146,10 +145,10 @@ class CavePopulator extends AmountPopulator {
$length = 7; $length = 7;
if ($height < 7) if ($height < 7)
$height = 7; $height = 7;
if ($random->nextBoundedInt ( 10 ) == 0) { if ($random->nextBoundedInt(10 ) == 0) {
foreach ( $generator = $this->generateBranch ( $x, $y, $z, $length, $height, $depth, $random ) as $gen ) { foreach($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random ) as $gen ) {
if (! (yield $gen)) if (! (yield $gen))
$generator->send ( self::STOP ); $generator->send(self::STOP);
} }
} }
} }

View file

@ -26,14 +26,14 @@ class DeadbushPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX * 16, $chunkX * 16 + 15 ); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange ( $chunkZ * 16, $chunkZ * 16 + 15 ); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== - 1 && $level->getBlockIdAt ( $x, $y - 1, $z ) == Block::SAND) { if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) {
$level->setBlockIdAt ( $x, $y, $z, Block::DEAD_BUSH ); $level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
$level->setBlockDataAt ( $x, $y, $z, 1 ); $level->setBlockDataAt($x, $y, $z, 1);
} }
} }
} }
@ -45,11 +45,11 @@ class DeadbushPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) { for($y = 127; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;
} }
} }
return $y === 0 ? - 1 : ++ $y; return $y === 0 ? - 1 : $y++;
} }
} }

View file

@ -0,0 +1,64 @@
<?php
/*
* FallenTreePopulator from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
*/
namespace Ad5001\BetterGen\populator;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\FallenTree;
use Ad5001\BetterGen\populator\AmountPopulator;
class FallenTreePopulator extends AmountPopulator {
protected $level;
/*
* Constructs the class
* @param $type int
*/
public function __construct() {
$this->setBaseAmount(1);
$this->setRandomAmount(2);
}
/*
* Populate the chunk
* @param $level pocketmine\level\ChunkManager
* @param $chunkX int
* @param $chunkZ int
* @param $random pocketmine\utils\Random
*/
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level;
$amount = $this->getAmount($random);
$fallenTree = new FallenTree();
for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y, $z, $random )) {
$fallenTree->placeObject($level, $x, $y, $z);
}
}
}
/*
* Gets the top block (y) on an x and z axes
* @param $x int
* @param $z int
*/
protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break;
}
}
return $y === 0 ? - 1 : $y++;
}
}

View file

@ -60,7 +60,7 @@ class FloatingIslandPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -68,7 +68,7 @@ class FloatingIslandPopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
@ -138,14 +138,14 @@ class FloatingIslandPopulator extends AmountPopulator {
*/ */
public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) { public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) {
$ores = new Ore (); $ores = new Ore ();
$ores->setOreTypes ( [ $ores->setOreTypes([
new OreType ( new CoalOre (), 20, 16, $pos->y - $height, $pos->y ), new OreType(new CoalOre (), 20, 16, $pos->y - $height, $pos->y ),
new OreType ( new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)), new OreType(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
new OreType ( new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
new OreType ( new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)),
new OreType ( new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
new OreType ( new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4)) new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
] ); ]);
$ores->populate($level, $x >> 4, $z >> 4, $random); $ores->populate($level, $x >> 4, $z >> 4, $random);
} }
} }

View file

@ -26,14 +26,14 @@ class IglooPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt ( 100 ) > 30) if ($random->nextBoundedInt(100 ) > 30)
return; return;
$igloo = new Igloo (); $igloo = new Igloo ();
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ) - 1; $y = $this->getHighestWorkableBlock($x, $z ) - 1;
if ($igloo->canPlaceObject ( $level, $x, $y, $z, $random )) if ($igloo->canPlaceObject($level, $x, $y, $z, $random ))
$igloo->placeObject ( $level, $x, $y, $z, $random ); $igloo->placeObject($level, $x, $y, $z, $random);
} }
/* /*
@ -43,7 +43,7 @@ class IglooPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -51,6 +51,6 @@ class IglooPopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -27,22 +27,22 @@ class LakePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$ory = $random->nextRange ( 20, 63 ); // Water level $ory = $random->nextRange(20, 63); // Water level
$y = $ory; $y = $ory;
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
$x += $random->nextRange ( - 1, 1 ); $x += $random->nextRange(- 1, 1);
$y += $random->nextRange ( - 1, 1 ); $y += $random->nextRange(- 1, 1);
$z += $random->nextRange ( - 1, 1 ); $z += $random->nextRange(- 1, 1);
if ($level->getBlockIdAt ( $x, $y, $z ) !== Block::AIR) if ($level->getBlockIdAt($x, $y, $z ) !== Block::AIR)
BuildingUtils::buildRandom ( $this->level, new Vector3 ( $x, $y, $z ), new Vector3 ( 5, 5, 5 ), $random, Block::get ( Block::WATER ) ); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3(5, 5, 5 ), $random, Block::get(Block::WATER ));
} }
for($xx = $x - 8; $xx <= $x + 8; $xx ++) for($xx = $x - 8; $xx <= $x + 8; $xx ++)
for($zz = $z - 8; $zz <= $z + 8; $zz ++) for($zz = $z - 8; $zz <= $z + 8; $zz ++)
for($yy = $ory + 1; $yy <= $y + 3; $yy ++) for($yy = $ory + 1; $yy <= $y + 3; $yy ++)
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::WATER) if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::WATER)
$level->setBlockIdAt ( $xx, $yy, $zz, Block::AIR ); $level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
} }
/* /*
@ -52,7 +52,7 @@ class LakePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -60,6 +60,6 @@ class LakePopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -34,31 +34,31 @@ class MineshaftPopulator extends AmountPopulator {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
if ($this->getAmount ( $random ) < 100) if ($this->getAmount($random ) < 100)
return; return;
$this->level = $level; $this->level = $level;
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange ( 5, 50 ); $y = $random->nextRange(5, 50);
// First filling the large dirt place (center of the mineshaft) // First filling the large dirt place (center of the mineshaft)
BuildingUtils::fill ( $level, new Vector3 ( $x - 6, $y, $x - 6 ), new Vector3 ( $x + 6, $y + 8, $z + 6 ), Block::get ( Block::AIR ) ); BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6 ), new Vector3($x + 6, $y + 8, $z + 6 ), Block::get(Block::AIR ));
BuildingUtils::fill ( $level, new Vector3 ( $x - 6, $y, $x - 6 ), new Vector3 ( $x + 6, $y, $z + 6 ), Block::get ( Block::DIRT ) ); BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6 ), new Vector3($x + 6, $y, $z + 6 ), Block::get(Block::DIRT ));
$startingPath = $random->nextBoundedInt ( 4 ); $startingPath = $random->nextBoundedInt(4);
$this->maxPath = $random->nextBoundedInt ( 100 ) + 50; $this->maxPath = $random->nextBoundedInt(100 ) + 50;
foreach ( array_fill ( 0, $startingPath, 1 ) as $hey ) { foreach(array_fill(0, $startingPath, 1 ) as $hey ) {
$dir = $random->nextBoundedInt ( 4 ); $dir = $random->nextBoundedInt(4);
switch ($dir) { switch ($dir) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart ( $x + 6, $y + $random->nextBoundedInt ( 5 ), $z + $random->nextBoundedInt ( 12 ) - 6, $dir, $random ); $this->generateMineshaftPart($x + 6, $y + $random->nextBoundedInt(5 ), $z + $random->nextBoundedInt(12 ) - 6, $dir, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$this->generateMineshaftPart ( $x - 6, $y + $random->nextBoundedInt ( 5 ), $z + $random->nextBoundedInt ( 12 ) - 6, $dir, $random ); $this->generateMineshaftPart($x - 6, $y + $random->nextBoundedInt(5 ), $z + $random->nextBoundedInt(12 ) - 6, $dir, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$this->generateMineshaftPart ( $x + $random->nextBoundedInt ( 12 ) - 6, $y + $random->nextBoundedInt ( 8 ), $z + 6, $dir, $random ); $this->generateMineshaftPart($x + $random->nextBoundedInt(12 ) - 6, $y + $random->nextBoundedInt(8 ), $z + 6, $dir, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$this->generateMineshaftPart ( $x + $random->nextBoundedInt ( 12 ) - 6, $y + $random->nextBoundedInt ( 8 ), $z - 6, $dir, $random ); $this->generateMineshaftPart($x + $random->nextBoundedInt(12 ) - 6, $y + $random->nextBoundedInt(8 ), $z - 6, $dir, $random);
break; break;
} }
} }
@ -76,192 +76,192 @@ class MineshaftPopulator extends AmountPopulator {
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) { public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
if ($this->maxPath -- < 1) if ($this->maxPath -- < 1)
return; return;
$type = $random->nextBoundedInt ( 3 ); $type = $random->nextBoundedInt(3);
$level = $this->level; $level = $this->level;
switch ($type) { switch ($type) {
case self::TYPE_FORWARD : case self::TYPE_FORWARD :
switch ($dir) { switch ($dir) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill ( $this->level, new Vector3 ( $x, $y, $z - 1 ), new Vector3 ( $x + 4, $y + 2, $z + 1 ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x + 4, $y + 2, $z + 1 ), Block::get(Block::AIR ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback ( new Vector3 ( $x, $y - 1, $z - 1 ), new Vector3 ( $x + 4, $y - 1, $z + 1 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback ( new Vector3 ( $x, $y, $z ), new Vector3 ( $x + 4, $y, $z ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
$random = $params [1]; $random = $params [1];
if ($random->nextBoundedInt ( 3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 1 ); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
}, $this->level, $random ); }, $this->level, $random);
// After this, building the floor maintener (the wood structure) // After this, building the floor maintener (the wood structure)
$level->setBlockIdAt ( $x, $y, $z - 1, Block::FENCE ); $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y, $z + 1, Block::FENCE ); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 1, $z - 1, Block::FENCE ); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 1, $z + 1, Block::FENCE ); $level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z + 1, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::TORCH ); $level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt ( $x + 1, $y + 2, $z, 2 ); $level->setBlockDataAt($x + 1, $y + 2, $z, 2);
// Generating chest // Generating chest
if ($random->nextBoundedInt ( 30 ) == 0) { if ($random->nextBoundedInt(30 ) == 0) {
$direction = ( int ) $random->nextBoolean (); $direction =(int ) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = - 1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 = ( int ) $random->nextBoolean (); $direction2 =(int ) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable ( new Vector3 ( $x + $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random ); LootTable::buildLootTable(new Vector3($x + $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt ( 30 ) !== 0) if ($random->nextBoundedInt(30 ) !== 0)
$this->generateMineshaftPart ( $x + 5, $y, $z, $dir, $random ); $this->generateMineshaftPart($x + 5, $y, $z, $dir, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill ( $this->level, new Vector3 ( $x, $y, $z - 1 ), new Vector3 ( $x - 4, $y + 2, $z + 1 ) ); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback ( new Vector3 ( $x, $y - 1, $z - 1 ), new Vector3 ( $x - 4, $y - 1, $z + 1 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback ( new Vector3 ( $x, $y, $z ), new Vector3 ( $x - 4, $y, $z ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
$random = $params [1]; $random = $params [1];
if ($random->nextBoundedInt ( 3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 1 ); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
}, $this->level, $random ); }, $this->level, $random);
// After this, building the floor maintener (the wood structure) // After this, building the floor maintener (the wood structure)
$level->setBlockIdAt ( $x, $y, $z - 1, Block::FENCE ); $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y, $z + 1, Block::FENCE ); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 1, $z - 1, Block::FENCE ); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 1, $z + 1, Block::FENCE ); $level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z + 1, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
$level->setBlockIdAt ( $x - 1, $y + 2, $z, Block::TORCH ); $level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt ( $x - 1, $y + 2, $z, 1 ); $level->setBlockDataAt($x - 1, $y + 2, $z, 1);
// Generating chest // Generating chest
if ($random->nextBoundedInt ( 30 ) == 0) { if ($random->nextBoundedInt(30 ) == 0) {
$direction = ( int ) $random->nextBoolean (); $direction =(int ) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = - 1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 = ( int ) $random->nextBoolean (); $direction2 =(int ) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = $direction2 =
LootTable::buildLootTable ( new Vector3 ( $x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random ); LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt ( 30 ) !== 0) if ($random->nextBoundedInt(30 ) !== 0)
$this->generateMineshaftPart ( $x - 5, $y, $z, $dir, $random ); $this->generateMineshaftPart($x - 5, $y, $z, $dir, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill ( $this->level, new Vector3 ( $x - 1, $y, $z ), new Vector3 ( $x + 1, $y + 2, $z + 4 ) ); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z + 4 ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback ( new Vector3 ( $x - 1, $y - 1, $z ), new Vector3 ( $x + 1, $y - 1, $z + 4 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback ( new Vector3 ( $x, $y, $z ), new Vector3 ( $x, $y, $z + 4 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
$random = $params [1]; $random = $params [1];
if ($random->nextBoundedInt ( 3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 0 ); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
}, $this->level, $random ); }, $this->level, $random);
// After this, building the floor maintener (the wood structure) // After this, building the floor maintener (the wood structure)
$level->setBlockIdAt ( $x - 1, $y, $z, Block::FENCE ); $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE);
$level->setBlockIdAt ( $x + 1, $y, $z, Block::FENCE ); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
$level->setBlockIdAt ( $x - 1, $y + 1, $z, Block::FENCE ); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
$level->setBlockIdAt ( $x + 1, $y + 1, $z, Block::FENCE ); $level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
$level->setBlockIdAt ( $x - 1, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::TORCH ); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt ( $x, $y + 2, $z - 1, 4 ); $level->setBlockDataAt($x, $y + 2, $z - 1, 4);
// Generating chest // Generating chest
if ($random->nextBoundedInt ( 30 ) == 0) { if ($random->nextBoundedInt(30 ) == 0) {
$direction = ( int ) $random->nextBoolean (); $direction =(int ) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = - 1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 = ( int ) $random->nextBoolean (); $direction2 =(int ) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable ( new Vector3 ( $x + $direction, $y, $z + $direction2 ), LootTable::LOOT_MINESHAFT, $random ); LootTable::buildLootTable(new Vector3($x + $direction, $y, $z + $direction2 ), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt ( 30 ) !== 0) if ($random->nextBoundedInt(30 ) !== 0)
$this->generateMineshaftPart ( $x, $y, $z + 5, $dir, $random ); $this->generateMineshaftPart($x, $y, $z + 5, $dir, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill ( $this->level, new Vector3 ( $x - 1, $y, $z ), new Vector3 ( $x + 1, $y + 2, $z - 4 ) ); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback ( new Vector3 ( $x - 1, $y - 1, $z ), new Vector3 ( $x + 1, $y - 1, $z - 4 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback ( new Vector3 ( $x, $y, $z ), new Vector3 ( $x, $y, $z - 4 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
$random = $params [1]; $random = $params [1];
if ($random->nextBoundedInt ( 3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 0 ); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
}, $this->level, $random ); }, $this->level, $random);
// After this, building the floor maintener (the wood structure) // After this, building the floor maintener (the wood structure)
$level->setBlockIdAt ( $x - 1, $y, $z, Block::FENCE ); $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE);
$level->setBlockIdAt ( $x + 1, $y, $z, Block::FENCE ); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
$level->setBlockIdAt ( $x - 1, $y + 1, $z, Block::FENCE ); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
$level->setBlockIdAt ( $x + 1, $y + 1, $z, Block::FENCE ); $level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
$level->setBlockIdAt ( $x - 1, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::PLANK ); $level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::TORCH ); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt ( $x, $y + 2, $z - 1, 3 ); $level->setBlockDataAt($x, $y + 2, $z - 1, 3);
// Generating chest // Generating chest
if ($random->nextBoundedInt ( 30 ) == 0) { if ($random->nextBoundedInt(30 ) == 0) {
$direction = ( int ) $random->nextBoolean (); $direction =(int ) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = - 1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 = ( int ) $random->nextBoolean (); $direction2 =(int ) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable ( new Vector3 ( $x + $direction, $y, $z - $direction2 ), LootTable::LOOT_MINESHAFT, $random ); LootTable::buildLootTable(new Vector3($x + $direction, $y, $z - $direction2 ), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt ( 30 ) !== 0) if ($random->nextBoundedInt(30 ) !== 0)
$this->generateMineshaftPart ( $x, $y, $z - 5, $dir, $random ); $this->generateMineshaftPart($x, $y, $z - 5, $dir, $random);
break; break;
} }
// Doing cobwebs // Doing cobwebs
$webNum = $random->nextBoundedInt ( 5 ) + 2; $webNum = $random->nextBoundedInt(5 ) + 2;
for($i = 0; $i < $webNum; $i ++) { for($i = 0; $i < $webNum; $i ++) {
$xx = $x + $random->nextBoundedInt ( 5 ) - 2; $xx = $x + $random->nextBoundedInt(5 ) - 2;
$yy = $y + $random->nextBoundedInt ( 3 ); $yy = $y + $random->nextBoundedInt(3);
$zz = $z + $random->nextBoundedInt ( 5 ) - 2; $zz = $z + $random->nextBoundedInt(5 ) - 2;
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::AIR) if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR)
$level->setBlockIdAt ( $xx, $yy, $zz, Block::COBWEB ); $level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
} }
break; break;
case self::TYPE_CROSSPATH : case self::TYPE_CROSSPATH :
@ -274,36 +274,36 @@ class MineshaftPopulator extends AmountPopulator {
switch ($dir) { switch ($dir) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$x ++; $x ++;
unset ( $possiblePathes [0] ); unset($possiblePathes [0]);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$x --; $x --;
unset ( $possiblePathes [1] ); unset($possiblePathes [1]);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$z ++; $z ++;
unset ( $possiblePathes [2] ); unset($possiblePathes [2]);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$z --; $z --;
unset ( $possiblePathes [3] ); unset($possiblePathes [3]);
break; break;
} }
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback ( new Vector3 ( $x + 1, $y - 1, $z - 1 ), new Vector3 ( $x - 1, $y - 1, $z + 1 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fill ( $this->level, new Vector3 ( $x - 1, $y, $z - 1 ), new Vector3 ( $x + 1, $y + 6, $z + 1 ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z - 1 ), new Vector3($x + 1, $y + 6, $z + 1 ), Block::get(Block::AIR ));
BuildingUtils::corners ( $this->level, new Vector3 ( $x - 1, $y, $z - 1 ), new Vector3 ( $x + 1, $y + 6, $z + 1 ), Block::get ( Block::PLANK ) ); BuildingUtils::corners($this->level, new Vector3($x - 1, $y, $z - 1 ), new Vector3($x + 1, $y + 6, $z + 1 ), Block::get(Block::PLANK ));
$newFloor = $random->nextBoolean (); $newFloor = $random->nextBoolean ();
$numberFloor = $random->nextBoundedInt ( 4 + ($newFloor ? 5 : 0) ); $numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
$possiblePathes = [ $possiblePathes = [
$possiblePathes, $possiblePathes,
($newFloor ? [ ($newFloor ? [
@ -314,93 +314,93 @@ class MineshaftPopulator extends AmountPopulator {
] : [ ]) ] : [ ])
]; ];
for($i = 7; $i > $newfloor; $i --) { for($i = 7; $i > $newfloor; $i --) {
$chooseNew = ( int ) $newFloor && $random->nextBoolean (); $chooseNew =(int ) $newFloor && $random->nextBoolean ();
$choose = $random->nextBoundedInt ( 4 ); $choose = $random->nextBoundedInt(4);
unset ( $possiblePathes [$chooseNew] [$choose] ); unset($possiblePathes [$chooseNew] [$choose]);
} }
// Buidling pathes // Buidling pathes
foreach ( $possiblePathes [0] as $path ) { foreach($possiblePathes [0] as $path ) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart ( $x + 2, $y, $z, self::DIR_XPLUS, $random ); $this->generateMineshaftPart($x + 2, $y, $z, self::DIR_XPLUS, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$this->generateMineshaftPart ( $x - 2, $y, $z, self::DIR_XMIN, $random ); $this->generateMineshaftPart($x - 2, $y, $z, self::DIR_XMIN, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$this->generateMineshaftPart ( $x, $y, $z + 2, self::DIR_ZPLUS, $random ); $this->generateMineshaftPart($x, $y, $z + 2, self::DIR_ZPLUS, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$this->generateMineshaftPart ( $x, $y, $z - 2, self::DIR_ZMIN, $random ); $this->generateMineshaftPart($x, $y, $z - 2, self::DIR_ZMIN, $random);
break; break;
} }
} }
foreach ( $possiblePathes [1] as $path ) { foreach($possiblePathes [1] as $path ) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart ( $x + 2, $y + 4, $z, self::DIR_XPLUS, $random ); $this->generateMineshaftPart($x + 2, $y + 4, $z, self::DIR_XPLUS, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$this->generateMineshaftPart ( $x - 2, $y + 4, $z, self::DIR_XMIN, $random ); $this->generateMineshaftPart($x - 2, $y + 4, $z, self::DIR_XMIN, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$this->generateMineshaftPart ( $x, $y + 4, $z + 2, self::DIR_ZPLUS, $random ); $this->generateMineshaftPart($x, $y + 4, $z + 2, self::DIR_ZPLUS, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$this->generateMineshaftPart ( $x, $y + 4, $z - 2, self::DIR_ZMIN, $random ); $this->generateMineshaftPart($x, $y + 4, $z - 2, self::DIR_ZMIN, $random);
break; break;
} }
} }
// Doing cobwebs // Doing cobwebs
$webNum = $random->nextBoundedInt ( 5 ) + 2; $webNum = $random->nextBoundedInt(5 ) + 2;
for($i = 0; $i < $webNum; $i ++) { for($i = 0; $i < $webNum; $i ++) {
$xx = $x + $random->nextBoundedInt ( 3 ) - 1; $xx = $x + $random->nextBoundedInt(3 ) - 1;
$yy = $y + $random->nextBoundedInt ( 6 ); $yy = $y + $random->nextBoundedInt(6);
$zz = $z + $random->nextBoundedInt ( 3 ) - 1; $zz = $z + $random->nextBoundedInt(3 ) - 1;
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::AIR) if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR)
$level->setBlockIdAt ( $xx, $yy, $zz, Block::COBWEB ); $level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
} }
break; break;
case self::TYPE_STAIRS : case self::TYPE_STAIRS :
if($y <= 5) { if($y <= 5) {
$this->generateMineshaftPart ( $x, $y, $z, $dir, $random ); $this->generateMineshaftPart($x, $y, $z, $dir, $random);
return; return;
} }
// Building stairs // Building stairs
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
BuildingUtils::fill ( $this->level, new Vector3 ( $x + $i, $y - $i - 1, $z - 2 ), new Vector3 ( $x + $i, $y - $i + 3, $z + 2 ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback ( new Vector3 ( $x + $i, $y - $i - 2, $z - 2 ), new Vector3 ( $x + $i, $y - $i - 2, $z + 2 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
BuildingUtils::fill ( $this->level, new Vector3 ( $x - $i, $y - $i - 1, $z - 2 ), new Vector3 ( $x - $i, $y - $i + 3, $z + 2 ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback ( new Vector3 ( $x - $i, $y - $i - 2, $z - 2 ), new Vector3 ( $x - $i, $y - $i - 2, $z + 2 ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
BuildingUtils::fill ( $this->level, new Vector3 ( $x - 2, $y - $i - 1, $z + $i ), new Vector3 ( $x + 2, $y - $i + 3, $z + $i ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback ( new Vector3 ( $x - 2, $y - $i - 2, $z + $i ), new Vector3 ( $x + 2, $y - $i - 2, $z + $i ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
BuildingUtils::fill ( $this->level, new Vector3 ( $x - 2, $y - $i - 1, $z - $i ), new Vector3 ( $x + 2, $y - $i + 3, $z - $i ), Block::get ( Block::AIR ) ); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback ( new Vector3 ( $x - 2, $y - $i - 2, $z - $i ), new Vector3 ( $x + 2, $y - $i - 2, $z - $i ), function ($v3, $params) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, $params) {
$level = $params [0]; $level = $params [0];
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK ); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level ); }, $this->level);
break; break;
} }
} }
@ -408,16 +408,16 @@ class MineshaftPopulator extends AmountPopulator {
// Next one // Next one
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart ( $x + 4, $y - 4, $z, self::DIR_XPLUS, $random ); $this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$this->generateMineshaftPart ( $x - 4, $y - 4, $z, self::DIR_XMIN, $random ); $this->generateMineshaftPart($x - 4, $y - 4, $z, self::DIR_XMIN, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$this->generateMineshaftPart ( $x, $y - 4, $z + 4, self::DIR_ZPLUS, $random ); $this->generateMineshaftPart($x, $y - 4, $z + 4, self::DIR_ZPLUS, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$this->generateMineshaftPart ( $x, $y - 4, $z - 4, self::DIR_ZMIN, $random ); $this->generateMineshaftPart($x, $y - 4, $z - 4, self::DIR_ZMIN, $random);
break; break;
} }
break; break;

View file

@ -27,18 +27,18 @@ class RavinePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
if ($amount > 50) { // Only build one per chunk if ($amount > 50) { // Only build one per chunk
$depth = $random->nextBoundedInt ( 60 ) + 30; // 2Much4U? $depth = $random->nextBoundedInt(60 ) + 30; // 2Much4U?
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange ( 5, $this->getHighestWorkableBlock ( $x, $z ) ); $y = $random->nextRange(5, $this->getHighestWorkableBlock($x, $z ));
$deffX = $x; $deffX = $x;
$deffZ = $z; $deffZ = $z;
$height = $random->nextRange ( 15, 30 ); $height = $random->nextRange(15, 30);
$length = $random->nextRange ( 5, 12 ); $length = $random->nextRange(5, 12);
for($i = 0; $i < $depth; $i ++) { for($i = 0; $i < $depth; $i ++) {
$this->buildRavinePart ( $x, $y, $z, $height, $length, $random ); $this->buildRavinePart($x, $y, $z, $height, $length, $random);
$diffX = $x - $deffX; $diffX = $x - $deffX;
$diffZ = $z - $deffZ; $diffZ = $z - $deffZ;
if ($diffX > $length / 2) if ($diffX > $length / 2)
@ -53,11 +53,11 @@ class RavinePopulator extends AmountPopulator {
$length = 10; $length = 10;
if ($length < 5) if ($length < 5)
$length = 5; $length = 5;
$x += $random->nextRange ( 0 + $diffX, 2 + $diffX ) - 1; $x += $random->nextRange(0 + $diffX, 2 + $diffX ) - 1;
$y += $random->nextRange ( 0, 2 ) - 1; $y += $random->nextRange(0, 2 ) - 1;
$z += $random->nextRange ( 0 + $diffZ, 2 + $diffZ ) - 1; $z += $random->nextRange(0 + $diffZ, 2 + $diffZ ) - 1;
$heigth += $random->nextRange ( 0, 2 ) - 1; $heigth += $random->nextRange(0, 2 ) - 1;
$length += $random->nextRange ( 0, 2 ) - 1; $length += $random->nextRange(0, 2 ) - 1;
} }
} }
} }
@ -69,7 +69,7 @@ class RavinePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER and $b !== Block::WATER) {
@ -77,7 +77,7 @@ class RavinePopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
/* /*
@ -94,25 +94,25 @@ class RavinePopulator extends AmountPopulator {
for($yy = $y; $yy <= $y + $height; $yy ++) { for($yy = $y; $yy <= $y + $height; $yy ++) {
for($zz = $z - $length; $zz <= $z + $length; $zz ++) { for($zz = $z - $length; $zz <= $z + $length; $zz ++) {
$oldXB = $xBounded; $oldXB = $xBounded;
$xBounded = $random->nextBoundedInt ( self::NOISE * 2 ) - self::NOISE; $xBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE;
$oldZB = $zBounded; $oldZB = $zBounded;
$zBounded = $random->nextBoundedInt ( self::NOISE * 2 ) - self::NOISE; $zBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE;
if ($xBounded > self::NOISE - 2) { if ($xBounded > self::NOISE - 2) {
$xBounded = 1; $xBounded = 1;
} elseif ($xBounded < - self::NOISE + 2) { } elseif ($xBounded < - self::NOISE + 2) {
$xBounded = - 1; $xBounded = -1;
} else { } else {
$xBounded = $oldXB; $xBounded = $oldXB;
} }
if ($zBounded > self::NOISE - 2) { if ($zBounded > self::NOISE - 2) {
$zBounded = 1; $zBounded = 1;
} elseif ($zBounded < - self::NOISE + 2) { } elseif ($zBounded < - self::NOISE + 2) {
$zBounded = - 1; $zBounded = -1;
} else { } else {
$zBounded = $oldZB; $zBounded = $oldZB;
} }
if (abs ( (abs ( $xx ) - abs ( $x )) ** 2 + (abs ( $zz ) - abs ( $z )) ** 2 ) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && ! in_array ( $this->level->getBlockIdAt ( ( int ) round ( $xx ), ( int ) round ( $yy ), ( int ) round ( $zz ) ), BuildingUtils::TO_NOT_OVERWRITE ) && ! in_array ( $this->level->getBlockIdAt ( ( int ) round ( $xx ), ( int ) round ( $yy + 1 ), ( int ) round ( $zz ) ), BuildingUtils::TO_NOT_OVERWRITE )) { if (abs((abs($xx ) - abs($x )) ** 2 + (abs($zz ) - abs($z )) ** 2 ) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && ! in_array($this->level->getBlockIdAt(( int ) round($xx ),(int ) round($yy ),(int ) round($zz ) ), BuildingUtils::TO_NOT_OVERWRITE ) && ! in_array($this->level->getBlockIdAt(( int ) round($xx ),(int ) round($yy + 1 ),(int ) round($zz ) ), BuildingUtils::TO_NOT_OVERWRITE )) {
$this->level->setBlockIdAt ( ( int ) round ( $xx ), ( int ) round ( $yy ), ( int ) round ( $zz ), Block::AIR ); $this->level->setBlockIdAt(( int ) round($xx ),(int ) round($yy ),(int ) round($zz ), Block::AIR);
} }
} }
} }

View file

@ -21,8 +21,8 @@ class SugarCanePopulator extends AmountPopulator {
* Constructs the class * Constructs the class
*/ */
public function __construct() { public function __construct() {
$this->setBaseAmount ( 1 ); $this->setBaseAmount(1);
$this->setRandomAmount ( 2 ); $this->setRandomAmount(2);
} }
/* /*
@ -34,14 +34,14 @@ class SugarCanePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
$sugarcane = new SugarCane (); $sugarcane = new SugarCane ();
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX * 16, $chunkX * 16 + 15 ); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange ( $chunkZ * 16, $chunkZ * 16 + 15 ); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== - 1 and $sugarcane->canPlaceObject ( $level, $x, $y, $z, $random )) { if ($y !== -1 and $sugarcane->canPlaceObject($level, $x, $y, $z, $random )) {
$sugarcane->placeObject ( $level, $x, $y, $z ); $sugarcane->placeObject($level, $x, $y, $z);
} }
} }
} }
@ -53,11 +53,11 @@ class SugarCanePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) { for($y = 127; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;
} }
} }
return $y === 0 ? - 1 : ++ $y; return $y === 0 ? - 1 : $y++;
} }
} }

View file

@ -26,14 +26,14 @@ class TemplePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt ( 1000 ) > 70) if ($random->nextBoundedInt(1000 ) > 70)
return; return;
$temple = new Temple (); $temple = new Temple ();
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($temple->canPlaceObject ( $level, $x, $y, $z, $random )) if ($temple->canPlaceObject($level, $x, $y, $z, $random ))
$temple->placeObject ( $level, $x, $y - 1, $z, $random ); $temple->placeObject($level, $x, $y - 1, $z, $random);
} }
/* /*
@ -43,12 +43,12 @@ class TemplePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -40,17 +40,17 @@ class TreePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount ( $random ); $amount = $this->getAmount($random);
for($i = 0; $i < $amount; ++ $i) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ); $y = $this->getHighestWorkableBlock($x, $z);
if ($y === - 1) { if ($y === -1) {
continue; continue;
} }
$tree = new self::$types [$this->type] (); $tree = new self::$types [$this->type] ();
if ($tree->canPlaceObject ( $level, $x, $y, $z, $random )) { if ($tree->canPlaceObject($level, $x, $y, $z, $random )) {
$tree->placeObject ( $level, $x, $y, $z, $random ); $tree->placeObject($level, $x, $y, $z, $random);
} }
} }
} }
@ -62,7 +62,7 @@ class TreePopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) { } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
@ -70,6 +70,6 @@ class TreePopulator extends AmountPopulator {
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -26,14 +26,14 @@ class WellPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt ( 1000 ) > 25) if ($random->nextBoundedInt(1000 ) > 25)
return; // ~1 chance / 1000 due to building limitations. return; // ~1 chance / 1000 due to building limitations.
$well = new Well (); $well = new Well ();
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 ); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 ); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock ( $x, $z ) - 1; $y = $this->getHighestWorkableBlock($x, $z ) - 1;
if ($well->canPlaceObject ( $level, $x, $y, $z, $random )) if ($well->canPlaceObject($level, $x, $y, $z, $random ))
$well->placeObject ( $level, $x, $y, $z, $random ); $well->placeObject($level, $x, $y, $z, $random);
} }
/* /*
@ -43,12 +43,12 @@ class WellPopulator extends AmountPopulator {
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = 127; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt ( $x, $y, $z ); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;
} }
} }
return ++ $y; return $y++;
} }
} }

View file

@ -47,16 +47,16 @@ class Bush extends Object {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$number = $random->nextBoundedInt ( 6 ); $number = $random->nextBoundedInt(6);
$pos = new Vector3 ( $x, $y, $z ); $pos = new Vector3($x, $y, $z);
$this->placeLeaf ( $pos->x, $pos->y, $pos->z, $level ); $this->placeLeaf($pos->x, $pos->y, $pos->z, $level);
for($i = 0; $i < $number; $i ++) { for($i = 0; $i < $number; $i ++) {
$transfer = $random->nextBoolean (); $transfer = $random->nextBoolean ();
$direction = $random->nextBoundedInt ( 6 ); $direction = $random->nextBoundedInt(6);
$newPos = $pos->getSide ( $direction ); $newPos = $pos->getSide($direction);
if ($transfer) if ($transfer)
$pos = $newPos; $pos = $newPos;
$this->placeLeaf ( $newPos->x, $newPos->y, $newPos->z, $level ); $this->placeLeaf($newPos->x, $newPos->y, $newPos->z, $level);
} }
} }
@ -68,9 +68,9 @@ class Bush extends Object {
* @param $level pocketmine\level\ChunkManager * @param $level pocketmine\level\ChunkManager
*/ */
public function placeLeaf($x, $y, $z, ChunkManager $level) { public function placeLeaf($x, $y, $z, ChunkManager $level) {
if (isset ( $this->overridable [$level->getBlockIdAt ( $x, $y, $z )] ) && ! isset ( $this->overridable [$level->getBlockIdAt ( $x, $y - 1, $z )] )) { if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) {
$level->setBlockIdAt ( $x, $y, $z, $this->leaf [0] ); $level->setBlockIdAt($x, $y, $z, $this->leaf [0]);
$level->setBlockDataAt ( $x, $y, $z, $this->leaf [1] ); $level->setBlockDataAt($x, $y, $z, $this->leaf [1]);
} }
} }
} }

View file

@ -26,10 +26,10 @@ class Cactus extends Object {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt ( 3 ); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt ( $x, $y - 1, $z ); $below = $level->getBlockIdAt($x, $y - 1, $z);
for($yy = $y; $yy <= $y + $totalHeight; $yy ++) { for($yy = $y; $yy <= $y + $totalHeight; $yy ++) {
if ($level->getBlockIdAt ( $x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt ( $x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt ( $x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt ( $x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt ( $x, $yy, $z + 1 ) !== Block::AIR)) { if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) {
return false; return false;
} }
} }
@ -45,10 +45,10 @@ class Cactus extends Object {
*/ */
public function placeObject(ChunkManager $level, int $x, int $y, int $z) { public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
for($yy = 0; $yy < $this->totalHeight; $yy ++) { for($yy = 0; $yy < $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt ( $x, $y + $yy, $z ) != Block::AIR) { if ($level->getBlockIdAt($x, $y + $yy, $z ) != Block::AIR) {
return; return;
} }
$level->setBlockIdAt ( $x, $y + $yy, $z, Block::CACTUS ); $level->setBlockIdAt($x, $y + $yy, $z, Block::CACTUS);
} }
} }
} }

View file

@ -0,0 +1,76 @@
<?php
/*
* Bush from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
*/
namespace Ad5001\BetterGen\structure;
use pocketmine\block\Leaves;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object;
class Bush extends Object {
public $overridable = [
Block::AIR => true,
17 => true,
Block::SNOW_LAYER => true,
Block::LOG2 => true
];
protected $trunk;
protected $direction;
/*
* Constructs the class
* @param $trunkId int
* @param $trunkData int
*/
public function __construct($trunk = Block::WOOD, $trunkData = 0) {
$this->trunk = [
$trunkId,
$trunkData
];
}
/*
* Places a fallen tree
* @param $level pocketmine\level\ChunkManager
* @param $x int
* @param $y int
* @param $z int
* @param $random pocketmine\utils\Random
*/
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$number = $random->nextBoundedInt(6);
$pos = new Vector3($x, $y, $z);
$this->placeLeaf($pos->x, $pos->y, $pos->z, $level);
for($i = 0; $i < $number; $i ++) {
$transfer = $random->nextBoolean ();
$direction = $random->nextBoundedInt(4);
$newPos = $pos->getSide($direction);
if ($transfer)
$pos = $newPos;
$this->placeLeaf($newPos->x, $newPos->y, $newPos->z, $level);
}
}
/*
* Places a Block
* @param $x int
* @param $y int
* @param $z int
* @param $level pocketmine\level\ChunkManager
*/
public function placeBlock($x, $y, $z, ChunkManager $level) {
if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) {
$level->setBlockIdAt($x, $y, $z, $this->trunk [0]);
$level->setBlockDataAt($x, $y, $z, $this->trunk [1]);
}
}
}

View file

@ -38,34 +38,34 @@ class Igloo extends Object {
* @return bool * @return bool
*/ */
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->direction = $random->nextBoundedInt ( 4 ); $this->direction = $random->nextBoundedInt(4);
switch ($this->direction) { switch ($this->direction) {
case 0 : // Entrance is x+ case 0 : // Entrance is x+
for($xx = $x - 3; $xx <= $x + 4; $xx ++) for($xx = $x - 3; $xx <= $x + 4; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
break; break;
case 1 : // Entrance is x- case 1 : // Entrance is x-
for($xx = $x - 4; $xx <= $x + 3; $xx ++) for($xx = $x - 4; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
break; break;
case 2 : // Entrence is z+ case 2 : // Entrence is z+
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
break; break;
case 3 : // Entrance is z- case 3 : // Entrance is z-
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 4; $zz <= $z + 3; $zz ++) for($zz = $z - 4; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
break; break;
} }
@ -81,80 +81,80 @@ class Igloo extends Object {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
if (! isset ( $this->direction ) && ! $this->canPlaceObject ( $level, $x, $y, $z, $random )) if (! isset($this->direction ) && ! $this->canPlaceObject($level, $x, $y, $z, $random ))
return false; return false;
switch ($this->direction) { switch ($this->direction) {
case 0 : // Entrance is x+ case 0 : // Entrance is x+
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 4; $xx ++) for($xx = $x - 3; $xx <= $x + 4; $xx ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
$level->setBlockIdAt ( $x + 3 + $i, $y, $z, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y, $z, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3 + $i, $y + 3, $z, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y + 3, $z, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3 + $i, $y + 1, $z + 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3 + $i, $y + 1, $z - 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y + 1, $z - 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3 + $i, $y + 2, $z + 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y + 2, $z + 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3 + $i, $y + 2, $z - 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3 + $i, $y + 2, $z - 1, Block::SNOW_BLOCK);
} }
// Back // Back
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $x - 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
} }
// Sides // Sides
for($xx = $x - 1; $xx <= $x + 1; $xx ++) { for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
$level->setBlockIdAt ( $xx, $y + 1, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 1, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z + 3, Block::SNOW_BLOCK);
} }
$level->setBlockIdAt ( $x, $y + 1, $z + 3, Block::ICE ); $level->setBlockIdAt($x, $y + 1, $z + 3, Block::ICE);
$level->setBlockIdAt ( $x, $y + 1, $z - 3, Block::ICE ); $level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
// Diags // Diags
for($i = 1; $i <= 2; $i ++) { for($i = 1; $i <= 2; $i ++) {
$level->setBlockIdAt ( $x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
} }
// 2nd layer // 2nd layer
for($i = 0; $i < 3; $i ++) { for($i = 0; $i < 3; $i ++) {
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
} }
// Top // Top
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
} }
// Carpets // Carpets
for($xx = $x - 2; $xx <= $x + 1; $xx ++) for($xx = $x - 2; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 1, $zz, Block::CARPET ); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furnitures
// Bed // Bed
$level->setBlockIdAt ( $x - 1, $y + 1, $z + 2, Block::BED_BLOCK ); $level->setBlockIdAt($x - 1, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockIdAt ( $x, $y + 1, $z + 2, Block::BED_BLOCK ); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockDataAt ( $x - 1, $y + 1, $z + 2, 9 ); $level->setBlockDataAt($x - 1, $y + 1, $z + 2, 9);
$level->setBlockDataAt ( $x, $y + 1, $z + 2, 1 ); $level->setBlockDataAt($x, $y + 1, $z + 2, 1);
// Other // Other
$level->setBlockIdAt ( $x - 1, $y + 1, $z - 2, Block::CRAFTING_TABLE ); $level->setBlockIdAt($x - 1, $y + 1, $z - 2, Block::CRAFTING_TABLE);
$level->setBlockIdAt ( $x, $y + 1, $z - 2, Block::REDSTONE_TORCH ); $level->setBlockIdAt($x, $y + 1, $z - 2, Block::REDSTONE_TORCH);
$level->setBlockIdAt ( $x + 1, $y + 1, $z - 2, Block::FURNACE ); $level->setBlockIdAt($x + 1, $y + 1, $z - 2, Block::FURNACE);
break; break;
@ -163,73 +163,73 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 4; $xx <= $x + 3; $xx ++) for($xx = $x - 4; $xx <= $x + 3; $xx ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
$level->setBlockIdAt ( $x - 3 - $i, $y, $z, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y, $z, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3 - $i, $y + 3, $z, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y + 3, $z, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3 - $i, $y + 1, $z + 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y + 1, $z + 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3 - $i, $y + 1, $z - 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y + 1, $z - 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3 - $i, $y + 2, $z + 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y + 2, $z + 1, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3 - $i, $y + 2, $z - 1, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3 - $i, $y + 2, $z - 1, Block::SNOW_BLOCK);
} }
// Back // Back
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $x + 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
} }
// Sides // Sides
for($xx = $x - 1; $xx <= $x + 1; $xx ++) { for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
$level->setBlockIdAt ( $xx, $y + 1, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 1, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z + 3, Block::SNOW_BLOCK);
} }
$level->setBlockIdAt ( $x, $y + 1, $z + 3, Block::ICE ); $level->setBlockIdAt($x, $y + 1, $z + 3, Block::ICE);
$level->setBlockIdAt ( $x, $y + 1, $z - 3, Block::ICE ); $level->setBlockIdAt($x, $y + 1, $z - 3, Block::ICE);
// Diags // Diags
for($i = 1; $i <= 2; $i ++) { for($i = 1; $i <= 2; $i ++) {
$level->setBlockIdAt ( $x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
} }
// 2nd layer // 2nd layer
for($i = 0; $i < 3; $i ++) { for($i = 0; $i < 3; $i ++) {
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
} }
// Top // Top
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
} }
// Carpets // Carpets
for($xx = $x - 1; $xx <= $x + 2; $xx ++) for($xx = $x - 1; $xx <= $x + 2; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 1, $zz, Block::CARPET ); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furnitures
// Bed // Bed
$level->setBlockIdAt ( $x + 1, $y + 1, $z + 2, Block::BED_BLOCK ); $level->setBlockIdAt($x + 1, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockIdAt ( $x, $y + 1, $z + 2, Block::BED_BLOCK ); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockDataAt ( $x + 1, $y + 1, $z + 2, 11 ); $level->setBlockDataAt($x + 1, $y + 1, $z + 2, 11);
$level->setBlockDataAt ( $x, $y + 1, $z + 2, 3 ); $level->setBlockDataAt($x, $y + 1, $z + 2, 3);
// Other // Other
$level->setBlockIdAt ( $x + 1, $y + 1, $z - 2, Block::CRAFTING_TABLE ); $level->setBlockIdAt($x + 1, $y + 1, $z - 2, Block::CRAFTING_TABLE);
$level->setBlockIdAt ( $x, $y + 1, $z - 2, Block::REDSTONE_TORCH ); $level->setBlockIdAt($x, $y + 1, $z - 2, Block::REDSTONE_TORCH);
$level->setBlockIdAt ( $x - 1, $y + 1, $z - 2, Block::FURNACE ); $level->setBlockIdAt($x - 1, $y + 1, $z - 2, Block::FURNACE);
break; break;
// Third direction // Third direction
@ -237,73 +237,73 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
$level->setBlockIdAt ( $x, $y, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x, $y, $z + 3 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x, $y + 3, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x, $y + 3, $z + 3 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1, $y + 1, $z + 3 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 1, $y + 2, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 1, $y + 2, $z + 3 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1, $y + 2, $z + 3 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1, $y + 2, $z + 3 + $i, Block::SNOW_BLOCK);
} }
// Back // Back
for($xx = $x - 1; $xx <= $x + 1; $xx ++) { for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
$level->setBlockIdAt ( $xx, $y + 1, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z - 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z - 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z - 3, Block::SNOW_BLOCK);
} }
// Sides // Sides
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $x - 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
} }
$level->setBlockIdAt ( $x + 3, $y + 1, $z, Block::ICE ); $level->setBlockIdAt($x + 3, $y + 1, $z, Block::ICE);
$level->setBlockIdAt ( $x - 3, $y + 1, $z, Block::ICE ); $level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
// Diags // Diags
for($i = 1; $i <= 2; $i ++) { for($i = 1; $i <= 2; $i ++) {
$level->setBlockIdAt ( $x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
} }
// 2nd layer // 2nd layer
for($i = 0; $i < 3; $i ++) { for($i = 0; $i < 3; $i ++) {
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
} }
// Top // Top
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
} }
// Carpets // Carpets
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 2; $zz <= $z + 1; $zz ++) { for($zz = $z - 2; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 1, $zz, Block::CARPET ); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furnitures
// Bed // Bed
$level->setBlockIdAt ( $x + 2, $y + 1, $z - 1, Block::BED_BLOCK ); $level->setBlockIdAt($x + 2, $y + 1, $z - 1, Block::BED_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 1, $z, Block::BED_BLOCK ); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK);
$level->setBlockDataAt ( $x + 2, $y + 1, $z - 1, 10 ); $level->setBlockDataAt($x + 2, $y + 1, $z - 1, 10);
$level->setBlockDataAt ( $x + 2, $y + 1, $z, 2 ); $level->setBlockDataAt($x + 2, $y + 1, $z, 2);
// Other // Other
$level->setBlockIdAt ( $x - 2, $y + 1, $z + 1, Block::CRAFTING_TABLE ); $level->setBlockIdAt($x - 2, $y + 1, $z + 1, Block::CRAFTING_TABLE);
$level->setBlockIdAt ( $x - 2, $y + 1, $z, Block::REDSTONE_TORCH ); $level->setBlockIdAt($x - 2, $y + 1, $z, Block::REDSTONE_TORCH);
$level->setBlockIdAt ( $x - 2, $y + 1, $z - 1, Block::FURNACE ); $level->setBlockIdAt($x - 2, $y + 1, $z - 1, Block::FURNACE);
break; break;
// Fourth direction // Fourth direction
@ -311,73 +311,73 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($zz = $z - 4; $zz <= $z + 3; $zz ++) for($zz = $z - 4; $zz <= $z + 3; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
$level->setBlockIdAt ( $x, $y, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x, $y, $z - 3 - $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x, $y + 3, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x, $y + 3, $z - 3 - $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1, $y + 1, $z - 3 - $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 1, $y + 2, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 1, $y + 2, $z - 3 - $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1, $y + 2, $z - 3 - $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1, $y + 2, $z - 3 - $i, Block::SNOW_BLOCK);
} }
// Back // Back
for($xx = $x - 1; $xx <= $x + 1; $xx ++) { for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
$level->setBlockIdAt ( $xx, $y + 1, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 1, $z + 3, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y + 2, $z + 3, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 2, $z + 3, Block::SNOW_BLOCK);
} }
// Sides // Sides
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $x - 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3, $y + 1, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 1, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 3, $y + 2, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
} }
$level->setBlockIdAt ( $x + 3, $y + 1, $z, Block::ICE ); $level->setBlockIdAt($x + 3, $y + 1, $z, Block::ICE);
$level->setBlockIdAt ( $x - 3, $y + 1, $z, Block::ICE ); $level->setBlockIdAt($x - 3, $y + 1, $z, Block::ICE);
// Diags // Diags
for($i = 1; $i <= 2; $i ++) { for($i = 1; $i <= 2; $i ++) {
$level->setBlockIdAt ( $x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + $i, $z - 2, Block::SNOW_BLOCK);
} }
// 2nd layer // 2nd layer
for($i = 0; $i < 3; $i ++) { for($i = 0; $i < 3; $i ++) {
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z + 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 1 + $i, $y + 3, $z - 2, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK ); $level->setBlockIdAt($x - 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK);
} }
// Top // Top
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) { for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK ); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
} }
// Carpets // Carpets
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 2; $zz ++) { for($zz = $z - 1; $zz <= $z + 2; $zz ++) {
$level->setBlockIdAt ( $xx, $y + 1, $zz, Block::CARPET ); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furnitures
// Bed // Bed
$level->setBlockIdAt ( $x + 2, $y + 1, $z + 1, Block::BED_BLOCK ); $level->setBlockIdAt($x + 2, $y + 1, $z + 1, Block::BED_BLOCK);
$level->setBlockIdAt ( $x + 2, $y + 1, $z, Block::BED_BLOCK ); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK);
$level->setBlockDataAt ( $x + 2, $y + 1, $z + 1, 8 ); $level->setBlockDataAt($x + 2, $y + 1, $z + 1, 8);
$level->setBlockDataAt ( $x + 2, $y + 1, $z, 0 ); $level->setBlockDataAt($x + 2, $y + 1, $z, 0);
// Other // Other
$level->setBlockIdAt ( $x - 2, $y + 1, $z - 1, Block::CRAFTING_TABLE ); $level->setBlockIdAt($x - 2, $y + 1, $z - 1, Block::CRAFTING_TABLE);
$level->setBlockIdAt ( $x - 2, $y + 1, $z, Block::REDSTONE_TORCH ); $level->setBlockIdAt($x - 2, $y + 1, $z, Block::REDSTONE_TORCH);
$level->setBlockIdAt ( $x - 2, $y + 1, $z + 1, Block::FURNACE ); $level->setBlockIdAt($x - 2, $y + 1, $z + 1, Block::FURNACE);
break; break;
} }
} }

View file

@ -448,24 +448,24 @@ class SakuraTree extends Tree {
* @param $random $random * @param $random $random
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$percentage = $random->nextBoundedInt ( 100 ); $percentage = $random->nextBoundedInt(100);
if ($percentage > 10) { if ($percentage > 10) {
return; return;
} }
$trunkHeight = 7 + $random->nextBoundedInt ( 7 ); $trunkHeight = 7 + $random->nextBoundedInt(7);
$direction = $random->nextBoundedInt ( 3 ); // Choosing building north east west south $direction = $random->nextBoundedInt(3); // Choosing building north east west south
switch ($direction) { switch ($direction) {
case 0 : case 0 :
$xDiff = 0; $xDiff = 0;
$zDiff = - 1; $zDiff = -1;
break; break;
case 1 : case 1 :
$xDiff = 0; $xDiff = 0;
$zDiff = 1; $zDiff = 1;
break; break;
case 2 : case 2 :
$xDiff = - 1; $xDiff = -1;
$zDiff = 0; $zDiff = 0;
break; break;
case 3 : case 3 :
@ -473,10 +473,10 @@ class SakuraTree extends Tree {
$zDiff = 0; $zDiff = 0;
break; break;
} }
list ( $vParts, $hParts ) = self::TRUNK_POS [$trunkHeight]; list($vParts, $hParts ) = self::TRUNK_POS [$trunkHeight];
$this->setLog ( $level, $x, $y, $z ); $this->setLog($level, $x, $y, $z);
list ( $lastX, $lastY, $lastZ ) = [ list($lastX, $lastY, $lastZ ) = [
$x, $x,
$y, $y,
$z $z
@ -488,8 +488,8 @@ class SakuraTree extends Tree {
$lastX += $xDiff * 2; $lastX += $xDiff * 2;
$lastY ++; $lastY ++;
$lastZ += $zDiff * 2; $lastZ += $zDiff * 2;
$this->setLog ( $level, $lastX - $xDiff, $lastY, $lastZ - $zDiff ); $this->setLog($level, $lastX - $xDiff, $lastY, $lastZ - $zDiff);
$this->setLog ( $level, $lastX, $lastY, $lastZ ); $this->setLog($level, $lastX, $lastY, $lastZ);
} }
} }
@ -497,7 +497,7 @@ class SakuraTree extends Tree {
$lastX += $xDiff; $lastX += $xDiff;
$lastY ++; $lastY ++;
$lastZ += $zDiff; $lastZ += $zDiff;
$this->setLog ( $level, $lastX, $lastY, $lastZ ); $this->setLog($level, $lastX, $lastY, $lastZ);
// Filling verticaly // Filling verticaly
if ($vParts > 0) { if ($vParts > 0) {
@ -505,8 +505,8 @@ class SakuraTree extends Tree {
$lastX += $xDiff; $lastX += $xDiff;
$lastY += 2; $lastY += 2;
$lastZ += $zDiff; $lastZ += $zDiff;
$this->setLog ( $level, $lastX, $lastY - 1, $lastZ ); $this->setLog($level, $lastX, $lastY - 1, $lastZ);
$this->setLog ( $level, $lastX, $lastY, $lastZ ); $this->setLog($level, $lastX, $lastY, $lastZ);
} }
} }
// Filling the top trunk. // Filling the top trunk.
@ -514,26 +514,26 @@ class SakuraTree extends Tree {
$lastY ++; $lastY ++;
$lastZ += $zDiff; $lastZ += $zDiff;
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
$this->setLog ( $level, $lastX, $lastY + $i, $lastZ ); $this->setLog($level, $lastX, $lastY + $i, $lastZ);
} }
$lastY ++; $lastY ++;
// FIlling the branches. // FIlling the branches.
$branchLen2 = function ($base) { $branchLen2 = function ($base) {
return ceil ( $base / 2 ); return ceil($base / 2);
}; };
for($dir = 0; $dir < 4; $dir ++) { for($dir = 0; $dir < 4; $dir ++) {
switch ($dir) { switch ($dir) {
case 0 : case 0 :
$xd = 0; $xd = 0;
$zd = - 1; $zd = -1;
break; break;
case 1 : case 1 :
$xd = 0; $xd = 0;
$zd = 1; $zd = 1;
break; break;
case 2 : case 2 :
$xd = - 1; $xd = -1;
$zd = 0; $zd = 0;
break; break;
case 3 : case 3 :
@ -542,8 +542,8 @@ class SakuraTree extends Tree {
break; break;
} }
$stickLen = round ( $trunkHeight / 3 ); $stickLen = round($trunkHeight / 3);
$stickLen2 = call_user_func ( $branchLen2, $stickLen ); $stickLen2 = call_user_func($branchLen2, $stickLen);
$totalLength = $stickLen + $stickLen2; // Length of the stick $totalLength = $stickLen + $stickLen2; // Length of the stick
$sideLen = $totalLength ** 2; // Side length $sideLen = $totalLength ** 2; // Side length
@ -553,13 +553,13 @@ class SakuraTree extends Tree {
$lZ1 = $lastZ + ($zd * $i); $lZ1 = $lastZ + ($zd * $i);
if ($zd !== 0) if ($zd !== 0)
for($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x ++) { for($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x ++) {
$this->setLeave ( $level, $x, $lastY + 3, $lZ1, $random ); $this->setLeave($level, $x, $lastY + 3, $lZ1, $random);
} }
if ($xd !== 0) if ($xd !== 0)
for($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z ++) { for($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z ++) {
$this->setLeave ( $level, $lX1, $lastY + 3, $z, $random ); $this->setLeave($level, $lX1, $lastY + 3, $z, $random);
} }
$this->setLog ( $level, $lX1, $lastY, $lZ1 ); $this->setLog($level, $lX1, $lastY, $lZ1);
} }
// Second branch part. + second leave part // Second branch part. + second leave part
@ -569,13 +569,13 @@ class SakuraTree extends Tree {
$lZ = $lZ1 + ($zd * $i); $lZ = $lZ1 + ($zd * $i);
if ($zd !== 0) if ($zd !== 0)
for($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x ++) { for($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x ++) {
$this->setLeave ( $level, $x, $lastY + 2, $lZ, $random ); $this->setLeave($level, $x, $lastY + 2, $lZ, $random);
} }
if ($xd !== 0) if ($xd !== 0)
for($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z ++) { for($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z ++) {
$this->setLeave ( $level, $lX, $lastY + 2, $z, $random ); $this->setLeave($level, $lX, $lastY + 2, $z, $random);
} }
$this->setLog ( $level, $lX, $lastY + 1, $lZ ); $this->setLog($level, $lX, $lastY + 1, $lZ);
} }
$lX += $xd; $lX += $xd;
@ -583,15 +583,15 @@ class SakuraTree extends Tree {
// Leaves falling from the tree forward // Leaves falling from the tree forward
if ($lastZ !== $lZ) { // Z has changed, using X for setting if ($lastZ !== $lZ) { // Z has changed, using X for setting
for($x = $lX - $numForward; $x <= $lX + $numForward; $x ++) { for($x = $lX - $numForward; $x <= $lX + $numForward; $x ++) {
$numDown = $random->nextBoundedInt ( 3 ) + 1; $numDown = $random->nextBoundedInt(3 ) + 1;
for($y = $lastY + 1; $y > $lastY - $numDown; $y --) for($y = $lastY + 1; $y > $lastY - $numDown; $y --)
$this->setLeave ( $level, $x, $y, $lZ, $random ); $this->setLeave($level, $x, $y, $lZ, $random);
} }
} else { // Z have stayed, X has changed } else { // Z have stayed, X has changed
for($z = $lZ - $numForward; $z <= $lZ + $numForward; $z ++) { for($z = $lZ - $numForward; $z <= $lZ + $numForward; $z ++) {
$numDown = $random->nextBoundedInt ( 3 ) + 1; $numDown = $random->nextBoundedInt(3 ) + 1;
for($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y --) for($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y --)
$this->setLeave ( $level, $lX, $y, $z, $random ); $this->setLeave($level, $lX, $y, $z, $random);
} }
} }
@ -600,14 +600,14 @@ class SakuraTree extends Tree {
switch ($dir + 1) { switch ($dir + 1) {
case 4 : case 4 :
$xd2 = 0; $xd2 = 0;
$zd2 = - 1; $zd2 = -1;
break; break;
case 1 : case 1 :
$xd2 = 0; $xd2 = 0;
$zd2 = 1; $zd2 = 1;
break; break;
case 2 : case 2 :
$xd2 = - 1; $xd2 = -1;
$zd2 = 0; $zd2 = 0;
break; break;
case 3 : case 3 :
@ -617,15 +617,15 @@ class SakuraTree extends Tree {
} }
// Leaves falling from the tree diagonaly // Leaves falling from the tree diagonaly
foreach ( self::DIAG_LEAVES [$trunkHeight] as $pos ) { foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) {
$numDown = $random->nextBoundedInt ( 3 ) + 1; $numDown = $random->nextBoundedInt(3 ) + 1;
for($y = $lastY + 1; $y > $lastY - $numDown; $y --) for($y = $lastY + 1; $y > $lastY - $numDown; $y --)
$this->setLeave ( $level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random ); $this->setLeave($level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random);
} }
// Additional leaves // Additional leaves
foreach ( self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) { foreach(self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) {
$this->setLeave ( $level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random ); $this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random);
} }
} }
} }
@ -638,8 +638,8 @@ class SakuraTree extends Tree {
* @param $z int * @param $z int
*/ */
public function setLog(ChunkManager $level, $x, $y, $z) { public function setLog(ChunkManager $level, $x, $y, $z) {
$level->setBlockIdAt ( $x, $y, $z, $this->trunkBlock ); $level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
$level->setBlockDataAt ( $x, $y, $z, $this->type ); $level->setBlockDataAt($x, $y, $z, $this->type);
} }
/* /*
@ -655,7 +655,7 @@ class SakuraTree extends Tree {
$this->leafType, $this->leafType,
$this->leaf2Type $this->leaf2Type
] [( int ) $random->nextBoolean ()]; ] [( int ) $random->nextBoolean ()];
$level->setBlockIdAt ( $x, $y, $z, $this->leafBlock ); $level->setBlockIdAt($x, $y, $z, $this->leafBlock);
$level->setBlockDataAt ( $x, $y, $z, $data ); $level->setBlockDataAt($x, $y, $z, $data);
} }
} }

View file

@ -26,9 +26,9 @@ class SugarCane extends Object {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt ( 3 ); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt ( $x, $y - 1, $z ); $below = $level->getBlockIdAt($x, $y - 1, $z);
if (($below == Block::SAND || $below == Block::GRASS) && ($level->getBlockIdAt ( $x + 1, $y - 1, $z ) == Block::WATER || $level->getBlockIdAt ( $x - 1, $y - 1, $z ) == Block::WATER || $level->getBlockIdAt ( $x, $y - 1, $z + 1 ) == Block::WATER || $level->getBlockIdAt ( $x, $y - 1, $z - 1 ) == Block::WATER)) { if (($below == Block::SAND || $below == Block::GRASS) && ($level->getBlockIdAt($x + 1, $y - 1, $z ) == Block::WATER || $level->getBlockIdAt($x - 1, $y - 1, $z ) == Block::WATER || $level->getBlockIdAt($x, $y - 1, $z + 1 ) == Block::WATER || $level->getBlockIdAt($x, $y - 1, $z - 1 ) == Block::WATER)) {
return true; return true;
} }
return false; return false;
@ -43,10 +43,10 @@ class SugarCane extends Object {
*/ */
public function placeObject(ChunkManager $level, int $x, int $y, int $z) { public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
for($yy = 0; $yy < $this->totalHeight; $yy ++) { for($yy = 0; $yy < $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt ( $x, $y + $yy, $z ) != Block::AIR) { if ($level->getBlockIdAt($x, $y + $yy, $z ) != Block::AIR) {
return; return;
} }
$level->setBlockIdAt ( $x, $y + $yy, $z, Block::SUGARCANE_BLOCK ); $level->setBlockIdAt($x, $y + $yy, $z, Block::SUGARCANE_BLOCK);
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -62,7 +62,7 @@ class Well extends Object {
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for($xx = $x - 2; $xx <= $x + 2; $xx ++)
for($yy = $y; $yy <= $y + 3; $yy ++) for($yy = $y; $yy <= $y + 3; $yy ++)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for($zz = $z - 2; $zz <= $z + 2; $zz ++)
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
return true; return true;
} }
@ -77,31 +77,31 @@ class Well extends Object {
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level; $this->level = $level;
foreach ( $this->directions as $direction ) { foreach($this->directions as $direction ) {
// Building pillard // Building pillard
for($yy = $y; $yy < $y + 3; $yy ++) for($yy = $y; $yy < $y + 3; $yy ++)
$this->placeBlock ( $x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE ); $this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE);
// Building corners // Building corners
$this->placeBlock ( $x + ($direction [0] * 2), $y, $z + $direction [1], Block::SANDSTONE ); $this->placeBlock($x + ($direction [0] * 2), $y, $z + $direction [1], Block::SANDSTONE);
$this->placeBlock ( $x + $direction [0], $y, $z + ($direction [1] * 2), Block::SANDSTONE ); $this->placeBlock($x + $direction [0], $y, $z + ($direction [1] * 2), Block::SANDSTONE);
$this->placeBlock ( $x + ($direction [0] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE ); $this->placeBlock($x + ($direction [0] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE);
// Building slabs on the sides. Places two times due to all directions. // Building slabs on the sides. Places two times due to all directions.
$this->placeSlab ( $x + ($direction [0] * 2), $y, $z ); $this->placeSlab($x + ($direction [0] * 2), $y, $z);
$this->placeSlab ( $x, $y, $z + ($direction [1] * 2) ); $this->placeSlab($x, $y, $z + ($direction [1] * 2));
// Placing water.Places two times due to all directions. // Placing water.Places two times due to all directions.
$this->placeBlock ( $x + $direction [0], $y, $z, Block::WATER ); $this->placeBlock($x + $direction [0], $y, $z, Block::WATER);
$this->placeBlock ( $x, $y, $z + $direction [1], Block::WATER ); $this->placeBlock($x, $y, $z + $direction [1], Block::WATER);
} }
// Finitions // Finitions
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for($zz = $z - 1; $zz <= $z + 1; $zz ++)
$this->placeSlab ( $xx, $y + 3, $zz ); $this->placeSlab($xx, $y + 3, $zz);
$this->placeSlab ( $x, $y + 3, $z, Block::SANDSTONE ); $this->placeSlab($x, $y + 3, $z, Block::SANDSTONE);
$this->placeSlab ( $x, $y, $z, Block::WATER ); $this->placeSlab($x, $y, $z, Block::WATER);
} }
/* /*
@ -112,8 +112,8 @@ class Well extends Object {
* @return void * @return void
*/ */
public function placeSlab($x, $y, $z) { public function placeSlab($x, $y, $z) {
$this->level->setBlockIdAt ( $x, $y, $z, 44 ); $this->level->setBlockIdAt($x, $y, $z, 44);
$this->level->setBlockDataAt ( $x, $y, $z, 1 ); $this->level->setBlockDataAt($x, $y, $z, 1);
} }
/* /*
@ -125,6 +125,6 @@ class Well extends Object {
* @return void * @return void
*/ */
public function placeBlock($x, $y, $z, $id) { public function placeBlock($x, $y, $z, $id) {
$this->level->setBlockIdAt ( $x, $y, $z, $id ); $this->level->setBlockIdAt($x, $y, $z, $id);
} }
} }

View file

@ -35,13 +35,13 @@ class BuildingUtils {
*/ */
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) { public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
if ($block == null) if ($block == null)
$block = Block::get ( Block::AIR ); $block = Block::get(Block::AIR);
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($y = $pos1->y; $y >= $pos2->y; $y --) for($y = $pos1->y; $y >= $pos2->y; $y --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt ( $x, $y, $z, $block->getId () ); $level->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt ( $x, $y, $z, $block->getDamage () ); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
} }
} }
@ -54,11 +54,11 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) { public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) {
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($y = $pos1->y; $y >= $pos2->y; $y --) for($y = $pos1->y; $y >= $pos2->y; $y --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
call_user_func ( $call, new Vector3 ( $x, $y, $z ), $params ); call_user_func($call, new Vector3($x, $y, $z ), $params);
} }
} }
@ -71,19 +71,19 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) { for($y = $pos1->y; $y >= $pos2->y; $y --) {
for($x = $pos1->x; $x >= $pos2->x; $x --) { for($x = $pos1->x; $x >= $pos2->x; $x --) {
$level->setBlockIdAt ( $x, $y, $pos1->z, $block->getId () ); $level->setBlockIdAt($x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt ( $x, $y, $pos1->z, $block->getDamage () ); $level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt ( $x, $y, $pos2->z, $block->getId () ); $level->setBlockIdAt($x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt ( $x, $y, $pos2->z, $block->getDamage () ); $level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage ());
} }
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt ( $pos1->x, $y, $z, $block->getId () ); $level->setBlockIdAt($pos1->x, $y, $z, $block->getId ());
$level->setBlockDataAt ( $pos1->x, $y, $z, $block->getDamage () ); $level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage ());
$level->setBlockIdAt ( $pos2->x, $y, $z, $block->getId () ); $level->setBlockIdAt($pos2->x, $y, $z, $block->getId ());
$level->setBlockDataAt ( $pos2->x, $y, $z, $block->getDamage () ); $level->setBlockDataAt($pos2->x, $y, $z, $block->getDamage ());
} }
} }
} }
@ -97,11 +97,11 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt ( $x, $pos1->y, $z, $block->getId () ); $level->setBlockIdAt($x, $pos1->y, $z, $block->getId ());
$level->setBlockDataAt ( $x, $pos1->y, $z, $block->getDamage () ); $level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage ());
} }
} }
@ -114,16 +114,16 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) { for($y = $pos1->y; $y >= $pos2->y; $y --) {
$level->setBlockIdAt ( $pos1->x, $y, $pos1->z, $block->getId () ); $level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt ( $pos1->x, $y, $pos1->z, $block->getDamage () ); $level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt ( $pos2->x, $y, $pos1->z, $block->getId () ); $level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt ( $pos2->x, $y, $pos1->z, $block->getDamage () ); $level->setBlockDataAt($pos2->x, $y, $pos1->z, $block->getDamage ());
$level->setBlockIdAt ( $pos1->x, $y, $pos2->z, $block->getId () ); $level->setBlockIdAt($pos1->x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt ( $pos1->x, $y, $pos2->z, $block->getDamage () ); $level->setBlockDataAt($pos1->x, $y, $pos2->z, $block->getDamage ());
$level->setBlockIdAt ( $pos2->x, $y, $pos2->z, $block->getId () ); $level->setBlockIdAt($pos2->x, $y, $pos2->z, $block->getId ());
$level->setBlockDataAt ( $pos2->x, $y, $pos2->z, $block->getDamage () ); $level->setBlockDataAt($pos2->x, $y, $pos2->z, $block->getDamage ());
} }
} }
@ -136,11 +136,11 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 ); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt ( $x, $pos2->y, $z, $block->getId () ); $level->setBlockIdAt($x, $pos2->y, $z, $block->getId ());
$level->setBlockDataAt ( $x, $pos2->y, $z, $block->getDamage () ); $level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage ());
} }
} }
@ -154,17 +154,17 @@ class BuildingUtils {
* @return void * @return void
*/ */
public function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) { public function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
$xBounded = $random->nextBoundedInt ( 3 ) - 1; $xBounded = $random->nextBoundedInt(3 ) - 1;
$yBounded = $random->nextBoundedInt ( 3 ) - 1; $yBounded = $random->nextBoundedInt(3 ) - 1;
$zBounded = $random->nextBoundedInt ( 3 ) - 1; $zBounded = $random->nextBoundedInt(3 ) - 1;
$pos = $pos->round (); $pos = $pos->round ();
for($x = $pos->x - ($infos->x / 2); $x <= $pos->x + ($infos->x / 2); $x ++) { for($x = $pos->x - ($infos->x / 2); $x <= $pos->x + ($infos->x / 2); $x ++) {
for($y = $pos->y - ($infos->y / 2); $y <= $pos->y + ($infos->y / 2); $y ++) { for($y = $pos->y - ($infos->y / 2); $y <= $pos->y + ($infos->y / 2); $y ++) {
for($z = $pos->z - ($infos->z / 2); $z <= $pos->z + ($infos->z / 2); $z ++) { for($z = $pos->z - ($infos->z / 2); $z <= $pos->z + ($infos->z / 2); $z ++) {
// if(abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < (abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2 // if(abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < (abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2
if (abs ( (abs ( $x ) - abs ( $pos->x )) ** 2 + ($y - $pos->y) ** 2 + (abs ( $z ) - abs ( $pos->z )) ** 2 ) < ((($infos->x / 2 - $xBounded) + ($infos->y / 2 - $yBounded) + ($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && ! in_array ( $level->getBlockIdAt ( $x, $y, $z ), self::TO_NOT_OVERWRITE ) && ! in_array ( $level->getBlockIdAt ( $x, $y + 1, $z ), self::TO_NOT_OVERWRITE )) { if (abs((abs($x ) - abs($pos->x )) ** 2 + ($y - $pos->y) ** 2 + (abs($z ) - abs($pos->z )) ** 2 ) < ((($infos->x / 2 - $xBounded) + ($infos->y / 2 - $yBounded) + ($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && ! in_array($level->getBlockIdAt($x, $y, $z ), self::TO_NOT_OVERWRITE ) && ! in_array($level->getBlockIdAt($x, $y + 1, $z ), self::TO_NOT_OVERWRITE )) {
$level->setBlockIdAt ( $x, $y, $z, $block->getId () ); $level->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt ( $x, $y, $z, $block->getDamage () ); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
} }
} }
} }
@ -178,8 +178,8 @@ class BuildingUtils {
* @return array * @return array
*/ */
protected static function minmax(Vector3 $pos1, Vector3 $pos2): array { protected static function minmax(Vector3 $pos1, Vector3 $pos2): array {
$v1 = new Vector3 ( max ( $pos1->x, $pos2->x ), max ( $pos1->y, $pos2->y ), max ( $pos1->z, $pos2->z ) ); $v1 = new Vector3(max($pos1->x, $pos2->x ), max($pos1->y, $pos2->y ), max($pos1->z, $pos2->z ));
$v2 = new Vector3 ( min ( $pos1->x, $pos2->x ), min ( $pos1->y, $pos2->y ), min ( $pos1->z, $pos2->z ) ); $v2 = new Vector3(min($pos1->x, $pos2->x ), min($pos1->y, $pos2->y ), min($pos1->z, $pos2->z ));
return [ return [
$v1, $v1,
$v2 $v2