use of org.spongepowered.api.entity.projectile.source.ProjectileSource 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.projectile.source.ProjectileSource 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.projectile.source.ProjectileSource 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(), 16, 16, 16);
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());
}
use of org.spongepowered.api.entity.projectile.source.ProjectileSource in project Skree by Skelril.
the class PointOfContactClusterListener method onBlockCollide.
@Listener
public void onBlockCollide(CollideEvent.Impact event, @First Projectile projectile) {
ProjectileSource source = projectile.getShooter();
if (!(source instanceof Living)) {
return;
}
Living sourceEntity = (Living) source;
if (!isApplicable(sourceEntity)) {
return;
}
if (cooldownHandler.canUseAbility(sourceEntity)) {
cooldownHandler.useAbility(sourceEntity);
} else {
return;
}
attackCluster.getNextAbilityToRun().run(sourceEntity, event.getImpactPoint());
}
Aggregations