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

Hello,

 

I've been working on my API for quite some time and I thought - why not make forge events for more user-friendly environment (till now I've been using abstract base class in which you can override and add your stuff).

 

I tried to follow event (EntitLivingBase - which later I want to extend with e.g EventSkillCast, etc.) system by call hierarchy but that didn't end well. It's all mixup of compiled and decopiled classes stitched together by EventBus, ForgeHooks and other weird stuff.

 

Question is - is making new event as easy as registering it via EventBus, making its call-code in right place and then just adding @SubscribeEvent? Or maybe are those coded deeply inside forge code that can't be accesed from outside?

 

Just to be on safe side - we are talking about totally new events created by forge mod.

 

Quick edit:

From what I'm seeing now is that @SubscribeEvent is being searched for on mod registration, so I guess registering new event would not be possible by mod itself, but still - maybe somehow?

 

for (Method method : target.getClass().getMethods())
        {
            for (Class<?> cls : supers)
            {
                try
                {
                    Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes());
                    if (real.isAnnotationPresent(SubscribeEvent.class))
...

1.7.10 is no longer supported by forge, you are on your own.

I've never tried it, but it looks like you should be able to just define your own subclass of Event and then post() it to the relevant event bus.

 

Should be pretty simple -- try it!

Yep, that's all it takes to make an event: create a class extending Event or any of its subclasses, then post it to the Forge event bus wherever you need it. Typically it only makes sense to create and post an event if you are expecting other people to be using your API, though there are some cases where it is useful to use events within your own code.

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.