Jump to content

1.18.2 Deferred registration and registration timing issue


BrewingCoder

Recommended Posts

I appear to be running into a timing issue; something that I do not experience in a development environment when running Minecraft from IntelliJ but do experience when running outside of development.

 

I get the following error when running outside dev:

[23:53:27] [Worker-Main-20/ERROR]: Exception caught during firing event: Registry Object not present: brewtools:abyssal
	Index: 1
	Listeners:
		0: NORMAL
		1: ASM: class com.brewingcoder.brewtools.world.OreGeneration createConfiguredOreFeature(Lnet/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent;)V
java.lang.NullPointerException: Registry Object not present: brewtools:abyssal
	at java.base/java.util.Objects.requireNonNull(Objects.java:334)

 

Which basically means that the OreGeneration appears to be attempting to register before the blocks?

All of my registrations happen inside the constructor of my Mod Class like so:

public BrewTools()
    {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        Configs.register();
        ModBlocks.register(bus);
        ModItems.register(bus);
        ModSounds.register(bus);
        bus.addListener(this::setup);
        bus.addListener(this::enqueueIMC);
        bus.addGenericListener(BlockEntityType.class,this::registerTileEntities);
        MinecraftForge.EVENT_BUS.register(this);
        MinecraftForge.EVENT_BUS.addListener(EventPriority.LOW, OreGeneration::onBiomeLoadingEvent);
    }

 

as you can see, the Blocks are registering before the Ore Generation features.  The blocks are registered using the typical deferred registry method like so:

 

public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BrewTools.MODID);

public static final RegistryObject<Block> ABYSSAL = registerBlock("abyssal",()-> new Block(defaultProps));
  ....
  
public static void register(IEventBus bus){
        BLOCKS.register(bus);
}

 

Any idea why this is happening?  Especially why it would work in development but not in a non-development environment?

 

-BC

Link to comment
Share on other sites

Sure thing, here's a gist of the error log when running outside of dev:  https://gist.github.com/BrewingCoder/0b4d9bca2b6b6586cd1578e99072b972

The repo is here:  https://github.com/BrewingCoder/BrewTools

This issue only started occurring recently.  The last few commits and builds I've done have been around implementing data generation to replace static files.

Though I do need to do a few more tests reverting back to a lower forge build though -- I just realized that a bump to 40.1.0 was also a recent change.

 

-BC

Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

Your build.gradle cannot be imported, because you have hardcoded requirements for your githubToken and curseToken. You should make these optional so that others can import your repository.

You annotated your ModDataGenerator class with @Mod, so FML takes it as your main mod class and ignores your other @Mod class.

Thank you!! Crap I originally just C/P'd that exact code block from another source and never revisited it; just the actual generators. 

And regarding the tokens;  yes, but you know my mod is like small potatoes, and fixing up the ci/cd stuff in the build was like waaay down on my to-do list :)  I will definitely get that figured out.

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.

Announcements



×
×
  • Create New...

Important Information

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