示例#1
0
 public final function getBlock()
 {
     if ($this->block instanceof Block) {
         return $this->block;
     } else {
         return BlockAPI::get(AIR);
     }
 }
示例#2
0
 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 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 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;
     }
 }
示例#5
0
 public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($face !== 0) {
         $faces = array(2 => 2, 3 => 3, 4 => 4, 5 => 5);
         if (!isset($faces[$face])) {
             $this->meta = floor(($player->entity->yaw + 180) * 16 / 360 + 0.5) & 0xf;
             $this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);
             return true;
         } else {
             $this->meta = $faces[$face];
             $this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta, true, false, true));
             return true;
         }
     }
     return false;
 }
示例#6
0
 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;
 }
示例#7
0
 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;
 }
示例#8
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(BED_BLOCK);
     parent::__construct(BED, 0, $count, "Bed");
     $this->maxStackSize = 1;
 }
示例#9
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(CARROT_BLOCK);
     parent::__construct(CARROT, 0, $count, "Carrot");
 }
示例#10
0
 public function update()
 {
     if ($this->closed === true) {
         return false;
     }
     if ($this->class === TILE_FURNACE) {
         $fuel = $this->getSlot(1);
         $raw = $this->getSlot(0);
         $product = $this->getSlot(2);
         $smelt = $raw->getSmeltItem();
         $canSmelt = ($smelt !== false and $raw->count > 0 and ($product->getID() === $smelt->getID() and $product->getMetadata() === $smelt->getMetadata() and $product->count < $product->getMaxStackSize() or $product->getID() === AIR));
         if ($this->data["BurnTime"] <= 0 and $canSmelt and $fuel->getFuelTime() !== false and $fuel->count > 0) {
             $this->lastUpdate = microtime(true);
             $this->data["MaxTime"] = $this->data["BurnTime"] = floor($fuel->getFuelTime() * 20);
             $this->data["BurnTicks"] = 0;
             --$fuel->count;
             if ($fuel->count === 0) {
                 $fuel = BlockAPI::getItem(AIR, 0, 0);
             }
             $this->setSlot(1, $fuel, false);
             $current = $this->level->getBlock($this);
             if ($current->getID() === FURNACE) {
                 $this->level->setBlock($this, BlockAPI::get(BURNING_FURNACE, $current->getMetadata()), true, false, true);
             }
         }
         if ($this->data["BurnTime"] > 0) {
             $ticks = (microtime(true) - $this->lastUpdate) * 20;
             $this->data["BurnTime"] -= $ticks;
             $this->data["BurnTicks"] = ceil($this->data["BurnTime"] / $this->data["MaxTime"] * 200);
             if ($smelt !== false and $canSmelt) {
                 $this->data["CookTime"] += $ticks;
                 if ($this->data["CookTime"] >= 200) {
                     //10 seconds
                     $product = BlockAPI::getItem($smelt->getID(), $smelt->getMetadata(), $product->count + 1);
                     $this->setSlot(2, $product, false);
                     --$raw->count;
                     if ($raw->count === 0) {
                         $raw = BlockAPI::getItem(AIR, 0, 0);
                     }
                     $this->setSlot(0, $raw, false);
                     $this->data["CookTime"] -= 200;
                 }
             } elseif ($this->data["BurnTime"] <= 0) {
                 $this->data["BurnTime"] = 0;
                 $this->data["CookTime"] = 0;
                 $this->data["BurnTicks"] = 0;
             } else {
                 $this->data["CookTime"] = 0;
             }
             $this->server->schedule(2, array($this, "update"));
             $this->scheduledUpdate = true;
         } else {
             $current = $this->level->getBlock($this);
             if ($current->getID() === BURNING_FURNACE) {
                 $this->level->setBlock($this, BlockAPI::get(FURNACE, $current->getMetadata()), true, false, true);
             }
             $this->data["CookTime"] = 0;
             $this->data["BurnTime"] = 0;
             $this->data["BurnTicks"] = 0;
             $this->scheduledUpdate = false;
         }
     }
     $this->server->handle("tile.update", $this);
     $this->lastUpdate = microtime(true);
 }
示例#11
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(POTATO_BLOCK);
     parent::__construct(POTATO, 0, $count, "Potato");
 }
 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;
 }
