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;
}
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))));
}
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());
}
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));
}
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;
}
Aggregations