explodeB() public method

public explodeB ( ) : boolean
return boolean
Exemplo n.º 1
0
 public function onUpdate($currentTick)
 {
     if ($this->closed) {
         return false;
     }
     $this->timings->startTiming();
     $hasUpdate = parent::onUpdate($currentTick);
     if (!$this->hadCollision and $this->isCritical) {
         $this->level->addParticle(new CriticalParticle($this->add($this->width / 2 + mt_rand(-100, 100) / 500, $this->height / 2 + mt_rand(-100, 100) / 500, $this->width / 2 + mt_rand(-100, 100) / 500)));
     } elseif ($this->onGround) {
         $this->isCritical = false;
     }
     if ($this->age > 1200 or $this->isCollided) {
         $hasUpdate = true;
         if ($this->isCollided and $this->canExplode) {
             $this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 2.8));
             if (!$ev->isCancelled()) {
                 $explosion = new Explosion($this, $ev->getForce(), $this->shootingEntity);
                 if ($ev->isBlockBreaking()) {
                     $explosion->explodeA();
                 }
                 $explosion->explodeB();
             }
         }
         $this->kill();
     }
     $this->timings->stopTiming();
     return $hasUpdate;
 }
Exemplo n.º 2
0
 public function onMove(PlayerMoveEvent $event)
 {
     $cfg = $this->getConfig();
     $player = $event->getPlayer();
     $c4 = $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->floor()->subtract(0, 1));
     $e = new Explosion($player, $cfg->get("Explosion-Radius"));
     if ($c4->getId() === $cfg->get("C4-Block")) {
         if ($cfg->get("Remove-Terrain") == true) {
             $player->sendMessage(TextFormat::YELLOW . "[C-4]" . TextFormat::RED . " Booom!!");
             $e->explodeA();
             $e->explodeB();
         } else {
             $player->sendMessage(TextFormat::YELLOW . "[C-4]" . TextFormat::RED . " Booom!!");
             $e->explodeB();
         }
     }
 }
Exemplo n.º 3
0
 public function explode()
 {
     $this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4));
     if (!$ev->isCancelled()) {
         $explosion = new Explosion($this, $ev->getForce(), $this);
         if ($ev->isBlockBreaking()) {
             $explosion->explodeA();
         }
         $explosion->explodeB();
     }
 }
Exemplo n.º 4
0
 public function onRun($currentTick)
 {
     $explosion = new Explosion(new Position($this->entity->getX(), $this->entity->getY(), $this->entity->getZ(), $this->entity->getLevel()), $this->radius);
     if (!$this->entity->isAlive()) {
         return;
     }
     $this->entity->close();
     if ($explosion->explodeA()) {
         $explosion->explodeB();
     }
 }
 public function blowPlayer($pl, $yield, $magic)
 {
     $this->owner->getServer()->getPluginManager()->callEvent($cc = new ExplosionPrimeEvent($pl, $yield));
     if ($cc->isCancelled()) {
         return false;
     }
     $explosion = new Explosion($pl, $yield);
     if (!$magic) {
         $explosion->explodeA();
     }
     $explosion->explodeB();
     return true;
 }
 public function explodePlayer($player, $sender, $force)
 {
     $exploded = false;
     foreach ($this->getServer()->getOnlinePlayers() as $p) {
         if ($p->getName() === $player) {
             $sender->sendMessage("§f[§cEYF§f] §9" . $player . " §fwas blown up!");
             $p->sendMessage("§c" . $sender->getName() . " §fblew you up!");
             $position = $p->getPosition();
             $explosion = new Explosion($position, $force, $this);
             $explosion->explodeB();
             $exploded = true;
             break;
         }
     }
     if ($exploded === false) {
         $sender->sendMessage("§f[§cEYF§f] Could not find player §9" . $player);
     }
 }
