Jump to content

Recommended Posts

Posted (edited)

I've been trying to get find an event which fires when the player get's hurt, that is, our current player. I've tried LivingHurtEvent, but it doesn't seem to even fire on a multiplayer world. What event can I use for this?

Edited by Frontear

I am a human and this action was performed manually. Please contact Frontear if you have any questions or concerns.

Posted (edited)
5 hours ago, diesieben07 said:

LivingHurtEvent is fired immediately when a living entity receives damage, it can be used to alter the damage or cancel it outright.

LivingDamageEvent is fired after all damage calculations have been done (armor, potions, LivingHurtEvent (unless cancelled)).

Both of these fire for players. They do sometimes fire on the logical client, but not in a useful fashion.

Perhaps it's my code's fault, because LivingHurtEvent does not fire while on a multiplayer world, even for myself. While I can understand that LivingHurtEvent on EntityLIvingBase wouldn't normally fire because I don't have direct access to all the players on the server, I was hoping the event in EntityPlayer would fire for myself. Is this even possible for me to do?

 

Relevant code:

@SubscribeEvent public void onLivingHurt(LivingHurtEvent event) {
  if (event.getEntity().getName().equals(mc.player.getName()) {
    // the player has been hurt
    doSomething();
  }
}

 

 

EDIT:

I've found a method which works properly, It is LivingAttackEvent

Edited by Frontear

I am a human and this action was performed manually. Please contact Frontear if you have any questions or concerns.

Posted

And your code will crash the desiccated server. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 hour ago, Draco18s said:

And your code will crash the desiccated server. 

Dedicated server* (close enough).  I'm guessing that was autocomplete in action right there XD

 

But yeah, in *most cases*, you would want the LivingHurtEvent, on the server side, though I have no idea what you're actually trying to do, so I can't say for sure.

Posted
2 hours ago, Laike_Endaril said:

Dedicated server* (close enough).  I'm guessing that was autocomplete in action right there XD

Yeah, that. Was on tablet at a party.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
3 hours ago, diesieben07 said:

Best way to spend a party :P

In between turns of fighting OblivAeon? I'm sure it was fine.

(Also, we won. Took 8 freaking hours)

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.