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.

[Solved]How do I register a Scheduled Tick Handler?

Featured Replies

Posted

Hello there, I've been trying to make a Scheduled Tick handler, but I'm not sure where to register it and how.

 

This is how I do it nowin the base mod class:

 

 

@ServerStarting

public void serverStarting(FMLServerStartingEvent event)

{

   

TickHandler tickHandler = new TickHandler(chunkControl);

TickRegistry.registerScheduledTickHandler(tickHandler, Side.SERVER);

 

 

}

 

 

 

 

 

Note that chunkControl is an object of the base mod class(and in every other thing works ok).

 

And this is the Tick Handler:

 

 

 

public class TickHandler implements IScheduledTickHandler {

 

private ChunkControl chunkControl;

 

public TickHandler (ChunkControl chunkcontrol){

 

chunkControl = chunkcontrol;

}

 

@Override

public void tickStart(EnumSet<TickType> type, Object... tickData) {

// TODO Auto-generated method stub

 

}

 

@Override

public void tickEnd(EnumSet<TickType> type, Object... tickData) {

// TODO Auto-generated method stub

chunkControl.updateReserve();

}

 

@Override

public EnumSet<TickType> ticks() {

// TODO Auto-generated method stub

return null;

}

 

@Override

public String getLabel() {

// TODO Auto-generated method stub

return null;

}

 

@Override

public int nextTickSpacing() {

// TODO Auto-generated method stub

return 1;

}

 

}

 

 

 

 

When I debug it doesn't go through any of the handler methods. What am I doing wrong?

 

Also and slightly unrelated, the return of the nextTickSpacing method is the amount of ticks until the tickStart is called? or is it of the tickEnd? or I'm missing absolutely everything?

 

Thank you.

 

  • Author

Okay I was able to pull it out after a while. The problem was that I had to return a EnumSet of some sort  in the ticks() method, so I did this:

 

 

 

 

@Override

public EnumSet<TickType> ticks() {

// TODO Auto-generated method stub

return EnumSet.of(TickType.SERVER);

}

 

 

 

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.