Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

 

Backstory:

Spoiler

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.

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);
}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.