Skip to content

[1.21] Custom materials can't be registered #4381

@jurrejelle

Description

@jurrejelle

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

1.21 latest

Minecraft Version

1.21.1 NeoForge

Recipe Viewer Installed

None

Environment

Singleplayer

Cross-Mod Interaction

Yes

Other Installed Mods

dev env

Expected Behavior

Registering a material with

StartupEvents.registry('gtceu:material', event => {
    event.create('gtceu:soul_stained_alumina')
        .color(0xdb3dff).secondaryColor(0xe683fc)
        .ingot()
})

works

Actual Behavior

It doesn't

Steps to Reproduce

see above

Additional Information

it seems what's happening is

All of the problems are likely in CommonInit
Since our onRegister runs when any registry event is fired, GTM materials register just fine during that call, before the RegisterMaterials event is called
Since it has Priority.HIGH on the RegisterEvent, onRegisterEarly runs before any actual registering to the registries by KJS takes place, which closes the material registry
Only then, after the registry is closed, the addon material registration is ran

I think there's a few options here:
I manually call the neoforge material registration event during onRegister after initMaterials
I move material registration to a different event and call that
I move the closing of the material registry to a RegisterEventLate with Priority.LOW to run after the material registry stuff

3 seems the neatest option, but that seems to run into problems with other registry events for e.g. items and fluids being fired before the material registry is closed or the postmaterial event is fired

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions