Controlify

Controlify

609k Downloads

[Bug/Crash] Minecraft will crash upon pressing F3+Esc in a singleplayer world with this mod.

fintmc opened this issue ยท 1 comments

commented

Current Behaviour

When you press F3+Esc in minecraft, it will pause the world but not show the menu screen, instead it will show a message saying "Game paused" or something similar. When using this mod, the game will instead crash with the logs below.

Expected Behaviour

Pressing F3+Esc will show the pause screen and not crash.

Screenshots

No response

Reproduction Steps

Using Minecraft 1.20.1, Fabric 0.15.6, Fabric API 0.90.0+1.20.1, YetAnotherConfigLib 3.2.1+1.20
Originally found with FabulouslyOptimized modpack, later tested with the configs above on default MC settings.

  1. Open an existing or create a new singleplayer world with the mod.
  2. Press F3+Esc

Logs

---- Minecraft Crash Report ----
// Oops.

Time: 2024-02-03 08:52:55
Description: Unexpected error

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.orElseThrow(Optional.java:377)
	at dev.isxander.controlify.screenop.compat.vanilla.PauseScreenProcessor.onWidgetRebuild(PauseScreenProcessor.java:40)
	at net.minecraft.class_437.handler$zcb000$controlify$onScreenInitialInit(class_437.java:1169)
	at net.minecraft.class_437.method_25423(class_437.java:297)
	at net.minecraft.class_310.method_1507(class_310.java:1080)
	at net.minecraft.class_310.method_20539(class_310.java:1672)
	at net.minecraft.class_309.method_1466(class_309.java:430)
	at net.minecraft.class_309.method_22678(class_309.java:477)
	at net.minecraft.class_1255.execute(class_1255.java:102)
	at net.minecraft.class_309.method_22676(class_309.java:477)
	at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:44)
	at org.lwjgl.system.JNI.invokeV(Native Method)
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3403)
	at com.mojang.blaze3d.systems.RenderSystem.pollEvents(RenderSystem.java:201)
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:212)
	at net.minecraft.class_1041.method_15998(class_1041.java:288)
	at net.minecraft.class_310.method_1523(class_310.java:1241)
	at net.minecraft.class_310.method_1514(class_310.java:802)
	at net.minecraft.client.main.Main.main(Main.java:250)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:243)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:278)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)

Mod Version

1.6.0+1.20

Controller

none used

Bluetooth

  • Yes

Operating System

Linux/SteamOS

ARM

  • Yes

Additional Information

Before you say anything, I was unable to use the latest version of Minecraft to do the tests and I did look into the code before submitting this report.

Analyzing the stacktrace I figured it must be an issue where dev.isxander.controlify.screenop.compat.vanilla.PauseScreenProcessor.onWidgetRebuild at PauseScreenProcessor.java:40 calls Optional.orElseThrow(), which crashes the game. Looking into the code I found that on line 41 of the file, it tries to call getWidget("menu.returnToGame") and if not found error out (.orElseThrow()):

// src/main/java/dev/isxander/controlify/screenop/compat/vanilla/PauseScreenProcessor.java
...
/* 39 */      if (screen.showsPauseMenu()) {
/* 40 */          ButtonGuideApi.addGuideToButtonBuiltin(
/* 41 */                  (AbstractButton) getWidget("menu.returnToGame").orElseThrow(),
                                        // ^ here                         ^ crash is from here
/* 42 */                  bindings -> bindings.GUI_BACK,
/* 43 */                  ButtonRenderPosition.TEXT,
/* 44 */                  ButtonGuidePredicate.ALWAYS
/* 45 */          );
...

But since the F3+Esc pause screen doesn't have buttons, the getWidget() call will return an empty value and cause a crash.

If anyone could, please test this issue on newer versions of MC, because the code is still present it is also an issue with the newer versions.

Just to make sure...

  • I have made sure I am using the latest version of Controlify for the latest version of Minecraft.
  • I have made sure there are no other issues describing the same problem on the issue tracker.
commented

just realized that it will also crash on line 47 too for the same reason on the f3+esc screen