Search in sources :

Example 1 with Vector3i

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

the class Luminositor method onRightClick.

@Listener
public void onRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
    Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
    if (optHeldItem.isPresent()) /* && optClickedPosition.isPresent() */
    {
        if (this.equals(optHeldItem.get().getItem())) {
            Direction dir = event.getTargetSide();
            Optional<Location<World>> optTargetBlockLoc = event.getTargetBlock().getLocation();
            if (!optTargetBlockLoc.isPresent()) {
                return;
            }
            Location<World> targetBlockLoc = optTargetBlockLoc.get();
            Vector3i targPos = targetBlockLoc.getBlockPosition().add(dir.toVector3d().toInt());
            Location<World> trueTargBlock = new Location<>(targetBlockLoc.getExtent(), targPos);
            int lightLevel = LightLevelUtil.getMaxLightLevel(trueTargBlock).get();
            TextColor color;
            if (lightLevel >= 12) {
                color = TextColors.GREEN;
            } else if (lightLevel >= 8) {
                color = TextColors.RED;
            } else {
                color = TextColors.DARK_RED;
            }
            // TODO system message.color(color)
            player.sendMessage(Text.of(TextColors.YELLOW, "Light level: ", color, lightLevel));
            event.setUseBlockResult(Tristate.FALSE);
        }
    }
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) TextColor(org.spongepowered.api.text.format.TextColor) ItemStack(org.spongepowered.api.item.inventory.ItemStack) World(org.spongepowered.api.world.World) Direction(org.spongepowered.api.util.Direction) Location(org.spongepowered.api.world.Location) Listener(org.spongepowered.api.event.Listener)

Example 2 with Vector3i

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

the class BarrierBlockTerrainGenerator method populate.

@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
    Vector3i min = buffer.getBlockMin();
    Vector3i max = buffer.getBlockMax();
    for (int y = min.getY(); y <= max.getY(); ++y) {
        for (int x = min.getX(); x <= max.getX(); ++x) {
            for (int z = min.getZ(); z <= max.getZ(); ++z) {
                buffer.setBlockType(x, y, z, BlockTypes.BARRIER, Cause.source(SkreePlugin.container()).build());
            }
        }
    }
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i)

Example 3 with Vector3i

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

the class SolidWorldTerrainGenerator method populate.

@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
    Vector3i min = buffer.getBlockMin();
    Vector3i max = buffer.getBlockMax();
    for (int y = min.getY(); y <= max.getY() - 5; ++y) {
        for (int x = min.getX(); x <= max.getX(); ++x) {
            for (int z = min.getZ(); z <= max.getZ(); ++z) {
                buffer.setBlockType(x, y, z, BlockTypes.BEDROCK, Cause.source(SkreePlugin.container()).build());
            }
        }
    }
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i)

Example 4 with Vector3i

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

the class CursedMineInstance method setUp.

private void setUp() {
    Vector3i offset = getRegion().getMinimumPoint();
    entryPoint = new Location<>(getRegion().getExtent(), offset.getX() + 71.5, offset.getY() + 59, offset.getZ() + 86.5);
    floodGate = new ZoneBoundingBox(offset.add(66, 40, 131), new Vector3i(13, 1, 9));
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox)

Example 5 with Vector3i

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

the class CursedMineInstance method drain.

public void drain() {
    for (Entity e : getContained(Carrier.class)) {
        // TODO Inventory API not fully implemented
        if (!(e instanceof Player)) {
            continue;
        }
        Inventory eInventory = ((Carrier) e).getInventory();
        if (e instanceof Player) {
            Location<World> playerLoc = e.getLocation();
            // Emerald
            long diff = System.currentTimeMillis() - lastActivation;
            if (playerLoc.getY() < 30 && (lastActivation == 0 || diff <= timeTilPumpShutoff * .35 || diff >= timeTilPumpShutoff * 5)) {
                PositionRandomizer randomizer = new PositionRandomizer(5);
                for (int i = 0; i < Probability.getRangedRandom(2, 5); i++) {
                    Vector3i targetPos;
                    do {
                        targetPos = randomizer.createPosition3i(playerLoc.getPosition());
                    } while (getRegion().getExtent().getBlockType(targetPos) != BlockTypes.AIR);
                    Entity entity = getRegion().getExtent().createEntity(EntityTypes.BLAZE, targetPos);
                    getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.MOB_SPAWNER).build()).build());
                }
            }
        }
        for (int i = 0; i < (eInventory.size() / 2) - 2 || i < 1; i++) {
            if (e instanceof Player) {
                if (Probability.getChance(15) && checkInventory((Player) e)) {
                    ((Player) e).sendMessage(Text.of(TextColors.YELLOW, "Divine intervention protects some of your items."));
                    continue;
                }
            }
            // Iron
            eInventory.query(ItemTypes.IRON_BLOCK).poll(Probability.getRandom(2));
            eInventory.query(ItemTypes.IRON_ORE).poll(Probability.getRandom(4));
            eInventory.query(ItemTypes.IRON_INGOT).poll(Probability.getRandom(8));
            // Gold
            eInventory.query(ItemTypes.GOLD_BLOCK).poll(Probability.getRandom(2));
            eInventory.query(ItemTypes.GOLD_ORE).poll(Probability.getRandom(4));
            eInventory.query(ItemTypes.GOLD_INGOT).poll(Probability.getRandom(10));
            eInventory.query(ItemTypes.GOLD_NUGGET).poll(Probability.getRandom(80));
            // Redstone
            eInventory.query(ItemTypes.REDSTONE_ORE).poll(Probability.getRandom(2));
            eInventory.query(ItemTypes.REDSTONE).poll(Probability.getRandom(34));
            // Lap
            eInventory.query(ItemTypes.LAPIS_BLOCK).poll(Probability.getRandom(2));
            eInventory.query(ItemTypes.LAPIS_ORE).poll(Probability.getRandom(4));
            eInventory.query(LAPIS_DYE).poll(Probability.getRandom(34));
            // Diamond
            eInventory.query(ItemTypes.DIAMOND_BLOCK).poll(Probability.getRandom(2));
            eInventory.query(ItemTypes.DIAMOND_ORE).poll(Probability.getRandom(4));
            eInventory.query(ItemTypes.DIAMOND).poll(Probability.getRandom(16));
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) PositionRandomizer(com.skelril.nitro.position.PositionRandomizer) Player(org.spongepowered.api.entity.living.player.Player) Vector3i(com.flowpowered.math.vector.Vector3i) Carrier(org.spongepowered.api.item.inventory.Carrier) World(org.spongepowered.api.world.World) Inventory(org.spongepowered.api.item.inventory.Inventory)

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