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

Hi! I'm creating a new class that doesn't extend any existing classes and I want to have an onUpdate() method in it that will run every tick while the game is running (not like in the title screen or anything, only in-game). I know all the existing onUpdate() methods are in some way linked to the run() method in the base Minecraft.class class, but it's never a good idea to edit the source code of Minecraft. So, I was wondering if forge has any annotations I can put over the method to update it every tick and make my life easier, or any classes I can extend that are linked to the world and contains an onUpdate() method that will run when the game is running? I'd like to not have to make a new run() method by implementing Runnable, as it might mess with Minecraft's ticking system or something like that.

 

Thanks :)

IGN: matte006

Played Minecraft since summer 2011.

Modding is my life now.

Please check out my mod :)

https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028

  • Author

I never really got the hang of events, but I'm guessing this is wrong, as it didn't work

@SubscribeEvent
public void onUpdate(TickEvent.WorldTickEvent event) {
    System.out.println("Hello World!"); //Some example code
}

 

Edit: nvm I'm stupid, I forgot to register the event in the EventHandler :P

IGN: matte006

Played Minecraft since summer 2011.

Modding is my life now.

Please check out my mod :)

https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028

To set up an event handler, you have to register an instance of the containing class with one of Forge's busses. I'm not sure which bus is required for WorldTickEvent though.

You probably solved it alredy, but:

 

* Tick Events are FML.

FMLCommonHandler.instance().bus().register(new FMLEvents());

 

While FMLEvents is class containing @SubscribeEvent methods.

 

Note that ALL tick events have 2 phases - START and END - you need to specify phase, otherwise code runst twice per tick.

More notes:

Server and worl tick run only on SERVER.

Client and Render run only on CLIENT.

Player runs on both.

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

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.