cn.nukkit.potion.Effect Java Examples

The following examples show how to use cn.nukkit.potion.Effect. 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
protected void initEntity() {
    if (this.namedTag.contains("ActiveEffects")) {
        ListTag<CompoundTag> effects = this.namedTag.getList("ActiveEffects", CompoundTag.class);
        for (CompoundTag e : effects.getAll()) {
            Effect effect = Effect.getEffect(e.getByte("Id"));
            if (effect == null) {
                continue;
            }

            effect.setAmplifier(e.getByte("Amplifier")).setDuration(e.getInt("Duration")).setVisible(e.getBoolean("showParticles"));

            this.addEffect(effect);
        }
    }

    if (this.namedTag.contains("CustomName")) {
        this.setNameTag(this.namedTag.getString("CustomName"));
        if (this.namedTag.contains("CustomNameVisible")) {
            this.setNameTagVisible(this.namedTag.getBoolean("CustomNameVisible"));
        }
    }

    this.scheduleUpdate();
}
 
Example #2
Source File: Block.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public double getBreakTime(Item item, Player player) {
    Objects.requireNonNull(item, "getBreakTime: Item can not be null");
    Objects.requireNonNull(player, "getBreakTime: Player can not be null");
    double blockHardness = getHardness();
    boolean correctTool = correctTool0(getToolType(), item);
    boolean canHarvestWithHand = canHarvestWithHand();
    int blockId = getId();
    int itemToolType = toolType0(item);
    int itemTier = item.getTier();
    int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
            .map(Enchantment::getLevel).orElse(0);
    int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
            .map(Effect::getAmplifier).orElse(0);
    boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
            Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
                    .map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
    boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
    return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
            efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
 
Example #3
Source File: BlockLava.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onEntityCollide(Entity entity) {
    entity.highestPosition -= (entity.highestPosition - entity.y) * 0.5;
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.LAVA, 4));
    }

    // Always setting the duration to 15 seconds? TODO
    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 15);
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled()
            // Making sure the entity is acutally alive and not invulnerable.
            && entity.isAlive()
            && entity.noDamageTicks == 0) {
        entity.setOnFire(ev.getDuration());
    }

    super.onEntityCollide(entity);
}
 
Example #4
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 #5
Source File: Block.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public double getBreakTime(Item item, Player player) {
    Objects.requireNonNull(item, "getBreakTime: Item can not be null");
    Objects.requireNonNull(player, "getBreakTime: Player can not be null");
    double blockHardness = getHardness();
    boolean correctTool = correctTool0(getToolType(), item);
    boolean canHarvestWithHand = canHarvestWithHand();
    int blockId = getId();
    int itemToolType = toolType0(item);
    int itemTier = item.getTier();
    int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
            .map(Enchantment::getLevel).orElse(0);
    int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
            .map(Effect::getAmplifier).orElse(0);
    boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
            Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
                    .map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
    boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
    return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
            efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
 
Example #6
Source File: Block.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public double getBreakTime(Item item, Player player) {
    Objects.requireNonNull(item, "getBreakTime: Item can not be null");
    Objects.requireNonNull(player, "getBreakTime: Player can not be null");
    double blockHardness = getHardness();

    if (blockHardness == 0) {
        return 0;
    }

    boolean correctTool = correctTool0(getToolType(), item);
    boolean canHarvestWithHand = canHarvestWithHand();
    int blockId = getId();
    int itemToolType = toolType0(item);
    int itemTier = item.getTier();
    int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
            .map(Enchantment::getLevel).orElse(0);
    int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
            .map(Effect::getAmplifier).orElse(0);
    boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
            Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
                    .map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
    boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
    return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
            efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
 
Example #7
Source File: BlockLava.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onEntityCollide(Entity entity) {
    entity.highestPosition -= (entity.highestPosition - entity.y) * 0.5;

    // Always setting the duration to 15 seconds? TODO
    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 15);
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled()
            // Making sure the entity is actually alive and not invulnerable.
            && entity.isAlive()
            && entity.noDamageTicks == 0) {
        entity.setOnFire(ev.getDuration());
    }

    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.LAVA, 4));
    }

    super.onEntityCollide(entity);
}
 
