本文整理匯總了PHP中pocketmine\item\Item::getID方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getID方法的具體用法?PHP Item::getID怎麽用?PHP Item::getID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\item\Item
的用法示例。
在下文中一共展示了Item::getID方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($this->meta < 0x7 && $item->getID() === Item::DYE && $item->getDamage() === 0xf) {
//Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
if ($block->meta > 0x7) {
$block->meta = 0x7;
}
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
if ($player->isSurvival()) {
$item->count--;
}
return true;
}
}
return false;
}
示例2: __construct
public function __construct(Location $loc, $name, $skin, $slim, Item $item, NPCWork $work)
{
$this->pos = $loc;
$this->eid = Entity::$entityCount++;
$this->skin = $skin;
$this->slim = $slim;
$this->name = $name;
$this->item = $item->getID();
$this->meta = $item->getDamage();
$this->work = $work;
}
示例3: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getID() === Item::DYE and $item->getDamage() === 0xf) {
//Bonemeal
$this->meta = 0x7;
$this->getLevel()->setBlock($this, $this, true, true);
$item->count--;
return true;
}
return false;
}
示例4: 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;
}
return false;
}
示例5: saveNBT
public function saveNBT()
{
$this->namedtag->Item = new Compound("Item", ["id" => new Short("id", $this->item->getID()), "Damage" => new Short("Damage", $this->item->getDamage()), "Count" => new Byte("Count", $this->item->getCount())]);
$this->namedtag->Health = new Short("Health", $this->getHealth());
$this->namedtag->Age = new Short("Age", $this->age);
$this->namedtag->PickupDelay = new Short("PickupDelay", $this->pickupDelay);
if ($this->owner !== null) {
$this->namedtag->Owner = new String("Owner", $this->owner);
}
if ($this->thrower !== null) {
$this->namedtag->Thrower = new String("Thrower", $this->thrower);
}
}
示例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::FLINT_STEEL) {
if (($player->gamemode & 0x1) === 0) {
$item->useOn($this);
}
$data = ["x" => $this->x + 0.5, "y" => $this->y + 0.5, "z" => $this->z + 0.5, "power" => 4, "fuse" => 20 * 4];
$this->getLevel()->setBlock($this, new Air(), false, false, true);
//TODO
//$e = Server::getInstance()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
//$e->spawnToAll();
return true;
}
return false;
}
示例8: 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) {
$this->getLevel()->setBlock($b, new Sugarcane(), true);
break;
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this, true);
}
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例9: setItem
/**
* This method should not be used by plugins, use the Inventory
*
* @param int $index
* @param Item $item
*
* @return bool
*/
public function setItem($index, Item $item)
{
$i = $this->getSlotIndex($index);
$d = new Compound(false, [new Byte("Count", $item->getCount()), new Byte("Slot", $index), new Short("id", $item->getID()), new Short("Damage", $item->getDamage())]);
if ($item->getID() === Item::AIR or $item->getCount() <= 0) {
if ($i >= 0) {
unset($this->namedtag->Items[$i]);
}
} elseif ($i < 0) {
for ($i = 0; $i <= $this->getSize(); ++$i) {
if (!isset($this->namedtag->Items[$i])) {
break;
}
}
$this->namedtag->Items[$i] = $d;
} else {
$this->namedtag->Items[$i] = $d;
}
return true;
}
示例10: putSlot
protected function putSlot(Item $item)
{
if ($item->getID() === 0) {
$this->putShort(-1);
} else {
$this->putShort($item->getID());
$this->putByte($item->getCount());
$this->putShort($item->getDamage());
$nbt = $item->getCompoundTag();
$this->putByte(strlen($nbt));
$this->put($nbt);
}
}
示例11: match
public function match(Item $item)
{
return $this->matchRaw($this->id, $item->getID(), $this->defaultID) and $this->matchRaw($this->damage, $item->getDamage(), $this->defaultDamage);
}
示例12: hasItemPlayer
/**
* @param Player $player
* @param Item $item
* @return boolean
*/
private function hasItemPlayer(Player $player, Item $item)
{
if ($this->SignShop->getProvider()->getPlayer(strtolower($player->getName()))["authorized"] == "root") {
return true;
}
$ris = 0;
if ($player->getGamemode() != 1) {
for ($i = 0; $i <= $player->getInventory()->getSize(); ++$i) {
$inv = $player->getInventory()->getItem($i);
if ($inv->getID() == $item->getID() && $inv->getDamage() == $item->getDamage()) {
$ris = $ris + $inv->getCount();
}
}
}
if ($ris >= $item->getCount()) {
return true;
}
return false;
}
示例13: equals
public final function equals(Item $item, $checkDamage = false)
{
return $this->id === $item->getID() and ($checkDamage === false or $this->getDamage() === $item->getDamage());
}
示例14: dropItem
/**
* @param Vector3 $source
* @param Item $item
* @param Vector3 $motion
*/
public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, $delay = 10)
{
$motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion;
if ($item->getID() !== Item::AIR and $item->getCount() > 0) {
$itemEntity = new DroppedItem($this->getChunkAt($source->getX() >> 4, $source->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $source->getX()), new Double("", $source->getY()), new Double("", $source->getZ())]), "Motion" => new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)]), "Health" => new Short("Health", 5), "Item" => new Compound("Item", ["id" => new Short("id", $item->getID()), "Damage" => new Short("Damage", $item->getDamage()), "Count" => new Byte("Count", $item->getCount())]), "PickupDelay" => new Short("PickupDelay", $delay)]));
$itemEntity->spawnToAll();
}
}
示例15: W_replace
private function W_replace($selection, Item $block1, $blocks2)
{
if (!is_array($selection) or $selection[0] === false or $selection[1] === false or $selection[0][3] !== $selection[1][3]) {
return "Make a selection first.";
}
$totalCount = $this->countBlocks($selection);
if ($totalCount > 524288) {
$send = false;
} else {
$send = true;
}
$level = $this->getServer()->getLevelByName($selection[0][3]);
$id1 = $block1->getID();
$meta1 = $block1->getDamage();
$bcnt2 = count($blocks2) - 1;
if ($bcnt2 < 0) {
return "Incorrect blocks.";
}
$startX = min($selection[0][0], $selection[1][0]);
$endX = max($selection[0][0], $selection[1][0]);
$startY = min($selection[0][1], $selection[1][1]);
$endY = max($selection[0][1], $selection[1][1]);
$startZ = min($selection[0][2], $selection[1][2]);
$endZ = max($selection[0][2], $selection[1][2]);
$count = 0;
for ($x = $startX; $x <= $endX; ++$x) {
for ($y = $startY; $y <= $endY; ++$y) {
for ($z = $startZ; $z <= $endZ; ++$z) {
$b = $level->getBlock(new Vector3($x, $y, $z));
if ($b->getID() === $id1 and ($meta1 === false or $b->getDamage() === $meta1)) {
$count += (int) $level->setBlock($b, $blocks2[mt_rand(0, $bcnt2)]->getBlock(), false, $send);
}
unset($b);
}
}
}
if ($send === false) {
$forceSend = function ($X, $Y, $Z) {
$this->changedCount[$X . ":" . $Y . ":" . $Z] = 4096;
};
$forceSend->bindTo($level, $level);
for ($X = $startX >> 4; $X <= $endX >> 4; ++$X) {
for ($Y = $startY >> 4; $Y <= $endY >> 4; ++$Y) {
for ($Z = $startZ >> 4; $Z <= $endZ >> 4; ++$Z) {
$forceSend($X, $Y, $Z);
}
}
}
}
return "{$count} block(s) have been changed.";
}