Java Code Examples for cn.nukkit.entity.Entity#getMaxHealth()

The following examples show how to use cn.nukkit.entity.Entity#getMaxHealth() . 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: Effect.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void applyEffect(Entity entity) {
    switch (this.id) {
        case Effect.POISON: //POISON
            if (entity.getHealth() > 1) {
                entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            }
            break;
        case Effect.WITHER: //WITHER
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            break;
        case Effect.REGENERATION: //REGENERATION
            if (entity.getHealth() < entity.getMaxHealth()) {
                entity.heal(new EntityRegainHealthEvent(entity, 1, EntityRegainHealthEvent.CAUSE_MAGIC));
            }
            break;
    }
}
 
Example 2
Source File: Effect.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public void applyEffect(Entity entity) {
    switch (this.id) {
        case Effect.POISON: //POISON
            if (entity.getHealth() > 1) {
                entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            }
            break;
        case Effect.WITHER: //WITHER
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            break;
        case Effect.REGENERATION: //REGENERATION
            if (entity.getHealth() < entity.getMaxHealth()) {
                entity.heal(new EntityRegainHealthEvent(entity, 1, EntityRegainHealthEvent.CAUSE_MAGIC));
            }
            break;
        case Effect.SPEED:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * 0.2 + 1) * 0.1));
            }
            break;
        case Effect.SLOWNESS:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * -0.15 + 1) * 0.1));
            }
            break;
    }
}
 
Example 3
Source File: Effect.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void applyEffect(Entity entity) {
    switch (this.id) {
        case Effect.POISON: //POISON
            if (entity.getHealth() > 1) {
                entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            }
            break;
        case Effect.WITHER: //WITHER
            entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, 1));
            break;
        case Effect.REGENERATION: //REGENERATION
            if (entity.getHealth() < entity.getMaxHealth()) {
                entity.heal(new EntityRegainHealthEvent(entity, 1, EntityRegainHealthEvent.CAUSE_MAGIC));
            }
            break;
        case Effect.SPEED:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * 0.2 + 1) * 0.1));
            }
            break;
        case Effect.SLOWNESS:
            if (entity instanceof Player) {
                ((Player) entity).setMovementSpeed((float) (((this.amplifier + 1) * -0.15 + 1) * 0.1));
            }
            break;
    }
}