Jump to content

Custom RecipeBookType cause game to crash


yusufgamer

Recommended Posts

I tried creating my own RecipeBookType

 

enum class RecipeBookTypeInit {
    ARMOUR_CRAFTING;

    /** Returns the recipe book type for this container. */
    fun get(): RecipeBookType {
        return RecipeBookType.create(name.lowercase().replace("_", ""))
    }
}

 

But when i run the game click on my custom crafting table gui it crashes and i get an out of bond exception

java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
	at java.util.EnumMap.get(EnumMap.java:244) ~[?:?] {}
	at net.minecraft.stats.RecipeBookSettings.isOpen(RecipeBookSettings.java:30) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading}
	at net.minecraft.stats.RecipeBook.isOpen(RecipeBook.java:69) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading}
	at net.minecraft.client.gui.screens.recipebook.RecipeBookComponent.isVisibleAccordingToBookData(RecipeBookComponent.java:162) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.recipebook.RecipeBookComponent.tick(RecipeBookComponent.java:240) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at io.github.realyusufismail.armourandtoolsmod.core.blocks.armour.CustomArmourCraftingTableScreen.containerTick(CustomArmourCraftingTableScreen.kt:79) ~[main/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.tick(AbstractContainerScreen.java:631) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.lambda$tick$39(Minecraft.java:1830) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:530) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.tick(Minecraft.java:1829) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1123) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:718) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.run(Main.java:212) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:51) ~[forge-1.19.3-44.1.0_mapped_parchment_2022.12.18-1.19.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:25) ~[fmlloader-1.19.3-44.1.0.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.8.jar:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {}

In there error it refers to CustomArmourCraftingTableScreen recipeBookComponent. Do i need to create my own?

CustomArmourCraftingTableScreen full code : https://github.com/RealYusufIsmail/Armour-and-Tools-Mod/blob/1.19.3-1.0.0.alpha.5/src/main/kotlin/io/github/realyusufismail/armourandtoolsmod/core/blocks/armour/CustomArmourCraftingTableScreen.kt

 

Link to comment
Share on other sites

You can't create new enum values lazily.

You need to create them as singletons as early as possible so that other code knows it exists.

See for example the RecipeBookSettings contructor. It loops over all known enum values and creates information.

If it doesn't know your enum value exists at that point it won't create one for your enum value and you will get errors like the one you show.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

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.

Announcements



×
×
  • Create New...

Important Information

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