Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Event that fires when player is hurt?


Frontear
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi, i have a FMLServerStartingEvent and i need register RegisterCommandsEvent, but i can't make this. Event logging only goes through the constructor, are there any workarounds to solve this?
    • alrdy found it i think sry to anyone
    • cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: codechicken/lib/packet/PacketCustom$ICustomPacketHandler     at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)     at cpw.mods.fml.common.Loader.loadMods(Loader.java:544)     at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208)     at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)     at net.minecraft.client.main.Main.main(SourceFile:148)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:210)     at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:245)     at org.multimc.EntryPoint.listen(EntryPoint.java:143)     at org.multimc.EntryPoint.main(EntryPoint.java:34) Caused by: java.lang.NoClassDefFoundError: codechicken/lib/packet/PacketCustom$ICustomPacketHandler     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Unknown Source)     at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:440)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)     at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)     at cpw.mods.fml.common.Loader.loadMods(Loader.java:513)     ... 18 more Caused by: java.lang.ClassNotFoundException: codechicken.lib.packet.PacketCustom$ICustomPacketHandler     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101)     at java.lang.ClassLoader.loadClass(Unknown Source)     at java.lang.ClassLoader.loadClass(Unknown Source)     ... 43 more
    • Not directly related to your answer, but does that mean, if I want to make an Obsidian Block into a projectile (extend projectile class), whilst retaining its default properties, I am out of luck and I have to "mess with internals"? Maybe there is a way to unregister default Minecraft blocks and add fake ones? Impostors of sort.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.