This commit is contained in:
Jesse Boyd 2017-08-10 00:41:19 +10:00
parent 62295e227a
commit 2b0f1e62b7
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
6 changed files with 161 additions and 103 deletions

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.CharFaweChunk;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
@ -269,7 +268,7 @@ public class BukkitChunk_All extends CharFaweChunk<Chunk, BukkitQueue_All> {
continue;
}
if (light != place) {
light = light && Settings.IMP.LIGHTING.MODE != 0;
light = light && getParent().getSettings().LIGHTING.MODE != 0;
if (light) {
parent.enableLighting(disableResult);
}

View File

@ -145,6 +145,11 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
return new BukkitChunk_All(this, x, z);
}
@Override
public boolean supportsChangeTask() {
return false;
}
private int skip;
@Override

View File

@ -201,6 +201,10 @@ public abstract class FaweQueue implements HasFaweQueue, Extent {
this.progressTask = progressTask;
}
public boolean supportsChangeTask() {
return true;
}
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
this.changeTask = changeTask;
}

View File

@ -11,6 +11,8 @@ import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
@ -49,6 +51,11 @@ public class DelegateFaweQueue extends FaweQueue {
return parent.setMCA(mcaX, mcaZ, region, whileLocked, load);
}
@Override
public boolean supportsChangeTask() {
return parent.supportsChangeTask();
}
@Override
public String getWorldName() {
return parent.getWorldName();
@ -396,6 +403,51 @@ public class DelegateFaweQueue extends FaweQueue {
return parent.getRelighter();
}
@Override
public Vector getMinimumPoint() {
return parent.getMinimumPoint();
}
@Override
public Vector getMaximumPoint() {
return parent.getMaximumPoint();
}
@Override
public BaseBlock getLazyBlock(int x, int y, int z) {
return parent.getLazyBlock(x, y, z);
}
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
return parent.setBlock(x, y, z, block);
}
@Override
public BaseBlock getBlock(Vector position) {
return parent.getBlock(position);
}
@Override
public BaseBiome getBiome(Vector2D position) {
return parent.getBiome(position);
}
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
return parent.setBlock(position, block);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
return parent.setBiome(position, biome);
}
@Override
public FaweQueue getQueue() {
return parent.getQueue();
}
@Override
public Settings getSettings() {
return parent.getSettings();

View File

@ -252,12 +252,6 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
if (checkMemory == null) {
checkMemory = player != null && !fastmode;
}
if (combineStages == null) {
combineStages = Settings.IMP.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue);
}
if (!limit.FAST_PLACEMENT) {
combineStages = false;
}
if (checkMemory) {
if (MemUtil.isMemoryLimitedSlow()) {
if (Perm.hasPermission(player, "worldedit.fast")) {
@ -268,9 +262,6 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
}
this.originalLimit = limit;
this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
if (this.blockBag != null) {
combineStages = false;
}
this.limit = limit.copy();
if (queue == null) {
if (world instanceof MCAWorld) {
@ -279,6 +270,15 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
queue = SetQueue.IMP.getNewQueue(this, fastmode || limit.FAST_PLACEMENT, autoQueue);
}
}
if (combineStages == null) {
combineStages = Settings.IMP.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue);
}
if (!limit.FAST_PLACEMENT || !queue.supportsChangeTask()) {
combineStages = false;
}
if (this.blockBag != null) {
combineStages = false;
}
if (Settings.IMP.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
queue = new MCAQueue(queue);
}
@ -3356,6 +3356,8 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
}
}
final Set<Vector2D> chunks = region.getChunks();
MutableBlockVector mutable = new MutableBlockVector();
MutableBlockVector2D mutable2D = new MutableBlockVector2D();
for (Vector2D chunk : new FastChunkIterator(chunks, this)) {
final int cx = chunk.getBlockX();
final int cz = chunk.getBlockZ();
@ -3370,97 +3372,92 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
if (((containsBot2 && containsTop2)) && !containsBot1 && !containsTop1) {
continue;
}
final MutableBlockVector2D mutable = new MutableBlockVector2D();
RunnableVal<Vector2D> r = new RunnableVal<Vector2D>() {
@Override
public void run(Vector2D chunk) {
boolean conNextX = chunks.contains(mutable.setComponents(cx + 1, cz));
boolean conNextZ = chunks.contains(mutable.setComponents(cx, cz + 1));
boolean containsAny = false;
if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) {
containsAny = true;
if (fcs != null) {
for (int x = 0; x < 16; x++) {
int xx = x + bx;
for (int z = 0; z < 16; z++) {
int zz = z + bz;
for (int y = 0; y < getMaxY() + 1; y++) {
int from = queue.getCombinedId4DataDebug(xx, y, zz, 0, EditSession.this);
if (!FaweCache.hasNBT(from >> 4)) {
fcs.add(xx, y, zz, from, 0);
} else {
try {
Vector loc = new Vector(xx, y, zz);
BaseBlock block = getLazyBlock(loc);
fcs.add(loc, block, FaweCache.CACHE_BLOCK[0]);
} catch (Throwable e) {
fcs.add(xx, y, zz, from, 0);
}
}
boolean conNextX = chunks.contains(mutable2D.setComponents(cx + 1, cz));
boolean conNextZ = chunks.contains(mutable2D.setComponents(cx, cz + 1));
boolean containsAny = false;
if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) {
containsAny = true;
if (fcs != null) {
for (int x = 0; x < 16; x++) {
int xx = x + bx;
for (int z = 0; z < 16; z++) {
int zz = z + bz;
for (int y = 0; y < getMaxY() + 1; y++) {
int from = queue.getCombinedId4DataDebug(xx, y, zz, 0, EditSession.this);
if (!FaweCache.hasNBT(from >> 4)) {
fcs.add(xx, y, zz, from, 0);
} else {
try {
Vector loc = new Vector(xx, y, zz);
BaseBlock block = getLazyBlock(loc);
fcs.add(loc, block, FaweCache.CACHE_BLOCK[0]);
} catch (Throwable e) {
fcs.add(xx, y, zz, from, 0);
}
}
}
}
} else {
int tx = 16;
int tz = 16;
if (!conNextX) {
setExistingBlocks(new Vector(bx + 16, 0, bz), new Vector(bx + 31, getMaxY(), bz + 15));
}
if (!conNextZ) {
setExistingBlocks(new Vector(bx, 0, bz + 16), new Vector(bx + 15, getMaxY(), bz + 31));
}
if (!chunks.contains(mutable.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) {
setExistingBlocks(new Vector(bx + 16, 0, bz + 16), new Vector(bx + 31, getMaxY(), bz + 31));
}
MutableBlockVector mutable = new MutableBlockVector(0, 0, 0);
for (int x = 0; x < tx; x++) {
int xx = x + bx;
mutable.mutX(xx);
for (int z = 0; z < tz; z++) {
int zz = z + bz;
mutable.mutZ(zz);
for (int y = 0; y < getMaxY() + 1; y++) {
mutable.mutY(y);
int from = queue.getCombinedId4Data(xx, y, zz);
boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable);
if (contains) {
containsAny = true;
if (fcs != null) {
if (!FaweCache.hasNBT(from >> 4)) {
fcs.add(xx, y, zz, from, 0);
} else {
try {
BaseBlock block = getLazyBlock(mutable);
fcs.add(mutable, block, FaweCache.CACHE_BLOCK[0]);
} catch (Throwable e) {
fcs.add(xx, y, zz, from, 0);
}
}
}
} else {
short id = (short) (from >> 4);
byte data = (byte) (from & 0xf);
queue.setBlock(xx, y, zz, id, data);
if (FaweCache.hasNBT(id)) {
CompoundTag tile = queue.getTileEntity(xx, y, zz);
if (tile != null) {
queue.setTile(xx, y, zz, tile);
}
}
}
}
}
}
}
if (containsAny) {
changes++;
queue.regenerateChunk(cx, cz, biome, seed);
}
}
};
r.value = chunk;
TaskManager.IMP.sync(r);
} else {
if (!conNextX) {
setExistingBlocks(new Vector(bx + 16, 0, bz), new Vector(bx + 31, getMaxY(), bz + 15));
}
if (!conNextZ) {
setExistingBlocks(new Vector(bx, 0, bz + 16), new Vector(bx + 15, getMaxY(), bz + 31));
}
if (!chunks.contains(mutable2D.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) {
setExistingBlocks(new Vector(bx + 16, 0, bz + 16), new Vector(bx + 31, getMaxY(), bz + 31));
}
for (int x = 0; x < 16; x++) {
int xx = x + bx;
mutable.mutX(xx);
for (int z = 0; z < 16; z++) {
int zz = z + bz;
mutable.mutZ(zz);
for (int y = 0; y < getMaxY() + 1; y++) {
mutable.mutY(y);
boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable);
if (contains) {
containsAny = true;
if (fcs != null) {
int from = queue.getCombinedId4Data(xx, y, zz);
if (!FaweCache.hasNBT(from >> 4)) {
fcs.add(xx, y, zz, from, 0);
} else {
try {
BaseBlock block = getLazyBlock(mutable);
fcs.add(mutable, block, FaweCache.CACHE_BLOCK[0]);
} catch (Throwable e) {
fcs.add(xx, y, zz, from, 0);
}
}
}
} else {
int from = queue.getCombinedId4Data(xx, y, zz);
short id = (short) (from >> 4);
byte data = (byte) (from & 0xf);
queue.setBlock(xx, y, zz, id, data);
if (FaweCache.hasNBT(id)) {
CompoundTag tile = queue.getTileEntity(xx, y, zz);
if (tile != null) {
queue.setTile(xx, y, zz, tile);
}
}
}
}
}
}
}
if (containsAny) {
changes++;
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
queue.regenerateChunk(cx, cz, biome, seed);
}
});
}
}
if (changes != 0) {
flushQueue();

View File

@ -332,7 +332,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override
public Iterator<Vector2D> iterator() {
return new Iterator<Vector2D>() {
private MutableBlockVector2D pos = new MutableBlockVector2D().setComponents(minX, minZ);
private MutableBlockVector2D pos = new MutableBlockVector2D().setComponents(maxX + 1, maxZ);
@Override
public boolean hasNext() {
@ -343,12 +343,13 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
public Vector2D next() {
Vector2D result = pos;
// calc next
if (pos.getX() < maxX) {
pos.setComponents(pos.getX() + 1, pos.getZ());
} else if (pos.getZ() < maxZ) {
pos.setComponents(minX, pos.getZ() + 1);
} else {
pos = null;
pos.setComponents(pos.getX() - 1, pos.getZ());
if (pos.getX() <= minX) {
if (pos.getZ() == minZ) {
pos = null;
} else if (pos.getX() < minX) {
pos.setComponents(maxX, pos.getZ() - 1);
}
}
return result;
}