Search in sources :

Example 21 with Vector3i

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

the class ZonePool method getLastMarkedPoint.

public Vector2i getLastMarkedPoint() throws IllegalStateException {
    if (globalBoxList.isEmpty()) {
        return new Vector2i(0, 0);
    }
    globalBoxList.sort((a, b) -> {
        Vector3i aMax = a.getMaximumPoint();
        Vector3i bMax = b.getMaximumPoint();
        if (aMax.getX() < bMax.getX() || aMax.getZ() < bMax.getZ()) {
            return -1;
        }
        return 1;
    });
    Vector3i lastMax = globalBoxList.get(globalBoxList.size() - 1).getMaximumPoint();
    return new Vector2i(lastMax.getX() + 1, lastMax.getZ() + 1);
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) Vector2i(com.flowpowered.math.vector.Vector2i)

Example 22 with Vector3i

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

the class JungleRaidEffectProcessor method distributor.

private static void distributor(JungleRaidInstance inst) {
    FlagEffectData data = inst.getFlagData();
    boolean isSuddenDeath = inst.isSuddenDeath();
    if (isSuddenDeath) {
        data.amt = 100;
    }
    if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || inst.isFlagEnabled(JungleRaidFlag.GRENADES) || inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET) || isSuddenDeath) {
        Vector3i bvMax = inst.getRegion().getMaximumPoint();
        Vector3i bvMin = inst.getRegion().getMinimumPoint();
        for (int i = 0; i < Probability.getRangedRandom(data.amt / 3, data.amt); i++) {
            Location<World> testLoc = new Location<>(inst.getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY(), Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
            if (testLoc.getBlockType() != BlockTypes.AIR)
                continue;
            if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || isSuddenDeath) {
                PrimedTNT explosive = (PrimedTNT) inst.getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, testLoc.getPosition());
                explosive.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, random.nextDouble() * 2 * -1, random.nextDouble() * 2.0 - 1));
                explosive.offer(Keys.FUSE_DURATION, 20 * 4);
                // TODO used to have a 1/4 chance of creating fire
                inst.getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
            }
            if (inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET)) {
                PotionEffectType type = Probability.pickOneOf(Sponge.getRegistry().getAllOf(PotionEffectType.class));
                for (int ii = Probability.getRandom(5); ii > 0; --ii) {
                    ThrownPotion potion = (ThrownPotion) inst.getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, testLoc.getPosition());
                    potion.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, 0, random.nextDouble() * 2.0 - 1));
                    potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(PotionEffect.of(type, 1, type.isInstant() ? 1 : 20 * 10)));
                    inst.getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
                }
            }
            if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
                new ItemDropper(testLoc).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.SNOWBALL, Probability.getRandom(3))), SpawnTypes.PLUGIN);
            }
        }
        if (data.amt < 150 && Probability.getChance(inst.isFlagEnabled(JungleRaidFlag.SUPER) ? 9 : 25))
            ++data.amt;
    }
}
Also used : PrimedTNT(org.spongepowered.api.entity.explosive.PrimedTNT) ItemDropper(com.skelril.nitro.item.ItemDropper) Vector3d(com.flowpowered.math.vector.Vector3d) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType) Vector3i(com.flowpowered.math.vector.Vector3i) ThrownPotion(org.spongepowered.api.entity.projectile.ThrownPotion) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location)

Example 23 with Vector3i

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

the class GoldRushInstance method setup.

private void setup() {
    Vector3i offset = getRegion().getMinimumPoint();
    rewardChest = new Location<>(getRegion().getExtent(), offset.getX() + 15, offset.getY() + 2, offset.getZ() + 6);
    startingRoom = new ZoneBoundingBox(offset.add(2, 1, 76), new Vector3i(27, 7, 14));
    keyRoom = new ZoneBoundingBox(offset.add(1, 1, 36), new Vector3i(30, 7, 39));
    flashMemoryRoom = new ZoneBoundingBox(offset.add(11, 1, 17), new Vector3i(9, 7, 19));
    flashMemoryDoor = new ZoneBoundingBox(offset.add(14, 1, 36), new Vector3i(3, 3, 1));
    rewardRoomDoor = new ZoneBoundingBox(offset.add(14, 1, 16), new Vector3i(3, 3, 1));
    // Setup room one
    findChestAndKeys();
    // Setup room two
    findLeversAndFloodBlocks();
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i)

