Jump to content

Issue when referring to a registered block: 'Registry Object Not Present'


Syric

Recommended Posts

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!

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.