示例#13
0
 /**
  * @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;
 }
示例#14
0
 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;
 }
示例#15
0
 public function update()
 {
     if ($this->closed === true) {
         return false;
     }
     $now = microtime(true);
     if ($this->check === false) {
         $this->lastUpdate = $now;
         return;
     }
     $tdiff = $now - $this->lastUpdate;
     if ($this->tickCounter === 0) {
         $this->tickCounter = 1;
         $hasUpdate = $this->environmentUpdate();
     } else {
         $hasUpdate = true;
         $this->tickCounter = 0;
     }
     if ($this->closed === true) {
         return false;
     }
     if ($this->isStatic === false) {
         $startX = floor($this->x - 0.5 - $this->size - 1);
         //prefix for flying when player on fence
         $y = (int) floor($this->y - 1);
         $startZ = floor($this->z - 0.5 - $this->size - 1);
         $endX = ceil($this->x - 0.5 + $this->size + 1);
         $endZ = ceil($this->z - 0.5 + $this->size + 1);
         $support = false;
         $isFlying = true;
         for ($z = $startZ; $z <= $endZ; ++$z) {
             for ($x = $startX; $x <= $endX; ++$x) {
                 $v = new Vector3($x, $y, $z);
                 if ($this->isSupport($v, $this->size)) {
                     $b = $this->level->getBlock($v);
                     if ($b->isSolid === true) {
                         $support = true;
                         $isFlying = false;
                         break;
                     } elseif ($b instanceof LiquidBlock or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL) {
                         $isFlying = false;
                     }
                 }
             }
             if ($support === true) {
                 break;
             }
         }
         if ($this->class !== ENTITY_PLAYER) {
             $update = false;
             if ($this->class !== ENTITY_OBJECT and $this->type !== OBJECT_PRIMEDTNT or $support === false) {
                 $drag = 0.4 * $tdiff;
                 if ($this->speedX != 0) {
                     $this->speedX -= $this->speedX * $drag;
                     $this->x += $this->speedX * $tdiff;
                     $update = true;
                 }
                 if ($this->speedZ != 0) {
                     $this->speedZ -= $this->speedZ * $drag;
                     $this->z += $this->speedZ * $tdiff;
                     $update = true;
                 }
                 if ($this->speedY != 0) {
                     $this->speedY -= $this->speedY * $drag;
                     $ny = $this->y + $this->speedY * $tdiff;
                     if ($ny <= $this->y) {
                         $x = (int) ($this->x - 0.5);
                         $z = (int) ($this->z - 0.5);
                         $lim = (int) floor($ny);
                         for ($y = (int) ceil($this->y) - 1; $y >= $lim; --$y) {
                             if ($this->level->getBlock(new Vector3($x, $y, $z))->isSolid === true) {
                                 $ny = $y + 1;
                                 $this->speedY = 0;
                                 $support = true;
                                 if ($this->class === ENTITY_FALLING) {
                                     $this->y = $ny;
                                     $fall = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y)), intval($this->z - 0.5)));
                                     $down = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y) - 1), intval($this->z - 0.5)));
                                     if ($fall->isFullBlock === false or $down->isFullBlock === false) {
                                         $this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xffff, 0, 1), true);
                                     } else {
                                         $this->level->setBlock($fall, BlockAPI::get($this->data["Tile"]), true, false, true);
                                     }
                                     $this->server->api->handle("entity.motion", $this);
                                     $this->close();
                                     return false;
                                 }
                                 break;
                             }
                         }
                     }
                     $this->y = $ny;
                     $update = true;
                 }
             }
             if ($support === false) {
                 $this->speedY -= ($this->class === ENTITY_FALLING ? 18 : 32) * $tdiff;
                 $update = true;
             } else {
                 $this->speedX = 0;
                 $this->speedY = 0;
                 $this->speedZ = 0;
                 $this->server->api->handle("entity.move", $this);
                 if ($this->class === ENTITY_OBJECT and $this->type !== OBJECT_PRIMEDTNT or $this->speedY <= 0.1) {
                     $update = false;
                     $this->server->api->handle("entity.motion", $this);
                 }
             }
             if ($update === true) {
                 $hasUpdate = true;
                 $this->server->api->handle("entity.motion", $this);
             }
         } elseif ($this->player instanceof Player) {
             if ($isFlying === true and ($this->player->gamemode & 0x1) === 0x0) {
                 if ($this->fallY === false or $this->fallStart === false) {
                     $this->fallY = $y;
                     $this->fallStart = microtime(true);
                 } elseif ($this->class === ENTITY_PLAYER and $this->fallStart + 5 < microtime(true)) {
                     if ($this->server->api->getProperty("allow-flight") !== true and $this->server->handle("player.flying", $this->player) !== true) {
                         $this->player->close("flying");
                         return;
                     }
                 } elseif ($y > $this->fallY) {
                     $this->fallY = $y;
                 }
             } elseif ($this->fallY !== false) {
                 //Fall damage!
                 if ($y < $this->fallY) {
                     $d = $this->level->getBlock(new Vector3($x, $y + 1, $z));
                     $d2 = $this->level->getBlock(new Vector3($x, $y + 2, $z));
                     $dmg = $this->fallY - $y - 3;
                     if ($dmg > 0 and !$d instanceof LiquidBlock and $d->getID() !== LADDER and $d->getID() !== COBWEB and !$d2 instanceof LiquidBlock and $d2->getID() !== LADDER and $d2->getID() !== COBWEB) {
                         $this->harm($dmg, "fall");
                     }
                 }
                 $this->fallY = false;
                 $this->fallStart = false;
             }
             $this->calculateVelocity();
             if ($this->speed <= 9 or $this->speed <= 20 and ($this->player->gamemode & 0x1) === 0x1) {
                 $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]);
             }
         }
     }
     if ($this->class !== ENTITY_PLAYER) {
         $this->updateMovement();
         if ($hasUpdate === true) {
             $this->server->schedule(5, array($this, "update"));
         }
     }
     $this->lastUpdate = $now;
 }
 public function handler(&$data, $event)
 {
     switch ($event) {
         case "server.close":
             file_put_contents("./plugins/Essentials/Logindata.dat", serialize($this->password));
             break;
         case "player.join":
             $this->logined[$data->__get("iusername")] = false;
             $this->forget[$data->__get("iusername")] = 0;
             break;
         case "tile.update":
             if ($data->class === TILE_SIGN) {
                 $player = $this->api->player->get($data->data["creator"]);
                 $line = $data->data["Text1"] . $data->data["Text2"] . $data->data["Text3"] . $data->data["Text4"];
                 if ($this->logined[$player->__get("iusername")] === false and $line[0] !== "/") {
                     $player->sendChat("Please login first.");
                     $this->api->tileentity->remove($data->id);
                     $player->level->setBlock(new Vector3($data->x, $data->y, $data->z), BlockAPI::get(AIR));
                     return false;
                 }
             }
             break;
         case "player.flying":
             if ($this->logined[$data->__get("iusername")] === false) {
                 $username = $data->__get("username");
                 $x = $data->entity->x;
                 $y = $data->level->getSpawn()->getY();
                 $z = $data->entity->z;
                 $this->api->player->tppos($username, $x, $y, $z);
                 $data->sendChat("Please login first.");
                 return true;
             }
             break;
         case "player.move":
             if ($this->config["login-after-move"] === false) {
                 return false;
             }
             break;
         case "player.interact":
             $player = $this->api->player->getByEID($data["entity"]->eid);
             if ($this->logined[$player->__get("iusername")] === false) {
                 $player->sendChat("Please login first.");
                 return false;
             }
             break;
         case "player.block.touch":
             if ($this->logined[$data["player"]->__get("iusername")] === false and $this->signCheck($data["type"], $data["item"], $data["target"]) === false) {
                 $data["player"]->sendChat("Please login first.");
                 return false;
             }
             break;
         case "player.block.activate":
             /*if($this->logined[$data["player"]->__get("iusername")] === false and $data["target"]->isActivable === true){
             			$data["player"]->sendChat("Please login first.");
             			return false;
             		}*/
             break;
         case "plugin.forge.api":
             $data["CommandAPI"]->register("register", "<password>", array($this, "commandHandler"));
             $data["CommandAPI"]->register("login", "<password>", array($this, "commandHandler"));
             $data["CommandAPI"]->register("logout", "", array($this, "commandHandler"));
             $data["CommandAPI"]->register("password", "<remove|change> <player> <password>", array($this, "commandHandler"));
             break;
         case "api.cmd.command":
             if ($this->logined[$data["issuer"]->__get("iusername")] !== true) {
                 foreach ($this->config["login-after-commands"] as $cmd) {
                     if ($cmd === $data["cmd"]) {
                         return true;
                     }
                 }
                 return false;
             }
             break;
     }
 }
