Last active
August 29, 2015 14:07
-
-
Save keepoff07/d3dee893618c68e74454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventHandler | |
public void onEntityExplode(EntityExplodeEvent e){ | |
Entity entity = e.getEntity(); | |
if(entity instanceof TNTPrimed){ | |
List<Block> lb = e.blockList(); | |
Location loc = entity.getLocation(); | |
TNTExprotion(loc, lb); | |
return; | |
} | |
} | |
@SuppressWarnings("deprecation") | |
private void TNTExprotion(Location loc, List<Block> lb){ | |
Random r = new Random(); | |
for (Block block : lb){ | |
int i = r.nextInt(5); | |
if (i == 0){ | |
double x = r.nextInt(10) - 5; | |
double z = r.nextInt(10) - 5; | |
Location l = block.getLocation(); | |
Material mate = block.getType(); | |
byte data = block.getData(); | |
FallingBlock fb = loc.getWorld().spawnFallingBlock(l, mate, data); | |
fb.setDropItem(false); | |
fb.setVelocity(fb.getVelocity().add(loc.toVector().subtract(l.add(x, 5.0D, z).toVector()).normalize().multiply(-1.5D))); | |
} | |
} | |
} | |
@SuppressWarnings("deprecation") | |
@EventHandler | |
public void onEntityChangeBlock(EntityChangeBlockEvent e){ | |
if(e.getEntity() instanceof FallingBlock){ | |
FallingBlock fb = (FallingBlock)e.getEntity(); | |
Location location = fb.getLocation(); | |
World world = fb.getWorld(); | |
int blockid = fb.getBlockId(); | |
world.playEffect(location, Effect.STEP_SOUND, blockid); | |
e.setCancelled(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment