Fixed formating.

This commit is contained in:
Ad5001 2017-05-13 23:27:10 +02:00
parent e8f2961eab
commit be6965b909
28 changed files with 335 additions and 336 deletions

View file

@ -53,23 +53,23 @@ class BetterDesert extends SandyBiome implements Mountainable {
$this->temperature = 0.5; $this->temperature = 0.5;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover([ $this->setGroundCover([
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ) Block::get(Block::SANDSTONE, 0)
]); ]);
} }
public function getName(): string { public function getName(): string {

View file

@ -50,7 +50,7 @@ class BetterForest extends ForestBiome implements Mountainable {
$this->addPopulator($ft); $this->addPopulator($ft);
$trees = new TreePopulator($type); $trees = new TreePopulator($type);
$trees->setBaseAmount((null !== @constant(TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant(TreePopulator::$types [$type] . "::maxPerChunk" ) : 5); $trees->setBaseAmount((null !== @constant(TreePopulator::$types [$type] . "::maxPerChunk")) ? constant(TreePopulator::$types [$type] . "::maxPerChunk") : 5);
$this->addPopulator($trees); $this->addPopulator($trees);
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass () : new \pocketmine\level\generator\populator\TallGrass(); $tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass () : new \pocketmine\level\generator\populator\TallGrass();
@ -81,10 +81,10 @@ class BetterForest extends ForestBiome implements Mountainable {
* @return bool * @return bool
*/ */
public static function registerForest(string $name, string $treeClass, array $infos): bool { public static function registerForest(string $name, string $treeClass, array $infos): bool {
self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest"; self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass) [count(explode("\\", $treeClass))]) . " Forest";
TreePopulator::$types [] = $treeClass; TreePopulator::$types [] = $treeClass;
self::$ids [] = Main::SAKURA_FOREST + (count(self::$types ) - 2); self::$ids [] = Main::SAKURA_FOREST + (count(self::$types) - 2);
Main::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos )); Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
return true; return true;
} }
} }

View file

@ -24,11 +24,11 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
public function __construct() { public function __construct() {
parent::__construct (); parent::__construct ();
$this->setGroundCover([ $this->setGroundCover([
Block::get(Block::SNOW, 0 ), Block::get(Block::SNOW, 0),
Block::get(Block::GRASS, 0 ), Block::get(Block::GRASS, 0),
Block::get(Block::DIRT, 0 ), Block::get(Block::DIRT, 0),
Block::get(Block::DIRT, 0 ), Block::get(Block::DIRT, 0),
Block::get(Block::DIRT, 0 ) Block::get(Block::DIRT, 0)
]); ]);
$this->addPopulator(new IglooPopulator ()); $this->addPopulator(new IglooPopulator ());

View file

@ -44,7 +44,7 @@ class BetterMesa extends SandyBiome {
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore(); $ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
$ores->setOreTypes([ $ores->setOreTypes([
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32 ) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32 ) Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
]); ]);
$this->addPopulator($cactus); $this->addPopulator($cactus);
@ -58,50 +58,50 @@ class BetterMesa extends SandyBiome {
$this->temperature = 0.8; $this->temperature = 0.8;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover([ $this->setGroundCover([
Block::get(Block::DIRT, 0 ), Block::get(Block::DIRT, 0),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 4 ), Block::get(Block::STAINED_HARDENED_CLAY, 4),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 0 ), Block::get(Block::STAINED_HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ) Block::get(Block::RED_SANDSTONE, 0)
]); ]);
} }
public function getName(): string { public function getName(): string {

View file

@ -39,7 +39,7 @@ class BetterMesaPlains extends SandyBiome {
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore(); $ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
$ores->setOreTypes([ $ores->setOreTypes([
Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32 ) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32 ) Main::isOtherNS() ? new \pocketmine\level\generator\normal\object\OreType(new GoldOre (), 2, 8, 0, 32) : new \pocketmine\level\generator\object\OreType(new GoldOre (), 2, 8, 0, 32)
]); ]);
$this->addPopulator($cactus); $this->addPopulator($cactus);
@ -53,51 +53,51 @@ class BetterMesaPlains extends SandyBiome {
$this->temperature = 0.6; $this->temperature = 0.6;
$this->rainfall = 0; $this->rainfall = 0;
$this->setGroundCover([ $this->setGroundCover([
Block::get(Block::SAND, 1 ), Block::get(Block::SAND, 1),
Block::get(Block::SAND, 1 ), Block::get(Block::SAND, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 12 ), Block::get(Block::STAINED_HARDENED_CLAY, 12),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 14 ), Block::get(Block::STAINED_HARDENED_CLAY, 14),
Block::get(Block::STAINED_HARDENED_CLAY, 4 ), Block::get(Block::STAINED_HARDENED_CLAY, 4),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 0 ), Block::get(Block::STAINED_HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 7 ), Block::get(Block::STAINED_HARDENED_CLAY, 7),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::HARDENED_CLAY, 0 ), Block::get(Block::HARDENED_CLAY, 0),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::STAINED_HARDENED_CLAY, 1 ), Block::get(Block::STAINED_HARDENED_CLAY, 1),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ), Block::get(Block::RED_SANDSTONE, 0),
Block::get(Block::RED_SANDSTONE, 0 ) Block::get(Block::RED_SANDSTONE, 0)
]); ]);
} }
public function getName(): string { public function getName(): string {

View file

@ -22,17 +22,17 @@ class BetterRiver extends Biome {
$this->clearPopulators (); $this->clearPopulators ();
$this->setGroundCover([ $this->setGroundCover([
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SAND, 0 ), Block::get(Block::SAND, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ), Block::get(Block::SANDSTONE, 0),
Block::get(Block::SANDSTONE, 0 ) Block::get(Block::SANDSTONE, 0)
]); ]);
$this->setElevation(60, 60); $this->setElevation(60, 60);

View file

@ -44,10 +44,10 @@ class BetterBiomeSelector extends BiomeSelector {
$this->biomes [$biome->getId ()] = $biome; $this->biomes [$biome->getId ()] = $biome;
} }
public function getTemperature($x, $z) { public function getTemperature($x, $z) {
return ($this->temperature->noise2D($x, $z, true ) + 1) / 2; return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
} }
public function getRainfall($x, $z) { public function getRainfall($x, $z) {
return ($this->rainfall->noise2D($x, $z, true ) + 1) / 2; return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
} }
/** /**
@ -60,8 +60,8 @@ class BetterBiomeSelector extends BiomeSelector {
* @return Biome * @return Biome
*/ */
public function pickBiome($x, $z) { public function pickBiome($x, $z) {
$temperature = ($this->getTemperature($x, $z )); $temperature = ($this->getTemperature($x, $z));
$rainfall = ($this->getRainfall($x, $z )); $rainfall = ($this->getRainfall($x, $z));
$biomeId = BetterNormal::getBiome($temperature, $rainfall); $biomeId = BetterNormal::getBiome($temperature, $rainfall);
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback)); $b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback));

View file