Example #8
Source File: Entity.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void fall(float fallDistance) {
    float damage = (float) Math.floor(fallDistance - 3 - (this.hasEffect(Effect.JUMP) ? this.getEffect(Effect.JUMP).getAmplifier() + 1 : 0));
    if (damage > 0) {
        this.attack(new EntityDamageEvent(this, DamageCause.FALL, damage));
    }

    if (fallDistance > 0.75) {
        BlockVector3 v = new BlockVector3(getFloorX(), getFloorY() - 1, getFloorZ());
        int down = this.level.getBlockIdAt(v.x, v.y, v.z);

        if (down == Item.FARMLAND) {
            if (this instanceof Player) {
                Player p = (Player) this;
                PlayerInteractEvent ev = new PlayerInteractEvent(p, p.getInventory().getItemInHand(), this.temporalVector.setComponents(v.x, v.y, v.z), null, Action.PHYSICAL);
                this.server.getPluginManager().callEvent(ev);
                if (ev.isCancelled()) {
                    return;
                }
            }
            this.level.setBlock(this.temporalVector.setComponents(v.x, v.y, v.z), new BlockDirt(), true, true);
        }
    }
}
 
Example #9
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 #10
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 #11
Source File: Entity.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void addEffect(Effect effect) {
    if (effect == null) {
        return; //here add null means add nothing
    }

    Effect oldEffect = this.effects.getOrDefault(effect.getId(), null);
    if (oldEffect != null) {
        if (Math.abs(effect.getAmplifier()) < Math.abs(oldEffect.getAmplifier())) return;
        if (Math.abs(effect.getAmplifier()) == Math.abs(oldEffect.getAmplifier())
                && effect.getDuration() < oldEffect.getDuration()) return;
        effect.add(this, true);
    } else {
        effect.add(this, false);
    }

    this.effects.put(effect.getId(), effect);

    this.recalculateEffectColor();

    if (effect.getId() == Effect.HEALTH_BOOST) {
        this.setHealth(this.getHealth() + 4 * (effect.getAmplifier() + 1));
    }

}
 
Example #12
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
protected void initEntity() {
    if (this.namedTag.contains("ActiveEffects")) {
        ListTag<CompoundTag> effects = this.namedTag.getList("ActiveEffects", CompoundTag.class);
        for (CompoundTag e : effects.getAll()) {
            Effect effect = Effect.getEffect(e.getByte("Id"));
            if (effect == null) {
                continue;
            }

            effect.setAmplifier(e.getByte("Amplifier")).setDuration(e.getInt("Duration")).setVisible(e.getBoolean("showParticles"));

            this.addEffect(effect);
        }
    }

    if (this.namedTag.contains("CustomName")) {
        this.setNameTag(this.namedTag.getString("CustomName"));
        if (this.namedTag.contains("CustomNameVisible")) {
            this.setNameTagVisible(this.namedTag.getBoolean("CustomNameVisible"));
        }
    }

    this.scheduleUpdate();
}
 
Example #13
Source File: FoodEffective.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onEatenBy(Player player) {
    super.onEatenBy(player);
    List<Effect> toApply = new LinkedList<>();
    effects.forEach((effect, chance) -> {
        if (chance >= Math.random()) toApply.add(effect.clone());
    });
    toApply.forEach(player::addEffect);
    return true;
}
 
Example #14
Source File: BlockFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityCollide(Entity entity) {
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
    }

    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 8);
    if (entity instanceof EntityArrow) {
        ev.setCancelled();
    }
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled() && entity instanceof Player && !((Player) entity).isCreative()) {
        entity.setOnFire(ev.getDuration());
    }
}
 
Example #15
Source File: PlayerFood.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void updateFoodExpLevel(double use) {
    if (!this.getPlayer().isFoodEnabled()) return;
    if (Server.getInstance().getDifficulty() == 0) return;
    if (this.getPlayer().hasEffect(Effect.SATURATION)) return;
    this.foodExpLevel += use;
    if (this.foodExpLevel > 4) {
        this.useHunger(1);
        this.foodExpLevel = 0;
    }
}
 
