Better Statistics Screen

Better Statistics Screen

21M Downloads

[Fabric 1.19.4 v2.7] | Error connecting to the server

IFedor-F opened this issue ยท 6 comments

commented

Hi, I have a strange bug when connecting to the server
image
https://mclo.gs/NNM9lOz
I noticed this bug only on one server, when connecting to others everything is fine

commented

Hello! Thanks a lot for respoting the bug.

Here's a technical explanation of what I believe might be going on if you're interested in reading it.

So, I've been examining the Yarn deobfuscation mappings to deobfuscate the error message and identify its cause. Here's what I've found:

  • `field_1724` is the `player` field in the `MinecraftClient` class
    • `FIELD field_1724 player Lnet/minecraft/class_746;`
  • `class_746` is the `ClientPlayerEntity`
    • `CLASS net/minecraft/class_746 net/minecraft/client/network/ClientPlayerEntity`
  • `method_7334` pertains to a player's `GameProfile`
    • `METHOD method_7334 getGameProfile ()Lcom/mojang/authlib/GameProfile;`

I'll try to simplify this:

The `MinecraftClient` class is crucial for the client-side game as it tracks everything that happens when you start the game. It has a field/property named `player` which is of the type `ClientPlayerEntity`. This property tracks the player on your end (client-side player) when you're in-game, but it is "undefined" when you're in the main menu.

The error appears to be occurring because something is trying to access the `player` property before it's defined. When you join a world, the `player` is undefined until you're fully logged into a server. If something triggers a mod (possibly mine) to access the `player` property before it's defined, a `NullPointerException` error occurs, which basically means "Hey, you're trying to access something that doesn't exist".


So with the technical explanation above in mind, I'm not sure why my mod (if indeed it is the cause) would attempt to access the "player" property during server login. Thanks for the logs as well, as they are vrey helpful, but unfortunately, they do not include the error's "stack trace". In case you don't know what that is, a "stack trace" is an essential debugging tool that indicates exactly which lines of code are causing issues, so the absence of the stack trace might be due to the game not including it.

From what I see in the mod's code, one possible issue could occur if a server sends player statistics during the login process. This might cause Better Stats to attempt to read these statistics and associate them with the "player" property, which at that moment is still "undefined", leading to the error. Although it's unclear why a server would send player statistics during login, altho I will update the mod to handle this situation just in case this is indeed the source of the problem. I'll also look further into my code to make sure I didn't miss any other potential flaws.

In the meantime, could you let me know if this specifically takes place while Better Stats is installed? Thanks again for the bug report, and have a great day!

commented

Upon further inspection, it's definitely my fault:
Sprite-0002

So yeah, your server is for some reason sending you statistics or something as you're logging on, causing Better Stats to react too early, causing the error. Sorry about all that and for such a long response. Will have it fixed asap.

commented

I can't test this with stack trace, but without this mod I can go in
If necessary, I can give you the ip of the server
Thanks for support

commented

I fixed that one line of code and published a temp. pre-release here on GitHub:
https://github.com/TheCSMods/mc-better-stats/releases/tag/v2.7.1

Please give it a try and see if it fixes your issue before I publish the patch.

commented

Yes, the new version is working, thanks for fixing it!

commented

And thank you for spotting the issue, reporting it, and helping me resolve it. Have a great day again!