From df69ea8814a446502a0d096f542cbbb6879c80cd Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Wed, 14 Nov 2012 19:52:40 -0600 Subject: Rework skull dropping. Fixes BUKKIT-2930 and BUKKIT-2820 Skulls need their tile entity in order to create an item correctly when broken unlike every other block. Instead of sprinkling special cases all over the code just override dropNaturally for skulls to read from their tile entity and make sure everything that wants to drop them calls this method before removing the block. There is only one case where this wasn't already true so we end up with much less special casing. --- src/main/java/net/minecraft/server/BlockSkull.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/main/java/net/minecraft/server/BlockSkull.java') diff --git a/src/main/java/net/minecraft/server/BlockSkull.java b/src/main/java/net/minecraft/server/BlockSkull.java index 968bd941..d5fd3ad3 100644 --- a/src/main/java/net/minecraft/server/BlockSkull.java +++ b/src/main/java/net/minecraft/server/BlockSkull.java @@ -78,8 +78,21 @@ public class BlockSkull extends BlockContainer { return i; } - // CraftBukkit - drop the item like every other block - // public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {} + // CraftBukkit start - special case dropping so we can get info from the tile entity + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { + if (world.random.nextFloat() < f) { + ItemStack itemstack = new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k)); + TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); + + if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) { + itemstack.setTag(new NBTTagCompound()); + itemstack.getTag().setString("SkullOwner", tileentityskull.getExtraType()); + } + + this.b(world, i, j, k, itemstack); + } + } + // CraftBukkit end public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { if (entityhuman.abilities.canInstantlyBuild) { @@ -92,7 +105,7 @@ public class BlockSkull extends BlockContainer { public void remove(World world, int i, int j, int k, int l, int i1) { if (!world.isStatic) { - /* CraftBukkit start - don't special code dropping the item + /* CraftBukkit start - drop item in code above, not here if ((i1 & 8) == 0) { ItemStack itemstack = new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k)); TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); -- cgit v1.2.3