Example #16
Source File: FoodEffective.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onEatenBy(Player player) {
    super.onEatenBy(player);
    List<Effect> toApply = new LinkedList<>();
    effects.forEach((effect, chance) -> {
        if (chance >= Math.random()) toApply.add(effect.clone());
    });
    toApply.forEach(player::addEffect);
    return true;
}
 
Example #17
Source File: EnchantmentDamageArthropods.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void doPostAttack(Entity attacker, Entity entity) {
    if (entity instanceof EntityArthropod) {
        int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level);
        entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3));
    }
}
 
Example #18
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void removeEffect(int effectId) {
    if (this.effects.containsKey(effectId)) {
        Effect effect = this.effects.get(effectId);
        this.effects.remove(effectId);
        effect.remove(this);

        this.recalculateEffectColor();
    }
}
 
Example #19
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void addEffect(Effect effect) {
    if (effect == null) {
        return; //here add null means add nothing
    }

    Effect oldEffect = this.effects.getOrDefault(effect.getId(), null);
    if (oldEffect != null) {
        if (Math.abs(effect.getAmplifier()) < Math.abs(oldEffect.getAmplifier())) {
            return;
        }
        if (Math.abs(effect.getAmplifier()) == Math.abs(oldEffect.getAmplifier())
                && effect.getDuration() < oldEffect.getDuration()) {
            return;
        }
        effect.add(this, true);
    } else {
        effect.add(this, false);
    }

    this.effects.put(effect.getId(), effect);

    this.recalculateEffectColor();

    if (effect.getId() == Effect.HEALTH_BOOST) {
        this.setHealth(this.getHealth() + 4 * (effect.getAmplifier() + 1));
    }

}
 
Example #20
Source File: FoodEffective.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onEatenBy(Player player) {
    super.onEatenBy(player);
    List<Effect> toApply = new LinkedList<>();
    effects.forEach((effect, chance) -> {
        if (chance >= Math.random()) toApply.add(effect.clone());
    });
    toApply.forEach(player::addEffect);
    return true;
}
 
Example #21
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
protected void recalculateEffectColor() {
    int[] color = new int[3];
    int count = 0;
    boolean ambient = true;
    for (Effect effect : this.effects.values()) {
        if (effect.isVisible()) {
            int[] c = effect.getColor();
            color[0] += c[0] * (effect.getAmplifier() + 1);
            color[1] += c[1] * (effect.getAmplifier() + 1);
            color[2] += c[2] * (effect.getAmplifier() + 1);
            count += effect.getAmplifier() + 1;
            if (!effect.isAmbient()) {
                ambient = false;
            }
        }
    }

    if (count > 0) {
        int r = (color[0] / count) & 0xff;
        int g = (color[1] / count) & 0xff;
        int b = (color[2] / count) & 0xff;

        this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, (r << 16) + (g << 8) + b));
        this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, ambient ? 1 : 0));
    } else {
        this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0));
        this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0));
    }
}
 
Example #22
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void sendPotionEffects(Player player) {
    for (Effect effect : this.effects.values()) {
        MobEffectPacket pk = new MobEffectPacket();
        pk.eid = this.getId();
        pk.effectId = effect.getId();
        pk.amplifier = effect.getAmplifier();
        pk.particles = effect.isVisible();
        pk.duration = effect.getDuration();
        pk.eventId = MobEffectPacket.EVENT_ADD;

        player.dataPacket(pk);
    }
}
 
Example #23
Source File: EntityDamageByEntityEvent.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
protected void addAttackerModifiers(Entity damager) {
    if (damager.hasEffect(Effect.STRENGTH)) {
        this.setDamage((float) (this.getDamage(DamageModifier.BASE) * 0.3 * (damager.getEffect(Effect.STRENGTH).getAmplifier() + 1)), DamageModifier.STRENGTH);
    }

    if (damager.hasEffect(Effect.WEAKNESS)) {
        this.setDamage(-(float) (this.getDamage(DamageModifier.BASE) * 0.2 * (damager.getEffect(Effect.WEAKNESS).getAmplifier() + 1)), DamageModifier.WEAKNESS);
    }
}
 
