Minecraft / Mods

Explosion Physics

  • 7
  • 1
  • playlist_add
  • share
  • more_horiz
avatar Pangamma2
Level 54 : Grandmaster Pixel Painter
195
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 disallowedBlocks = new ArrayList();
@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));
}

}
}

<>
Progress100% complete
Game VersionMinecraft 1.4.7
Tags

Comments : 4

star Login or register to post a comment.

Show Comments

1 - 4 of 4

  • XemPhill
  • Level 1
  • New Miner
  • September 6, 2013, 7:31 pm
Uppppdaaateee!!!!
  • Pangamma2
  • Level 54
  • Grandmaster Pixel Painter
  • September 7, 2013, 11:37 am
lol. It doesn't need an update. It doesn't rely on craftbukkit code and will therefore never break.
  • duke_Frans
  • Level 64
  • High Grandmaster Modder
  • March 2, 2013, 11:09 am
Awesome, diamond and sub
  • Pangamma2
  • Level 54
  • Grandmaster Pixel Painter
  • March 3, 2013, 6:47 am
Thank you!

1 - 4 of 4

Show Comments

Search

Browse

Site

© 2010 - 2018
planetminecraft.com

Welcome