作者:mattiasaxelsso
项目:PocketMine-M
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;
}
作者:Creeperface0
项目:ImagicalMin
private function setBlock(Vector3 $p, Level $lvl, ItemBlock $b, $meta)
{
$block = $b->getBlock();
$block->setDamage($meta);
$lvl->setBlock($p, $b);
return true;
}
作者:boyboo
项目:PocketMine-M
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;
}
作者:gitter-badge
项目:DynamicHu
public function isLevelCorrect(Level $level)
{
if ($this->world === "*") {
return true;
}
return strtolower($level->getName()) === $this->world;
}
作者:PepbookPv
项目:Genisy
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;
}
作者:xHF
项目:ImagicalMin
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");
}
作者:wsj717
项目:PocketMine-M
public function __construct(Level $level, FullChunk $chunk)
{
$this->state = true;
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkClass = get_class($chunk);
}
作者:NameNoOne10
项目:PocketMine-Plugin
/**
* @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;
}
作者:TexusDar
项目:Ananas-M
public function __construct(Level $level, Generator $generator)
{
$this->generator = get_class($generator);
$this->settings = $generator->getSettings();
$this->seed = $level->getSeed();
$this->levelId = $level->getId();
}
作者:iTXTec
项目:Genisy
public static function isRegistered(Level $level)
{
if (isset(self::$registeredLevel[$level->getName()])) {
return true;
}
return false;
}
作者:iTXTec
项目:Genisy
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();
}
作者:AnonymousProject
项目:PocketMine-MP-Origina
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);
}
作者:BoysElCrac
项目:xPermission
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();
}
作者:BoysElCrac
项目:xPermission
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();
}
作者:legoboy021
项目:LegionPE-Theta-Bas
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()]);
}
}
}
}
作者:TexusDar
项目:Ananas-M
public function setMetadata($block, $metadataKey, MetadataValue $newMetadatavalue)
{
if (!$block instanceof Block) {
throw new \InvalidArgumentException("Object must be a Block");
}
if ($block->getLevel() === $this->owningLevel) {
parent::setMetadata($block, $metadataKey, $newMetadatavalue);
} else {
throw new \InvalidStateException("Block does not belong to world " . $this->owningLevel->getName());
}
}
作者:xpyctu
项目:PocketMinePlusPlu
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (($player->gamemode & 0x1) === 0 and $this->useOn($block) and $this->getDamage() >= $this->getMaxDurability()) {
$player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0));
}
if ($block->getId() === self::AIR and $target instanceof Solid) {
$level->setBlock($block, new Fire(), \true);
return \true;
}
return \false;
}
作者:nesgohoo
项目:PMMP-Plugin
public function sideCheck($x, $y, $z, Level $level, $name)
{
if ($level->getBlockIdAt($x, $y, $z) == Block::CHEST) {
if (isset($this->configData["{$x}:{$y}:{$z}"])) {
if ($this->configData["{$x}:{$y}:{$z}"] != $name) {
return true;
}
}
}
return false;
}
作者:robozer
项目:S
public static function addParticles(Level $level, $name, Position $pos1, $count = 5)
{
$xd = (double) 280;
$yd = (double) 260;
$zd = (double) 280;
$particle1 = self::getParticle($name, $pos1, $xd, $yd, $zd, 0);
$random = new Random((int) (\microtime(\true) * 1000) + \mt_rand());
for ($i = 0; $i < $count; ++$i) {
$particle1->setComponents($pos1->x + $random->nextSignedFloat() * $xd, $pos1->y + $random->nextSignedFloat() * $yd, $pos1->z + $random->nextSignedFloat() * $zd);
$level->addParticle($particle1);
}
}
作者:0-DevMatthew-
项目:pocketmine-plugin
public function delHome(IPlayer $player, Level $level)
{
$n = strtolower($player->getName());
$l = "l-" . strtolower($level->getName());
if (!isset($this->homes[$l]) || !isset($this->homes[$l][$n])) {
return;
}
unset($this->homes[$l][$n]);
if (count($this->homes[$l]) == 0) {
unset($this->homes[$l]);
}
$this->saveHomes();
}