Fixing formating (again)
This commit is contained in:
parent
be6965b909
commit
668cc0de55
12 changed files with 142 additions and 137 deletions
|
@ -107,62 +107,62 @@ class Main extends PluginBase implements Listener {
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 1 : // /createworld <name>
|
case 1 : // /createworld <name>
|
||||||
$name = $args [0];
|
$name = $args[0];
|
||||||
$generator = Generator::getGenerator("betternormal");
|
$generator = Generator::getGenerator("betternormal");
|
||||||
$generatorName = "betternormal";
|
$generatorName = "betternormal";
|
||||||
$seed = $this->generateRandomSeed();
|
$seed = $this->generateRandomSeed();
|
||||||
$options = [];
|
$options = [];
|
||||||
break;
|
break;
|
||||||
case 2 : // /createworld <name> [generator = betternormal]
|
case 2 : // /createworld <name> [generator = betternormal]
|
||||||
$name = $args [0];
|
$name = $args[0];
|
||||||
$generator = Generator::getGenerator($args [1]);
|
$generator = Generator::getGenerator($args[1]);
|
||||||
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
|
if (Generator::getGeneratorName($generator) !== strtolower($args[1])) {
|
||||||
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args [1]);
|
$generatorName = strtolower($args[1]);
|
||||||
$seed = $this->generateRandomSeed();
|
$seed = $this->generateRandomSeed();
|
||||||
$options = [];
|
$options = [];
|
||||||
break;
|
break;
|
||||||
case 3 : // /createworld <name> [generator = betternormal] [seed = rand()]
|
case 3 : // /createworld <name> [generator = betternormal] [seed = rand()]
|
||||||
$name = $args [0];
|
$name = $args[0];
|
||||||
$generator = Generator::getGenerator($args [1]);
|
$generator = Generator::getGenerator($args[1]);
|
||||||
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
|
if (Generator::getGeneratorName($generator) !== strtolower($args[1])) {
|
||||||
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$generatorName = strtolower($args [1]);
|
$generatorName = strtolower($args[1]);
|
||||||
if (preg_match("[^\d]", $args [2]) !== false) {
|
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) {
|
||||||
$parts [$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
$seed = implode("", $parts);
|
||||||
} else {
|
} else {
|
||||||
$seed = $args [2];
|
$seed = $args[2];
|
||||||
}
|
}
|
||||||
$options = [];
|
$options = [];
|
||||||
break;
|
break;
|
||||||
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
|
||||||
$name = $args [0];
|
$name = $args[0];
|
||||||
$generator = Generator::getGenerator($args [1]);
|
$generator = Generator::getGenerator($args[1]);
|
||||||
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
|
if (Generator::getGeneratorName($generator) !== strtolower($args[1])) {
|
||||||
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$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) {
|
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) {
|
||||||
$parts [$key] = ord($str);
|
$parts[$key] = ord($str);
|
||||||
}
|
}
|
||||||
$seed = implode("", $parts);
|
$seed = implode("", $parts);
|
||||||
} else {
|
} else {
|
||||||
$seed = $args [2];
|
$seed = $args[2];
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
|
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -227,7 +227,7 @@ class Main extends PluginBase implements Listener {
|
||||||
return false;
|
return false;
|
||||||
if (!@is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree"))
|
if (!@is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree"))
|
||||||
return false;
|
return false;
|
||||||
if (count($infos) < 2 or !is_float($infos [0]) or !is_float($infos [1]))
|
if (count($infos) < 2 or !is_float($infos[0]) or !is_float($infos[1]))
|
||||||
return false;
|
return false;
|
||||||
return BetterForest::registerForest($name, $treeClass, $infos);
|
return BetterForest::registerForest($name, $treeClass, $infos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -60,8 +60,8 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
|
|
||||||
$this->setElevation(63, 69);
|
$this->setElevation(63, 69);
|
||||||
|
|
||||||
$this->temperature = $infos [0];
|
$this->temperature = $infos[0];
|
||||||
$this->rainfall = $infos [1];
|
$this->rainfall = $infos[1];
|
||||||
}
|
}
|
||||||
public function getName() {
|
public function getName() {
|
||||||
return str_ireplace(" ", "", self::$types[$this->type]);
|
return str_ireplace(" ", "", self::$types[$this->type]);
|
||||||
|
@ -72,7 +72,7 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return self::$ids [$this->type];
|
return self::$ids[$this->type];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
@ -81,9 +81,9 @@ class BetterForest extends ForestBiome implements Mountainable {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function registerForest(string $name, string $treeClass, array $infos): bool {
|
public static function registerForest(string $name, string $treeClass, array $infos): bool {
|
||||||
self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass) [count(explode("\\", $treeClass))]) . " Forest";
|
self::$types[] = str_ireplace("tree", "", explode("\\", $treeClass)[count(explode("\\", $treeClass))]) . " Forest";
|
||||||
TreePopulator::$types [] = $treeClass;
|
TreePopulator::$types[] = $treeClass;
|
||||||
self::$ids [] = Main::SAKURA_FOREST + (count(self::$types) - 2);
|
self::$ids[] = Main::SAKURA_FOREST + (count(self::$types) - 2);
|
||||||
Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
|
Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class BetterBiomeSelector extends BiomeSelector {
|
||||||
public function recalculate() {
|
public function recalculate() {
|
||||||
} // Using our own system, No need for that
|
} // Using our own system, No need for that
|
||||||
public function addBiome(Biome $biome) {
|
public function addBiome(Biome $biome) {
|
||||||
$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;
|
||||||
|
@ -64,7 +64,7 @@ class BetterBiomeSelector extends BiomeSelector {
|
||||||
$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));
|
||||||
return $b;
|
return $b;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -74,7 +74,10 @@ class BetterNormal extends Generator {
|
||||||
protected static $GAUSSIAN_KERNEL = null; // From main class
|
protected static $GAUSSIAN_KERNEL = null; // From main class
|
||||||
protected static $SMOOTH_SIZE = 2;
|
protected static $SMOOTH_SIZE = 2;
|
||||||
protected static $options = [
|
protected static $options = [
|
||||||
"deleteBiomes" => [
|
"delBio" => [
|
||||||
|
],
|
||||||
|
"delStruct" => [
|
||||||
|
"Lakes"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
protected $waterHeight = 63;
|
protected $waterHeight = 63;
|
||||||
|
@ -116,7 +119,7 @@ class BetterNormal extends Generator {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$this->random = $random;
|
$this->random = $random;
|
||||||
|
|
||||||
self::$levels [] = $level;
|
self::$levels[] = $level;
|
||||||
|
|
||||||
$this->random->setSeed($this->level->getSeed ());
|
$this->random->setSeed($this->level->getSeed ());
|
||||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
||||||
|
@ -158,57 +161,57 @@ class BetterNormal extends Generator {
|
||||||
$this->selector->recalculate ();
|
$this->selector->recalculate ();
|
||||||
|
|
||||||
$cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover();
|
$cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover();
|
||||||
$this->generationPopulators [] = $cover;
|
$this->generationPopulators[] = $cover;
|
||||||
|
|
||||||
// https://twitter.com/Ad5001P4F/status/859430935468670976
|
if() {
|
||||||
// $lake = new LakePopulator ();
|
$lake = new LakePopulator();
|
||||||
// $lake->setBaseAmount(0);
|
$lake->setBaseAmount(0);
|
||||||
// $lake->setRandomAmount(1);
|
$lake->setRandomAmount(1);
|
||||||
// $this->generationPopulators [] = $lake;
|
$this->generationPopulators[] = $lake;
|
||||||
|
|
||||||
$cave = new CavePopulator ();
|
$cave = new CavePopulator ();
|
||||||
$cave->setBaseAmount(0);
|
$cave->setBaseAmount(0);
|
||||||
$cave->setRandomAmount(2);
|
$cave->setRandomAmount(2);
|
||||||
$this->generationPopulators [] = $cave;
|
$this->generationPopulators[] = $cave;
|
||||||
|
|
||||||
$ravine = new RavinePopulator ();
|
$ravine = new RavinePopulator ();
|
||||||
$ravine->setBaseAmount(0);
|
$ravine->setBaseAmount(0);
|
||||||
$ravine->setRandomAmount(51);
|
$ravine->setRandomAmount(51);
|
||||||
$this->generationPopulators [] = $ravine;
|
$this->generationPopulators[] = $ravine;
|
||||||
|
|
||||||
$mineshaft = new MineshaftPopulator ();
|
$mineshaft = new MineshaftPopulator ();
|
||||||
$mineshaft->setBaseAmount(0);
|
$mineshaft->setBaseAmount(0);
|
||||||
$mineshaft->setRandomAmount(102);
|
$mineshaft->setRandomAmount(102);
|
||||||
$this->populators [] = $mineshaft;
|
$this->populators[] = $mineshaft;
|
||||||
|
|
||||||
|
|
||||||
$fisl = new FloatingIslandPopulator();
|
$fisl = new FloatingIslandPopulator();
|
||||||
$fisl->setBaseAmount(0);
|
$fisl->setBaseAmount(0);
|
||||||
$fisl->setRandomAmount(132);
|
$fisl->setRandomAmount(132);
|
||||||
$this->populators [] = $fisl;
|
$this->populators[] = $fisl;
|
||||||
|
|
||||||
$ores = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -217,13 +220,13 @@ class BetterNormal extends Generator {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function registerBiome(Biome $biome): bool {
|
public static function registerBiome(Biome $biome): bool {
|
||||||
if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["deleteBiomes"])) {
|
if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["delBio"])) {
|
||||||
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,8 +239,8 @@ 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)
|
||||||
|
@ -248,7 +251,7 @@ class BetterNormal extends Generator {
|
||||||
$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;
|
||||||
|
@ -298,16 +301,16 @@ class BetterNormal extends Generator {
|
||||||
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
||||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||||
|
|
||||||
$weight = self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
|
$weight = self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE];
|
||||||
|
|
||||||
if ($sx === 0 and $sz === 0) {
|
if ($sx === 0 and $sz === 0) {
|
||||||
$adjacent = $biome;
|
$adjacent = $biome;
|
||||||
} else {
|
} else {
|
||||||
$index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
$index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
||||||
if (isset($biomeCache [$index])) {
|
if (isset($biomeCache[$index])) {
|
||||||
$adjacent = $biomeCache [$index];
|
$adjacent = $biomeCache[$index];
|
||||||
} else {
|
} else {
|
||||||
$biomeCache [$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
$biomeCache[$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$minSum += ($adjacent->getMinElevation () - 1) * $weight;
|
$minSum += ($adjacent->getMinElevation () - 1) * $weight;
|
||||||
|
@ -327,7 +330,7 @@ class BetterNormal extends Generator {
|
||||||
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
$chunk->setBlockId($x, $y, $z, Block::BEDROCK);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$noiseValue = $noise [$x] [$z] [$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum);
|
$noiseValue = $noise[$x] [$z] [$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum);
|
||||||
|
|
||||||
if ($noiseValue > 0) {
|
if ($noiseValue > 0) {
|
||||||
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
$chunk->setBlockId($x, $y, $z, Block::STONE);
|
||||||
|
@ -374,15 +377,17 @@ class BetterNormal extends Generator {
|
||||||
public function __construct(array $options = []) {
|
public function __construct(array $options = []) {
|
||||||
self::$options["preset"] = $options["preset"];
|
self::$options["preset"] = $options["preset"];
|
||||||
$options = (array) json_decode($options["preset"]);
|
$options = (array) json_decode($options["preset"]);
|
||||||
if(isset($options["deleteBiomes"]) && is_string($options["deleteBiomes"])) {
|
if(isset($options["delBio"])) {
|
||||||
$options["deleteBiomes"] = explode(",", $options["deleteBiomes"]);
|
if(is_string($options["de"])) $options["delBio"] = explode(",", $options["delBio"]);
|
||||||
if(count($options["deleteBiomes"]) !== 0) {
|
if(count($options["delBio"]) !== 0) {
|
||||||
self::$options["deleteBiomes"] = $options["deleteBiomes"];
|
self::$options["delBio"] = $options["delBio"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(isset($options["delStruct"])) {
|
||||||
if(isset($options["deleteBiomes"]) && count($options["deleteBiomes"]) !== 0) {
|
if(is_string($options["delStruct"])) $options["delStruct"] = explode(",", $options["delStruct"]);
|
||||||
self::$options["deleteBiomes"] = $options["deleteBiomes"];
|
if(count($options["delStruct"]) !== 0) {
|
||||||
|
self::$options["delStruct"] = $options["delStruct"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (self::$GAUSSIAN_KERNEL === null) {
|
if (self::$GAUSSIAN_KERNEL === null) {
|
||||||
self::generateKernel ();
|
self::generateKernel ();
|
||||||
|
@ -399,12 +404,12 @@ class BetterNormal extends Generator {
|
||||||
$bellHeight = 2 * self::$SMOOTH_SIZE;
|
$bellHeight = 2 * self::$SMOOTH_SIZE;
|
||||||
|
|
||||||
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
for($sx = - self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; $sx++) {
|
||||||
self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] = [ ];
|
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] = [ ];
|
||||||
|
|
||||||
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
for($sz = - self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; $sz++) {
|
||||||
$bx = $bellSize * $sx;
|
$bx = $bellSize * $sx;
|
||||||
$bz = $bellSize * $sz;
|
$bz = $bellSize * $sz;
|
||||||
self::$GAUSSIAN_KERNEL [$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp(- ($bx * $bx + $bz * $bz) / 2);
|
self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE] [$sz + self::$SMOOTH_SIZE] = $bellHeight * exp(- ($bx * $bx + $bz * $bz) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,19 +271,19 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
switch ($dir) {
|
switch ($dir) {
|
||||||
case self::DIR_XPLUS :
|
case self::DIR_XPLUS :
|
||||||
$x ++;
|
$x ++;
|
||||||
unset($possiblePathes [0]);
|
unset($possiblePathes[0]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_XMIN :
|
case self::DIR_XMIN :
|
||||||
$x --;
|
$x --;
|
||||||
unset($possiblePathes [1]);
|
unset($possiblePathes[1]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZPLUS :
|
case self::DIR_ZPLUS :
|
||||||
$z ++;
|
$z ++;
|
||||||
unset($possiblePathes [2]);
|
unset($possiblePathes[2]);
|
||||||
break;
|
break;
|
||||||
case self::DIR_ZMIN :
|
case self::DIR_ZMIN :
|
||||||
$z --;
|
$z --;
|
||||||
unset($possiblePathes [3]);
|
unset($possiblePathes[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
$numberFloor = $random->nextBoundedInt(4 + ($newFloor ? 5 : 0));
|
||||||
$possiblePathes = [
|
$possiblePathes = [
|
||||||
$possiblePathes,
|
$possiblePathes,
|
||||||
($newFloor ? [
|
($newFloor ?[
|
||||||
self::DIR_XPLUS,
|
self::DIR_XPLUS,
|
||||||
self::DIR_XMIN,
|
self::DIR_XMIN,
|
||||||
self::DIR_ZPLUS,
|
self::DIR_ZPLUS,
|
||||||
|
@ -313,10 +313,10 @@ 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);
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TreePopulator extends AmountPopulator {
|
||||||
if ($y === -1) {
|
if ($y === -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$treeC = self::$types [$this->type];
|
$treeC = self::$types[$this->type];
|
||||||
/** @var Tree $tree */
|
/** @var Tree $tree */
|
||||||
$tree = new $treeC();
|
$tree = new $treeC();
|
||||||
$tree->placeObject($level, $x, $y, $z, $random);
|
$tree->placeObject($level, $x, $y, $z, $random);
|
||||||
|
|
|
@ -72,9 +72,9 @@ class Bush extends Object {
|
||||||
* @param $level pocketmine\level\ChunkManager
|
* @param $level pocketmine\level\ChunkManager
|
||||||
*/
|
*/
|
||||||
public function placeLeaf($x, $y, $z, ChunkManager $level) {
|
public function placeLeaf($x, $y, $z, ChunkManager $level) {
|
||||||
if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z)]) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z)])) {
|
if (isset($this->overridable[$level->getBlockIdAt($x, $y, $z)]) && ! isset($this->overridable[$level->getBlockIdAt($x, $y - 1, $z)])) {
|
||||||
$level->setBlockIdAt($x, $y, $z, $this->leaf [0]);
|
$level->setBlockIdAt($x, $y, $z, $this->leaf[0]);
|
||||||
$level->setBlockDataAt($x, $y, $z, $this->leaf [1]);
|
$level->setBlockDataAt($x, $y, $z, $this->leaf[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -155,9 +155,9 @@ 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class Igloo extends Object {
|
||||||
// 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 ++) {
|
||||||
|
|
|
@ -493,7 +493,7 @@ class SakuraTree extends Tree {
|
||||||
$zDiff = 0;
|
$zDiff = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
list($vParts, $hParts) = self::TRUNK_POS [$trunkHeight];
|
list($vParts, $hParts) = self::TRUNK_POS[$trunkHeight];
|
||||||
|
|
||||||
$this->setLog($level, $x, $y, $z);
|
$this->setLog($level, $x, $y, $z);
|
||||||
list($lastX, $lastY, $lastZ) = [
|
list($lastX, $lastY, $lastZ) = [
|
||||||
|
@ -643,15 +643,15 @@ class SakuraTree extends Tree {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leaves falling from the tree diagonally
|
// Leaves falling from the tree diagonally
|
||||||
foreach (self::DIAG_LEAVES [$trunkHeight] as $pos) {
|
foreach (self::DIAG_LEAVES[$trunkHeight] as $pos) {
|
||||||
$numDown = $random->nextBoundedInt(3) + 1;
|
$numDown = $random->nextBoundedInt(3) + 1;
|
||||||
for ($y = $lastY + 1; $y > $lastY - $numDown; $y--)
|
for ($y = $lastY + 1; $y > $lastY - $numDown; $y--)
|
||||||
$this->setLeave($level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random);
|
$this->setLeave($level, $lastX + $pos[0], $y, $lastZ + $pos[1], $random);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additional leaves
|
// Additional leaves
|
||||||
foreach (self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos) {
|
foreach (self::ADDITIONAL_BLOCKS[$trunkHeight] as $pos) {
|
||||||
$this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random);
|
$this->setLeave($level, $lastX + $pos[0], $lastY + 2, $lastZ + $pos[1], $random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class Temple extends Object {
|
||||||
for ($xx = $x - 10; $xx <= $x + 10; $xx++)
|
for ($xx = $x - 10; $xx <= $x + 10; $xx++)
|
||||||
for ($yy = $y + 1; $yy <= $y + 11; $yy++)
|
for ($yy = $y + 1; $yy <= $y + 11; $yy++)
|
||||||
for ($zz = $z - 10; $zz <= $z + 10; $zz++)
|
for ($zz = $z - 10; $zz <= $z + 10; $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;
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,8 @@ class Temple extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (self::THREE_DIAGS as $diagPos) {
|
foreach (self::THREE_DIAGS as $diagPos) {
|
||||||
$this->placeBlock($x + $diagPos [0], $y - 10, $z + $diagPos [1], Block::SANDSTONE, 1);
|
$this->placeBlock($x + $diagPos[0], $y - 10, $z + $diagPos[1], Block::SANDSTONE, 1);
|
||||||
$this->placeBlock($x + $diagPos [0], $y - 11, $z + $diagPos [1], Block::SANDSTONE, 2);
|
$this->placeBlock($x + $diagPos[0], $y - 11, $z + $diagPos[1], Block::SANDSTONE, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floor + TNT
|
// Floor + TNT
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue