Jump to content

[1.17.1] Registering client sided event handler


GnRSlashSP

Recommended Posts

Hi!

I want to understand how this works. Reading Forge Documentation I made this at first:

@Mod.EventBusSubscriber(modid = RedOptionsMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class StaticClientOnlyEventHandler {

  @SubscribeEvent
  public static void spriteAdd(TextureStitchEvent.Pre event) {
    if (!event.getMap().location().equals(InventoryMenu.BLOCK_ATLAS)) return;
    event.addSprite(Resources.FILTER);
  }
}

But this event is never fired (I don't think it should have been registered..)So, I removed the line: @Mod.EventBusSubscriber, and I did this at my mod class:
 

if (FMLLoader.getDist().isClient())
    FMLJavaModLoadingContext.get().getModEventBus().register(StaticClientOnlyEventHandler.class);

And it is working (working and don't crashing at server side).
Tow questions:

1. Why the first method didn't work, am I missing something? 

2. Is the second way the correct way to register specific side events, using (FMLLoader.getDist().isClient()) ?

Thank you!

 

Edited by GnRSlashSP

†GnR† Slash

can one man truly make a difference?

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.