FancyMenu [Fabric] [MOVED TO NEW PROJECT]

FancyMenu [Fabric] [MOVED TO NEW PROJECT]

17M Downloads

NullPointerException because GuiScreenEvent$DrawScreenEvent$Post.getGui() is null

Fourmisain opened this issue ยท 3 comments

commented

Describe the bug
Using the F3+F4 menu to switch game modes consistently causes a NullPointerException due to de.keksuccino.konkrete.events.client.GuiScreenEvent$DrawScreenEvent$Post.getGui() being null.

To Reproduce
Steps to reproduce the behavior:

  1. Boot Minecraft
  2. Load any world with cheats enabled
  3. Press F3+F4 to switch the game mode
  4. Observe the error

Expected behavior
No error

Crash Log

[22:12:02] [Render thread/INFO]: [STDOUT]: ################# ERROR [KONKRETE] #################
[22:12:02] [Render thread/INFO]: [STDOUT]: Failed to invoke event!
[22:12:02] [Render thread/INFO]: [STDOUT]: Event Subscription Class: class de.keksuccino.fancymenu.menu.fancy.helper.CustomizationHelper
[22:12:02] [Render thread/INFO]: [STDOUT]: Event Subscription Method Name: onRenderPost
[22:12:02] [Render thread/INFO]: [STDOUT]: Event Name: de.keksuccino.konkrete.events.client.GuiScreenEvent$DrawScreenEvent$Post
[22:12:02] [Render thread/INFO]: [STDOUT]: ####################################################
[22:12:02] [Render thread/INFO]: [STDOUT]: 
[22:12:02] [Render thread/INFO]: [STDERR]: java.lang.reflect.InvocationTargetException
[22:12:02] [Render thread/INFO]: [STDERR]: 	at jdk.internal.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at de.keksuccino.konkrete.events.EventHandler.invokeEvent(EventHandler.java:115)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at de.keksuccino.konkrete.events.EventHandler.callEventsFor(EventHandler.java:105)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.minecraft.class_757.handler$zjo000$afterRenderScreen(class_757.java:2066)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.minecraft.class_757.method_3192(class_757.java:881)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.minecraft.class_310.method_1523(class_310.java:1143)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.minecraft.class_310.method_1514(class_310.java:734)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.minecraft.client.main.Main.main(Main.java:237)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
[22:12:02] [Render thread/INFO]: [STDERR]: 	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
[22:12:02] [Render thread/INFO]: [STDERR]: Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because the return value of "de.keksuccino.konkrete.events.client.GuiScreenEvent$DrawScreenEvent$Post.getGui()" is null
[22:12:02] [Render thread/INFO]: [STDERR]: 	at de.keksuccino.fancymenu.menu.fancy.helper.CustomizationHelper.onRenderPost(CustomizationHelper.java:56)
[22:12:02] [Render thread/INFO]: [STDERR]: 	... 13 more
[22:12:02] [Server thread/INFO]: [Fourmisain: Set own game mode to Creative Mode]
[22:12:02] [Render thread/INFO]: [CHAT] Set own game mode to Creative Mode

Basic Informations:

  • OS: Windows
  • FancyMenu Version 2.8.0-1
  • Fabric Version 0.14.8
  • Minecraft Version 1.19
  • Active Mods: Only Konkrete 1.3.3 and Fabric API 0.56.1
  • Launcher: Vanilla

Additional Notes:
This is most likely the exact same issue as Keksuccino/Konkrete#5 and Keksuccino/Konkrete#9.

The error happens after letting go of F3+F4 and hence closing the screen, meaning Minecraft.getInstance().screen will be null at this point.

These are the only two lines in Konkrete which create DrawScreenEvent.Post and they use Minecraft.getInstance().screen:
https://github.com/Keksuccino/Konkrete/blob/ba749500455e44d6e7f6dcd85c26d44162d47b89/src/main/java/de/keksuccino/konkrete/mixin/mixins/client/MixinGameRenderer.java#L43
https://github.com/Keksuccino/Konkrete/blob/ba749500455e44d6e7f6dcd85c26d44162d47b89/src/main/java/de/keksuccino/konkrete/mixin/mixins/client/MixinGameRenderer.java#L61

I'm not sure why screen doesn't seem to be null when closing other screens like the inventory screen, but the easiest fix for this issue is probably just adding a null check in both instances (or in FancyMenu here).

commented

This should be fixed in Konkrete v1.3.3-3. Please report back if it's working now :)

commented

Looks fixed to me!
Tried it with a few different screens and the error doesn't appear anymore.

commented

Nice, thank you for reporting it! :)