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.

Featured Replies

Posted

I'm working on a system for brewing various items in cauldrons. As part of this, I have created the 'Substance' class, referring to various things one might put in a cauldron, and during initial modloading (immediately after calling the deferred registries to register my items, blocks, etc.) I am filling out a list of possible Substances. One such substance, 'crash_pad', is equivalent to a modded block, also called 'crash_pad'. When defining it as a Substance, I reference its item format, like so: (The problem line, #16, is marked with an asterisk.)

public class SubstanceList {
    public static ArrayList<Substance> list = new ArrayList<Substance>();

    public static Substance water = new Substance("water", new Ingredient[]{}, false, null);
*   public static Substance crash_pad = new Substance("crash_pad", new Ingredient[]{}, true, registerBlocks.CRASH_PAD.get().asItem());
    //Substance constructor takes in (String, Ingredient[], boolean, Item).

    public SubstanceList() {
        initialize();
    }

    public static void initialize() {
        list.add(water);
        list.add(crash_pad);
    }

    //For getting ingredients
    private static Ingredient get(Item item) {
        return IngredientsDict.get(item);
    }

}

When I try to launch the game, I get an error saying that the crash_pad registry object was not present.  The full crash report is available here, the most relevant part (in my estimation) is quoted here:

Quote

    Mod File: main
    Failure message: Alchemy Plus (alchemyplus) has failed to load correctly
        java.lang.ExceptionInInitializerError: null
    Mod Version: NONE
    Mod Issue URL: NOT PROVIDED
    Exception message: java.lang.NullPointerException: Registry Object not present: alchemyplus:crash_pad
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_271] {}
    at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[forge:?] {re:classloading}
    at syric.alchemyplus.alchemy.SubstanceList.<clinit>(SubstanceList.java:16) ~[?:?] {re:classloading}
    at syric.alchemyplus.AlchemyPlus.<init>(AlchemyPlus.java:38) ~[?:?] {re:classloading}

I'm not sure why the game is having trouble finding the registered item, given that I run the registers prior to calling SubstanceList.initialize(). This is the constructor from my main mod file: (The asterisked line is line 38, where the issue was thrown in the crash log above.)

public AlchemyPlus() {
        registry.register();
        IngredientsDict.initialize();
*        SubstanceList.initialize();
        RecipeList.initialize();
...
}

I suspect the issue has something to do with me misunderstanding registries, because I'm still pretty iffy on the details of how they work. What exactly is going wrong?

If more information or code is needed, don't hesitate to ask- I'm not confident enough to say that I've definitely provided all relevant code!

Thanks for the help!

  • Author

That helps, thank you! Where can I go to learn more about FMLCommonSetupEvent, and how to use it?

(Edit: in addition to the readthedocs.io, I'm already there)

Edited by Syric

  • Author

Understood. I guess I'll just brush up on events in general. Thanks again!

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.