forked from Ad5001/BetterGen
Merge pull request #34 from wyt3dr4g0n/master
Updated code for 3.0.0ALPHA9
This commit is contained in:
commit
e7ef5620d1
17 changed files with 76 additions and 82 deletions
|
@ -17,7 +17,7 @@ author: Ad5001
|
||||||
main: Ad5001\BetterGen\Main
|
main: Ad5001\BetterGen\Main
|
||||||
version: 1.1
|
version: 1.1
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api: [3.0.1, 3.0.0-ALPHA3]
|
api: [3.0.0-ALPHA9]
|
||||||
commands:
|
commands:
|
||||||
createworld:
|
createworld:
|
||||||
description: Generates a new world.
|
description: Generates a new world.
|
||||||
|
|
|
@ -127,15 +127,13 @@ class Main extends PluginBase implements Listener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args[1]);
|
$generatorName = strtolower($args[1]);
|
||||||
if (preg_match("[^\d]", $args[2]) !== false) {
|
|
||||||
$parts = str_split($args[2]);
|
$parts = str_split($args[2]);
|
||||||
foreach ($parts as $key=>$str) {
|
foreach ($parts as $key=>$str) {
|
||||||
|
if(is_numeric($str) == false && $str <> '-'){
|
||||||
$parts[$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
|
||||||
} else {
|
|
||||||
$seed = $args[2];
|
|
||||||
}
|
}
|
||||||
|
$seed = (int)implode("", $parts);
|
||||||
$options = [];
|
$options = [];
|
||||||
break;
|
break;
|
||||||
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
||||||
|
@ -147,15 +145,13 @@ class Main extends PluginBase implements Listener {
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args[1]);
|
$generatorName = strtolower($args[1]);
|
||||||
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
|
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
|
||||||
if (preg_match("[^\d]", $args[2]) !== false) {
|
|
||||||
$parts = str_split($args[2]);
|
$parts = str_split($args[2]);
|
||||||
foreach ($parts as $key=>$str) {
|
foreach ($parts as $key=>$str) {
|
||||||
|
if(is_numeric($str) == false && $str <> '-'){
|
||||||
$parts[$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
|
||||||
} else {
|
|
||||||
$seed = $args[2];
|
|
||||||
}
|
}
|
||||||
|
$seed = (int)implode("", $parts);
|
||||||
unset($args[0], $args[1], $args[2]);
|
unset($args[0], $args[1], $args[2]);
|
||||||
$options = json_decode($args[3], true);
|
$options = json_decode($args[3], true);
|
||||||
if (!is_array($options)) {
|
if (!is_array($options)) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
$this->temperature = $infos[0];
|
$this->temperature = $infos[0];
|
||||||
$this->rainfall = $infos[1];
|
$this->rainfall = $infos[1];
|
||||||
}
|
}
|
||||||
public function getName() {
|
public function getName(): string {
|
||||||
return str_ireplace(" ", "", self::$types[$this->type]);
|
return str_ireplace(" ", "", self::$types[$this->type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return self::$ids[$this->type];
|
return self::$ids[$this->type];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -127,7 +127,7 @@ class BetterMesa extends SandyBiome {
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return 39;
|
return 39;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -122,7 +122,7 @@ class BetterMesaPlains extends SandyBiome {
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId(): int {
|
||||||
return 40;
|
return 40;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -101,7 +101,7 @@ class BetterBiomeSelector extends BiomeSelector {
|
||||||
*
|
*
|
||||||
* @return Biome
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public function pickBiome($x, $z) {
|
public function pickBiome($x, $z): Biome {
|
||||||
$temperature = ($this->getTemperature($x, $z));
|
$temperature = ($this->getTemperature($x, $z));
|
||||||
$rainfall = ($this->getRainfall($x, $z));
|
$rainfall = ($this->getRainfall($x, $z));
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ class BetterNormal extends Generator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
* @return Biome
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public function pickBiome($x, $z) {
|
public function pickBiome($x, $z): Biome {
|
||||||
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed ();
|
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed ();
|
||||||
$hash *= $hash + 223;
|
$hash *= $hash + 223;
|
||||||
$xNoise = $hash >> 20 & 3;
|
$xNoise = $hash >> 20 & 3;
|
||||||
|
|
|
@ -100,7 +100,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
// 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::PLANKS);
|
||||||
}, $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) {
|
||||||
|
@ -114,9 +114,9 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
|
||||||
$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
|
||||||
|
@ -141,7 +141,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $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) {
|
||||||
|
@ -155,9 +155,9 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
$level->setBlockIdAt($x, $y + 1, $z + 1, Block::FENCE);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z - 1, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z + 1, Block::PLANKS);
|
||||||
$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
|
||||||
|
@ -182,7 +182,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $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) {
|
||||||
|
@ -196,9 +196,9 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
|
||||||
$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
|
||||||
|
@ -223,7 +223,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $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) {
|
||||||
|
@ -237,9 +237,9 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
$level->setBlockIdAt($x + 1, $y + 1, $z, Block::FENCE);
|
||||||
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x - 1, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x, $y + 2, $z, Block::PLANKS);
|
||||||
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANK);
|
$level->setBlockIdAt($x + 1, $y + 2, $z, Block::PLANKS);
|
||||||
$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
|
||||||
|
@ -298,13 +298,13 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $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::PLANKS));
|
||||||
|
|
||||||
$newFloor = $random->nextBoolean ();
|
$newFloor = $random->nextBoolean ();
|
||||||
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
||||||
|
@ -378,7 +378,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_XMIN :
|
case self::DIR_XMIN :
|
||||||
|
@ -386,7 +386,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZPLUS :
|
case self::DIR_ZPLUS :
|
||||||
|
@ -394,7 +394,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZMIN :
|
case self::DIR_ZMIN :
|
||||||
|
@ -402,7 +402,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
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::PLANKS);
|
||||||
}, $this->level);
|
}, $this->level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Bush extends Object {
|
class Bush extends PopulatorObject {
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
17 => true,
|
17 => true,
|
||||||
|
|
|
@ -19,10 +19,10 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Cactus extends Object {
|
class Cactus extends PopulatorObject {
|
||||||
|
|
||||||
protected $totalHeight;
|
protected $totalHeight;
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ namespace Ad5001\BetterGen\structure;
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Dungeons extends Object {
|
class Dungeons extends PopulatorObject {
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
17 => true,
|
17 => true,
|
||||||
|
|
|
@ -20,13 +20,13 @@ namespace Ad5001\BetterGen\structure;
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\level\generator\object\Tree as ObjectTree;
|
use pocketmine\level\generator\object\Tree as ObjectTree;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
|
||||||
class FallenTree extends Object {
|
class FallenTree extends PopulatorObject {
|
||||||
public static $overridable = [
|
public static $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
6 => true,
|
6 => true,
|
||||||
|
@ -37,8 +37,7 @@ class FallenTree extends Object {
|
||||||
Block::SNOW_LAYER => true,
|
Block::SNOW_LAYER => true,
|
||||||
Block::LOG2 => true,
|
Block::LOG2 => true,
|
||||||
Block::LEAVES2 => true,
|
Block::LEAVES2 => true,
|
||||||
Block::CACTUS => true
|
Block::CACTUS => true];
|
||||||
];
|
|
||||||
/** @var Tree */
|
/** @var Tree */
|
||||||
protected $tree;
|
protected $tree;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
@ -68,9 +67,9 @@ class FallenTree extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
echo "Checking at $x $y $z FallenTree\n";
|
//echo "Checking at $x $y $z FallenTree\n";
|
||||||
$randomHeight = round($random->nextBoundedInt($this->tree->trunkHeight < 6 ? 6 : $this->tree->trunkHeight) - ($this->tree->trunkHeight < 6 ? 3 : $this->tree->trunkHeight / 2));
|
$randomHeight = round($random->nextBoundedInt($this->tree->treeHeight < 6 ? 6 : $this->tree->treeHeight) - ($this->tree->treeHeight < 6 ? 3 : $this->tree->treeHeight / 2));
|
||||||
$this->length = ($this->tree->trunkHeight ?? 5) + $randomHeight;
|
$this->length = ($this->tree->treeHeight ?? 5) + $randomHeight;
|
||||||
$this->direction = $random->nextBoundedInt(4);
|
$this->direction = $random->nextBoundedInt(4);
|
||||||
$this->random = $random;
|
$this->random = $random;
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
|
@ -78,12 +77,12 @@ class FallenTree extends Object {
|
||||||
case 1:// Z+
|
case 1:// Z+
|
||||||
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function($v3, $level) {
|
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function($v3, $level) {
|
||||||
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x, $y - 1, $z + $this->length), function($v3, $level) {
|
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x, $y - 1, $z + $this->length), function($v3, $level) {
|
||||||
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level));
|
}, $level));
|
||||||
|
@ -95,12 +94,12 @@ class FallenTree extends Object {
|
||||||
case 3: // X+
|
case 3: // X+
|
||||||
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) {
|
$return = array_merge(BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) {
|
||||||
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(!isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is not overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x + $this->length, $y - 1, $z), function($v3, $level) {
|
}, $level), BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z), new Vector3($x + $this->length, $y - 1, $z), function($v3, $level) {
|
||||||
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
if(isset(\Ad5001\BetterGen\structure\FallenTree::$overridable[$level->getBlockIdAt($v3->x, $v3->y, $v3->z)])) {
|
||||||
echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
//echo "$v3 is overwritable (" . $level->getBlockIdAt($v3->x, $v3->y, $v3->z) . ").\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, $level));
|
}, $level));
|
||||||
|
@ -122,7 +121,7 @@ class FallenTree extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function placeObject(ChunkManager $level, $x, $y, $z) {
|
public function placeObject(ChunkManager $level, $x, $y, $z) {
|
||||||
echo "Placing at $x $y $z FallenTree D: $this->direction, L: $this->length\n";
|
//echo "Placing at $x $y $z FallenTree D: $this->direction, L: $this->length\n";
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
case 0:
|
case 0:
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
|
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
|
||||||
|
|
|
@ -19,10 +19,10 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Igloo extends Object {
|
class Igloo extends PopulatorObject {
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
Block::AIR => true,
|
Block::AIR => true,
|
||||||
6 => true,
|
6 => true,
|
||||||
|
|
|
@ -20,10 +20,10 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class SugarCane extends Object {
|
class SugarCane extends PopulatorObject {
|
||||||
|
|
||||||
protected $totalHeight;
|
protected $totalHeight;
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ namespace Ad5001\BetterGen\structure;
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
class Temple extends Object {
|
class Temple extends PopulatorObject {
|
||||||
const DIRECTION_PLUSX = 0;
|
const DIRECTION_PLUSX = 0;
|
||||||
const DIRECTION_MINX = 1;
|
const DIRECTION_MINX = 1;
|
||||||
const DIRECTION_PLUSZ = 2;
|
const DIRECTION_PLUSZ = 2;
|
||||||
|
|
|
@ -20,11 +20,11 @@ namespace Ad5001\BetterGen\structure;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\level\generator\object\Object;
|
use pocketmine\level\generator\object\PopulatorObject;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
|
||||||
class Well extends Object {
|
class Well extends PopulatorObject {
|
||||||
/** @var ChunkManager */
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
public $overridable = [
|
public $overridable = [
|
||||||
|
|
|
@ -30,8 +30,7 @@ class BuildingUtils {
|
||||||
Block::LAVA,
|
Block::LAVA,
|
||||||
Block::BEDROCK,
|
Block::BEDROCK,
|
||||||
Block::CACTUS,
|
Block::CACTUS,
|
||||||
Block::PLANK
|
Block::PLANKS];
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an area
|
* Fills an area
|
||||||
|
|
Loading…
Reference in a new issue