Too early fuel loading
lilypuree opened this issue ยท 8 comments
loading fuels in the mod constructor causes issues with other mods. Wouldn't it be better to use the CommonSetupEvent?
@RuochenFu21 Can you merge this fix into the 1.18.2 version too please?
@I-Knight-I This is a issue, not a pull request.
@I-Knight-I This is a issue, not a pull request.
Yup, my bad. Is this something you know how to fix?
I have no experience with Forge mods, only plugins. Nonetheless, I gave it a try and, whilst I fixed the crashing, I can't seem to get any fluids pumped into the blaze burners. I'm also getting dozens of errors in the console about NoSuchField: FLUID
for various ingredients in different mods.
The changes I made were to the mod constructor class:
// The value here should match an entry in the META-INF/mods.toml file
@Mod(value = CreateLiquidFuel.MOD_ID)
public class CreateLiquidFuel {
// Directly reference a slf4j logger
public static final String MOD_ID = "createliquidfuel";
public CreateLiquidFuel() {
// MinecraftForge.EVENT_BUS.register(this);
FMLJavaModLoadingContext.get().getModEventBus().register(this); // Changed the event bus registration
}
@Mod.EventBusSubscriber
public static class ForgeEvents {
@SubscribeEvent
public static void addReloadListeners(AddReloadListenerEvent event) {
event.addListener(LiquidBurnerFuelJsonLoader.INSTANCE);
}
@SubscribeEvent
static void onCommonSetup(FMLCommonSetupEvent event) { // Added this event subscriber
// DrainableFuelLoad.load() // I also tried this, but same result
event.enqueueWork(DrainableFuelLoader::load);
}
}
}
https://docs.minecraftforge.net/en/1.20.x/concepts/lifecycle/#registry-events
Registration is handled after mod construction, and as mods are loaded in parallel your code that iterates through the item registry will be incompatible with any mod that registers items if it's loaded after yours.
The usage of the internal Forge method at that point is also problematic. Tags are not loaded before mod construction so there's no point.