Search in sources :

Example 16 with Entity

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());
}
Also used : Entity(org.spongepowered.api.entity.Entity)

Example 17 with Entity

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());
}
Also used : Entity(org.spongepowered.api.entity.Entity) Vector3d(com.flowpowered.math.vector.Vector3d) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType)

Example 18 with Entity

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);
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) World(org.spongepowered.api.world.World)

Example 19 with Entity

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);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Listener(org.spongepowered.api.event.Listener)

Example 20 with Entity

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;
}
Also used : Entity(org.spongepowered.api.entity.Entity) Vector3d(com.flowpowered.math.vector.Vector3d) ArrayList(java.util.ArrayList)

Aggregations

Entity (org.spongepowered.api.entity.Entity)59 Player (org.spongepowered.api.entity.living.player.Player)23 World (org.spongepowered.api.world.World)19 Living (org.spongepowered.api.entity.living.Living)17 Listener (org.spongepowered.api.event.Listener)13 Vector3d (com.flowpowered.math.vector.Vector3d)10 ArrayList (java.util.ArrayList)8 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)8 Instruction (com.skelril.openboss.Instruction)7 ItemStack (org.spongepowered.api.item.inventory.ItemStack)7 Location (org.spongepowered.api.world.Location)7 Zombie (org.spongepowered.api.entity.living.monster.Zombie)6 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)6 ZoneBossDetail (com.skelril.skree.content.zone.ZoneBossDetail)5 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)5 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)5 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)5 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)4 Vector3i (com.flowpowered.math.vector.Vector3i)3 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)3