    001    package net.minecraft.tileentity;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.nbt.NBTTagCompound;
    006    import net.minecraft.network.packet.Packet;
    007    import net.minecraft.network.packet.Packet132TileEntityData;
    008
    009    public class TileEntitySkull extends TileEntity
    010    {
    011        /** Entity type for this skull. */
    012        private int skullType;
    013
    014        /** The skull's rotation. */
    015        private int skullRotation;
    016
    017        /** Extra data for this skull, used as player username by player heads */
    018        private String extraType = "";
    019
    020        /**
    021         * Writes a tile entity to NBT.
    022         */
    023        public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    024        {
    025            super.writeToNBT(par1NBTTagCompound);
    026            par1NBTTagCompound.setByte("SkullType", (byte)(this.skullType & 255));
    027            par1NBTTagCompound.setByte("Rot", (byte)(this.skullRotation & 255));
    028            par1NBTTagCompound.setString("ExtraType", this.extraType);
    029        }
    030
    031        /**
    032         * Reads a tile entity from NBT.
    033         */
    034        public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    035        {
    036            super.readFromNBT(par1NBTTagCompound);
    037            this.skullType = par1NBTTagCompound.getByte("SkullType");
    038            this.skullRotation = par1NBTTagCompound.getByte("Rot");
    039
    040            if (par1NBTTagCompound.hasKey("ExtraType"))
    041            {
    042                this.extraType = par1NBTTagCompound.getString("ExtraType");
    043            }
    044        }
    045
    046        /**
    047         * Overriden in a sign to provide the text.
    048         */
    049        public Packet getDescriptionPacket()
    050        {
    051            NBTTagCompound var1 = new NBTTagCompound();
    052            this.writeToNBT(var1);
    053            return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, var1);
    054        }
    055
    056        public void func_82118_a(int par1, String par2Str)
    057        {
    058            this.skullType = par1;
    059            this.extraType = par2Str;
    060        }
    061
    062        public int func_82117_a()
    063        {
    064            return this.skullType;
    065        }
    066
    067        public void func_82116_a(int par1)
    068        {
    069            this.skullRotation = par1;
    070        }
    071
    072        @SideOnly(Side.CLIENT)
    073        public int func_82119_b()
    074        {
    075            return this.skullRotation;
    076        }
    077
    078        public String func_82120_c()
    079        {
    080            return this.extraType;
    081        }
    082    }