diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-08 00:23:06 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-08 00:31:21 +1100 |
commit | b08b85bd265f6b3e540409d4ab955a413942ae87 (patch) | |
tree | 8060a215a3a02544638208652db25986f057c6a2 /src/main/java/org/bukkit | |
parent | 4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a (diff) | |
download | craftbukkit-b08b85bd265f6b3e540409d4ab955a413942ae87.tar craftbukkit-b08b85bd265f6b3e540409d4ab955a413942ae87.tar.gz craftbukkit-b08b85bd265f6b3e540409d4ab955a413942ae87.tar.lz craftbukkit-b08b85bd265f6b3e540409d4ab955a413942ae87.tar.xz craftbukkit-b08b85bd265f6b3e540409d4ab955a413942ae87.zip |
Teach EnderDragon how to throw EntityExplosionEvents when it breaks blocks
We also teach CraftWorld how to explode an event, taken from
Explosion.a(boolean) (the code that breaks blocks and drops them on the ground).
The EnderDragon has a flag that slows it down when it hits unbreakable blocks:
Obsidian, White Stone or Bedrock. It might be useful to extend the event so that
plugins can set this.
Letting the API set the default yield for an explosion event has been
deprecated, so we now set the default yield using the appropriate constructor.
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0740b302..334930f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -895,4 +895,21 @@ public class CraftWorld implements World { public File getWorldFolder() { return ((WorldNBTStorage)world.getDataManager()).getDirectory(); } + + public void explodeBlock(Block block, float yield) { + // First of all, don't explode fire + if (block.getType().equals(Material.FIRE)) { + return; + } + int blockId = block.getTypeId(); + int blockX = block.getX(); + int blockY = block.getY(); + int blockZ = block.getZ(); + // following code is lifted from Explosion.a(boolean), and modified + net.minecraft.server.Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), yield, 0); + block.setType(org.bukkit.Material.AIR); + // not sure what this does, seems to have something to do with the 'base' material of a block. + // For example, WOODEN_STAIRS does something with WOOD in this method + net.minecraft.server.Block.byId[blockId].a_(this.world, blockX, blockY, blockZ); + } } |