Topic category: Troubleshooting, bugs, and solutions
My custom code works perfectly in intelliJ, but when I put the same code in Mcreator, it gives this error:
Failure message: api_test (api_test) encountered an error during the construct event phase
java.lang.NullPointerException: Cannot invoke "net.minecraft.client.gui.Font.width(net.minecraft.network.chat.FormattedText)" because "net.minecraft.client.Minecraft.getInstance().font" is null
Exception message: java.lang.NullPointerException: Cannot invoke "net.minecraft.client.gui.Font.width(net.minecraft.network.chat.FormattedText)" because "net.minecraft.client.Minecraft.getInstance().font" is null
Stacktrace:
at me.shedaniel.clothconfig2.gui.entries.TextFieldListEntry.<init>(TextFieldListEntry.java:85) ~[cloth-config-forge-11.1.118_mapped_official_1.20.1.jar%23198!/:?] {re:classloading,pl:runtimedistcleaner:A}
at me.shedaniel.clothconfig2.gui.entries.AbstractNumberListEntry.<init>(AbstractNumberListEntry.java:59) ~[cloth-config-forge-11.1.118_mapped_official_1.20.1.jar%23198!/:?] {re:classloading}
at me.shedaniel.clothconfig2.gui.entries.IntegerListEntry.<init>(IntegerListEntry.java:51) ~[cloth-config-forge-11.1.118_mapped_official_1.20.1.jar%23198!/:?] {re:classloading,pl:runtimedistcleaner:A}
at me.shedaniel.clothconfig2.impl.builders.IntFieldBuilder.build(IntFieldBuilder.java:105) ~[cloth-config-forge-11.1.118_mapped_official_1.20.1.jar%23198!/:?] {re:classloading,pl:runtimedistcleaner:A}
at net.mcreator.apitest.procedures.ModConfigProcedure.execute(ModConfigProcedure.java:47) ~[%23196!/:?] {re:classloading}
at net.mcreator.apitest.procedures.ModConfigProcedure.execute(ModConfigProcedure.java:34) ~[%23196!/:?] {re:classloading}
at net.mcreator.apitest.procedures.ModConfigProcedure.init(ModConfigProcedure.java:29) ~[%23196!/:?] {re:classloading}
at net.mcreator.apitest.procedures.__ModConfigProcedure_init_FMLConstructModEvent.invoke(.dynamic) ~[%23196!/:?] {re:classloading,pl:eventbus:B}
Code:ConfigCategory general = builder.getOrCreateCategory(Component.literal("general"));
ConfigCategory preview = builder.getOrCreateCategory(Component.literal("preview"));
builder.setTitle(Component.literal("My Mod Config"));
builder.setDefaultBackgroundTexture(new ResourceLocation("minecraft:textures/block/stone.png"));
general.addEntry(entryBuilder.startIntField(Component.literal("Field int"), 10).setDefaultValue(10).setMin(0).setMax(100).build();
What is the problem with code?