Posted April 16, 20205 yr I'm trying to create a new registry... Which I think I've mostly got down besides one thorn in my side - I can seem to get the RegisterEvent.NewRegistry Event to trigger. Here is my Event Handler: public class CommonEventHandler { @SubscribeEvent public void onChunkAttachCapabilitiesEvent(AttachCapabilitiesEvent<Chunk> evt) { evt.addCapability(SymbolHandler.Provider.NAME, new SymbolHandler.Provider()); } @SubscribeEvent public void onCreateRegistryEvent(RegistryEvent.NewRegistry evt) { SymbolRegistration.onCreateRegistryEvent(evt); } @SubscribeEvent public void onSymbolRegistryEvent(RegistryEvent.Register<Symbol> evt) { SymbolRegistration.registerSymbols(evt); } } And here is where I register the handler: @Mod("runicarcana") public class RunicArcana { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "runicarcana"; //Capability Registration @CapabilityInject(ISymbolHandler.class) public static Capability<ISymbolHandler> SYMBOL_CAP = null; public RunicArcana() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new CommonEventHandler()); MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); Registration.init(); } (I know it's messy right now... I'll clean it up [eventually]) Does anybody out there know why I can't seem to get RegistryEvent.NewRegistry to trigger? Any help is greatly appreciated!
April 16, 20205 yr Author Figured it out. Seems like the Registry Event is not on the normal Event Bus, and you have to use FMLJavaModLoadingContext.get().getModEventBus().addListener() In order to properly access it.
April 16, 20205 yr Hi FYI some notes from my testing on the buses so far... // Beware - there are two event busses: the MinecraftForge.EVENT_BUS, and your own ModEventBus. // If you subscribe your event to the wrong bus, it will never get called. // likewise, beware of the difference between static and non-static methods, i.e. // If you register a class, but the @SubscribeEvent is on a non-static method, it won't be called. e.g. // MOD_EVENT_BUS.register(MyClass.class); // public class ServerLifecycleEvents { // @SubscribeEvent // public void onServerStartingEvent(FMLServerStartingEvent event) { // missing static! --> never gets called} // } // Based on my testing: ModEventBus is used for setup events only, in the following order: // * RegistryEvent of all types // * ColorHandlerEvent for blocks & items // * ParticleFactoryRegisterEvent // * FMLCommonSetupEvent // * TextureStitchEvent // * ModelBakeEvent // * FMLClientSetupEvent or FMLDedicatedServerSetupEvent // * ModelRegistryEvent // * Other ModLifecycleEvents such as InterModEnqueueEvent, InterModProcessEvent // Everything else: the MinecraftForge.EVENT_BUS -TGG
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.