Exemplo n.º 7
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "blowup") {
         return false;
     }
     if (count($args) == 0) {
         return false;
     }
     $pl = $this->owner->getServer()->getPlayer($args[0]);
     if (!$pl) {
         $sender->sendMessage(mc::_("%1% not found.", $args[0]));
         return true;
     }
     array_shift($args);
     $yield = 5;
     $magic = false;
     foreach ($args as $i) {
         if (is_numeric($i)) {
             $yield = intval($i);
             if ($yield < 1) {
                 $yield = 1;
             }
         } elseif (strtolower($i) == "magic") {
             $magic = true;
         } elseif (strtolower($i) == "normal") {
             $magic = false;
         }
     }
     $this->owner->getServer()->getPluginManager()->callEvent($cc = new ExplosionPrimeEvent($pl, $yield));
     if ($cc->isCancelled()) {
         return true;
     }
     $explosion = new Explosion($pl, $yield);
     if (!$magic) {
         $explosion->explodeA();
     }
     $explosion->explodeB();
     return true;
 }
Exemplo n.º 8
0
 public function onRun($currentTick)
 {
     if ($this->event->isCancelled()) {
         return;
     }
     $arrow = $this->event->getEntity();
     $murder = $this->event->getEntity()->shootingEntity;
     if (!$arrow instanceof Arrow) {
         return;
     }
     if (!$murder instanceof Player) {
         return;
     }
     $this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($arrow, 3.2));
     if (!$ev->isCancelled()) {
         $arrow->getLevel()->addParticle(new MobSpawnParticle($arrow, 2, 2));
         $explosion = new Explosion($arrow, $ev->getForce(), $murder);
         $explosion->explodeB();
     }
     $reflection_class = new \ReflectionClass($arrow);
     $property = $reflection_class->getProperty('age');
     $property->setAccessible(true);
     $property->setValue($arrow, 7000);
 }
Exemplo n.º 9
0
 public function akira($n, $pos, $magic, $yield)
 {
     $this->getServer()->broadcastMessage("AAAAKIIIIIRAAAAA!!!!!");
     $source = $this->getServer()->getPlayer($n);
     $this->getServer()->getPluginManager()->callEvent($cc = new ExplosionPrimeEvent($source, $yield));
     if ($cc->isCancelled()) {
         //echo("Cancelled\n");//##DEBUG
         return;
     }
     $explosion = new Explosion($pos, $yield);
     if (!$magic) {
         $explosion->explodeA();
     }
     $explosion->explodeB();
 }
