I appear to be running into a timing issue; something that I do not experience in a development environment when running Minecraft from IntelliJ but do experience when running outside of development.
I get the following error when running outside dev:
[23:53:27] [Worker-Main-20/ERROR]: Exception caught during firing event: Registry Object not present: brewtools:abyssal
Index: 1
Listeners:
0: NORMAL
1: ASM: class com.brewingcoder.brewtools.world.OreGeneration createConfiguredOreFeature(Lnet/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent;)V
java.lang.NullPointerException: Registry Object not present: brewtools:abyssal
at java.base/java.util.Objects.requireNonNull(Objects.java:334)
Which basically means that the OreGeneration appears to be attempting to register before the blocks?
All of my registrations happen inside the constructor of my Mod Class like so:
public BrewTools()
{
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
Configs.register();
ModBlocks.register(bus);
ModItems.register(bus);
ModSounds.register(bus);
bus.addListener(this::setup);
bus.addListener(this::enqueueIMC);
bus.addGenericListener(BlockEntityType.class,this::registerTileEntities);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.addListener(EventPriority.LOW, OreGeneration::onBiomeLoadingEvent);
}
as you can see, the Blocks are registering before the Ore Generation features. The blocks are registered using the typical deferred registry method like so:
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BrewTools.MODID);
public static final RegistryObject<Block> ABYSSAL = registerBlock("abyssal",()-> new Block(defaultProps));
....
public static void register(IEventBus bus){
BLOCKS.register(bus);
}
Any idea why this is happening? Especially why it would work in development but not in a non-development environment?
-BC