Search in sources :

Example 11 with IntegratedRunnable

use of com.skelril.nitro.time.IntegratedRunnable 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);
}
Also used : PointOfContact(com.skelril.nitro.registry.dynamic.ability.PointOfContact) CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) Location(org.spongepowered.api.world.Location) ParticleGenerator(com.skelril.nitro.particle.ParticleGenerator) Collection(java.util.Collection) Item(org.spongepowered.api.entity.Item) Entity(org.spongepowered.api.entity.Entity) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) TimedRunnable(com.skelril.nitro.time.TimedRunnable) TimeUnit(java.util.concurrent.TimeUnit) SkreePlugin(com.skelril.skree.SkreePlugin) World(org.spongepowered.api.world.World) Task(org.spongepowered.api.scheduler.Task) Living(org.spongepowered.api.entity.living.Living) Item(org.spongepowered.api.entity.Item) Task(org.spongepowered.api.scheduler.Task) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) TimedRunnable(com.skelril.nitro.time.TimedRunnable)

Example 12 with IntegratedRunnable

use of com.skelril.nitro.time.IntegratedRunnable 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."));
}
Also used : Keys(org.spongepowered.api.data.key.Keys) Vector3d(com.flowpowered.math.vector.Vector3d) SpecialAttack(com.skelril.nitro.registry.dynamic.ability.SpecialAttack) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) ArrayList(java.util.ArrayList) TimedRunnable(com.skelril.nitro.time.TimedRunnable) SkreePlugin(com.skelril.skree.SkreePlugin) Text(org.spongepowered.api.text.Text) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Task(org.spongepowered.api.scheduler.Task) Living(org.spongepowered.api.entity.living.Living) TextColors(org.spongepowered.api.text.format.TextColors) CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) Location(org.spongepowered.api.world.Location) BlockTypes(org.spongepowered.api.block.BlockTypes) Collection(java.util.Collection) PassableProperty(org.spongepowered.api.data.property.block.PassableProperty) Entity(org.spongepowered.api.entity.Entity) Monster(org.spongepowered.api.entity.living.monster.Monster) BlockState(org.spongepowered.api.block.BlockState) TimeUnit(java.util.concurrent.TimeUnit) AbstractProperty(org.spongepowered.api.data.property.AbstractProperty) Cause(org.spongepowered.api.event.cause.Cause) List(java.util.List) DyeColors(org.spongepowered.api.data.type.DyeColors) Explosion(org.spongepowered.api.world.explosion.Explosion) Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World) BlockType(org.spongepowered.api.block.BlockType) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) Player(org.spongepowered.api.entity.living.player.Player) Task(org.spongepowered.api.scheduler.Task) ArrayList(java.util.ArrayList) World(org.spongepowered.api.world.World) TimedRunnable(com.skelril.nitro.time.TimedRunnable) Vector3d(com.flowpowered.math.vector.Vector3d) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) Monster(org.spongepowered.api.entity.living.monster.Monster) Vector3i(com.flowpowered.math.vector.Vector3i) Location(org.spongepowered.api.world.Location)

Aggregations

IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)12 TimedRunnable (com.skelril.nitro.time.TimedRunnable)12 Task (org.spongepowered.api.scheduler.Task)9 Vector3d (com.flowpowered.math.vector.Vector3d)5 Vector3i (com.flowpowered.math.vector.Vector3i)5 Living (org.spongepowered.api.entity.living.Living)5 SkreePlugin (com.skelril.skree.SkreePlugin)4 TimeUnit (java.util.concurrent.TimeUnit)4 Entity (org.spongepowered.api.entity.Entity)4 Location (org.spongepowered.api.world.Location)4 World (org.spongepowered.api.world.World)4 CuboidContainmentPredicate (com.skelril.nitro.position.CuboidContainmentPredicate)3 BlockType (org.spongepowered.api.block.BlockType)3 Player (org.spongepowered.api.entity.living.player.Player)3 Text (org.spongepowered.api.text.Text)3 TextColors (org.spongepowered.api.text.format.TextColors)3 ParticleGenerator (com.skelril.nitro.particle.ParticleGenerator)2 Probability (com.skelril.nitro.probability.Probability)2 SpecialAttack (com.skelril.nitro.registry.dynamic.ability.SpecialAttack)2 Collection (java.util.Collection)2