Exemplo n.º 1
0
  public boolean explodeWithEvent() {
    if (power < 0.1f) return true;

    Set<BlockVector> droppedBlocks = calculateBlocks();

    EntityExplodeEvent event =
        EventFactory.callEvent(
            new EntityExplodeEvent(source, location, toBlockList(droppedBlocks), yield));
    if (event.isCancelled()) return false;

    this.yield = event.getYield();

    playOutSoundAndParticles();

    List<Block> blocks = toBlockList(droppedBlocks);

    for (Block block : blocks) {
      handleBlockExplosion((GlowBlock) block);
    }

    if (incendiary) {
      for (Block block : blocks) {
        setBlockOnFire((GlowBlock) block);
      }
    }

    Collection<GlowPlayer> affectedPlayers = damageEntities();
    for (GlowPlayer player : affectedPlayers) {
      playOutExplosion(player, droppedBlocks);
    }

    return true;
  }
Exemplo n.º 2
0
  private void setBlockOnFire(GlowBlock block) {
    if (random.nextInt(3) != 0) return;

    Block below = block.getRelative(BlockFace.DOWN);
    // TODO: check for flammable blocks
    Material belowType = below.getType();
    if (belowType == Material.AIR || belowType == Material.FIRE) return;

    BlockIgniteEvent event =
        EventFactory.callEvent(
            new BlockIgniteEvent(block, BlockIgniteEvent.IgniteCause.EXPLOSION, source));
    if (event.isCancelled()) return;

    block.setType(Material.FIRE);
  }