本文整理汇总了PHP中pocketmine\level\generator\biome\Biome类的典型用法代码示例。如果您正苦于以下问题:PHP Biome类的具体用法?PHP Biome怎么用?PHP Biome使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Biome类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateChunk
public function generateChunk($chunkX, $chunkZ)
{
if ($this->emptyChunk !== null) {
//Use the cached empty chunk instead of generating a new one
$this->chunk = clone $this->emptyChunk;
} else {
$this->chunk = clone $this->level->getChunk($chunkX, $chunkZ);
$this->chunk->setGenerated();
$c = Biome::getBiome(1)->getColor();
$R = $c >> 16;
$G = $c >> 8 & 0xff;
$B = $c & 0xff;
for ($Z = 0; $Z < 16; ++$Z) {
for ($X = 0; $X < 16; ++$X) {
$this->chunk->setBiomeId($X, $Z, 1);
$this->chunk->setBiomeColor($X, $Z, $R, $G, $B);
for ($y = 0; $y < 128; ++$y) {
$this->chunk->setBlockId($X, $y, $Z, Block::AIR);
}
}
}
$spawn = $this->getSpawn();
if ($spawn->getX() >> 4 === $chunkX and $spawn->getZ() >> 4 === $chunkZ) {
$this->chunk->setBlockId(0, 64, 0, Block::GRASS);
} else {
$this->emptyChunk = $this->chunk;
}
}
$chunk = clone $this->chunk;
$chunk->setX($chunkX);
$chunk->setZ($chunkZ);
$this->level->setChunk($chunkX, $chunkZ, $chunk);
}
示例2: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) === 0) {
$biomes = TextFormat::WHITE . implode(", ", array_keys($this->biomes));
$sender->sendMessage($this->translateString("biome.possible", [$biomes]));
return true;
} elseif (count($args) !== 1) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$biome = strtoupper($args[0]);
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
return true;
}
if ($plot->owner !== $sender->getName()) {
$sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
return true;
}
if (!isset($this->biomes[$biome])) {
$sender->sendMessage(TextFormat::RED . $this->translateString("biome.invalid"));
$biomes = implode(", ", array_keys($this->biomes));
$sender->sendMessage(TextFormat::RED . $this->translateString("biome.possible", [$biomes]));
return true;
}
$biome = Biome::getBiome($this->biomes[$biome]);
if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
$sender->sendMessage($this->translateString("biome.success", [$biome->getName()]));
} else {
$sender->sendMessage(TextFormat::RED . $this->translateString("error"));
}
return true;
}
示例3: populate
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random)
{
$chunk = $level->getChunk($chunkX, $chunkZ);
for ($x = 0; $x < 16; ++$x) {
for ($z = 0; $z < 16; ++$z) {
$biome = Biome::getBiome($chunk->getBiomeId($x, $z));
$cover = $biome->getGroundCover();
if (count($cover) > 0) {
$diffY = 0;
if (!$cover[0]->isSolid()) {
$diffY = 1;
}
$column = $chunk->getBlockIdColumn($x, $z);
for ($y = 127; $y > 0; --$y) {
if ($column[$y] !== "" and !Block::get(ord($column[$y]))->isTransparent()) {
break;
}
}
$startY = min(127, $y + $diffY);
$endY = $startY - count($cover);
for ($y = $startY; $y > $endY and $y >= 0; --$y) {
$b = $cover[$startY - $y];
if ($column[$y] === "" and $b->isSolid()) {
break;
}
if ($b->getDamage() === 0) {
$chunk->setBlockId($x, $y, $z, $b->getId());
} else {
$chunk->setBlock($x, $y, $z, $b->getId(), $b->getDamage());
}
}
}
}
}
}
示例4: execute
public function execute(CommandSender $sender, array $args)
{
if (count($args) !== 1) {
return false;
}
$player = $sender->getServer()->getPlayer($sender->getName());
$biome = strtoupper($args[0]);
$plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
if ($plot === null) {
$sender->sendMessage(TextFormat::RED . "You are not standing on an island");
return true;
}
if ($plot->owner !== $sender->getName()) {
$sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
return true;
}
if (!isset($this->biomes[$biome])) {
$sender->sendMessage(TextFormat::RED . "That biome doesn't exist");
$biomes = implode(", ", array_keys($this->biomes));
$sender->sendMessage(TextFormat::RED . "The possible biomes are: {$biomes}");
return true;
}
$biome = Biome::getBiome($this->biomes[$biome]);
if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
$sender->sendMessage(TextFormat::GREEN . "Changed the island biome");
} else {
$sender->sendMessage(TextFormat::RED . "Could not change the island biome");
}
return true;
}
示例5: parsePreset
protected function parsePreset($preset, $chunkX, $chunkZ)
{
$this->preset = $preset;
$preset = explode(";", $preset);
$version = (int) $preset[0];
$blocks = isset($preset[1]) ? $preset[1] : "";
$biome = isset($preset[2]) ? $preset[2] : 1;
$options = isset($preset[3]) ? $preset[3] : "";
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
$y = 0;
$this->structure = [];
$this->chunks = [];
foreach ($matches[3] as $i => $b) {
$b = Item::fromString($b . $matches[4][$i]);
$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 = clone $this->level->getChunk($chunkX, $chunkZ);
$this->chunk->setGenerated();
$c = Biome::getBiome($biome)->getColor();
$R = $c >> 16;
$G = $c >> 8 & 0xff;
$B = $c & 0xff;
for ($Z = 0; $Z < 16; ++$Z) {
for ($X = 0; $X < 16; ++$X) {
$this->chunk->setBiomeId($X, $Z, $biome);
$this->chunk->setBiomeColor($X, $Z, $R, $G, $B);
for ($y = 0; $y < 128; ++$y) {
$this->chunk->setBlock($X, $y, $Z, ...$this->structure[$y]);
}
}
}
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;
}
}
示例6: onRun
public function onRun()
{
Block::init();
Biome::init();
$manager = new SimpleChunkManager($this->seed);
$this->saveToThreadStore("generation.level{$this->levelId}.manager", $manager);
/** @var Generator $generator */
$generator = $this->generator;
$generator = new $generator($this->settings);
$generator->init($manager, new Random($manager->getSeed()));
$this->saveToThreadStore("generation.level{$this->levelId}.generator", $generator);
}
示例7: checkOldBiomes
protected function checkOldBiomes($data)
{
if (strlen($data) !== 256) {
return;
}
for ($x = 0; $x < 16; ++$x) {
for ($z = 0; $z < 16; ++$z) {
$biome = Biome::getBiome(ord($data[($z << 4) + $x]));
$this->setBiomeId($x, $z, $biome->getId());
$c = $biome->getColor();
$this->setBiomeColor($x, $z, $c >> 16, $c >> 8 & 0xff, $c & 0xff);
}
}
}
示例8: register
protected static function register($id, Biome $biome)
{
self::$biomes[(int) $id] = $biome;
$biome->setId((int) $id);
$biome->grassColor = self::generateBiomeColor($biome->getTemperature(), $biome->getRainfall());
$flowerPopFound = false;
foreach ($biome->getPopulators() as $populator) {
if ($populator instanceof Flower) {
$flowerPopFound = true;
break;
}
}
if ($flowerPopFound === false) {
$flower = new Flower();
$biome->addPopulator($flower);
}
}
示例9: generateChunk
public function generateChunk($chunkX, $chunkZ)
{
$spawn = $this->getSpawn();
// Adjust spawn so it is relative to current chunk...
$spawn->x = $spawn->x - ($chunkX << 4);
$spawn->z = $spawn->z - ($chunkZ << 4);
$inSpawn = -$this->radius <= $spawn->x && $spawn->x < 16 + $this->radius && -$this->radius <= $spawn->z && $spawn->z < 16 + $this->radius;
if ($inSpawn || $this->chunk === null) {
$chunk = $this->level->getChunk($chunkX, $chunkZ);
$chunk->setGenerated();
$c = Biome::getBiome($this->biome)->getColor();
$R = $c >> 16;
$G = $c >> 8 & 0xff;
$B = $c & 0xff;
$rad2 = $this->radius * $this->radius;
for ($Z = 0; $Z < 16; ++$Z) {
for ($X = 0; $X < 16; ++$X) {
$chunk->setBiomeId($X, $Z, $biome);
$chunk->setBiomeColor($X, $Z, $R, $G, $B);
$chunk->setBlock($X, 0, $Z, $this->baseFloor, 0);
for ($y = 1; $y < 128; ++$y) {
$chunk->setBlock($X, $y, $Z, Block::AIR, 0);
}
if (self::inSpawn($rad2, $spawn->x, $spawn->z, $X, $Z)) {
$chunk->setBlock($X, $this->floorLevel, $Z, $this->block);
}
}
}
if (!$inSpawn) {
$this->chunk = clone $chunk;
}
} else {
$chunk = clone $this->chunk;
}
$chunk->setX($chunkX);
$chunk->setZ($chunkZ);
$this->level->setChunk($chunkX, $chunkZ, $chunk);
}
示例10: generateChunk
public function generateChunk($chunkX, $chunkZ)
{
$this->chunk = clone $this->level->getChunk($chunkX, $chunkZ);
$this->chunk->setGenerated();
$c = Biome::getBiome(1)->getColor();
$R = $c >> 16;
$G = $c >> 8 & 0xff;
$B = $c & 0xff;
for ($Z = 0; $Z < 16; ++$Z) {
for ($X = 0; $X < 16; ++$X) {
$this->chunk->setBiomeId($X, $Z, 1);
$this->chunk->setBiomeColor($X, $Z, $R, $G, $B);
for ($y = 0; $y < 128; ++$y) {
$this->chunk->setBlockId($X, $y, $Z, Block::AIR);
}
}
}
$this->chunk->setBlockId(8, 64, 8, Block::GRASS);
$chunk = clone $this->chunk;
$chunk->setX($chunkX);
$chunk->setZ($chunkZ);
$this->level->setChunk($chunkX, $chunkZ, $chunk);
}
示例11: register
protected static function register($id, Biome $biome)
{
self::$biomes[(int) $id] = $biome;
$biome->setId((int) $id);
}
示例12: __construct
//.........这里部分代码省略.........
$this->banByName->load();
@touch($this->dataPath . "banned-ips.txt");
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
$this->banByIP->load();
$this->maxPlayers = $this->getConfigInt("max-players", 20);
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
$this->setConfigInt("difficulty", 3);
}
define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
if ($this->logger instanceof MainLogger) {
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
}
if (\pocketmine\DEBUG >= 0) {
@cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
}
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
$this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
$this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
$this->network = new Network($this);
$this->network->setName($this->getMotd());
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [$this->getName(), ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, $this->getCodename(), $this->getApiVersion()]));
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
Timings::init();
$this->consoleSender = new ConsoleCommandSender();
$this->commandMap = new SimpleCommandMap($this);
$this->registerEntities();
$this->registerTiles();
InventoryType::init();
Block::init();
Item::init();
Biome::init();
Effect::init();
Enchantment::init();
Attribute::init();
/** TODO: @deprecated */
TextWrapper::init();
$this->craftingManager = new CraftingManager();
$this->pluginManager = new PluginManager($this, $this->commandMap);
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
$this->profilingTickRate = (double) $this->getProperty("settings.profile-report-trigger", 20);
$this->pluginManager->registerInterface(PharPluginLoader::class);
$this->pluginManager->registerInterface(ScriptPluginLoader::class);
set_exception_handler([$this, "exceptionHandler"]);
register_shutdown_function([$this, "crashDump"]);
$this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
$this->network->registerInterface(new RakLibInterface($this));
$this->pluginManager->loadPlugins($this->pluginPath);
$this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
$this->enablePlugins(PluginLoadOrder::STARTUP);
LevelProviderManager::addProvider($this, Anvil::class);
LevelProviderManager::addProvider($this, McRegion::class);
if (extension_loaded("leveldb")) {
$this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
LevelProviderManager::addProvider($this, LevelDB::class);
}
Generator::addGenerator(Flat::class, "flat");
Generator::addGenerator(Normal::class, "normal");
Generator::addGenerator(Normal::class, "default");
Generator::addGenerator(Nether::class, "hell");
Generator::addGenerator(Nether::class, "nether");
foreach ((array) $this->getProperty("worlds", []) as $name => $worldSetting) {
if ($this->loadLevel($name) === false) {
示例13: setPlotBiome
/**
* Changes the biome of a plot
*
* @api
* @param Plot $plot
* @param Biome $biome
* @return bool
*/
public function setPlotBiome(Plot $plot, Biome $biome)
{
$plotLevel = $this->getLevelSettings($plot->levelName);
if ($plotLevel === null) {
return false;
}
$level = $this->getServer()->getLevelByName($plot->levelName);
$pos = $this->getPlotPosition($plot);
$plotSize = $plotLevel->plotSize;
$xMax = $pos->x + $plotSize;
$zMax = $pos->z + $plotSize;
$chunkIndexes = [];
for ($x = $pos->x; $x < $xMax; $x++) {
for ($z = $pos->z; $z < $zMax; $z++) {
$index = Level::chunkHash($x >> 4, $z >> 4);
if (!in_array($index, $chunkIndexes)) {
$chunkIndexes[] = $index;
}
$color = $biome->getColor();
$R = $color >> 16;
$G = $color >> 8 & 0xff;
$B = $color & 0xff;
$level->setBiomeColor($x, $z, $R, $G, $B);
}
}
foreach ($chunkIndexes as $index) {
Level::getXZ($index, $X, $Z);
$chunk = $level->getChunk($X, $Z);
foreach ($level->getChunkPlayers($X, $Z) as $player) {
$player->onChunkChanged($chunk);
}
}
$plot->biome = $biome->getName();
$this->dataProvider->savePlot($plot);
return true;
}
示例14: populateChunk
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);
}
示例15: register
protected static function register($id, Biome $biome)
{
self::$biomes[(int) $id] = $biome;
$biome->setId((int) $id);
$biome->grassColor = self::generateBiomeColor($biome->getTemperature(), $biome->getRainfall());
}