use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class FreakyFourInstance method runCharlotte.
private void runCharlotte() {
Living boss = getBoss(FreakyFourBoss.CHARLOTTE).get();
for (int i = Probability.getRandom(10); i > 0; --i) {
spawnCharlotteMinion(boss.getLocation().getPosition());
}
ZoneBoundingBox charlotteRG = regions.get(FreakyFourBoss.CHARLOTTE);
switch(Probability.getRandom(3)) {
case 1:
createWall(charlotteRG, type -> type == BlockTypes.AIR, type -> type == BlockTypes.WEB, BlockTypes.AIR, BlockTypes.WEB, 1, config.charlotteFloorWeb);
break;
case 2:
if (boss instanceof Monster) {
Optional<Entity> optTarget = ((Monster) boss).getTarget();
if (optTarget.isPresent() && contains(optTarget.get())) {
Entity target = optTarget.get();
ZoneBoundingBox targetArea = new ZoneBoundingBox(target.getLocation().getPosition().sub(1, 1, 1).toInt(), new Vector3i(3, 3, 3));
targetArea.forAll(pt -> {
if (getRegion().getExtent().getBlockType(pt) == BlockTypes.AIR) {
getRegion().getExtent().setBlockType(pt, BlockTypes.WEB, Cause.source(SkreePlugin.container()).build());
}
});
}
break;
}
case 3:
charlotteRG.forAll(pt -> {
if (!Probability.getChance(config.charlotteWebSpider)) {
return;
}
if (getRegion().getExtent().getBlockType(pt) == BlockTypes.WEB) {
getRegion().getExtent().setBlockType(pt, BlockTypes.AIR, Cause.source(SkreePlugin.container()).build());
spawnCharlotteMinion(pt.toDouble().add(.5, 0, .5));
}
});
break;
}
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class RangedSpecialAttackClusterListener method getSource.
public Optional<Clause<Living, ItemStackSnapshot>> getSource(Cause cause) {
Optional<EntityDamageSource> optEntityDamageSource = cause.first(EntityDamageSource.class);
if (!optEntityDamageSource.isPresent()) {
return Optional.empty();
}
EntityDamageSource damageSource = optEntityDamageSource.get();
if (!(damageSource instanceof IndirectEntityDamageSource)) {
return Optional.empty();
}
Entity projectile = damageSource.getSource();
Entity source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
if (!(source instanceof Living)) {
return Optional.empty();
}
return Optional.of(new Clause<>((Living) source, projectile.get(SHOOTING_ITEM_DATA_KEY).map(Optional::get).orElse(null)));
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class DefensiveClusterListener method getSource.
public Optional<Living> getSource(Cause cause) {
Optional<EntityDamageSource> optEntityDamageSource = cause.first(EntityDamageSource.class);
if (!optEntityDamageSource.isPresent()) {
return Optional.empty();
}
EntityDamageSource damageSource = optEntityDamageSource.get();
Entity source;
if (damageSource instanceof IndirectEntityDamageSource) {
source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
} else {
source = damageSource.getSource();
}
if (!(source instanceof Living)) {
return Optional.empty();
}
return Optional.of((Living) source);
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class DefensiveClusterListener method onPlayerCombat.
@Listener(order = Order.LATE)
public void onPlayerCombat(DamageEntityEvent event) {
Entity defendingEntity = event.getTargetEntity();
if (!(defendingEntity instanceof Living)) {
return;
}
Optional<Living> optAttackingEntity = getSource(event.getCause());
if (!optAttackingEntity.isPresent()) {
return;
}
Living attackingEntity = optAttackingEntity.get();
if (!applicabilityTest.test((Living) defendingEntity, null)) {
return;
}
if (cooldownHandler.canUseAbility(defendingEntity)) {
cooldownHandler.useAbility(defendingEntity);
} else {
return;
}
defensiveCluster.getNextAbilityToUse().run((Living) defendingEntity, attackingEntity, event);
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class MeleeAttackClusterListener method onPlayerCombat.
@Listener(order = Order.LATE)
public void onPlayerCombat(DamageEntityEvent event) {
Entity targetEntity = event.getTargetEntity();
if (!(targetEntity instanceof Living)) {
return;
}
Optional<Living> optSourceEntity = getSource(event.getCause());
if (!optSourceEntity.isPresent()) {
return;
}
Living sourceEntity = optSourceEntity.get();
if (!test(sourceEntity)) {
return;
}
if (cooldownHandler.canUseAbility(sourceEntity)) {
cooldownHandler.useAbility(sourceEntity);
} else {
return;
}
attackCluster.getNextAttackToRun().run(sourceEntity, (Living) targetEntity, event);
}
Aggregations