Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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

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() {

    public static void initialize() {

    //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:


    Mod File: main
    Failure message: Alchemy Plus (alchemyplus) has failed to load correctly
        java.lang.ExceptionInInitializerError: null
    Mod Version: NONE
    Exception message: java.lang.NullPointerException: Registry Object not present: alchemyplus:crash_pad
    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() {
*        SubstanceList.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 post
Share on other sites

Registry events happen before FMLCommonSetupEvent. You can't just refer to registry objects in some random static initializer and expect them to already be registered. Either use suppliers (the RegistryObject itself already is one) and call get on demand when you need it or wait until FMLCommonSetupEvent.

  • Thanks 1
Link to post
Share on other sites
Posted (edited)

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
Link to post
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.

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.

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I'm creating a gui (container-less) and for the sake of visual simplicity, I'd like background screen components like the healthbar and hotbar to go away while this screen is open, like how pressing alt+f1 declutters the screen.  Anyone know how I can do this? 
    • Hi forum, I have a problem with forge 1.17.1  Every time i try to start version forge 1.17.1 it says: Game crasht Can Someone help me please Kind regards, Sven
    • I don't even have Optifine installed and the game doesn't start, it crashes right away
    • public enum ModArmorMaterial implements IArmorMaterial { ARGENTITE(Alcamod.ModID + ":argentite", 40, new int[] { 3, 6, 8, 3 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.5F, 0.15F, () -> { return Ingredient.fromItems(ModItems.ARGENTITE_INGOT.get()); }), AZURITE(Alcamod.ModID + ":azurite", 45, new int[] { 3, 6, 8, 3 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.7F, 0.16F, () -> { return Ingredient.fromItems(ModItems.AZURITE_INGOT.get()); }), EMATITE(Alcamod.ModID + ":ematite", 50, new int[] { 3, 6, 8, 3 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.17F, () -> { return Ingredient.fromItems(ModItems.EMATITE_INGOT.get()); }), BARITE(Alcamod.ModID + ":barite", 60, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.2F, 0.19F, () -> { return Ingredient.fromItems(ModItems.BARITE_INGOT.get()); }), UNPOWERED_NETHER_STAR(Alcamod.ModID + ":unpowered_nether_star", 70, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.21F, () -> { return Ingredient.fromItems(Items.NETHER_STAR.getItem()); }), NETHER_STAR(Alcamod.ModID + ":nether_star", 80, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 5.0F, 0.35F, () -> { return Ingredient.fromItems(ModItems.POWERED_NETHER_STAR.get()); }), INVERTED_NETHER_STAR(Alcamod.ModID + ":inverted_nether_star", 100, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 6.0F, 0.60F, () -> { return Ingredient.fromItems(ModItems.INVERTED_NETHER_STAR.get()); }); private static final int[] MAX_DAMAGE_ARRAY = new int[] { 11, 16, 15, 13 }; private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; private final SoundEvent soundEvent; private final float toughness; private final float knockBackResistance; private final Supplier<Ingredient> repairMaterial; ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterial) { this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; this.repairMaterial = repairMaterial; this.knockBackResistance = knockbackResistance; } @Override public int getDurability(EquipmentSlotType slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDamageReductionAmount(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantability() { return this.enchantability; } @Override public SoundEvent getSoundEvent() { return this.soundEvent; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.get(); } @Override public String getName() { return this.name; } @OnlyIn( Dist.CLIENT ) @Override public float getToughness() { return this.toughness; } public float getKnockbackResistance() { return this.knockBackResistance; } }  
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.