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

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

Closed
IFedor-F opened this issue May 15, 2023 · 6 comments
Closed

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

IFedor-F opened this issue May 15, 2023 · 6 comments
Assignees
Labels
Bug Something isn't working Completed The issue has been resolved (does not mean the resolution has been published yet tho).

Comments

@IFedor-F
Copy link

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

@IFedor-F IFedor-F added the Bug Something isn't working label May 15, 2023
@TheCSDev
Copy link
Member

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!

@TheCSDev
Copy link
Member

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.

@IFedor-F
Copy link
Author

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

@TheCSDev
Copy link
Member

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.

@IFedor-F
Copy link
Author

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

@TheCSDev TheCSDev self-assigned this May 15, 2023
@TheCSDev TheCSDev added the Completed The issue has been resolved (does not mean the resolution has been published yet tho). label May 15, 2023
@TheCSDev
Copy link
Member

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

@TheCSDev TheCSDev pinned this issue May 15, 2023
@TheCSDev TheCSDev unpinned this issue Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Completed The issue has been resolved (does not mean the resolution has been published yet tho).
Projects
None yet
Development

No branches or pull requests

2 participants