Jump to content

@SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) not working


Recommended Posts

Posted

When I call TickEvent.ClientTickEvent in my Main.java it does nothing but when I call it in other files like utils.MM it works fine

 

    @SubscribeEvent
    public void onTick(TickEvent.ClientTickEvent event) {
        System.out.println("tick");

}

Im new to moding so this is prolly a dumb question

 

 

 

Posted (edited)

there are two ways that method would be called for that event:

variant 1 - manual: you called addListener. see ExampleMod.java for example.

variant 2 - automagic: if a class is annotated with @Mod.EventBusSubscriber and the event is made static and annotated with @SubscribeEvent, forge will handle everything.

use variant 2, but not in main class.

Edited by MFMods
  • Like 1
Posted

hold on. do not do both 1 and 2.

do variant 2. annotation on class, annotation on event handler method, make method static.

you do not want events to trigger twice.

  • Thanks 1

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.