Yes I am doing a client-only mod, it only checks if the player takes damage, and what amout of damage
Thanks to DavidM, I managed to get it working, but now I have a second, more complicated problem.
I'm now using LivingAttackEvent event to detect when i take damage, I check if the entity taking damage is my own character, and then I log the amout of damage taken.
This method works great with all "singleplayer" methods of taking damage, like fall damage, mobs, fire ... But when an other player hits me, the amout of damage that LivingAttackEvent logs is 0.0 damage, even with a diamond sword. Is that a bug from forge or am I doing this wrong ?
Here's the code i'm using :
@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event)
{
if (event != null && event.getEntity() != null)
{
Entity victimentity = event.getEntity();
Entity sourceentity = event.getSource().getTrueSource();
String playerName = "";
playerName = (String)(victimentity.getDisplayName().getString());
if (victimentity.getDisplayName().getString().equals("Superburger90"))
{
System.out.println("Player attacked ! damage : " + event.getAmount());
}
}
}