Jump to content

[1.19.2, SOLVED] Intermittent NPE at screen renderring


Kosh

Recommended Posts

Hello. I have a problem with my gui screen. It crash game from time to time(but mostly it works correctly) without any obvoiuse reasons, when it tries to call "super.renderBackground".

java.lang.NullPointerException: Cannot read field "level" because "this.minecraft" is null
	at net.minecraft.client.gui.screens.Screen.renderBackground(Screen.java:442) ~[forge-1.19.2-43.1.47_mapped_official_1.19.2-recomp.jar%23183!/:?] 

May be some one know why it happens?

 

My screen: https://github.com/NightKosh/Sophisticated-wolves/blob/feature/1.19.2_update/src/main/java/sophisticated_wolves/gui/WolfFoodConfigScreen.java

"debug" and "latest" logs https://gist.github.com/NightKosh/e73c29bb2ea336b1d6336f64d92ec384

Edited by Kosh
Link to comment
Share on other sites

10 minutes ago, MistaOmega said:

Line 522: java.lang.IllegalStateException: Rendersystem called from wrong thread

Screens are client side only, so make sure you're opening the screen from the client

 

So

Minecraft.getInstance().setScreen(....);

opens screen for both client and server side?

 

 

It looks like it solve my problem. Thank you!

Edited by Kosh
  • Like 1
Link to comment
Share on other sites

Yeah, I'd check to see what tick that you're referencing during this block:

 

else if (FoodUtils.isBone(stack)) {
                Minecraft.getInstance().setScreen(new WolfFoodConfigScreen(this));
                stack.shrink(1);
                return InteractionResult.SUCCESS;
            }

add a level.IsClientSide() check before setting that screen so that when the server side tick passes through that function, it is ignored

  • Like 1
Link to comment
Share on other sites

  • Kosh changed the title to [1.19.2, SOLVED] Intermittent NPE at screen renderring

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.