本文整理汇总了PHP中BukkitPE\item\Item::getDamage方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getDamage方法的具体用法?PHP Item::getDamage怎么用?PHP Item::getDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BukkitPE\item\Item
的用法示例。
在下文中一共展示了Item::getDamage方法的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: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $this->getSide(0);
if ($face !== 0 && $fy > 0.5 && $target->getId() !== self::SKULL_BLOCK && !$down instanceof SkullBlock) {
$this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, 0), true, true);
if ($face === 1) {
$rot = new Byte("Rot", floor($player->yaw * 16 / 360 + 0.5) & 0xf);
} else {
$rot = new Byte("Rot", 0);
}
$nbt = new Compound("", [new String("id", Tile::SKULL), new Int("x", $block->x), new Int("y", $block->y), new Int("z", $block->z), new Byte("SkullType", $item->getDamage()), $rot]);
$chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4);
$pot = Tile::createTile("Skull", $chunk, $nbt);
$this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, $face), true, true);
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: first
public function first(Item $item)
{
$count = max(1, $item->getCount());
$checkDamage = $item->getDamage() === null ? false : true;
$checkTags = $item->getCompoundTag() === null ? false : true;
foreach ($this->getContents() as $index => $i) {
if ($item->equals($i, $checkDamage, $checkTags) and $i->getCount() >= $count) {
return $index;
}
}
return -1;
}
示例10: 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());
}
示例11: 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;
}
示例12: __construct
public function __construct(Vector3 $pos, Item $item)
{
parent::__construct($pos, Particle::TYPE_ITEM_BREAK, $item->getId() << 16 | $item->getDamage());
}
示例13: 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);
}