mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Better vanilla layers support (no meta, MCPE doesn't support it)
This commit is contained in:
@ -82,6 +82,21 @@ class Flat extends Generator{
|
||||
}*/
|
||||
}
|
||||
|
||||
public static function parseLayers(string $layers) : array{
|
||||
$result = [];
|
||||
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $layers), $matches);
|
||||
$y = 0;
|
||||
foreach($matches[3] as $i => $b){
|
||||
$b = Item::fromString($b . $matches[4][$i]);
|
||||
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
||||
for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
|
||||
$result[$cY] = [$b->getId(), $b->getDamage()];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function parsePreset($preset, $chunkX, $chunkZ){
|
||||
$this->preset = $preset;
|
||||
$preset = explode(";", $preset);
|
||||
@ -89,19 +104,11 @@ class Flat extends Generator{
|
||||
$blocks = $preset[1] ?? "";
|
||||
$biome = $preset[2] ?? 1;
|
||||
$options = $preset[3] ?? "";
|
||||
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
|
||||
$y = 0;
|
||||
$this->structure = [];
|
||||
$this->chunks = [];
|
||||
foreach($matches[3] as $i => $b){
|
||||
$b = Item::fromString($b . $matches[4][$i]);
|
||||
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
||||
for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
|
||||
$this->structure[$cY] = [$b->getId(), $b->getDamage()];
|
||||
}
|
||||
}
|
||||
$this->structure = self::parseLayers($blocks);
|
||||
|
||||
$this->floorLevel = $y;
|
||||
$this->chunks = [];
|
||||
|
||||
$this->floorLevel = $y = count($this->structure);
|
||||
|
||||
for(; $y < 0xFF; ++$y){
|
||||
$this->structure[$y] = [0, 0];
|
||||
|
Reference in New Issue
Block a user