Tutorial Getting Raw Damage / Getting Damage After Reduction Applied

Discussion in 'Resources' started by SuperSniper, Oct 2, 2015.

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

    SuperSniper

    I don't really know why this is a thing, but I've been lots of people asking how to get Damage before / after the reduction or addition is added. It's actually very simple and I don't even know why I'm making this post really, since everyone should know about this by now.

    So first, to get the Raw Damage (Damage without any reductions or additions done to it), use the EntityDamageEvent, and the method to get it is "event.getDamage()". Everyone thinks that this is the final damage with all of the reductions or additions applied to it, but it's not. It's the raw damage before anything has been done to it.

    EXAMPLE:
    Code:
    @EventHandler
    public void onDamage(EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
    Player player = (Player)e.getEntity();
    double damage = event.getDamage();
    // Do Stuff
    
    Second, is the Final Damage (Damage with all reductions or additions done to it). This is the damage which is calculated using the potion effect buffs/debuffs, armor, etc.

    EXAMPLE:
    Code:
    @EventHandler
    public void onDamage(EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
    Player player = (Player)e.getEntity();
    final double damage = event.getFinalDamage();
    // Do Stuff
    
     
  2. Offline

    teej107

    @SuperSniper I don't think we need a resource/tutorial explaining what the JavaDocs already do. People should read the JavaDocs and if you think they aren't clear, then this resource is more of a clarification and not a tutorial.
     
Thread Status:
Not open for further replies.

Share This Page