    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    public class TileEntitySign extends TileEntity
    007    {
    008        /** An array of four strings storing the lines of text on the sign. */
    009        public String[] signText = new String[] {"", "", "", ""};
    010
    011        /**
    012         * The index of the line currently being edited. Only used on client side, but defined on both. Note this is only
    013         * really used when the > < are going to be visible.
    014         */
    015        public int lineBeingEdited = -1;
    016        private boolean isEditable = true;
    017
    018        /**
    019         * Writes a tile entity to NBT.
    020         */
    021        public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    022        {
    023            super.writeToNBT(par1NBTTagCompound);
    024            par1NBTTagCompound.setString("Text1", this.signText[0]);
    025            par1NBTTagCompound.setString("Text2", this.signText[1]);
    026            par1NBTTagCompound.setString("Text3", this.signText[2]);
    027            par1NBTTagCompound.setString("Text4", this.signText[3]);
    028        }
    029
    030        /**
    031         * Reads a tile entity from NBT.
    032         */
    033        public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    034        {
    035            this.isEditable = false;
    036            super.readFromNBT(par1NBTTagCompound);
    037
    038            for (int var2 = 0; var2 < 4; ++var2)
    039            {
    040                this.signText[var2] = par1NBTTagCompound.getString("Text" + (var2 + 1));
    041
    042                if (this.signText[var2].length() > 15)
    043                {
    044                    this.signText[var2] = this.signText[var2].substring(0, 15);
    045                }
    046            }
    047        }
    048
    049        /**
    050         * Overriden in a sign to provide the text.
    051         */
    052        public Packet getDescriptionPacket()
    053        {
    054            String[] var1 = new String[4];
    055            System.arraycopy(this.signText, 0, var1, 0, 4);
    056            return new Packet130UpdateSign(this.xCoord, this.yCoord, this.zCoord, var1);
    057        }
    058
    059        public boolean isEditable()
    060        {
    061            return this.isEditable;
    062        }
    063
    064        @SideOnly(Side.CLIENT)
    065
    066        /**
    067         * Sets the sign's isEditable flag to the specified parameter.
    068         */
    069        public void setEditable(boolean par1)
    070        {
    071            this.isEditable = par1;
    072        }
    073    }