Forge Config API Port

Forge Config API Port

29M Downloads

[Bug]: Crash when editing "defineInList" config value in "Configured" integration UI

zomabies opened this issue ยท 1 comments

commented

Mod Loader (Required)

Fabric

Minecraft Version (Required)

1.19.2

Mod Version (Required)

4.2.9

Notes (Required)

When using the "Configured" UI to modify defineInList config value, it crashes the client with a null exception.

Description: keyPressed event handler

java.lang.NullPointerException: keyPressed event handler
	at java.base/java.util.Objects.requireNonNull(Unknown Source)
	at java.base/java.util.Optional.of(Unknown Source)
	at net.minecraftforge.configured.ReflectionHelper.get(ReflectionHelper.java:72)
	at net.minecraftforge.configured.ForgeValue.loadRange(ForgeValue.java:179)
	at net.minecraftforge.configured.ForgeValue.getValidationHint(ForgeValue.java:118)
	at com.mrcrayfish.configured.client.screen.ConfigScreen$StringItem.lambda$new$0(ConfigScreen.java:637)
	at com.mrcrayfish.configured.client.screen.EditStringScreen.updateValidation(EditStringScreen.java:77)
	at com.mrcrayfish.configured.client.screen.EditStringScreen.lambda$init$0(EditStringScreen.java:55)
	at net.minecraft.class_342.method_1874(class_342.java:151)
	at net.minecraft.class_342.method_1883(class_342.java:257)
	at net.minecraft.class_342.method_1878(class_342.java:201)
	at net.minecraft.class_342.method_16873(class_342.java:159)
	at net.minecraft.class_342.method_25404(class_342.java:320)
	at net.minecraft.class_4069.method_25404(class_4069.java:65)
	at net.minecraft.class_437.method_25404(class_437.java:124)
	at net.minecraft.class_309.method_1454(class_309.java:374)
	at net.minecraft.class_437.method_25412(class_437.java:489)
	at net.minecraft.class_309.method_1466(class_309.java:370)
	at net.minecraft.class_309.method_22678(class_309.java:462)
	at net.minecraft.class_1255.execute(class_1255.java:103)
	at net.minecraft.class_309.method_22676(class_309.java:462)
	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.flipFrame(RenderSystem.java:197)

Code for reproduction

ForgeConfigSpec.ConfigValue<String> value;

List<String> selection = List.of("1", "2", "3");
value = builder
        .comment("Test selection", "Valid value: ", String.join(", ", selection))
        .defineInList("choice", "2", selection);

Cause

On line 179 in ForgeValue, ReflectionHelper#get calls Optional#of instead of Optional#ofNullable.

Optional<Object> range = ReflectionHelper.get(ReflectionHelper.getDeclaredField(ForgeConfigSpec.ValueSpec.class, "range"), this.valueSpec);

1.20 branch might be affected

latest.log (Optional)

No response

commented

Thanks, fixed in the latest version.