示例#17
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(CAKE_BLOCK);
     $this->maxStackSize = 1;
     parent::__construct(CAKE, 0, $count, "Cake");
 }
示例#18
0
 public function explode()
 {
     $server = ServerAPI::request();
     if ($this->size < 0.1 or $server->api->dhandle("entity.explosion", array("level" => $this->level, "source" => $this->source, "size" => $this->size)) === false) {
         return false;
     }
     $mRays = $this->rays - 1;
     for ($i = 0; $i < $this->rays; ++$i) {
         for ($j = 0; $j < $this->rays; ++$j) {
             for ($k = 0; $k < $this->rays; ++$k) {
                 if ($i == 0 or $i == $mRays or $j == 0 or $j == $mRays or $k == 0 or $k == $mRays) {
                     $vector = new Vector3($i / $mRays * 2 - 1, $j / $mRays * 2 - 1, $k / $mRays * 2 - 1);
                     //($i / $mRays) * 2 - 1
                     $vector = $vector->normalize()->multiply($this->stepLen);
                     $pointer = clone $this->source;
                     for ($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75) {
                         $vBlock = $pointer->floor();
                         $blockID = $this->level->level->getBlockID($vBlock->x, $vBlock->y, $vBlock->z);
                         if ($blockID > 0) {
                             $block = BlockAPI::get($blockID, 0);
                             $block->x = $vBlock->x;
                             $block->y = $vBlock->y;
                             $block->z = $vBlock->z;
                             $blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen;
                             if ($blastForce > 0) {
                                 $index = ($block->x << 15) + ($block->z << 7) + $block->y;
                                 if (!isset($this->affectedBlocks[$index])) {
                                     $this->affectedBlocks[$index] = $block;
                                 }
                             }
                         }
                         $pointer = $pointer->add($vector);
                     }
                 }
             }
         }
     }
     $send = array();
     $source = $this->source->floor();
     $radius = 2 * $this->size;
     foreach ($server->api->entity->getRadius($this->source, $radius) as $entity) {
         $impact = (1 - $this->source->distance($entity) / $radius) * 0.5;
         //placeholder, 0.7 should be exposure
         $damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
         $entity->harm($damage, "explosion");
     }
     foreach ($this->affectedBlocks as $block) {
         if ($block instanceof TNTBlock) {
             $data = array("x" => $block->x + 0.5, "y" => $block->y + 0.5, "z" => $block->z + 0.5, "power" => 4, "fuse" => mt_rand(10, 30));
             $e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
             $server->api->entity->spawnToAll($e);
         } elseif (mt_rand(0, 10000) < 1 / $this->size * 10000) {
             if (isset(self::$specialDrops[$block->getID()])) {
                 $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(self::$specialDrops[$block->getID()], 0));
             } else {
                 $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z)));
             }
         }
         $this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
         $send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
     }
     $pk = new ExplodePacket();
     $pk->x = $this->source->x;
     $pk->y = $this->source->y;
     $pk->z = $this->source->z;
     $pk->radius = $this->size;
     $pk->records = $send;
     $server->api->player->broadcastPacket($this->level->players, $pk);
 }
示例#19
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(PUMPKIN_STEM);
     parent::__construct(PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds");
 }
示例#20
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(BEETROOT_BLOCK);
     parent::__construct(BEETROOT_SEEDS, 0, $count, "Beetroot Seeds");
 }
示例#21
0
 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;
 }
示例#22
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(SUGARCANE_BLOCK);
     parent::__construct(SUGARCANE, 0, $count, "Sugar Cane");
 }
示例#23
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(WHEAT_BLOCK);
     parent::__construct(WHEAT_SEEDS, 0, $count, "Wheat Seeds");
 }
示例#24
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(MELON_STEM);
     parent::__construct(MELON_SEEDS, 0, $count, "Melon Seeds");
 }
示例#25
0
 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));
 }
示例#26
0
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = BlockAPI::get(SIGN_POST);
     $this->maxStackSize = 16;
     parent::__construct(SIGN, 0, $count, "Sign");
 }