Some tips when using the FAWE API - nik2143/FastAsyncWorldedit-Legacy GitHub Wiki
See here.
// Naive approach:
for (Vector pt : region) {
BaseBlock block = editSession.getBlock(pt);
// Do something
}
// Good approach:
// - Performs chunk preloading
for (Vector pt : new FastIterator(region, editSession)) {
BaseBlock block = editSession.getBlock(pt);
// Do something
}
The following classes will perform chunk preloading:
- FastIterator
- Fast2DIterator
- FastChunkIterator
- BreadFirstSearch
- RegionVisitor
// Naive approach: single block changes
for (int x = 0; x <= 100; x++) {
for (int z = 0; z <= 100; z++) {
editSession.setBlock(x, 64, z, block);
}
}
// Good approach:
// - Does chunk preloading
// - Performs on entire chunks rather than single blocks
// - Does stuff in parallel
Region region = new CuboidRegion(new Vector(0, 64, 0), new Vector(100, 64, 100));
editSession.setBlocks(region, block);
// Naive approach: Storing individual positions
Set<Vector> positions = new HashSet<>(); // Then store some block positions here
// Good approach:
// - Faster and currently uses up to 800x less memory
positions = new BlockVectorSet();
FAWE has not optimized these at all to be used async. Consider using the TaskBuilder to break it up on the main thread instead.