Simple Voice Chat

Simple Voice Chat

34M Downloads

Velocity plugin not working with 1.20.6

MusclePr opened this issue ยท 7 comments

commented

Confirmation

  • I have read the wiki

Bug description

Error occurred connect via Velocity from Minecraft 1.20.6
Error_with_velocity_1 20 6

Client

  • Minecraft 1.20.6
  • Fabric Loader 0.15.11-1.20.6
  • fabric-api-0.99.0+1.20.6.jar
  • voicechat-fabric-1.20.6-2.5.15.jar

Proxy

  • Velocity 3.3.0-SNAPSHOT (git-afd8b55f-b390)
  • voicechat-velocity-2.5.12.jar

Server

  • Paper version 1.20.6-88-master@980cff9 (2024-05-21T15:52:13Z)
  • voicechat-bukkit-2.5.13.jar

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

commented

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.

commented

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

public ByteBuffer toBytes() {
int maxHostSize = voiceHost.length() * 4 + 5;
int size = 16 + 4 + 16 + 1 + 4 + 8 + 4 + 1 + maxHostSize + 1;
ByteBuffer buffer = ByteBuffer.allocate(size);
ByteBufferWrapper buf = new ByteBufferWrapper(buffer);
buf.writeUUID(secret);
buf.writeInt(serverPort);
buf.writeUUID(playerUUID);
buf.writeByte(codec);
buf.writeInt(mtuSize);
buf.writeDouble(voiceChatDistance);
buf.writeInt(keepAlive);
buf.writeBoolean(groupsEnabled);
buf.writeUtf(voiceHost, 32767);
buf.writeBoolean(allowRecording);
return buffer;
}

Maybe this will fix it?

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

[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
commented

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

+     buffer.flip();
      return buffer;
commented

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

public ByteBuffer toBytes() {
int maxHostSize = voiceHost.length() * 4 + 5;
int size = 16 + 4 + 16 + 1 + 4 + 8 + 4 + 1 + maxHostSize + 1;
ByteBuffer buffer = ByteBuffer.allocate(size);
ByteBufferWrapper buf = new ByteBufferWrapper(buffer);
buf.writeUUID(secret);
buf.writeInt(serverPort);
buf.writeUUID(playerUUID);
buf.writeByte(codec);
buf.writeInt(mtuSize);
buf.writeDouble(voiceChatDistance);
buf.writeInt(keepAlive);
buf.writeBoolean(groupsEnabled);
buf.writeUtf(voiceHost, 32767);
buf.writeBoolean(allowRecording);
return buffer;
}

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?

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

This seems to work though...

commented

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.