Jump to content

Recommended Posts

Posted (edited)

Hey modder community,

I just don't understand what is wrong with my code.

I nearly tried everything to fix my problem but the LivingHurtEvent still does not work on servers.

 

Thats my code:

 

Main Class:

@SidedProxy(clientSide = "PACKAGE_NAME_IS_CORRECT.ClientProxy", serverSide = "PACKAGE_NAME_IS_CORRECT.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	proxy.preInit(event);
}

@EventHandler
public void onInit(FMLInitializationEvent event) {
	proxy.onInit(event);
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
	proxy.postInit(event);
}

 

CommonProxy:

public class CommonProxy {
	public void preInit(FMLPreInitializationEvent event) {}

	public void onInit(FMLInitializationEvent event) {}

	public void postInit(FMLPostInitializationEvent event) {
		MinecraftForge.EVENT_BUS.register(new EntityHurtListener());
	}
}

 

ClientProxy:

@Override
public void preInit(FMLPreInitializationEvent event) {
	super.preInit(event);
}

@Override
public void onInit(FMLInitializationEvent event) {
	super.onInit(event);
}

@Override
public void postInit(FMLPostInitializationEvent event) {
	super.postInit(event);

	// BLABLA CLIENTSIDE STUFF SUCH AS KEYBINDS, OTHER EVENTS

}

 

EntityHurtListener:

public class EntityHurtListener {

	private static final Logger logger = LogManager.getLogger();

	@SubscribeEvent
	public void onLivingHurt(LivingHurtEvent e) {

		logger.info("LivingHurtEvent");
		System.out.println("LivingHurtEvent");

	}

}

 

As you can see, I registered the event the postInit() of CommonProxy.

I also tried registering in init(), aswell as the ClientProxy (init and postInit).

My event is working fine for Slimes on SinglePlayer (couldn't test with playerEntities) but as I said it's not getting fired in any way.

Please help me, I already read the source code of many mods but still couldn't find my error.

Thanks :)

Edited by MysteriousHacks
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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