Posted March 4, 20187 yr Hiya, I made a small mod that listens for when the player gets damaged. It works perfectly in SP but when I join a server it doesn't work anymore. How do I allow it to run in multiplayer?
March 4, 20187 yr Author Sure, this is my `init` method: @EventHandler public void init(FMLInitializationEvent event) { // some example code logger.info("ShockMod loaded."); MinecraftForge.EVENT_BUS.register(new LivingDamageEventHandler(logger)); } The EventHandler is just @SubscribeEvent public void livingDamage(LivingDamageEvent event) { this.logger.info("Event entity id: " + event.getEntity().getEntityId() + " | My id: " + Minecraft.getMinecraft().player.getEntityId()); if (event.getEntity().getEntityId() != Minecraft.getMinecraft().player.getEntityId()) { return; } //Do stuff } And these are the flags(?) I supply to the @Mod flag. public static final String MODID = "shockmod"; public static final String NAME = "Shock Mod"; public static final String VERSION = "1.0"; public static final boolean CLIENTSIDEONLY = true; public static final boolean CANBEDEACTIVATED = true; Edited March 4, 20187 yr by Tvde1
March 4, 20187 yr Author 2 minutes ago, diesieben07 said: Minecraft is a client-only class. What are you trying to achieve by checking for Minecraft::player? There is no "the player" on a server. There are many players. This mod is running on the client. I want it to work when connected to a server.
March 4, 20187 yr Author Do you know which event runs on the client where I can get notified whenever the logged in player gets hurt?
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.