Jump to content

Recommended Posts

Posted (edited)

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
Posted

Server - no mod

Client - has the mod subscribing to living attack event

Client with mod connects to client without mod, will client receive the event

 

I believe that is what the OP is asking.

Posted

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.

Posted (edited)
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
Posted

Basically, the client does not know about damage unless the server tells it, so as far as I can tell, you cannot do what you are looking to do with only a client side mod.

Posted

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 ?

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

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