Jump to content

[1.14.4] Check Damage Source


77inthebag

Recommended Posts

1 hour ago, 77inthebag said:

I'm trying to check if a mob's death is caused by a player. What is the proper way to do this? I'm planning on using the LivingDeathEvent, but I don't know where to go from there.

Check if LivingDeathEvent::getSource().getTrueSource() instanceof EntityPlayer. First make sure it's not null, otherwise you'd get Java NullPointerException.

Edited by Differentiation
Link to comment
Share on other sites

45 minutes ago, Differentiation said:

First make sure it's not null, otherwise you'd get Java NullPointerException.

That's not true it's built in to the instanceof check. And getSource() will never return null.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.