mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-07-09 02:10:03 +00:00
82bcc0e9a5
* begin allowing "post processing" of chunks - restores legacy capability to continue saving edits in the background after sending the chunks - speeds up the edit clientside - nail in the coffin of the terrible and staticly coded coreedit - We should totally make IronGolem work so Core* is no longer used by anyone * begin allowing background history saving * Handle post processors in queues properly * Use futures for postprocessing so we're not waiting for them needlessly * better use of closed boolean * Reword
96 lines
2.6 KiB
Java
96 lines
2.6 KiB
Java
package com.boydti.fawe.object.extent;
|
|
|
|
import com.boydti.fawe.beta.IChunk;
|
|
import com.boydti.fawe.beta.IChunkGet;
|
|
import com.boydti.fawe.beta.IChunkSet;
|
|
import com.boydti.fawe.object.FaweLimit;
|
|
import com.sk89q.worldedit.extent.Extent;
|
|
import com.sk89q.worldedit.regions.Region;
|
|
import com.sk89q.worldedit.regions.RegionIntersection;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.concurrent.Future;
|
|
|
|
public class MultiRegionExtent extends FaweRegionExtent {
|
|
|
|
private final RegionIntersection intersection;
|
|
private final Region[] regions;
|
|
private Region region;
|
|
private int index;
|
|
|
|
/**
|
|
* Create a new instance.
|
|
*
|
|
* @param extent the extent
|
|
*/
|
|
public MultiRegionExtent(Extent extent, FaweLimit limit, Region[] regions) {
|
|
super(extent, limit);
|
|
this.index = 0;
|
|
this.region = regions[0];
|
|
this.regions = regions;
|
|
this.intersection = new RegionIntersection(Arrays.asList(regions));
|
|
}
|
|
|
|
@Override
|
|
public boolean contains(int x, int y, int z) {
|
|
if (region.contains(x, y, z)) {
|
|
return true;
|
|
}
|
|
for (int i = 0; i < regions.length; i++) {
|
|
if (i != index) {
|
|
Region current = regions[i];
|
|
if (current.contains(x, y, z)) {
|
|
region = current;
|
|
index = i;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean processGet(int chunkX, int chunkZ) {
|
|
for (Region region : regions) {
|
|
if (region.containsChunk(chunkX, chunkZ)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean contains(int x, int z) {
|
|
if (region.contains(x, z)) {
|
|
return true;
|
|
}
|
|
for (int i = 0; i < regions.length; i++) {
|
|
if (i != index) {
|
|
Region current = regions[i];
|
|
if (current.contains(x, z)) {
|
|
region = current;
|
|
index = i;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public Collection<Region> getRegions() {
|
|
return Arrays.asList(regions);
|
|
}
|
|
|
|
@Override
|
|
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
|
return intersection.processSet(chunk, get, set);
|
|
}
|
|
|
|
@Override
|
|
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
|
return intersection.postProcessSet(chunk, get, set);
|
|
}
|
|
}
|