public Collection<ItemStack> getDrops() { List<ItemStack> drops = new ArrayList<ItemStack>(); net.minecraft.server.Block block = this.getNMSBlock(); if (block != Blocks.AIR) { byte data = getData(); // based on nms.Block.dropNaturally int count = block.getDropCount(0, chunk.getHandle().world.random); for (int i = 0; i < count; ++i) { Item item = block.getDropType(data, chunk.getHandle().world.random, 0); if (item != null) { // Skulls are special, their data is based on the tile entity if (Blocks.SKULL == block) { 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.getGameProfile() != null) { nmsStack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); nmsStack.getTag().set("SkullOwner", nbttagcompound); } drops.add(CraftItemStack.asBukkitCopy(nmsStack)); // We don't want to drop cocoa blocks, we want to drop cocoa beans. } else if (Blocks.COCOA == block) { int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1); for (int j = 0; j < dropAmount; ++j) { drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3)); } } else { drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data))); } } } } return drops; }
@Override void applyToItem(NBTTagCompound tag) { super.applyToItem(tag); if (hasOwner()) { NBTTagCompound owner = new NBTTagCompound(); GameProfileSerializer.serialize(owner, profile); tag.set(SKULL_OWNER.NBT, owner); } }
CraftMetaSkull(NBTTagCompound tag) { super(tag); if (tag.hasKeyOfType(SKULL_OWNER.NBT, 10)) { profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_OWNER.NBT)); } else if (tag.hasKeyOfType(SKULL_OWNER.NBT, 8) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { profile = new GameProfile(null, tag.getString(SKULL_OWNER.NBT)); } }
@Override void serializeInternal(final Map<String, NBTBase> internalTags) { if (profile != null) { NBTTagCompound nbtData = new NBTTagCompound(); GameProfileSerializer.serialize(nbtData, profile); internalTags.put(SKULL_PROFILE.NBT, nbtData); } }
@Override void deserializeInternal(NBTTagCompound tag) { if (tag.hasKeyOfType(SKULL_PROFILE.NBT, 10)) { profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT)); } }