public static function growTree(ChunkManager $level, $x, $y, $z, Random $random, $type = 0) { switch ($type) { case Sapling::SPRUCE: $tree = new SpruceTree(); break; case Sapling::BIRCH: if ($random->nextBoundedInt(39) === 0) { $tree = new BirchTree(true); } else { $tree = new BirchTree(); } break; case Sapling::JUNGLE: $tree = new JungleTree(); break; case Sapling::OAK: default: $tree = new OakTree(); /*if($random->nextRange(0, 9) === 0){ $tree = new BigTree(); }else{*/ //} break; } if ($tree->canPlaceObject($level, $x, $y, $z, $random)) { $tree->placeObject($level, $x, $y, $z, $random); } }
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->treeHeight = $random->nextBoundedInt(4) + 6; $topSize = $this->treeHeight - (1 + $random->nextBoundedInt(2)); $lRadius = 2 + $random->nextBoundedInt(2); $this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - $random->nextBoundedInt(3)); $radius = $random->nextBoundedInt(2); $maxR = 1; $minR = 0; for ($yy = 0; $yy <= $topSize; ++$yy) { $yyy = $y + $this->treeHeight - $yy; for ($xx = $x - $radius; $xx <= $x + $radius; ++$xx) { $xOff = abs($xx - $x); for ($zz = $z - $radius; $zz <= $z + $radius; ++$zz) { $zOff = abs($zz - $z); if ($xOff === $radius and $zOff === $radius and $radius > 0) { continue; } if (!Block::$solid[$level->getBlockIdAt($xx, $yyy, $zz)]) { $level->setBlockIdAt($xx, $yyy, $zz, $this->leafBlock); $level->setBlockDataAt($xx, $yyy, $zz, $this->type); } } } if ($radius >= $maxR) { $radius = $minR; $minR = 1; if (++$maxR > $lRadius) { $maxR = $lRadius; } } else { ++$radius; } } }
public function execute(CommandSender $sender, $currentAlias, array $args) { if (!$this->testPermission($sender)) { return true; } if (count($args) < 7) { $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); return true; } if ($sender instanceof Player) { $level = $sender->getLevel(); } else { $level = $sender->getServer()->getDefaultLevel(); } $name = strtolower($args[0]); $pos = new Vector3((double) $args[1], (double) $args[2], (double) $args[3]); $xd = (double) $args[4]; $yd = (double) $args[5]; $zd = (double) $args[6]; $count = isset($args[7]) ? max(1, (int) $args[7]) : 1; $data = isset($args[8]) ? (int) $args[8] : null; $particle = $this->getParticle($name, $pos, $xd, $yd, $zd, $data); if ($particle === null) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.particle.notFound", [$name])); return true; } $sender->sendMessage(new TranslationContainer("commands.particle.success", [$name, $count])); $random = new Random((int) (microtime(true) * 1000) + mt_rand()); for ($i = 0; $i < $count; ++$i) { $particle->setComponents($pos->x + $random->nextSignedFloat() * $xd, $pos->y + $random->nextSignedFloat() * $yd, $pos->z + $random->nextSignedFloat() * $zd); $level->addParticle($particle); } return true; }
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->treeHeight = $random->nextBoundedInt(3) + 5; if ($this->superBirch) { $this->treeHeight += 5; } parent::placeObject($level, $x, $y, $z, $random); }
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { if ($random->nextRange(0, $this->waterOdd) === 0) { $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 16); $y = $random->nextBoundedInt(128); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 16); $pond = new \BukkitPE\level\generator\object\Pond($random, new Water()); if ($pond->canPlaceObject($level, $x, $y, $z)) { $pond->placeObject($level, $x, $y, $z); } } }
public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, $count = 15, $radius = 10) { $arr = [[Block::DANDELION, 0], [Block::POPPY, 0], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1]]; $arrC = count($arr) - 1; for ($c = 0; $c < $count; ++$c) { $x = $random->nextRange($pos->x - $radius, $pos->x + $radius); $z = $random->nextRange($pos->z - $radius, $pos->z + $radius); if ($level->getBlockIdAt($x, $pos->y + 1, $z) === Block::AIR and $level->getBlockIdAt($x, $pos->y, $z) === Block::GRASS) { $t = $arr[$random->nextRange(0, $arrC)]; $level->setBlockIdAt($x, $pos->y + 1, $z, $t[0]); $level->setBlockDataAt($x, $pos->y + 1, $z, $t[1]); } } }
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { $this->level = $level; $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount; for ($i = 0; $i < $amount; ++$i) { $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); $y = $this->getHighestWorkableBlock($x, $z); if ($y === -1) { continue; } ObjectTree::growTree($this->level, $x, $y, $z, $random, $this->type); } }
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { foreach ($this->oreTypes as $type) { $ore = new ObjectOre($random, $type); for ($i = 0; $i < $ore->type->clusterCount; ++$i) { $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15); $y = $random->nextRange($ore->type->minHeight, $ore->type->maxHeight); $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15); if ($ore->canPlaceObject($level, $x, $y, $z)) { $ore->placeObject($level, $x, $y, $z); } } } }
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { $this->level = $level; $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount; for ($i = 0; $i < $amount; ++$i) { $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $y = $this->getHighestWorkableBlock($x, $z); if ($y !== -1 and $this->canTallGrassStay($x, $y, $z)) { $this->level->setBlockIdAt($x, $y, $z, Block::TALL_GRASS); $this->level->setBlockDataAt($x, $y, $z, 1); } } }
public function populateChunk($chunkX, $chunkZ) { $this->random->setSeed(0xdeadbeef ^ $chunkX << 8 ^ $chunkZ ^ $this->level->getSeed()); foreach ($this->populators as $populator) { $populator->populate($this->level, $chunkX, $chunkZ, $this->random); } }
public function populateChunk($chunkX, $chunkZ) { $this->random->setSeed(0xdeadbeef ^ $chunkX << 8 ^ $chunkZ ^ $this->level->getSeed()); foreach ($this->populators as $populator) { $populator->populate($this->level, $chunkX, $chunkZ, $this->random); } $chunk = $this->level->getChunk($chunkX, $chunkZ); $biome = Biome::getBiome($chunk->getBiomeId(7, 7)); $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random); }
public function __construct(Random $random, $octaves, $persistence, $expansion = 1) { $this->octaves = $octaves; $this->persistence = $persistence; $this->expansion = $expansion; $this->offsetX = $random->nextFloat() * 256; $this->offsetY = $random->nextFloat() * 256; $this->offsetZ = $random->nextFloat() * 256; for ($i = 0; $i < 512; ++$i) { $this->perm[$i] = 0; } for ($i = 0; $i < 256; ++$i) { $this->perm[$i] = $random->nextBoundedInt(256); } for ($i = 0; $i < 256; ++$i) { $pos = $random->nextBoundedInt(256 - $i) + $i; $old = $this->perm[$i]; $this->perm[$i] = $this->perm[$pos]; $this->perm[$pos] = $old; $this->perm[$i + 256] = $this->perm[$i]; } }
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->treeHeight = $random->nextBoundedInt(3) + 4; parent::placeObject($level, $x, $y, $z, $random); }
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { if ($random->nextRange(0, self::$ODD) === 0) { //$mineshaft = new Mineshaft($random); } }