Search in sources :

Example 46 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class GoldRushInstance method randomizeLevers.

private void randomizeLevers() {
    if (System.currentTimeMillis() - lastLeverSwitch >= TimeUnit.SECONDS.toMillis(14)) {
        for (Location<World> entry : leverBlocks.keySet()) {
            BlockState state = entry.getBlock();
            entry.getExtent().setBlock(entry.getBlockPosition(), state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state), Cause.source(SkreePlugin.container()).build());
            leverBlocks.put(entry, !Probability.getChance(3));
        }
        lastLeverSwitch = System.currentTimeMillis();
        randomizeLevers();
    } else if (System.currentTimeMillis() - lastLeverSwitch == 0) {
        for (Location<World> entry : leverBlocks.keySet()) {
            Location<World> targLoc = entry.add(0, -2, 0);
            targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
        }
        Task.builder().execute(() -> {
            for (Map.Entry<Location<World>, Boolean> entry : leverBlocks.entrySet()) {
                Location<World> targLoc = entry.getKey().add(0, -2, 0);
                targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), entry.getValue() ? BlockTypes.REDSTONE_BLOCK : BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
            }
            Task.builder().execute(this::randomizeLevers).delayTicks(15).submit(SkreePlugin.inst());
        }).delayTicks(15).submit(SkreePlugin.inst());
    } else {
        for (Location<World> entry : leverBlocks.keySet()) {
            Location<World> targLoc = entry.add(0, -2, 0);
            targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
        }
    }
}
Also used : BlockState(org.spongepowered.api.block.BlockState) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location)

Example 47 with World

use of org.spongepowered.api.world.World 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 48 with World

use of org.spongepowered.api.world.World 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)

Example 49 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class GoldRushInstance method checkKeys.

public boolean checkKeys() {
    if (!checkingKeys) {
        return keysTriggered;
    }
    for (Location<World> lock : locks) {
        Optional<org.spongepowered.api.block.tileentity.TileEntity> optTileEnt = lock.getTileEntity();
        if (!optTileEnt.isPresent()) {
            return false;
        }
        org.spongepowered.api.block.tileentity.TileEntity tileEnt = optTileEnt.get();
        Optional<List<Text>> optTexts = tileEnt.get(Keys.SIGN_LINES);
        if (!optTexts.isPresent()) {
            return false;
        }
        if (optTexts.get().get(2).toPlain().startsWith("-"))
            return false;
    }
    return true;
}
Also used : TileEntity(org.spongepowered.api.block.tileentity.TileEntity) TileEntity(org.spongepowered.api.block.tileentity.TileEntity) World(org.spongepowered.api.world.World)

Example 50 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class PatientXInstance method setUp.

public void setUp() {
    Vector3i min = getRegion().getMinimumPoint();
    World world = getRegion().getExtent();
    destinations.add(new Location<>(world, min.getX() + 11.5, min.getY() + 25, min.getZ() + 34.5));
    destinations.add(new Location<>(world, min.getX() + 10.5, min.getY() + 20, min.getZ() + 34.5));
    destinations.add(new Location<>(world, min.getX() + 57.5, min.getY() + 25, min.getZ() + 34.5));
    destinations.add(new Location<>(world, min.getX() + 63.5, min.getY() + 25, min.getZ() + 45.5));
    destinations.add(new Location<>(world, min.getX() + 62.5, min.getY() + 18, min.getZ() + 34.5));
    destinations.add(new Location<>(world, min.getX() + 34.5, min.getY() + 29, min.getZ() + 60.5));
    destinations.add(new Location<>(world, min.getX() + 34.5, min.getY() + 18, min.getZ() + 34.5));
    destinations.add(new Location<>(world, min.getX() + 24.5, min.getY() + 29, min.getZ() + 41.5));
    destinations.add(getCenter());
    ice = new ZoneBoundingBox(min.add(14, 17, 14), new Vector3i(49, 1, 45));
    drops = new ZoneBoundingBox(min.add(14, 24, 14), new Vector3i(41, 1, 41));
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World)

Aggregations

World (org.spongepowered.api.world.World)81 Listener (org.spongepowered.api.event.Listener)24 Location (org.spongepowered.api.world.Location)23 Entity (org.spongepowered.api.entity.Entity)18 Player (org.spongepowered.api.entity.living.player.Player)18 Vector3i (com.flowpowered.math.vector.Vector3i)11 WorldService (com.skelril.skree.service.WorldService)11 BlockType (org.spongepowered.api.block.BlockType)10 ItemStack (org.spongepowered.api.item.inventory.ItemStack)10 Vector3d (com.flowpowered.math.vector.Vector3d)9 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)8 ArrayList (java.util.ArrayList)7 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)7 BlockState (org.spongepowered.api.block.BlockState)7 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)6 Living (org.spongepowered.api.entity.living.Living)5 Monster (org.spongepowered.api.entity.living.monster.Monster)5 ItemDropper (com.skelril.nitro.item.ItemDropper)4 ModifierService (com.skelril.skree.service.ModifierService)4 IOException (java.io.IOException)4