Entity .getHealth

Discussion in 'Plugin Development' started by stazek, May 8, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    stazek

    Hello guys! Today (xd) I want to get damaged entity health. This is my code:
    CAN SB HELP <3
    Code:
    @EventHandlerpublic boolean EntityDamageEvent(@NotNull Entity e, @NotNull EntityDamageEvent.DamageCause cause, double damage){
    if(e instanceof Player){
    
    }else{
    e.setCustomName(e.getCustomName());
    }
    return true;
    }
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    @stazek You copied the constructor.
    Listener would be this:
    Code:
    @EventHandler
    public void onEntityDamage(EntityDamageEvent){
    // Your code here
    }
    And you can call getEntity on it.
     
  3. Offline

    stazek

    I don't understand
     
  4. Offline

    timtower Administrator Administrator Moderator

    What part?
     
  5. Offline

    stazek

    Every part... how it works?
     
  6. Offline

    timtower Administrator Administrator Moderator

    Start by listening to the event.
     
  7. Offline

    stazek

    But how will "look" finished code? Pls write example with my code above.
     
  8. Offline

    timtower Administrator Administrator Moderator

    Your code above does not work as it is not an event.
    You are using the constructor parameters there.
     
  9. Offline

    stazek

    So... how will it look finally? Can you write it.
     
  10. Offline

    timtower Administrator Administrator Moderator

    No, I won't spoonfeed.
     
  11. Offline

    KarimAKL

Thread Status:
Not open for further replies.

Share This Page