@ -99,7 +99,7 @@ class BetterNormal extends Generator {
} }
$b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1); $b = $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000 ) < 3) { if ($b instanceof Mountainable && $this->random->nextBoundedInt(1000) < 3) {
$b = clone $b; $b = clone $b;
// $b->setElevation($b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100)); // $b->setElevation($b->getMinElevation () + (50 * $b->getMinElevation () / 100), $b->getMaxElevation () + (50 * $b->getMinElevation () / 100));
} }
@ -122,35 +122,35 @@ class BetterNormal extends Generator {
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32); $this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
$this->random->setSeed($this->level->getSeed ()); $this->random->setSeed($this->level->getSeed ());
$this->registerBiome(Biome::getBiome(Biome::OCEAN )); $this->registerBiome(Biome::getBiome(Biome::OCEAN));
$this->registerBiome(Biome::getBiome(Biome::PLAINS )); $this->registerBiome(Biome::getBiome(Biome::PLAINS));
$this->registerBiome(new BetterDesert ()); $this->registerBiome(new BetterDesert ());
$this->registerBiome(new BetterMesa ()); $this->registerBiome(new BetterMesa ());
$this->registerBiome(new BetterMesaPlains ()); $this->registerBiome(new BetterMesaPlains ());
$this->registerBiome(Biome::getBiome(Biome::TAIGA )); $this->registerBiome(Biome::getBiome(Biome::TAIGA));
$this->registerBiome(Biome::getBiome(Biome::SWAMP )); $this->registerBiome(Biome::getBiome(Biome::SWAMP));
$this->registerBiome(new BetterRiver ()); $this->registerBiome(new BetterRiver ());
$this->registerBiome(new BetterIcePlains ()); $this->registerBiome(new BetterIcePlains ());
$this->registerBiome(new BetterForest(0, [ $this->registerBiome(new BetterForest(0, [
0.6, 0.6,
0.5 0.5
] )); ]));
$this->registerBiome(new BetterForest(1, [ $this->registerBiome(new BetterForest(1, [
0.7, 0.7,
0.8 0.8
] )); ]));
$this->registerBiome(new BetterForest(2, [ $this->registerBiome(new BetterForest(2, [
0.6, 0.6,
0.4 0.4
] )); ]));
$this->selector = new BetterBiomeSelector($random, [ $this->selector = new BetterBiomeSelector($random, [
self::class, self::class,
"getBiome" "getBiome"
], self::getBiome(0, 0 )); ], self::getBiome(0, 0));
foreach(self::$biomes as $rain ) { foreach(self::$biomes as $rain) {
foreach($rain as $biome ) { foreach($rain as $biome) {
$this->selector->addBiome($biome); $this->selector->addBiome($biome);
} }
} }
@ -189,24 +189,24 @@ class BetterNormal extends Generator {
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore(); $ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
if(Main::isOtherNS()) $ores->setOreTypes([ if(Main::isOtherNS()) $ores->setOreTypes([
new OreType2(new CoalOre (), 20, 16, 0, 128 ), new OreType2(new CoalOre (), 20, 16, 0, 128),
new OreType2(new IronOre (), 20, 8, 0, 64 ), new OreType2(new IronOre (), 20, 8, 0, 64),
new OreType2(new RedstoneOre (), 8, 7, 0, 16 ), new OreType2(new RedstoneOre (), 8, 7, 0, 16),
new OreType2(new LapisOre (), 1, 6, 0, 32 ), new OreType2(new LapisOre (), 1, 6, 0, 32),
new OreType2(new GoldOre (), 2, 8, 0, 32 ), new OreType2(new GoldOre (), 2, 8, 0, 32),
new OreType2(new DiamondOre (), 1, 7, 0, 16 ), new OreType2(new DiamondOre (), 1, 7, 0, 16),
new OreType2(new Dirt (), 20, 32, 0, 128 ), new OreType2(new Dirt (), 20, 32, 0, 128),
new OreType2(new Gravel (), 10, 16, 0, 128 ) new OreType2(new Gravel (), 10, 16, 0, 128)
]); ]);
if(!Main::isOtherNS()) $ores->setOreTypes([ if(!Main::isOtherNS()) $ores->setOreTypes([
new OreType(new CoalOre (), 20, 16, 0, 128 ), new OreType(new CoalOre (), 20, 16, 0, 128),
new OreType(new IronOre (), 20, 8, 0, 64 ), new OreType(new IronOre (), 20, 8, 0, 64),
new OreType(new RedstoneOre (), 8, 7, 0, 16 ), new OreType(new RedstoneOre (), 8, 7, 0, 16),
new OreType(new LapisOre (), 1, 6, 0, 32 ), new OreType(new LapisOre (), 1, 6, 0, 32),
new OreType(new GoldOre (), 2, 8, 0, 32 ), new OreType(new GoldOre (), 2, 8, 0, 32),
new OreType(new DiamondOre (), 1, 7, 0, 16 ), new OreType(new DiamondOre (), 1, 7, 0, 16),
new OreType(new Dirt (), 20, 32, 0, 128 ), new OreType(new Dirt (), 20, 32, 0, 128),
new OreType(new Gravel (), 10, 16, 0, 128 ) new OreType(new Gravel (), 10, 16, 0, 128)
]); ]);
$this->populators [] = $ores; $this->populators [] = $ores;
} }
@ -220,10 +220,10 @@ class BetterNormal extends Generator {
if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["deleteBiomes"])) { if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["deleteBiomes"])) {
return false; return false;
} }
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 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 ()] = [ ]; if (! isset(self::$biomes[(string) $biome->getRainfall ()])) self::$biomes [( string) $biome->getRainfall ()] = [ ];
self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome; self::$biomes [( string) $biome->getRainfall ()] [( string) $biome->getTemperature ()] = $biome;
ksort(self::$biomes [( string ) $biome->getRainfall ()]); ksort(self::$biomes [( string) $biome->getRainfall ()]);
ksort(self::$biomes); ksort(self::$biomes);
self::$biomeById[$biome->getId()] = $biome; self::$biomeById[$biome->getId()] = $biome;
return true; return true;
@ -236,26 +236,26 @@ class BetterNormal extends Generator {
*/ */
public static function getBiome($temperature, $rainfall) { public static function getBiome($temperature, $rainfall) {
$ret = null; $ret = null;
if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) { if (! isset(self::$biomes [( string) round($rainfall, 1)])) {
while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) { while(! isset(self::$biomes [( string) round($rainfall, 1)])) {
if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05) if (abs($rainfall - round($rainfall, 1)) >= 0.05)
$rainfall += 0.1; $rainfall += 0.1;
if (abs($rainfall - round($rainfall, 1 ) ) < 0.05) if (abs($rainfall - round($rainfall, 1)) < 0.05)
$rainfall -= 0.1; $rainfall -= 0.1;
if (round($rainfall, 1 ) < 0) if (round($rainfall, 1) < 0)
$rainfall = 0; $rainfall = 0;
if (round($rainfall, 1 ) >= 0.9) if (round($rainfall, 1) >= 0.9)
$rainfall = 0.9; $rainfall = 0.9;
} }
} }
$b = self::$biomes [( string ) round($rainfall, 1 )]; $b = self::$biomes [( string) round($rainfall, 1)];
foreach($b as $t => $biome ) { foreach($b as $t => $biome) {
if ($temperature <=(float ) $t) { if ($temperature <=(float) $t) {
$ret = $biome; $ret = $biome;
break; break;
} }
} }
if (is_string($ret )) { if (is_string($ret)) {
$ret = new $ret (); $ret = new $ret ();
} }
return $ret; return $ret;
@ -304,7 +304,7 @@ class BetterNormal extends Generator {
$adjacent = $biome; $adjacent = $biome;
} else { } else {
$index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz); $index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
if (isset($biomeCache [$index] )) { if (isset($biomeCache [$index])) {
$adjacent = $biomeCache [$index]; $adjacent = $biomeCache [$index];
} else { } else {
$biomeCache [$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz); $biomeCache [$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
@ -338,7 +338,7 @@ class BetterNormal extends Generator {
} }
} }
foreach($this->generationPopulators as $populator ) { foreach($this->generationPopulators as $populator) {
$populator->populate($this->level, $chunkX, $chunkZ, $this->random); $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
} }
} }
@ -350,7 +350,7 @@ class BetterNormal extends Generator {
*/ */
public function populateChunk($chunkX, $chunkZ) { public function populateChunk($chunkX, $chunkZ) {
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ()); $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
foreach($this->populators as $populator ) { foreach($this->populators as $populator) {
$populator->populate($this->level, $chunkX, $chunkZ, $this->random); $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
} }
@ -358,12 +358,12 @@ class BetterNormal extends Generator {
for($x = $chunkX; $x < $chunkX + 16; $x ++) for($x = $chunkX; $x < $chunkX + 16; $x ++)
for($z = $chunkZ; $z < $chunkZ + 16; $z ++) for($z = $chunkZ; $z < $chunkZ + 16; $z ++)
for($y = 1; $y < 11; $y ++) { for($y = 1; $y < 11; $y ++) {
if (! in_array($this->level->getBlockIdAt($x, $y, $z ), self::NOT_OVERWRITABLE )) if (! in_array($this->level->getBlockIdAt($x, $y, $z), self::NOT_OVERWRITABLE))
$this->level->setBlockIdAt($x, $y, $z, Block::LAVA); $this->level->setBlockIdAt($x, $y, $z, Block::LAVA);
} }
$chunk = $this->level->getChunk($chunkX, $chunkZ); $chunk = $this->level->getChunk($chunkX, $chunkZ);
$biome = self::getBiomeById($chunk->getBiomeId(7, 7 )); $biome = self::getBiomeById($chunk->getBiomeId(7, 7));
$biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random); $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
} }
@ -429,7 +429,7 @@ class BetterNormal extends Generator {
* Returns a safe spawn location * Returns a safe spawn location
*/ */
public function getSafeSpawn() { public function getSafeSpawn() {
return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127 ), 127.5); return new Vector3(127.5, $this->getHighestWorkableBlock(127, 127), 127.5);
} }
/* /*

View file

@ -47,7 +47,7 @@ class CactusPopulator extends AmountPopulator {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 and $cactus->canPlaceObject($level, $x, $y, $z, $random )) { if ($y !== -1 and $cactus->canPlaceObject($level, $x, $y, $z, $random)) {
$cactus->placeObject($level, $x, $y, $z); $cactus->placeObject($level, $x, $y, $z);
} }
} }

View file

@ -40,7 +40,7 @@ class CavePopulator extends AmountPopulator {
for($i = 0; $i < $amount; $i++) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z )); $y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
// echo "Generating cave at $x, $y, $z." . PHP_EOL; // echo "Generating cave at $x, $y, $z." . PHP_EOL;
$this->generateCave($x, $y, $z, $random); $this->generateCave($x, $y, $z, $random);
} }
@ -49,8 +49,8 @@ class CavePopulator extends AmountPopulator {
for($i = 0; $i < $random->nextBoundedInt(5) + 3; $i ++) { for($i = 0; $i < $random->nextBoundedInt(5) + 3; $i ++) {
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z )); $y = $random->nextRange(10, $this->getHighestWorkableBlock($x, $z));
if ($level->getBlockIdAt($x, $y, $z ) == Block::STONE && ($level->getBlockIdAt($x + 1, $y, $z ) == Block::AIR || $level->getBlockIdAt($x - 1, $y, $z ) == Block::AIR || $level->getBlockIdAt($x, $y, $z + 1 ) == Block::AIR || $level->getBlockIdAt($x, $y, $z - 1 ) == Block::AIR) && $level->getBlockIdAt($x, $y - 1, $z ) !== Block::AIR && $level->getBlockIdAt($x, $y + 1, $z ) !== Block::AIR) { if ($level->getBlockIdAt($x, $y, $z) == Block::STONE && ($level->getBlockIdAt($x + 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x - 1, $y, $z) == Block::AIR || $level->getBlockIdAt($x, $y, $z + 1) == Block::AIR || $level->getBlockIdAt($x, $y, $z - 1) == Block::AIR) && $level->getBlockIdAt($x, $y - 1, $z) !== Block::AIR && $level->getBlockIdAt($x, $y + 1, $z) !== Block::AIR) {
if ($y < 40 && $random->nextBoolean ()) { if ($y < 40 && $random->nextBoolean ()) {
$level->setBlockIdAt($x, $y, $z, Block::LAVA); $level->setBlockIdAt($x, $y, $z, Block::LAVA);
} else { } else {
@ -87,9 +87,8 @@ class CavePopulator extends AmountPopulator {
* @return void * @return void
*/ */
public function generateCave($x, $y, $z, Random $random) { public function generateCave($x, $y, $z, Random $random) {
$generatedBranches = $random->nextBoundedInt(10 ) + 1; $generatedBranches = $random->nextBoundedInt(10) + 1;
// echo "Num of branch left => " . $generatedBranches . PHP_EOL; foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random) as $v3) {
foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) {
$generatedBranches --; $generatedBranches --;
if ($generatedBranches <= 0) { if ($generatedBranches <= 0) {
$gen->send(self::STOP); $gen->send(self::STOP);
@ -111,34 +110,34 @@ class CavePopulator extends AmountPopulator {
* @return void * @return void
*/ */
public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) { public function generateBranch($x, $y, $z, $length, $height, $depth, Random $random) {
if (! (yield new Vector3($x, $y, $z ))) { if (! (yield new Vector3($x, $y, $z))) {
for($i = 0; $i <= 4; $i ++) { for($i = 0; $i <= 4; $i ++) {
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3($length - $i, $height - $i, $depth - $i ), $random, Block::get(Block::AIR )); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length - $i, $height - $i, $depth - $i), $random, Block::get(Block::AIR));
$x += round(($random->nextBoundedInt(round(30 * ($length / 10) ) + 1 ) / 10 - 2)); $x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
$yP = $random->nextRange(- 14, 14); $yP = $random->nextRange(-14, 14);
if ($yP > 12) { if ($yP > 12) {
$y ++; $y ++;
} elseif ($yP < - 12) { } elseif ($yP < - 12) {
$y --; $y --;
} }
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1)); $z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
return; return;
} }
} }
$repeat = $random->nextBoundedInt(25 ) + 15; $repeat = $random->nextBoundedInt(25) + 15;
while($repeat -- > 0 ) { while($repeat-- > 0) {
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3($length, $height, $depth ), $random, Block::get(Block::AIR )); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3($length, $height, $depth), $random, Block::get(Block::AIR));
$x += round(($random->nextBoundedInt(round(30 * ($length / 10) ) + 1 ) / 10 - 2)); $x += round(($random->nextBoundedInt(round(30 * ($length / 10)) + 1) / 10 - 2));
$yP = $random->nextRange(- 14, 14); $yP = $random->nextRange(- 14, 14);
if ($yP > 12) { if ($yP > 12) {
$y ++; $y ++;
} elseif ($yP < - 12) { } elseif ($yP < - 12) {
$y --; $y --;
} }
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1)); $z += round(($random->nextBoundedInt(round(30 * ($depth / 10)) + 1) / 10 - 1));
$height += $random->nextBoundedInt(3 ) - 1; $height += $random->nextBoundedInt(3) - 1;
$length += $random->nextBoundedInt(3 ) - 1; $length += $random->nextBoundedInt(3) - 1;
$depth += $random->nextBoundedInt(3 ) - 1; $depth += $random->nextBoundedInt(3) - 1;
if ($height < 3) if ($height < 3)
$height = 3; $height = 3;
if ($length < 3) if ($length < 3)
@ -151,8 +150,8 @@ class CavePopulator extends AmountPopulator {
$length = 7; $length = 7;
if ($height < 7) if ($height < 7)
$height = 7; $height = 7;
if ($random->nextBoundedInt(10 ) == 0) { if ($random->nextBoundedInt(10) == 0) {
foreach($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random ) as $gen ) { foreach($generator = $this->generateBranch($x, $y, $z, $length, $height, $depth, $random) as $gen) {
if (! (yield $gen)) if (! (yield $gen))
$generator->send(self::STOP); $generator->send(self::STOP);
} }

View file

@ -40,7 +40,7 @@ class DeadbushPopulator extends AmountPopulator {
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
if(!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue; if(!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue;
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) { if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z) == Block::SAND) {
$level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH); $level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
$level->setBlockDataAt($x, $y, $z, 1); $level->setBlockDataAt($x, $y, $z, 1);
} }

View file

@ -54,7 +54,7 @@ class FallenTreePopulator extends AmountPopulator {
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if(isset(FallenTree::$overridable[$level->getBlockIdAt($x, $y, $z)])) $y--; // Changing $y if 1 block to high. if(isset(FallenTree::$overridable[$level->getBlockIdAt($x, $y, $z)])) $y--; // Changing $y if 1 block to high.
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random )) { if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random)) {
$fallenTree->placeObject($level, $x, $y + 1, $z); $fallenTree->placeObject($level, $x, $y + 1, $z);
} }
} }

