ashjack Posted August 29, 2015 Share Posted August 29, 2015 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. Quote Link to comment Share on other sites More sharing options...
kauan99 Posted August 29, 2015 Share Posted August 29, 2015 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. Quote WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons Link to comment Share on other sites More sharing options...
Recommended Posts
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.