Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.