use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class ArrowFishingHandler method onProjectileTickEvent.
@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
Projectile projectile = event.getTargetEntity();
if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
return;
}
Location<World> loc = projectile.getLocation();
if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
ProjectileSource source = projectile.getShooter();
double modifier = 1;
if (source instanceof Living) {
modifier = 50;
}
Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
int rolls = 1;
if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
if (source instanceof Living) {
rolls = 15;
} else {
rolls = 5;
}
}
new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
}
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class SnipeeBossManager method handleBinds.
private void handleBinds() {
List<Instruction<BindCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> bindProcessor = getBindProcessor();
bindProcessor.add(new NamedBindInstruction<>("Snipee"));
bindProcessor.add(new HealthBindInstruction<>(config.snipeeHP));
bindProcessor.add((condition, boss) -> {
Living entity = boss.getTargetEntity().get();
if (entity instanceof ArmorEquipable) {
((ArmorEquipable) entity).setItemInHand(HandTypes.MAIN_HAND, newItemStack(ItemTypes.BOW));
}
return Optional.empty();
});
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class SnipeeBossManager method handleDamage.
private void handleDamage() {
List<Instruction<DamageCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> damageProcessor = getDamageProcessor();
damageProcessor.add((condition, boss) -> {
Entity attacked = condition.getAttacked();
if (attacked instanceof Living) {
EntityHealthUtil.forceDamage((Living) attacked, EntityHealthUtil.getMaxHealth((Living) attacked) * config.snipeeDamage);
condition.getEvent().setBaseDamage(0);
}
return Optional.empty();
});
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class BackTeleportInstruction method apply.
@Override
public Optional<Instruction<DamagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> apply(DamagedCondition damagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>> livingZoneBossDetailBoss) {
DamageEntityEvent event = damagedCondition.getEvent();
new PlayerCombatParser() {
@Override
public void processPlayerAttack(Player attacker, Living defender) {
boolean backTeleport = Probability.getChance(config.backTeleport);
if (backTeleport || damagedCondition.getDamageSource().get() instanceof IndirectEntityDamageSource) {
double distSQ = 2;
double maxDist = 1;
if (defender instanceof Skeleton) {
distSQ = defender.getLocation().getPosition().distanceSquared(attacker.getLocation().getPosition());
maxDist = config.snipeeTeleportDist;
}
if (backTeleport || distSQ > Math.pow(maxDist, 2)) {
final Entity finalDamager = attacker;
Task.builder().execute(() -> {
defender.setLocation(finalDamager.getLocation());
throwBack(defender);
}).delayTicks(1).submit(SkreePlugin.inst());
}
}
}
}.parse(event);
return Optional.empty();
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class CharlotteBossManager method handleUnbinds.
private void handleUnbinds() {
List<Instruction<UnbindCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> unbindProcessor = getUnbindProcessor();
unbindProcessor.add(new FreakyFourBossDeath());
}
Aggregations