mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-04 07:28:17 +01:00
Fixes #686
This commit is contained in:
parent
62295e227a
commit
2b0f1e62b7
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe.bukkit.v0;
|
package com.boydti.fawe.bukkit.v0;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.config.Settings;
|
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
@ -269,7 +268,7 @@ public class BukkitChunk_All extends CharFaweChunk<Chunk, BukkitQueue_All> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (light != place) {
|
if (light != place) {
|
||||||
light = light && Settings.IMP.LIGHTING.MODE != 0;
|
light = light && getParent().getSettings().LIGHTING.MODE != 0;
|
||||||
if (light) {
|
if (light) {
|
||||||
parent.enableLighting(disableResult);
|
parent.enableLighting(disableResult);
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,11 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
|||||||
return new BukkitChunk_All(this, x, z);
|
return new BukkitChunk_All(this, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsChangeTask() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private int skip;
|
private int skip;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,6 +201,10 @@ public abstract class FaweQueue implements HasFaweQueue, Extent {
|
|||||||
this.progressTask = progressTask;
|
this.progressTask = progressTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean supportsChangeTask() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
|
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
|
||||||
this.changeTask = changeTask;
|
this.changeTask = changeTask;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import com.boydti.fawe.object.exception.FaweException;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
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.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -49,6 +51,11 @@ public class DelegateFaweQueue extends FaweQueue {
|
|||||||
return parent.setMCA(mcaX, mcaZ, region, whileLocked, load);
|
return parent.setMCA(mcaX, mcaZ, region, whileLocked, load);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsChangeTask() {
|
||||||
|
return parent.supportsChangeTask();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWorldName() {
|
public String getWorldName() {
|
||||||
return parent.getWorldName();
|
return parent.getWorldName();
|
||||||
@ -396,6 +403,51 @@ public class DelegateFaweQueue extends FaweQueue {
|
|||||||
return parent.getRelighter();
|
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
|
@Override
|
||||||
public Settings getSettings() {
|
public Settings getSettings() {
|
||||||
return parent.getSettings();
|
return parent.getSettings();
|
||||||
|
@ -252,12 +252,6 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
if (checkMemory == null) {
|
if (checkMemory == null) {
|
||||||
checkMemory = player != null && !fastmode;
|
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 (checkMemory) {
|
||||||
if (MemUtil.isMemoryLimitedSlow()) {
|
if (MemUtil.isMemoryLimitedSlow()) {
|
||||||
if (Perm.hasPermission(player, "worldedit.fast")) {
|
if (Perm.hasPermission(player, "worldedit.fast")) {
|
||||||
@ -268,9 +262,6 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
}
|
}
|
||||||
this.originalLimit = limit;
|
this.originalLimit = limit;
|
||||||
this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
|
this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
|
||||||
if (this.blockBag != null) {
|
|
||||||
combineStages = false;
|
|
||||||
}
|
|
||||||
this.limit = limit.copy();
|
this.limit = limit.copy();
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
if (world instanceof MCAWorld) {
|
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);
|
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)) {
|
if (Settings.IMP.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
|
||||||
queue = new MCAQueue(queue);
|
queue = new MCAQueue(queue);
|
||||||
}
|
}
|
||||||
@ -3356,6 +3356,8 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Set<Vector2D> chunks = region.getChunks();
|
final Set<Vector2D> chunks = region.getChunks();
|
||||||
|
MutableBlockVector mutable = new MutableBlockVector();
|
||||||
|
MutableBlockVector2D mutable2D = new MutableBlockVector2D();
|
||||||
for (Vector2D chunk : new FastChunkIterator(chunks, this)) {
|
for (Vector2D chunk : new FastChunkIterator(chunks, this)) {
|
||||||
final int cx = chunk.getBlockX();
|
final int cx = chunk.getBlockX();
|
||||||
final int cz = chunk.getBlockZ();
|
final int cz = chunk.getBlockZ();
|
||||||
@ -3370,97 +3372,92 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
if (((containsBot2 && containsTop2)) && !containsBot1 && !containsTop1) {
|
if (((containsBot2 && containsTop2)) && !containsBot1 && !containsTop1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final MutableBlockVector2D mutable = new MutableBlockVector2D();
|
boolean conNextX = chunks.contains(mutable2D.setComponents(cx + 1, cz));
|
||||||
RunnableVal<Vector2D> r = new RunnableVal<Vector2D>() {
|
boolean conNextZ = chunks.contains(mutable2D.setComponents(cx, cz + 1));
|
||||||
@Override
|
boolean containsAny = false;
|
||||||
public void run(Vector2D chunk) {
|
if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) {
|
||||||
boolean conNextX = chunks.contains(mutable.setComponents(cx + 1, cz));
|
containsAny = true;
|
||||||
boolean conNextZ = chunks.contains(mutable.setComponents(cx, cz + 1));
|
if (fcs != null) {
|
||||||
boolean containsAny = false;
|
for (int x = 0; x < 16; x++) {
|
||||||
if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) {
|
int xx = x + bx;
|
||||||
containsAny = true;
|
for (int z = 0; z < 16; z++) {
|
||||||
if (fcs != null) {
|
int zz = z + bz;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int y = 0; y < getMaxY() + 1; y++) {
|
||||||
int xx = x + bx;
|
int from = queue.getCombinedId4DataDebug(xx, y, zz, 0, EditSession.this);
|
||||||
for (int z = 0; z < 16; z++) {
|
if (!FaweCache.hasNBT(from >> 4)) {
|
||||||
int zz = z + bz;
|
fcs.add(xx, y, zz, from, 0);
|
||||||
for (int y = 0; y < getMaxY() + 1; y++) {
|
} else {
|
||||||
int from = queue.getCombinedId4DataDebug(xx, y, zz, 0, EditSession.this);
|
try {
|
||||||
if (!FaweCache.hasNBT(from >> 4)) {
|
Vector loc = new Vector(xx, y, zz);
|
||||||
fcs.add(xx, y, zz, from, 0);
|
BaseBlock block = getLazyBlock(loc);
|
||||||
} else {
|
fcs.add(loc, block, FaweCache.CACHE_BLOCK[0]);
|
||||||
try {
|
} catch (Throwable e) {
|
||||||
Vector loc = new Vector(xx, y, zz);
|
fcs.add(xx, y, zz, from, 0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
r.value = chunk;
|
if (!conNextX) {
|
||||||
TaskManager.IMP.sync(r);
|
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) {
|
if (changes != 0) {
|
||||||
flushQueue();
|
flushQueue();
|
||||||
|
@ -332,7 +332,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
@Override
|
@Override
|
||||||
public Iterator<Vector2D> iterator() {
|
public Iterator<Vector2D> iterator() {
|
||||||
return new Iterator<Vector2D>() {
|
return new Iterator<Vector2D>() {
|
||||||
private MutableBlockVector2D pos = new MutableBlockVector2D().setComponents(minX, minZ);
|
private MutableBlockVector2D pos = new MutableBlockVector2D().setComponents(maxX + 1, maxZ);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@ -343,12 +343,13 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public Vector2D next() {
|
public Vector2D next() {
|
||||||
Vector2D result = pos;
|
Vector2D result = pos;
|
||||||
// calc next
|
// calc next
|
||||||
if (pos.getX() < maxX) {
|
pos.setComponents(pos.getX() - 1, pos.getZ());
|
||||||
pos.setComponents(pos.getX() + 1, pos.getZ());
|
if (pos.getX() <= minX) {
|
||||||
} else if (pos.getZ() < maxZ) {
|
if (pos.getZ() == minZ) {
|
||||||
pos.setComponents(minX, pos.getZ() + 1);
|
pos = null;
|
||||||
} else {
|
} else if (pos.getX() < minX) {
|
||||||
pos = null;
|
pos.setComponents(maxX, pos.getZ() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user