Jump to content

When do forge registries freeze?


Gogo1234

Recommended Posts

I want to initialize things to DeferredRegisters, but not statically.

public static final RegistryObject<Block> bonzanium_casing=register.register(BonzaniumCasing.class.getAnnotation(Register.class).id(),()->new BonzaniumCasing());

↑ This is what I don't want

I want something like this ↓

public static final RegistryObject<Block> bonzanium_casing=register(new BonzaniumCasing());

protected static final RegistryObject<Block> register(Block block){

        if(block.getClass().isAnnotationPresent(Register.class)){
            Register reg = block.getClass().getAnnotation(Register.class);
            String id=reg.id();
            return register.register(id,()->block);
        }else {
            Internal.LOGGER.warn("Block {} has no @Register annotation",block.getClass().getName());
            return null;
        }
    }

Whenever I try to do something like that i get the following error?

Caused by: java.lang.IllegalStateException: Registry is already frozen

Why does that happen? When do the registries freeze?

Edited by Gogo1234
Link to comment
Share on other sites

  • Gogo1234 changed the title to When do forge registries freeze?

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.