use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class CannonCurse method accept.
@Override
public void accept(Player player) {
Entity entity = player.getWorld().createEntity(EntityTypes.FIREBALL, player.getLocation().getPosition());
player.getWorld().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class DeadlyPotionCurse method throwSlashPotion.
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] { PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS };
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(random.nextDouble() * .5 - .25, random.nextDouble() * .4 + .1, random.nextDouble() * .5 - .25));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class MainWorldWrapper method run.
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder().duration(3 * 20).amplifier(5).particles(false).potionType(PotionEffectTypes.SPEED).build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
use of org.spongepowered.api.entity.Entity 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 (!isApplicable(sourceEntity)) {
return;
}
if (cooldownHandler.canUseAbility(sourceEntity)) {
cooldownHandler.useAbility(sourceEntity);
} else {
return;
}
attackCluster.getNextAttackToRun().run(sourceEntity, (Living) targetEntity, event);
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class VelocityEntitySpawner method sendRadial.
public static List<Entity> sendRadial(EntityType type, Location<World> loc, int amt, float speed, Cause cause) {
final double tau = 2 * Math.PI;
double arc = tau / amt;
List<Entity> resultSet = new ArrayList<>();
for (double a = 0; a < tau; a += arc) {
Optional<Entity> optEnt = send(type, loc, new Vector3d(Math.cos(a), 0, Math.sin(a)), speed, cause);
if (optEnt.isPresent()) {
resultSet.add(optEnt.get());
}
}
return resultSet;
}
Aggregations