Jump to content

Creating a Custom Registry


Syric

Recommended Posts

I want to make a custom registry for ingredients. I have an 'Ingredient' class defined.

From the main mod class (emphasis added with !):

public Alchemine() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;

        // Register the commonSetup method for modloading
        modEventBus.addListener(this::commonSetup);
        forgeEventBus.addListener(this::handleFog);
        forgeEventBus.addListener(this::handleFogColor);

!       registry.register();


        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

Then from the registry utility class:

public static void register() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        AlchemineBlocks.register(modEventBus);
        AlchemineItems.register(modEventBus);
        AlchemineBlockEntityTypes.register(modEventBus);
!       AlchemicalIngredients.register(modEventBus);
    }

I don't think the problem's with either of those, but they're there for completeness. Finally, the AlchemicalIngredients class:

public class AlchemicalIngredients {

    private static boolean isInitialized = false;

    public static final DeferredRegister<Ingredient> INGREDIENTS = DeferredRegister.create(new ResourceLocation(Alchemine.MODID, "Ingredients"), Alchemine.MODID);


    public static void register(final IEventBus modEventBus) {
        if (isInitialized) {
            throw new IllegalStateException("Ingredients already initialized");
        }
        INGREDIENTS.makeRegistry(RegistryBuilder::new);
        INGREDIENTS.register(modEventBus);
        isInitialized = true;
        LogManager.getLogManager().getLogger(Alchemine.MODID).info("Registered ingredients");
    }
}

 

When I try to run the game, though, I get this crash report, complaining about: 

---- Minecraft Crash Report ----
// You're mean.

Time: 6/20/22, 1:48 AM
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
	at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:55) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2389%2396!/:?] {re:classloading}
	at net.minecraftforge.client.loading.ClientModLoader.completeModLoading(ClientModLoader.java:170) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2389%2396!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.lambda$new$1(Minecraft.java:553) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.Util.ifElse(Util.java:432) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading}
	at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:547) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.LoadingOverlay.render(LoadingOverlay.java:135) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:885) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1071) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:661) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:24) ~[fmlloader-1.19-41.0.17.jar%230!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.6.jar%2310!/:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraft.resources.ResourceLocation.<init>(ResourceLocation.java:37) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading}
-- MOD alchemine --
Details:
	Caused by 0: java.lang.reflect.InvocationTargetException
		at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:79) ~[?:?] {}
		at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?] {}
		at java.lang.reflect.Constructor.newInstance(Constructor.java:483) ~[?:?] {}
		at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19-41.0.17.jar%2391!/:?] {}
		at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19-41.0.17.jar%2394!/:?] {}
		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 1: java.lang.ExceptionInInitializerError
		at syric.alchemine.setup.registry.register(registry.java:17) ~[%2395!/:?] {re:classloading}
		at syric.alchemine.Alchemine.<init>(Alchemine.java:45) ~[%2395!/:?] {re:classloading}
		at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) ~[?:?] {}
		at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?] {}
		at java.lang.reflect.Constructor.newInstance(Constructor.java:483) ~[?:?] {}
		at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19-41.0.17.jar%2391!/:?] {}
		at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19-41.0.17.jar%2394!/:?] {}
		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) ~[?:?] {}

	Mod File: main
	Failure message: Alchemine (alchemine) has failed to load correctly
		java.lang.reflect.InvocationTargetException: null
	Mod Version: 0.0NONE
	Mod Issue URL: NOT PROVIDED
	Exception message: net.minecraft.ResourceLocationException: Non [a-z0-9/._-] character in path of location: alchemine:Ingredients
Stacktrace:
	at net.minecraft.resources.ResourceLocation.<init>(ResourceLocation.java:37) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading}
	at net.minecraft.resources.ResourceLocation.<init>(ResourceLocation.java:46) ~[forge-1.19-41.0.17_mapped_official_1.19-recomp.jar%2390!/:?] {re:classloading}
	at syric.alchemine.brewing.ingredients.AlchemicalIngredients.<clinit>(AlchemicalIngredients.java:19) ~[%2395!/:?] {re:classloading}
	at syric.alchemine.setup.registry.register(registry.java:17) ~[%2395!/:?] {re:classloading}
	at syric.alchemine.Alchemine.<init>(Alchemine.java:45) ~[%2395!/:?] {re:classloading}
	at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) ~[?:?] {}
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?] {}
	at java.lang.reflect.Constructor.newInstance(Constructor.java:483) ~[?:?] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19-41.0.17.jar%2391!/:?] {}
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19-41.0.17.jar%2394!/:?] {}
	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) ~[?:?] {}


