Search in sources :

Example 26 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class GoldRushInstance method moveToRoom.

private void moveToRoom(Player player, ZoneBoundingBox room) {
    Vector3d target = room.getCenter();
    target = new Vector3d(target.getX(), 2, target.getZ());
    player.setLocation(new Location<>(getRegion().getExtent(), target));
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d)

Example 27 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class SkyWarsInstance method setup.

private void setup() {
    teams = createTeamsMapping();
    Vector3d centerPoint = getRegion().getCenter();
    startingLocation = new Location<>(getRegion().getExtent(), centerPoint.getX(), 14, centerPoint.getZ());
    showStartingPlatform(true);
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d)

Example 28 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class AntiPeskListener method punish.

private void punish(Player player) {
    player.sendMessage(Text.of(TextColors.RED, "Command forbidden..."));
    player.sendMessage(Text.of(TextColors.RED, "... prepare to hate your life ..."));
    IntegratedRunnable integratedRunnable = new IntegratedRunnable() {

        @Override
        public boolean run(int times) {
            player.setVelocity(new Vector3d(Probability.getRangedRandom(-3.0, 3.0), Probability.getRangedRandom(-3.0, 3.0), Probability.getRangedRandom(-3.0, 3.0)));
            return true;
        }

        @Override
        public void end() {
            player.kick(Text.of("How about you don't do that again, K?"));
        }
    };
    TimedRunnable<IntegratedRunnable> runnable = new TimedRunnable<>(integratedRunnable, 12);
    Task task = Task.builder().execute(runnable).interval(1, TimeUnit.SECONDS).delay(5, TimeUnit.SECONDS).submit(SkreePlugin.inst());
    runnable.setTask(task);
}
Also used : Task(org.spongepowered.api.scheduler.Task) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) Vector3d(com.flowpowered.math.vector.Vector3d) TimedRunnable(com.skelril.nitro.time.TimedRunnable)

Example 29 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class VelocityEntitySpawner method sendRadial.

public static List<Entity> sendRadial(EntityType type, Living living, int amt, float speed, Cause cause) {
    Location<World> livingLocation = living.getLocation();
    Optional<EyeLocationProperty> optEyeLoc = living.getProperty(EyeLocationProperty.class);
    if (optEyeLoc.isPresent()) {
        Vector3d eyePosition = optEyeLoc.get().getValue();
        livingLocation = livingLocation.setPosition(eyePosition);
    }
    return sendRadial(type, livingLocation, amt, speed, cause);
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) World(org.spongepowered.api.world.World) EyeLocationProperty(org.spongepowered.api.data.property.entity.EyeLocationProperty)

Example 30 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class VelocityEntitySpawner method send.

public static Optional<Entity> send(EntityType type, Location<World> loc, Vector3d dir, float speed, Cause cause) {
    Vector3d actualDir = dir.normalize();
    // Shift the entity out two movements to prevent collision with the source entity
    Vector3d finalVecLoc = loc.getPosition().add(actualDir.mul(2));
    loc = loc.setPosition(finalVecLoc);
    Entity entity = loc.getExtent().createEntity(type, loc.getPosition());
    entity.setVelocity(dir.mul(speed));
    return loc.getExtent().spawnEntity(entity, cause) ? Optional.of(entity) : Optional.empty();
}
Also used : Entity(org.spongepowered.api.entity.Entity) Vector3d(com.flowpowered.math.vector.Vector3d)

Aggregations

Vector3d (com.flowpowered.math.vector.Vector3d)30 Location (org.spongepowered.api.world.Location)11 Entity (org.spongepowered.api.entity.Entity)10 Player (org.spongepowered.api.entity.living.player.Player)9 World (org.spongepowered.api.world.World)9 BlockType (org.spongepowered.api.block.BlockType)5 Listener (org.spongepowered.api.event.Listener)5 ItemStack (org.spongepowered.api.item.inventory.ItemStack)5 Vector3i (com.flowpowered.math.vector.Vector3i)4 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)4 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)4 Zombie (org.spongepowered.api.entity.living.monster.Zombie)4 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)4 ItemDropper (com.skelril.nitro.item.ItemDropper)3 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)3 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)3 TimedRunnable (com.skelril.nitro.time.TimedRunnable)3 ParticleEffect (org.spongepowered.api.effect.particle.ParticleEffect)3 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)3 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)3