75 $split = array_map(
'\trim', explode(
',', $layers, limit: World::Y_MAX - World::Y_MIN));
77 $itemParser = LegacyStringToItemParser::getInstance();
78 foreach($split as $line){
79 if(preg_match(
'#^(?:(\d+)[x|*])?(.+)$#', $line, $matches) !== 1){
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, limit: 4);
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], limit: PHP_INT_MAX);
117 $k = explode(
"=", $k, limit: 3);
119 $params[$k[0]] = $k[1];
123 $options[$option] = $params;
125 return new self($structure, $biomeId, $options);