Jump to content

[1.15.2] Registry Object not present. Why does this happen?


Recommended Posts

https://github.com/JGgithub2018/Vanilla-Automation Repo for the mod.




I am working on a mod for 1.15.2. In fact, my first mod. I followed a tutorial from TechnoVision (previously Loremaster), but replacing base classes with helper methods, since it's much cleaner to use helper methods. TechnoVision has yet to release a video on making blocks, so I went ahead and tried to do it myself. However, I ran into this issue and I'm not sure why this happens.

I'm using a helper method on the ModRegistry.Blocks class which registers BlockItems for each block. However, an exception occurs in the for each loop, specifically when getting entries. Since when did the register not have an object that was just registered?


Thanks everyone.

Link to comment
Share on other sites

Just because you put a method in-between two registers doesn't mean anything. You're trying to register the BlockItem before the Blocks have even had a chance to be registered. If you want to register an item block the way you're doing it, you have to wait for each block to be registered and then activate your method. Otherwise, use the same instance of the block used when registering in your item.


One of the easiest examples of registering the block and item at the same time is like so:

private static <T extends Block> RegistryObject<T> register(String id, T block, @Nullable Function<T, BlockItem> item) {
	if(item != null) CustomItems.ITEMS.register(id, () -> item.apply(block));
	return BLOCKS.register(id, () -> block);


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.

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.