Search in sources :

Example 1 with PotionEffect

use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.

the class PatientXInstance 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));
    getRegion().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 2 with PotionEffect

use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.

the class CursedMineInstance method poison.

public void poison(Player player, int duration) {
    if (Probability.getChance(player.getLocation().getBlockY() / 2)) {
        PotionEffect posionEffect = PotionEffect.of(PotionEffectTypes.POISON, 2, 20 * duration);
        List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
        potionEffects.add(posionEffect);
        player.offer(Keys.POTION_EFFECTS, potionEffects);
        player.sendMessage(Text.of(TextColors.RED, "The ore releases a toxic gas poisoning you!"));
    }
}
Also used : PotionEffect(org.spongepowered.api.effect.potion.PotionEffect)

Example 3 with PotionEffect

use of org.spongepowered.api.effect.potion.PotionEffect 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 4 with PotionEffect

use of org.spongepowered.api.effect.potion.PotionEffect 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 5 with PotionEffect

use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.

the class FreakyFourInstance method runFrimus.

private void runFrimus() {
    createWall(getRegion(FreakyFourBoss.FRIMUS), type -> type == BlockTypes.AIR, type -> type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA, BlockTypes.AIR, BlockTypes.LAVA, config.frimusWallDensity, -1);
    for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
        List<PotionEffect> oldPotions = player.get(Keys.POTION_EFFECTS).orElse(new ArrayList<>());
        List<PotionEffect> newPotions = oldPotions.stream().filter(effect -> effect.getType() != PotionEffectTypes.FIRE_RESISTANCE).collect(Collectors.toList());
        if (oldPotions.size() != newPotions.size()) {
            player.offer(Keys.POTION_EFFECTS, newPotions);
        }
    }
}
Also used : LegacyZoneBase(com.skelril.skree.content.zone.LegacyZoneBase) Boss(com.skelril.openboss.Boss) Keys(org.spongepowered.api.data.key.Keys) BossManager(com.skelril.openboss.BossManager) PARTICIPANT(com.skelril.skree.service.internal.zone.PlayerClassifier.PARTICIPANT) SpawnCause(org.spongepowered.api.event.cause.entity.spawn.SpawnCause) Vector3d(com.flowpowered.math.vector.Vector3d) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) ArrayList(java.util.ArrayList) TimedRunnable(com.skelril.nitro.time.TimedRunnable) PotionEffectTypes(org.spongepowered.api.effect.potion.PotionEffectTypes) CharlotteBossManager(com.skelril.skree.content.zone.group.freakyfour.boss.CharlotteBossManager) SkreePlugin(com.skelril.skree.SkreePlugin) FrimusBossManager(com.skelril.skree.content.zone.group.freakyfour.boss.FrimusBossManager) EntityTypes(org.spongepowered.api.entity.EntityTypes) DaBombBossManager(com.skelril.skree.content.zone.group.freakyfour.boss.DaBombBossManager) ZoneRegion(com.skelril.skree.service.internal.zone.ZoneRegion) Task(org.spongepowered.api.scheduler.Task) ZoneStatus(com.skelril.skree.service.internal.zone.ZoneStatus) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) Probability(com.skelril.nitro.probability.Probability) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail) Living(org.spongepowered.api.entity.living.Living) CaveSpider(org.spongepowered.api.entity.living.monster.CaveSpider) Location(org.spongepowered.api.world.Location) EnumMap(java.util.EnumMap) Predicate(java.util.function.Predicate) BlockTypes(org.spongepowered.api.block.BlockTypes) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) PlayerClassifier(com.skelril.skree.service.internal.zone.PlayerClassifier) Entity(org.spongepowered.api.entity.Entity) Collectors(java.util.stream.Collectors) Monster(org.spongepowered.api.entity.living.monster.Monster) SnipeeBossManager(com.skelril.skree.content.zone.group.freakyfour.boss.SnipeeBossManager) Cause(org.spongepowered.api.event.cause.Cause) SpawnTypes(org.spongepowered.api.event.cause.entity.spawn.SpawnTypes) List(java.util.List) Explosion(org.spongepowered.api.world.explosion.Explosion) VelocityEntitySpawner(com.skelril.nitro.entity.VelocityEntitySpawner) Vector3i(com.flowpowered.math.vector.Vector3i) BlockType(org.spongepowered.api.block.BlockType) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox) Clause(com.skelril.nitro.Clause) Player(org.spongepowered.api.entity.living.player.Player) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect)

Aggregations

PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)37 Entity (org.spongepowered.api.entity.Entity)11 Player (org.spongepowered.api.entity.living.player.Player)11 ArrayList (java.util.ArrayList)6 Vector3d (com.flowpowered.math.vector.Vector3d)5 List (java.util.List)5 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)5 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)4 MobEffectInstance (net.minecraft.world.effect.MobEffectInstance)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)3 TimedRunnable (com.skelril.nitro.time.TimedRunnable)3 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 BlockType (org.spongepowered.api.block.BlockType)3 Keys (org.spongepowered.api.data.Keys)3 Keys (org.spongepowered.api.data.key.Keys)3 Listener (org.spongepowered.api.event.Listener)3 Cause (org.spongepowered.api.event.cause.Cause)3