promotional bannermobile promotional banner

ExplosionPhysics

Explosions fling blocks away from the source.
<p>blocks land</p>

blocks land

<p>KABOOM! Look at those blocks fly!</p>

KABOOM! Look at those blocks fly!

<p>Cover it and get ready.</p>

Cover it and get ready.

<p>shows blocks being flung away from source. </p>

shows blocks being flung away from source.

<p>Next, cover it with tnt. </p>

Next, cover it with tnt.

<p>get something to blow up.</p>

get something to blow up.

Description

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) First, find something to blow up. Next, cover it in TnT. Cover it. get ready to blow it up! KABOOM! WATCH THOSE BLOCKS FLY! Aftermath

/*
 * 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));
		}
		
	}
}

The ExplosionPhysics Team

profile avatar
  • 6
    Projects
  • 56.4K
    Downloads

More from _ForgeUser6953472View all

  • FarPlacer project image

    FarPlacer

    • 977
    • Bukkit Plugins

    Place and remove blocks at a distance. Useful for building pixelart.

    • 977
    • July 8, 2017
    • Bukkit Plugins
  • LumenTech project image

    LumenTech

    • 1.6K
    • Bukkit Plugins

    Security, anti grief, admin tools, punishment, efficiency, debugging,dynamic motd, shortcuts

    • 1.6K
    • July 6, 2017
    • Bukkit Plugins
    • +2
  • GravityControl project image

    GravityControl

    • 7.2K
    • Bukkit Plugins

    Snowball based fly plugin. Also works with particle physics equations for better realism!

    • 7.2K
    • June 18, 2017
    • Bukkit Plugins
    • +2
  • SuperMobs project image

    SuperMobs

    • 27.0K
    • Bukkit Plugins

    Adds new mobs into game play without forcing users to install client mods.

    • 27.0K
    • February 17, 2014
    • Bukkit Plugins
  • FarPlacer project image

    FarPlacer

    • 977
    • Bukkit Plugins

    Place and remove blocks at a distance. Useful for building pixelart.

    • 977
    • July 8, 2017
    • Bukkit Plugins
  • LumenTech project image

    LumenTech

    • 1.6K
    • Bukkit Plugins

    Security, anti grief, admin tools, punishment, efficiency, debugging,dynamic motd, shortcuts

    • 1.6K
    • July 6, 2017
    • Bukkit Plugins
    • +2
  • GravityControl project image

    GravityControl

    • 7.2K
    • Bukkit Plugins

    Snowball based fly plugin. Also works with particle physics equations for better realism!

    • 7.2K
    • June 18, 2017
    • Bukkit Plugins
    • +2
  • SuperMobs project image

    SuperMobs

    • 27.0K
    • Bukkit Plugins

    Adds new mobs into game play without forcing users to install client mods.

    • 27.0K
    • February 17, 2014
    • Bukkit Plugins