73 $split = array_map(
'\trim', explode(
',', $layers));
75 $itemParser = LegacyStringToItemParser::getInstance();
76 foreach($split as $line){
77 if(preg_match(
'#^(?:(\d+)[x|*])?(.+)$#', $line, $matches) !== 1){
81 $cnt = $matches[1] !==
"" ? (int) $matches[1] : 1;
83 $b = $itemParser->parse($matches[2])->getBlock();
84 }
catch(LegacyStringToItemParserException $e){
87 for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
88 $result[$cY] = $b->getStateId();
98 public static function parsePreset(
string $presetString) : self{
99 $preset = explode(
";", $presetString);
100 $blocks = $preset[1] ??
"";
101 $biomeId = (int) ($preset[2] ?? BiomeIds::PLAINS);
102 $optionsString = $preset[3] ??
"";
103 $structure = self::parseLayers($blocks);
107 preg_match_all(
'#(([0-9a-z_]{1,})\(?([0-9a-z_ =:]{0,})\)?),?#', $optionsString, $matches);
108 foreach($matches[2] as $i => $option){
110 if($matches[3][$i] !==
""){
112 $p = explode(
" ", $matches[3][$i]);
114 $k = explode(
"=", $k);
116 $params[$k[0]] = $k[1];
120 $options[$option] = $params;
122 return new self($structure, $biomeId, $options);