77inthebag Posted September 7, 2019 Share Posted September 7, 2019 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. Quote Link to comment Share on other sites More sharing options...
Differentiation Posted September 7, 2019 Share Posted September 7, 2019 (edited) 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, 2019 by Differentiation Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 7, 2019 Share Posted September 7, 2019 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. Quote 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 More sharing options...
Drizzs Posted September 7, 2019 Share Posted September 7, 2019 You can also check if getSource() instanceof DamageSource you can create your own damage source pretty easily. Also its PlayerEntity Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.