Example 24 with Vector3i

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

the class JungleRaidInstance method getRandomLocation.

public Location<World> getRandomLocation() {
    Vector3i offset = getRegion().getMinimumPoint();
    Vector3i boundingBox = getRegion().getBoundingBox();
    while (true) {
        Vector3i randomDest = new Vector3i(Probability.getRandom(boundingBox.getX()), Probability.getRangedRandom(16, 80), Probability.getRandom(boundingBox.getZ())).add(offset);
        Optional<Location<World>> optSafeDest = SafeTeleportHelper.getSafeDest(new Location<>(getRegion().getExtent(), randomDest));
        if (optSafeDest.isPresent()) {
            Location<World> safeDest = optSafeDest.get();
            if (16 < safeDest.getY() && safeDest.getY() < 79) {
                return safeDest.add(.5, 0, .5);
            }
        }
    }
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location)

Example 25 with Vector3i

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

the class GoldRushInstance method flood.

private void flood() {
    if (getTimeSinceStart() >= getTimeTilFlood()) {
        for (Location<World> floodBlock : floodBlocks) {
            floodBlock.getExtent().setBlockType(floodBlock.getBlockPosition(), floodBlockType, Cause.source(SkreePlugin.container()).build());
        }
        if (System.currentTimeMillis() - lastFlood >= TimeUnit.SECONDS.toMillis(30 / getPlayerMod())) {
            Vector3i min = flashMemoryRoom.getMinimumPoint();
            Vector3i max = flashMemoryRoom.getMaximumPoint();
            int minX = min.getX();
            int minZ = min.getZ();
            int minY = min.getY();
            int maxX = max.getX();
            int maxZ = max.getZ();
            int maxY = max.getY();
            for (int x = minX; x <= maxX; x++) {
                for (int z = minZ; z <= maxZ; z++) {
                    for (int y = minY; y <= maxY; y++) {
                        BlockType type = getRegion().getExtent().getBlockType(x, y, z);
                        if (type == BlockTypes.AIR) {
                            getRegion().getExtent().setBlockType(x, y, z, floodBlockType, Cause.source(SkreePlugin.container()).build());
                            break;
                        }
                    }
                }
            }
            lastFlood = System.currentTimeMillis();
        }
    }
}
Also used : BlockType(org.spongepowered.api.block.BlockType) Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World)

Aggregations

Vector3i (com.flowpowered.math.vector.Vector3i)28 World (org.spongepowered.api.world.World)11 Location (org.spongepowered.api.world.Location)8 BlockType (org.spongepowered.api.block.BlockType)5 ZoneBoundingBox (com.skelril.skree.service.internal.zone.ZoneBoundingBox)4 Vector3d (com.flowpowered.math.vector.Vector3d)3 Vector2i (com.flowpowered.math.vector.Vector2i)2 EditSession (com.sk89q.worldedit.EditSession)2 Vector (com.sk89q.worldedit.Vector)2 ItemDropper (com.skelril.nitro.item.ItemDropper)2 PositionRandomizer (com.skelril.nitro.position.PositionRandomizer)2 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)2 TimedRunnable (com.skelril.nitro.time.TimedRunnable)2 Entity (org.spongepowered.api.entity.Entity)2 Listener (org.spongepowered.api.event.Listener)2 ItemStack (org.spongepowered.api.item.inventory.ItemStack)2 Vector2d (com.flowpowered.math.vector.Vector2d)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)1 Operation (com.sk89q.worldedit.function.operation.Operation)1