use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class MeleeAttackClusterListener 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 = 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 ItemVortex method run.
@Override
public void run(Living owner, Location<World> target) {
IntegratedRunnable vortex = new IntegratedRunnable() {
@Override
public boolean run(int times) {
ParticleGenerator.enderTeleport(target, 1);
getTargetEntities(target).stream().filter(e -> e instanceof Item).forEach(e -> {
e.setLocation(owner.getLocation());
});
return true;
}
@Override
public void end() {
}
};
TimedRunnable<IntegratedRunnable> runnable = new TimedRunnable<>(vortex, 3);
Task task = Task.builder().execute(runnable).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
runnable.setTask(task);
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class DoomBlade method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
notify(owner, Text.of(TextColors.YELLOW, "Your weapon releases a huge burst of energy."));
double dmgTotal = 0;
for (Entity e : getTargetEntities(target)) {
if (!e.isRemoved() && e instanceof Living) {
if (e.equals(owner)) {
continue;
}
double damage = getDamage(e);
if (!e.damage(damage, damageSource(owner))) {
continue;
}
ParticleGenerator.mobSpawnerFlames(e.getLocation(), 20);
dmgTotal += damage;
}
}
notify(owner, Text.of(TextColors.YELLOW, "Your sword dishes out an incredible ", (int) Math.ceil(dmgTotal), " damage!"));
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class FearBomb method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
final List<Location<World>> blocks = new ArrayList<>();
Location<World> originalLocation = target.getLocation();
Vector3d max = originalLocation.getPosition().add(1, 0, 1);
Vector3d min = originalLocation.getPosition().sub(1, 0, 1);
for (int x = min.getFloorX(); x <= max.getFloorX(); ++x) {
for (int z = min.getFloorZ(); z <= max.getFloorZ(); ++z) {
Location<World> loc = target.getLocation().setBlockPosition(new Vector3i(x, target.getLocation().getBlockY(), z));
while (loc.getY() > 0 && isPassable(loc.getBlockType())) {
loc = loc.add(0, -1, 0);
}
blocks.add(loc);
}
}
IntegratedRunnable bomb = new IntegratedRunnable() {
@Override
public boolean run(int times) {
Collection<Player> players = blocks.get(0).getExtent().getPlayers();
for (Location<World> loc : blocks) {
if (isPassable(loc.getBlockType())) {
continue;
}
for (Player player : players) {
player.sendBlockChange(loc.getBlockPosition(), times % 2 == 0 ? WHITE_WOOL_STATE : RED_WOOL_STATE);
}
}
return true;
}
@Override
public void end() {
Collection<Player> players = blocks.get(0).getExtent().getPlayers();
for (Location<World> loc : blocks) {
loc.getExtent().triggerExplosion(Explosion.builder().radius(3).location(loc).shouldBreakBlocks(false).shouldDamageEntities(false).canCauseFire(false).build(), Cause.source(SkreePlugin.container()).build());
for (Player player : players) {
player.resetBlockChange(loc.getBlockPosition());
}
}
getTargetEntities(originalLocation).stream().filter((e) -> e instanceof Monster || e instanceof Player).forEach((entity) -> {
entity.damage(10000, damageSource(owner));
});
}
};
TimedRunnable<IntegratedRunnable> timedRunnable = new TimedRunnable<>(bomb, 6);
Task task = Task.builder().execute(timedRunnable).interval(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
timedRunnable.setTask(task);
notify(owner, Text.of(TextColors.YELLOW, "Your bow creates a powerful bomb."));
}
use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.
the class FearStrike method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
for (Entity e : getTargetEntities(target)) {
if (!e.isRemoved() && e instanceof Living) {
if (e.equals(owner)) {
continue;
}
if (!e.damage(10, damageSource(owner))) {
continue;
}
Vector3d velocity = EntityDirectionUtil.getFacingVector(owner).mul(2);
velocity = new Vector3d(velocity.getX(), Math.max(velocity.getY(), Math.random() * 1.3 + 1.97), velocity.getZ());
e.setVelocity(velocity);
e.offer(Keys.FIRE_TICKS, 20 * (Probability.getRandom(40) + 20));
}
}
notify(owner, Text.of(TextColors.YELLOW, "You fire a terrifyingly powerful shot."));
}
Aggregations