Posted September 7, 20196 yr 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.
September 7, 20196 yr 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 September 7, 20196 yr by Differentiation
September 7, 20196 yr 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.
September 7, 20196 yr You can also check if getSource() instanceof DamageSource you can create your own damage source pretty easily. Also its PlayerEntity
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.