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