Exemplo n.º 10
0
 public function blockBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     if ($block->getId() === $this->data["lucky_block"] && $this->isAllowedWorld($block->getLevel())) {
         $player = $event->getPlayer();
         if (!$player->hasPermission("luckyblock.use")) {
             $player->sendMessage($this->tag . $this->message->get("not_allowed"));
             return;
         }
         $event->setCancelled();
         $player->getLevel()->setBlock($block, new Block(Block::AIR), false, true);
         $rand = new Random();
         switch ($rand->nextRange(1, 12)) {
             case 1:
                 if (!isset($this->data["functions"]["spawnTree"]) || $this->data["functions"]["spawnTree"]) {
                     $type = Sapling::OAK;
                     switch ($rand->nextRange(0, 3)) {
                         case 1:
                             $type = Sapling::BIRCH;
                             break;
                         case 2:
                             $type = Sapling::SPRUCE;
                             break;
                         case 3:
                             $type = Sapling::JUNGLE;
                             break;
                     }
                     if ($player->getLevel()->setBlock($block, new Sapling($type), true, true)) {
                         $player->getLevel()->getBlock($block)->onActivate(new Item(Item::DYE, 15), $player);
                         $player->sendMessage($this->tag . $this->message->get("tree"));
                     }
                     break;
                 }
             case 2:
                 if (!isset($this->data["functions"]["explosion"]) || $this->data["functions"]["explosion"]) {
                     $explosion = new Explosion($block, mt_rand($this->data["explosion_min"], $this->data["explosion_max"]));
                     if ($explosion->explodeA()) {
                         $explosion->explodeB();
                     }
                     $player->sendMessage($this->tag . $this->message->get("explosion"));
                     break;
                 }
             case 3:
                 if (!isset($this->data["functions"]["dropItem"]) || $this->data["functions"]["dropItem"]) {
                     if (mt_rand(0, 1)) {
                         if ($this->itemLoop($player, $block)) {
                             break;
                         }
                     }
                     if (count($this->data["items_dropped"]) === 0) {
                         $item = $this->randItem();
                     } else {
                         $item = $this->data["items_dropped"][mt_rand(0, count($this->data["items_dropped"]) - 1)];
                     }
                     $player->getLevel()->dropItem($block, $item);
                     $player->sendMessage($this->tag . $this->message->get("drop"));
                     break;
                 }
             case 4:
                 if (!isset($this->data["functions"]["bedrock"]) || $this->data["functions"]["bedrock"]) {
                     $player->getLevel()->setBlock($block, new Block(Block::BEDROCK));
                     $p = new Position($block->x, $block->y + 1, $block->z, $block->level);
                     if ($player->getLevel()->getBlock($p)->getId() != Block::AIR) {
                         break;
                     }
                     $block->getLevel()->setBlock($p, Block::get(Item::SIGN_POST));
                     $sign = new Sign($player->getLevel()->getChunk($block->x >> 4, $block->z >> 4), new CompoundTag(false, array(new IntTag("x", (int) $block->x), new IntTag("y", (int) $block->y + 1), new IntTag("z", (int) $block->z), new StringTag("Text1", $this->tag), new StringTag("Text2", $this->message->get("signText")))));
                     $sign->spawnToAll();
                     $player->sendMessage($this->tag . $this->message->get("sign"));
                     break;
                 }
             case 5:
                 if (!isset($this->data["functions"]["prison"]) || $this->data["functions"]["prison"]) {
                     $pos = $event->getPlayer();
                     $pos->x = round($pos->x) + 0.5;
                     $pos->y = round($pos->y);
                     $pos->z = round($pos->z) + 0.5;
                     $player->teleport($pos, $player->getYaw(), $player->getPitch());
                     $arr = [];
                     switch ($rand->nextRange(1, 5)) {
                         case 1:
                             $player->getLevel()->setBlock(new Position($pos->x, $pos->y - 1, $pos->z, $pos->getLevel()), new Block(Block::OBSIDIAN));
                             for ($x = $pos->x - 1; $x <= $pos->x + 1; $x++) {
                                 for ($z = $pos->z - 1; $z <= $pos->z + 1; $z++) {
                                     if (!($x === $pos->x && $z === $pos->z)) {
                                         for ($y = $pos->y; $y <= $pos->y + 2; $y++) {
                                             $player->getLevel()->setBlock(new Position($x, $y, $z, $pos->getLevel()), new Block(Block::OBSIDIAN));
                                         }
                                     }
                                 }
                             }
                             $player->getLevel()->updateAround($pos);
                             $player->sendMessage($this->tag . $this->message->get("prison"));
                             break;
                         case 2:
                             $player->getLevel()->setBlock(new Position($pos->x, $pos->y - 1, $pos->z, $pos->getLevel()), new Block(Block::STILL_LAVA));
                             $player->getLevel()->setBlock(new Position($pos->x, $pos->y - 2, $pos->z, $pos->getLevel()), new Block(Block::GLASS));
                             for ($x = $pos->x - 1; $x <= $pos->x + 1; $x++) {
                                 for ($z = $pos->z - 1; $z <= $pos->z + 1; $z++) {
                                     if (!($x === $pos->x && $z === $pos->z)) {
                                         for ($y = $pos->y; $y <= $pos->y + 2; $y++) {
                                             $player->getLevel()->setBlock(new Position($x, $y, $z, $pos->getLevel()), new Block(Block::IRON_BAR));
                                         }
                                     }
                                 }
                             }
                             $player->getLevel()->updateAround($pos);
                             $player->sendMessage($this->tag . $this->message->get("prison"));
                             break;
                         case 3:
                             $player->getLevel()->setBlock(new Position($pos->x, $pos->y - 1, $pos->z, $pos->getLevel()), new Block(Block::SANDSTONE));
                             for ($x = $pos->x - 1; $x <= $pos->x + 1; $x++) {
                                 for ($z = $pos->z - 1; $z <= $pos->z + 1; $z++) {
                                     if (!($x === $pos->x && $z === $pos->z)) {
                                         for ($y = $pos->y; $y <= $pos->y + 2; $y++) {
                                             $player->getLevel()->setBlock(new Position($x, $y, $z, $pos->getLevel()), new Block(Block::IRON_BAR));
                                         }
                                     }
                                 }
                             }
                             break;
                         case 4:
                             $arr = [["x" => -1, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 0, "z" => 0, "block" => Block::STILL_WATER], ["x" => 0, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 1, "z" => 0, "block" => Block::GLASS], ["x" => -1, "y" => 1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 1, "z" => -1, "block" => Block::GLASS], ["x" => 0, "y" => 1, "z" => 0, "block" => Block::STILL_WATER], ["x" => 0, "y" => 1, "z" => 1, "block" => Block::GLASS], ["x" => 1, "y" => 1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 1, "z" => 0, "block" => Block::GLASS], ["x" => 1, "y" => 1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN]];
                             break;
                         case 5:
                             $arr = [["x" => -1, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => -1, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => -1, "y" => 1, "z" => 1, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => 1, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => 1, "block" => Block::COBWEB]];
                             break;
                     }
                     $pos = $player->getPosition();
                     foreach ($arr as $i => $c) {
                         $player->getLevel()->setBlock($pos->add($c["x"], $c["y"], $c["z"]), Block::get($c["block"]), true, true);
                     }
                     break;
                 }
             case 6:
                 if (!isset($this->data["functions"]["chest"]) || $this->data["functions"]["chest"]) {
                     $player->getLevel()->setBlock($block, new Block(Block::CHEST), true, true);
                     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z)]);
                     $nbt->Items->setTagType(NBT::TAG_Compound);
                     $tile = Tile::createTile("Chest", $block->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
                     if ($tile instanceof Chest) {
                         for ($i = 0; $i <= mt_rand(1, $this->data["max_chest_item"]); $i++) {
                             if (count($this->data["items_dropped"]) === 0) {
                                 $item = $this->randItem();
                             } else {
                                 $item = $this->data["items_dropped"][mt_rand(0, count($this->data["items_dropped"]) - 1)];
                             }
                             $tile->getInventory()->setItem($i, $item);
                         }
                         $player->sendMessage($this->tag . $this->message->get("chest"));
                     }
                     break;
                 }
             case 7:
                 if (!isset($this->data["functions"]["teleport"]) || $this->data["functions"]["teleport"]) {
                     $player->teleport($player->getLevel()->getSpawnLocation(), $player->getYaw(), $player->getPitch());
                     $player->sendMessage($this->tag . $this->message->get("spawn"));
                     break;
                 }
             case 8:
                 if (!isset($this->data["functions"]["potion"]) || $this->data["functions"]["potion"]) {
                     if (count($this->data["potions"])) {
                         $effect = Effect::getEffectByName($this->data["potions"][$rand->nextRange(0, count($this->data["potions"]) - 1)]);
                         $effect->setDuration($rand->nextRange(20, $this->data["max_duration"] * 20));
                         $player->addEffect($effect);
                         $player->sendMessage($this->tag . $this->message->get("effect"));
                     } else {
                         $player->sendMessage($this->tag . $this->message->get("unlucky"));
                     }
                     break;
                 }
             case 9:
                 //exec command
                 if (!isset($this->data["functions"]["execCmd"]) || $this->data["functions"]["execCmd"]) {
                     if (count($this->data["commands"])) {
                         $cmd = $this->data["commands"][$rand->nextRange(0, count($this->data["commands"]) - 1)];
                         $cmd = str_replace(["%PLAYER%", "%X%", "%Y%", "%Z%", "%WORLD%", "%IP%", "%XP%"], [$player->getName(), $player->getX(), $player->getY(), $player->getZ(), $player->getLevel()->getName(), $player->getAddress(), $player->getXpLevel()], $cmd);
                         $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $cmd);
                         $player->sendMessage($this->tag . $this->message->get("command"));
                         break;
                     }
                 }
             case 10:
                 //mob
                 if (!isset($this->data["functions"]["mob"]) || $this->data["functions"]["mob"]) {
                     if (count($this->data["mob"])) {
                         $mob = $this->data["mob"][$rand->nextRange(0, count($this->data["mob"]) - 1)];
                         if ($this->isExistsEntity($mob)) {
                             $nbt = new CompoundTag("", [new ListTag("Pos", [new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ())]), new ListTag("Rotation", [new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch())]), new StringTag("CustomName", $this->tag)]);
                             $entity = Entity::createEntity($mob, $player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
                             if ($entity instanceof Entity) {
                                 $entity->spawnToAll();
                                 $this->getServer()->getScheduler()->scheduleDelayedTask(new TaskExplodeMob($this, $entity, mt_rand($this->data["explosion_min"], $this->data["explosion_max"])), 20 * mt_rand(1, $this->data["mob_explosion_delay"]));
                                 $player->sendMessage($this->tag . $this->message->get("mob"));
                                 break;
                             }
                         }
                     }
                 }
             case 11:
                 if (!isset($this->data["functions"]["lightning"]) || $this->data["functions"]["lightning"]) {
                     $player->getLevel()->spawnLightning($player);
                     $player->sendMessage($this->tag . $this->message->get("lightning"));
                     break;
                 }
             case 12:
                 $player->sendMessage($this->tag . $this->message->get("unlucky"));
                 break;
         }
         $player->getLevel()->save();
     }
 }
