use of com.skelril.nitro.position.CuboidContainmentPredicate in project Skree by Skelril.
the class DamageNearby method apply.
@Override
public Optional<Instruction<DamagedCondition, T>> apply(DamagedCondition damagedCondition, T bossDetail) {
Living boss = bossDetail.getTargetEntity().get();
CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(boss.getLocation().getPosition(), 2, 2, 2);
boss.getNearbyEntities(e -> predicate.test(e.getLocation().getPosition())).stream().filter(e -> e instanceof Living).map(e -> (Living) e).filter(e -> checkTarget(bossDetail, e)).forEach(e -> damage(bossDetail, e));
return Optional.empty();
}
use of com.skelril.nitro.position.CuboidContainmentPredicate 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();
});
}
use of com.skelril.nitro.position.CuboidContainmentPredicate in project Skree by Skelril.
the class JungleRaidEffectListener method onProjectileHit.
@Listener
public void onProjectileHit(CollideEvent.Impact event, @First Entity entity) {
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(entity);
if (!optInst.isPresent()) {
return;
}
JungleRaidInstance inst = optInst.get();
if (inst.getState() != JungleRaidState.IN_PROGRESS) {
return;
}
int explosionSize = 2;
if (entity.getType() == EntityTypes.TIPPED_ARROW) {
if (inst.isFlagEnabled(JungleRaidFlag.TORMENT_ARROWS)) {
ProjectileSource shooter = ((Arrow) entity).getShooter();
CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(entity.getLocation().getPosition(), 4, 4, 4);
for (Entity e : entity.getNearbyEntities(en -> predicate.test(en.getLocation().getPosition()))) {
if (e.equals(shooter)) {
continue;
}
if (e instanceof Living && shooter instanceof Living) {
e.damage(1, IndirectEntityDamageSource.builder().type(DamageTypes.PROJECTILE).entity(entity).proxySource((Living) shooter).build());
if (Probability.getChance(5)) {
EntityHealthUtil.heal((Living) shooter, 1);
}
}
}
}
if (inst.isFlagEnabled(JungleRaidFlag.EXPLOSIVE_ARROWS)) {
if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
explosionSize = 4;
}
} else {
return;
}
}
if (entity instanceof Snowball) {
if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
explosionSize = 10;
} else {
explosionSize = 6;
}
} else {
return;
}
}
if (entity instanceof ThrownPotion) {
return;
}
entity.getLocation().getExtent().triggerExplosion(Explosion.builder().radius(explosionSize).location(entity.getLocation()).shouldDamageEntities(true).shouldBreakBlocks(true).build(), Cause.source(SkreePlugin.container()).build());
}
Aggregations