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; }
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; }
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; }
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; }
protected function putSlot(Item $item) { $this->putShort($item->getID()); $this->putByte($item->count); $this->putShort($item->getMetadata()); }
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; }
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; }
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; }