View file

@ -146,7 +146,7 @@ class FloatingIslandPopulator extends AmountPopulator {
public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) { public function populateOres(ChunkManager $level, Vector3 $pos, int $width, int $height, Random $random) {
$ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore(); $ores = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\Ore() : new \pocketmine\level\generator\populator\Ore();
if(Main::isOtherNS()) $ores->setOreTypes([ if(Main::isOtherNS()) $ores->setOreTypes([
new OreType2(new CoalOre (), 20, 16, $pos->y - $height, $pos->y ), new OreType2(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
new OreType2(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)), new OreType2(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
new OreType2(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)), new OreType2(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
new OreType2(new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)), new OreType2(new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)),
@ -154,7 +154,7 @@ class FloatingIslandPopulator extends AmountPopulator {
new OreType2(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4)) new OreType2(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
]); ]);
if(!Main::isOtherNS()) $ores->setOreTypes([ if(!Main::isOtherNS()) $ores->setOreTypes([
new OreType(new CoalOre (), 20, 16, $pos->y - $height, $pos->y ), new OreType(new CoalOre (), 20, 16, $pos->y - $height, $pos->y),
new OreType(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)), new OreType(new IronOre (), 20, 8, $pos->y - $height, $pos->y - round($height * 0.75)),
new OreType(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new RedstoneOre (), 8, 7, $pos->y - $height, $pos->y - round($height / 2)),
new OreType(new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new LapisOre (), 1, 6, $pos->y - $height, $pos->y - round($height / 2)),

View file

@ -33,13 +33,13 @@ class IglooPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt(100 ) > 30) if ($random->nextBoundedInt(100) > 30)
return; return;
$igloo = new Igloo (); $igloo = new Igloo ();
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock($x, $z ) - 1; $y = $this->getHighestWorkableBlock($x, $z) - 1;
if ($igloo->canPlaceObject($level, $x, $y, $z, $random )) if ($igloo->canPlaceObject($level, $x, $y, $z, $random))
$igloo->placeObject($level, $x, $y, $z, $random); $igloo->placeObject($level, $x, $y, $z, $random);
} }

View file

@ -42,13 +42,13 @@ class LakePopulator extends AmountPopulator {
$x += $random->nextRange(- 1, 1); $x += $random->nextRange(- 1, 1);
$y += $random->nextRange(- 1, 1); $y += $random->nextRange(- 1, 1);
$z += $random->nextRange(- 1, 1); $z += $random->nextRange(- 1, 1);
if ($level->getBlockIdAt($x, $y, $z ) !== Block::AIR) if ($level->getBlockIdAt($x, $y, $z) !== Block::AIR)
BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z ), new Vector3(5, 5, 5 ), $random, Block::get(Block::WATER )); BuildingUtils::buildRandom($this->level, new Vector3($x, $y, $z), new Vector3(5, 5, 5), $random, Block::get(Block::WATER));
} }
for($xx = $x - 8; $xx <= $x + 8; $xx ++) for($xx = $x - 8; $xx <= $x + 8; $xx ++)
for($zz = $z - 8; $zz <= $z + 8; $zz ++) for($zz = $z - 8; $zz <= $z + 8; $zz ++)
for($yy = $ory + 1; $yy <= $y + 3; $yy ++) for($yy = $ory + 1; $yy <= $y + 3; $yy ++)
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::WATER) if ($level->getBlockIdAt($xx, $yy, $zz) == Block::WATER)
$level->setBlockIdAt($xx, $yy, $zz, Block::AIR); $level->setBlockIdAt($xx, $yy, $zz, Block::AIR);
} }

