Search in sources :

Example 11 with Vector3i

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

the class ZoneRelativePositionListener method onBlockInteract.

@Listener
public void onBlockInteract(InteractBlockEvent.Secondary event, @First Player player) {
    Optional<Location<World>> optLocation = event.getTargetBlock().getLocation();
    if (!optLocation.isPresent()) {
        return;
    }
    Location<World> location = optLocation.get();
    Optional<T> optInst = getApplicable(location);
    if (!optInst.isPresent()) {
        return;
    }
    T inst = optInst.get();
    Vector3i minPoint = inst.getRegion().getMinimumPoint();
    Vector3i clickedPoint = location.getBlockPosition();
    Vector3i offset = clickedPoint.sub(minPoint);
    player.sendMessage(Text.of("Offset: ", offset));
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location) Listener(org.spongepowered.api.event.Listener)

Example 12 with Vector3i

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

the class FreakyFourInstance method dabombDetonate.

public void dabombDetonate(double percentEffectiveness) {
    ZoneBoundingBox dabomb_RG = getRegion(FreakyFourBoss.DA_BOMB);
    Vector3i min = dabomb_RG.getMinimumPoint();
    Vector3i max = dabomb_RG.getMaximumPoint();
    int minX = min.getX();
    int minY = min.getY();
    int minZ = min.getZ();
    int maxX = max.getX();
    int maxZ = max.getZ();
    int dmgFact = (int) Math.max(3, percentEffectiveness * config.daBombTNTStrength);
    for (int x = minX; x < maxX; ++x) {
        for (int z = minZ; z < maxZ; ++z) {
            if (Probability.getChance(config.daBombTNT)) {
                getRegion().getExtent().triggerExplosion(Explosion.builder().location(new Location<>(getRegion().getExtent(), new Vector3d(x, minY, z))).radius(dmgFact).canCauseFire(false).shouldDamageEntities(true).build(), Cause.source(SkreePlugin.container()).build());
            }
        }
    }
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) Vector3i(com.flowpowered.math.vector.Vector3i) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox) Location(org.spongepowered.api.world.Location)

Example 13 with Vector3i

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

the class FreakyFourInstance method createWall.

private void createWall(ZoneBoundingBox region, Predicate<BlockType> oldExpr, Predicate<BlockType> newExpr, BlockType oldType, BlockType newType, int density, int floodFloor) {
    final Vector3i min = region.getMinimumPoint();
    final Vector3i max = region.getMaximumPoint();
    int minX = min.getX();
    int minY = min.getY();
    int minZ = min.getZ();
    int maxX = max.getX();
    int maxY = max.getY();
    int maxZ = max.getZ();
    int initialTimes = maxZ - minZ + 1;
    IntegratedRunnable integratedRunnable = new IntegratedRunnable() {

        @Override
        public boolean run(int times) {
            int startZ = minZ + (initialTimes - times) - 1;
            for (int x = minX; x <= maxX; ++x) {
                for (int z = startZ; z < Math.min(maxZ, startZ + 4); ++z) {
                    boolean flood = Probability.getChance(density);
                    for (int y = minY; y <= maxY; ++y) {
                        BlockType block = getRegion().getExtent().getBlockType(x, y, z);
                        if (z == startZ && newExpr.test(block)) {
                            getRegion().getExtent().setBlockType(x, y, z, oldType, Cause.source(SkreePlugin.container()).build());
                        } else if (flood && oldExpr.test(block)) {
                            getRegion().getExtent().setBlockType(x, y, z, newType, Cause.source(SkreePlugin.container()).build());
                        }
                    }
                }
            }
            return true;
        }

        @Override
        public void end() {
            if (floodFloor != -1) {
                for (int x = minX; x <= maxX; ++x) {
                    for (int z = minZ; z <= maxZ; ++z) {
                        if (!Probability.getChance(floodFloor))
                            continue;
                        BlockType block = getRegion().getExtent().getBlockType(x, minY, z);
                        if (oldExpr.test(block)) {
                            getRegion().getExtent().setBlockType(x, minY, z, newType, Cause.source(SkreePlugin.container()).build());
                        }
                    }
                }
            }
        }
    };
    TimedRunnable<IntegratedRunnable> timedRunnable = new TimedRunnable<>(integratedRunnable, initialTimes);
    Task task = Task.builder().execute(timedRunnable).interval(500, MILLISECONDS).submit(SkreePlugin.inst());
    timedRunnable.setTask(task);
}
Also used : Task(org.spongepowered.api.scheduler.Task) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) BlockType(org.spongepowered.api.block.BlockType) Vector3i(com.flowpowered.math.vector.Vector3i) TimedRunnable(com.skelril.nitro.time.TimedRunnable)

Example 14 with Vector3i

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

the class TheForgeInstance method getRandomEntryPoint.

private Location<World> getRandomEntryPoint() {
    Vector3i minimumPoint = getRegion().getMinimumPoint();
    Vector3i maximumPoint = getRegion().getMaximumPoint();
    Location<World> targetPoint;
    do {
        double targetX = Probability.getRangedRandom(minimumPoint.getX(), maximumPoint.getX()) + .5;
        double targetY = minimumPoint.getY() + 7;
        double targetZ = Probability.getRangedRandom(minimumPoint.getZ(), maximumPoint.getZ()) + .5;
        targetPoint = new Location<>(getRegion().getExtent(), targetX, targetY, targetZ);
    } while (!isValidTeleportDestination(targetPoint));
    return targetPoint;
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) World(org.spongepowered.api.world.World)

Example 15 with Vector3i

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

the class FreakyFourInstance method setUp.

private void setUp() {
    Vector3i offset = region.getMinimumPoint();
    regions.put(FreakyFourBoss.CHARLOTTE, new ZoneBoundingBox(offset.add(72, 7, 1), new Vector3i(22, 5, 41)));
    regions.put(FreakyFourBoss.FRIMUS, new ZoneBoundingBox(offset.add(48, 7, 1), new Vector3i(22, 5, 41)));
    regions.put(FreakyFourBoss.DA_BOMB, new ZoneBoundingBox(offset.add(24, 7, 1), new Vector3i(22, 5, 41)));
    regions.put(FreakyFourBoss.SNIPEE, new ZoneBoundingBox(offset.add(1, 7, 1), new Vector3i(21, 5, 41)));
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox)

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