Java Code Examples for cn.nukkit.event.entity.EntityDamageEvent.DamageCause#FIRE_TICK

The following examples show how to use cn.nukkit.event.entity.EntityDamageEvent.DamageCause#FIRE_TICK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Entity.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public boolean attack(EntityDamageEvent source) {
    if (hasEffect(Effect.FIRE_RESISTANCE)
            && (source.getCause() == DamageCause.FIRE
            || source.getCause() == DamageCause.FIRE_TICK
            || source.getCause() == DamageCause.LAVA)) {
        return false;
    }

    getServer().getPluginManager().callEvent(source);
    if (source.isCancelled()) {
        return false;
    }
    if (this.absorption > 0) {  //Damage Absorption
        float absorptionHealth = this.absorption - source.getFinalDamage() > 0 ? source.getFinalDamage() : this.absorption;
        this.setAbsorption(this.absorption - absorptionHealth);
        source.setDamage(-absorptionHealth, EntityDamageEvent.DamageModifier.ABSORPTION);
    }
    setLastDamageCause(source);
    setHealth(getHealth() - source.getFinalDamage());
    return true;
}
 
Example 2
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public boolean attack(EntityDamageEvent source) {
    if (hasEffect(Effect.FIRE_RESISTANCE)
            && (source.getCause() == DamageCause.FIRE
            || source.getCause() == DamageCause.FIRE_TICK
            || source.getCause() == DamageCause.LAVA)) {
        return false;
    }

    getServer().getPluginManager().callEvent(source);
    if (source.isCancelled()) {
        return false;
    }
    if (this.absorption > 0) {  // Damage Absorption
        this.setAbsorption(Math.max(0, this.getAbsorption() + source.getDamage(EntityDamageEvent.DamageModifier.ABSORPTION)));
    }
    setLastDamageCause(source);
    setHealth(getHealth() - source.getFinalDamage());
    return true;
}
 
Example 3
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public boolean attack(EntityDamageEvent source) {
    if (hasEffect(Effect.FIRE_RESISTANCE)
            && (source.getCause() == DamageCause.FIRE
            || source.getCause() == DamageCause.FIRE_TICK
            || source.getCause() == DamageCause.LAVA)) {
        return false;
    }

    getServer().getPluginManager().callEvent(source);
    if (source.isCancelled()) {
        return false;
    }
    if (this.absorption > 0) {  //Damage Absorption
        float absorptionHealth = this.absorption - source.getFinalDamage() > 0 ? source.getFinalDamage() : this.absorption;
        this.setAbsorption(this.absorption - absorptionHealth);
        source.setDamage(-absorptionHealth, EntityDamageEvent.DamageModifier.ABSORPTION);
    }
    setLastDamageCause(source);
    setHealth(getHealth() - source.getFinalDamage());
    return true;
}
 
Example 4
Source File: EntityItem.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION)
            && super.attack(source);
}
 
Example 5
Source File: EntityXPOrb.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION)
            && super.attack(source);
}
 
Example 6
Source File: EnchantmentProtectionFire.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public float getDamageProtection(EntityDamageEvent e) {
    DamageCause cause = e.getCause();

    if (level <= 0 || (cause != DamageCause.LAVA && cause != DamageCause.FIRE && cause != DamageCause.FIRE_TICK)) {
        return 0;
    }

    return (float) (getLevel() * getTypeModifier());
}
 
Example 7
Source File: EntityItem.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.CONTACT ||
            source.getCause() == DamageCause.FIRE_TICK ||
            (source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION) &&
            !this.isInsideOfWater() && (this.item == null ||
            this.item.getId() != Item.NETHER_STAR)) && super.attack(source);
}
 
Example 8
Source File: EntityXPOrb.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            (source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION) &&
            !this.isInsideOfWater()) && super.attack(source);
}
 
Example 9
Source File: EntityFirework.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION)
            && super.attack(source);
}
 
Example 10
Source File: EnchantmentProtectionFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public float getProtectionFactor(EntityDamageEvent e) {
    DamageCause cause = e.getCause();

    if (level <= 0 || (cause != DamageCause.LAVA && cause != DamageCause.FIRE && cause != DamageCause.FIRE_TICK)) {
        return 0;
    }

    return (float) (getLevel() * getTypeModifier());
}
 
Example 11
Source File: EntityItem.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION)
            && super.attack(source);
}
 
Example 12
Source File: EntityXPOrb.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean attack(EntityDamageEvent source) {
    return (source.getCause() == DamageCause.VOID ||
            source.getCause() == DamageCause.FIRE_TICK ||
            source.getCause() == DamageCause.ENTITY_EXPLOSION ||
            source.getCause() == DamageCause.BLOCK_EXPLOSION)
            && super.attack(source);
}
 
Example 13
Source File: EnchantmentProtectionFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public float getDamageProtection(EntityDamageEvent e) {
    DamageCause cause = e.getCause();

    if (level <= 0 || (cause != DamageCause.LAVA && cause != DamageCause.FIRE && cause != DamageCause.FIRE_TICK)) {
        return 0;
    }

    return (float) (getLevel() * getTypeModifier());
}