Posted July 11, 201510 yr The name should say it all. I would like to check when the player gets attacked (without events if possible) if the damage is a mob, otherwise not render the hud effect.
July 11, 201510 yr LivingHurtEvent and the various attack events all have a DamageSource field which has the getSourceOfDamage() method - that returns the entity ultimately responsible for causing the damage, such as the shooter of an arrow or melee attacker. You'll want to double-check that the event is firing on the client side - for non-players, these are server only events. http://i.imgur.com/NdrFdld.png[/img]
July 11, 201510 yr Author to check if it is client side would I just do: if (world.isRemote) { code }
July 11, 201510 yr You could do that and print the result to the console, or use your logger to print a message and it will automatically let you know which side it printed from. But I'm 90% sure that those specific events also get called on the client when the entity involved is a player, but maybe that is only if the attacking entity is a player... can't remember off the top of my head, which is why I suggested testing it for yourself. If it turns out that LivingHurtEvent is only called server side when attacked by mobs (which, now that I think about it more, I believe is the case), you will have to send a packet. http://i.imgur.com/NdrFdld.png[/img]
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.