本文整理汇总了PHP中Item::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getMetadata方法的具体用法?PHP Item::getMetadata怎么用?PHP Item::getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::getMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Item $item, Player $player)
{
if ($item->getID() === DYE and $item->getMetadata() === 0xf) {
//Bonemeal
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x3);
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例2: onActivate
public function onActivate(Item $item, Player $player)
{
if ($item->getID() === DYE and $item->getMetadata() === 0xf) {
//Bonemeal
$this->meta = 0x7;
$this->level->setBlock($this, $this, true, false, true);
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例3: onActivate
public function onActivate(Item $item, Player $player)
{
if ($item->getID() === DYE and $item->getMetadata() === 0xf) {
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
TallGrassObject::growGrass($this->level, $this, new Random(), 8, 2);
return true;
} elseif ($item->isHoe()) {
if (($player->gamemode & 0x1) === 0) {
$item->useOn($this);
}
$this->level->setBlock($this, new FarmlandBlock());
return true;
}
return false;
}
示例4: onActivate
public function onActivate(Item $item, Player $player)
{
if ($item->getID() === DYE and $item->getMetadata() === 0xf) {
//Bonemeal
if ($this->getSide(0)->getID() !== SUGARCANE_BLOCK) {
for ($y = 1; $y < 3; ++$y) {
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if ($b->getID() === AIR) {
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break;
}
}
$this->meta = 0;
$this->level->setBlock($this, $this, true, false, true);
}
if (($player->gamemode & 0x1) === 0) {
$item->count--;
}
return true;
}
return false;
}
示例5: putSlot
protected function putSlot(Item $item)
{
$this->putShort($item->getID());
$this->putByte($item->count);
$this->putShort($item->getMetadata());
}
示例6: W_replace
private function W_replace($selection, Item $block1, $blocks2, &$output = null)
{
if (!is_array($selection) or $selection[0] === false or $selection[1] === false or $selection[0][3] !== $selection[1][3]) {
$output .= "Make a selection first.\n";
return false;
}
$totalCount = $this->countBlocks($selection);
if ($totalCount > 524288) {
$send = false;
} else {
$send = true;
}
$level = $selection[0][3];
$id1 = $block1->getID();
$meta1 = $block1->getMetadata();
$bcnt2 = count($blocks2) - 1;
if ($bcnt2 < 0) {
$output .= "Incorrect blocks.\n";
return false;
}
$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->getMetadata() === $meta1)) {
$count += (int) $level->setBlockRaw($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);
}
}
}
}
$output .= "{$count} block(s) have been changed.\n";
return true;
}
示例7: setSlot
public function setSlot($s, Item $item, $update = true, $offset = 0)
{
$i = $this->getSlotIndex($s);
$d = array("Count" => $item->count, "Slot" => $s, "id" => $item->getID(), "Damage" => $item->getMetadata());
if ($i === false) {
return false;
} elseif ($item->getID() === AIR or $item->count <= 0) {
if ($i >= 0) {
unset($this->data["Items"][$i]);
}
} elseif ($i < 0) {
$this->data["Items"][] = $d;
} else {
$this->data["Items"][$i] = $d;
}
$this->server->api->dhandle("tile.container.slot", array("tile" => $this, "slot" => $s, "offset" => $offset, "slotdata" => $item));
if ($update === true and $this->scheduledUpdate === false) {
$this->update();
}
return true;
}
示例8: W_replace
private function W_replace($selection, Item $block1, $blocks2, &$output = null)
{
if (!is_array($selection) or $selection[0] === false or $selection[1] === false or $selection[0][3] !== $selection[1][3]) {
$output .= "Make a selection first.\n";
return false;
}
$level = $selection[0][3];
$id1 = $block1->getID();
$meta1 = $block1->getMetadata();
$bcnt2 = count($blocks2) - 1;
if ($bcnt2 < 0) {
$output .= "Incorrect blocks.\n";
return false;
}
$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->getMetadata() === $meta1)) {
$count += (int) $level->setBlock($b, $blocks2[mt_rand(0, $bcnt2)]->getBlock(), false);
}
}
}
}
$output .= "{$count} block(s) have been changed.\n";
return true;
}