    001    package net.minecraft.network.packet;
    002
    003    import java.io.DataInputStream;
    004    import java.io.DataOutputStream;
    005    import java.io.IOException;
    006
    007    public class Packet3Chat extends Packet
    008    {
    009        /** Maximum number of characters allowed in chat string in each packet. */
    010        public static int maxChatLength = 119;
    011
    012        /** The message being sent. */
    013        public String message;
    014        private boolean field_73477_c;
    015
    016        public Packet3Chat()
    017        {
    018            this.field_73477_c = true;
    019        }
    020
    021        public Packet3Chat(String par1Str)
    022        {
    023            this(par1Str, true);
    024        }
    025
    026        public Packet3Chat(String par1Str, boolean par2)
    027        {
    028            this.field_73477_c = true;
    029
    030            if (par1Str.length() > maxChatLength)
    031            {
    032                par1Str = par1Str.substring(0, maxChatLength);
    033            }
    034
    035            this.message = par1Str;
    036            this.field_73477_c = par2;
    037        }
    038
    039        /**
    040         * Abstract. Reads the raw packet data from the data stream.
    041         */
    042        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    043        {
    044            this.message = readString(par1DataInputStream, maxChatLength);
    045        }
    046
    047        /**
    048         * Abstract. Writes the raw packet data to the data stream.
    049         */
    050        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    051        {
    052            writeString(this.message, par1DataOutputStream);
    053        }
    054
    055        /**
    056         * Passes this Packet on to the NetHandler for processing.
    057         */
    058        public void processPacket(NetHandler par1NetHandler)
    059        {
    060            par1NetHandler.handleChat(this);
    061        }
    062
    063        /**
    064         * Abstract. Return the size of the packet (not counting the header).
    065         */
    066        public int getPacketSize()
    067        {
    068            return 2 + this.message.length() * 2;
    069        }
    070
    071        public boolean func_73475_d()
    072        {
    073            return this.field_73477_c;
    074        }
    075
    076        /**
    077         * if this returns false, processPacket is deffered for processReadPackets to handle
    078         */
    079        public boolean isWritePacket()
    080        {
    081            return !this.message.startsWith("/");
    082        }
    083    }