ExplosionPhysics
When a TNT block or other explosive goes off, it will turn all blocks into falling blocks, and then shoot them off with a vector away from the source explosion. All drops are cancelled. Have fun!
All it does, is convert the blocks that n explosion would normally destroy into FallingBlock entities. It then shoots those entities off in different directions. Also it will not run the method if the event is cancelled (in the case of worldguard cancelling explosive block damage)

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package explosionphysics; import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.FallingBlock; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; /** * * @author Taylor */ public class ExplosionPhysics extends JavaPlugin implements Listener{ public ArrayList<Material> disallowedBlocks = new ArrayList<Material>(); @Override public void onEnable(){ getServer().getPluginManager().registerEvents(new ExplosionPhysics(), this); disallowedBlocks.clear(); disallowedBlocks.add(Material.TNT); disallowedBlocks.add(Material.PISTON_BASE); disallowedBlocks.add(Material.PISTON_EXTENSION); disallowedBlocks.add(Material.PISTON_MOVING_PIECE); disallowedBlocks.add(Material.PISTON_STICKY_BASE); } @EventHandler(priority = EventPriority.NORMAL) public void onBlockExplode(org.bukkit.event.entity.EntityExplodeEvent e){ if (e.isCancelled()){return;} if (e.blockList().isEmpty()){return;} e.setYield(0F); double x = 0; double y = 0; double z = 0; Location eLoc = e.getLocation(); World w = eLoc.getWorld(); for (int i = 0; i < e.blockList().size();i++){ Block b = e.blockList().get(i); Location bLoc =b.getLocation(); if (disallowedBlocks.contains(b.getType())){continue;} x = bLoc.getX() - eLoc.getX(); y = bLoc.getY() - eLoc.getY() + .5; z = bLoc.getZ() - eLoc.getZ(); FallingBlock fb = w.spawnFallingBlock(bLoc, b.getType(), (byte)b.getData()); fb.setDropItem(false); fb.setVelocity(new Vector(x,y,z)); } } }
-
View User Profile
-
Send Message
Posted Oct 14, 2012@Chemical_Datas
I'm kind of busy with my other plugin right now... http://dev.bukkit.org/server-mods/supermobs/ But I've posted the code if anyone wants to make a duplication or a better version.
-
View User Profile
-
Send Message
Posted Oct 14, 2012OH yeah, good idea. Could you also add weights to the blocks so they dont go flying everywhere?
-
View User Profile
-
Send Message
Posted Oct 14, 2012@fazaro
yes... you know I could probably just fix this by having a configurable list of blocks this thing won't affect. Should I do it?
-
View User Profile
-
Send Message
Posted Oct 14, 2012it drop water blocks too?
-
View User Profile
-
Send Message
Posted Oct 14, 2012@minstrel271
fixed. http://dev.bukkit.org/server-mods/explosionphysics/files/2-1-0-1/
-
View User Profile
-
Send Message
Posted Oct 14, 2012Destorying a extended piston with TNT result in duplication of a piston
-
View User Profile
-
Send Message
Posted Oct 11, 2012@cadika_orade
IT could, but you need to tell me why you want those features first. Right now it's a very simple one/two method plugin.
-
View User Profile
-
Send Message
Posted Oct 11, 2012@minstrel271
yes
-
View User Profile
-
Send Message
Posted Oct 11, 2012Could it be configurable to break a percentage of blocks and throw the rest? Perhaps configurable mass for specific blocks, to make lighter blocks fly farther than heavier blocks? Also, configurable drop-cancellation rate on broken blocks, if possible.
With those options, my server could make great use of this! :D
-
View User Profile
-
Send Message
Posted Oct 10, 2012Will it work with creeper explosion too?
-
View User Profile
-
Send Message
Posted Oct 9, 2012@Pangamma
Still not approved? Screw it! I'm moving on to rocket science in minecraft. blaarrghhhh *flails arms in the air*
-
View User Profile
-
Send Message
Posted Oct 8, 2012Also, it respects regions and worldguard protections.