View file

@ -41,31 +41,31 @@ class MineshaftPopulator extends AmountPopulator {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
if ($this->getAmount($random ) < 100) if ($this->getAmount($random) < 100)
return; return;
$this->level = $level; $this->level = $level;
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange(5, 50); $y = $random->nextRange(5, 50);
// First filling the large dirt place (center of the mineshaft) // First filling the large dirt place (center of the mineshaft)
BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6 ), new Vector3($x + 6, $y + 8, $z + 6 ), Block::get(Block::AIR )); BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6), new Vector3($x + 6, $y + 8, $z + 6), Block::get(Block::AIR));
BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6 ), new Vector3($x + 6, $y, $z + 6 ), Block::get(Block::DIRT )); BuildingUtils::fill($level, new Vector3($x - 6, $y, $x - 6), new Vector3($x + 6, $y, $z + 6), Block::get(Block::DIRT));
$startingPath = $random->nextBoundedInt(4); $startingPath = $random->nextBoundedInt(4);
$this->maxPath = $random->nextBoundedInt(100 ) + 50; $this->maxPath = $random->nextBoundedInt(100) + 50;
foreach(array_fill(0, $startingPath, 1 ) as $hey ) { foreach(array_fill(0, $startingPath, 1) as $hey) {
$dir = $random->nextBoundedInt(4); $dir = $random->nextBoundedInt(4);
switch ($dir) { switch ($dir) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart($x + 6, $y + $random->nextBoundedInt(5 ), $z + $random->nextBoundedInt(12 ) - 6, $dir, $random); $this->generateMineshaftPart($x + 6, $y + $random->nextBoundedInt(5), $z + $random->nextBoundedInt(12) - 6, $dir, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
$this->generateMineshaftPart($x - 6, $y + $random->nextBoundedInt(5 ), $z + $random->nextBoundedInt(12 ) - 6, $dir, $random); $this->generateMineshaftPart($x - 6, $y + $random->nextBoundedInt(5), $z + $random->nextBoundedInt(12) - 6, $dir, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
$this->generateMineshaftPart($x + $random->nextBoundedInt(12 ) - 6, $y + $random->nextBoundedInt(8 ), $z + 6, $dir, $random); $this->generateMineshaftPart($x + $random->nextBoundedInt(12) - 6, $y + $random->nextBoundedInt(8), $z + 6, $dir, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
$this->generateMineshaftPart($x + $random->nextBoundedInt(12 ) - 6, $y + $random->nextBoundedInt(8 ), $z - 6, $dir, $random); $this->generateMineshaftPart($x + $random->nextBoundedInt(12) - 6, $y + $random->nextBoundedInt(8), $z - 6, $dir, $random);
break; break;
} }
} }
@ -89,15 +89,15 @@ class MineshaftPopulator extends AmountPopulator {
switch ($dir) { switch ($dir) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x + 4, $y + 2, $z + 1 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1), new Vector3($x + 4, $y + 2, $z + 1), Block::get(Block::AIR));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x + 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
@ -113,32 +113,32 @@ class MineshaftPopulator extends AmountPopulator {
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH); $level->setBlockIdAt($x + 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt($x + 1, $y + 2, $z, 2); $level->setBlockDataAt($x + 1, $y + 2, $z, 2);
// Generating chest // Generating chest
if ($random->nextBoundedInt(30 ) == 0) { if ($random->nextBoundedInt(30) == 0) {
$direction =(int ) $random->nextBoolean (); $direction =(int) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = -1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 =(int ) $random->nextBoolean (); $direction2 =(int) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable(new Vector3($x + $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random); LootTable::buildLootTable(new Vector3($x + $direction2, $y, $z + $direction), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt(30 ) !== 0) if ($random->nextBoundedInt(30) !== 0)
$this->generateMineshaftPart($x + 5, $y, $z, $dir, $random); $this->generateMineshaftPart($x + 5, $y, $z, $dir, $random);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 )); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1), new Vector3($x - 4, $y + 2, $z + 1));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1), new Vector3($x - 4, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x - 4, $y, $z), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
@ -154,32 +154,32 @@ class MineshaftPopulator extends AmountPopulator {
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH); $level->setBlockIdAt($x - 1, $y + 2, $z, Block::TORCH);
$level->setBlockDataAt($x - 1, $y + 2, $z, 1); $level->setBlockDataAt($x - 1, $y + 2, $z, 1);
// Generating chest // Generating chest
if ($random->nextBoundedInt(30 ) == 0) { if ($random->nextBoundedInt(30) == 0) {
$direction =(int ) $random->nextBoolean (); $direction =(int) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = -1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 =(int ) $random->nextBoolean (); $direction2 =(int) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random); LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt(30 ) !== 0) if ($random->nextBoundedInt(30) !== 0)
$this->generateMineshaftPart($x - 5, $y, $z, $dir, $random); $this->generateMineshaftPart($x - 5, $y, $z, $dir, $random);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z + 4 )); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z), new Vector3($x + 1, $y + 2, $z + 4));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z + 4), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, ChunkManager $level, Random $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + 4), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
@ -195,32 +195,32 @@ class MineshaftPopulator extends AmountPopulator {
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt($x, $y + 2, $z - 1, 4); $level->setBlockDataAt($x, $y + 2, $z - 1, 4);
// Generating chest // Generating chest
if ($random->nextBoundedInt(30 ) == 0) { if ($random->nextBoundedInt(30) == 0) {
$direction =(int ) $random->nextBoolean (); $direction =(int) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = -1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 =(int ) $random->nextBoolean (); $direction2 =(int) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable(new Vector3($x + $direction, $y, $z + $direction2 ), LootTable::LOOT_MINESHAFT, $random); LootTable::buildLootTable(new Vector3($x + $direction, $y, $z + $direction2), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt(30 ) !== 0) if ($random->nextBoundedInt(30) !== 0)
$this->generateMineshaftPart($x, $y, $z + 5, $dir, $random); $this->generateMineshaftPart($x, $y, $z + 5, $dir, $random);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 )); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z), new Vector3($x + 1, $y + 2, $z - 4));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z), new Vector3($x + 1, $y - 1, $z - 4), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, ChunkManager $level, Random $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z - 4), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
@ -236,28 +236,28 @@ class MineshaftPopulator extends AmountPopulator {
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH); $level->setBlockIdAt($x, $y + 2, $z - 1, Block::TORCH);
$level->setBlockDataAt($x, $y + 2, $z - 1, 3); $level->setBlockDataAt($x, $y + 2, $z - 1, 3);
// Generating chest // Generating chest
if ($random->nextBoundedInt(30 ) == 0) { if ($random->nextBoundedInt(30) == 0) {
$direction =(int ) $random->nextBoolean (); $direction =(int) $random->nextBoolean ();
if ($direction == 0) if ($direction == 0)
$direction = -1; // Choosing the part of the rail. $direction = -1; // Choosing the part of the rail.
$direction2 =(int ) $random->nextBoolean (); $direction2 =(int) $random->nextBoolean ();
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = 4; $direction2 = 4;
LootTable::buildLootTable(new Vector3($x + $direction, $y, $z - $direction2 ), LootTable::LOOT_MINESHAFT, $random); LootTable::buildLootTable(new Vector3($x + $direction, $y, $z - $direction2), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt(30 ) !== 0) if ($random->nextBoundedInt(30) !== 0)
$this->generateMineshaftPart($x, $y, $z - 5, $dir, $random); $this->generateMineshaftPart($x, $y, $z - 5, $dir, $random);
break; break;
} }
// Doing cobwebs // Doing cobwebs
$webNum = $random->nextBoundedInt(5 ) + 2; $webNum = $random->nextBoundedInt(5) + 2;
for($i = 0; $i < $webNum; $i ++) { for($i = 0; $i < $webNum; $i ++) {
$xx = $x + $random->nextBoundedInt(5 ) - 2; $xx = $x + $random->nextBoundedInt(5) - 2;
$yy = $y + $random->nextBoundedInt(3); $yy = $y + $random->nextBoundedInt(3);
$zz = $z + $random->nextBoundedInt(5 ) - 2; $zz = $z + $random->nextBoundedInt(5) - 2;
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR) if ($level->getBlockIdAt($xx, $yy, $zz) == Block::AIR)
$level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB); $level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
} }
break; break;
@ -288,16 +288,16 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1), new Vector3($x - 1, $y - 1, $z + 1), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z - 1 ), new Vector3($x + 1, $y + 6, $z + 1 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::AIR));
BuildingUtils::corners($this->level, new Vector3($x - 1, $y, $z - 1 ), new Vector3($x + 1, $y + 6, $z + 1 ), Block::get(Block::PLANK )); BuildingUtils::corners($this->level, new Vector3($x - 1, $y, $z - 1), new Vector3($x + 1, $y + 6, $z + 1), Block::get(Block::PLANK));
$newFloor = $random->nextBoolean (); $newFloor = $random->nextBoolean ();
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0)); $numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
@ -311,12 +311,12 @@ class MineshaftPopulator extends AmountPopulator {
] : [ ]) ] : [ ])
]; ];
for($i = 7; $i > $newFloor; $i --) { for($i = 7; $i > $newFloor; $i --) {
$chooseNew =(int ) $newFloor && $random->nextBoolean (); $chooseNew =(int) $newFloor && $random->nextBoolean ();
$choose = $random->nextBoundedInt(4); $choose = $random->nextBoundedInt(4);
unset($possiblePathes [$chooseNew] [$choose]); unset($possiblePathes [$chooseNew] [$choose]);
} }
// Building pathes // Building pathes
foreach($possiblePathes [0] as $path ) { foreach($possiblePathes [0] as $path) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart($x + 2, $y, $z, self::DIR_XPLUS, $random); $this->generateMineshaftPart($x + 2, $y, $z, self::DIR_XPLUS, $random);
@ -332,7 +332,7 @@ class MineshaftPopulator extends AmountPopulator {
break; break;
} }
} }
foreach($possiblePathes [1] as $path ) { foreach($possiblePathes [1] as $path) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart($x + 2, $y + 4, $z, self::DIR_XPLUS, $random); $this->generateMineshaftPart($x + 2, $y + 4, $z, self::DIR_XPLUS, $random);
@ -350,12 +350,12 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Doing cobwebs // Doing cobwebs
$webNum = $random->nextBoundedInt(5 ) + 2; $webNum = $random->nextBoundedInt(5) + 2;
for($i = 0; $i < $webNum; $i ++) { for($i = 0; $i < $webNum; $i ++) {
$xx = $x + $random->nextBoundedInt(3 ) - 1; $xx = $x + $random->nextBoundedInt(3) - 1;
$yy = $y + $random->nextBoundedInt(6); $yy = $y + $random->nextBoundedInt(6);
$zz = $z + $random->nextBoundedInt(3 ) - 1; $zz = $z + $random->nextBoundedInt(3) - 1;
if ($level->getBlockIdAt($xx, $yy, $zz ) == Block::AIR) if ($level->getBlockIdAt($xx, $yy, $zz) == Block::AIR)
$level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB); $level->setBlockIdAt($xx, $yy, $zz, Block::COBWEB);
} }
break; break;
@ -368,33 +368,33 @@ class MineshaftPopulator extends AmountPopulator {
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
switch ($i) { switch ($i) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2), new Vector3($x + $i, $y - $i + 3, $z + 2), Block::get(Block::AIR));
BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2), new Vector3($x + $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2), new Vector3($x - $i, $y - $i + 3, $z + 2), Block::get(Block::AIR));
BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2), new Vector3($x - $i, $y - $i - 2, $z + 2), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i), new Vector3($x + 2, $y - $i + 3, $z + $i), Block::get(Block::AIR));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i), new Vector3($x + 2, $y - $i - 2, $z + $i), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i), new Vector3($x + 2, $y - $i + 3, $z - $i), Block::get(Block::AIR));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, ChunkManager $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i), new Vector3($x + 2, $y - $i - 2, $z - $i), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;

