本文整理匯總了PHP中pocketmine\level\format\FullChunk::setBlockData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FullChunk::setBlockData方法的具體用法?PHP FullChunk::setBlockData怎麽用?PHP FullChunk::setBlockData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\level\format\FullChunk
的用法示例。
在下文中一共展示了FullChunk::setBlockData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parsePreset
protected function parsePreset($preset)
{
$this->preset = $preset;
$preset = explode(";", $preset);
$version = (int) $preset[0];
$blocks = @$preset[1];
$biome = isset($preset[2]) ? $preset[2] : 1;
$options = isset($preset[3]) ? $preset[3] : "";
preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
$y = 0;
$this->structure = [];
$this->chunks = [];
foreach ($matches[3] as $i => $b) {
$b = Item::fromString($b);
$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->floorLevel = $y;
for (; $y < 0xff; ++$y) {
$this->structure[$y] = [0, 0];
}
$this->chunk = $this->level->getChunk(0, 0);
$this->chunk->setGenerated();
for ($Z = 0; $Z < 16; ++$Z) {
for ($X = 0; $X < 16; ++$X) {
for ($y = 0; $y < 128; ++$y) {
if ($this->structure[$y][0] !== 0) {
$this->chunk->setBlockId($X, $y, $Z, $this->structure[$y][0]);
}
if ($this->structure[$y][0] !== 0) {
$this->chunk->setBlockData($X, $y, $Z, $this->structure[$y][1]);
}
}
}
}
preg_match_all('#(([0-9a-z_]{1,})\\(?([0-9a-z_ =:]{0,})\\)?),?#', $options, $matches);
foreach ($matches[2] as $i => $option) {
$params = true;
if ($matches[3][$i] !== "") {
$params = [];
$p = explode(" ", $matches[3][$i]);
foreach ($p as $k) {
$k = explode("=", $k);
if (isset($k[1])) {
$params[$k[0]] = $k[1];
}
}
}
$this->options[$option] = $params;
}
}