use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.
the class TransformRegion method polygonize.
@Override
public List<BlockVector2> polygonize(int maxPoints) {
List<BlockVector2> origPoints = region.polygonize(maxPoints);
List<BlockVector2> transformedPoints = new ArrayList<>();
for (BlockVector2 vector : origPoints) {
transformedPoints.add(transform.apply(vector.toVector3(0)).toVector2().toBlockPoint());
}
return transformedPoints;
}
use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.
the class Polygonal2DRegionSelector method learnChanges.
@Override
public void learnChanges() {
BlockVector2 pt = region.getPoints().get(0);
pos1 = BlockVector3.at(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
}
use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.
the class Regenerator method getChunkCoordsRegen.
// algorithms
private List<Long> getChunkCoordsRegen(Region region, int border) {
// needs to be square num of chunks
BlockVector3 oldMin = region.getMinimumPoint();
BlockVector3 newMin = BlockVector3.at((oldMin.getX() >> 4 << 4) - border * 16, oldMin.getY(), (oldMin.getZ() >> 4 << 4) - border * 16);
BlockVector3 oldMax = region.getMaximumPoint();
BlockVector3 newMax = BlockVector3.at((oldMax.getX() >> 4 << 4) + (border + 1) * 16 - 1, oldMax.getY(), (oldMax.getZ() >> 4 << 4) + (border + 1) * 16 - 1);
Region adjustedRegion = new CuboidRegion(newMin, newMax);
return adjustedRegion.getChunks().stream().map(c -> BlockVector2.at(c.getX(), c.getZ())).sorted(Comparator.comparingInt(BlockVector2::getZ).thenComparingInt(// needed for RegionLimitedWorldAccess
BlockVector2::getX)).map(c -> MathMan.pairInt(c.getX(), c.getZ())).collect(Collectors.toList());
}
use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.
the class FileSystemSnapshotDatabaseTest method setUpStatic.
@BeforeAll
static void setUpStatic() throws IOException, DataException {
try (InputStream in = Resources.getResource("world_region.mca.gzip").openStream();
GZIPInputStream gzIn = new GZIPInputStream(in)) {
REGION_DATA = ByteStreams.toByteArray(gzIn);
}
McRegionReader reader = new McRegionReader(new ByteArrayInputStream(REGION_DATA));
try {
// Find the single chunk
BlockVector2 chunkPos = IntStream.range(0, 32).mapToObj(x -> IntStream.range(0, 32).filter(z -> reader.hasChunk(x, z)).mapToObj(z -> BlockVector2.at(x, z))).flatMap(Function.identity()).findAny().orElseThrow(() -> new AssertionError("No chunk in region file."));
ByteArrayOutputStream cap = new ByteArrayOutputStream();
try (InputStream in = reader.getChunkInputStream(chunkPos);
GZIPOutputStream gzOut = new GZIPOutputStream(cap)) {
ByteStreams.copy(in, gzOut);
}
CHUNK_DATA = cap.toByteArray();
CHUNK_TAG = ChunkStoreHelper.readCompoundTag(() -> new GZIPInputStream(new ByteArrayInputStream(CHUNK_DATA)));
CHUNK_POS = chunkPos.toBlockVector3();
} finally {
reader.close();
}
TEMP_DIR = Files.createTempDirectory("worldedit-fs-snap-dbs").toRealPath();
}
use of com.sk89q.worldedit.math.BlockVector2 in project FastAsyncWorldEdit by IntellectualSites.
the class AsyncPreloader method run.
@Override
public void run() {
FaweTimer timer = Fawe.instance().getTimer();
if (cancelled.get()) {
return;
}
if (update.isEmpty()) {
TaskManager.taskManager().laterAsync(this, 1);
return;
}
Iterator<Map.Entry<UUID, MutablePair<World, Set<BlockVector2>>>> plrIter = update.entrySet().iterator();
while (timer.getTPS() > 18 && plrIter.hasNext()) {
if (cancelled.get()) {
return;
}
Map.Entry<UUID, MutablePair<World, Set<BlockVector2>>> entry = plrIter.next();
MutablePair<World, Set<BlockVector2>> pair = entry.getValue();
World world = pair.getKey();
Set<BlockVector2> chunks = pair.getValue();
if (chunks != null) {
Iterator<BlockVector2> chunksIter = chunks.iterator();
while (chunksIter.hasNext() && pair.getValue() == chunks) {
// Ensure the queued load is still valid
BlockVector2 chunk = chunksIter.next();
queueLoad(world, chunk);
}
}
plrIter.remove();
}
if (cancelled.get()) {
return;
}
TaskManager.taskManager().laterAsync(this, 20);
}
Aggregations