View file

@ -36,10 +36,10 @@ class RavinePopulator extends AmountPopulator {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount($random); $amount = $this->getAmount($random);
if ($amount > 50) { // Only build one per chunk if ($amount > 50) { // Only build one per chunk
$depth = $random->nextBoundedInt(60 ) + 30; // 2Much4U? $depth = $random->nextBoundedInt(60) + 30; // 2Much4U?
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $random->nextRange(5, $this->getHighestWorkableBlock($x, $z )); $y = $random->nextRange(5, $this->getHighestWorkableBlock($x, $z));
$deffX = $x; $deffX = $x;
$deffZ = $z; $deffZ = $z;
$height = $random->nextRange(15, 30); $height = $random->nextRange(15, 30);
@ -60,11 +60,11 @@ class RavinePopulator extends AmountPopulator {
$length = 10; $length = 10;
if ($length < 5) if ($length < 5)
$length = 5; $length = 5;
$x += $random->nextRange(0 + $diffX, 2 + $diffX ) - 1; $x += $random->nextRange(0 + $diffX, 2 + $diffX) - 1;
$y += $random->nextRange(0, 2 ) - 1; $y += $random->nextRange(0, 2) - 1;
$z += $random->nextRange(0 + $diffZ, 2 + $diffZ ) - 1; $z += $random->nextRange(0 + $diffZ, 2 + $diffZ) - 1;
$height += $random->nextRange(0, 2 ) - 1; $height += $random->nextRange(0, 2) - 1;
$length += $random->nextRange(0, 2 ) - 1; $length += $random->nextRange(0, 2) - 1;
} }
} }
} }
@ -103,9 +103,9 @@ class RavinePopulator extends AmountPopulator {
for($yy = $y; $yy <= $y + $height; $yy ++) { for($yy = $y; $yy <= $y + $height; $yy ++) {
for($zz = $z - $length; $zz <= $z + $length; $zz ++) { for($zz = $z - $length; $zz <= $z + $length; $zz ++) {
$oldXB = $xBounded; $oldXB = $xBounded;
$xBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE; $xBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
$oldZB = $zBounded; $oldZB = $zBounded;
$zBounded = $random->nextBoundedInt(self::NOISE * 2 ) - self::NOISE; $zBounded = $random->nextBoundedInt(self::NOISE * 2) - self::NOISE;
if ($xBounded > self::NOISE - 2) { if ($xBounded > self::NOISE - 2) {
$xBounded = 1; $xBounded = 1;
} elseif ($xBounded < - self::NOISE + 2) { } elseif ($xBounded < - self::NOISE + 2) {
@ -120,8 +120,8 @@ class RavinePopulator extends AmountPopulator {
} else { } else {
$zBounded = $oldZB; $zBounded = $oldZB;
} }
if (abs((abs($xx ) - abs($x )) ** 2 + (abs($zz ) - abs($z )) ** 2 ) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && ! in_array($this->level->getBlockIdAt(( int ) round($xx ),(int ) round($yy ),(int ) round($zz ) ), BuildingUtils::TO_NOT_OVERWRITE ) && ! in_array($this->level->getBlockIdAt(( int ) round($xx ),(int ) round($yy + 1 ),(int ) round($zz ) ), BuildingUtils::TO_NOT_OVERWRITE )) { if (abs((abs($xx) - abs($x)) ** 2 + (abs($zz) - abs($z)) ** 2) < ((($length / 2 - $xBounded) + ($length / 2 - $zBounded)) / 2) ** 2 && $y > 0 && ! in_array($this->level->getBlockIdAt(( int) round($xx),(int) round($yy),(int) round($zz)), BuildingUtils::TO_NOT_OVERWRITE) && ! in_array($this->level->getBlockIdAt(( int) round($xx),(int) round($yy + 1),(int) round($zz)), BuildingUtils::TO_NOT_OVERWRITE)) {
$this->level->setBlockIdAt(( int ) round($xx ),(int ) round($yy ),(int ) round($zz ), Block::AIR); $this->level->setBlockIdAt(( int) round($xx),(int) round($yy),(int) round($zz), Block::AIR);
} }
} }
} }

View file

@ -46,7 +46,7 @@ class SugarCanePopulator extends AmountPopulator {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 and $sugarcane->canPlaceObject($level, $x, $y, $z, $random )) { if ($y !== -1 and $sugarcane->canPlaceObject($level, $x, $y, $z, $random)) {
$sugarcane->placeObject($level, $x, $y, $z); $sugarcane->placeObject($level, $x, $y, $z);
} }
} }

