Search in sources :

Example 26 with BlockVector2

use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.

the class IQueueExtent method apply.

@Override
default <T extends Filter> T apply(Region region, T filter, boolean full) {
    final Set<BlockVector2> chunks = region.getChunks();
    ChunkFilterBlock block = null;
    for (BlockVector2 chunk : chunks) {
        block = apply(block, filter, region, chunk.getX(), chunk.getZ(), full);
    }
    flush();
    return filter;
}
Also used : ChunkFilterBlock(com.fastasyncworldedit.core.extent.filter.block.ChunkFilterBlock) BlockVector2(com.sk89q.worldedit.math.BlockVector2)

Example 27 with BlockVector2

use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.

the class ChunkCommands method chunkInfo.

@Command(name = "chunkinfo", aliases = { "/chunkinfo" }, desc = "Get information about the chunk you're inside")
@CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player) {
    Location pos = player.getBlockLocation();
    int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
    int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
    final BlockVector2 chunkPos = BlockVector2.at(chunkX, chunkZ);
    player.print(Caption.of("worldedit.chunkinfo.chunk", TextComponent.of(chunkX), TextComponent.of(chunkZ)));
    player.print(Caption.of("worldedit.chunkinfo.old-filename", TextComponent.of(LegacyChunkStore.getFilename(chunkPos))));
    player.print(Caption.of("worldedit.chunkinfo.mcregion-filename", TextComponent.of(McRegionChunkStore.getFilename(chunkPos))));
}
Also used : BlockVector2(com.sk89q.worldedit.math.BlockVector2) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 28 with BlockVector2

use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.

the class HistorySubCommands method summary.

@Command(name = "info", aliases = { "summary", "summarize" }, desc = "Summarize an edit")
@CommandPermissions("worldedit.history.info")
public synchronized void summary(Player player, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @Arg(desc = "edit index") Integer index) throws WorldEditException, ExecutionException, InterruptedException {
    RollbackOptimizedHistory edit = database.getEdit(other, index).get();
    if (edit == null) {
        player.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
        return;
    }
    Location origin = player.getLocation();
    String name = Fawe.platform().getName(edit.getUUID());
    String cmd = edit.getCommand();
    BlockVector3 pos1 = edit.getMinimumPoint();
    BlockVector3 pos2 = edit.getMaximumPoint();
    double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX()));
    double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ()));
    int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
    BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.getX(), edit.getOriginZ() - origin.getZ());
    Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL);
    long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
    String timeStr = MainUtil.secToTime(seconds);
    int size = edit.size();
    boolean biomes = edit.getBioFile().exists();
    boolean createdEnts = edit.getEnttFile().exists();
    boolean removedEnts = edit.getEntfFile().exists();
    boolean createdTiles = edit.getNbttFile().exists();
    boolean removedTiles = edit.getNbtfFile().exists();
    TranslatableComponent header = Caption.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd);
    String sizeStr = StringMan.humanReadableByteCountBin(edit.getSizeOnDisk());
    String extra = "";
    if (biomes) {
        extra += "biomes, ";
    }
    if (createdEnts) {
        extra += "+entity, ";
    }
    if (removedEnts) {
        extra += "-entity, ";
    }
    if (createdTiles) {
        extra += "+tile, ";
    }
    if (removedTiles) {
        extra += "-tile, ";
    }
    TranslatableComponent body = Caption.of("fawe.worldedit.history.find.element.more", size, edit.getMinimumPoint(), edit.getMaximumPoint(), extra.trim(), sizeStr);
    Component distr = TextComponent.of("/history distr").clickEvent(ClickEvent.suggestCommand("//history distr " + other + " " + index));
    TextComponentProducer content = new TextComponentProducer().append(header).newline().append(body).newline().append(distr);
    player.print(content.create());
}
Also used : TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) BlockVector3(com.sk89q.worldedit.math.BlockVector3) BlockVector2(com.sk89q.worldedit.math.BlockVector2) Direction(com.sk89q.worldedit.util.Direction) RollbackOptimizedHistory(com.fastasyncworldedit.core.history.RollbackOptimizedHistory) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) Component(com.sk89q.worldedit.util.formatting.text.Component) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 29 with BlockVector2

use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method lay.

@Command(name = "/lay", desc = "Set the top block in the region")
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void lay(Actor actor, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg) throws WorldEditException {
    // FAWE start - world min/maxY
    int maxY = region.getMaximumY();
    int minY = region.getMinimumY();
    // FAWE end
    Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
    Iterator<BlockVector2> iter = flat.iterator();
    // FAWE start - world min/maxY
    int y = minY;
    // FAWE end
    int affected = 0;
    while (iter.hasNext()) {
        BlockVector2 pos = iter.next();
        int x = pos.getBlockX();
        int z = pos.getBlockZ();
        // FAWE start - world min/maxY
        y = editSession.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
        // FAWE end
        editSession.setBlock(x, y, z, patternArg);
        affected++;
    }
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
}
Also used : BlockVector2(com.sk89q.worldedit.math.BlockVector2) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 30 with BlockVector2

use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.

the class Polygonal2DRegionSelector method selectSecondary.

@Override
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
    if (region.size() > 0) {
        final List<BlockVector2> points = region.getPoints();
        final BlockVector2 lastPoint = points.get(region.size() - 1);
        if (lastPoint.getBlockX() == position.getBlockX() && lastPoint.getBlockZ() == position.getBlockZ()) {
            return false;
        }
        Optional<Integer> vertexLimit = limits.getPolygonVertexLimit();
        if (vertexLimit.isPresent() && points.size() > vertexLimit.get()) {
            return false;
        }
    }
    region.addPoint(position);
    region.expandY(position.getBlockY());
    return true;
}
Also used : BlockVector2(com.sk89q.worldedit.math.BlockVector2)

Aggregations

BlockVector2 (com.sk89q.worldedit.math.BlockVector2)55 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)19 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)9 Map (java.util.Map)9 ProtectedPolygonalRegion (com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion)7 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)6 LinkedHashMap (java.util.LinkedHashMap)6 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 Path (java.nio.file.Path)5 Iterator (java.util.Iterator)5 Set (java.util.Set)5 JsonIOException (com.google.gson.JsonIOException)4 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)4 Location (com.sk89q.worldedit.util.Location)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 List (java.util.List)4 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)3 Region (com.sk89q.worldedit.regions.Region)3