Search in sources :

Example 1 with Spider

use of org.spongepowered.api.entity.living.monster.Spider in project Skree by Skelril.

the class Fangz method setupFangz.

private void setupFangz() {
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Spider.class));
    List<Instruction<BindCondition, Boss<Spider, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
    bindProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Fangz"));
            bossEnt.offer(Keys.CUSTOM_NAME_VISIBLE, true);
            double bossHealth = 20 * 50 * boss.getDetail().getLevel();
            setMaxHealth(bossEnt, bossHealth, true);
        }
        return Optional.empty();
    });
    List<Instruction<UnbindCondition, Boss<Spider, WildernessBossDetail>>> unbindProcessor = bossManager.getUnbindProcessor();
    unbindProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(bossEnt.getLocation().getPosition(), 3, 2, 3);
            for (Entity aEntity : bossEnt.getNearbyEntities((entity) -> predicate.test(entity.getLocation().getPosition()))) {
                Optional<PotionEffectData> optPotionEffects = aEntity.getOrCreate(PotionEffectData.class);
                if (!optPotionEffects.isPresent()) {
                    continue;
                }
                PotionEffectData potionEffects = optPotionEffects.get();
                potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, 20 * 30));
                potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 2, 20 * 30));
                aEntity.offer(potionEffects);
            }
        }
        return Optional.empty();
    });
    List<Instruction<DamageCondition, Boss<Spider, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            Entity eToHit = condition.getAttacked();
            if (!(eToHit instanceof Living)) {
                return Optional.empty();
            }
            Living toHit = (Living) eToHit;
            DamageEntityEvent event = condition.getEvent();
            event.setBaseDamage(event.getBaseDamage() * 2);
            EntityHealthUtil.heal(bossEnt, event.getBaseDamage());
            Optional<PotionEffectData> optPotionEffects = toHit.getOrCreate(PotionEffectData.class);
            if (!optPotionEffects.isPresent()) {
                return Optional.empty();
            }
            PotionEffectData potionEffects = optPotionEffects.get();
            potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 1, 20 * 15));
            potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 1, 20 * 15));
            toHit.offer(potionEffects);
        }
        return Optional.empty();
    });
}
Also used : CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Entity(org.spongepowered.api.entity.Entity) WildernessBossDetail(com.skelril.skree.content.world.wilderness.WildernessBossDetail) Living(org.spongepowered.api.entity.living.Living) Instruction(com.skelril.openboss.Instruction) Spider(org.spongepowered.api.entity.living.monster.Spider) PotionEffectData(org.spongepowered.api.data.manipulator.mutable.PotionEffectData)

Aggregations

CuboidContainmentPredicate (com.skelril.nitro.position.CuboidContainmentPredicate)1 Instruction (com.skelril.openboss.Instruction)1 WildernessBossDetail (com.skelril.skree.content.world.wilderness.WildernessBossDetail)1 PotionEffectData (org.spongepowered.api.data.manipulator.mutable.PotionEffectData)1 Entity (org.spongepowered.api.entity.Entity)1 Living (org.spongepowered.api.entity.living.Living)1 Spider (org.spongepowered.api.entity.living.monster.Spider)1 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)1