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.
This commit is contained in:
Travis Watkins
2012-10-29 12:38:34 -05:00
parent 14f4bd9024
commit 216cddb2ab
4 changed files with 30 additions and 8 deletions

View File

@@ -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;
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);
result = true;
}
setTypeId(Material.AIR.getId());
if (block != null) {
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
return true;
}
return false;
return result;
}
public boolean breakNaturally(ItemStack item) {