public static Packet readPacket(DataInputStream par0DataInputStream, boolean par1) throws IOException
    {
        int i = 0;
        Packet packet = null;

        try
        {
            i = par0DataInputStream.read();

            if (i == -1)
            {
                return null;
            }

            if (par1 && !serverPacketIdList.contains(Integer.valueOf(i)) || !par1 && !clientPacketIdList.contains(Integer.valueOf(i)))
            {
                throw new IOException((new StringBuilder()).append("Bad packet id ").append(i).toString());
            }

            packet = getNewPacket(i);

            if (packet == null)
            {
                throw new IOException((new StringBuilder()).append("Bad packet id ").append(i).toString());
            }

            packet.readPacketData(par0DataInputStream);
            field_73292_n++;
            field_73293_o += packet.getPacketSize();
        }
        catch (EOFException eofexception)
        {
            System.out.println("Reached end of stream");
            return null;
        }

        PacketCount.countPacket(i, packet.getPacketSize());
        field_73292_n++;
        field_73293_o += packet.getPacketSize();
        return packet;
    }