use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class PlayerCombatParser method parse.
default default void parse(DamageEntityEvent event) {
Entity entity = event.getTargetEntity();
if (!(entity instanceof Living)) {
return;
}
Optional<DamageSource> optDamageSource = event.getCause().first(DamageSource.class);
if (optDamageSource.isPresent()) {
Entity srcEntity = null;
Entity indirectSrcEntity = null;
if (optDamageSource.get() instanceof IndirectEntityDamageSource) {
srcEntity = ((IndirectEntityDamageSource) optDamageSource.get()).getIndirectSource();
indirectSrcEntity = ((IndirectEntityDamageSource) optDamageSource.get()).getSource();
} else if (optDamageSource.get() instanceof EntityDamageSource) {
srcEntity = ((EntityDamageSource) optDamageSource.get()).getSource();
}
if (!(srcEntity instanceof Living)) {
if (entity instanceof Player) {
processNonLivingAttack(optDamageSource.get(), (Player) entity);
}
return;
}
Living living = (Living) srcEntity;
if (verify(living)) {
if (entity instanceof Player && living instanceof Player) {
processPvP((Player) living, (Player) entity);
processPvP((Player) living, (Player) entity, indirectSrcEntity);
} else if (entity instanceof Player) {
processMonsterAttack(living, (Player) entity);
} else if (living instanceof Player) {
processPlayerAttack((Player) living, (Living) entity);
}
}
}
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class PlayerCombatParser method parse.
default default void parse(CollideEntityEvent.Impact event) {
Optional<Projectile> optProjectile = event.getCause().first(Projectile.class);
if (!optProjectile.isPresent()) {
return;
}
Projectile projectile = optProjectile.get();
ProjectileSource source = optProjectile.get().getShooter();
if (!(source instanceof Player)) {
return;
}
Player attacker = (Player) source;
for (Entity anEntity : event.getEntities()) {
if (anEntity instanceof Player) {
Player defender = (Player) anEntity;
processPvP(attacker, defender);
processPvP(attacker, defender, projectile);
}
}
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class ThorAttack method apply.
@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
Living bossEnt = zombieCatacombsBossDetailBoss.getTargetEntity().get();
Entity toHit = damageCondition.getAttacked();
toHit.setVelocity(EntityDirectionUtil.getFacingVector(bossEnt).mul(2));
Task.builder().execute(() -> {
Location<World> targetLoc = toHit.getLocation();
Task.builder().execute(() -> {
Lightning lightning = (Lightning) toHit.getWorld().createEntity(EntityTypes.LIGHTNING, targetLoc.getPosition());
toHit.getWorld().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}).delay(750, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
}).delay(1500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
return Optional.empty();
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class FreakyFourInstance method spawnCharlotteMinion.
private void spawnCharlotteMinion(Vector3d position) {
Entity entity = getRegion().getExtent().createEntity(EntityTypes.CAVE_SPIDER, position);
getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
Boss<CaveSpider, ZoneBossDetail<FreakyFourInstance>> boss = new Boss<>((CaveSpider) entity, new ZoneBossDetail<>(this));
charlotteMinions.add(boss);
charlotteManager.getMinionManager().bind(boss);
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class FrimusBossManager 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, Math.max(1, Probability.getRandom(EntityHealthUtil.getHealth((Living) attacked)) - 5));
condition.getEvent().setBaseDamage(0);
}
return Optional.empty();
});
}
Aggregations