无法连接到Minecraft服务器

I get this error when I try to connect to a Minecraft server using a slightly modified Minecraft client made from scratch in Java from here: Original Minecraft client Java code: Java sending handshake packets to minecraft server My modified version of the code above: https://pastebin.com/FmsBzKnm The error comes from somewhere here...


        socket.close();
        Socket socket2 = new Socket();

        while (!socket2.isConnected()) {
            socket2.connect(host, 4000);
            Thread.sleep(500);
        }

        DataOutputStream out2 = new DataOutputStream(socket2.getOutputStream());
        DataInputStream in2 = new DataInputStream(socket2.getInputStream());

        int packetId2 = getHandshakeAndReturn(version, address, port, 2, out2, in2);
        byte[] test = new byte[readVarInt(in2)];
        in2.readFully(test);
        System.out.println(new String(test));

当我运行此命令时,出现以下错误:内部异常:io.netty.handler.codec.DecoderException:java.lang.IndexOutOfBoundsException:readerIndex(1)+ length(1)超过writerIndex(1):PooledUnsafeDirectByteBuf(ridx:1,widx :1,上限:1)

评论