#"Registry is already frozen" error

168 messages · Page 1 of 1 (latest)

icy halo
#

I'm working on a system to retrieve the length of sounds. I already have a system to cache the lengths into a JSON file using datagen, and I get the following error: java.util.concurrent.CompletionException: java.lang.IllegalStateException: Registry is already frozen (trying to add key ResourceKey[minecraft:sound_event / darkwest:conner_voiceline])
I've tried everything to solve it. Restructuring my asset loading, moving to Fabric's ResourceManagerHelper instead of my own weird custom asset loading. The only GitHub issue I've seen regarding this error says I need Fabric API to solve it, but I am literally depending on Fabric API and I'm still getting this error.

Here's my SoundsResourceReloader class: https://pastebin.com/fyq0ynvb

I'm registering it in my ModInitializer

ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES)
                .registerReloadListener(new SoundsResourceReloader());

I've tried registering all the sounds separately outside the resource reloader (in onInitialize) and only loading the data inside the reload listener but I got the same error. Calling Registry.register doesn't work for any of my sounds.

PS: please ping when replying!! sorry if i reply a bit late im going to bed after posting this

median plank
#

@icy halo you can't register sounds outside your mod initialization timeframe. The registries are indeed frozen after that

#

resources are loaded (and re-loaded) why after that

icy halo
#
public class DarkWestMod implements ModInitializer {
    @Override
    public void onInitialize() {
        // Asset loading
        ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES)
                .registerReloadListener(new SoundsResourceReloader());

        // Getting/registering data
        for (ModSound sound : ModSound.values()) {
            if (Registries.SOUND_EVENT.get(sound.id) == null) {
                sound.event = SoundEvent.of(sound.id);
                Registry.register(Registries.SOUND_EVENT, sound.id, sound.event);
            }
        }
    }
}

This is enough to trigger that error

#

like sorry for the colourful language but what the fuck, I am calling Registry.register in onInitialize

#

And there are only about 8 of those sounds, so its not like its getting stuck in a for loop

#

The error disappears if i remove that Registry.register line

#

the Fabric docs also say you can register stuff inside the apply function for resource reloaders but im not sure thats safe

median plank
#

You are registerng the sounds in your reload listenr too

median plank
icy halo
icy halo
#

it was a dumb mistake on my end to try to register stuff during the resource reloader since i don't need to register anything dynamically

#

problem is

#

I am no longer registering stuff during the resource reloader

#

and I'm still getting that exact same error

median plank
#

please post your current/real code and the full stack trace of the exception you are getting now

icy halo
#

It... It won't update my code

#

unless I clean my entire gradle project

#

and re-build again

#

that is, what????

#

that might be why i kept getting this error regardless of what I tried

#

I cleaned out my project and that error disappeared

icy halo
#

nope

#

still getting that error

#
[16:31:48] [Render thread/ERROR] (Minecraft) Error executing task on Client
 java.lang.IllegalStateException: Registry is already frozen (trying to add key ResourceKey[minecraft:sound_event / darkwest:conner_voiceline])
    at net.minecraft.registry.SimpleRegistry.assertNotFrozen(SimpleRegistry.java:143) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.registry.SimpleRegistry.set(SimpleRegistry.java:143) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.registry.SimpleRegistry.add(SimpleRegistry.java:178) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.registry.Registry.register(Registry.java:317) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.registry.Registry.register(Registry.java:308) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at flooferland.darkwest.sound.ModSound.registerSoundEvent(ModSound.java:55) ~[main/:?]
    at flooferland.darkwest.sound.ModSound.registerSounds(ModSound.java:74) ~[main/:?]
    at flooferland.darkwest.DarkWestMod.lambda$onInitialize$0(DarkWestMod.java:32) ~[main/:?]
    at flooferland.darkwest.DarkWestMod$$Lambda$4823/0x000000002095f4b0.run(Unknown Source) ~[?:?]
    at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor.java:149) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor.java:29) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor.java:126) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor.java:120) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1171) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:838) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.minecraft.client.main.Main.main(Main.java:237) ~[minecraft-merged-cf7b7e01a4-1.20.4-net.fabricmc.yarn.1_20_4.1.20.4+build.3-v2.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) ~[fabric-loader-0.15.10.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) ~[fabric-loader-0.15.10.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.15.10.jar:?]
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) ~[dev-launch-injector-0.2.1+build.8.jar:?]
#

thats the full stack trace

#

.. and its referencing a method that no longer exists... ModSound.registerSounds
great

#

I have cleaned out and recompiled my entire gradle project and I'm getting an error regarding a method that no longer exists

#

.\gradlew clean doesn't seem to actually clean the gradle folder NanaPoker

median plank
#

Clean cleans the build directory

icy halo
#

I don't get whats going on

#

wait huh i could've sworn i updated something

#

sorry, everything is being weird

#

I'm getting an error saying EVERY SINGLE sound and asset from the game is missing

#

what

#

all i did was run .\gradlew clean, delete .gradle in my user profile and my project, and I ran .\gradlew build and opened up my project and ran it

#

and im now getting an error when running the project saying fabric-api is missing

icy halo
#

