本文整理汇总了PHP中pocketmine\item\Item::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::get方法的具体用法?PHP Item::get怎么用?PHP Item::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\item\Item
的用法示例。
在下文中一共展示了Item::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: playerItemConsume
public function playerItemConsume(PlayerItemConsumeEvent $event)
{
$player = $event->getPlayer();
if ($player->getGamemode() == 0) {
$item = $event->getItem();
$item_consumed = $item->getID();
if ($this->isExistsItem($item_consumed)) {
$event->setCancelled();
$count = $item->getCount();
if ($count == 1) {
$item = Item::get(0, 0, 0);
} else {
$item->setCount($count - 1);
}
$player->getInventory()->setItemInHand($item);
if ($item_consumed == 367 || $item_consumed == 365) {
if ($this->setPlayerPoisoned($player->getDisplayName(), $this->poison[$item_consumed]) == true) {
$this->chat($player, "You have been poisoned by food", 4);
}
}
$var = $this->items[$item_consumed];
$this->addFoodLevel($player, $var[0]);
$this->addFoodSaturationLevel($player, $var[1]);
$this->test($player->getDisplayName());
}
}
}
示例2: attackEntity
public function attackEntity(Entity $player)
{
if ($this->attackDelay > 30 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 200) {
$this->attackDelay = 0;
$f = 2;
$yaw = $this->yaw + mt_rand(-220, 220) / 10;
$pitch = $this->pitch + mt_rand(-120, 120) / 10;
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2), new DoubleTag("", $this->y + 2), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI) * $f), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
$fireball = Entity::createEntity("FireBall", $this->chunk, $nbt, $this);
if ($fireball instanceof FireBall) {
$fireball->setExplode(true);
}
$fireball->setMotion($fireball->getMotion()->multiply($f));
$ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $fireball, $f);
$this->server->getPluginManager()->callEvent($ev);
$projectile = $ev->getProjectile();
if ($ev->isCancelled()) {
$projectile->kill();
} elseif ($projectile instanceof Projectile) {
$this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
if ($launch->isCancelled()) {
$projectile->kill();
} else {
$projectile->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
}
}
}
示例3: onUpdate
public function onUpdate($type)
{
if ($type === Level::BLOCK_UPDATE_NORMAL) {
if ($this->getSide(0)->isTransparent === true) {
//TODO: Replace with common break method
$this->getLevel()->dropItem($this, Item::get(Item::MELON_SEEDS, 0, mt_rand(0, 2)));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
return Level::BLOCK_UPDATE_NORMAL;
}
} elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
if (mt_rand(0, 2) == 1) {
if ($this->meta < 0x7) {
++$this->meta;
$this->getLevel()->setBlock($this, $this, true);
return Level::BLOCK_UPDATE_RANDOM;
} else {
for ($side = 2; $side <= 5; ++$side) {
$b = $this->getSide($side);
if ($b->getID() === self::MELON_BLOCK) {
return Level::BLOCK_UPDATE_RANDOM;
}
}
$side = $this->getSide(mt_rand(2, 5));
$d = $side->getSide(0);
if ($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)) {
$this->getLevel()->setBlock($side, new Melon(), true);
}
}
}
return Level::BLOCK_UPDATE_RANDOM;
}
return false;
}
示例4: onEnable
public function onEnable()
{
//アイテムの追加
Item::$list[self::ITEM_FLOWER_POT] = ItemFlowerPot::class;
//ブロックの追加
$this->registerBlock(self::BLOCK_FLOWER_POT, BlockFlowerPot::class);
//ブロックタイルエンティティの追加
Tile::registerTile(FlowerPot::class);
//アイテムをクリエイティブタブに追加
Item::addCreativeItem(Item::get(self::ITEM_FLOWER_POT, 0));
//一応レシピ追加
Server::getInstance()->getCraftingManager()->registerRecipe((new ShapedRecipe(Item::get(MainClass::ITEM_FLOWER_POT, 0, 1), "X X", " X "))->setIngredient("X", Item::get(Item::BRICK, null)));
//omake skull
//アイテムの追加
Item::$list[self::ITEM_SKULL] = ItemSkull::class;
//ブロックの追加
$this->registerBlock(self::BLOCK_SKULL, BlockSkull::class);
//ブロックタイルエンティティの追加
Tile::registerTile(Skull::class);
//アイテムをクリエイティブタブに追加
Item::addCreativeItem(Item::get(self::ITEM_SKULL, 0));
Item::addCreativeItem(Item::get(self::ITEM_SKULL, 1));
Item::addCreativeItem(Item::get(self::ITEM_SKULL, 2));
Item::addCreativeItem(Item::get(self::ITEM_SKULL, 3));
Item::addCreativeItem(Item::get(self::ITEM_SKULL, 4));
}
示例5: spawnToAll
public function spawnToAll()
{
parent::spawnToAll();
if ($this->getLevel()->getServer()->lightningFire) {
$fire = ItemItem::get(ItemItem::FIRE)->getBlock();
$oldBlock = $this->getLevel()->getBlock($this);
if ($oldBlock instanceof Liquid) {
} elseif ($oldBlock->isSolid()) {
$v3 = new Vector3($this->x, $this->y + 1, $this->z);
} else {
$v3 = new Vector3($this->x, $this->y, $this->z);
}
if (isset($v3)) {
$this->getLevel()->setBlock($v3, $fire);
}
foreach ($this->level->getNearbyEntities($this->boundingBox->grow(4, 3, 4), $this) as $entity) {
if ($entity instanceof Player) {
$damage = mt_rand(8, 20);
$ev = new EntityDamageByEntityEvent($this, $entity, EntityDamageByEntityEvent::CAUSE_LIGHTNING, $damage);
if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
$ev->useArmors();
}
$entity->setOnFire(mt_rand(3, 8));
}
if ($entity instanceof Creeper) {
$entity->setPowered(true, $this);
}
}
}
}
示例6: onQuit
public function onQuit(PlayerQuitEvent $event)
{
$this->clearjoin = $this->getConfig()->get("Clear on Quit");
if ($this->clearjoin == true) {
$event->getPlayer()->getInventory()->setContents(array(Item::get(0, 0, 0)));
}
}
示例7: onBreak
public function onBreak(BlockBreakEvent $e)
{
$p = $e->getPlayer();
$b = $e->getBlock();
if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t1-chance")) == "1") {
for ($i = 0; $i <= 5; $i++) {
$p->getLevel()->addParticle(new LavaParticle($b, 2));
}
$p->getLevel()->addSound(new PopSound($p));
$this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::RED . "Tier 1" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
foreach ($this->getConfig()->get("t1-loot") as $loot) {
$p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t1-item-max"))));
}
}
if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t2-chance")) == "1") {
for ($i = 0; $i <= 8; $i++) {
$p->getLevel()->addParticle(new LavaParticle($b, 2));
}
$p->getLevel()->addSound(new PopSound($p));
$this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::GOLD . "Tier 2" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
foreach ($this->getConfig()->get("t2-loot") as $loot) {
$p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t2-item-max"))));
}
}
if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t3-chance")) == "1") {
for ($i = 0; $i <= 11; $i++) {
$p->getLevel()->addParticle(new LavaParticle($b, 2));
}
$p->getLevel()->addSound(new PopSound($p));
$this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::YELLOW . "Tier 3" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
foreach ($this->getConfig()->get("t3-loot") as $loot) {
$p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t3-item-max"))));
}
}
}
示例8: onUpdate
public function onUpdate()
{
$this->entityBaseTick();
if ($this->closed !== false) {
return false;
}
$this->motionY -= $this->gravity;
$this->move($this->motionX, $this->motionY, $this->motionZ);
$friction = 1 - $this->drag;
$this->motionX *= $friction;
$this->motionY *= 1 - $this->drag;
$this->motionZ *= $friction;
$pos = $this->floor();
if ($this->ticksLived === 1) {
$block = $this->level->getBlock($pos);
if ($block->getID() != $this->blockId) {
$this->kill();
return true;
}
$this->level->setBlock($pos, Block::get(0, true));
}
if ($this->onGround) {
$this->kill();
$block = $this->level->getBlock($pos);
if (!$block->isFullBlock) {
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), 0, 1));
} else {
$this->getLevel()->setBlock($pos, Block::get($this->getBlock(), 0), true);
}
}
$this->updateMovement();
return !$this->onGround or $this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0;
}
示例9: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($player === null or $player->isSurvival() !== true) {
return false;
}
if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
if ($ev->isCancelled()) {
return false;
} else {
if ($this->count <= 1) {
$player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
return true;
} else {
$this->count--;
$player->getInventory()->setItemInHand($this);
}
if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
$player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
} else {
$motion = $player->getDirectionVector()->multiply(0.4);
$position = clone $player->getPosition();
$player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
}
return true;
}
}
return false;
}
示例10: onRun
public function onRun($currentTick)
{
if ($this->getPlugin()->status == "enabled") {
$level = $this->getPlugin()->getServer()->getLevelByName($this->getPlugin()->cfg["World"]);
foreach ($this->getPlugin()->getServer()->getOnlinePlayers() as $p) {
if ($this->getPlugin()->config()["Popup.Enabled"] == true) {
$p->sendPopup($this->getPlugin()->config()["Popup.Message"]);
}
}
$this->getPlugin()->secs++;
if ($level !== null) {
$level->dropItem(new Vector3($this->getPlugin()->cfg["Coordinates"]["X"], $this->getPlugin()->cfg["Coordinates"]["Y"], $this->getPlugin()->cfg["Coordinates"]["Z"]), Item::get($this->getPlugin()->getRandomItem(), 0, mt_rand(1, 5)));
} else {
$this->getPlugin()->getLogger()->warning("§cItems could not be dropped. World doesn't exist.");
}
}
if ($this->getPlugin()->secs == $this->getPlugin()->config()["Duration"]) {
if ($this->getPlugin()->status == "enabled") {
$this->getPlugin()->getServer()->broadcastMessage($this->getPlugin()->config()["Message.Ended"]);
$this->getPlugin()->status = "ended";
$this->getPlugin()->secs = 0;
$this->getPlugin()->time = $this->getPlugin()->cfg["Time"];
}
}
}
示例11: aht
function aht(dgar $E)
{
$B = $E->getPlayer();
if ($B->pitch > 87 && $E->isSneaking()) {
$D = $B->getName();
if (isset($this->link[$B->getName()])) {
return true;
}
$C = bcadd("1095216660480", mt_rand(0, 0x7fffffff));
$L = $B->getSkinData();
$I = $B->getName() . "'s chair";
$K = UUID::fromData($C, $L, $I);
$A = new faeafgv();
$A->uuid = $K;
$A->username = $I;
$A->eid = $C;
$A->x = $B->x;
$A->y = $B->y - 3;
$A->z = $B->z;
$A->speedX = 0;
$A->speedY = 0;
$A->speedZ = 0;
$A->yaw = 0;
$A->pitch = 0;
$A->item = Item::get(0, 0);
$A->metadata = [0 => [0, 32], 1 => [1, 300], 2 => [4, ""], 3 => [0, 1], 4 => [0, 0], 15 => [0, 0]];
Server::broadcastPacket(Server::getInstance()->getOnlinePlayers(), $A->setChannel(6));
$this->uid[$C] = $K;
$this->rhaethat($A->eid, $B);
}
}
示例12: onRespawn
public function onRespawn(PlayerRespawnEvent $e)
{
$cfg = $this->getConfig();
$player = $e->getPlayer();
$player->getInventory()->setItem(25, Item::get($cfg->get("HidePlayers-Item"), 0, 1));
$player->getInventory()->setItem(26, Item::get($cfg->get("ShowPlayers-Item"), 0, 1));
}
示例13: getDrops
public function getDrops()
{
$drops = [ItemItem::get(ItemItem::ARROW, 0, mt_rand(0, 2)), ItemItem::get(ItemItem::BONE, 0, mt_rand(0, 2))];
if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player) {
if (\mt_rand(0, 199) < 5) {
switch (\mt_rand(0, 10)) {
case 0:
case 1:
case 2:
case 3:
case 4:
$drops[] = ItemItem::get(ItemItem::BOW, 0, 1);
break;
case 5:
case 6:
case 7:
$drops[] = ItemItem::get(ItemItem::CHAIN_CHESTPLATE, 0, 1);
break;
case 8:
case 9:
$drops[] = ItemItem::get(ItemItem::GOLD_CHESTPLATE, 0, 1);
break;
case 10:
$drops[] = ItemItem::get(ItemItem::IRON_CHESTPLATE, 0, 1);
break;
}
}
}
return $drops;
}
示例14: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
$faces = [2 => 0, 3 => 2, 4 => 1, 5 => 3];
$motives = [["Kebab", 1, 1], ["Aztec", 1, 1], ["Alban", 1, 1], ["Aztec2", 1, 1], ["Bomb", 1, 1], ["Plant", 1, 1], ["Wasteland", 1, 1], ["Wanderer", 1, 2], ["Graham", 1, 2], ["Pool", 2, 1], ["Courbet", 2, 1], ["Sunset", 2, 1], ["Sea", 2, 1], ["Creebet", 2, 1], ["Match", 2, 2], ["Bust", 2, 2], ["Stage", 2, 2], ["Void", 2, 2], ["SkullAndRoses", 2, 2], ["Fighters", 4, 2], ["Skeleton", 4, 3], ["DonkeyKong", 4, 3], ["Pointer", 4, 4], ["Pigscene", 4, 4], ["Flaming Skull", 4, 4]];
$motive = $motives[mt_rand(0, count($motives) - 1)];
$data = ["x" => $target->x, "y" => $target->y + 0.4, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
$nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new EnumTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
$painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
$painting->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
//TODO
//$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
//$e->spawnToAll();
/*if(($player->gamemode & 0x01) === 0x00){
$player->removeItem(Item::get($this->getId(), $this->getDamage(), 1));
}*/
return true;
}
return false;
}
示例15: kill
public function kill()
{
parent::kill();
foreach ($this->getDrops() as $i) {
$this->getLevel()->dropItem($this, ItemItem::get($i[0], $i[1], $i[2]));
}
}