Get Absorption Level?

Discussion in 'Plugin Development' started by MezaGalaxus, Nov 22, 2015.

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

    MezaGalaxus

    I'm writing a plugin that regenerates absorption levels after a given time and I'm wondering if there's any code I can use to simply list the "health" remaining in the absorption.
     
  2. Offline

    Scimiguy

    I actually don't think you can..

    The best you can do is listen to the EntityDamageEvent and work out how many hearts would remain after each
     
  3. Offline

    teej107

  4. Offline

    MezaGalaxus

    They do not. They only list the health, not the absorption.
     
  5. Offline

    teej107

    Absorption adds health for a certain amount of time.
    I'm not certain if
     
  6. Offline

    Scimiguy

    Absorbtion doesn't add health, it adds absorbtion points
     
  7. Offline

    Lightspeed

    @MezaGalaxus
    Code:
    int absorpHearts(Player p)
    {
        for (PotionEffect pe : p.getActivePotionEffects())
        {
            if (pe.getType().equals(PotionEffectType.ABSORPTION))
            {
                int amt = pe.getAmplifier() * 2 + 2;
                return amt;
            }
        }
        return 0;
    }
    Can be used to get how many extra hearts they should have
    To regen them you have to regenerate 2 hearts ate a time or:
    Create a system to create a fake absorption heart by
    #1: Add half a heart using
    Code:
    player.setMaxHealth(p.getMaxHealth() + 1);
    #2: Add a system when they take damage to remove this extra health
    Code:
    if (player.getHealth() <= 20)
    {
            player.resetMaxHealth();
    }
    Put that in a damage listener for a player
    #3 When regenerated turn those hearts into an asorption heart remeber every 1 is 2 hearts
    #4 Add checks making sure they still have this potion effects in the regenerate health and damage entity.
    Didn't understand this or need more help tag or pm me.
     
  8. Offline

    Scimiguy

    @Lightspeed
    That'll get you the max absorbtion hearts, not the current though
     
    MezaGalaxus likes this.
  9. Offline

    MezaGalaxus

    @Lightspeed , @Scimiguy is right, the multiplier stays the same no matter how many hearts of absorption the player has remaining.

    Out of interest, would there be a way to stop players regenerating health if they have more than 20 health? That way you'd be able to have this "shield bar" that doesn't regenerate health and is even more flexible than absorption.
     
  10. Offline

    Xerox262

    EntityPlayer#getAbsorptionHearts()
     
Thread Status:
Not open for further replies.

Share This Page