Ok I justed tested some thing:
Side side = FMLCommonHandler.instance().getSide();
On Single- and Multi-Player it allways returned "CLIENT", but why can I not recive the Event on Mutliplayer then?
@EventHandler
public void preinit(FMLPreInitializationEvent e) throws AWTException, NativeHookException {
FMLCommonHandler.instance().bus().register(new HurtEvent());
MinecraftForge.EVENT_BUS.register(new HurtEvent());
}
And I need it to work on Client only.
Ok I changed some things around:
1. I made a new Class:
public class HurtEvent {
@SubscribeEvent
public void OnKeyInputx(LivingHurtEvent e) {
System.out.println("HurtEvent");
}
}
2. And I registered this class by calling:
FMLCommonHandler.instance().bus().register(new HurtEvent());
3. I also registered the Code by calling:
MinecraftForge.EVENT_BUS.register(new HurtEvent());
Does anyone know why it is still not working?
No there is no mod on the server...
A player has the mod installed and he joines a normal Bukkit or Spigot server.
And now the Event doesnt get triggered.
I even tried:
@SubscribeEvent
public void OnKeyInput(LivingHurtEvent e) {
System.out.println("test");
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("HurtEvent"));
}
And I do not get "test" in the console.
Ok.
I registered the Event with:
FMLCommonHandler.instance().bus().register(new Main());
and my new Code is:
@SubscribeEvent
public void OnKeyInput(LivingHurtEvent e) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("HurtEvent"));
}
But I still do not get the message on a Server. In Singleplayer it works.