Asynchronous World
The world, unlocked
With phantom, strapped with FAWE, all world modifications are handled async anyways through FAWE, however we have added some useful utilities so you don't have to add all of the dependencies for FAWE and reconfigure your environment.
Getting the Async World
This retreives the async world implementation by FAWE, you can modify this async or sync.
new A()
{
@Override
public void async()
{
World world = W.getAsyncWorld("world_name");
world.getBlockAt(0, 0, 0).setType(Material.GLASS);
world.getBlockAt(0, 0, 0).getChunk().getX();
}
};
Queue async modifications (while sync or async)
Most of the time, blocks need to be modified quickly without the worry of having to dive into an async task/thread for each modification. We have created a multiworld queue and a master queue for even faster handling.
Getting a Phantom Queue
This method is safe for sync and async processing, you will need to manually flush the queue
//Get a queue for this world
PhantomWorld world = new PhantomWorld(Bukkit.getWorld("world"));
PhantomEditSession queue = new PhantomEditSession(world);
//Set and get things (async or sync)
queue.set(world.getBlockAt(0, 0, 0).getLocation(), Material.GLASS);
//Flush when you are finished
queue.flush();
Getting a Phantom World Queue
This method can queue any world without having to supply the world. The world queue is supplied and created within this queue when it is modified.
//Just using a world as an example
//Since we dont have a location
World world = Bukkit.getWorld("world");
//No need to supply a queue
PhantomWorldQueue queue = new PhantomWorldQueue();
//Queue stuff
queue.set(world.getBlockAt(0, 0, 0).getLocation(), Material.ACACIA_DOOR);
//Flush when complete
queue.flush();
Queue to the MasterQueue
There is an even quicker way to queue changes to the world sync or async. However this auto queues, meaning multithreaded modifications may look weird while applying it. The queue is flushed 20 times a second.
// Just using a world as an example
// Since we dont have a location
World world = Bukkit.getWorld("world");
EditSessionController.queue(world.getSpawnLocation(), new MaterialBlock(Material.GLASS));
Relight Chunks
Relighting chunks is very simple. Relighting the same chunk with different blocks will only relight the chunk once. It is relit async on a queue every second.
//Relight a chunk from a block (multiple relights will be merged)
Photon.relight(Block);
//Relight by chunk
Photon.relight(Chunk);
//Relight by location (entire chunk is relit)
Photon.relight(Location);