本文整理汇总了PHP中BukkitPE\item\Item::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getId方法的具体用法?PHP Item::getId怎么用?PHP Item::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BukkitPE\item\Item
的用法示例。
在下文中一共展示了Item::getId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Item $item, Player $player = null)
{
$tile = $this->getLevel()->getTile($this);
if ($tile instanceof FlowerPotTile) {
if ($tile->getFlowerPotItem() === Item::AIR) {
switch ($item->getId()) {
case Item::TALL_GRASS:
if ($item->getDamage() === 1) {
break;
}
case Item::SAPLING:
case Item::DEAD_BUSH:
case Item::DANDELION:
case Item::RED_FLOWER:
case Item::BROWN_MUSHROOM:
case Item::RED_MUSHROOM:
case Item::CACTUS:
$tile->setFlowerPotData($item->getId(), $item->getDamage());
$this->setDamage($item->getDamage());
if ($player->isSurvival()) {
$item->count--;
}
return true;
break;
}
}
}
return false;
}
示例2: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
//Bonemeal
if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
for ($y = 1; $y < 3; ++$y) {
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if ($b->getId() === self::AIR) {
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
}
break;
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this, true);
}
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例3: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf and $this->getDamage() === 1 || $this->getDamage() === 2) {
$this->getLevel()->setBlock($this->getSide(1), new DoublePlant($this->getDamage() + 1 ^ 0x8));
$this->getLevel()->setBlock($this, new DoublePlant($this->getDamage() + 1));
return true;
} else {
return false;
}
}
示例4: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::FLINT_STEEL) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new Air(), true);
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x + 0.5), new Double("", $this->y), new Double("", $this->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", -sin($mot) * 0.02), new Double("", 0.2), new Double("", -cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Fuse" => new Byte("Fuse", 80)]));
$tnt->spawnToAll();
return true;
}
return false;
}
示例5: putItemHelper
/**
* @param Item $item
* @param int $slot
* @return Compound
*/
public static function putItemHelper(Item $item, $slot = null)
{
$tag = new Compound(null, ["id" => new Short("id", $item->getId()), "Count" => new Byte("Count", $item->getCount()), "Damage" => new Short("Damage", $item->getDamage())]);
if ($slot !== null) {
$tag->Slot = new Byte("Slot", (int) $slot);
}
if ($item->hasCompoundTag()) {
$tag->tag = clone $item->getNamedTag();
$tag->tag->setName("tag");
}
return $tag;
}
示例6: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
//Bonemeal
//TODO: change log type
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->meta & 0x7);
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例7: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
$item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
return true;
} elseif ($item->isHoe()) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new Farmland());
return true;
} elseif ($item->isShovel() and $this->getSide(1)->getId() === Block::AIR) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new GrassPath());
return true;
}
return false;
}
示例8: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
//Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
if ($block->meta > 7) {
$block->meta = 7;
}
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
}
$item->count--;
return true;
}
return false;
}
示例9: equals
public final function equals(Item $item, $checkDamage = true, $checkCompound = true)
{
return $this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage()) and ($checkCompound === false or $this->getCompoundTag() === $item->getCompoundTag());
}
示例10: matchBrewingRecipe
/**
* @param Item $input
*
* @return BrewingRecipe
*/
public function matchBrewingRecipe(Item $input)
{
if (isset($this->BrewingRecipes[$input->getId() . ":" . $input->getDamage()])) {
return $this->BrewingRecipes[$input->getId() . ":" . $input->getDamage()];
} elseif (isset($this->BrewingRecipes[$input->getId() . ":?"])) {
return $this->BrewingRecipes[$input->getId() . ":?"];
}
return null;
}
示例11: __construct
public function __construct(Vector3 $pos, Item $item)
{
parent::__construct($pos, Particle::TYPE_ITEM_BREAK, $item->getId() << 16 | $item->getDamage());
}
示例12: putSlot
public function putSlot(Item $item)
{
if ($item->getId() === 0) {
$this->putShort(0);
return;
}
$this->putShort($item->getId());
$this->putByte($item->getCount());
$this->putShort($item->getDamage() === null ? -1 : $item->getDamage());
$nbt = $item->getCompoundTag();
$this->putShort(strlen($nbt));
$this->put($nbt);
}
示例13: setItem
public function setItem($index, Item $item)
{
if ($index < 0 or $index >= $this->size) {
return false;
} elseif ($item->getId() === 0 or $item->getCount() <= 0) {
return $this->clear($index);
}
if ($index >= $this->getSize()) {
//Armor change
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
if ($ev->isCancelled() and $this->getHolder() instanceof Human) {
$this->sendArmorSlot($index, $this->getViewers());
return false;
}
$item = $ev->getNewItem();
} else {
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
if ($ev->isCancelled()) {
$this->sendSlot($index, $this->getViewers());
return false;
}
$item = $ev->getNewItem();
}
$old = $this->getItem($index);
$this->slots[$index] = clone $item;
$this->onSlotChange($index, $old);
if ($this->getHolder() instanceof Player) {
if ($this->getHolder()->isSurvival()) {
$this->sendContents($this->getHolder());
}
}
return true;
}