Disable P2's we region restrictions (so that it uses FAWE's)
Fix extent binding
Fix filtering on null sections
Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-11 16:49:13 +00:00
Ursprung 9d6f2df908
Commit 7aa0d9c122
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
19 geänderte Dateien mit 77 neuen und 58 gelöschten Zeilen

Datei anzeigen

@ -58,7 +58,7 @@ public interface IChunk extends Trimable, IChunkGet, IChunkSet {
* @param block The filter block
* @param region The region allowed to filter (may be null)
*/
void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region);
void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full);
// /**
// * Flood through all the blocks in the chunk

Datei anzeigen

@ -116,8 +116,8 @@ public interface IDelegateChunk<U extends IQueueChunk> extends IQueueChunk {
}
@Override
default void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
getParent().filterBlocks(filter, block, region);
default void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
getParent().filterBlocks(filter, block, region, full);
}
@Override

Datei anzeigen

@ -144,7 +144,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
*/
boolean isEmpty();
default ChunkFilterBlock apply(ChunkFilterBlock block, Filter filter, Region region, int chunkX, int chunkZ) {
default ChunkFilterBlock apply(ChunkFilterBlock block, Filter filter, Region region, int chunkX, int chunkZ, boolean full) {
if (!filter.appliesChunk(chunkX, chunkZ)) {
return block;
}
@ -158,18 +158,18 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
if (block == null) {
block = this.initFilterBlock();
}
chunk.filterBlocks(filter, block, region);
chunk.filterBlocks(filter, block, region, full);
}
this.submit(chunk);
return block;
}
@Override
default <T extends Filter> T apply(Region region, T filter) {
default <T extends Filter> T apply(Region region, T filter, boolean full) {
final Set<BlockVector2> chunks = region.getChunks();
ChunkFilterBlock block = null;
for (BlockVector2 chunk : chunks) {
block = apply(block, filter, region, chunk.getX(), chunk.getZ());
block = apply(block, filter, region, chunk.getX(), chunk.getZ(), full);
}
flush();
return filter;

Datei anzeigen

@ -310,18 +310,19 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
}
@Override
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
final IChunkGet get = getOrCreateGet();
final IChunkSet set = getOrCreateSet();
try {
if (region != null) {
region.filter(this, filter, block, get, set);
region.filter(this, filter, block, get, set, full);
} else {
block = block.init(chunkX, chunkZ, get);
for (int layer = 0; layer < 16; layer++) {
if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) {
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(this, layer)) {
continue;
}
System.out.println("Apply layer " + full);
block.init(get, set, layer);
block.filter(filter);
}

Datei anzeigen

@ -51,7 +51,7 @@ public enum NullChunk implements IQueueChunk {
}
@Override
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
}

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.filter.block;
import static com.sk89q.worldedit.world.block.BlockTypesCache.states;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.FilterBlockMask;
import com.boydti.fawe.beta.Flood;
@ -65,7 +66,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
FilterBlockMask mask) {
final int maxDepth = flood.getMaxDepth();
final boolean checkDepth = maxDepth < Character.MAX_VALUE;
if (init(iget, iset, layer) != null) {
if (init(iget, iset, layer) != null) { // TODO replace with hasSection
while ((index = flood.poll()) != -1) {
x = index & 15;
z = index >> 4 & 15;
@ -89,10 +90,11 @@ public class CharFilterBlock extends ChunkFilterBlock {
this.layer = layer;
final CharGetBlocks get = (CharGetBlocks) iget;
if (!get.hasSection(layer)) {
return null;
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
} else {
getArr = get.sections[layer].get(get, layer);
}
this.set = iset;
getArr = get.sections[layer].get(get, layer);
if (set.hasSection(layer)) {
setArr = set.load(layer);
delegate = FULL;

Datei anzeigen

@ -449,11 +449,11 @@ public class LimitExtent extends PassthroughExtent {
}
@Override
public <T extends Filter> T apply(Region region, T filter) {
public <T extends Filter> T apply(Region region, T filter, boolean full) {
limit.THROW_MAX_CHECKS(region.getArea());
limit.THROW_MAX_CHANGES(region.getArea());
try {
return getExtent().apply(region, filter);
return getExtent().apply(region, filter, full);
} catch (FaweException e) {
if (!limit.MAX_FAILS()) {
throw e;

Datei anzeigen

@ -73,7 +73,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
}
@Override
public <T extends Filter> T apply(Region region, T filter) {
public <T extends Filter> T apply(Region region, T filter, boolean full) {
// The chunks positions to iterate over
final Set<BlockVector2> chunks = region.getChunks();
final Iterator<BlockVector2> chunksIter = chunks.iterator();
@ -82,7 +82,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
final int size = Math.min(chunks.size(), Settings.IMP.QUEUE.PARALLEL_THREADS);
if (size <= 1) {
BlockVector2 pos = chunksIter.next();
getExtent().apply(null, filter, region, pos.getX(), pos.getZ());
getExtent().apply(null, filter, region, pos.getX(), pos.getZ(), full);
} else {
final ForkJoinTask[] tasks = IntStream.range(0, size).mapToObj(i -> handler.submit(() -> {
try {
@ -103,7 +103,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
X = pos.getX();
Z = pos.getZ();
}
block = queue.apply(block, newFilter, region, X, Z);
block = queue.apply(block, newFilter, region, X, Z, full);
}
queue.flush();
}
@ -131,20 +131,20 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
return
// Apply a filter over a region
apply(region, searchMask
.toFilter(new CountFilter())) // Adapt the mask to a filter which counts
.toFilter(new CountFilter()), false) // Adapt the mask to a filter which counts
.getParent() // Get the counter of this mask
.getTotal(); // Get the total from the counter
}
@Override
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
apply(region, block);
apply(region, block, true);
return getChanges();
}
@Override
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
apply(region, pattern);
apply(region, pattern, true);
return getChanges();
}
@ -163,18 +163,18 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
@Override
public int replaceBlocks(Region region, Mask mask, Pattern pattern)
throws MaxChangedBlocksException {
apply(region, mask.toFilter(pattern));
apply(region, mask.toFilter(pattern), false);
return getChanges();
}
@Override
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
return apply(region, new DistrFilter()).getDistribution();
return apply(region, new DistrFilter(), false).getDistribution();
}
@Override
public List<Countable<BlockType>> getBlockDistribution(Region region) {
return apply(region, new DistrFilter()).getTypeDistribution();
return apply(region, new DistrFilter(), false).getTypeDistribution();
}
/**

Datei anzeigen

@ -562,14 +562,14 @@ public class MCAChunk implements IChunk {
}
@Override
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
try {
if (region != null) {
region.filter(this, filter, block, this, this);
region.filter(this, filter, block, this, this, full);
} else {
block = block.init(chunkX, chunkZ, this);
for (int layer = 0; layer < 16; layer++) {
if (!this.hasSection(layer) || !filter.appliesLayer(this, layer)) {
if ((!full && !this.hasSection(layer)) || !filter.appliesLayer(this, layer)) {
continue;
}
block.init(this, this, layer);

Datei anzeigen

@ -39,6 +39,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
super("PlotSquared");
Fawe.debug("Optimizing PlotSquared");
if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) {
Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false;
setupBlockQueue();
setupSchematicHandler();
setupChunkManager();

Datei anzeigen

@ -1,5 +1,6 @@
package com.sk89q.worldedit.extension.platform.binding;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.internal.annotation.Selection;
@ -55,7 +56,7 @@ public class Bindings {
Annotation annotation = annotations[0] == binding ? annotations[1] : annotations[0];
key = Key.of(ret, annotation);
} else {
System.out.println("Cannot annotate: " + method + " with " + StringMan.getString(annotations));
Fawe.debug("Cannot annotate: " + method + " with " + StringMan.getString(annotations));
return false;
}

Datei anzeigen

@ -91,7 +91,7 @@ public class ProvideBindings extends Bindings {
}
@Binding
public Extent getExtent(Actor actor, InjectedValueAccess access, InjectedValueStore store) {
public Extent getExtent(Actor actor, InjectedValueAccess access) {
Optional<EditSession> editSessionOpt = access.injectedValue(Key.of(EditSession.class));
if (editSessionOpt.isPresent()) {
return editSessionOpt.get();
@ -102,7 +102,10 @@ public class ProvideBindings extends Bindings {
}
Player plr = getPlayer(actor);
EditSession editSession = editSession(getLocalSession(plr), plr);
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
if (access instanceof InjectedValueStore) {
InjectedValueStore store = (InjectedValueStore) access;
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
}
return editSession;
}
}

Datei anzeigen

@ -652,7 +652,7 @@ public interface Extent extends InputExtent, OutputExtent {
return this;
}
default <T extends Filter> T apply(Region region, T filter) {
default <T extends Filter> T apply(Region region, T filter, boolean full) {
return apply((Iterable<BlockVector3>) region, filter);
}

Datei anzeigen

@ -1,5 +1,6 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.sk89q.jnbt.CompoundTag;
@ -250,4 +251,14 @@ public class PassthroughExtent extends AbstractDelegateExtent {
public boolean isWorld() {
return getExtent().isWorld();
}
@Override
public <T extends Filter> T apply(Region region, T filter, boolean full) {
return getExtent().apply(region, filter, full);
}
@Override
public <T extends Filter> T apply(Iterable<BlockVector3> positions, T filter) {
return getExtent().apply(positions, filter);
}
}

Datei anzeigen

@ -172,7 +172,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
// }
@Override
default <T extends Filter> T apply(Region region, T filter) {
default <T extends Filter> T apply(Region region, T filter, boolean full) {
if (region.equals(getRegion())) {
return apply(this, filter);
} else {

Datei anzeigen

@ -671,14 +671,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) {
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
block = block.init(chunkX, chunkZ, get);
if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) {
filter(chunk, filter, block, get, set, minY, maxY);
filter(chunk, filter, block, get, set, minY, maxY, full);
return;
}
int localMinX = Math.max(minX, chunkX << 4) & 15;
@ -692,19 +692,19 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
int minSection = minY >> 4;
int maxSection = maxY >> 4;
if (minSection == maxSection) {
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ);
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ, full);
return;
}
if (yStart != 0) {
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, 15, localMaxZ);
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, 15, localMaxZ, full);
minSection++;
}
if (yEnd != 15) {
filter(chunk, filter, block, get, set, minSection, localMinX, 0, localMinZ, localMaxX, 15, localMaxZ);
filter(chunk, filter, block, get, set, minSection, localMinX, 0, localMinZ, localMaxX, 15, localMaxZ, full);
maxSection--;
}
for (int layer = minSection; layer <= maxSection; layer++) {
filter(chunk, filter, block, get, set, layer, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ);
filter(chunk, filter, block, get, set, layer, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ, full);
}
}

Datei anzeigen

@ -406,15 +406,15 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
@Override
public void filter(final IChunk chunk, final Filter filter, final ChunkFilterBlock block,
final IChunkGet get, final IChunkSet set) {
final IChunkGet get, final IChunkSet set, boolean full) {
int bcx = chunk.getX() >> 4;
int bcz = chunk.getZ() >> 4;
int tcx = bcx + 15;
int tcz = bcz + 15;
if (contains(bcx, bcz) && contains(tcx, tcz)) {
filter(chunk, filter, block, get, set, minY, maxY);
filter(chunk, filter, block, get, set, minY, maxY, full);
return;
}
super.filter(chunk, filter, block, get, set);
super.filter(chunk, filter, block, get, set, full);
}
}

Datei anzeigen

@ -336,7 +336,7 @@ public class EllipsoidRegion extends AbstractRegion {
}
@Override
public void filter(IChunk chunk, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
public void filter(IChunk chunk, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set, boolean full) {
// Check bounds
// This needs to be able to perform 50M blocks/sec otherwise it becomes a bottleneck
int cx = center.getBlockX();
@ -385,7 +385,7 @@ public class EllipsoidRegion extends AbstractRegion {
int yBotFull = Math.max(0, cy - diffYFull);
int yTopFull = Math.min(255, cy + diffYFull);
// Set those layers
filter(chunk, filter, block, get, set, yBotFull, yTopFull);
filter(chunk, filter, block, get, set, yBotFull, yTopFull, full);
// Fill the remaining layers
if (yBotFull != 0 || yTopFull != 255) {
@ -405,7 +405,7 @@ public class EllipsoidRegion extends AbstractRegion {
} else {
super.filter(chunk, filter, block, get, set); // TODO optimize non spheres
super.filter(chunk, filter, block, get, set, full); // TODO optimize non spheres
}
}
}

Datei anzeigen

@ -203,53 +203,53 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
return getMaximumPoint().getY();
}
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) {
int minSection = Math.max(0, getMinimumY() >> 4);
int maxSection = Math.min(15, getMaximumY() >> 4);
for (int layer = minSection; layer <= maxSection; layer++) {
if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return;
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
block = block.init(get, set, layer);
block.filter(filter, this);
}
}
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, final int minY, final int maxY) {
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, final int minY, final int maxY, boolean full) {
int minSection = minY >> 4;
int maxSection = maxY >> 4;
int yStart = (minY & 15);
int yEnd = (maxY & 15);
if (minSection == maxSection) {
filter(chunk, filter, block, get, set, minSection, yStart, yEnd);
filter(chunk, filter, block, get, set, minSection, yStart, yEnd, full);
return;
}
if (yStart != 0) {
filter(chunk, filter, block, get, set, minSection, yStart, 15);
filter(chunk, filter, block, get, set, minSection, yStart, 15, full);
minSection++;
}
if (yEnd != 15) {
filter(chunk, filter, block, get, set, minSection, 0, yEnd);
filter(chunk, filter, block, get, set, minSection, 0, yEnd, full);
maxSection--;
}
for (int layer = minSection; layer <= maxSection; layer++) {
filter(chunk, filter, block, get, set, layer);
filter(chunk, filter, block, get, set, layer, full);
}
return;
}
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer) {
if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return;
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) {
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
block = block.init(get, set, layer);
block.filter(filter);
}
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return;
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) {
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
block = block.init(get, set, layer);
block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ);
}
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd) {
if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return;
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) {
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
block = block.init(get, set, layer);
block.filter(filter, yStart, yEnd);
}