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

I have made an event handling class, and have registered it using the following:

 

public class EventManager 
{
@EventHandler
public void load(FMLInitializationEvent event)
{
	FMLCommonHandler.instance().bus().register(new EventManager());
}


 @SubscribeEvent
 public void onEntitySpawn(EntityJoinWorldEvent event)
 {
	 MineAILog.log.info("Entity Has Spawned");
	 if (event.entity instanceof EntityMob) 
	 {
		 MineAILog.log.info("Entity is a mob");
		 assignAI((EntityMob) event.entity, event);
	 }
 }

 private void assignAI(EntityMob e, Event ev)
 {
		e.tasks.addTask(4, new EntityAIAttackOnCollide(e, EntityAI.class, 1.0D, false));
		e.targetTasks.addTask(4, new EntityAINearestAttackableTarget(e, EntityAI.class, 0, true));

 }
}

 

And yet the event does not fire at all, and the log functions do not run. I have also tried registering the EventManager class in the main mod class, but this has not worked either. I honestly do not know why it is not firing.

your "load" method can't be annotated with @EventHandler because that's not your mod class. you can invoke it from inside the actual load method from your mod class, or move the register code there and delete this method from EventManager. the other thing wrong is that you're registering to the wrong bus. EntityJoinWorld event is fired in MinecraftForge.EVENT_BUS.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

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.