本文整理匯總了PHP中pocketmine\item\Item::isCreativeItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::isCreativeItem方法的具體用法?PHP Item::isCreativeItem怎麽用?PHP Item::isCreativeItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\item\Item
的用法示例。
在下文中一共展示了Item::isCreativeItem方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerItem
public function registerItem($id, $class)
{
Item::$list[$id] = $class;
if (Item::isCreativeItem($item = new $class())) {
Item::addCreativeItem($item);
}
}
示例2: registerBlock
public function registerBlock($id, $class)
{
Block::$list[$id] = $class;
if ($id < 255) {
Item::$list[$id] = $class;
if (!Item::isCreativeItem($item = Item::get($id))) {
Item::addCreativeItem($item);
}
}
for ($data = 0; $data < 16; ++$data) {
Block::$fullList[$id << 4 | $data] = new $class($data);
}
}
示例3: onEnable
public function onEnable()
{
$path = $this->getServer()->getDataPath() . "plugins/EntityManager/";
if (!is_dir($path)) {
mkdir($path);
}
$getData = function ($ar, $key, $default) {
$vars = explode(".", $key);
$base = array_shift($vars);
if (!isset($ar[$base])) {
return $default;
}
$base = $ar[$base];
while (count($vars) > 0) {
$baseKey = array_shift($vars);
if (!is_array($base) or !isset($base[$baseKey])) {
return $default;
}
$base = $base[$baseKey];
}
return $base;
};
$data = [];
if (file_exists($path . "config.yml")) {
$data = yaml_parse($this->yaml($path . "config.yml"));
}
self::$data = ["entity" => ["maximum" => $getData($data, "entity.maximum", 50), "explode" => $getData($data, "entity.explode", true)], "spawn" => ["rand" => $getData($data, "spawn.rand", "1/5"), "tick" => $getData($data, "spawn.tick", 150)], "autospawn" => ["turn-on" => $getData($data, "autospawn.turn-on", $getData($data, "spawn.auto", true)), "radius" => $getData($data, "autospawn.radius", $getData($data, "spawn.radius", 25))]];
file_put_contents($path . "config.yml", yaml_emit(self::$data, YAML_UTF8_ENCODING));
if (file_exists($path . "SpawnerData.yml")) {
self::$spawn = yaml_parse($this->yaml($path . "SpawnerData.yml"));
unlink($path . "SpawnerData.yml");
} elseif (file_exists($path . "spawner.yml")) {
self::$spawn = yaml_parse($this->yaml($path . "spawner.yml"));
} else {
self::$spawn = [];
file_put_contents($path . "spawner.yml", yaml_emit([], YAML_UTF8_ENCODING));
}
if (file_exists($path . "drops.yml")) {
self::$drops = yaml_parse($this->yaml($path . "drops.yml"));
} else {
self::$drops = [Zombie::NETWORK_ID => [], Creeper::NETWORK_ID => []];
file_put_contents($path . "drops.yml", yaml_emit([], YAML_UTF8_ENCODING));
}
foreach (self::$knownEntities as $id => $name) {
if (!is_numeric($id)) {
continue;
}
$item = Item::get(Item::SPAWN_EGG, $id);
if (!Item::isCreativeItem($item)) {
Item::addCreativeItem($item);
}
}
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->getServer()->getLogger()->info(TextFormat::GOLD . "[EntityManager]Plugin has been enabled");
$this->getServer()->getScheduler()->scheduleRepeatingTask(new UpdateEntityTask($this), 1);
$this->getServer()->getScheduler()->scheduleRepeatingTask(new SpawnEntityTask($this), $this->getData("spawn.tick"));
}