-- System Details --
Details:
	Minecraft Version: 1.19
	Minecraft Version ID: 1.19
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 18.0.1.1, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
	Memory: 824614400 bytes (786 MiB) / 1409286144 bytes (1344 MiB) up to 2116026368 bytes (2018 MiB)
	CPUs: 8
	Processor Vendor: GenuineIntel
	Processor Name: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
	Identifier: Intel64 Family 6 Model 142 Stepping 10
	Microarchitecture: Coffee Lake
	Frequency (GHz): 1.80
	Number of physical packages: 1
	Number of physical CPUs: 4
	Number of logical CPUs: 8
	Graphics card #0 name: NVIDIA GeForce MX150
	Graphics card #0 vendor: NVIDIA (0x10de)
	Graphics card #0 VRAM (MB): 2048.00
	Graphics card #0 deviceId: 0x1d10
	Graphics card #0 versionInfo: DriverVersion=26.21.14.4223
	Graphics card #1 name: Intel(R) UHD Graphics 620
	Graphics card #1 vendor: Intel Corporation (0x8086)
	Graphics card #1 VRAM (MB): 1024.00
	Graphics card #1 deviceId: 0x5917
	Graphics card #1 versionInfo: DriverVersion=23.20.16.5038
	Memory slot #0 capacity (MB): 8192.00
	Memory slot #0 clockSpeed (GHz): 1.60
	Memory slot #0 type: DDR3
	Virtual memory max (MB): 19066.14
	Virtual memory used (MB): 15878.22
	Swap memory total (MB): 10996.92
	Swap memory used (MB): 2259.47
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 9.1.6+9.1.6+main.14b0cc03
	ModLauncher launch target: forgeclientuserdev
	ModLauncher naming: mcp
	ModLauncher services: 
		 mixin PLUGINSERVICE 
		 eventbus PLUGINSERVICE 
		 slf4jfixer PLUGINSERVICE 
		 object_holder_definalize PLUGINSERVICE 
		 runtime_enum_extender PLUGINSERVICE 
		 capability_token_subclass PLUGINSERVICE 
		 accesstransformer PLUGINSERVICE 
		 runtimedistcleaner PLUGINSERVICE 
		 mixin TRANSFORMATIONSERVICE 
		 fml TRANSFORMATIONSERVICE 
	FML Language Providers: 
		[email protected]
		lowcodefml@null
		javafml@null
	Mod List: 
		forge-1.19-41.0.17_mapped_official_1.19-recomp.jar|Minecraft                     |minecraft                     |1.19                |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
		                                                  |Forge                         |forge                         |41.0.17             |COMMON_SET|Manifest: NOSIGNATURE
		main                                              |Alchemine                     |alchemine                     |0.0NONE             |ERROR     |Manifest: NOSIGNATURE
	Crash Report UUID: 357be982-9699-4897-8441-d3d03af22f28
	FML: 41.0
	Forge: net.minecraftforge:41.0.17

 

From what I can tell, I've screwed something up with the ResourceLocation, which is to be expected considering I'm not entirely sure what I'm doing in that department. Any help would be appreciated.

Link to comment
Share on other sites

8 hours ago, diesieben07 said:

It tells you exactly what is wrong.

Yeah, I saw that and assumed it was referring to the ':', which I didn't have any control over, so I didn't know what it wanted me to do about it.

...but on second thought it's because I capitalized 'Ingredients', isn't it.

Edit: yes it was (and also I used the wrong logger. oops)

Edited by Syric
Link to comment
Share on other sites

14 minutes ago, Luis_ST said:

does it work now, this should answer the question for your own

Oops, forgot to update the post. The question was rhetorical; I was not actually seeking an answer on something so easily done myself.

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.



×
×
  • Create New...

Important Information

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