Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.18.2] Custom JSON recipe causing Init error


Recommended Posts

Hi,

I have begun to port my mod from 1.18.1 to 1.18.2 and my custom JSON recipe system is stopping me from loading the game up at the moment. Everything worked in 1.18.1, but I know that the minor version change actually had major changes behind the scenes, so Im wondering if anyone knows what my issue is.

CraftingManager.java

Spoiler

package com.tcn.dimensionalpocketsii.core.management;

import com.tcn.cosmoslibrary.CosmosLibrary;
import com.tcn.cosmoslibrary.common.runtime.CosmosRuntimeHelper;
import com.tcn.dimensionalpocketsii.DimensionalPockets;
import com.tcn.dimensionalpocketsii.core.crafting.UpgradeStationRecipe;

import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

@Mod.EventBusSubscriber(modid = DimensionalPockets.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
public class CraftingManager {

    public static final RecipeSerializer<UpgradeStationRecipe> RECIPE_SERIALIZER_UPGRADE_STATION = new UpgradeStationRecipe.Serializer();
    public static final RecipeType<UpgradeStationRecipe> RECIPE_TYPE_UPGRADE_STATION = RecipeType.register(DimensionalPockets.MOD_ID + ":upgrading");
    
    @SubscribeEvent
    public static void onRecipeSerializerRegistry(final RegistryEvent.Register<RecipeSerializer<?>> event) {
        event.getRegistry().registerAll(
            CosmosRuntimeHelper.setupString(DimensionalPockets.MOD_ID, "upgrading", RECIPE_SERIALIZER_UPGRADE_STATION)
        );

        CosmosLibrary.CONSOLE.startup("RecipeSerializer<?> Registration complete.");
    }
}

I am assuming that Mojang has locked the vanilla Recipe Type system, but I cannot seem to find an alternative.

Crash Report (Snippet):

Spoiler

[21:46:55] [modloading-worker-0/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Failed to register automatic subscribers. ModID: dimensionalpocketsii, class com.tcn.dimensionalpocketsii.DimensionalPockets
java.lang.ExceptionInInitializerError: null
    at java.lang.Class.forName0(Native Method) ~[?:?] {}
    at java.lang.Class.forName(Class.java:467) ~[?:?] {}
    at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.lambda$inject$6(AutomaticEventSubscriber.java:61) ~[javafmllanguage-1.18.2-40.1.0.jar%2377!/:?] {}
    at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {}
    at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:48) ~[javafmllanguage-1.18.2-40.1.0.jar%2377!/:?] {}
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:77) ~[javafmllanguage-1.18.2-40.1.0.jar%2377!/:?] {}
    at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:106) ~[fmlcore-1.18.2-40.1.0.jar%2379!/:?] {}
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?] {}
    at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) [?:?] {}
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) [?:?] {}
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) [?:?] {}
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) [?:?] {}
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) [?:?] {}
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) [?:?] {}
Caused by: java.lang.IllegalStateException: Registry is already frozen (trying to add key ResourceKey[minecraft:recipe_type / dimensionalpocketsii:upgrading])
    at net.minecraft.core.MappedRegistry.validateWrite(MappedRegistry.java:78) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.core.MappedRegistry.registerMapping(MappedRegistry.java:87) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.core.MappedRegistry.registerMapping(MappedRegistry.java:83) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.core.MappedRegistry.register(MappedRegistry.java:129) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.core.Registry.register(Registry.java:564) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.core.Registry.register(Registry.java:560) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at net.minecraft.world.item.crafting.RecipeType.register(RecipeType.java:20) ~[forge-1.18.2-40.1.0_mapped_official_1.18.2.jar%2376!/:?] {re:classloading}
    at com.tcn.dimensionalpocketsii.core.management.CraftingManager.<clinit>(CraftingManager.java:19) ~[%2380!/:1.18.1-5.1.1.60-universal] {re:classloading}
    ... 14 more
[21:46:55] [modloading-worker-0/DEBUG] [ne.mi.fm.co.ConfigTracker/CONFIG]: Config file jei-server.toml for jei tracking

 

Ive been out of the scene for a few months, so am not in the loop with major changes, so go easy :) Thanks in advance

Link to comment
Share on other sites

51 minutes ago, diesieben07 said:

Use DeferredRegister for all registrations.

Note that your registration was already incorrect in 1.18.1 and before.

 

Okay thanks, I need to wrap my head around this new system. Do I use this for *literally* everything? MenuTypes, BlockEntityTypes etc?

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.