I cleaned and rebuilt twice

#

the game icon is missing and every single sound is missing

#

.... but the game doesn't freeze when it launches now

#

just what the fuck

median plank
#

Your dev env is messed up

#

Close idea, deletethe build and .idea direcotries

#

Re import your Gradle project from scratch

icy halo
#

i swear

#

I can't delete it

#

I'm literally the administrator

#

I am that account

#

it asks me for administrator perms, then tells me i do not have permission

#

weird

#

that was just Microsoft File Explorer being garbage tho nvm

median plank
#

Not really but ok

icy halo
#

nah it was

#

I've used file explorer for basically my entire life

#

i was able to delete it by running rm in an administrator shell

#

idk why my .idea folder keeps breaking everything

#

This is the like 5th time I've deleted that folder and set up my project again

median plank
#

Is your main project directory inside an onedrive managed folder?

icy halo
#

thankfully i do not use OneDrive

#

That issue is solved

#

Registry is already frozen is not

icy halo
#

ModSound.registerSoundEvent and ModSound.registerSounds no longer exist

#

Why is it giving me an error about 2 functions that no longer even exist

#

even after cleaning out the cache and reloading everything

#

i cleaned out the .gradle under my user profile too

icy halo
#

i don't know what to do

#

This issue is insane

#

Some code that no longer exists is giving me an error even after literally cleaning out my entire project

#

unless its just the stack trace thats bugged out idk

#

BUT EVEN IF ITS THE STACK TRACE

#

HOW DOES IT REMEMBER A METHOD ITS NEVER SEEN

#

AND REGARDLESS

#

If it's just the stack trace it means this issue is even more fucked up

icy halo
#

Sorry I am very angry

#

but this makes no fucking sense

#

This mod does the exact thing i was doing

#

it registers stuff in onInitialize

#

and stores the things that need to be registered inside an enum

median plank
#

post your DarkWestMod class

#

(the whole text)

icy halo
#
package flooferland.darkwest;

import flooferland.darkwest.block.ModBlocksComplex;
import flooferland.darkwest.block.ModBlocks;
import flooferland.darkwest.entity.ModEntities;
import flooferland.darkwest.event.ServerTickHandler;
import flooferland.darkwest.item.ModItemGroups;
import flooferland.darkwest.item.ModItems;
import flooferland.darkwest.resource.SoundsResourceReloader;
import flooferland.darkwest.sound.ModSound;
import flooferland.darkwest.util.DarkWestEnv;
import flooferland.darkwest.world.gen.ModWorldGeneration;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.ResourceType;
import net.minecraft.sound.SoundEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.bernie.geckolib.GeckoLib;

public class DarkWestMod implements ModInitializer {
    public static final String MOD_ID = "darkwest";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        // Asset loading
        ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES)
                .registerReloadListener(new SoundsResourceReloader());
        
        // Registering content; Making sure classes won't get optimized away
        ModItemGroups.registerItemGroups();
        ModItems.registerItems();
        ModBlocks.registerBlocks();
        ModEntities.registerEntities();
        ModBlocksComplex.registerBlockEntities();
        ModSound.registerSounds();
        ModWorldGeneration.generateWorld();

        // Initializing dependencies
        GeckoLib.initialize();
        
        // Events
        ServerTickEvents.START_SERVER_TICK.register(new ServerTickHandler());
        
        // region | Checking if the optional mods are installed
        if (DarkWestEnv.isToughAsNailsLoaded()) {
            LOGGER.info("Tough As Nails detected");
        }
        // endregion

        // region | Flammables & Fuel
        FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.SHARINGA_LOG, 5, 5);
        FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.STRIPPED_SHARINGA_LOG, 5, 5);
        FlammableBlockRegistry.getDefaultInstance().add(ModBlocks.SHARINGA_PLANKS, 5, 20);
        FuelRegistry.INSTANCE.add(ModBlocks.SHARINGA_LOG, 100);
        FuelRegistry.INSTANCE.add(ModBlocks.STRIPPED_SHARINGA_LOG, 100);
        FuelRegistry.INSTANCE.add(ModBlocks.SHARINGA_PLANKS, 50);
        LOGGER.info("Made logs able to burn (😱) and strip (🤨📸)");
        // endregion
        
        // Should not be used for sharinga stuff, but it may be handy
        // StrippableBlockRegistry.register(ModBlocks.SOME_LOG, ModBlocks.STRIPPED_SOME_LOG);
        
        // Silly message :3
        LOGGER.info("Conner is ready to pay you a visit.");
        
        // Keeps things clean for my mod
        if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
            System.out.println("\n\nDev environment detected.\nClearing the console.." + "\n".repeat(12));
        }
    }
}
#

(ignore the silliness)

#

I moved the registry back into ModSound.registerSounds

icy halo
# icy halo I moved the registry back into `ModSound.registerSounds`
public static void registerSounds() {
    // Getting/registering data
    for (ModSound sound : ModSound.values()) {
        if (Registries.SOUND_EVENT.get(sound.id) == null) {
            sound.event = SoundEvent.of(sound.id);
            Registry.register(Registries.SOUND_EVENT, sound.id, sound.event);
        }
    }
    DarkWestMod.LOGGER.info("Registered the sounds for " + DarkWestMod.MOD_ID);
}
#

