Jump to content

Recommended Posts

Posted

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".

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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