    001package net.minecraft.tileentity;
    002
    003import net.minecraft.item.ItemStack;
    004import net.minecraft.nbt.NBTTagCompound;
    005
    006public class TileEntityRecordPlayer extends TileEntity
    007{
    008    /** ID of record which is in Jukebox */
    009    private ItemStack record;
    010
    011    /**
    012     * Reads a tile entity from NBT.
    013     */
    014    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    015    {
    016        super.readFromNBT(par1NBTTagCompound);
    017
    018        if (par1NBTTagCompound.hasKey("RecordItem"))
    019        {
    020            this.func_96098_a(ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("RecordItem")));
    021        }
    022        else if (par1NBTTagCompound.getInteger("Record") > 0)
    023        {
    024            this.func_96098_a(new ItemStack(par1NBTTagCompound.getInteger("Record"), 1, 0));
    025        }
    026    }
    027
    028    /**
    029     * Writes a tile entity to NBT.
    030     */
    031    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    032    {
    033        super.writeToNBT(par1NBTTagCompound);
    034
    035        if (this.func_96097_a() != null)
    036        {
    037            par1NBTTagCompound.setCompoundTag("RecordItem", this.func_96097_a().writeToNBT(new NBTTagCompound()));
    038            par1NBTTagCompound.setInteger("Record", this.func_96097_a().itemID);
    039        }
    040    }
    041
    042    public ItemStack func_96097_a()
    043    {
    044        return this.record;
    045    }
    046
    047    public void func_96098_a(ItemStack par1ItemStack)
    048    {
    049        this.record = par1ItemStack;
    050        this.onInventoryChanged();
    051    }
    052}