diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-12-20 15:06:01 -0600 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-12-20 15:06:01 -0600 |
commit | ca7f67da9d5989e51ebc29bfa6291d6a0cc82933 (patch) | |
tree | 1760bb9278c681da8c33aaf0085d095241903028 /src | |
parent | ed2dd31a80a429b1da1221a30b8acceff54ff951 (diff) | |
download | craftbukkit-ca7f67da9d5989e51ebc29bfa6291d6a0cc82933.tar craftbukkit-ca7f67da9d5989e51ebc29bfa6291d6a0cc82933.tar.gz craftbukkit-ca7f67da9d5989e51ebc29bfa6291d6a0cc82933.tar.lz craftbukkit-ca7f67da9d5989e51ebc29bfa6291d6a0cc82933.tar.xz craftbukkit-ca7f67da9d5989e51ebc29bfa6291d6a0cc82933.zip |
Fetch correct info for skulls in block.getDrops(). Fixes BUKKIT-3205
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 70e7df7e..63053ebc 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -3,10 +3,13 @@ package org.bukkit.craftbukkit.block; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; import net.minecraft.server.BiomeBase; import net.minecraft.server.BlockRedstoneWire; import net.minecraft.server.EnumSkyBlock; +import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.TileEntitySkull; import org.bukkit.Chunk; import org.bukkit.Location; @@ -18,13 +21,12 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.PistonMoveReaction; import org.bukkit.craftbukkit.CraftChunk; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.bukkit.util.BlockVector; -import java.util.List; - public class CraftBlock implements Block { private final CraftChunk chunk; private final int x; @@ -388,7 +390,20 @@ public class CraftBlock implements Block { for (int i = 0; i < count; ++i) { int item = block.getDropType(data, chunk.getHandle().world.random, 0); if (item > 0) { - drops.add(new ItemStack(item, 1, (short) block.getDropData(data))); + // Skulls are special, their data is based on the tile entity + if (net.minecraft.server.Block.SKULL.id == this.getTypeId()) { + net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z)); + TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z); + + if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) { + nmsStack.setTag(new NBTTagCompound()); + nmsStack.getTag().setString("SkullOwner", tileentityskull.getExtraType()); + } + + drops.add(CraftItemStack.asBukkitCopy(nmsStack)); + } else { + drops.add(new ItemStack(item, 1, (short) block.getDropData(data))); + } } } } |