mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-22 02:25:53 +01:00
Page:
TaskBuilder
Pages
API
Anvil API
AsyncWorld
Brushes
Clipboard API
Commands
Configuration
Copying a region to another world.
CreateFromImage
Download Instructions: Bukkit Spigot
Fawe TaskManager
FawePlayer
FaweQueue
Home
JavaScript API
Jobs API
Light API
NBT stream API
Packet sending
Pasting a schematic
Permissions
Progress API
Recovering corrupt NBT files (MCA Schematic etc.)
Region restriction API
Registering Custom Masks, Patterns and Transforms
Registering custom brushes or commands
Rollback API
Some tips when using the FAWE API
TaskBuilder
TextureUtil block and biome coloring
Third party loggers
Transforms
Web API
WorldEdit FAWE mask list
WorldEdit EditSession
WorldEdit World Player
WorldEdit and FAWE patterns
4
TaskBuilder
Jesse Boyd edited this page 2016-11-02 04:05:02 +11:00
Table of Contents
Overview
The TaskBuilder simplifies creating sequential sync/async tasks. https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/boydti/fawe/util/task/TaskBuilder.java
Methods:
- sync([Runnable|ReturnTask|ReceiveTask|Task]) - Run a task on the main thread
- async([Runnable|ReturnTask|ReceiveTask|Task]) - Run a task off the main thread
- delay([int|DelayedTask]) - Delay the next task by a number of ticks
- syncParallel([Runnable|ReturnTask|ReceiveTask|Task]) - Run all the next syncParallel tasks in parallel
- asyncParallel([Runnable|ReturnTask|ReceiveTask|Task]) - Run all the next asyncParallel tasks in parallel
- syncWhenFree([SplitTask|ReturnTask|ReceiveTask|Task]) - Run a task when there's free time on the main thread
- abortIfTrue(Task<Boolean,Object>) - Abort all tasks if true
- build() - Starts execution
- buildAsync() - Starts execution from an async thread
Multiple tasks
Just prints the number 6
new TaskBuilder()
.async((ReturnTask<Integer>) () -> 5 + 1)
.sync((ReceiveTask) input -> System.out.println(input))
.build();
SplitTask example
Split up a task and run it when the main thread is free.
// In reality you'd use one of EditSession, AsyncWorld, FaweQueue instead.
// But this is just an example of how you can split up a task with the FAWE API
final World world = Bukkit.getWorld("world");
new TaskBuilder()
// Execution will be split into multiple 20ms tasks
.syncWhenFree(new TaskBuilder.SplitTask(20) {
@Override
public Object exec(Object previous) {
for (int x = 0; x < 100; x++) {
for (int y = 0; y < 100; y++) {
for (int z = 0; z < 100; z++) {
world.getBlockAt(x, y, z).setType(Material.STONE);
// FAWE will use this point to split the task
// You can have multiple split points
split();
}
}
}
// We don't really need the result for any next tasks
return null;
}
})
.build();
Task meta
The TaskBuilder extends Metadatable, so you can use it to store temporary data: https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/boydti/fawe/object/Metadatable.java
final TaskBuilder task = new TaskBuilder();
task.sync(() -> {
task.setMeta("blah", 5);
return task.<Integer>getMeta("blah") + 56;
});
This Wiki is for Legacy Versions (1.8 - 1.12.2). Check here for 1.13+ versions: https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/