本文整理汇总了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]);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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]);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
//.........这里部分代码省略.........
示例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))];
}
示例15: getDrops
public function getDrops()
{
return [ItemItem::get(ItemItem::BOAT, 0, 1)];
}