Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

  • 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.

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.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.