    001package net.minecraft.tileentity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.nbt.NBTTagCompound;
    006import net.minecraft.network.packet.Packet;
    007import net.minecraft.network.packet.Packet132TileEntityData;
    008
    009public 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 nbttagcompound = new NBTTagCompound();
    052        this.writeToNBT(nbttagcompound);
    053        return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound);
    054    }
    055
    056    /**
    057     * Set the entity type for the skull
    058     */
    059    public void setSkullType(int par1, String par2Str)
    060    {
    061        this.skullType = par1;
    062        this.extraType = par2Str;
    063    }
    064
    065    /**
    066     * Get the entity type for the skull
    067     */
    068    public int getSkullType()
    069    {
    070        return this.skullType;
    071    }
    072
    073    /**
    074     * Set the skull's rotation
    075     */
    076    public void setSkullRotation(int par1)
    077    {
    078        this.skullRotation = par1;
    079    }
    080
    081    @SideOnly(Side.CLIENT)
    082    public int func_82119_b()
    083    {
    084        return this.skullRotation;
    085    }
    086
    087    /**
    088     * Get the extra data foor this skull, used as player username by player heads
    089     */
    090    public String getExtraType()
    091    {
    092        return this.extraType;
    093    }
    094}