How do i make safe explosion?

Discussion in 'Spigot Plugin Development' started by userv2, May 27, 2017.

  1. title says all
     
  2. Do you mean explosion effects, not actual explosions?
    There's a World#spawnParticle method.
     
  3. Maybe let a TNT or something explode and cancel the blockbreakevent?
     
  4. With a TNT:
    Code (Text):
    @EventHandler
    public void onEntityExplode(EntityExplodeEvent event) {
        if (event.getEntity() instanceof TNTPrimed) {
            for (Block block : event.blockList())
                event.blockList().remove(block);
        }
    }
    Spawn a normal Explosion-Effect:
    Code (Text):
    player.getWorld().createExplosion(player.getLocation(), 0, false);
     
    • Agree Agree x 1
  5. Thank you! just what i needed