Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
- public void onEntityExplode(EntityExplodeEvent e){
- for(Block b : e.blockList()){
- if(b.getType().equals(Material.REDSTONE)
- || b.getType().equals(Material.REDSTONE_COMPARATOR)
- || b.getType().equals(Material.REDSTONE_COMPARATOR_OFF)
- || b.getType().equals(Material.REDSTONE_COMPARATOR_ON)
- || b.getType().equals(Material.REDSTONE_TORCH_OFF)
- || b.getType().equals(Material.REDSTONE_TORCH_ON)
- || b.getType().equals(Material.REDSTONE_WIRE)
- || b.getType().equals(Material.DIODE)
- || b.getType().equals(Material.DIODE_BLOCK_OFF)
- || b.getType().equals(Material.DIODE_BLOCK_ON)
- || b.getType().equals(Material.FIRE)
- || b.getType().equals(Material.LEAVES)){
- b.breakNaturally();
- }
- if(b.getType().equals(Material.TNT)){
- b.setType(Material.AIR);
- b.getLocation().getWorld().spawnEntity(b.getLocation(), EntityType.PRIMED_TNT);
- }
- else{
- bounceBlock(b);
- }
- }
- }
- @SuppressWarnings("deprecation")
- public void bounceBlock(Block b){
- if(b == null) return;
- FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
- b.setType(Material.AIR);
- fb.setDropItem(false);
- float x = (float)0;
- float y = 1;
- float z = (float)0;
- fb.setVelocity(new Vector(x, y, z));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement