Jump to content

retrieving player on death event


stellarfirefly

Recommended Posts

I'm intercepting the entityDeath (correction, the LivingDeathEvent) event and I want to retrieve the "death message" if it is a player.  The only data passed to this handler is a DamageSource object (event.source).  The death message itself may be retrieved with event.source.getDeathMessage(), but that method wants to be passed an EntityPlayer object.  So then two questions:

 

1.  How can I determine within this event handler if it triggered upon a player death?  Because it seems to also trigger on animal and monster deaths.

 

2.  Where exactly do I find the proper EntityPlayer to pass to getDeathMessage()?

 

My guess for #2 is that it is the EntityPlayer for the player in question, but the only object passed to this handler is the damage source.  So I'm guessing that if someone can tell me how to figure out the "damage target" then that will answer both of these questions.

 

adv(thanks)ance

Link to comment
Share on other sites

Okay, this is interesting.  I gave it a try and it seems to work just fine within my development environment.  But pushing it out to production, I keep getting an error that the event.entity field does not exist.

 

I crawled around the code some, and it seems like event.entityLiving is also a viable option.  But just like before, using that works just fine when running and testing it in Eclipse, but once I zip it up and drop it onto the production server, crash and burn:  "[sEVERE] [Minecraft] Encountered an unexpected exception NoSuchFieldError / java.lang.NoSuchFieldError: entityLiving"

 

Any ideas?

Link to comment
Share on other sites

Update:  It was a simple explanation.  My production environment is two weeks old.  Not a very long time, but long enough that it means it is using Forge 6.0.1 and Minecraft 1.4.2.  It seems changes were made (for the better) so that this code works just fine... in 6.3.0.  >_>

 

Thanks again for the advice!

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.