public static Packet readPacket(DataInputStream par0DataInputStream, boolean par1) throws IOException
    {
        boolean var2 = false;
        Packet var3 = null;
        int var6;

        try
        {
            var6 = par0DataInputStream.read();

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

            if (par1 && !serverPacketIdList.contains(Integer.valueOf(var6)) || !par1 && !clientPacketIdList.contains(Integer.valueOf(var6)))
            {
                throw new IOException("Bad packet id " + var6);
            }

            var3 = getNewPacket(var6);

            if (var3 == null)
            {
                throw new IOException("Bad packet id " + var6);
            }

            var3.readPacketData(par0DataInputStream);
            ++field_48158_m;
            field_48156_n += (long)var3.getPacketSize();
        }
        catch (EOFException var5)
        {
            System.out.println("Reached end of stream");
            return null;
        }

        PacketCount.countPacket(var6, (long)var3.getPacketSize());
        ++field_48158_m;
        field_48156_n += (long)var3.getPacketSize();
        return var3;
    }