Example #24
Source File: EnchantmentDamageArthropods.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void doPostAttack(Entity attacker, Entity entity) {
    if (entity instanceof EntityArthropod) {
        int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level);
        entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3));
    }
}
 
Example #25
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
protected void recalculateEffectColor() {
    int[] color = new int[3];
    int count = 0;
    boolean ambient = true;
    for (Effect effect : this.effects.values()) {
        if (effect.isVisible()) {
            int[] c = effect.getColor();
            color[0] += c[0] * (effect.getAmplifier() + 1);
            color[1] += c[1] * (effect.getAmplifier() + 1);
            color[2] += c[2] * (effect.getAmplifier() + 1);
            count += effect.getAmplifier() + 1;
            if (!effect.isAmbient()) {
                ambient = false;
            }
        }
    }

    if (count > 0) {
        int r = (color[0] / count) & 0xff;
        int g = (color[1] / count) & 0xff;
        int b = (color[2] / count) & 0xff;

        this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, (r << 16) + (g << 8) + b));
        this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, ambient ? 1 : 0));
    } else {
        this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0));
        this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0));
    }
}
 
Example #26
Source File: BlockMagma.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityCollide(Entity entity) {
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        if (entity instanceof Player) {
            Player p = (Player) entity;
            if (!p.isCreative() && !p.isSpectator() && !p.isSneaking()) {
                entity.attack(new EntityDamageByBlockEvent(this, entity, EntityDamageEvent.DamageCause.LAVA, 1));
            }
        } else {
            entity.attack(new EntityDamageByBlockEvent(this, entity, EntityDamageEvent.DamageCause.LAVA, 1));
        }
    }
}
 
Example #27
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void sendPotionEffects(Player player) {
    for (Effect effect : this.effects.values()) {
        MobEffectPacket pk = new MobEffectPacket();
        pk.eid = this.getId();
        pk.effectId = effect.getId();
        pk.amplifier = effect.getAmplifier();
        pk.particles = effect.isVisible();
        pk.duration = effect.getDuration();
        pk.eventId = MobEffectPacket.EVENT_ADD;

        player.dataPacket(pk);
    }
}
 
Example #28
Source File: BlockFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityCollide(Entity entity) {
    if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
        entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
    }

    EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 8);
    if (entity instanceof EntityArrow) {
        ev.setCancelled();
    }
    Server.getInstance().getPluginManager().callEvent(ev);
    if (!ev.isCancelled() && entity.isAlive() && entity.noDamageTicks == 0) {
        entity.setOnFire(ev.getDuration());
    }
}
 
Example #29
Source File: PlayerFood.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void updateFoodExpLevel(double use) {
    if (!this.getPlayer().isFoodEnabled()) return;
    if (Server.getInstance().getDifficulty() == 0) return;
    if (this.getPlayer().hasEffect(Effect.SATURATION)) return;
    this.foodExpLevel += use;
    if (this.foodExpLevel > 4) {
        this.useHunger(1);
        this.foodExpLevel = 0;
    }
}
 
Example #30
Source File: EntityDamageEvent.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public EntityDamageEvent(Entity entity, DamageCause cause, Map<DamageModifier, Float> modifiers) {
    this.entity = entity;
    this.cause = cause;
    this.modifiers = new EnumMap<>(modifiers);

    this.originals = ImmutableMap.copyOf(this.modifiers);

    if (!this.modifiers.containsKey(DamageModifier.BASE)) {
        throw new EventException("BASE Damage modifier missing");
    }

    if (entity.hasEffect(Effect.DAMAGE_RESISTANCE)) {
        this.setDamage((float) -(this.getDamage(DamageModifier.BASE) * 0.20 * (entity.getEffect(Effect.DAMAGE_RESISTANCE).getAmplifier() + 1)), DamageModifier.RESISTANCE);
    }
}