public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { $down = $this->getSide(0); if ($down->getID() !== SAND and $down->getID() !== CACTUS) { //Replace with common break method $this->level->setBlock($this, new AirBlock(), false); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); return BLOCK_UPDATE_NORMAL; } } elseif ($type === BLOCK_UPDATE_RANDOM) { if ($this->getSide(0)->getID() !== CACTUS) { if ($this->meta == 0xf) { 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 CactusBlock(), true, false, true); break; } } $this->meta = 0; $this->level->setBlock($this, $this, false); } else { ++$this->meta; $this->level->setBlock($this, $this, false); } return BLOCK_UPDATE_RANDOM; } } return false; }
private static function parseRecipe($recipe) { $recipe = explode("=>", $recipe); $recipeItems = array(); foreach (explode(",", $recipe[0]) as $item) { $item = explode("x", $item); $id = explode(":", $item[0]); $meta = array_pop($id); $id = $id[0]; $it = BlockAPI::fromString($id); $recipeItems[$it->getID()] = array($it->getID(), $meta === "?" ? false : intval($meta) & 0xffff, intval($item[1])); } ksort($recipeItems); $item = explode("x", $recipe[1]); $id = explode(":", $item[0]); $meta = array_pop($id); $id = $id[0]; $it = BlockAPI::fromString($id); $craftItem = array($it->getID(), intval($meta) & 0xffff, intval($item[1])); $recipeString = ""; foreach ($recipeItems as $item) { $recipeString .= $item[0] . "x" . $item[2] . ","; } $recipeString = substr($recipeString, 0, -1) . "=>" . $craftItem[0] . "x" . $craftItem[2]; return array($recipeItems, $craftItem, $recipeString); }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { if ($this->getSide(0)->isTransparent === true) { //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } } elseif ($type === BLOCK_UPDATE_RANDOM) { //Growth if (mt_rand(1, 7) === 1) { if (($this->meta & 0x8) === 0x8) { TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x3); } else { $this->meta |= 0x8; $this->level->setBlock($this, $this, true, false, true); return BLOCK_UPDATE_RANDOM; } } else { return BLOCK_UPDATE_RANDOM; } } return false; }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { if ($this->getSide(0)->isTransparent === true) { //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2))); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } } elseif ($type === BLOCK_UPDATE_RANDOM) { if (mt_rand(0, 2) == 1) { if ($this->meta < 0x7) { ++$this->meta; $this->level->setBlock($this, $this, true, false, true); return BLOCK_UPDATE_RANDOM; } else { for ($side = 2; $side <= 5; ++$side) { $b = $this->getSide($side); if ($b->getID() === MELON_BLOCK) { return BLOCK_UPDATE_RANDOM; } } $side = $this->getSide(mt_rand(2, 5)); $d = $side->getSide(0); if ($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)) { $this->level->setBlock($side, new MelonBlock(), true, false, true); } } } return BLOCK_UPDATE_RANDOM; } return false; }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH) { $this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false, false, true); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); return BLOCK_UPDATE_WEAK; } return false; }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { if ($this->getSide(0)->isTransparent === true) { //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); $this->level->setBlock($this, new AirBlock(), false); return BLOCK_UPDATE_NORMAL; } } return false; }
public static function growGrass(Level $level, Vector3 $pos, Random $random, $count = 15, $radius = 10) { $arr = array(BlockAPI::get(DANDELION, 0), BlockAPI::get(CYAN_FLOWER, 0), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1)); $arrC = count($arr) - 1; for ($c = 0; $c < $count; ++$c) { $x = $random->nextRange($pos->x - $radius, $pos->x + $radius); $z = $random->nextRange($pos->z - $radius, $pos->z + $radius); if ($level->level->getBlockID($x, $pos->y + 1, $z) === AIR and $level->level->getBlockID($x, $pos->y, $z) === GRASS) { $t = $arr[$random->nextRange(0, $arrC)]; $level->setBlockRaw(new Vector3($x, $pos->y + 1, $z), $t); } } }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { $side = $this->getMetadata(); $faces = array(1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0); if ($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)) { //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1)); $this->level->setBlock($this, new AirBlock(), true, false, true); return BLOCK_UPDATE_NORMAL; } } return false; }
public function handler(&$data, $event) { switch ($event) { case "tile.update": if ($data->class === TILE_SIGN) { $line = $data->data["Text1"] . $data->data["Text2"] . $data->data["Text3"] . $data->data["Text4"]; if ($line[0] === "/") { $player = $this->api->player->get($data->data["creator"]); $this->run(str_replace("/", "", $line), $player); $player->level->setBlock(new Vector3($data->data["x"], $data->data["y"], $data->data["z"]), BlockAPI::get(AIR)); $this->api->tileentity->remove($data->id); } } break; } }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz) { $down = $this->getSide(0); if ($down->isTransparent === false) { $faces = array(0 => 3, 1 => 4, 2 => 2, 3 => 5); $d = $player->entity->getDirection(); $next = $this->getSide($faces[($d + 3) % 4]); $downNext = $this->getSide(0); if ($next->isReplaceable === true and $downNext->isTransparent === false) { $meta = ($d + 3) % 4 & 0x3; $this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true); $this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x8), true, false, true); return true; } } return false; }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz) { $this->meta &= 0x7; if ($face === 0) { if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0x8 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) { $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); return true; } elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) { $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); return true; } else { $this->meta |= 0x8; } } elseif ($face === 1) { if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) { $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); return true; } elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) { $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); return true; } } elseif (!$player->entity->inBlock($block)) { if ($block->getID() === WOOD_SLAB) { if (($block->getMetadata() & 0x7) === ($this->meta & 0x7)) { $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); return true; } return false; } else { if ($fy > 0.5) { $this->meta |= 0x8; } } } else { return false; } if ($block->getID() === WOOD_SLAB and ($target->getMetadata() & 0x7) !== ($this->meta & 0x7)) { return false; } $this->level->setBlock($block, $this, true, false, true); return true; }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { if ($this->getSide(0)->isTransparent === true) { //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1)); $this->level->setBlock($this, new AirBlock(), false, false, true); return BLOCK_UPDATE_NORMAL; } } elseif ($type === BLOCK_UPDATE_RANDOM) { if (mt_rand(0, 2) == 1) { if ($this->meta < 0x7) { ++$this->meta; $this->level->setBlock($this, $this, true, false, true); return BLOCK_UPDATE_RANDOM; } } else { return BLOCK_UPDATE_RANDOM; } } return false; }
/** * @param Item $item * @param Player $player * * @return boolean */ public function onActivate(Item $item, Player $player) { if (($this->meta & 0x8) === 0x8) { //Top $down = $this->getSide(0); if ($down->getID() === $this->id) { $meta = $down->getMetadata() ^ 0x4; $this->level->setBlock($down, BlockAPI::get($this->id, $meta), true, false, true); $players = ServerAPI::request()->api->player->getAll($this->level); unset($players[$player->CID]); $pk = new LevelEventPacket(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->evid = 1003; $pk->data = 0; ServerAPI::request()->api->player->broadcastPacket($players, $pk); return true; } return false; } else { $this->meta ^= 0x4; $this->level->setBlock($this, $this, true, false, true); $players = ServerAPI::request()->api->player->getAll($this->level); unset($players[$player->CID]); $pk = new LevelEventPacket(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->evid = 1003; $pk->data = 0; ServerAPI::request()->api->player->broadcastPacket($players, $pk); } return true; }
public function initPlayer($player) { if ($player->gamemode === CREATIVE) { foreach ($player->inventory as $slot => $item) { if ($this->api->ban->isOp($player->__get("iusername"))) { $player->setSlot($slot, BlockAPI::fromString($this->config["creative-item-op"][$slot])); } else { $player->setSlot($slot, BlockAPI::fromString($this->config["creative-item"][$slot])); } } } }
public final function getSmeltItem() { if (!isset(SmeltingData::$product[$this->id])) { return false; } if (isset(SmeltingData::$product[$this->id][0]) and !is_array(SmeltingData::$product[$this->id][0])) { return BlockAPI::getItem(SmeltingData::$product[$this->id][0], SmeltingData::$product[$this->id][1]); } if (!isset(SmeltingData::$product[$this->id][$this->meta])) { return false; } return BlockAPI::getItem(SmeltingData::$product[$this->id][$this->meta][0], SmeltingData::$product[$this->id][$this->meta][1]); }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(IRON_DOOR_BLOCK); parent::__construct(IRON_DOOR, 0, $count, "Iron Door"); $this->maxStackSize = 1; }
private function carpet(Entity $player) { $session =& $this->sessions[$player->player->CID]; $startX = (int) ($player->x - ($session["size"] - 1) / 2); $y = (int) $player->y - 1; if ($player->pitch > 75) { --$y; } $startZ = (int) ($player->z - ($session["size"] - 1) / 2); $endX = $startX + $session["size"]; $endZ = $startZ + $session["size"]; $newBlocks = array(); for ($x = $startX; $x < $endX; ++$x) { for ($z = $startZ; $z < $endZ; ++$z) { $i = "{$x}.{$y}.{$z}"; if (isset($session["blocks"][$i])) { $newBlocks[$i] = $session["blocks"][$i]; unset($session["blocks"][$i]); } else { $newBlocks[$i] = $player->level->getBlock(new Vector3($x, $y, $z)); if ($newBlocks[$i]->getID() === AIR) { $session["blocks"][$i] = BlockAPI::get(GLASS); $session["blocks"][$i]->position(new Position($x, $y, $z, $player->level)); } } } } foreach ($session["blocks"] as $i => $block) { $index = array_map("intval", explode(".", $i)); foreach ($this->api->player->getAll($player->level) as $p) { $p->dataPacket(MC_UPDATE_BLOCK, array("x" => $index[0], "y" => $index[1], "z" => $index[2], "block" => $block->getID(), "meta" => $block->getMetadata())); } } $this->sessions[$player->player->CID]["blocks"] = $newBlocks; }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(CARROT_BLOCK); parent::__construct(CARROT, 0, $count, "Carrot"); }
public function confiscateItems() { $players = $this->api->player->getAll(); if (count($players) == 0) { return; } $air = BlockAPI::getItem(Air, 0, 0); foreach ($players as $player) { foreach ($player->inventory as $s => $item) { if ($item->getID() !== Air) { $player->inventory[$s] = $air; } } $player->armor = array($air, $air, $air, $air); $player->sendInventorySlot(); $player->sendArmor($player); } }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(BED_BLOCK); parent::__construct(BED, 0, $count, "Bed"); $this->maxStackSize = 1; }
public function onUpdate($type) { if ($type === BLOCK_UPDATE_NORMAL) { if (($this->meta & 0b1100) === 0) { $this->meta |= 0x8; $this->level->setBlock($this, $this, false, false, true); return BLOCK_UPDATE_RANDOM; } } elseif ($type === BLOCK_UPDATE_RANDOM) { if (($this->meta & 0b1100) === 0x8) { $this->meta &= 0x3; $visited = array(); $check = 0; if ($this->findLog($this, $visited, 0, $check) === true) { $this->level->setBlock($this, $this, false, false, true); } else { $this->level->setBlock($this, new AirBlock(), false, false, true); if (mt_rand(1, 20) === 1) { //Saplings ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SAPLING, $this->meta & 0x3, 1)); } if (($this->meta & 0x3) === LeavesBlock::OAK and mt_rand(1, 200) === 1) { //Apples ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(APPLE, 0, 1)); } return BLOCK_UPDATE_NORMAL; } } } return false; }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(WHEAT_BLOCK); parent::__construct(WHEAT_SEEDS, 0, $count, "Wheat Seeds"); }
private function startTransaction($username, $shopInfo, $c) { if (!file_exists("./plugins/PocketMoney/config.yml")) { $this->api->chat->sendTo(false, "[ChestShop][Error]PocketMoney plugin has not been loaded.", $username); console("[ChestShop][Error]PocketMoney plugin has not been loaded."); return; } $buyerMoney = $this->api->dhandle("money.player.get", array('username' => $username)); if ($buyerMoney === false) { return; } if ($buyerMoney < $shopInfo['price']) { $this->api->chat->sendTo(false, "[ChestShop]Your money is not enough.", $username); return; } $chest = $this->api->tile->get(new Position($c->x, $c->y, $c->z, $c->level)); $saleNum = 0; for ($i = 0; $i < CHEST_SLOTS; $i++) { $item = $chest->getSlot($i); if ($item->getID() === $shopInfo['productID']) { $saleNum += $item->count; } } if ($saleNum < $shopInfo['saleNum']) { $this->api->chat->sendTo(false, "[ChestShop]The stock is not enough.", $username); $this->api->chat->sendTo(false, "[ChestShop]Please notify the owner of the lack.", $username); return; } $cmd = "give"; $params = array($username, $shopInfo['productID'], $shopInfo['saleNum']); $issuer = $this->api->player->get($username); $alias = false; $this->api->block->commandHandler($cmd, $params, $issuer, $alias); $tmpNum = $shopInfo['saleNum']; for ($i = 0; $i < CHEST_SLOTS; $i++) { $item = $chest->getSlot($i); if ($item->getID() === $shopInfo['productID']) { if ($item->count <= $tmpNum) { $chest->setSlot($i, BlockAPI::getItem(AIR, 0, 0)); $tmpNum -= $item->count; } else { $count = $item->count - $tmpNum; $chest->setSlot($i, BlockAPI::getItem($item->getID(), 0, $count)); break; } } } $this->api->dhandle("money.handle", array('username' => $username, 'method' => 'grant', 'amount' => -$shopInfo['price'])); $this->api->dhandle("money.handle", array('username' => $shopInfo['shopOwner'], 'method' => 'grant', 'amount' => $shopInfo['price'])); $this->api->chat->sendTo(false, "[ChestShop]Completed the transaction.", $username); return; }
private function W_paste($clipboard, Position $pos, &$output = null) { if (count($clipboard) !== 2) { $output .= "Copy something first.\n"; return false; } $clipboard[0][0] += $pos->x - 0.5; $clipboard[0][1] += $pos->y; $clipboard[0][2] += $pos->z - 0.5; $offset = array_map("round", $clipboard[0]); $count = 0; foreach ($clipboard[1] as $x => $i) { foreach ($i as $y => $j) { foreach ($j as $z => $block) { $b = BlockAPI::get(ord($block[0]), ord($block[1])); $count += (int) $pos->level->setBlockRaw(new Vector3($x + $offset[0], $y + $offset[1], $z + $offset[2]), $b, false); unset($b); } } } $output .= "{$count} block(s) have been changed.\n"; return true; }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(MELON_STEM); parent::__construct(MELON_SEEDS, 0, $count, "Melon Seeds"); }
public function __construct($meta = 0, $count = 1) { $this->block = BlockAPI::get(POTATO_BLOCK); parent::__construct(POTATO, 0, $count, "Potato"); }
public function spawn($player) { if (!$player instanceof Player) { $player = $this->server->api->player->get($player); } if ($player->eid === $this->eid or $this->closed !== false or $player->level !== $this->level and $this->class !== ENTITY_PLAYER) { return false; } switch ($this->class) { case ENTITY_PLAYER: if ($this->player->connected !== true or $this->player->spawned === false) { return false; } $pk = new AddPlayerPacket(); $pk->clientID = 0; //$this->player->clientID; $pk->username = $this->player->username; $pk->eid = $this->eid; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = 0; $pk->pitch = 0; $pk->unknown1 = 0; $pk->unknown2 = 0; $pk->metadata = $this->getMetadata(); $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); $pk = new PlayerEquipmentPacket(); $pk->eid = $this->eid; $pk->item = $this->player->getSlot($this->player->slot)->getID(); $pk->meta = $this->player->getSlot($this->player->slot)->getMetadata(); $pk->slot = 0; $player->dataPacket($pk); $this->player->sendArmor($player); break; case ENTITY_ITEM: $pk = new AddItemEntityPacket(); $pk->eid = $this->eid; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->roll = 0; $pk->item = BlockAPI::getItem($this->type, $this->meta, $this->stack); $pk->metadata = $this->getMetadata(); $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); break; case ENTITY_MOB: $pk = new AddMobPacket(); $pk->eid = $this->eid; $pk->type = $this->type; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->getMetadata(); $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); break; case ENTITY_OBJECT: if ($this->type === OBJECT_PAINTING) { $pk = new AddPaintingPacket(); $pk->eid = $this->eid; $pk->x = (int) $this->x; $pk->y = (int) $this->y; $pk->z = (int) $this->z; $pk->direction = $this->getDirection(); $pk->title = $this->data["Motive"]; $player->dataPacket($pk); } elseif ($this->type === OBJECT_PRIMEDTNT) { $pk = new AddEntityPacket(); $pk->eid = $this->eid; $pk->type = $this->type; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->did = 0; $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); } elseif ($this->type === OBJECT_ARROW) { $pk = new AddEntityPacket(); $pk->eid = $this->eid; $pk->type = $this->type; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->did = 0; $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); } break; case ENTITY_FALLING: $pk = new AddEntityPacket(); $pk->eid = $this->eid; $pk->type = $this->type; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->did = -$this->data["Tile"]; $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); $pk->eid = $this->eid; $pk->speedX = $this->speedX; $pk->speedY = $this->speedY; $pk->speedZ = $this->speedZ; $player->dataPacket($pk); break; } }
public function handler(&$data, $event) { switch ($event) { case "server.close": //file_put_contents("./plugins/Essentials/Protectdata.dat", serialize($this->save)); break; case "plugin.forge.api": $data["CommandAPI"]->register("blundo", "<player>", array($this, "defaultCommands")); break; case "entity.explosion": if ($this->config["allow-explosion"] === false) { return true; } break; case "tile.update": break; case "player.block.place": if ($data["item"]->getID() === CHEST) { $this->protect["chest"][$data["player"]->__get("iusername")][] = new Protect($this->api, $data["player"]->__get("iusername"), new Position($data["block"]->x, $data["block"]->y, $data["block"]->z, $data["player"]->level)); break; } if ($this->api->ban->isOp($data["player"]->__get("iusername")) === false) { $items = BlockAPI::fromString($this->config["blacklist"]["placement"], true); foreach ($items as $item) { if ($data["item"]->getID() === $item->getID() and $data["item"]->getMetadata() === $item->getMetadata()) { return false; } } } break; case "player.block.break": if ($data["target"]->getID() === CHEST) { $t = $this->get(new Position($data["target"]->x, $data["target"]->y, $data["target"]->z, $data["player"]->level)); if ($t !== false) { if ($this->api->ban->isOp($data["player"]->__get("iusername"))) { $t->__destruct(); break; } $break = $t->onBreak($output, $data["player"]); if ($output != "") { $data["player"]->sendChat($output); } return $break; } break; } if ($this->api->ban->isOp($data["player"]->__get("iusername")) === false) { $items = BlockAPI::fromString($this->config["blacklist"]["break"], true); foreach ($items as $item) { if ($data["target"]->getID() === $item->getID() and $data["target"]->getMetadata() === $item->getMetadata()) { return false; } } } break; case "player.block.activate": if ($data["target"]->getID() === CHEST) { $output = ""; $t = $this->get(new Position($data["target"]->x, $data["target"]->y, $data["target"]->z, $data["player"]->level)); if ($data["item"]->getID() === STICK and ($this->api->ban->isOp($data["player"]->__get("iusername")) or $t->owner === $data["player"]->__get("iusername"))) { $t->protectChange($output); if ($output != "") { $data["player"]->sendChat($output); } return false; } if ($t !== false) { $open = $t->onOpen($output, $data["player"]); if ($output != "") { $data["player"]->sendChat($output); } return $open; } } elseif ($data["target"]->getID() === WOOD_DOOR_BLOCK) { return false; } break; } }
public function getBlock(Vector3 $pos) { if (!isset($this->level) or $pos instanceof Position and $pos->level !== $this) { return false; } $b = $this->level->getBlock($pos->x, $pos->y, $pos->z); return BlockAPI::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this)); }
protected function getSlot() { $id = $this->getShort(); $cnt = $this->getByte(); return BlockAPI::getItem($id, $this->getShort(), $cnt); }