74 $split = array_map(
'\trim', explode(
',', $layers));
76 $itemParser = LegacyStringToItemParser::getInstance();
77 foreach($split as $line){
78 preg_match(
'#^(?:(\d+)[x|*])?(.+)$#', $line, $matches);
79 if(count($matches) !== 3){
83 $cnt = $matches[1] !==
"" ? (int) $matches[1] : 1;
85 $b = $itemParser->parse($matches[2])->getBlock();
86 }
catch(LegacyStringToItemParserException $e){
89 for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
90 $result[$cY] = $b->getStateId();
101 $preset = explode(
";", $presetString);
102 $blocks = $preset[1] ??
"";
103 $biomeId = (int) ($preset[2] ?? BiomeIds::PLAINS);
104 $optionsString = $preset[3] ??
"";
105 $structure = self::parseLayers($blocks);
109 preg_match_all(
'#(([0-9a-z_]{1,})\(?([0-9a-z_ =:]{0,})\)?),?#', $optionsString, $matches);
110 foreach($matches[2] as $i => $option){
112 if($matches[3][$i] !==
""){
114 $p = explode(
" ", $matches[3][$i]);
116 $k = explode(
"=", $k);
118 $params[$k[0]] = $k[1];
122 $options[(string) $option] = $params;
124 return new self($structure, $biomeId, $options);