View file

@ -33,13 +33,13 @@ class TemplePopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt(1000 ) > 70) if ($random->nextBoundedInt(1000) > 70)
return; return;
$temple = new Temple (); $temple = new Temple ();
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($temple->canPlaceObject($level, $x, $y, $z, $random )) if ($temple->canPlaceObject($level, $x, $y, $z, $random))
$temple->placeObject($level, $x, $y - 1, $z, $random); $temple->placeObject($level, $x, $y - 1, $z, $random);
} }

View file

@ -33,13 +33,13 @@ class WellPopulator extends AmountPopulator {
*/ */
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if ($random->nextBoundedInt(1000 ) > 25) if ($random->nextBoundedInt(1000) > 25)
return; // ~1 chance / 1000 due to building limitations. return; // ~1 chance / 1000 due to building limitations.
$well = new Well (); $well = new Well ();
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock($x, $z ) - 1; $y = $this->getHighestWorkableBlock($x, $z) - 1;
if ($well->canPlaceObject($level, $x, $y, $z, $random )) if ($well->canPlaceObject($level, $x, $y, $z, $random))
$well->placeObject($level, $x, $y, $z, $random); $well->placeObject($level, $x, $y, $z, $random);
} }

View file

@ -72,7 +72,7 @@ class Bush extends Object {
* @param $level pocketmine\level\ChunkManager * @param $level pocketmine\level\ChunkManager
*/ */
public function placeLeaf($x, $y, $z, ChunkManager $level) { public function placeLeaf($x, $y, $z, ChunkManager $level) {
if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) { if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z)]) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z)])) {
$level->setBlockIdAt($x, $y, $z, $this->leaf [0]); $level->setBlockIdAt($x, $y, $z, $this->leaf [0]);
$level->setBlockDataAt($x, $y, $z, $this->leaf [1]); $level->setBlockDataAt($x, $y, $z, $this->leaf [1]);
} }

