Jump to content

DamageSource.getEntity() always null


Yario

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.