package net.minecraft.network.play.server;

import java.io.IOException;
import net.minecraft.network.INetHandler;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class S45PacketTitle implements Packet
{
    private S45PacketTitle.Type field_179812_a;
    private IChatComponent field_179810_b;
    private int field_179811_c;
    private int field_179808_d;
    private int field_179809_e;
    private static final String __OBFID = "CL_00002287";

    public S45PacketTitle() {}

    public S45PacketTitle(S45PacketTitle.Type p_i45953_1_, IChatComponent p_i45953_2_)
    {
        this(p_i45953_1_, p_i45953_2_, -1, -1, -1);
    }

    public S45PacketTitle(int p_i45954_1_, int p_i45954_2_, int p_i45954_3_)
    {
        this(S45PacketTitle.Type.TIMES, (IChatComponent)null, p_i45954_1_, p_i45954_2_, p_i45954_3_);
    }

    public S45PacketTitle(S45PacketTitle.Type p_i45955_1_, IChatComponent p_i45955_2_, int p_i45955_3_, int p_i45955_4_, int p_i45955_5_)
    {
        this.field_179812_a = p_i45955_1_;
        this.field_179810_b = p_i45955_2_;
        this.field_179811_c = p_i45955_3_;
        this.field_179808_d = p_i45955_4_;
        this.field_179809_e = p_i45955_5_;
    }

    /**
     * Reads the raw packet data from the data stream.
     */
    public void readPacketData(PacketBuffer data) throws IOException
    {
        this.field_179812_a = (S45PacketTitle.Type)data.readEnumValue(S45PacketTitle.Type.class);

        if (this.field_179812_a == S45PacketTitle.Type.TITLE || this.field_179812_a == S45PacketTitle.Type.SUBTITLE)
        {
            this.field_179810_b = data.readChatComponent();
        }

        if (this.field_179812_a == S45PacketTitle.Type.TIMES)
        {
            this.field_179811_c = data.readInt();
            this.field_179808_d = data.readInt();
            this.field_179809_e = data.readInt();
        }
    }

    /**
     * Writes the raw packet data to the data stream.
     */
    public void writePacketData(PacketBuffer data) throws IOException
    {
        data.writeEnumValue(this.field_179812_a);

        if (this.field_179812_a == S45PacketTitle.Type.TITLE || this.field_179812_a == S45PacketTitle.Type.SUBTITLE)
        {
            data.writeChatComponent(this.field_179810_b);
        }

        if (this.field_179812_a == S45PacketTitle.Type.TIMES)
        {
            data.writeInt(this.field_179811_c);
            data.writeInt(this.field_179808_d);
            data.writeInt(this.field_179809_e);
        }
    }

    public void func_179802_a(INetHandlerPlayClient p_179802_1_)
    {
        p_179802_1_.func_175099_a(this);
    }

    @SideOnly(Side.CLIENT)
    public S45PacketTitle.Type func_179807_a()
    {
        return this.field_179812_a;
    }

    /**
     * Passes this Packet on to the NetHandler for processing.
     */
    public void processPacket(INetHandler handler)
    {
        this.func_179802_a((INetHandlerPlayClient)handler);
    }

    @SideOnly(Side.CLIENT)
    public IChatComponent func_179805_b()
    {
        return this.field_179810_b;
    }

    @SideOnly(Side.CLIENT)
    public int func_179806_c()
    {
        return this.field_179811_c;
    }

    @SideOnly(Side.CLIENT)
    public int func_179804_d()
    {
        return this.field_179808_d;
    }

    @SideOnly(Side.CLIENT)
    public int func_179803_e()
    {
        return this.field_179809_e;
    }

    public static enum Type
    {
        TITLE,
        SUBTITLE,
        TIMES,
        CLEAR,
        RESET;

        private static final String __OBFID = "CL_00002286";

        public static S45PacketTitle.Type func_179969_a(String p_179969_0_)
        {
            S45PacketTitle.Type[] atype = values();
            int i = atype.length;

            for (int j = 0; j < i; ++j)
            {
                S45PacketTitle.Type type = atype[j];

                if (type.name().equalsIgnoreCase(p_179969_0_))
                {
                    return type;
                }
            }

            return TITLE;
        }

        public static String[] func_179971_a()
        {
            String[] astring = new String[values().length];
            int i = 0;
            S45PacketTitle.Type[] atype = values();
            int j = atype.length;

            for (int k = 0; k < j; ++k)
            {
                S45PacketTitle.Type type = atype[k];
                astring[i++] = type.name().toLowerCase();
            }

            return astring;
        }
    }
}