Jump to content

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


Ynscription

Recommended Posts

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.

 

Link to comment
Share on other sites

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);

}

 

 

 

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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