Fixing a bad formatting
This commit is contained in:
parent
36956495ee
commit
2d6bb2c679
32 changed files with 1403 additions and 1264 deletions
|
@ -20,51 +20,51 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
|
|||
class BetterDesert extends SandyBiome implements Mountainable {
|
||||
public function __construct() {
|
||||
$deadBush = new DeadbushPopulator ();
|
||||
$deadBush->setBaseAmount ( 1 );
|
||||
$deadBush->setRandomAmount ( 2 );
|
||||
$deadBush->setBaseAmount(1);
|
||||
$deadBush->setRandomAmount(2);
|
||||
|
||||
$cactus = new CactusPopulator ();
|
||||
$cactus->setBaseAmount ( 1 );
|
||||
$cactus->setRandomAmount ( 2 );
|
||||
$cactus->setBaseAmount(1);
|
||||
$cactus->setRandomAmount(2);
|
||||
|
||||
$sugarCane = new SugarCanePopulator ();
|
||||
$sugarCane->setRandomAmount ( 20 );
|
||||
$sugarCane->setBaseAmount ( 3 );
|
||||
$sugarCane->setRandomAmount(20);
|
||||
$sugarCane->setBaseAmount(3);
|
||||
|
||||
$temple = new TemplePopulator ();
|
||||
|
||||
$well = new WellPopulator ();
|
||||
|
||||
$this->addPopulator ( $cactus );
|
||||
$this->addPopulator ( $deadBush );
|
||||
$this->addPopulator ( $sugarCane );
|
||||
$this->addPopulator ( $temple );
|
||||
$this->addPopulator ( $well );
|
||||
$this->addPopulator($cactus);
|
||||
$this->addPopulator($deadBush);
|
||||
$this->addPopulator($sugarCane);
|
||||
$this->addPopulator($temple);
|
||||
$this->addPopulator($well);
|
||||
|
||||
$this->setElevation ( 63, 70 );
|
||||
$this->setElevation(63, 70);
|
||||
// $this->setElevation(66, 70);
|
||||
|
||||
$this->temperature = 0.5;
|
||||
$this->rainfall = 0;
|
||||
$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::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->setGroundCover([
|
||||
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 )
|
||||
]);
|
||||
}
|
||||
public function getName(): string {
|
||||
return "Better Desert";
|
||||
|
|
|
@ -27,24 +27,24 @@ class BetterForest extends ForestBiome implements Mountainable {
|
|||
Main::SAKURA_FOREST
|
||||
];
|
||||
public function __construct($type = 0, array $infos = [0.6, 0.5]) {
|
||||
parent::__construct ( $type );
|
||||
parent::__construct($type);
|
||||
$this->clearPopulators ();
|
||||
|
||||
$this->type = $type;
|
||||
|
||||
$bush = new BushPopulator ( $type );
|
||||
$bush->setBaseAmount ( 10 );
|
||||
$this->addPopulator ( $bush );
|
||||
$trees = new TreePopulator ( $type );
|
||||
$trees->setBaseAmount ( (null !== @constant ( TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant ( TreePopulator::$types [$type] . "::maxPerChunk" ) : 5 );
|
||||
$this->addPopulator ( $trees );
|
||||
$bush = new BushPopulator($type);
|
||||
$bush->setBaseAmount(10);
|
||||
$this->addPopulator($bush);
|
||||
$trees = new TreePopulator($type);
|
||||
$trees->setBaseAmount((null !== @constant(TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant(TreePopulator::$types [$type] . "::maxPerChunk" ) : 5);
|
||||
$this->addPopulator($trees);
|
||||
|
||||
$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->rainfall = $infos [1];
|
||||
|
@ -68,9 +68,9 @@ class BetterForest extends ForestBiome implements Mountainable {
|
|||
* @return 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;
|
||||
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 ) );
|
||||
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 ));
|
||||
}
|
||||
}
|
|
@ -18,21 +18,21 @@ use Ad5001\BetterGen\populator\IglooPopulator;
|
|||
class BetterIcePlains extends SnowyBiome implements Mountainable {
|
||||
public function __construct() {
|
||||
parent::__construct ();
|
||||
$this->setGroundCover ( [
|
||||
Block::get ( Block::SNOW, 0 ),
|
||||
Block::get ( Block::GRASS, 0 ),
|
||||
Block::get ( Block::DIRT, 0 ),
|
||||
Block::get ( Block::DIRT, 0 ),
|
||||
Block::get ( Block::DIRT, 0 )
|
||||
] );
|
||||
$this->addPopulator ( new IglooPopulator () );
|
||||
$this->setGroundCover([
|
||||
Block::get(Block::SNOW, 0 ),
|
||||
Block::get(Block::GRASS, 0 ),
|
||||
Block::get(Block::DIRT, 0 ),
|
||||
Block::get(Block::DIRT, 0 ),
|
||||
Block::get(Block::DIRT, 0 )
|
||||
]);
|
||||
$this->addPopulator(new IglooPopulator ());
|
||||
|
||||
$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->rainfall = 0.8;
|
||||
|
|
|
@ -23,82 +23,82 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
|
|||
class BetterMesa extends SandyBiome {
|
||||
public function __construct() {
|
||||
$deadBush = new DeadbushPopulator ();
|
||||
$deadBush->setBaseAmount ( 1 );
|
||||
$deadBush->setRandomAmount ( 2 );
|
||||
$deadBush->setBaseAmount(1);
|
||||
$deadBush->setRandomAmount(2);
|
||||
|
||||
$cactus = new CactusPopulator ();
|
||||
$cactus->setBaseAmount ( 1 );
|
||||
$cactus->setRandomAmount ( 2 );
|
||||
$cactus->setBaseAmount(1);
|
||||
$cactus->setRandomAmount(2);
|
||||
|
||||
$sugarCane = new SugarCanePopulator ();
|
||||
$sugarCane->setRandomAmount ( 20 );
|
||||
$sugarCane->setBaseAmount ( 3 );
|
||||
$sugarCane->setRandomAmount(20);
|
||||
$sugarCane->setBaseAmount(3);
|
||||
|
||||
$sugarCane = new TreePopulator ();
|
||||
$sugarCane->setRandomAmount ( 2 );
|
||||
$sugarCane->setBaseAmount ( 0 );
|
||||
$sugarCane->setRandomAmount(2);
|
||||
$sugarCane->setBaseAmount(0);
|
||||
|
||||
$ores = new Ore ();
|
||||
$ores->setOreTypes ( [
|
||||
new OreType ( new GoldOre (), 2, 8, 0, 32 )
|
||||
] );
|
||||
$ores->setOreTypes([
|
||||
new OreType(new GoldOre (), 2, 8, 0, 32 )
|
||||
]);
|
||||
|
||||
$this->addPopulator ( $cactus );
|
||||
$this->addPopulator ( $deadBush );
|
||||
$this->addPopulator ( $sugarCane );
|
||||
$this->addPopulator ( $ores );
|
||||
$this->addPopulator($cactus);
|
||||
$this->addPopulator($deadBush);
|
||||
$this->addPopulator($sugarCane);
|
||||
$this->addPopulator($ores);
|
||||
|
||||
$this->setElevation ( 80, 83 );
|
||||
$this->setElevation(80, 83);
|
||||
// $this->setElevation(66, 70);
|
||||
|
||||
$this->temperature = 0.8;
|
||||
$this->rainfall = 0;
|
||||
$this->setGroundCover ( [
|
||||
Block::get ( Block::DIRT, 0 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
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, 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, 7 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
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::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 )
|
||||
] );
|
||||
$this->setGroundCover([
|
||||
Block::get(Block::DIRT, 0 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
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, 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, 7 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
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::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 )
|
||||
]);
|
||||
}
|
||||
public function getName(): string {
|
||||
return "Better Mesa";
|
||||
|
|
|
@ -21,79 +21,79 @@ use Ad5001\BetterGen\populator\SugarCanePopulator;
|
|||
class BetterMesaPlains extends SandyBiome {
|
||||
public function __construct() {
|
||||
$deadBush = new DeadbushPopulator ();
|
||||
$deadBush->setBaseAmount ( 1 );
|
||||
$deadBush->setRandomAmount ( 2 );
|
||||
$deadBush->setBaseAmount(1);
|
||||
$deadBush->setRandomAmount(2);
|
||||
|
||||
$cactus = new CactusPopulator ();
|
||||
$cactus->setBaseAmount ( 1 );
|
||||
$cactus->setRandomAmount ( 2 );
|
||||
$cactus->setBaseAmount(1);
|
||||
$cactus->setRandomAmount(2);
|
||||
|
||||
$sugarCane = new SugarCanePopulator ();
|
||||
$sugarCane->setRandomAmount ( 20 );
|
||||
$sugarCane->setBaseAmount ( 3 );
|
||||
$sugarCane->setRandomAmount(20);
|
||||
$sugarCane->setBaseAmount(3);
|
||||
|
||||
$ores = new Ore ();
|
||||
$ores->setOreTypes ( [
|
||||
new OreType ( new GoldOre (), 20, 8, 0, 32 )
|
||||
] );
|
||||
$ores->setOreTypes([
|
||||
new OreType(new GoldOre (), 20, 8, 0, 32 )
|
||||
]);
|
||||
|
||||
$this->addPopulator ( $cactus );
|
||||
$this->addPopulator ( $deadBush );
|
||||
$this->addPopulator ( $sugarCane );
|
||||
$this->addPopulator ( $ores );
|
||||
$this->addPopulator($cactus);
|
||||
$this->addPopulator($deadBush);
|
||||
$this->addPopulator($sugarCane);
|
||||
$this->addPopulator($ores);
|
||||
|
||||
$this->setElevation ( 62, 67 );
|
||||
$this->setElevation(62, 67);
|
||||
// $this->setElevation(66, 70);
|
||||
|
||||
$this->temperature = 0.6;
|
||||
$this->rainfall = 0;
|
||||
$this->setGroundCover ( [
|
||||
Block::get ( Block::SAND, 1 ),
|
||||
Block::get ( Block::SAND, 1 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get ( Block::HARDENED_CLAY, 0 ),
|
||||
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, 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, 7 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 0 ),
|
||||
Block::get ( Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
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::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 )
|
||||
] );
|
||||
$this->setGroundCover([
|
||||
Block::get(Block::SAND, 1 ),
|
||||
Block::get(Block::SAND, 1 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 1 ),
|
||||
Block::get(Block::HARDENED_CLAY, 0 ),
|
||||
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, 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, 7 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 0 ),
|
||||
Block::get(Block::STAINED_HARDENED_CLAY, 7 ),
|
||||
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::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 )
|
||||
]);
|
||||
}
|
||||
public function getName(): string {
|
||||
return "Better Mesa Plains";
|
||||
|
|
|
@ -16,21 +16,21 @@ class BetterRiver extends Biome {
|
|||
public function __construct() {
|
||||
$this->clearPopulators ();
|
||||
|
||||
$this->setGroundCover ( [
|
||||
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 )
|
||||
] );
|
||||
$this->setGroundCover([
|
||||
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 )
|
||||
]);
|
||||
|
||||
$this->setElevation ( 60, 60 );
|
||||
$this->setElevation(60, 60);
|
||||
|
||||
$this->temperature = 0.5;
|
||||
$this->rainfall = 0.7;
|
||||
|
|
|
@ -30,8 +30,8 @@ class BetterBiomeSelector extends BiomeSelector {
|
|||
public function __construct(Random $random, callable $lookup, Biome $fallback) {
|
||||
$this->fallback = $fallback;
|
||||
$this->lookup = $lookup;
|
||||
$this->temperature = new Simplex ( $random, 2, 1 / 16, 1 / 512 );
|
||||
$this->rainfall = 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);
|
||||
}
|
||||
public function recalculate() {
|
||||
} // Using our own system, No need for that
|
||||
|
@ -39,10 +39,10 @@ class BetterBiomeSelector extends BiomeSelector {
|
|||
$this->biomes [$biome->getId ()] = $biome;
|
||||
}
|
||||
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) {
|
||||
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
|
||||
*/
|
||||
public function pickBiome($x, $z) {
|
||||
$temperature = ($this->getTemperature ( $x, $z ));
|
||||
$rainfall = ($this->getRainfall ( $x, $z ));
|
||||
$temperature = ($this->getTemperature($x, $z ));
|
||||
$rainfall = ($this->getRainfall($x, $z ));
|
||||
|
||||
$biomeId = BetterNormal::getBiome ( $temperature, $rainfall );
|
||||
$biomeId = BetterNormal::getBiome($temperature, $rainfall);
|
||||
// $biomeId = new \Ad5001\BetterGen\biome\BetterDesert();
|
||||
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback));
|
||||
return $b;
|
||||
|
|
|
@ -83,10 +83,10 @@ class BetterNormal extends Generator {
|
|||
$zNoise = 1;
|
||||
}
|
||||
|
||||
$b = $this->selector->pickBiome ( $x + $xNoise - 1, $z + $zNoise - 1 );
|
||||
if ($b instanceof Mountainable && $this->random->nextBoundedInt ( 1000 ) < 3) {
|
||||
$b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
|
||||
if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000 ) < 3) {
|
||||
$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;
|
||||
}
|
||||
|
@ -96,40 +96,40 @@ class BetterNormal extends Generator {
|
|||
|
||||
self::$levels [] = $level;
|
||||
|
||||
$this->random->setSeed ( $this->level->getSeed () );
|
||||
$this->noiseBase = new Simplex ( $this->random, 4, 1 / 4, 1 / 32 );
|
||||
$this->random->setSeed ( $this->level->getSeed () );
|
||||
$this->random->setSeed($this->level->getSeed ());
|
||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
||||
$this->random->setSeed($this->level->getSeed ());
|
||||
|
||||
$this->registerBiome ( Biome::getBiome ( Biome::OCEAN ) );
|
||||
$this->registerBiome ( Biome::getBiome ( Biome::PLAINS ) );
|
||||
$this->registerBiome ( new BetterDesert () );
|
||||
$this->registerBiome ( new BetterMesa () );
|
||||
$this->registerBiome ( new BetterMesaPlains () );
|
||||
$this->registerBiome ( Biome::getBiome ( Biome::TAIGA ) );
|
||||
$this->registerBiome ( Biome::getBiome ( Biome::SWAMP ) );
|
||||
$this->registerBiome ( new BetterRiver () );
|
||||
$this->registerBiome ( new BetterIcePlains () );
|
||||
$this->registerBiome ( new BetterForest ( 0, [
|
||||
$this->registerBiome(Biome::getBiome(Biome::OCEAN ));
|
||||
$this->registerBiome(Biome::getBiome(Biome::PLAINS ));
|
||||
$this->registerBiome(new BetterDesert ());
|
||||
$this->registerBiome(new BetterMesa ());
|
||||
$this->registerBiome(new BetterMesaPlains ());
|
||||
$this->registerBiome(Biome::getBiome(Biome::TAIGA ));
|
||||
$this->registerBiome(Biome::getBiome(Biome::SWAMP ));
|
||||
$this->registerBiome(new BetterRiver ());
|
||||
$this->registerBiome(new BetterIcePlains ());
|
||||
$this->registerBiome(new BetterForest(0, [
|
||||
0.6,
|
||||
0.5
|
||||
] ) );
|
||||
$this->registerBiome ( new BetterForest ( 1, [
|
||||
] ));
|
||||
$this->registerBiome(new BetterForest(1, [
|
||||
0.7,
|
||||
0.8
|
||||
] ) );
|
||||
$this->registerBiome ( new BetterForest ( 2, [
|
||||
] ));
|
||||
$this->registerBiome(new BetterForest(2, [
|
||||
0.6,
|
||||
0.4
|
||||
] ) );
|
||||
] ));
|
||||
|
||||
$this->selector = new BetterBiomeSelector ( $random, [
|
||||
$this->selector = new BetterBiomeSelector($random, [
|
||||
self::class,
|
||||
"getBiome"
|
||||
], self::getBiome ( 0, 0 ) );
|
||||
], self::getBiome(0, 0 ));
|
||||
|
||||
foreach ( self::$biomes as $rain ) {
|
||||
foreach ( $rain as $biome ) {
|
||||
$this->selector->addBiome ( $biome );
|
||||
foreach(self::$biomes as $rain ) {
|
||||
foreach($rain as $biome ) {
|
||||
$this->selector->addBiome($biome);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,41 +139,41 @@ class BetterNormal extends Generator {
|
|||
$this->generationPopulators [] = $cover;
|
||||
|
||||
$cave = new CavePopulator ();
|
||||
$cave->setBaseAmount ( 0 );
|
||||
$cave->setRandomAmount ( 2 );
|
||||
$cave->setBaseAmount(0);
|
||||
$cave->setRandomAmount(2);
|
||||
$this->populators [] = $cave;
|
||||
|
||||
$ravine = new RavinePopulator ();
|
||||
$ravine->setBaseAmount ( 0 );
|
||||
$ravine->setRandomAmount ( 51 );
|
||||
$ravine->setBaseAmount(0);
|
||||
$ravine->setRandomAmount(51);
|
||||
$this->populators [] = $ravine;
|
||||
|
||||
$mineshaft = new MineshaftPopulator ();
|
||||
$mineshaft->setBaseAmount ( 0 );
|
||||
$mineshaft->setRandomAmount ( 102 );
|
||||
$mineshaft->setBaseAmount(0);
|
||||
$mineshaft->setRandomAmount(102);
|
||||
$this->populators [] = $mineshaft;
|
||||
|
||||
$lake = new LakePopulator ();
|
||||
$lake->setBaseAmount ( 0 );
|
||||
$lake->setRandomAmount ( 1 );
|
||||
$lake->setBaseAmount(0);
|
||||
$lake->setRandomAmount(1);
|
||||
$this->generationPopulators [] = $lake;
|
||||
|
||||
$fisl = new FloatingIslandPopulator();
|
||||
$fisl->setBaseAmount ( 0 );
|
||||
$fisl->setRandomAmount ( 132 );
|
||||
$fisl->setBaseAmount(0);
|
||||
$fisl->setRandomAmount(132);
|
||||
$this->populators [] = $fisl;
|
||||
|
||||
$ores = new Ore ();
|
||||
$ores->setOreTypes ( [
|
||||
new OreType ( new CoalOre (), 20, 16, 0, 128 ),
|
||||
new OreType ( new IronOre (), 20, 8, 0, 64 ),
|
||||
new OreType ( new RedstoneOre (), 8, 7, 0, 16 ),
|
||||
new OreType ( new LapisOre (), 1, 6, 0, 32 ),
|
||||
new OreType ( new GoldOre (), 2, 8, 0, 32 ),
|
||||
new OreType ( new DiamondOre (), 1, 7, 0, 16 ),
|
||||
new OreType ( new Dirt (), 20, 32, 0, 128 ),
|
||||
new OreType ( new Gravel (), 10, 16, 0, 128 )
|
||||
] );
|
||||
$ores->setOreTypes([
|
||||
new OreType(new CoalOre (), 20, 16, 0, 128 ),
|
||||
new OreType(new IronOre (), 20, 8, 0, 64 ),
|
||||
new OreType(new RedstoneOre (), 8, 7, 0, 16 ),
|
||||
new OreType(new LapisOre (), 1, 6, 0, 32 ),
|
||||
new OreType(new GoldOre (), 2, 8, 0, 32 ),
|
||||
new OreType(new DiamondOre (), 1, 7, 0, 16 ),
|
||||
new OreType(new Dirt (), 20, 32, 0, 128 ),
|
||||
new OreType(new Gravel (), 10, 16, 0, 128 )
|
||||
]);
|
||||
$this->populators [] = $ores;
|
||||
}
|
||||
|
||||
|
@ -183,14 +183,14 @@ class BetterNormal extends Generator {
|
|||
* @return bool
|
||||
*/
|
||||
public static function registerBiome(Biome $biome): bool {
|
||||
foreach ( self::$levels as $lvl )
|
||||
if (isset ( $lvl->selector ))
|
||||
$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 ()] ))
|
||||
foreach(self::$levels as $lvl )
|
||||
if (isset($lvl->selector ))
|
||||
$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 ()] ))
|
||||
self::$biomes [( string ) $biome->getRainfall ()] = [ ];
|
||||
self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome;
|
||||
ksort ( self::$biomes [( string ) $biome->getRainfall ()] );
|
||||
ksort ( self::$biomes );
|
||||
ksort(self::$biomes [( string ) $biome->getRainfall ()]);
|
||||
ksort(self::$biomes);
|
||||
self::$biomeById[$biome->getId()] = $biome;
|
||||
return true;
|
||||
}
|
||||
|
@ -201,26 +201,26 @@ class BetterNormal extends Generator {
|
|||
* @param $rainfall float
|
||||
*/
|
||||
public static function getBiome($temperature, $rainfall) {
|
||||
if (! isset ( self::$biomes [( string ) round ( $rainfall, 1 )] )) {
|
||||
while ( ! isset ( self::$biomes [( string ) round ( $rainfall, 1 )] ) ) {
|
||||
if (abs ( $rainfall - round ( $rainfall, 1 ) ) >= 0.05)
|
||||
if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) {
|
||||
while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) {
|
||||
if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05)
|
||||
$rainfall += 0.1;
|
||||
if (abs ( $rainfall - round ( $rainfall, 1 ) ) < 0.05)
|
||||
if (abs($rainfall - round($rainfall, 1 ) ) < 0.05)
|
||||
$rainfall -= 0.1;
|
||||
if (round ( $rainfall, 1 ) < 0)
|
||||
if (round($rainfall, 1 ) < 0)
|
||||
$rainfall = 0;
|
||||
if (round ( $rainfall, 1 ) >= 0.9)
|
||||
if (round($rainfall, 1 ) >= 0.9)
|
||||
$rainfall = 0.9;
|
||||
}
|
||||
}
|
||||
$b = self::$biomes [( string ) round ( $rainfall, 1 )];
|
||||
foreach ( $b as $t => $biome ) {
|
||||
if ($temperature <= ( float ) $t) {
|
||||
$b = self::$biomes [( string ) round($rainfall, 1 )];
|
||||
foreach($b as $t => $biome ) {
|
||||
if ($temperature <=(float ) $t) {
|
||||
$ret = $biome;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_string ( $ret )) {
|
||||
if (is_string($ret )) {
|
||||
$ret = new $ret ();
|
||||
} else {
|
||||
return $ret;
|
||||
|
@ -245,36 +245,36 @@ class BetterNormal extends Generator {
|
|||
public function generateChunk($chunkX, $chunkZ) {
|
||||
$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 = [ ];
|
||||
|
||||
for($x = 0; $x < 16; ++ $x) {
|
||||
for($z = 0; $z < 16; ++ $z) {
|
||||
for($x = 0; $x < 16; $x++) {
|
||||
for($z = 0; $z < 16; $z++) {
|
||||
$minSum = 0;
|
||||
$maxSum = 0;
|
||||
$weightSum = 0;
|
||||
|
||||
$biome = $this->pickBiome ( $chunkX * 16 + $x, $chunkZ * 16 + $z );
|
||||
$chunk->setBiomeId ( $x, $z, $biome->getId () );
|
||||
$biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
|
||||
$chunk->setBiomeId($x, $z, $biome->getId ());
|
||||
|
||||
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; ++ $sx) {
|
||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++ $sz) {
|
||||
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||
|
||||
$weight = self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
|
||||
|
||||
if ($sx === 0 and $sz === 0) {
|
||||
$adjacent = $biome;
|
||||
} else {
|
||||
$index = Level::chunkHash ( $chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz );
|
||||
if (isset ( $biomeCache [$index] )) {
|
||||
$index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
||||
if (isset($biomeCache [$index] )) {
|
||||
$adjacent = $biomeCache [$index];
|
||||
} 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;
|
||||
|
@ -289,24 +289,24 @@ class BetterNormal extends Generator {
|
|||
|
||||
$smoothHeight = ($maxSum - $minSum) / 2;
|
||||
|
||||
for($y = 0; $y < 128; ++ $y) {
|
||||
for($y = 0; $y < 128; $y++) {
|
||||
if ($y < 3 || ($y < 5 && $this->random->nextBoolean ())) {
|
||||
$chunk->setBlockId ( $x, $y, $z, Block::BEDROCK );
|
||||
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
||||
continue;
|
||||
}
|
||||
$noiseValue = $noise [$x] [$z] [$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum);
|
||||
|
||||
if ($noiseValue > 0) {
|
||||
$chunk->setBlockId ( $x, $y, $z, Block::STONE );
|
||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||
} 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 ) {
|
||||
$populator->populate ( $this->level, $chunkX, $chunkZ, $this->random );
|
||||
foreach($this->generationPopulators as $populator ) {
|
||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,22 +316,22 @@ class BetterNormal extends Generator {
|
|||
* @param $chunk2 int
|
||||
*/
|
||||
public function populateChunk($chunkX, $chunkZ) {
|
||||
$this->random->setSeed ( 0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed () );
|
||||
foreach ( $this->populators as $populator ) {
|
||||
$populator->populate ( $this->level, $chunkX, $chunkZ, $this->random );
|
||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
|
||||
foreach($this->populators as $populator ) {
|
||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
|
||||
// Filling lava (lakes & rivers underground)...
|
||||
for($x = $chunkX; $x < $chunkX + 16; $x ++)
|
||||
for($z = $chunkZ; $z < $chunkZ + 16; $z ++)
|
||||
for($y = 1; $y < 11; $y ++) {
|
||||
if (! in_array ( $this->level->getBlockIdAt ( $x, $y, $z ), self::NOT_OVERWRITABLE ))
|
||||
$this->level->setBlockIdAt ( $x, $y, $z, Block::LAVA );
|
||||
if (! in_array($this->level->getBlockIdAt($x, $y, $z ), self::NOT_OVERWRITABLE ))
|
||||
$this->level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
||||
}
|
||||
|
||||
$chunk = $this->level->getChunk ( $chunkX, $chunkZ );
|
||||
$biome = Biome::getBiome ( $chunk->getBiomeId ( 7, 7 ) );
|
||||
$biome->populateChunk ( $this->level, $chunkX, $chunkZ, $this->random );
|
||||
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
||||
$biome = Biome::getBiome($chunk->getBiomeId(7, 7 ));
|
||||
$biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -353,13 +353,13 @@ class BetterNormal extends Generator {
|
|||
$bellSize = 1 / 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] = [ ];
|
||||
|
||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++ $sz) {
|
||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||
$bx = $bellSize * $sx;
|
||||
$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 [ ];
|
||||
}
|
||||
public function getSpawn() {
|
||||
return new Vector3 ( 127.5, 128, 127.5 );
|
||||
return new Vector3(127.5, 128, 127.5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a safe spawn location
|
||||
*/
|
||||
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) {
|
||||
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) {
|
||||
break;
|
||||
} 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
|
||||
*/
|
||||
public function reRegisterBiomes() {
|
||||
$reflection = new \ReflectionClass ( 'pocketmine\\level\\generator\\biome\\Biome' );
|
||||
$register = $reflection->getMethod ( 'register' );
|
||||
$register->setAccessible ( true );
|
||||
foreach ( self::$biomes as $rainfall => $arr ) {
|
||||
foreach ( $arr as $tmp => $biome ) {
|
||||
$register->invoke ( null, $biome->getId (), $biome );
|
||||
$reflection = new \ReflectionClass('pocketmine\\level\\generator\\biome\\Biome');
|
||||
$register = $reflection->getMethod('register');
|
||||
$register->setAccessible(true);
|
||||
foreach(self::$biomes as $rainfall => $arr ) {
|
||||
foreach($arr as $tmp => $biome ) {
|
||||
$register->invoke(null, $biome->getId (), $biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ abstract class AmountPopulator extends Populator {
|
|||
* @param $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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -36,17 +36,17 @@ class BushPopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
for($i = 0; $i < $amount; ++ $i) {
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $this->getHighestWorkableBlock ( $x, $z );
|
||||
if ($y === - 1) {
|
||||
$amount = $this->getAmount($random);
|
||||
for($i = 0; $i < $amount; $i++) {
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $this->getHighestWorkableBlock($x, $z);
|
||||
if ($y === -1) {
|
||||
continue;
|
||||
}
|
||||
$tree = new TreePopulator::$types [$this->type] ();
|
||||
$bush = new Bush ( $tree->leafBlock, $tree->leafType ?? $tree->type);
|
||||
$bush->placeObject ( $level, $x, $y, $z, $random );
|
||||
$bush = new Bush($tree->leafBlock, $tree->leafType ?? $tree->type);
|
||||
$bush->placeObject($level, $x, $y, $z, $random);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class BushPopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||
|
@ -65,6 +65,6 @@ class BushPopulator extends AmountPopulator {
|
|||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ class CactusPopulator extends AmountPopulator {
|
|||
* Constructs the class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setBaseAmount ( 1 );
|
||||
$this->setRandomAmount ( 2 );
|
||||
$this->setBaseAmount(1);
|
||||
$this->setRandomAmount(2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,14 +34,14 @@ class CactusPopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
$amount = $this->getAmount($random);
|
||||
$cactus = new Cactus ();
|
||||
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 $cactus->canPlaceObject ( $level, $x, $y, $z, $random )) {
|
||||
$cactus->placeObject ( $level, $x, $y, $z );
|
||||
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 $cactus->canPlaceObject($level, $x, $y, $z, $random )) {
|
||||
$cactus->placeObject($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ class CactusPopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $y === 0 ? - 1 : ++ $y;
|
||||
return $y === 0 ? - 1 : $y++;
|
||||
}
|
||||
}
|
|
@ -29,25 +29,25 @@ class CavePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
for($i = 0; $i < $amount; ++ $i) {
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $random->nextRange ( 10, $this->getHighestWorkableBlock ( $x, $z ) );
|
||||
$amount = $this->getAmount($random);
|
||||
for($i = 0; $i < $amount; $i++) {
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z ));
|
||||
// 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;
|
||||
// Filling water & lava sources randomly
|
||||
for($i = 0; $i < $random->nextBoundedInt ( 10 ) + 15; $i ++) {
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$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) {
|
||||
for($i = 0; $i < $random->nextBoundedInt(10 ) + 15; $i ++) {
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$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 ($y < 40 && $random->nextBoolean ()) {
|
||||
$level->setBlockIdAt ( $x, $y, $z, Block::LAVA );
|
||||
$level->setBlockIdAt($x, $y, $z, Block::LAVA);
|
||||
} 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) {
|
||||
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) {
|
||||
break;
|
||||
} 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
|
||||
*/
|
||||
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;
|
||||
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 --;
|
||||
if ($generatedBranches <= 0) {
|
||||
$gen->send ( self::STOP );
|
||||
$gen->send(self::STOP);
|
||||
} else {
|
||||
$gen->send ( self::CONTINUE );
|
||||
$gen->send(self::CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates a cave branch.
|
||||
* @param $x int
|
||||
|
@ -105,35 +104,35 @@ class CavePopulator extends AmountPopulator {
|
|||
* @return void
|
||||
*/
|
||||
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 ++) {
|
||||
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) );
|
||||
$yP = $random->nextRange ( - 14, 14 );
|
||||
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));
|
||||
$yP = $random->nextRange(- 14, 14);
|
||||
if ($yP > 12) {
|
||||
$y ++;
|
||||
} elseif ($yP < - 12) {
|
||||
$y --;
|
||||
}
|
||||
$z += round ( ($random->nextBoundedInt ( round ( 30 * ($depth / 10) ) + 1 ) / 10 - 1) );
|
||||
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1));
|
||||
return [ ];
|
||||
}
|
||||
}
|
||||
$repeat = $random->nextBoundedInt ( 25 ) + 15;
|
||||
while ( $repeat -- > 0 ) {
|
||||
$repeat = $random->nextBoundedInt(25 ) + 15;
|
||||
while($repeat -- > 0 ) {
|
||||
// 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 ) );
|
||||
$x += round ( ($random->nextBoundedInt ( round ( 30 * ($length / 10) ) + 1 ) / 10 - 2) );
|
||||
$yP = $random->nextRange ( - 14, 14 );
|
||||
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));
|
||||
$yP = $random->nextRange(- 14, 14);
|
||||
if ($yP > 12) {
|
||||
$y ++;
|
||||
} elseif ($yP < - 12) {
|
||||
$y --;
|
||||
}
|
||||
$z += round ( ($random->nextBoundedInt ( round ( 30 * ($depth / 10) ) + 1 ) / 10 - 1) );
|
||||
$height += $random->nextBoundedInt ( 3 ) - 1;
|
||||
$length += $random->nextBoundedInt ( 3 ) - 1;
|
||||
$depth += $random->nextBoundedInt ( 3 ) - 1;
|
||||
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1));
|
||||
$height += $random->nextBoundedInt(3 ) - 1;
|
||||
$length += $random->nextBoundedInt(3 ) - 1;
|
||||
$depth += $random->nextBoundedInt(3 ) - 1;
|
||||
if ($height < 3)
|
||||
$height = 3;
|
||||
if ($length < 3)
|
||||
|
@ -146,10 +145,10 @@ class CavePopulator extends AmountPopulator {
|
|||
$length = 7;
|
||||
if ($height < 7)
|
||||
$height = 7;
|
||||
if ($random->nextBoundedInt ( 10 ) == 0) {
|
||||
foreach ( $generator = $this->generateBranch ( $x, $y, $z, $length, $height, $depth, $random ) as $gen ) {
|
||||
if ($random->nextBoundedInt(10 ) == 0) {
|
||||
foreach($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random ) as $gen ) {
|
||||
if (! (yield $gen))
|
||||
$generator->send ( self::STOP );
|
||||
$generator->send(self::STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ class DeadbushPopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
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 && $level->getBlockIdAt ( $x, $y - 1, $z ) == Block::SAND) {
|
||||
$level->setBlockIdAt ( $x, $y, $z, Block::DEAD_BUSH );
|
||||
$level->setBlockDataAt ( $x, $y, $z, 1 );
|
||||
$amount = $this->getAmount($random);
|
||||
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 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) {
|
||||
$level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
|
||||
$level->setBlockDataAt($x, $y, $z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ class DeadbushPopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $y === 0 ? - 1 : ++ $y;
|
||||
return $y === 0 ? - 1 : $y++;
|
||||
}
|
||||
}
|
64
src/Ad5001/BetterGen/populator/FallenTreePopulator.php
Normal file
64
src/Ad5001/BetterGen/populator/FallenTreePopulator.php
Normal 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++;
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
} 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) {
|
||||
$ores = new Ore ();
|
||||
$ores->setOreTypes ( [
|
||||
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 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 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))
|
||||
] );
|
||||
$ores->setOreTypes([
|
||||
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 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 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))
|
||||
]);
|
||||
$ores->populate($level, $x >> 4, $z >> 4, $random);
|
||||
}
|
||||
}
|
|
@ -26,14 +26,14 @@ class IglooPopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
if ($random->nextBoundedInt ( 100 ) > 30)
|
||||
if ($random->nextBoundedInt(100 ) > 30)
|
||||
return;
|
||||
$igloo = new Igloo ();
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $this->getHighestWorkableBlock ( $x, $z ) - 1;
|
||||
if ($igloo->canPlaceObject ( $level, $x, $y, $z, $random ))
|
||||
$igloo->placeObject ( $level, $x, $y, $z, $random );
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $this->getHighestWorkableBlock($x, $z ) - 1;
|
||||
if ($igloo->canPlaceObject($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) {
|
||||
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) {
|
||||
break;
|
||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||
|
@ -51,6 +51,6 @@ class IglooPopulator extends AmountPopulator {
|
|||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -27,22 +27,22 @@ class LakePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$ory = $random->nextRange ( 20, 63 ); // Water level
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$ory = $random->nextRange(20, 63); // Water level
|
||||
$y = $ory;
|
||||
for($i = 0; $i < 4; $i ++) {
|
||||
$x += $random->nextRange ( - 1, 1 );
|
||||
$y += $random->nextRange ( - 1, 1 );
|
||||
$z += $random->nextRange ( - 1, 1 );
|
||||
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 ) );
|
||||
$x += $random->nextRange(- 1, 1);
|
||||
$y += $random->nextRange(- 1, 1);
|
||||
$z += $random->nextRange(- 1, 1);
|
||||
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 ));
|
||||
}
|
||||
for($xx = $x - 8; $xx <= $x + 8; $xx ++)
|
||||
for($zz = $z - 8; $zz <= $z + 8; $zz ++)
|
||||
for($yy = $ory + 1; $yy <= $y + 3; $yy ++)
|
||||
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::WATER)
|
||||
$level->setBlockIdAt ( $xx, $yy, $zz, Block::AIR );
|
||||
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::WATER)
|
||||
$level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,7 +52,7 @@ class LakePopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||
|
@ -60,6 +60,6 @@ class LakePopulator extends AmountPopulator {
|
|||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -34,31 +34,31 @@ class MineshaftPopulator extends AmountPopulator {
|
|||
* @param $random pocketmine\utils\Random
|
||||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
if ($this->getAmount ( $random ) < 100)
|
||||
if ($this->getAmount($random ) < 100)
|
||||
return;
|
||||
$this->level = $level;
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $random->nextRange ( 5, 50 );
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $random->nextRange(5, 50);
|
||||
// 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, $z + 6 ), Block::get ( Block::DIRT ) );
|
||||
$startingPath = $random->nextBoundedInt ( 4 );
|
||||
$this->maxPath = $random->nextBoundedInt ( 100 ) + 50;
|
||||
foreach ( array_fill ( 0, $startingPath, 1 ) as $hey ) {
|
||||
$dir = $random->nextBoundedInt ( 4 );
|
||||
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 ));
|
||||
$startingPath = $random->nextBoundedInt(4);
|
||||
$this->maxPath = $random->nextBoundedInt(100 ) + 50;
|
||||
foreach(array_fill(0, $startingPath, 1 ) as $hey ) {
|
||||
$dir = $random->nextBoundedInt(4);
|
||||
switch ($dir) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -76,192 +76,192 @@ class MineshaftPopulator extends AmountPopulator {
|
|||
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
|
||||
if ($this->maxPath -- < 1)
|
||||
return;
|
||||
$type = $random->nextBoundedInt ( 3 );
|
||||
$type = $random->nextBoundedInt(3);
|
||||
$level = $this->level;
|
||||
switch ($type) {
|
||||
case self::TYPE_FORWARD :
|
||||
switch ($dir) {
|
||||
case self::DIR_XPLUS :
|
||||
// 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.
|
||||
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];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
// 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];
|
||||
$random = $params [1];
|
||||
if ($random->nextBoundedInt ( 3 ) !== 0) {
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL );
|
||||
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 1 );
|
||||
if ($random->nextBoundedInt(3 ) !== 0) {
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
|
||||
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
|
||||
}
|
||||
}, $this->level, $random );
|
||||
}, $this->level, $random);
|
||||
// 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 + 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, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x, $y + 2, $z + 1, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::TORCH );
|
||||
$level->setBlockDataAt ( $x + 1, $y + 2, $z, 2 );
|
||||
$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 + 2, $z - 1, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
|
||||
$level->setBlockDataAt($x + 1, $y + 2, $z, 2);
|
||||
// Generating chest
|
||||
if ($random->nextBoundedInt ( 30 ) == 0) {
|
||||
$direction = ( int ) $random->nextBoolean ();
|
||||
if ($random->nextBoundedInt(30 ) == 0) {
|
||||
$direction =(int ) $random->nextBoolean ();
|
||||
if ($direction == 0)
|
||||
$direction = - 1; // Choosing the part of the rail.
|
||||
$direction2 = ( int ) $random->nextBoolean ();
|
||||
$direction = -1; // Choosing the part of the rail.
|
||||
$direction2 =(int ) $random->nextBoolean ();
|
||||
if ($direction2 == 0)
|
||||
$direction2 = 2;
|
||||
if ($direction2 == 1)
|
||||
$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)
|
||||
$this->generateMineshaftPart ( $x + 5, $y, $z, $dir, $random );
|
||||
if ($random->nextBoundedInt(30 ) !== 0)
|
||||
$this->generateMineshaftPart($x + 5, $y, $z, $dir, $random);
|
||||
break;
|
||||
case self::DIR_XMIN :
|
||||
// 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.
|
||||
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];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
// 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];
|
||||
$random = $params [1];
|
||||
if ($random->nextBoundedInt ( 3 ) !== 0) {
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL );
|
||||
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 1 );
|
||||
if ($random->nextBoundedInt(3 ) !== 0) {
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
|
||||
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
|
||||
}
|
||||
}, $this->level, $random );
|
||||
}, $this->level, $random);
|
||||
// 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 + 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, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x, $y + 2, $z + 1, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x - 1, $y + 2, $z, Block::TORCH );
|
||||
$level->setBlockDataAt ( $x - 1, $y + 2, $z, 1 );
|
||||
$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 + 2, $z - 1, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
|
||||
$level->setBlockDataAt($x - 1, $y + 2, $z, 1);
|
||||
// Generating chest
|
||||
if ($random->nextBoundedInt ( 30 ) == 0) {
|
||||
$direction = ( int ) $random->nextBoolean ();
|
||||
if ($random->nextBoundedInt(30 ) == 0) {
|
||||
$direction =(int ) $random->nextBoolean ();
|
||||
if ($direction == 0)
|
||||
$direction = - 1; // Choosing the part of the rail.
|
||||
$direction2 = ( int ) $random->nextBoolean ();
|
||||
$direction = -1; // Choosing the part of the rail.
|
||||
$direction2 =(int ) $random->nextBoolean ();
|
||||
if ($direction2 == 0)
|
||||
$direction2 = 2;
|
||||
if ($direction2 == 1)
|
||||
$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)
|
||||
$this->generateMineshaftPart ( $x - 5, $y, $z, $dir, $random );
|
||||
if ($random->nextBoundedInt(30 ) !== 0)
|
||||
$this->generateMineshaftPart($x - 5, $y, $z, $dir, $random);
|
||||
break;
|
||||
case self::DIR_ZPLUS :
|
||||
// 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.
|
||||
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];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
// 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];
|
||||
$random = $params [1];
|
||||
if ($random->nextBoundedInt ( 3 ) !== 0) {
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL );
|
||||
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 0 );
|
||||
if ($random->nextBoundedInt(3 ) !== 0) {
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
|
||||
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
|
||||
}
|
||||
}, $this->level, $random );
|
||||
}, $this->level, $random);
|
||||
// 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 + 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, $y + 2, $z, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::TORCH );
|
||||
$level->setBlockDataAt ( $x, $y + 2, $z - 1, 4 );
|
||||
$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 + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
||||
$level->setBlockDataAt($x, $y + 2, $z - 1, 4);
|
||||
// Generating chest
|
||||
if ($random->nextBoundedInt ( 30 ) == 0) {
|
||||
$direction = ( int ) $random->nextBoolean ();
|
||||
if ($random->nextBoundedInt(30 ) == 0) {
|
||||
$direction =(int ) $random->nextBoolean ();
|
||||
if ($direction == 0)
|
||||
$direction = - 1; // Choosing the part of the rail.
|
||||
$direction2 = ( int ) $random->nextBoolean ();
|
||||
$direction = -1; // Choosing the part of the rail.
|
||||
$direction2 =(int ) $random->nextBoolean ();
|
||||
if ($direction2 == 0)
|
||||
$direction2 = 2;
|
||||
if ($direction2 == 1)
|
||||
$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)
|
||||
$this->generateMineshaftPart ( $x, $y, $z + 5, $dir, $random );
|
||||
if ($random->nextBoundedInt(30 ) !== 0)
|
||||
$this->generateMineshaftPart($x, $y, $z + 5, $dir, $random);
|
||||
break;
|
||||
case self::DIR_ZMIN :
|
||||
// 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.
|
||||
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];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
// 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];
|
||||
$random = $params [1];
|
||||
if ($random->nextBoundedInt ( 3 ) !== 0) {
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::RAIL );
|
||||
$level->setBlockDataAt ( $v3->x, $v3->y, $v3->z, 0 );
|
||||
if ($random->nextBoundedInt(3 ) !== 0) {
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
|
||||
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
|
||||
}
|
||||
}, $this->level, $random );
|
||||
}, $this->level, $random);
|
||||
// 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 + 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, $y + 2, $z, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x + 1, $y + 2, $z, Block::PLANK );
|
||||
$level->setBlockIdAt ( $x, $y + 2, $z - 1, Block::TORCH );
|
||||
$level->setBlockDataAt ( $x, $y + 2, $z - 1, 3 );
|
||||
$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 + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
|
||||
$level->setBlockDataAt($x, $y + 2, $z - 1, 3);
|
||||
// Generating chest
|
||||
if ($random->nextBoundedInt ( 30 ) == 0) {
|
||||
$direction = ( int ) $random->nextBoolean ();
|
||||
if ($random->nextBoundedInt(30 ) == 0) {
|
||||
$direction =(int ) $random->nextBoolean ();
|
||||
if ($direction == 0)
|
||||
$direction = - 1; // Choosing the part of the rail.
|
||||
$direction2 = ( int ) $random->nextBoolean ();
|
||||
$direction = -1; // Choosing the part of the rail.
|
||||
$direction2 =(int ) $random->nextBoolean ();
|
||||
if ($direction2 == 0)
|
||||
$direction2 = 2;
|
||||
if ($direction2 == 1)
|
||||
$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)
|
||||
$this->generateMineshaftPart ( $x, $y, $z - 5, $dir, $random );
|
||||
if ($random->nextBoundedInt(30 ) !== 0)
|
||||
$this->generateMineshaftPart($x, $y, $z - 5, $dir, $random);
|
||||
break;
|
||||
}
|
||||
// Doing cobwebs
|
||||
$webNum = $random->nextBoundedInt ( 5 ) + 2;
|
||||
$webNum = $random->nextBoundedInt(5 ) + 2;
|
||||
for($i = 0; $i < $webNum; $i ++) {
|
||||
$xx = $x + $random->nextBoundedInt ( 5 ) - 2;
|
||||
$yy = $y + $random->nextBoundedInt ( 3 );
|
||||
$zz = $z + $random->nextBoundedInt ( 5 ) - 2;
|
||||
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $xx, $yy, $zz, Block::COBWEB );
|
||||
$xx = $x + $random->nextBoundedInt(5 ) - 2;
|
||||
$yy = $y + $random->nextBoundedInt(3);
|
||||
$zz = $z + $random->nextBoundedInt(5 ) - 2;
|
||||
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR)
|
||||
$level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_CROSSPATH :
|
||||
|
@ -274,36 +274,36 @@ class MineshaftPopulator extends AmountPopulator {
|
|||
switch ($dir) {
|
||||
case self::DIR_XPLUS :
|
||||
$x ++;
|
||||
unset ( $possiblePathes [0] );
|
||||
unset($possiblePathes [0]);
|
||||
break;
|
||||
case self::DIR_XMIN :
|
||||
$x --;
|
||||
unset ( $possiblePathes [1] );
|
||||
unset($possiblePathes [1]);
|
||||
break;
|
||||
case self::DIR_ZPLUS :
|
||||
$z ++;
|
||||
unset ( $possiblePathes [2] );
|
||||
unset($possiblePathes [2]);
|
||||
break;
|
||||
case self::DIR_ZMIN :
|
||||
$z --;
|
||||
unset ( $possiblePathes [3] );
|
||||
unset($possiblePathes [3]);
|
||||
break;
|
||||
}
|
||||
|
||||
// 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];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
// 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 ();
|
||||
$numberFloor = $random->nextBoundedInt ( 4 + ($newFloor ? 5 : 0) );
|
||||
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
||||
$possiblePathes = [
|
||||
$possiblePathes,
|
||||
($newFloor ? [
|
||||
|
@ -314,93 +314,93 @@ class MineshaftPopulator extends AmountPopulator {
|
|||
] : [ ])
|
||||
];
|
||||
for($i = 7; $i > $newfloor; $i --) {
|
||||
$chooseNew = ( int ) $newFloor && $random->nextBoolean ();
|
||||
$choose = $random->nextBoundedInt ( 4 );
|
||||
unset ( $possiblePathes [$chooseNew] [$choose] );
|
||||
$chooseNew =(int ) $newFloor && $random->nextBoolean ();
|
||||
$choose = $random->nextBoundedInt(4);
|
||||
unset($possiblePathes [$chooseNew] [$choose]);
|
||||
}
|
||||
// Buidling pathes
|
||||
foreach ( $possiblePathes [0] as $path ) {
|
||||
foreach($possiblePathes [0] as $path ) {
|
||||
switch ($path) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
foreach ( $possiblePathes [1] as $path ) {
|
||||
foreach($possiblePathes [1] as $path ) {
|
||||
switch ($path) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Doing cobwebs
|
||||
$webNum = $random->nextBoundedInt ( 5 ) + 2;
|
||||
$webNum = $random->nextBoundedInt(5 ) + 2;
|
||||
for($i = 0; $i < $webNum; $i ++) {
|
||||
$xx = $x + $random->nextBoundedInt ( 3 ) - 1;
|
||||
$yy = $y + $random->nextBoundedInt ( 6 );
|
||||
$zz = $z + $random->nextBoundedInt ( 3 ) - 1;
|
||||
if ($level->getBlockIdAt ( $xx, $yy, $zz ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $xx, $yy, $zz, Block::COBWEB );
|
||||
$xx = $x + $random->nextBoundedInt(3 ) - 1;
|
||||
$yy = $y + $random->nextBoundedInt(6);
|
||||
$zz = $z + $random->nextBoundedInt(3 ) - 1;
|
||||
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR)
|
||||
$level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_STAIRS :
|
||||
if($y <= 5) {
|
||||
$this->generateMineshaftPart ( $x, $y, $z, $dir, $random );
|
||||
$this->generateMineshaftPart($x, $y, $z, $dir, $random);
|
||||
return;
|
||||
}
|
||||
// Building stairs
|
||||
for($i = 0; $i < 4; $i ++) {
|
||||
switch ($path) {
|
||||
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::fillCallback ( new Vector3 ( $x + $i, $y - $i - 2, $z - 2 ), new Vector3 ( $x + $i, $y - $i - 2, $z + 2 ), function ($v3, $params) {
|
||||
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) {
|
||||
$level = $params [0];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
break;
|
||||
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::fillCallback ( new Vector3 ( $x - $i, $y - $i - 2, $z - 2 ), new Vector3 ( $x - $i, $y - $i - 2, $z + 2 ), function ($v3, $params) {
|
||||
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) {
|
||||
$level = $params [0];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
break;
|
||||
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::fillCallback ( new Vector3 ( $x - 2, $y - $i - 2, $z + $i ), new Vector3 ( $x + 2, $y - $i - 2, $z + $i ), function ($v3, $params) {
|
||||
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) {
|
||||
$level = $params [0];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
break;
|
||||
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::fillCallback ( new Vector3 ( $x - 2, $y - $i - 2, $z - $i ), new Vector3 ( $x + 2, $y - $i - 2, $z - $i ), function ($v3, $params) {
|
||||
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) {
|
||||
$level = $params [0];
|
||||
if ($level->getBlockIdAt ( $v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt ( $v3->x, $v3->y, $v3->z, Block::PLANK );
|
||||
}, $this->level );
|
||||
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
|
||||
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
|
||||
}, $this->level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -408,16 +408,16 @@ class MineshaftPopulator extends AmountPopulator {
|
|||
// Next one
|
||||
switch ($path) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
|
|
@ -27,18 +27,18 @@ class RavinePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
$amount = $this->getAmount($random);
|
||||
if ($amount > 50) { // Only build one per chunk
|
||||
$depth = $random->nextBoundedInt ( 60 ) + 30; // 2Much4U?
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $random->nextRange ( 5, $this->getHighestWorkableBlock ( $x, $z ) );
|
||||
$depth = $random->nextBoundedInt(60 ) + 30; // 2Much4U?
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $random->nextRange(5, $this->getHighestWorkableBlock($x, $z ));
|
||||
$deffX = $x;
|
||||
$deffZ = $z;
|
||||
$height = $random->nextRange ( 15, 30 );
|
||||
$length = $random->nextRange ( 5, 12 );
|
||||
$height = $random->nextRange(15, 30);
|
||||
$length = $random->nextRange(5, 12);
|
||||
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;
|
||||
$diffZ = $z - $deffZ;
|
||||
if ($diffX > $length / 2)
|
||||
|
@ -53,11 +53,11 @@ class RavinePopulator extends AmountPopulator {
|
|||
$length = 10;
|
||||
if ($length < 5)
|
||||
$length = 5;
|
||||
$x += $random->nextRange ( 0 + $diffX, 2 + $diffX ) - 1;
|
||||
$y += $random->nextRange ( 0, 2 ) - 1;
|
||||
$z += $random->nextRange ( 0 + $diffZ, 2 + $diffZ ) - 1;
|
||||
$heigth += $random->nextRange ( 0, 2 ) - 1;
|
||||
$length += $random->nextRange ( 0, 2 ) - 1;
|
||||
$x += $random->nextRange(0 + $diffX, 2 + $diffX ) - 1;
|
||||
$y += $random->nextRange(0, 2 ) - 1;
|
||||
$z += $random->nextRange(0 + $diffZ, 2 + $diffZ ) - 1;
|
||||
$heigth += $random->nextRange(0, 2 ) - 1;
|
||||
$length += $random->nextRange(0, 2 ) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class RavinePopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
} 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($zz = $z - $length; $zz <= $z + $length; $zz ++) {
|
||||
$oldXB = $xBounded;
|
||||
$xBounded = $random->nextBoundedInt ( self::NOISE * 2 ) - self::NOISE;
|
||||
$xBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE;
|
||||
$oldZB = $zBounded;
|
||||
$zBounded = $random->nextBoundedInt ( self::NOISE * 2 ) - self::NOISE;
|
||||
$zBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE;
|
||||
if ($xBounded > self::NOISE - 2) {
|
||||
$xBounded = 1;
|
||||
} elseif ($xBounded < - self::NOISE + 2) {
|
||||
$xBounded = - 1;
|
||||
$xBounded = -1;
|
||||
} else {
|
||||
$xBounded = $oldXB;
|
||||
}
|
||||
if ($zBounded > self::NOISE - 2) {
|
||||
$zBounded = 1;
|
||||
} elseif ($zBounded < - self::NOISE + 2) {
|
||||
$zBounded = - 1;
|
||||
$zBounded = -1;
|
||||
} else {
|
||||
$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 )) {
|
||||
$this->level->setBlockIdAt ( ( int ) round ( $xx ), ( int ) round ( $yy ), ( int ) round ( $zz ), Block::AIR );
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ class SugarCanePopulator extends AmountPopulator {
|
|||
* Constructs the class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setBaseAmount ( 1 );
|
||||
$this->setRandomAmount ( 2 );
|
||||
$this->setBaseAmount(1);
|
||||
$this->setRandomAmount(2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,14 +34,14 @@ class SugarCanePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
$amount = $this->getAmount($random);
|
||||
$sugarcane = new SugarCane ();
|
||||
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 $sugarcane->canPlaceObject ( $level, $x, $y, $z, $random )) {
|
||||
$sugarcane->placeObject ( $level, $x, $y, $z );
|
||||
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 $sugarcane->canPlaceObject($level, $x, $y, $z, $random )) {
|
||||
$sugarcane->placeObject($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ class SugarCanePopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $y === 0 ? - 1 : ++ $y;
|
||||
return $y === 0 ? - 1 : $y++;
|
||||
}
|
||||
}
|
|
@ -26,14 +26,14 @@ class TemplePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
if ($random->nextBoundedInt ( 1000 ) > 70)
|
||||
if ($random->nextBoundedInt(1000 ) > 70)
|
||||
return;
|
||||
$temple = new Temple ();
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $this->getHighestWorkableBlock ( $x, $z );
|
||||
if ($temple->canPlaceObject ( $level, $x, $y, $z, $random ))
|
||||
$temple->placeObject ( $level, $x, $y - 1, $z, $random );
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $this->getHighestWorkableBlock($x, $z);
|
||||
if ($temple->canPlaceObject($level, $x, $y, $z, $random ))
|
||||
$temple->placeObject($level, $x, $y - 1, $z, $random);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -43,12 +43,12 @@ class TemplePopulator extends AmountPopulator {
|
|||
*/
|
||||
protected function getHighestWorkableBlock($x, $z) {
|
||||
for($y = 127; $y > 0; -- $y) {
|
||||
$b = $this->level->getBlockIdAt ( $x, $y, $z );
|
||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||
if ($b === Block::SAND) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -40,17 +40,17 @@ class TreePopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
$amount = $this->getAmount ( $random );
|
||||
for($i = 0; $i < $amount; ++ $i) {
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $this->getHighestWorkableBlock ( $x, $z );
|
||||
if ($y === - 1) {
|
||||
$amount = $this->getAmount($random);
|
||||
for($i = 0; $i < $amount; $i++) {
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $this->getHighestWorkableBlock($x, $z);
|
||||
if ($y === -1) {
|
||||
continue;
|
||||
}
|
||||
$tree = new self::$types [$this->type] ();
|
||||
if ($tree->canPlaceObject ( $level, $x, $y, $z, $random )) {
|
||||
$tree->placeObject ( $level, $x, $y, $z, $random );
|
||||
if ($tree->canPlaceObject($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) {
|
||||
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) {
|
||||
break;
|
||||
} elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
|
||||
|
@ -70,6 +70,6 @@ class TreePopulator extends AmountPopulator {
|
|||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -26,14 +26,14 @@ class WellPopulator extends AmountPopulator {
|
|||
*/
|
||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||
$this->level = $level;
|
||||
if ($random->nextBoundedInt ( 1000 ) > 25)
|
||||
if ($random->nextBoundedInt(1000 ) > 25)
|
||||
return; // ~1 chance / 1000 due to building limitations.
|
||||
$well = new Well ();
|
||||
$x = $random->nextRange ( $chunkX << 4, ($chunkX << 4) + 15 );
|
||||
$z = $random->nextRange ( $chunkZ << 4, ($chunkZ << 4) + 15 );
|
||||
$y = $this->getHighestWorkableBlock ( $x, $z ) - 1;
|
||||
if ($well->canPlaceObject ( $level, $x, $y, $z, $random ))
|
||||
$well->placeObject ( $level, $x, $y, $z, $random );
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
$y = $this->getHighestWorkableBlock($x, $z ) - 1;
|
||||
if ($well->canPlaceObject($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) {
|
||||
for($y = 127; $y > 0; -- $y) {
|
||||
$b = $this->level->getBlockIdAt ( $x, $y, $z );
|
||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||
if ($b === Block::SAND) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ++ $y;
|
||||
return $y++;
|
||||
}
|
||||
}
|
|
@ -47,16 +47,16 @@ class Bush extends Object {
|
|||
* @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 );
|
||||
$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 ( 6 );
|
||||
$newPos = $pos->getSide ( $direction );
|
||||
$direction = $random->nextBoundedInt(6);
|
||||
$newPos = $pos->getSide($direction);
|
||||
if ($transfer)
|
||||
$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
|
||||
*/
|
||||
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 )] )) {
|
||||
$level->setBlockIdAt ( $x, $y, $z, $this->leaf [0] );
|
||||
$level->setBlockDataAt ( $x, $y, $z, $this->leaf [1] );
|
||||
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->setBlockDataAt($x, $y, $z, $this->leaf [1]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,10 +26,10 @@ class Cactus extends Object {
|
|||
* @param $random pocketmine\utils\Random
|
||||
*/
|
||||
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
||||
$this->totalHeight = 1 + $random->nextBoundedInt ( 3 );
|
||||
$below = $level->getBlockIdAt ( $x, $y - 1, $z );
|
||||
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
||||
$below = $level->getBlockIdAt($x, $y - 1, $z);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ class Cactus extends Object {
|
|||
*/
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
||||
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;
|
||||
}
|
||||
$level->setBlockIdAt ( $x, $y + $yy, $z, Block::CACTUS );
|
||||
$level->setBlockIdAt($x, $y + $yy, $z, Block::CACTUS);
|
||||
}
|
||||
}
|
||||
}
|
76
src/Ad5001/BetterGen/structure/FallenTree.php
Normal file
76
src/Ad5001/BetterGen/structure/FallenTree.php
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,34 +38,34 @@ class Igloo extends Object {
|
|||
* @return bool
|
||||
*/
|
||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||
$this->direction = $random->nextBoundedInt ( 4 );
|
||||
$this->direction = $random->nextBoundedInt(4);
|
||||
switch ($this->direction) {
|
||||
case 0 : // Entrance is x+
|
||||
for($xx = $x - 3; $xx <= $x + 4; $xx ++)
|
||||
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||
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;
|
||||
break;
|
||||
case 1 : // Entrance is x-
|
||||
for($xx = $x - 4; $xx <= $x + 3; $xx ++)
|
||||
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||
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;
|
||||
break;
|
||||
case 2 : // Entrence is z+
|
||||
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||
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;
|
||||
break;
|
||||
case 3 : // Entrance is z-
|
||||
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||
for($yy = $y + 1; $yy <= $y + 4; $yy ++)
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -81,80 +81,80 @@ class Igloo extends Object {
|
|||
* @param $random pocketmine\utils\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;
|
||||
switch ($this->direction) {
|
||||
case 0 : // Entrance is x+
|
||||
// Ground
|
||||
for($xx = $x - 3; $xx <= $x + 4; $xx ++)
|
||||
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
// Entrance
|
||||
for($i = 0; $i < 2; $i ++) {
|
||||
$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 + 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, $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 + 2, $z + 1, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($x + 3 + $i, $y + 2, $z - 1, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Back
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$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 + 1, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($x - 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Sides
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 1, $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 + 2, $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 + 1, $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
|
||||
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
|
||||
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 + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, 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);
|
||||
}
|
||||
|
||||
// Top
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Carpets
|
||||
for($xx = $x - 2; $xx <= $x + 1; $xx ++)
|
||||
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
|
||||
// Bed
|
||||
$level->setBlockIdAt ( $x - 1, $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, $y + 1, $z + 2, 1 );
|
||||
$level->setBlockIdAt($x - 1, $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, $y + 1, $z + 2, 1);
|
||||
// Other
|
||||
$level->setBlockIdAt ( $x - 1, $y + 1, $z - 2, Block::CRAFTING_TABLE );
|
||||
$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::CRAFTING_TABLE);
|
||||
$level->setBlockIdAt($x, $y + 1, $z - 2, Block::REDSTONE_TORCH);
|
||||
$level->setBlockIdAt($x + 1, $y + 1, $z - 2, Block::FURNACE);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -163,73 +163,73 @@ class Igloo extends Object {
|
|||
// Ground
|
||||
for($xx = $x - 4; $xx <= $x + 3; $xx ++)
|
||||
for($zz = $z - 3; $zz <= $z + 3; $zz ++)
|
||||
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
// Entrance
|
||||
for($i = 0; $i < 2; $i ++) {
|
||||
$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 + 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, $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 + 2, $z + 1, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($x - 3 - $i, $y + 2, $z - 1, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Back
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$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 + 1, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($x + 3, $y + 2, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Sides
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 1, $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 + 2, $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 + 1, $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
|
||||
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
|
||||
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 + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, 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);
|
||||
}
|
||||
|
||||
// Top
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Carpets
|
||||
for($xx = $x - 1; $xx <= $x + 2; $xx ++)
|
||||
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
|
||||
// Bed
|
||||
$level->setBlockIdAt ( $x + 1, $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, $y + 1, $z + 2, 3 );
|
||||
$level->setBlockIdAt($x + 1, $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, $y + 1, $z + 2, 3);
|
||||
// Other
|
||||
$level->setBlockIdAt ( $x + 1, $y + 1, $z - 2, Block::CRAFTING_TABLE );
|
||||
$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::CRAFTING_TABLE);
|
||||
$level->setBlockIdAt($x, $y + 1, $z - 2, Block::REDSTONE_TORCH);
|
||||
$level->setBlockIdAt($x - 1, $y + 1, $z - 2, Block::FURNACE);
|
||||
break;
|
||||
|
||||
// Third direction
|
||||
|
@ -237,73 +237,73 @@ class Igloo extends Object {
|
|||
// Ground
|
||||
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||
for($zz = $z - 3; $zz <= $z + 4; $zz ++)
|
||||
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
// Entrance
|
||||
for($i = 0; $i < 2; $i ++) {
|
||||
$level->setBlockIdAt ( $x, $y, $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 + 2, $z + 3 + $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 1, $y + 2, $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 + 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);
|
||||
}
|
||||
|
||||
// Back
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 1, $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 + 2, $z - 3, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Sides
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$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 + 1, $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 + 2, $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 + 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
|
||||
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
|
||||
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 + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, 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);
|
||||
}
|
||||
|
||||
// Top
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Carpets
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
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
|
||||
// Bed
|
||||
$level->setBlockIdAt ( $x + 2, $y + 1, $z - 1, 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, 2 );
|
||||
$level->setBlockIdAt($x + 2, $y + 1, $z - 1, 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, 2);
|
||||
// Other
|
||||
$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 - 1, Block::FURNACE );
|
||||
$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 - 1, Block::FURNACE);
|
||||
break;
|
||||
|
||||
// Fourth direction
|
||||
|
@ -311,73 +311,73 @@ class Igloo extends Object {
|
|||
// Ground
|
||||
for($xx = $x - 3; $xx <= $x + 3; $xx ++)
|
||||
for($zz = $z - 4; $zz <= $z + 3; $zz ++)
|
||||
if (! isset ( $this->overridable [$level->getBlockIdAt ( $xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] ))
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
// Entrance
|
||||
for($i = 0; $i < 2; $i ++) {
|
||||
$level->setBlockIdAt ( $x, $y, $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 + 2, $z - 3 - $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 1, $y + 2, $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 + 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);
|
||||
}
|
||||
|
||||
// Back
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 1, $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 + 2, $z + 3, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Sides
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$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 + 1, $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 + 2, $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 + 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
|
||||
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
|
||||
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 + 2, $y + 3, $z - 1 + $i, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $x - 2, $y + 3, $z - 1 + $i, 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);
|
||||
}
|
||||
|
||||
// Top
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++) {
|
||||
$level->setBlockIdAt ( $xx, $y + 4, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt ( $xx, $y, $zz, Block::SNOW_BLOCK );
|
||||
$level->setBlockIdAt($xx, $y + 4, $zz, Block::SNOW_BLOCK);
|
||||
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
|
||||
}
|
||||
|
||||
// Carpets
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
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
|
||||
// Bed
|
||||
$level->setBlockIdAt ( $x + 2, $y + 1, $z + 1, 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, 0 );
|
||||
$level->setBlockIdAt($x + 2, $y + 1, $z + 1, 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, 0);
|
||||
// Other
|
||||
$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 + 1, Block::FURNACE );
|
||||
$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 + 1, Block::FURNACE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,24 +448,24 @@ class SakuraTree extends Tree {
|
|||
* @param $random $random
|
||||
*/
|
||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||
$percentage = $random->nextBoundedInt ( 100 );
|
||||
$percentage = $random->nextBoundedInt(100);
|
||||
if ($percentage > 10) {
|
||||
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) {
|
||||
case 0 :
|
||||
$xDiff = 0;
|
||||
$zDiff = - 1;
|
||||
$zDiff = -1;
|
||||
break;
|
||||
case 1 :
|
||||
$xDiff = 0;
|
||||
$zDiff = 1;
|
||||
break;
|
||||
case 2 :
|
||||
$xDiff = - 1;
|
||||
$xDiff = -1;
|
||||
$zDiff = 0;
|
||||
break;
|
||||
case 3 :
|
||||
|
@ -473,10 +473,10 @@ class SakuraTree extends Tree {
|
|||
$zDiff = 0;
|
||||
break;
|
||||
}
|
||||
list ( $vParts, $hParts ) = self::TRUNK_POS [$trunkHeight];
|
||||
list($vParts, $hParts ) = self::TRUNK_POS [$trunkHeight];
|
||||
|
||||
$this->setLog ( $level, $x, $y, $z );
|
||||
list ( $lastX, $lastY, $lastZ ) = [
|
||||
$this->setLog($level, $x, $y, $z);
|
||||
list($lastX, $lastY, $lastZ ) = [
|
||||
$x,
|
||||
$y,
|
||||
$z
|
||||
|
@ -488,8 +488,8 @@ class SakuraTree extends Tree {
|
|||
$lastX += $xDiff * 2;
|
||||
$lastY ++;
|
||||
$lastZ += $zDiff * 2;
|
||||
$this->setLog ( $level, $lastX - $xDiff, $lastY, $lastZ - $zDiff );
|
||||
$this->setLog ( $level, $lastX, $lastY, $lastZ );
|
||||
$this->setLog($level, $lastX - $xDiff, $lastY, $lastZ - $zDiff);
|
||||
$this->setLog($level, $lastX, $lastY, $lastZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ class SakuraTree extends Tree {
|
|||
$lastX += $xDiff;
|
||||
$lastY ++;
|
||||
$lastZ += $zDiff;
|
||||
$this->setLog ( $level, $lastX, $lastY, $lastZ );
|
||||
$this->setLog($level, $lastX, $lastY, $lastZ);
|
||||
|
||||
// Filling verticaly
|
||||
if ($vParts > 0) {
|
||||
|
@ -505,8 +505,8 @@ class SakuraTree extends Tree {
|
|||
$lastX += $xDiff;
|
||||
$lastY += 2;
|
||||
$lastZ += $zDiff;
|
||||
$this->setLog ( $level, $lastX, $lastY - 1, $lastZ );
|
||||
$this->setLog ( $level, $lastX, $lastY, $lastZ );
|
||||
$this->setLog($level, $lastX, $lastY - 1, $lastZ);
|
||||
$this->setLog($level, $lastX, $lastY, $lastZ);
|
||||
}
|
||||
}
|
||||
// Filling the top trunk.
|
||||
|
@ -514,26 +514,26 @@ class SakuraTree extends Tree {
|
|||
$lastY ++;
|
||||
$lastZ += $zDiff;
|
||||
for($i = 0; $i < 4; $i ++) {
|
||||
$this->setLog ( $level, $lastX, $lastY + $i, $lastZ );
|
||||
$this->setLog($level, $lastX, $lastY + $i, $lastZ);
|
||||
}
|
||||
$lastY ++;
|
||||
// FIlling the branches.
|
||||
$branchLen2 = function ($base) {
|
||||
return ceil ( $base / 2 );
|
||||
return ceil($base / 2);
|
||||
};
|
||||
|
||||
for($dir = 0; $dir < 4; $dir ++) {
|
||||
switch ($dir) {
|
||||
case 0 :
|
||||
$xd = 0;
|
||||
$zd = - 1;
|
||||
$zd = -1;
|
||||
break;
|
||||
case 1 :
|
||||
$xd = 0;
|
||||
$zd = 1;
|
||||
break;
|
||||
case 2 :
|
||||
$xd = - 1;
|
||||
$xd = -1;
|
||||
$zd = 0;
|
||||
break;
|
||||
case 3 :
|
||||
|
@ -542,8 +542,8 @@ class SakuraTree extends Tree {
|
|||
break;
|
||||
}
|
||||
|
||||
$stickLen = round ( $trunkHeight / 3 );
|
||||
$stickLen2 = call_user_func ( $branchLen2, $stickLen );
|
||||
$stickLen = round($trunkHeight / 3);
|
||||
$stickLen2 = call_user_func($branchLen2, $stickLen);
|
||||
$totalLength = $stickLen + $stickLen2; // Length of the stick
|
||||
$sideLen = $totalLength ** 2; // Side length
|
||||
|
||||
|
@ -553,13 +553,13 @@ class SakuraTree extends Tree {
|
|||
$lZ1 = $lastZ + ($zd * $i);
|
||||
if ($zd !== 0)
|
||||
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)
|
||||
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
|
||||
|
@ -569,13 +569,13 @@ class SakuraTree extends Tree {
|
|||
$lZ = $lZ1 + ($zd * $i);
|
||||
if ($zd !== 0)
|
||||
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)
|
||||
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;
|
||||
|
@ -583,15 +583,15 @@ class SakuraTree extends Tree {
|
|||
// Leaves falling from the tree forward
|
||||
if ($lastZ !== $lZ) { // Z has changed, using X for setting
|
||||
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 --)
|
||||
$this->setLeave ( $level, $x, $y, $lZ, $random );
|
||||
$this->setLeave($level, $x, $y, $lZ, $random);
|
||||
}
|
||||
} else { // Z have stayed, X has changed
|
||||
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 --)
|
||||
$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) {
|
||||
case 4 :
|
||||
$xd2 = 0;
|
||||
$zd2 = - 1;
|
||||
$zd2 = -1;
|
||||
break;
|
||||
case 1 :
|
||||
$xd2 = 0;
|
||||
$zd2 = 1;
|
||||
break;
|
||||
case 2 :
|
||||
$xd2 = - 1;
|
||||
$xd2 = -1;
|
||||
$zd2 = 0;
|
||||
break;
|
||||
case 3 :
|
||||
|
@ -617,15 +617,15 @@ class SakuraTree extends Tree {
|
|||
}
|
||||
|
||||
// Leaves falling from the tree diagonaly
|
||||
foreach ( self::DIAG_LEAVES [$trunkHeight] as $pos ) {
|
||||
$numDown = $random->nextBoundedInt ( 3 ) + 1;
|
||||
foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) {
|
||||
$numDown = $random->nextBoundedInt(3 ) + 1;
|
||||
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
|
||||
foreach ( self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) {
|
||||
$this->setLeave ( $level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random );
|
||||
foreach(self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) {
|
||||
$this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -638,8 +638,8 @@ class SakuraTree extends Tree {
|
|||
* @param $z int
|
||||
*/
|
||||
public function setLog(ChunkManager $level, $x, $y, $z) {
|
||||
$level->setBlockIdAt ( $x, $y, $z, $this->trunkBlock );
|
||||
$level->setBlockDataAt ( $x, $y, $z, $this->type );
|
||||
$level->setBlockIdAt($x, $y, $z, $this->trunkBlock);
|
||||
$level->setBlockDataAt($x, $y, $z, $this->type);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -655,7 +655,7 @@ class SakuraTree extends Tree {
|
|||
$this->leafType,
|
||||
$this->leaf2Type
|
||||
] [( int ) $random->nextBoolean ()];
|
||||
$level->setBlockIdAt ( $x, $y, $z, $this->leafBlock );
|
||||
$level->setBlockDataAt ( $x, $y, $z, $data );
|
||||
$level->setBlockIdAt($x, $y, $z, $this->leafBlock);
|
||||
$level->setBlockDataAt($x, $y, $z, $data);
|
||||
}
|
||||
}
|
|
@ -26,9 +26,9 @@ class SugarCane extends Object {
|
|||
* @param $random pocketmine\utils\Random
|
||||
*/
|
||||
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
|
||||
$this->totalHeight = 1 + $random->nextBoundedInt ( 3 );
|
||||
$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)) {
|
||||
$this->totalHeight = 1 + $random->nextBoundedInt(3);
|
||||
$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)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -43,10 +43,10 @@ class SugarCane extends Object {
|
|||
*/
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
|
||||
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;
|
||||
}
|
||||
$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
|
@ -62,7 +62,7 @@ class Well extends Object {
|
|||
for($xx = $x - 2; $xx <= $x + 2; $xx ++)
|
||||
for($yy = $y; $yy <= $y + 3; $yy ++)
|
||||
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 true;
|
||||
}
|
||||
|
@ -77,31 +77,31 @@ class Well extends Object {
|
|||
*/
|
||||
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||
$this->level = $level;
|
||||
foreach ( $this->directions as $direction ) {
|
||||
foreach($this->directions as $direction ) {
|
||||
// Building pillard
|
||||
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
|
||||
$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] * 2), $y, $z + ($direction [1] * 2), 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] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE);
|
||||
|
||||
// Building slabs on the sides. Places two times due to all directions.
|
||||
$this->placeSlab ( $x + ($direction [0] * 2), $y, $z );
|
||||
$this->placeSlab ( $x, $y, $z + ($direction [1] * 2) );
|
||||
$this->placeSlab($x + ($direction [0] * 2), $y, $z);
|
||||
$this->placeSlab($x, $y, $z + ($direction [1] * 2));
|
||||
|
||||
// Placing water.Places two times due to all directions.
|
||||
$this->placeBlock ( $x + $direction [0], $y, $z, Block::WATER );
|
||||
$this->placeBlock ( $x, $y, $z + $direction [1], Block::WATER );
|
||||
$this->placeBlock($x + $direction [0], $y, $z, Block::WATER);
|
||||
$this->placeBlock($x, $y, $z + $direction [1], Block::WATER);
|
||||
}
|
||||
|
||||
// Finitions
|
||||
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
||||
for($zz = $z - 1; $zz <= $z + 1; $zz ++)
|
||||
$this->placeSlab ( $xx, $y + 3, $zz );
|
||||
$this->placeSlab ( $x, $y + 3, $z, Block::SANDSTONE );
|
||||
$this->placeSlab ( $x, $y, $z, Block::WATER );
|
||||
$this->placeSlab($xx, $y + 3, $zz);
|
||||
$this->placeSlab($x, $y + 3, $z, Block::SANDSTONE);
|
||||
$this->placeSlab($x, $y, $z, Block::WATER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -112,8 +112,8 @@ class Well extends Object {
|
|||
* @return void
|
||||
*/
|
||||
public function placeSlab($x, $y, $z) {
|
||||
$this->level->setBlockIdAt ( $x, $y, $z, 44 );
|
||||
$this->level->setBlockDataAt ( $x, $y, $z, 1 );
|
||||
$this->level->setBlockIdAt($x, $y, $z, 44);
|
||||
$this->level->setBlockDataAt($x, $y, $z, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -125,6 +125,6 @@ class Well extends Object {
|
|||
* @return void
|
||||
*/
|
||||
public function placeBlock($x, $y, $z, $id) {
|
||||
$this->level->setBlockIdAt ( $x, $y, $z, $id );
|
||||
$this->level->setBlockIdAt($x, $y, $z, $id);
|
||||
}
|
||||
}
|
|
@ -35,13 +35,13 @@ class BuildingUtils {
|
|||
*/
|
||||
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
|
||||
if ($block == null)
|
||||
$block = Block::get ( Block::AIR );
|
||||
list ( $pos1, $pos2 ) = self::minmax ( $pos1, $pos2 );
|
||||
$block = Block::get(Block::AIR);
|
||||
list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
|
||||
for($x = $pos1->x; $x >= $pos2->x; $x --)
|
||||
for($y = $pos1->y; $y >= $pos2->y; $y --)
|
||||
for($z = $pos1->z; $z >= $pos2->z; $z --) {
|
||||
$level->setBlockIdAt ( $x, $y, $z, $block->getId () );
|
||||
$level->setBlockDataAt ( $x, $y, $z, $block->getDamage () );
|
||||
$level->setBlockIdAt($x, $y, $z, $block->getId ());
|
||||
$level->setBlockDataAt($x, $y, $z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,11 +54,11 @@ class BuildingUtils {
|
|||
* @return void
|
||||
*/
|
||||
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($y = $pos1->y; $y >= $pos2->y; $y --)
|
||||
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
|
||||
*/
|
||||
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($x = $pos1->x; $x >= $pos2->x; $x --) {
|
||||
$level->setBlockIdAt ( $x, $y, $pos1->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $x, $y, $pos1->z, $block->getDamage () );
|
||||
$level->setBlockIdAt ( $x, $y, $pos2->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $x, $y, $pos2->z, $block->getDamage () );
|
||||
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId ());
|
||||
$level->setBlockDataAt($x, $y, $pos1->z, $block->getDamage ());
|
||||
$level->setBlockIdAt($x, $y, $pos2->z, $block->getId ());
|
||||
$level->setBlockDataAt($x, $y, $pos2->z, $block->getDamage ());
|
||||
}
|
||||
for($z = $pos1->z; $z >= $pos2->z; $z --) {
|
||||
$level->setBlockIdAt ( $pos1->x, $y, $z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos1->x, $y, $z, $block->getDamage () );
|
||||
$level->setBlockIdAt ( $pos2->x, $y, $z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos2->x, $y, $z, $block->getDamage () );
|
||||
$level->setBlockIdAt($pos1->x, $y, $z, $block->getId ());
|
||||
$level->setBlockDataAt($pos1->x, $y, $z, $block->getDamage ());
|
||||
$level->setBlockIdAt($pos2->x, $y, $z, $block->getId ());
|
||||
$level->setBlockDataAt($pos2->x, $y, $z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,11 @@ class BuildingUtils {
|
|||
* @return void
|
||||
*/
|
||||
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($z = $pos1->z; $z >= $pos2->z; $z --) {
|
||||
$level->setBlockIdAt ( $x, $pos1->y, $z, $block->getId () );
|
||||
$level->setBlockDataAt ( $x, $pos1->y, $z, $block->getDamage () );
|
||||
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId ());
|
||||
$level->setBlockDataAt($x, $pos1->y, $z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,16 +114,16 @@ class BuildingUtils {
|
|||
* @return void
|
||||
*/
|
||||
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 --) {
|
||||
$level->setBlockIdAt ( $pos1->x, $y, $pos1->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos1->x, $y, $pos1->z, $block->getDamage () );
|
||||
$level->setBlockIdAt ( $pos2->x, $y, $pos1->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos2->x, $y, $pos1->z, $block->getDamage () );
|
||||
$level->setBlockIdAt ( $pos1->x, $y, $pos2->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos1->x, $y, $pos2->z, $block->getDamage () );
|
||||
$level->setBlockIdAt ( $pos2->x, $y, $pos2->z, $block->getId () );
|
||||
$level->setBlockDataAt ( $pos2->x, $y, $pos2->z, $block->getDamage () );
|
||||
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId ());
|
||||
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage ());
|
||||
$level->setBlockIdAt($pos2->x, $y, $pos1->z, $block->getId ());
|
||||
$level->setBlockDataAt($pos2->x, $y, $pos1->z, $block->getDamage ());
|
||||
$level->setBlockIdAt($pos1->x, $y, $pos2->z, $block->getId ());
|
||||
$level->setBlockDataAt($pos1->x, $y, $pos2->z, $block->getDamage ());
|
||||
$level->setBlockIdAt($pos2->x, $y, $pos2->z, $block->getId ());
|
||||
$level->setBlockDataAt($pos2->x, $y, $pos2->z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,11 +136,11 @@ class BuildingUtils {
|
|||
* @return void
|
||||
*/
|
||||
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($z = $pos1->z; $z >= $pos2->z; $z --) {
|
||||
$level->setBlockIdAt ( $x, $pos2->y, $z, $block->getId () );
|
||||
$level->setBlockDataAt ( $x, $pos2->y, $z, $block->getDamage () );
|
||||
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId ());
|
||||
$level->setBlockDataAt($x, $pos2->y, $z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,17 +154,17 @@ class BuildingUtils {
|
|||
* @return void
|
||||
*/
|
||||
public function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
|
||||
$xBounded = $random->nextBoundedInt ( 3 ) - 1;
|
||||
$yBounded = $random->nextBoundedInt ( 3 ) - 1;
|
||||
$zBounded = $random->nextBoundedInt ( 3 ) - 1;
|
||||
$xBounded = $random->nextBoundedInt(3 ) - 1;
|
||||
$yBounded = $random->nextBoundedInt(3 ) - 1;
|
||||
$zBounded = $random->nextBoundedInt(3 ) - 1;
|
||||
$pos = $pos->round ();
|
||||
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($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 ) < ((($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->setBlockDataAt ( $x, $y, $z, $block->getDamage () );
|
||||
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->setBlockDataAt($x, $y, $z, $block->getDamage ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +178,8 @@ class BuildingUtils {
|
|||
* @return 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 ) );
|
||||
$v2 = new Vector3 ( min ( $pos1->x, $pos2->x ), min ( $pos1->y, $pos2->y ), min ( $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 ));
|
||||
return [
|
||||
$v1,
|
||||
$v2
|
||||
|
|
Loading…
Reference in a new issue