Advertisement
Lilret123

Explosion with effect

Feb 26th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
  2.     public void onEntityExplode(EntityExplodeEvent e){
  3.         for(Block b : e.blockList()){
  4.             if(b.getType().equals(Material.REDSTONE)
  5.                     || b.getType().equals(Material.REDSTONE_COMPARATOR)
  6.                     || b.getType().equals(Material.REDSTONE_COMPARATOR_OFF)
  7.                     || b.getType().equals(Material.REDSTONE_COMPARATOR_ON)
  8.                     || b.getType().equals(Material.REDSTONE_TORCH_OFF)
  9.                     || b.getType().equals(Material.REDSTONE_TORCH_ON)
  10.                     || b.getType().equals(Material.REDSTONE_WIRE)
  11.                     || b.getType().equals(Material.DIODE)
  12.                     || b.getType().equals(Material.DIODE_BLOCK_OFF)
  13.                     || b.getType().equals(Material.DIODE_BLOCK_ON)
  14.                     || b.getType().equals(Material.FIRE)
  15.                     || b.getType().equals(Material.LEAVES)){
  16.                 b.breakNaturally();
  17.             }
  18.             if(b.getType().equals(Material.TNT)){
  19.                 b.setType(Material.AIR);
  20.                 b.getLocation().getWorld().spawnEntity(b.getLocation(), EntityType.PRIMED_TNT);
  21.  
  22.             }
  23.             else{
  24.                 bounceBlock(b);
  25.  
  26.             }
  27.         }
  28.  
  29.     }
  30.  
  31.     @SuppressWarnings("deprecation")
  32.     public void bounceBlock(Block b){
  33.         if(b == null) return;
  34.  
  35.         FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
  36.         b.setType(Material.AIR);
  37.         fb.setDropItem(false);
  38.  
  39.         float x = (float)0;
  40.         float y = 1;
  41.         float z = (float)0;
  42.  
  43.         fb.setVelocity(new Vector(x, y, z));
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement