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

Steps for checking if an event is being fired:

1. Place this line of code in your event method:

Log.info("check");

2. Meet all the requirements in-game for the event to fire (i.e. be attacked by any other entity).

3. If [INFO] check doesn't show up on the console, you did NOT register your event.

 

Or just simply use the debugger :P 

Edited by Differentiation

  • Replies 61
  • Views 15.2k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • @DifferentiationIt's working wiht you in multiplayer with client-side mod only ?

  • @Differentiation, you're missing how mods are used. It is possible for people to make mods that only get applied to one side. For example, if I wanted to have my client render everything in pink for s

  • So the way it works is that when the server processes an attack it updates the client with an SPacketEntityStatus packet. Unfortunately, it is implemented in a very minimalistic way, presumably for pe

Posted Images

  • Author

Did the event fired with you in multiplayer in a server that havn't the mod on it?

OH!

I see.

If the server does not have the mod installed, nothing will work on the clients. The event in this case will NOT be fired.

Edited by Differentiation

  • Author

Use the mod on client-side only and tell me if the event is fired

  • Author

I know I want to be able to have an event when "thePlayer" got hitten by another entity and be able to do something like:
event.getEntity() all of this client-side.

I'm not quite understanding what you're trying to ask.

LivingAttackEvent will fire when you're in a Singleplayer world by yourself and Multiplayer server.

Edited by Differentiation

  • Author

@DifferentiationPlease read all the post and try to help me again because you are not helping me and you don't understand the problem.
If you cannot understand please stop speak in this topic

5 minutes ago, Yario said:

@DifferentiationPlease read all the post and try to help me again because you are not helping me and you don't understand the problem.
If you cannot understand please stop speak in this topic

	@SubscribeEvent
	public void onAttack(LivingAttackEvent event)
	{
		if (event.getEntity() instanceof EntityPlayer)
		{
			Entity attackerIn = event.getSource().getSourceOfDamage(); // this is your attacker instance, the entity attacking the target		
			EntityPlayer targetIn = (EntityPlayer) event.getEntity(); // this is your target instance, the entity being attacked by the attacker
			/*
             		* Here, you do whatever you want with your attacker and target.
             		* You can make the target set on flame, add potion effects, etc.
             		* Make sure you properly handle sides
             		*/
		}
	}

It's as simple as that, can't get any simpler, my friend, if you want lines to fire on the client, then send packets.

Edited by Differentiation

  • Author

I succefully get a DamageSource of the attack but

DamageSource::getEntity()

always return null.
I saw that I needed to use EntityDamageSource but how can I convert DamageSource to EntityDamageSource ?

2 minutes ago, Yario said:

The client cannot know who attacked himself ?

I honestly don't know, I haven't tried doing anything like this myself. I was just explaining what I believe Differentiation was trying to say to you since you said you didn't understand. :)

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.