henkelmax / simple-voice-chat

A working voice chat in Minecraft!
https://modrepo.de/minecraft/voicechat/wiki
422 stars 108 forks source link

Velocity plugin not working with 1.20.6 #693

Closed MusclePr closed 1 month ago

MusclePr commented 1 month ago

Confirmation

Bug description

Error occurred connect via Velocity from Minecraft 1.20.6 Error_with_velocity_1 20 6

Client

Minecraft version

1.20.6

Mod/Plugin version

Mod 1.20.6-2.5.15/Server Plugin 2.5.13/Velocity Plugin 2.5.12(beta)

Mod/Plugin loader and version

Fabric Loader 0.15.11-1.20.6

Steps to reproduce

Requires docker.

  1. Unzip setup.zip
  2. Run ./setup.sh on your new working directory.
  3. Run docker compose up
  4. Launch Minecraft 1.20.6 fabric
  5. Connect to localhost:25565 (velocity)
  6. Error occurred
  7. Connect localhost:25566 (no proxied server)
  8. No error.

Expected behavior

No error to connect

Log files

https://gist.github.com/MusclePr/718889be7049acb662ad81db96b083ef

Screenshots

No response

henkelmax commented 1 month ago

This is not an issue with the voice chat mod. This was caused by Velocity/ViaVersion. Make sure to update them all. If you need more information/help about that issue visit out Discord server.

henkelmax commented 1 month ago

So turns out this might actually be a bug with the velocity plugin. We had users before where updating ViaVersion fixed the issue, but that does not seem to be the case.

MusclePr commented 1 month ago

[S ---> C] Custom Payload|voicechat:secret [ID:25]

In case of direct connect to server: (SUCCESS)

{
    "data": "Vector of 56 unsigned chars",
    "identifier": "voicechat:secret"
}
ID:                0x19 (=25 Custom Payload)
SIZE:              0x10 (=16)
Identifier:        0x76 0x6f 0x69 0x63 0x65 0x63 0x68 0x61 0x74 0x3a 0x73 0x65 0x63 0x72 0x65 0x74 (=voicechat:secret)
?:                 0x8a 0x0c
----
UUID:              0xfd 0xcf 0x03 0xb7 0x7c 0x3a 0x79 0xc9 0x23 0xc3 0x31 0x0d 0xa2 0x35 0x00 0x00
Server Port:       0x5f 0x86 (=24454)
UUID:              0x7d 0x4c 0x96 0x96 0x6a 0x1a 0x3d 0xd4 0x80 0x0b 0xee 0xee 0xfd 0x4e 0xe8 0x78
Codec:             0x00
MTU Size:          0x00 0x00 0x04 0x00 (=1024)
voiceChatDistance: 0x40 0x48 0x00 0x00 0x00 0x00 0x00 0x00
keepAlive:         0x00 0x00 0x03 0xe8 (=1000)
groupEnabled:      0x01
voiceHost:         0x00
allowRecording:    0x01

In case of connect to server via Velocity: (ERROR)

{
    "data": "Vector of 60 unsigned chars",
    "identifier": "voicechat:secret"
}
ID:                0x19 (=25 Custom Payload)
SIZE:              0x10 (=16)
Identifier:        0x76 0x6f 0x69 0x63 0x65 0x63 0x68 0x61 0x74 0x3a 0x73 0x65 0x63 0x72 0x65 0x74 (=voicechat:secret)
?:                 0xe5 0xa0
----
UUID:              0x8c 0xc4 0x5d 0x43 0x0b 0x8b 0x0e 0x44 0x41 0xdf 0x07 0xbb 0x7b 0x53 0x00 0x00
Server Port:       0x63 0xe9 (=25577)
UUID:              0x7d 0x4c 0x96 0x96 0x6a 0x1a 0x3d 0xd4 0x80 0x0b 0xee 0xee 0xfd 0x4e 0xe8 0x78
Codec:             0x00 
MTU Size:          0x00 0x00 0x04 0x00 (=1024)
voiceChatDistance: 0x40 0x48 0x00 0x00 0x00 0x00 0x00 0x00
keepAlive:         0x00 0x00 0x03 0xe8 (=1000)
groupsEnabled:     0x01
voiceHost:         0x00
allowRecording:    0x01
UNKOWN:            0x00 0x00 0x00 0x00 <----- maybe problem
MusclePr commented 1 month ago

It seemed like the Velocity plugin was always sending the maximum allocated buffer size.

https://github.com/henkelmax/simple-voice-chat/blob/98da8a86bd017fff4385cab90bfb8713a2e7bc68/common-proxy/src/main/java/de/maxhenkel/voicechat/sniffer/SniffedSecretPacket.java#L42-L58

Maybe this will fix it?

      buf.writeUtf(voiceHost, 32767); 
      buf.writeBoolean(allowRecording); 
+     buffer.flip();
      return buffer;
  }
MusclePr commented 1 month ago

I have confirmed that there is no problem with both 1.20.4 and 1.20.6.

https://github.com/henkelmax/simple-voice-chat/blob/98da8a86bd017fff4385cab90bfb8713a2e7bc68/common-proxy/src/main/java/de/maxhenkel/voicechat/sniffer/SniffedSecretPacket.java#L57

+     buffer.flip();
      return buffer;
henkelmax commented 1 month ago

It seemed like the Velocity plugin was always sending the maximum allocated buffer size.

https://github.com/henkelmax/simple-voice-chat/blob/98da8a86bd017fff4385cab90bfb8713a2e7bc68/common-proxy/src/main/java/de/maxhenkel/voicechat/sniffer/SniffedSecretPacket.java#L42-L58

Maybe this will fix it?

      buf.writeUtf(voiceHost, 32767); 
      buf.writeBoolean(allowRecording); 
+     buffer.flip();
      return buffer;
  }

I just tested it out and the issue still persists using your suggestion.

Maybe i missed something?

henkelmax commented 1 month ago
byte[] data = new byte[buffer.position()];
System.arraycopy(buffer.array(), 0, data, 0, buffer.position());
return ByteBuffer.wrap(data);

This seems to work though...