本文整理汇总了PHP中BukkitPE\item\Item::getCreativeItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getCreativeItems方法的具体用法?PHP Item::getCreativeItems怎么用?PHP Item::getCreativeItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BukkitPE\item\Item
的用法示例。
在下文中一共展示了Item::getCreativeItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLogin
//.........这里部分代码省略.........
$alive = false;
Entity::setHealth(20);
} else {
Entity::setHealth($nbt["Health"]);
}
$this->expcurrent = $nbt["ExpCurrent"] > 0 ? $nbt["ExpCurrent"] : 0;
$this->explevel = $nbt["ExpLevel"] >= 0 ? $nbt["ExpLevel"] : 0;
$this->gamemode = $nbt["playerGameType"] & 0x3;
if ($this->server->getForceGamemode()) {
$this->gamemode = $this->server->getGamemode();
$nbt->playerGameType = new Int("playerGameType", $this->gamemode);
}
$this->allowFlight = $this->isCreative();
if (($level = $this->server->getLevelByName($nbt["Level"])) === null or !$alive) {
$this->setLevel($this->server->getDefaultLevel());
$nbt["Level"] = $this->level->getName();
$nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
$nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
$nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
} else {
$this->setLevel($level);
}
if (!$nbt instanceof Compound) {
$this->close($this->getLeaveMessage(), "Invalid data");
return;
}
$this->achievements = [];
/** @var Byte $achievement */
foreach ($nbt->Achievements as $achievement) {
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
}
$nbt->lastPlayed = new Long("lastPlayed", floor(microtime(true) * 1000));
if ($this->server->getAutoSave()) {
$this->server->saveOfflinePlayerData($this->username, $nbt, true);
}
parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
$this->loggedIn = true;
$this->server->addOnlinePlayer($this);
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
if ($ev->isCancelled()) {
$this->close($this->getLeaveMessage(), $ev->getKickMessage());
return;
}
if ($this->isCreative()) {
$this->inventory->setHeldItemSlot(0);
} else {
$this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0));
}
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_SUCCESS;
$this->dataPacket($pk);
if ($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level) {
$this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
}
$spawnPosition = $this->getSpawn();
$pk = new StartGamePacket();
$pk->seed = -1;
$pk->dimension = 0;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->spawnX = (int) $spawnPosition->x;
$pk->spawnY = (int) $spawnPosition->y;
$pk->spawnZ = (int) $spawnPosition->z;
$pk->generator = 1;
// 0 old, 1 infinite, 2 flat
$pk->gamemode = $this->gamemode & 0x1;
$pk->eid = 0;
// Always use EntityID as zero for the actual player
$this->dataPacket($pk);
$pk = new SetTimePacket();
$pk->time = $this->level->getTime();
$pk->started = $this->level->stopTime == false;
$this->dataPacket($pk);
$pk = new SetSpawnPositionPacket();
$pk->x = (int) $spawnPosition->x;
$pk->y = (int) $spawnPosition->y;
$pk->z = (int) $spawnPosition->z;
$this->dataPacket($pk);
$this->getAttribute()->sendAll();
$pk = new SetDifficultyPacket();
$pk->difficulty = $this->server->getDifficulty();
$this->dataPacket($pk);
$this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("BukkitPE.player.logIn", [TextFormat::AQUA . $this->username . TextFormat::WHITE, $this->ip, $this->port, $this->id, $this->level->getName(), round($this->x, 4), round($this->y, 4), round($this->z, 4)]));
if ($this->isOp()) {
$this->setRemoveFormat(false);
}
if ($this->gamemode === Player::SPECTATOR) {
$pk = new ContainerSetContentPacket();
$pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
$this->dataPacket($pk);
} else {
$pk = new ContainerSetContentPacket();
$pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
$pk->slots = Item::getCreativeItems();
$this->dataPacket($pk);
}
$this->forceMovement = $this->teleportPosition = $this->getPosition();
$this->server->onPlayerLogin($this);
}
示例2: sendContents
/**
* @param Player|Player[] $target
*/
public function sendContents($target)
{
if ($target instanceof Player) {
$target = [$target];
}
$pk = new ContainerSetContentPacket();
$pk->slots = [];
$holder = $this->getHolder();
if ($holder instanceof Player and $holder->isCreative()) {
// mwvent - return because this packet causes problems - TODO: why?
return;
//TODO: Remove this workaround because of broken client
foreach (Item::getCreativeItems() as $i => $item) {
$pk->slots[$i] = Item::getCreativeItem($i);
}
} else {
for ($i = 0; $i < $this->getSize(); ++$i) {
//Do not send armor by error here
$pk->slots[$i] = $this->getItem($i);
}
}
foreach ($target as $player) {
$pk->hotbar = [];
if ($player === $this->getHolder()) {
for ($i = 0; $i < $this->getHotbarSize(); ++$i) {
$index = $this->getHotbarSlotIndex($i);
$pk->hotbar[] = $index <= -1 ? -1 : $index + 9;
}
}
if (($id = $player->getWindowId($this)) === -1 or $player->spawned !== true) {
$this->close($player);
continue;
}
$pk->windowid = $id;
$player->dataPacket(clone $pk);
}
}