make cannons explode chest items

This commit is contained in:
Ben 2016-03-15 00:20:40 +00:00
parent e08ba29ac1
commit 864b12adbf

View File

@ -9,9 +9,11 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilBlock;
@ -143,6 +145,8 @@ public class Crater implements Listener
boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d);
if (block.getState() instanceof Chest) continue;
if (block.getType() == Material.AIR) continue;
if (air)
@ -183,6 +187,26 @@ public class Crater implements Listener
if (block.getType() == Material.AIR) continue;
if (block.getState() instanceof Chest)
{
Chest chest = (Chest) block.getState();
for (ItemStack item : chest.getBlockInventory().getContents())
{
if (item == null)
{
continue;
}
if (item.getType() == Material.AIR)
{
continue;
}
_origin.getWorld().dropItemNaturally(_origin, item);
}
}
if (
distance > _airChance &&
Math.random() > .75 &&