View file

@ -35,7 +35,7 @@ class Cactus extends Object {
$this->totalHeight = 1 + $random->nextBoundedInt(3); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z); $below = $level->getBlockIdAt($x, $y - 1, $z);
for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) { for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) { if ($level->getBlockIdAt($x, $yy, $z) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1) !== Block::AIR)) {
return false; return false;
} }
} }
@ -51,7 +51,7 @@ class Cactus extends Object {
*/ */
public function placeObject(ChunkManager $level, int $x, int $y, int $z) { public function placeObject(ChunkManager $level, int $x, int $y, int $z) {
for($yy = 0; $yy < $this->totalHeight; $yy ++) { for($yy = 0; $yy < $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt($x, $y + $yy, $z ) != Block::AIR) { if ($level->getBlockIdAt($x, $y + $yy, $z) != Block::AIR) {
return; return;
} }
$level->setBlockIdAt($x, $y + $yy, $z, Block::CACTUS); $level->setBlockIdAt($x, $y + $yy, $z, Block::CACTUS);

View file

@ -155,7 +155,7 @@ class FallenTree extends Object {
* @param $level pocketmine\level\ChunkManager * @param $level pocketmine\level\ChunkManager
*/ */
public function placeBlock($x, $y, $z, ChunkManager $level) { public function placeBlock($x, $y, $z, ChunkManager $level) {
if (isset(self::$overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset(self::$overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) { if (isset(self::$overridable [$level->getBlockIdAt($x, $y, $z)]) && ! isset(self::$overridable [$level->getBlockIdAt($x, $y - 1, $z)])) {
$level->setBlockIdAt($x, $y, $z, $this->trunk [0]); $level->setBlockIdAt($x, $y, $z, $this->trunk [0]);
$level->setBlockDataAt($x, $y, $z, $this->trunk [1]); $level->setBlockDataAt($x, $y, $z, $this->trunk [1]);
} }

View file

@ -49,28 +49,28 @@ class Igloo extends Object {
for($xx = $x - 3; $xx <= $x + 4; $xx ++) for($xx = $x - 3; $xx <= $x + 4; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
break; break;
case 1 : // Entrance is x- case 1 : // Entrance is x-
for($xx = $x - 4; $xx <= $x + 3; $xx ++) for($xx = $x - 4; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
break; break;
case 2 : // Entrance is z+ case 2 : // Entrance is z+
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
break; break;
case 3 : // Entrance is z- case 3 : // Entrance is z-
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 4; $zz <= $z + 3; $zz ++) for($zz = $z - 4; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
break; break;
} }
@ -87,14 +87,14 @@ class Igloo extends Object {
* @return bool placed * @return bool placed
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
if (! isset($this->direction ) && ! $this->canPlaceObject($level, $x, $y, $z, $random )) if (! isset($this->direction) && ! $this->canPlaceObject($level, $x, $y, $z, $random))
return false; return false;
switch ($this->direction) { switch ($this->direction) {
case 0 : // Entrance is x+ case 0 : // Entrance is x+
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 4; $xx ++) for($xx = $x - 3; $xx <= $x + 4; $xx ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz)]))
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
@ -169,7 +169,7 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 4; $xx <= $x + 3; $xx ++) for($xx = $x - 4; $xx <= $x + 3; $xx ++)
for($zz = $z - 3; $zz <= $z + 3; $zz ++) for($zz = $z - 3; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz)]))
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
@ -243,7 +243,7 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz)]))
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {
@ -317,7 +317,7 @@ class Igloo extends Object {
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($zz = $z - 4; $zz <= $z + 3; $zz ++) for($zz = $z - 4; $zz <= $z + 3; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $y, $zz)]))
$level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK); $level->setBlockIdAt($xx, $y, $zz, Block::SNOW_BLOCK);
// Entrance // Entrance
for($i = 0; $i < 2; $i ++) { for($i = 0; $i < 2; $i ++) {

View file

@ -680,7 +680,7 @@ class SakuraTree extends Tree {
$data = [ $data = [
$this->leafType, $this->leafType,
$this->leaf2Type $this->leaf2Type
] [( int )$random->nextBoolean()]; ] [( int)$random->nextBoolean()];
$level->setBlockIdAt($x, $y, $z, $this->realLeafBlock); $level->setBlockIdAt($x, $y, $z, $this->realLeafBlock);
$level->setBlockDataAt($x, $y, $z, $data); $level->setBlockDataAt($x, $y, $z, $data);
} }

View file

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

View file

@ -69,7 +69,7 @@ class Well extends Object {
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for($xx = $x - 2; $xx <= $x + 2; $xx ++)
for($yy = $y; $yy <= $y + 3; $yy ++) for($yy = $y; $yy <= $y + 3; $yy ++)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for($zz = $z - 2; $zz <= $z + 2; $zz ++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
return true; return true;
} }
@ -84,7 +84,7 @@ class Well extends Object {
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level; $this->level = $level;
foreach($this->directions as $direction ) { foreach($this->directions as $direction) {
// Building pillars // Building pillars
for($yy = $y; $yy < $y + 3; $yy ++) for($yy = $y; $yy < $y + 3; $yy ++)
$this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE); $this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE);

View file

@ -40,7 +40,7 @@ class BuildingUtils {
*/ */
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) { public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
if ($block == null) $block = Block::get(Block::AIR); if ($block == null) $block = Block::get(Block::AIR);
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) { 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->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt($x, $y, $z, $block->getDamage ()); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
@ -60,7 +60,7 @@ class BuildingUtils {
*/ */
public static function fillRandom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null, Random $random = null, $randMax = 3) { public static function fillRandom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null, Random $random = null, $randMax = 3) {
if ($block == null) $block = Block::get(Block::AIR); if ($block == null) $block = Block::get(Block::AIR);
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) if($random !== null ? $random->nextBoundedInt($randMax) == 0 : rand(0, $randMax) == 0) { for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) if($random !== null ? $random->nextBoundedInt($randMax) == 0 : rand(0, $randMax) == 0) {
$level->setBlockIdAt($x, $y, $z, $block->getId ()); $level->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt($x, $y, $z, $block->getDamage ()); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
@ -76,10 +76,10 @@ class BuildingUtils {
* @return array * @return array
*/ */
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array { public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
$return = []; $return = [];
for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) { for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) {
$return[] = call_user_func($call, new Vector3($x, $y, $z ), ...$params); $return[] = call_user_func($call, new Vector3($x, $y, $z), ...$params);
} }
return $return; return $return;
} }
@ -93,7 +93,7 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function walls(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) { for($y = $pos1->y; $y >= $pos2->y; $y --) {
for($x = $pos1->x; $x >= $pos2->x; $x --) { for($x = $pos1->x; $x >= $pos2->x; $x --) {
$level->setBlockIdAt($x, $y, $pos1->z, $block->getId ()); $level->setBlockIdAt($x, $y, $pos1->z, $block->getId ());
@ -119,7 +119,7 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function top(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt($x, $pos1->y, $z, $block->getId ()); $level->setBlockIdAt($x, $pos1->y, $z, $block->getId ());
@ -136,7 +136,7 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function corners(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($y = $pos1->y; $y >= $pos2->y; $y --) { for($y = $pos1->y; $y >= $pos2->y; $y --) {
$level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId ()); $level->setBlockIdAt($pos1->x, $y, $pos1->z, $block->getId ());
$level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage ()); $level->setBlockDataAt($pos1->x, $y, $pos1->z, $block->getDamage ());
@ -158,7 +158,7 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) { public static function bottom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block) {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --)
for($z = $pos1->z; $z >= $pos2->z; $z --) { for($z = $pos1->z; $z >= $pos2->z; $z --) {
$level->setBlockIdAt($x, $pos2->y, $z, $block->getId ()); $level->setBlockIdAt($x, $pos2->y, $z, $block->getId ());
@ -176,15 +176,15 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) { public static function buildRandom(ChunkManager $level, Vector3 $pos, Vector3 $infos, Random $random, Block $block) {
$xBounded = $random->nextBoundedInt(3 ) - 1; $xBounded = $random->nextBoundedInt(3) - 1;
$yBounded = $random->nextBoundedInt(3 ) - 1; $yBounded = $random->nextBoundedInt(3) - 1;
$zBounded = $random->nextBoundedInt(3 ) - 1; $zBounded = $random->nextBoundedInt(3) - 1;
$pos = $pos->round (); $pos = $pos->round ();
for($x = $pos->x - ($infos->x / 2); $x <= $pos->x + ($infos->x / 2); $x ++) { for($x = $pos->x - ($infos->x / 2); $x <= $pos->x + ($infos->x / 2); $x ++) {
for($y = $pos->y - ($infos->y / 2); $y <= $pos->y + ($infos->y / 2); $y ++) { for($y = $pos->y - ($infos->y / 2); $y <= $pos->y + ($infos->y / 2); $y ++) {
for($z = $pos->z - ($infos->z / 2); $z <= $pos->z + ($infos->z / 2); $z ++) { for($z = $pos->z - ($infos->z / 2); $z <= $pos->z + ($infos->z / 2); $z ++) {
// if(abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < (abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2 // if(abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < (abs($infos->x / 2 + $xBounded) + abs($infos->y / 2 + $yBounded) + abs($infos->z / 2 + $zBounded)) ** 2
if (abs((abs($x ) - abs($pos->x )) ** 2 + ($y - $pos->y) ** 2 + (abs($z ) - abs($pos->z )) ** 2 ) < ((($infos->x / 2 - $xBounded) + ($infos->y / 2 - $yBounded) + ($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && ! in_array($level->getBlockIdAt($x, $y, $z ), self::TO_NOT_OVERWRITE ) && ! in_array($level->getBlockIdAt($x, $y + 1, $z ), self::TO_NOT_OVERWRITE )) { if (abs((abs($x) - abs($pos->x)) ** 2 + ($y - $pos->y) ** 2 + (abs($z) - abs($pos->z)) ** 2) < ((($infos->x / 2 - $xBounded) + ($infos->y / 2 - $yBounded) + ($infos->z / 2 - $zBounded)) / 3) ** 2 && $y > 0 && ! in_array($level->getBlockIdAt($x, $y, $z), self::TO_NOT_OVERWRITE) && ! in_array($level->getBlockIdAt($x, $y + 1, $z), self::TO_NOT_OVERWRITE)) {
$level->setBlockIdAt($x, $y, $z, $block->getId ()); $level->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt($x, $y, $z, $block->getDamage ()); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
} }
@ -200,8 +200,8 @@ class BuildingUtils {
* @return array * @return array
*/ */
protected static function minmax(Vector3 $pos1, Vector3 $pos2): array { protected static function minmax(Vector3 $pos1, Vector3 $pos2): array {
$v1 = new Vector3(max($pos1->x, $pos2->x ), max($pos1->y, $pos2->y ), max($pos1->z, $pos2->z )); $v1 = new Vector3(max($pos1->x, $pos2->x), max($pos1->y, $pos2->y), max($pos1->z, $pos2->z));
$v2 = new Vector3(min($pos1->x, $pos2->x ), min($pos1->y, $pos2->y ), min($pos1->z, $pos2->z )); $v2 = new Vector3(min($pos1->x, $pos2->x), min($pos1->y, $pos2->y), min($pos1->z, $pos2->z));
return [ return [
$v1, $v1,
$v2 $v2