Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.19.4] Stats lost on client reconnect #85

Open
SpomJ opened this issue Dec 22, 2023 · 11 comments
Open

[1.19.4] Stats lost on client reconnect #85

SpomJ opened this issue Dec 22, 2023 · 11 comments

Comments

@SpomJ
Copy link

SpomJ commented Dec 22, 2023

if you are not connected at the time proxy logs in or you decide to reconnect, the following stats are broken:

  • Food restoration speed (for some reason food fills up as with saturation effect on, each time you lose a hunger point it resets then quickly goes to full again) [workaround: die / switch dimension]
  • Advancements menu is empty
  • Recipe book is empty
  • Exp is set to 0 until you lose/get some
  • If you were in a boat it could just be not sent to you so you can't break it and 2b2t invalidates your every movement so the only solution would be to call someone to go help you, join without a proxy (duh) or die somehow

might miss out on some but i think this is as far at goes for now

@Enchoseon
Copy link
Owner

Thank you for the list! These missed-the-first-packet desyncs are really more of an upstream caching issue, but have been around since 1.12.2 and a naive-but-functional fix would probably be pretty easy to throw in as an experimental feature (basically store missed packets and resend them when a user logs in).

Biggest reason I haven't done this, though, is security and non-vanilla behavior of DIYing it instead of fixing upstream code (e.g., a naive implementation could easily send cached packets containing coordinates the user shouldn't have access to).

Will look into fixing this.

Enchoseon added a commit that referenced this issue Dec 23, 2023
experimental.syncGamestate is an experimental flag that aggressively
sends fake packets in an attempt to sync the client's game state.

This is to help with clients getting desynced when they miss packets
that only get sent once, either by connecting to the proxy after it has
joined a game OR by logging in and out of the proxy.

Relevant Issue: #85

Current features:
1. Fix invisible vehicles
2. Forcibly update experience bar
3. Fix undismountable vehicles

TODO: (things to fix)
- Sign data desync (blank signs)
- Hunger
- Empty Advancements
- Empty Recipe book (from a cursory glance this appears to already
  be fixed upstream, not sure why this is broken)
- Unre-mountable vehicles after reconnecting
	* Probably something to with metadata or dismounting.
	* Breaking boat and placing it down again fixed this
@SpomJ
Copy link
Author

SpomJ commented Dec 23, 2023

Minecraft doesn't connect, at least while queueing:

Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonSyntaxException: Expected text to be a string, was an object ({"fi...t"})

So basically unwrap the string smh

@Enchoseon
Copy link
Owner

Hm, can't replicate with vanilla or Fabric (0.14.22) Minecraft client for 1.19.4 connecting or reconnecting to an account sitting in queue. Can you give some more details on how you got this crash?

@SpomJ
Copy link
Author

SpomJ commented Dec 24, 2023

I'm currently using a pretty modded setup (Fabric 1.20.2 FO + Multiconnect VFP + Meteor & baritone + Xaero* (xaeroplus too) + DH2).

Probably because of VFP, but still weird cuz it doesn't happen with feature turned off actually nevermind, it does not rely on this specific flag although it only started to happen after i git pull'd.

@SpomJ
Copy link
Author

SpomJ commented Dec 24, 2023

[15:09:09] [Render thread/INFO]: emissive suffixes loaded: {_e}.
[15:09:09] [Render thread/INFO]: Connecting to localhost, 25565
[15:09:10] [Render thread/INFO]: New minimap session initialized!
[15:09:10] [Render thread/INFO]: New world map session initialized!
[15:09:10] [Render thread/INFO]: Reloading pipeline on dimension change: NamespacedId{namespace='minecraft', name='overworld'} => NamespacedId{namespace='minecraft', name='the_end'}
[15:09:10] [Render thread/INFO]: Destroying pipeline NamespacedId{namespace='minecraft', name='the_end'}
[15:09:10] [Render thread/INFO]: Creating pipeline for dimension NamespacedId{namespace='minecraft', name='the_end'}
[15:09:10] [Render thread/INFO]: Started 1 worker threads
[15:09:10] [Render thread/INFO]: [STDOUT]: World seems to be a replay. Not loading Baritone cache.
[15:09:10] [Render thread/INFO]: [STDOUT]: Retrying to load Baritone cache
[15:09:10] [Render thread/INFO]: [STDOUT]: Baritone world data dir: /home/main/.local/share/PrismLauncher/instances/Fabulously Optimized/.minecraft/baritone/localhost/minecraft/the_end_256
[15:09:10] [Render thread/INFO]: [CHAT] \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPosition in queue: 303\nYou can purchase priority queue status to join the server faster, visit shop.2b2t.org
[15:09:11] [Render thread/WARN]: Time from main menu to in-game was 1.724062 seconds
[15:09:11] [Render thread/WARN]: Total time to load game and open world was 111.29006 seconds
[15:09:11] [Render thread/INFO]: Saving
[15:09:11] [Render thread/INFO]: Saved in 52 milliseconds.
[15:09:11] [Render thread/INFO]: Minimap session finalized.
[15:09:11] [Render thread/INFO]: Finalizing world map session...
[15:09:11] [Thread-10/INFO]: World map force-cleaned!
[15:09:11] [Render thread/INFO]: World map session finalized.
[15:09:11] [Render thread/INFO]: Stopping worker threads
[15:09:11] [Render thread/INFO]: emissive suffixes loaded: {_e}.
[15:09:11] [Render thread/WARN]: Client disconnected with reason: Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonSyntaxException: Expected text to be a string, was an object ({"fi...t"})