The stack trace seems correct now, but I'm not sure if thats just a coincidence

median plank
#

you said in the beginning that you depend on fabric api

#

the whole api or just some modules?

icy halo
#
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
#

i'm not sure what it does but I've kept it from the example project

median plank
#

ok, so it's the whole api

icy halo
#

I've heard it has a registry sync thing

#

ive tried previously importing in the registry sync module separately and it didnt fix it xD

median plank
#

yup. that's the thing that let you register objects in the mc registry system

#

but it is included in the whole api

icy halo
#

I see

median plank
#

flooferland.darkwest.DarkWestMod.lambda$onInitialize$0(DarkWestMod.java:32) ~[main/:?]

#

this is what's bugging me really

#

post the whole crash log somewhere please

#

your fabric.mod.json file too

icy halo
#

i'll dm you it

median plank
#

I don't accept dms

#

use a pastebin website

icy halo
#

k

#

yes i've tried removing the mods I use in my dev environment

#

actually not sure if that fixes it or not

#

its too inconsistent to tell

median plank
#

your fabric.mod.json?

icy halo
#
{
    "schemaVersion": 1,
    "id": "darkwest",
    "version": "${version}",
    "name": "Dark West",
    "description": "The mod for the Conner's Saloon Minecraft server. Some texture art made by OsyDPG (the Conner's Saloon artist)",
    "authors": ["FlooferLand"],
    "contact": {
        "homepage": "https://modrinth.com/mod/darkwest",
        "sources": "https://github.com/FlooferLand/DarkWestMod"
    },
    "license": "MIT",
    "icon": "/icons/icon.png",
    "environment": "*",
    "entrypoints": {
        "main": ["flooferland.darkwest.DarkWestMod"],
        "client": ["flooferland.darkwest.DarkWestClient"],
        "fabric-datagen": ["flooferland.darkwest.DarkWestDataGenerator"]
    },
    "accessWidener": "darkwest.accesswidener",
    "mixins": ["darkwest.mixins.json"],
    "depends": {
        "fabricloader": ">=0.15.10",
        "minecraft": ">=1.20.4",
        "java": ">=17",
        "fabric-api": ">=0.92.0",
        "geckolib": ">=4.4.2"
    },
    "recommends": {
        "toughasnails": "*"
    },
    "suggests": {
        "puddles": "*"
    }
}
#

right i forgot

#

(git repo is private for now)

median plank
# icy halo k

are you sure that this log is the one from the last version of your code?

#

[18:09:30] [Render thread/INFO] (darkwest) Registered the mod's block entities
[18:09:30] [Render thread/INFO] (darkwest) Registering world generation

#

I assume that those lines are printed by registerBlockEntities and generateWorld

#

but you call ModSound.registerSounds() in between

#

You also have a bunch of FileSystemExceptions at the beginning of the log so something is still wrong in your dev env

icy halo
#

doesnt seem important

#

I ran it again

#

and updated the log link i sent

median plank
#

[18:36:18] [Render thread/INFO] (darkwest) Registering the sounds for darkwest
[18:36:18] [Render thread/INFO] (darkwest) Registered the sounds for darkwest
[18:36:18] [Render thread/INFO] (darkwest) Registering world generation

icy halo
#

wait hold up

#

i had some logging saying Beginning to register the mod's sounds in the resource reloader

median plank
#

[18:36:26] [Render thread/INFO] (darkwest) Beginning to register the mod's sounds..

icy halo
#

yep

#

i left that there accidentally while moving code

#

updated again

#

for some reason my data generation is broken and I'm trying to fix that currently

#

I'm not sure if the registry thing is fixed or not

#

.. im not sure what could've even fixed it

#

all i did was move stuff from ModInitializer into a function that ModInitializer calls

median plank
#

it's not crashing there now

#

but it was not crashing there in the first log you posted

icy halo
#

yea it doesnt crash

#

whenever i get the registry error the game just froze up

#

it.. seems fixed?

#

that last error i was having was due to the sounds.json being wrong

#

It wrote the wrong thing to disk, for no apparent reason

#

im just using DataProvider.writeToPath

#

when looking at the actual json data i generated, it was correct

#

but it wasnt writing it to disk for some reason until i deleted the sounds.json inside main/generated

#

oh

#

That registry error is due to a mod I'm using in my dev environment..

#

Not sure where on earth the Error deleting temporary input jar true errors at the beginning come from

icy halo
#

in fact I'm happy this happened because I'm adding it to my breaks in my fabric.mod.json xD

icy halo
#

SO NEVERMIND

#

ITS STILL HAPPENING

#

.. just nvm

warm solar
icy halo
#

oh yee, i did

icy halo
#

still happening to this day

icy halo
warm solar
icy halo
#

I'm pretty sure in my case it was happening because there already was a copy of my mod inside of my mods folder

warm solar
#

Well i am also getting same error in basically empty new development ennv

icy halo
icy halo
#

syncronizational issue of sorts though