Minecraft Beta 1.7.3 protocol question.

Discussion in 'Programming' started by MrPowerGamerBR, May 11, 2016.

  1. Howdy!

    I'm trying to make a simple Minecraft Beta 1.7.3 client just for fun, however, I don't know if it is meant to be like this, or...

    Code (Text):
    try {
                Socket socket = new Socket(InetAddress.getByName("127.0.0.1"), 25565);

                socket.setSoTimeout(30000);

                socket.setTrafficClass(24);

                this.input = new DataInputStream(socket.getInputStream());

                this.output = new DataOutputStream(socket.getOutputStream());
                this.connected = true;

                new ListenThread().start();

                /*
                 * Start handshake
                 */
                HandshakePacket packet = new HandshakePacket("TestClient");

                packet.writeData(output);

                // Flush flushy!
                output.flush();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    Code (Text):
       
      private class ListenThread extends Thread {
         @Override
         public void run() {
           while(connected) {
             try {
               int opcode = input.readUnsignedByte();
               
               if(opcode < 0) {
                 continue;
               }
               
               // System.out.println(opcode);
               
               if (opcode == 50) {
                 int chunkX = input.readInt();
                 int chunkZ = input.readInt();
                 int mode = input.readInt();
                 
                 System.out.println("Chunk X: " + chunkX + ", Chunk Z: " + chunkZ);
               }
               if (opcode == 53) {
                 int blockX = input.readInt();
                 int blockY = input.read();
                 int blockZ = input.readInt();

                 int blockType = input.readByte();
                 int blockMeta = input.readByte();

                 System.out.println(blockX + ", " + blockY + ", " + blockZ);
                 
                 blocks.add(new Block(blockX, blockY, blockZ));
               }

               if (opcode == 2 && !loggedIn) {
                 LoginPacket packet = new LoginPacket("AsrielDreemurr");

                 packet.writeData(output);

                 // Flush flushy!
                 output.flush();

                 loggedIn = true;
               }
               
               if (opcode == 6 && !spawned) {
                 // System.out.println("Spawn Packet");
                 x = input.readInt();
                 y = input.readInt();
                 z = input.readInt();
               
                 spawned = true;
               }
             } catch (Exception e) {
               e.printStackTrace();
               connected = false;
             }
           }
         }
       }
     
    It does work, the client logs in into the server without any issue, however, it seems the server(?) sends a lot of update block packets/pre-chunk packets to EXTREME coordinates, just look at this:
    Code (Text):

    Initializing Sockets...
    50340096, 167, 6619201
    Chunk X: 6, Chunk Z: 7
    Chunk X: 7, Chunk Z: 8
    Chunk X: 5, Chunk Z: 8
    Chunk X: 5, Chunk Z: 6
    Chunk X: 7, Chunk Z: 6
    Chunk X: 8, Chunk Z: 7
    Chunk X: 8, Chunk Z: 9
    Chunk X: 6, Chunk Z: 9
    Chunk X: 4, Chunk Z: 9
    Chunk X: 4, Chunk Z: 7
    Chunk X: 4, Chunk Z: 5
    Chunk X: 6, Chunk Z: 5
    Chunk X: 8, Chunk Z: 5
    Chunk X: 9, Chunk Z: 6
    Chunk X: 9, Chunk Z: 8
    Chunk X: 9, Chunk Z: 10
    Chunk X: 7, Chunk Z: 10
    Chunk X: 5, Chunk Z: 10
    Chunk X: 3, Chunk Z: 10
    Chunk X: 3, Chunk Z: 8
    Chunk X: 3, Chunk Z: 6
    Chunk X: 3, Chunk Z: 4
    Chunk X: 5, Chunk Z: 4
    Chunk X: 7, Chunk Z: 4
    Chunk X: 9, Chunk Z: 4
    Chunk X: 10, Chunk Z: 5
    Chunk X: 10, Chunk Z: 7
    Chunk X: 10, Chunk Z: 9
    Chunk X: 10, Chunk Z: 11
    Chunk X: 8, Chunk Z: 11
    Chunk X: 6, Chunk Z: 11
    Chunk X: 4, Chunk Z: 11
    Chunk X: 2, Chunk Z: 11
    Chunk X: 2, Chunk Z: 9
    Chunk X: 2, Chunk Z: 7
    Chunk X: 2, Chunk Z: 5
    Chunk X: 2, Chunk Z: 3
    Chunk X: 4, Chunk Z: 3
    Chunk X: 6, Chunk Z: 3
    Chunk X: 8, Chunk Z: 3
    Chunk X: 10, Chunk Z: 3
    Chunk X: 11, Chunk Z: 4
    Chunk X: 11, Chunk Z: 6
    Chunk X: 11, Chunk Z: 8
    Chunk X: 11, Chunk Z: 10
    Chunk X: 11, Chunk Z: 12
    Chunk X: 9, Chunk Z: 12
    Chunk X: 7, Chunk Z: 12
    Chunk X: 5, Chunk Z: 12
    Chunk X: 3, Chunk Z: 12
    Chunk X: 1, Chunk Z: 12
    Chunk X: 1, Chunk Z: 10
    Chunk X: 1, Chunk Z: 8
    Chunk X: 1, Chunk Z: 6
    Chunk X: 1, Chunk Z: 4
    Chunk X: 1, Chunk Z: 2
    Chunk X: 3, Chunk Z: 2
    Chunk X: 5, Chunk Z: 2
    Chunk X: 7, Chunk Z: 2
    Chunk X: 9, Chunk Z: 2
    Chunk X: 11, Chunk Z: 2
    Chunk X: 12, Chunk Z: 3
    Chunk X: 12, Chunk Z: 5
    Chunk X: 12, Chunk Z: 7
    Chunk X: 12, Chunk Z: 9
    Chunk X: 12, Chunk Z: 11
    Chunk X: 12, Chunk Z: 13
    Chunk X: 10, Chunk Z: 13
    Chunk X: 8, Chunk Z: 13
    Chunk X: 6, Chunk Z: 13
    Chunk X: 4, Chunk Z: 13
    Chunk X: 2, Chunk Z: 13
    Chunk X: 0, Chunk Z: 13
    Chunk X: 0, Chunk Z: 11
    Chunk X: 0, Chunk Z: 9
    Chunk X: 0, Chunk Z: 7
    Chunk X: 0, Chunk Z: 5
    Chunk X: 0, Chunk Z: 3
    Chunk X: 0, Chunk Z: 1
    Chunk X: 2, Chunk Z: 1
    Chunk X: 4, Chunk Z: 1
    Chunk X: 6, Chunk Z: 1
    Chunk X: 8, Chunk Z: 1
    Chunk X: 10, Chunk Z: 1
    Chunk X: 12, Chunk Z: 1
    Chunk X: 13, Chunk Z: 2
    Chunk X: 13, Chunk Z: 4
    Chunk X: 13, Chunk Z: 6
    Chunk X: 13, Chunk Z: 8
    Chunk X: 13, Chunk Z: 10
    Chunk X: 13, Chunk Z: 12
    Chunk X: 13, Chunk Z: 14
    Chunk X: 11, Chunk Z: 14
    Chunk X: 9, Chunk Z: 14
    Chunk X: 7, Chunk Z: 14
    Chunk X: 5, Chunk Z: 14
    Chunk X: 3, Chunk Z: 14
    Chunk X: 1, Chunk Z: 14
    Chunk X: -1, Chunk Z: 14
    Chunk X: -1, Chunk Z: 12
    Chunk X: -1, Chunk Z: 10
    Chunk X: -1, Chunk Z: 8
    Chunk X: -1, Chunk Z: 6
    Chunk X: -1, Chunk Z: 4
    Chunk X: -1, Chunk Z: 2
    Chunk X: -1, Chunk Z: 0
    Chunk X: 1, Chunk Z: 0
    Chunk X: 3, Chunk Z: 0
    Chunk X: 5, Chunk Z: 0
    Chunk X: 7, Chunk Z: 0
    Chunk X: 9, Chunk Z: 0
    Chunk X: 11, Chunk Z: 0
    Chunk X: 13, Chunk Z: 0
    Chunk X: 14, Chunk Z: 1
    Chunk X: 14, Chunk Z: 3
    Chunk X: 14, Chunk Z: 5
    Chunk X: 14, Chunk Z: 7
    Chunk X: 14, Chunk Z: 9
    Chunk X: 14, Chunk Z: 11
    Chunk X: 14, Chunk Z: 13
    Chunk X: 14, Chunk Z: 15
    Chunk X: 12, Chunk Z: 15
    Chunk X: 10, Chunk Z: 15
    Chunk X: 8, Chunk Z: 15
    Chunk X: 6, Chunk Z: 15
    Chunk X: 4, Chunk Z: 15
    Chunk X: 2, Chunk Z: 15
    Chunk X: 0, Chunk Z: 15
    Chunk X: -2, Chunk Z: 15
    Chunk X: -2, Chunk Z: 13
    Chunk X: -2, Chunk Z: 11
    Chunk X: -2, Chunk Z: 9
    Chunk X: -2, Chunk Z: 7
    Chunk X: -2, Chunk Z: 5
    Chunk X: -2, Chunk Z: 3
    Chunk X: -2, Chunk Z: 1
    Chunk X: -2, Chunk Z: -1
    Chunk X: 0, Chunk Z: -1
    Chunk X: 2, Chunk Z: -1
    Chunk X: 4, Chunk Z: -1
    Chunk X: 6, Chunk Z: -1
    Chunk X: 8, Chunk Z: -1
    Chunk X: 10, Chunk Z: -1
    Chunk X: 12, Chunk Z: -1
    Chunk X: 14, Chunk Z: -1
    Chunk X: 15, Chunk Z: 0
    Chunk X: 15, Chunk Z: 2
    Chunk X: 15, Chunk Z: 4
    Chunk X: 15, Chunk Z: 6
    Chunk X: 15, Chunk Z: 8
    Chunk X: 15, Chunk Z: 10
    Chunk X: 15, Chunk Z: 12
    Chunk X: 15, Chunk Z: 14
    Chunk X: 15, Chunk Z: 16
    Chunk X: 13, Chunk Z: 16
    Chunk X: 11, Chunk Z: 16
    Chunk X: 9, Chunk Z: 16
    Chunk X: 7, Chunk Z: 16
    Chunk X: 5, Chunk Z: 16
    Chunk X: 3, Chunk Z: 16
    Chunk X: 1, Chunk Z: 16
    Chunk X: -1, Chunk Z: 16
    Chunk X: -3, Chunk Z: 16
    Chunk X: -3, Chunk Z: 14
    Chunk X: -3, Chunk Z: 12
    Chunk X: -3, Chunk Z: 10
    Chunk X: -3, Chunk Z: 8
    Chunk X: -3, Chunk Z: 6
    Chunk X: -3, Chunk Z: 4
    Chunk X: -3, Chunk Z: 2
    Chunk X: -3, Chunk Z: 0
    Chunk X: -3, Chunk Z: -2
    Chunk X: -1, Chunk Z: -2
    Chunk X: 1, Chunk Z: -2
    Chunk X: 3, Chunk Z: -2
    Chunk X: 5, Chunk Z: -2
    Chunk X: 7, Chunk Z: -2
    Chunk X: 9, Chunk Z: -2
    Chunk X: 11, Chunk Z: -2
    Chunk X: 13, Chunk Z: -2
    Chunk X: 15, Chunk Z: -2
    Chunk X: 16, Chunk Z: -1
    Chunk X: 16, Chunk Z: 1
    Chunk X: 16, Chunk Z: 3
    Chunk X: 16, Chunk Z: 5
    Chunk X: 16, Chunk Z: 7
    Chunk X: 16, Chunk Z: 9
    Chunk X: 16, Chunk Z: 11
    Chunk X: 16, Chunk Z: 13
    Chunk X: 16, Chunk Z: 15
    Chunk X: 16, Chunk Z: 17
    Chunk X: 14, Chunk Z: 17
    Chunk X: 12, Chunk Z: 17
    Chunk X: 10, Chunk Z: 17
    Chunk X: 8, Chunk Z: 17
    Chunk X: 6, Chunk Z: 17
    Chunk X: 4, Chunk Z: 17
    Chunk X: 2, Chunk Z: 17
    Chunk X: 0, Chunk Z: 17
    Chunk X: -2, Chunk Z: 17
    Chunk X: -4, Chunk Z: 17
    Chunk X: -4, Chunk Z: 15
    Chunk X: -4, Chunk Z: 13
    Chunk X: -4, Chunk Z: 11
    Chunk X: -4, Chunk Z: 9
    Chunk X: -4, Chunk Z: 7
    Chunk X: -4, Chunk Z: 5
    Chunk X: -4, Chunk Z: 3
    Chunk X: -4, Chunk Z: 1
    Chunk X: -4, Chunk Z: -1
    Chunk X: -4, Chunk Z: -3
    Chunk X: -2, Chunk Z: -3
    Chunk X: 0, Chunk Z: -3
    Chunk X: 2, Chunk Z: -3
    Chunk X: 4, Chunk Z: -3
    Chunk X: 6, Chunk Z: -3
    Chunk X: 8, Chunk Z: -3
    Chunk X: 10, Chunk Z: -3
    Chunk X: 12, Chunk Z: -3
    Chunk X: 14, Chunk Z: -3
    Chunk X: 16, Chunk Z: -3
    1744830509, 255, -1
    Create
    553648128, 24, -16777147
    Chunk X: 2031616, Chunk Z: 7143424
    Chunk X: -720774, Chunk Z: 520093696
    228, 17, 221
    Chunk X: -37028391, Chunk Z: 553648128
    110, 72, 129
    Chunk X: 520093696, Chunk Z: 419430400
    34349312, 0, 1245439
    Chunk X: 2031616, Chunk Z: 13434880
    -17169986, 33, 18
    2031616, 1, 2097152000
    1835008, 0, 436152064
    Chunk X: 553648128, Chunk Z: 334823943
    Chunk X: 520093696, Chunk Z: 352321793
    1835008, 0, 352492544
    2031616, 1, -1241385468
     
    (I'm using LibGDX, that's why there is a "Create" message, I added that message in the create() method).

    I'm not sure if this is the expected output, but... it feels... I don't know... "strange", that the b1.7.3 server sends update packets to extreme coords, but I'm not sure if that is because of an error on my code or the b1.7.3 server does it by default.

    Running CraftBukkit b1060, /version output:
    Code (Text):
    This server is running Craftbukkit version git-Bukkit-0.0.0-980-g4ed23b1-b1060jnks (MC: 1.7.3)
    This server is also sporting some funky dev build of Bukkit!