Posted July 11, 20169 yr When I subscribe to receive LivingAttackEvents, I don't get any events on the client end when a mob attacks the player. I get the events on the server in that case, though, and I get events on both ends when the player attacks a mob. Why is this happening? Here's a minimal test mod to demonstrate this problem: package com.example.examplemod; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "examplemod"; public static final String VERSION = "1.0"; @EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onLivingAttack(LivingAttackEvent event) { String victimName = event.getEntity().getDisplayName().getUnformattedText(); if(!event.getEntity().worldObj.isRemote) { System.out.println("local - victim is " + victimName); } else { System.out.println("remote - victim is " + victimName); } } } And here's the output of the player fighting a zombie: [22:52:43] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:43] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:43] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:43] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:43] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:44] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:44] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:44] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:44] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:44] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:45] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:45] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:46] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:46] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:46] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:47] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:47] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:48] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:48] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:48] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:49] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:49] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:49] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:49] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:49] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:50] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:50] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:50] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:50] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:50] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:51] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:51] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:52] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:52] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Zombie [22:52:52] [Client thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:34]: remote - victim is Zombie [22:52:53] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 [22:52:53] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:onLivingAttack:32]: local - victim is Player231 Note that there are no lines that say "remote - victim is Player231".
July 11, 20169 yr Because mobs ONLY process attacking on the server - players trigger the attack on both sides because the client player is by necessity the one that initiates the attack, i.e. via player input. http://i.imgur.com/NdrFdld.png[/img]
July 11, 20169 yr Author Okay. How should I work around that if I need to do stuff on the client when a mob attacks?
July 11, 20169 yr Send a packet. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.