本文整理汇总了PHP中pocketmine\level\Level类的典型用法代码示例。如果您正苦于以下问题:PHP Level类的具体用法?PHP Level怎么用?PHP Level使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX() + 0.5), new Double("", $block->getY()), new Double("", $block->getZ() + 0.5)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)])]);
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
return false;
}
示例2: setBlock
private function setBlock(Vector3 $p, Level $lvl, ItemBlock $b, $meta)
{
$block = $b->getBlock();
$block->setDamage($meta);
$lvl->setBlock($p, $b);
return true;
}
示例3: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($this->meta === Item::AIR) {
if ($target instanceof Liquid) {
$level->setBlock($target, new Air(), true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = $target instanceof Water ? Item::WATER : Item::LAVA;
}
return true;
}
} elseif ($this->meta === Item::WATER) {
//Support Make Non-Support Water to Support Water
if ($block->getID() === self::AIR || $block instanceof Water && ($block->getDamage() & 0x7) != 0x0) {
$water = new Water();
$level->setBlock($block, $water, true);
$water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
} elseif ($this->meta === Item::LAVA) {
if ($block->getID() === self::AIR) {
$level->setBlock($block, new Lava(), true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
}
return false;
}
示例4: isLevelCorrect
public function isLevelCorrect(Level $level)
{
if ($this->world === "*") {
return true;
}
return strtolower($level->getName()) === $this->world;
}
示例5: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->getId() == Block::MONSTER_SPAWNER) {
return true;
} else {
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
if ($this->hasCustomName()) {
$nbt->CustomName = new StringTag("CustomName", $this->getCustomName());
}
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
}
return false;
}
示例6: __construct
public function __construct(Level $level)
{
$name = $level->getFolderName() . " - ";
$this->mobSpawn = new TimingsHandler("** " . $name . "mobSpawn");
$this->doChunkUnload = new TimingsHandler("** " . $name . "doChunkUnload");
$this->doTickPending = new TimingsHandler("** " . $name . "doTickPending");
$this->doTickTiles = new TimingsHandler("** " . $name . "doTickTiles");
$this->doVillages = new TimingsHandler("** " . $name . "doVillages");
$this->doChunkMap = new TimingsHandler("** " . $name . "doChunkMap");
$this->doSounds = new TimingsHandler("** " . $name . "doSounds");
$this->doChunkGC = new TimingsHandler("** " . $name . "doChunkGC");
$this->doPortalForcer = new TimingsHandler("** " . $name . "doPortalForcer");
$this->entityTick = new TimingsHandler("** " . $name . "entityTick");
$this->tileEntityTick = new TimingsHandler("** " . $name . "tileEntityTick");
$this->tileEntityPending = new TimingsHandler("** " . $name . "tileEntityPending");
$this->syncChunkSendTimer = new TimingsHandler("** " . $name . "syncChunkSend");
$this->syncChunkSendPrepareTimer = new TimingsHandler("** " . $name . "syncChunkSendPrepare");
$this->syncChunkLoadTimer = new TimingsHandler("** " . $name . "syncChunkLoad");
$this->syncChunkLoadDataTimer = new TimingsHandler("** " . $name . "syncChunkLoad - Data");
$this->syncChunkLoadStructuresTimer = new TimingsHandler("** " . $name . "syncChunkLoad - Structures");
$this->syncChunkLoadEntitiesTimer = new TimingsHandler("** " . $name . "syncChunkLoad - Entities");
$this->syncChunkLoadTileEntitiesTimer = new TimingsHandler("** " . $name . "syncChunkLoad - TileEntities");
$this->syncChunkLoadTileTicksTimer = new TimingsHandler("** " . $name . "syncChunkLoad - TileTicks");
$this->syncChunkLoadPostTimer = new TimingsHandler("** " . $name . "syncChunkLoad - Post");
$this->tracker = new TimingsHandler($name . "tracker");
$this->doTick = new TimingsHandler($name . "doTick");
$this->tickEntities = new TimingsHandler($name . "tickEntities");
}
示例7: __construct
public function __construct(Level $level, FullChunk $chunk)
{
$this->state = true;
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkClass = get_class($chunk);
}
示例8: getShield
/**
* @param Level $level
* @return Shield|null
*/
public function getShield(Level $level)
{
if (isset($this->shields[strtolower($level->getName())])) {
return $this->shields[strtolower($level->getName())];
}
return null;
}
示例9: __construct
public function __construct(Level $level, Generator $generator)
{
$this->generator = get_class($generator);
$this->settings = $generator->getSettings();
$this->seed = $level->getSeed();
$this->levelId = $level->getId();
}
示例10: isRegistered
public static function isRegistered(Level $level)
{
if (isset(self::$registeredLevel[$level->getName()])) {
return true;
}
return false;
}
示例11: __construct
public function __construct(Level $level, Generator $generator)
{
$this->generator = get_class($generator);
$this->waterHeight = $generator->getWaterHeight();
$this->settings = serialize($generator->getSettings());
$this->seed = $level->getSeed();
$this->levelId = $level->getId();
}
示例12: __construct
public function __construct(Level $level, $duration = 1200)
{
$this->level = $level;
$this->weatherNow = self::SUNNY;
$this->duration = $duration;
$this->lastUpdate = $level->getServer()->getTick();
$this->temporalVector = new Vector3(0, 0, 0);
}
示例13: getWorldLoadedData
public function getWorldLoadedData(Level $level)
{
$temp_config = $this->getUserData();
if (!isset($temp_config["worlds"][$level->getName()])) {
$temp_config["worlds"][$level->getName()] = array("group" => $this->plugin->getDefaultGroup()->getName(), "permissions" => array());
$this->setUserData($temp_config);
}
return $this->getUserData();
}
示例14: getWorldLoadedData
public function getWorldLoadedData(Level $level)
{
$temp_config = $this->plugin->getGroupsData();
if (!isset($temp_config[$this->groupName]["worlds"][$level->getName()])) {
$this->plugin->getLogger()->warning("Permissions not set in " . $this->groupName . " in level: " . $level->getName() . ".");
$temp_config[$this->groupName]["worlds"][$level->getName()] = array("permissions" => array());
$this->plugin->setGroupsData($temp_config);
}
return $this->plugin->getGroupsData();
}
示例15: onUnload
public function onUnload(ChunkUnloadEvent $event)
{
if ($event->getLevel() === $this->level) {
foreach ($this->locs[Level::chunkHash($event->getChunk()->getX(), $event->getChunk()->getZ())] as $id => $spawn) {
if (isset($this->spawns[$spawn->getId()])) {
$this->level->removeEntity($this->spawns[$spawn->getId()]);
}
}
}
}