本文整理汇总了PHP中pocketmine\inventory\InventoryType类的典型用法代码示例。如果您正苦于以下问题:PHP InventoryType类的具体用法?PHP InventoryType怎么用?PHP InventoryType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InventoryType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Chest $left, Chest $right)
{
$this->left = $left->getRealInventory();
$this->right = $right->getRealInventory();
$items = array_merge($this->left->getContents(), $this->right->getContents());
BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST), $items);
}
示例2: __construct
public function __construct(Human $player, $contents = null)
{
$this->hotbar = range(0, $this->getHotbarSize() - 1, 1);
parent::__construct($player, InventoryType::get(InventoryType::PLAYER));
if ($contents !== null) {
if ($contents instanceof ListTag) {
//Saved data to be loaded into the inventory
foreach ($contents as $item) {
if ($item["Slot"] >= 0 and $item["Slot"] < $this->getHotbarSize()) {
//Hotbar
if (isset($item["TrueSlot"])) {
//Valid slot was found, change the linkage to this slot
if (0 <= $item["TrueSlot"] and $item["TrueSlot"] < $this->getSize()) {
$this->hotbar[$item["Slot"]] = $item["TrueSlot"];
} elseif ($item["TrueSlot"] < 0) {
//Link to an empty slot (empty hand)
$this->hotbar[$item["Slot"]] = -1;
}
}
/* If TrueSlot is not set, leave the slot index as its default which was filled in above
* This only overwrites slot indexes for valid links */
} elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
//Armor
$this->setItem($this->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item), false);
} else {
$this->setItem($item["Slot"] - $this->getHotbarSize(), NBT::getItemHelper($item), false);
}
}
} else {
throw new \InvalidArgumentException("Expecting ListTag, received " . gettype($contents));
}
}
}
示例3: __construct
/**
* @param InventoryHolder $holder
* @param InventoryType $type
* @param Item[] $items
* @param int $overrideSize
* @param string $overrideTitle
*/
public function __construct(InventoryHolder $holder, InventoryType $type, array $items = [], $overrideSize = \null, $overrideTitle = \null)
{
$this->holder = $holder;
$this->type = $type;
if ($overrideSize !== \null) {
$this->size = (int) $overrideSize;
} else {
$this->size = $this->type->getDefaultSize();
}
if ($overrideTitle !== \null) {
$this->title = $overrideTitle;
} else {
$this->title = $this->type->getDefaultTitle();
}
$this->name = $this->type->getDefaultTitle();
$this->setContents($items);
}
示例4: __construct
public function __construct(Player $p)
{
parent::__construct($p, InventoryType::get(2));
$inv = $p->getInventory();
$this->setContents($inv->getContents());
$this->armor = $inv->getArmorContents();
for ($i = 0; $i < 10; $i++) {
$this->hotbar[$i] = $inv->getHotbarSlotIndex($i);
}
}
示例5: __construct
/**
* @param DeFactoGui $main
* @param Button[] $buttons - list of buttons to display in the chest.
* @param int $size default 127 - size of the inventory.
* @param string|null $title - unused.
*/
public function __construct(DeFactoGui $main, $buttons = [], $size = 127, $title = null)
{
$this->main = $main;
$this->buttons = $buttons;
if ($size < count($buttons)) {
throw new \InvalidArgumentException("InteractiveInventory size is less than count of buttons passed");
}
/** @var Item[] $items */
$items = array_map(function (Button $button) {
return $button->onLoad($this);
}, $buttons);
parent::__construct($main->getFakeTile(), InventoryType::get(InventoryType::CHEST), $items, $size, $title);
}
示例6: __construct
public function __construct(Human $player)
{
$this->hotbar = array_fill(0, $this->getHotbarSize(), -1);
parent::__construct($player, InventoryType::get(InventoryType::PLAYER));
}
示例7: __construct
public function __construct($holder, $client)
{
$this->client = $client;
parent::__construct($holder, InventoryType::get(InventoryType::CHEST), [], null, "Trader Inventory");
}
示例8: __construct
//.........这里部分代码省略.........
}
@ini_set("memory_limit", $memory);
} else {
$this->setConfigString("memory-limit", "256M");
}
$this->network = new Network($this);
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);
}
define("ADVANCED_CACHE", $this->getProperty("settings.advanced-cache", false));
if (ADVANCED_CACHE == true) {
$this->logger->info("Advanced cache enabled");
}
Level::$COMPRESSION_LEVEL = $this->getProperty("chunk-sending.compression-level", 8);
if (defined("pocketmine\\DEBUG") and \pocketmine\DEBUG >= 0) {
@\cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
}
$this->logger->info("Starting Minecraft PE server on " . ($this->getIp() === "" ? "*" : $this->getIp()) . ":" . $this->getPort());
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
$this->addInterface($this->mainInterface = new RakLibInterface($this));
$this->logger->info("This server is running " . $this->getName() . " version " . ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE . " \"" . $this->getCodename() . "\" (API " . $this->getApiVersion() . ")");
$this->logger->info($this->getName() . " is distributed under the LGPL License");
PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins");
Timings::init();
$this->consoleSender = new ConsoleCommandSender();
$this->commandMap = new SimpleCommandMap($this);
$this->registerEntities();
$this->registerTiles();
InventoryType::init();
Block::init();
Item::init();
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->pluginManager->registerInterface(PharPluginLoader::class);
\set_exception_handler([$this, "exceptionHandler"]);
register_shutdown_function([$this, "crashDump"]);
$plugins = $this->pluginManager->loadPlugins($this->pluginPath);
$configPlugins = $this->getAdvancedProperty("plugins", []);
if (count($configPlugins) > 0) {
$this->getLogger()->info("Checking extra plugins");
$loadNew = false;
foreach ($configPlugins as $plugin => $download) {
if (!isset($plugins[$plugin])) {
$path = $this->pluginPath . "/" . $plugin . ".phar";
if (substr($download, 0, 4) === "http") {
$this->getLogger()->info("Downloading " . $plugin);
file_put_contents($path, Utils::getURL($download));
} else {
file_put_contents($path, file_get_contents($download));
}
$loadNew = true;
}
}
if ($loadNew) {
$this->pluginManager->loadPlugins($this->pluginPath);
}
}
$this->enablePlugins(PluginLoadOrder::STARTUP);
示例9: __construct
public function __construct(BrewingStand $tile)
{
parent::__construct($tile, InventoryType::get(InventoryType::BREWING_STAND));
}
示例10: __construct
public function __construct(Hopper $tile)
{
parent::__construct($tile, InventoryType::get(InventoryType::HOPPER));
}
示例11: __construct
//.........这里部分代码省略.........
$this->banByName->load();
@touch($this->dataPath . "banned-ips.txt");
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
$this->banByIP->load();
@touch($this->dataPath . "banned-cids.txt");
$this->banByCID = new BanList($this->dataPath . "banned-cids.txt");
$this->banByCID->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(), $this->getPocketMineVersion(), $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(min(32, $this->inventoryNum));
//Bigger than 32 with cause problems
Block::init();
Item::init();
Biome::init();
Effect::init();
Enchantment::init();
Attribute::init();
/** TODO: @deprecated */
//TextWrapper::init();
$this->craftingManager = new CraftingManager($this->readRecipesFromJson);
$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(FolderPluginLoader::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");
示例12: __construct
public function __construct(Chest $left, Chest $right)
{
$this->left = $left->getRealInventory();
$this->right = $right->getRealInventory();
BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST));
}
示例13: __construct
public function __construct(Dispenser $tile)
{
parent::__construct($tile, InventoryType::get(InventoryType::DISPENSER));
}
示例14: __construct
//.........这里部分代码省略.........
@touch($this->dataPath . "banned-players.txt");
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
$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));
ini_set('assert.exception', 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", random_bytes(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(), $this->getPocketMineVersion(), $this->getCodename(), $this->getApiVersion(), $this->getPocketMineBuild()]));
$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();
EnchantmentLevelTable::init();
Color::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);
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", "jenkins.clearskyteam.org"));
$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");
示例15: __construct
//.........这里部分代码省略.........
}
@touch($this->dataPath . "banned-players.txt");
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
$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");