当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::get方法代码示例

本文整理汇总了PHP中BukkitPE\item\Item::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::get方法的具体用法?PHP Item::get怎么用?PHP Item::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BukkitPE\item\Item的用法示例。


在下文中一共展示了Item::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getItem

 /**
  * This method should not be used by plugins, use the Inventory
  *
  * @param int $index
  *
  * @return Item
  */
 public function getItem($index)
 {
     $i = $this->getSlotIndex($index);
     if ($i < 0) {
         return Item::get(Item::AIR, 0, 0);
     } else {
         return NBT::getItemHelper($this->namedtag->Items[$i]);
     }
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:16,代码来源:Chest.php

示例2: getResult

 public function getResult()
 {
     if ($brew = $this->getHolder()->getServer()->getCraftingManager()->matchBrewingRecipe($this->getIngredient())) {
         $canbrew = $brew instanceof BrewingRecipe;
         if ($canbrew) {
             return $brew->getResult();
         }
     }
     return Item::get(Item::AIR, 0, 1);
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:10,代码来源:BrewingInventory.php

示例3: getDrops

 public function getDrops()
 {
     $drops = [];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_PORKCHOP, 0, mt_rand(1, 3));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_PORKCHOP, 0, mt_rand(1, 3));
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:10,代码来源:Pig.php

示例4: getDrops

 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::FEATHER, 0, mt_rand(0, 2))];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_CHICKEN, 0, mt_rand(1, 2));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_CHICKEN, 0, mt_rand(1, 2));
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:10,代码来源:Chicken.php

示例5: getDrops

 public function getDrops()
 {
     $drops = [];
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player) {
         $drops = [ItemItem::get(ItemItem::COAL, 0, mt_rand(0, 1)), ItemItem::get(ItemItem::BONE, 0, mt_rand(0, 2))];
     }
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof ChargedCreeper) {
         $drops = [ItemItem::get(ItemItem::SKULL, 1, 1)];
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:11,代码来源:WitherSkeleton.php

示例6: getDrops

 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::LEATHER, 0, mt_rand(0, 2))];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_BEEF, 0, mt_rand(1, 3));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_BEEF, 0, mt_rand(1, 3));
     }
     //TODO Add shearing drop red mushrooms
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:11,代码来源:Mooshroom.php

示例7: __construct

 public function __construct(Player $player, Block $block, Item $item, $instaBreak = false)
 {
     $this->block = $block;
     $this->item = $item;
     $this->player = $player;
     $this->instaBreak = (bool) $instaBreak;
     $drops = $player->isSurvival() ? $block->getDrops($item) : [];
     foreach ($drops as $i) {
         $this->blockDrops[] = Item::get($i[0], $i[1], $i[2]);
     }
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:11,代码来源:BlockBreakEvent.php

示例8: getItemHelper

 /**
  * @param Compound $tag
  * @return Item
  */
 public static function getItemHelper(Compound $tag)
 {
     if (!isset($tag->id) or !isset($tag->Count)) {
         return Item::get(0);
     }
     $item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
     if (isset($tag->tag) and $tag->tag instanceof Compound) {
         $item->setNamedTag($tag->tag);
     }
     return $item;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:15,代码来源:NBT.php

示例9: 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) {
             $drops[] = ItemItem::get(ItemItem::BOW, 0, 1);
         }
     }
     if ($this->lastDamageCause instanceof EntityExplodeEvent and $this->lastDamageCause->getEntity() instanceof ChargedCreeper) {
         ItemItem::get(ItemItem::SKULL, 0, 1);
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:13,代码来源:Skeleton.php

示例10: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     $realPos = $block->getSide($face);
     $boat = new BoatEntity($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $realPos->getX()), new Double("", $realPos->getY()), new Double("", $realPos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
     $boat->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);
     }
     return true;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:17,代码来源:Boat.php

示例11: getDrops

 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::ROTTEN_FLESH, 0, mt_rand(0, 1))];
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player) {
         if (mt_rand(0, 199) < 5) {
             switch (mt_rand(0, 2)) {
                 case 0:
                     $drops[] = ItemItem::get(ItemItem::GOLD_INGOT, 0, 1);
                     break;
                 case 1:
                     $drops[] = ItemItem::get(ItemItem::GOLDEN_SWORD, 0, 1);
                     break;
                 case 2:
                     $drops[] = ItemItem::get(ItemItem::GOLD_NUGGET, 0, 1);
                     break;
             }
         }
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:20,代码来源:PigZombie.php

示例12: getDrops

 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::ROTTEN_FLESH, 0, 1)];
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player) {
         if (mt_rand(0, 199) < 5) {
             switch (mt_rand(0, 2)) {
                 case 0:
                     $drops[] = ItemItem::get(ItemItem::IRON_INGOT, 0, 1);
                     break;
                 case 1:
                     $drops[] = ItemItem::get(ItemItem::CARROT, 0, 1);
                     break;
                 case 2:
                     $drops[] = ItemItem::get(ItemItem::POTATO, 0, 1);
                     break;
             }
         }
     }
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof ChargedCreeper) {
         $drops = [ItemItem::get(ItemItem::SKULL, 2, 1)];
     }
     return $drops;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:23,代码来源:Zombie.php

示例13: useItemOn

 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return boolean
  */
 public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player !== null) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
         if ($player->isSpectator()) {
             $ev->setCancelled();
         }
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if ($t->distance($s) <= $distance) {
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if (!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if (!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         } else {
             return false;
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->canBePlaced()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
         //can anyone explain this to me?- Zombie
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($player !== null) {
             if ($diff = $player->getNextPosition()->subtract($player->getPosition()) and $diff->lengthSquared() > 1.0E-5) {
                 $bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
                 if ($hand->getBoundingBox()->intersectsWith($bb)) {
                     ++$realCount;
                 }
             }
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     $tag = $item->getNamedTagEntry("CanPlaceOn");
     if ($tag instanceof Enum) {
         $canPlace = false;
         foreach ($tag as $v) {
             if ($v instanceof String) {
                 $entry = Item::fromString($v->getValue());
                 if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
                     $canPlace = true;
                     break;
                 }
//.........这里部分代码省略.........
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:101,代码来源:Level.php

示例14: getDrops

 public function getDrops()
 {
     return [ItemItem::get(ItemItem::IRON_INGOT, 0, mt_rand(3, 5)), ItemItem::get(ItemItem::POPPY, 0, mt_rand(0, 2))];
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:4,代码来源:IronGolem.php

示例15: getDrops

 public function getDrops()
 {
     return [ItemItem::get(ItemItem::BOAT, 0, 1)];
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:4,代码来源:Boat.php


注:本文中的BukkitPE\item\Item::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。