-
Notifications
You must be signed in to change notification settings - Fork 226
Some tips when using the FAWE API
stefvanschie edited this page Nov 5, 2018
·
3 revisions
// 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.
This wiki is outdated, move to https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/
This Wiki is for Legacy Versions (1.8 - 1.12.2). Check here for 1.13+ versions: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/