summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-10-29 12:38:34 -0500
committerTravis Watkins <amaranth@ubuntu.com>2012-10-29 12:54:16 -0500
commit216cddb2ab1473c642c40b9f09b612fa0877a13b (patch)
tree0ff5ab825a04bdf550c9bc8ae8699299ffde1c07
parent14f4bd9024cfdeb3a7d04c1ce3e688e38038722d (diff)
downloadcraftbukkit-216cddb2ab1473c642c40b9f09b612fa0877a13b.tar
craftbukkit-216cddb2ab1473c642c40b9f09b612fa0877a13b.tar.gz
craftbukkit-216cddb2ab1473c642c40b9f09b612fa0877a13b.tar.lz
craftbukkit-216cddb2ab1473c642c40b9f09b612fa0877a13b.tar.xz
craftbukkit-216cddb2ab1473c642c40b9f09b612fa0877a13b.zip
Get skull data before destroying block. Fixes BUKKIT-2723
Skull blocks store their type in a tile entity and use their block data as rotation. When breaking a block the block data is used for determining what item to drop. Simply changing this to use the skull method for getting their drop data is not enough because their tile entity is already gone. Therefore we have to special case skulls to get the correct data _and_ get that data before breaking the block.
-rw-r--r--src/main/java/net/minecraft/server/Explosion.java10
-rw-r--r--src/main/java/net/minecraft/server/ItemInWorldManager.java5
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java13
4 files changed, 28 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index fb30dc10..cf2108c6 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -264,8 +264,14 @@ public class Explosion {
// CraftBukkit - stop explosions from putting out fire
if (l > 0 && l != Block.FIRE.id) {
- // CraftBukkit
- Block.byId[l].dropNaturally(this.world, i, j, k, this.world.getData(i, j, k), event.getYield(), 0);
+ // CraftBukkit start - special case skulls, add yield
+ int data = this.world.getData(i, j, k);
+ if (l == Block.SKULL.id) {
+ data = Block.SKULL.getDropData(this.world, i, j, k);
+ }
+
+ Block.byId[l].dropNaturally(this.world, i, j, k, data, event.getYield(), 0);
+ // CraftBukkit end
if (this.world.setRawTypeIdAndData(i, j, k, 0, 0, this.world.isStatic)) {
this.world.applyPhysics(i, j, k, 0);
}
diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java
index cb13808f..025c25a7 100644
--- a/src/main/java/net/minecraft/server/ItemInWorldManager.java
+++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java
@@ -291,6 +291,11 @@ public class ItemInWorldManager {
int l = this.world.getTypeId(i, j, k);
if (Block.byId[l] == null) return false; // CraftBukkit - a plugin set block to air without cancelling
int i1 = this.world.getData(i, j, k);
+ // CraftBukkit start - special case skulls, their item data comes from a tile entity
+ if (l == Block.SKULL.id) {
+ i1 = Block.SKULL.getDropData(world, i, j, k);
+ }
+ // CraftBukkit end
this.world.a(this.player, 2001, i, j, k, l + (this.world.getData(i, j, k) << 12));
boolean flag = this.d(i, j, k);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 277c3b3d..2ca3078d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1083,7 +1083,11 @@ public class CraftWorld implements World {
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);
+ int data = block.getData();
+ if (blockId == net.minecraft.server.Block.SKULL.id) {
+ data = net.minecraft.server.Block.SKULL.getDropData(this.world, blockX, blockY, blockZ);
+ }
+ net.minecraft.server.Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, data, 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
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index c5c11fdd..b1eb4fc6 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -342,15 +342,22 @@ public class CraftBlock implements Block {
}
public boolean breakNaturally() {
+ // Order matters here, need to drop before setting to air so skulls can get their data
net.minecraft.server.Block block = net.minecraft.server.Block.byId[this.getTypeId()];
byte data = getData();
+ boolean result = false;
- setTypeId(Material.AIR.getId());
if (block != null) {
+ if (block.id == net.minecraft.server.Block.SKULL.id) {
+ data = (byte) block.getDropData(chunk.getHandle().world, x, y, z);
+ }
+
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
- return true;
+ result = true;
}
- return false;
+
+ setTypeId(Material.AIR.getId());
+ return result;
}
public boolean breakNaturally(ItemStack item) {