Exemplo n.º 11
0
 public function removeArrow(Event $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $arrow = $event->getEntity();
     $murder = $event->getEntity()->shootingEntity;
     $this->getServer()->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($arrow, 3.2));
     if (!$ev->isCancelled()) {
         $explosion = new Explosion($arrow, $ev->getForce(), $murder);
         $explosion->explodeB();
     }
     $reflection_class = new \ReflectionClass($arrow);
     $property = $reflection_class->getProperty('age');
     $property->setAccessible(true);
     $property->setValue($arrow, 7000);
 }
Exemplo n.º 12
0
 /**
  * 高密集型发包计时器
  * - 发送数据包
  * - 计算自由落体相关数据
  * 循环间隔:1 tick
  */
 public function CreeperRandomWalk()
 {
     foreach ($this->AIHolder->getServer()->getLevels() as $level) {
         foreach ($level->getEntities() as $zo) {
             if ($zo instanceof Creeper) {
                 if (isset($this->AIHolder->Creeper[$zo->getId()])) {
                     $zom =& $this->AIHolder->Creeper[$zo->getId()];
                     if ($zom['canAttack'] != 0) {
                         $zom['canAttack'] -= 1;
                     }
                     $pos = $zo->getLocation();
                     //echo ($zom['IsChasing']."\n");
                     if ($zom['boom'] == false) {
                         //真正的自由落体 by boybook
                         if ($zom['drop'] !== false) {
                             $olddrop = $zom['drop'];
                             $zom['drop'] += 0.5;
                             $drop = $zom['drop'];
                             //echo $drop."\n";
                             $dropy = $zo->getY() - ($olddrop * 0.05 + 0.0125);
                             $posd0 = new Vector3(floor($zo->getX()), floor($dropy), floor($zo->getZ()));
                             $posd = new Vector3($zo->getX(), $dropy, $zo->getZ());
                             if ($this->AIHolder->whatBlock($zo->getLevel(), $posd0) == "air") {
                                 $zo->setPosition($posd->add(0, 1, 0));
                                 //下降
                             } else {
                                 for ($i = 1; $i <= $drop; $i++) {
                                     $posd0->y++;
                                     if ($this->AIHolder->whatBlock($zo->getLevel(), $posd0) != "block") {
                                         $posd->y = $posd0->y;
                                         //$zo->setPosition($posd);  //下降完成
                                         $h = $zom['drop'] * $zom['drop'] / 20;
                                         $damage = $h - 3;
                                         //echo($h . ": " . $damage . "\n");
                                         if ($damage > 0) {
                                             $zo->setHealth($zo->getHealth() - $damage);
                                         }
                                         $zom['drop'] = false;
                                         break;
                                     }
                                 }
                             }
                         } else {
                             $drop = 0;
                         }
                         if ($zom['IsChasing'] !== false) {
                             //var_dump($zom['IsChasing']);
                             if (!$zom['knockBack']) {
                                 //echo $zy;
                                 $zom['up'] = 0;
                                 if ($this->AIHolder->whatBlock($level, $pos) == "water") {
                                     $zom['swim'] += 1;
                                     if ($zom['swim'] >= 20) {
                                         $zom['swim'] = 0;
                                     }
                                 } else {
                                     $zom['swim'] = 0;
                                 }
                                 //echo("目标:".$zo->getY()." ");
                                 //echo("原先:".$zom['oldv3']->y."\n");
                                 if (abs($zo->getY() - $zom['oldv3']->y) == 1 and $zom['canjump'] === true) {
                                     //var_dump("跳");
                                     $zom['canjump'] = false;
                                     $zom['jump'] = 0.5;
                                 } else {
                                     if ($zom['jump'] > 0.01) {
                                         $zom['jump'] -= 0.1;
                                     } else {
                                         $zom['jump'] = 0.01;
                                     }
                                 }
                                 $pk3 = new SetEntityMotionPacket();
                                 $pk3->entities = [[$zo->getID(), $zom['xxx'] / 10, -$zom['swim'] / 100 + $zom['jump'] - $drop, $zom['zzz'] / 10]];
                                 foreach ($zo->getViewers() as $pl) {
                                     $pl->dataPacket($pk3);
                                 }
                                 $p = $this->AIHolder->getServer()->getPlayer($zom['IsChasing']);
                                 if ($p instanceof Player) {
                                     if ($p->distance($pos) <= 1.3) {
                                         //苦力怕的火焰点燃人类
                                         // if ($zo->fireTicks > 0) {
                                         //   $p->setOnFire(5);
                                         // }
                                     }
                                     if ($p->distance($pos) <= 2) {
                                         //boom
                                         $zom['boom'] = 5;
                                     }
                                     if ($p->distance($pos) <= 1.5) {
                                         if ($zom['canAttack'] == 0) {
                                             $zom['canAttack'] = 20;
                                             @$p->knockBack($zo, 0, $zom['xxx'] / 10, $zom['zzz'] / 10);
                                             if ($p->isSurvival()) {
                                                 $damage = 0;
                                                 //echo $zoDamage."-".$damage."\n";
                                                 //$p->attack($damage);
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             //echo ".";
                             $pk3 = new SetEntityMotionPacket();
                             $pk3->entities = [[$zo->getID(), $zom['motionx'] / 10, 0, $zom['motionz'] / 10]];
                             foreach ($zo->getViewers() as $pl) {
                                 $pl->dataPacket($pk3);
                             }
                         }
                     } else {
                         $zom['boom'] = $zom['boom'] - 1;
                         if ($zom['boom'] <= 0) {
                             unset($this->AIHolder->Creeper[$zo->getId()]);
                             $level->getEntity($zo->getId())->close();
                             $e = new Explosion(new Position($zo->getX(), $zo->getY(), $zo->getZ(), $level), 4);
                             if ($this->AIHolder->getServer()->aiConfig["creeperexplode"]) {
                                 $e->explode();
                             } else {
                                 $e->explodeB();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
 public static function makeExplosion(Level $level, Position $pos)
 {
     $explosion = new Explosion($pos, 1);
     $explosion->explodeB();
     self::addParticles($level, "driplava", $pos, 80);
 }
Exemplo n.º 14
0
 public function SoldierGame(Entity $entity)
 {
     if ($this->checkEnableSoldierGame() and $entity->shootingEntity instanceof Player) {
         $this->getServer()->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($entity, 2.5));
         if (!$ev->isCancelled()) {
             $explosion = new Explosion($entity, $ev->getForce(), $entity->shootingEntity);
             $explosion->explodeB();
         }
     }
 }