@Enchoseon
Copy link
Owner

Okay, I replicated a crash with ViaFabricPlig (2.10.1) and Fabric API (0.91.2+1.20.2) on Minecraft Fabric 1.20.2. It wasn't the same error message you got, but I'm hoping that that's just because the mod stack changes the message.

I was able to stop the crash by clicking on "ViaFabricPlug" in the top-right of the multiplayer server listing screen and manually set it to 2b2t's version (1.19.4). After that, I was able to join and reconnect to the proxy without crashing.

If this doesn't work then please share the output of pnpm debug-info.

@SpomJ
Copy link
Author

SpomJ commented Dec 25, 2023

Nope. Still doesn't.

Viafabricplus version: 2.10.1 (from modrinth)

i-use@arch-btw ~/l/a/s/2based2wait (experimental/1.19.4)> dbg pnpm debug-info

> [email protected] debug-info /home/main/lib/app/src/2based2wait
> node ./scripts/debugFetch.js

sh: line 1: mocha: command not found
=== System Info ===
OS: Linux_6.6.6-arch1-1_x64
Memory: 11.1 GB (11980734464 Bytes)
Node Version: v21.4.0
=== 2Based2Wait Info ===
Current Commit Hash: 1d4f357
Package.json Version: 1.0.5-beta.1
File Hashes:
-./proxy.js:5650b64
-./package.json:0e480e0
-./package-lock.json:false
-./util/chatty.js:752922c
-./util/config.js:4d7af51
-./util/downloader.js:226ab53
-./util/logger.js:d9d8181
-./util/mineflayer.js:567a76c
-./util/ngrok.js:45d16cd
-./util/notifier.js:77fcfdd
-./util/queue.js:6b3e302
-./util/schemas.js:3b07e60
-./scripts/debugFetch.js:b5cab6a
-./scripts/processArchives.js:54b0188
-./scripts/updateNgrokBinary.js:fc021f1
-./test/test-config.json:50a8779
-./test/test.js:f9f9325
Last Modified File: ./proxy.js
=== Log Folders ===
- bridgeClientPackets(4 files/folders)
- chat(0 files/folders)
- error(0 files/folders)
- mineflayer(0 files/folders)
- proxy(1 files/folders)
- serverPackets(28 files/folders)
- worldDownloader(1 files/folders)
=== Tests ===
Config.json is Valid JSON5: true
Passes Mocha Tests: false
Is Mocha Installed: false
  ^ You can install mocha by running `pnpm i`!

The message on wrong version is indeed different, but this one still doesn't work. I would also appreciate if mahjong didn't limit actual error to 3 symbols

@SpomJ
Copy link
Author

SpomJ commented Dec 26, 2023

I think i might have found the underlying issue. It prints the following for a very brief period of time before i get logged off.
Error message

*sorry that it's quite blurry and a bit overlapped, it was quickly overwritten with gui again, so i had to record it on a video

@SpomJ
Copy link
Author

SpomJ commented Dec 29, 2023

Ok so i disabled cliGui and this is the one I got:

Creating packet bridge
Disconnecting client because error TypeError: Serialization error for play.toClient : Write error for undefined : Cannot read properties of undefined (reading 'length')
    at module.exports.Write.UUID (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/minecraft-protocol/src/datatypes/compiler-minecraft.js:50:25)
    at eval (eval at compile (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1873:30)
    at eval (eval at compile (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:258:12), <anonymous>:2359:11)
    at Object.packet_player_info (eval at compile (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:258:12), <anonymous>:2362:9)
    at eval (eval at compile (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:258:12), <anonymous>:3346:62)
    at packet (eval at compile (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:258:12), <anonymous>:3401:9)
    at CompiledProtodef.write (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:76:12)
    at e.message (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:102:25)
    at tryCatch (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/compiler.js:102:5)
    at Serializer.createPacketBuffer (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/serializer.js:12:23)
    at Serializer._transform (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/protodef/src/serializer.js:18:18)
    at Transform._read (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_transform.js:166:10)
    at Transform._write (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_transform.js:155:83)
    at doWrite (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:390:139)
    at writeOrBuffer (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:381:5)
    at Writable.write (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:302:11)
    at Client.write (/home/main/lib/app/src/2based2wait/node_modules/.pnpm/[email protected]/node_modules/minecraft-protocol/src/client.js:236:21)
    at Timeout._onTimeout (/home/main/lib/app/src/2based2wait/proxy.js:275:19)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  field: 'play.toClient'
}

@SpomJ
Copy link
Author

SpomJ commented Dec 29, 2023

It also appears to me 2b2t itself is using ViaVersion protocol, was your 2b2w config set to 1.19.4?

Okay, I replicated a crash with ViaFabricPlig (2.10.1) and Fabric API (0.91.2+1.20.2) on Minecraft Fabric 1.20.2. It wasn't the same error message you got, but I'm hoping that that's just because the mod stack changes the message.

I was able to stop the crash by clicking on "ViaFabricPlug" in the top-right of the multiplayer server listing screen and manually set it to 2b2t's version (1.19.4). After that, I was able to join and reconnect to the proxy without crashing.

If this doesn't work then please share the output of pnpm debug-info.

@BigBeefyCow666
Copy link

I had this same problem, and by looking through the code, found it could be avoided by setting the config value experimental/spoofPlayerInfo/active to false. It seems to be due to with the proxy doing something with a UUID and finding a skin from the Mojang servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants