mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 12:33:54 +00:00
Allow fastmode to be used in a lot more places
- Option to stop fastmode from bothering to fix existing ticking blocks
This commit is contained in:
@ -3,14 +3,12 @@ package com.boydti.fawe.beta;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.OutputExtent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for setting blocks
|
||||
@ -42,6 +40,13 @@ public interface IChunkSet extends IBlocks, OutputExtent {
|
||||
return getBiomes() != null;
|
||||
}
|
||||
|
||||
default boolean isFastMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//default to avoid tricky child classes. We only need it in a few cases anyway.
|
||||
default void setFastMode(boolean fastMode){}
|
||||
|
||||
@Override
|
||||
IChunkSet reset();
|
||||
|
||||
|
@ -82,6 +82,10 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
return BlockVector3.at(30000000, FaweCache.IMP.WORLD_MAX_Y, 30000000);
|
||||
}
|
||||
|
||||
void setFastMode(boolean fastMode);
|
||||
|
||||
boolean isFastMode();
|
||||
|
||||
/**
|
||||
* Create a new root IChunk object<br> - Full chunks will be reused, so a more optimized chunk
|
||||
* can be returned in that case<br> - Don't wrap the chunk, that should be done in {@link
|
||||
@ -143,6 +147,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
T chunk = this.getOrCreateChunk(chunkX, chunkZ);
|
||||
// Initialize
|
||||
chunk.init(this, chunkX, chunkZ);
|
||||
chunk.setFastMode(isFastMode());
|
||||
|
||||
T newChunk = filter.applyChunk(chunk, region);
|
||||
if (newChunk != null) {
|
||||
|
@ -34,6 +34,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
public BlockVector3ChunkMap<CompoundTag> tiles;
|
||||
public HashSet<CompoundTag> entities;
|
||||
public HashSet<UUID> entityRemoves;
|
||||
private boolean fastMode = false;
|
||||
|
||||
private CharSetBlocks() {}
|
||||
|
||||
@ -131,6 +132,16 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
entityRemoves.add(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFastMode(boolean fastMode) {
|
||||
this.fastMode = fastMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFastMode() {
|
||||
return fastMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (biomes != null) {
|
||||
|
@ -42,6 +42,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
private IQueueExtent<? extends IChunk> extent; // the parent queue extent which has this chunk
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private boolean fastmode;
|
||||
|
||||
private ChunkHolder() {
|
||||
this.delegate = NULL;
|
||||
@ -100,6 +101,16 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
return getOrCreateGet().load(layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFastMode() {
|
||||
return fastmode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFastMode(boolean fastmode) {
|
||||
this.fastmode = fastmode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getEntity(UUID uuid) {
|
||||
return delegate.get(this).getEntity(uuid);
|
||||
@ -313,6 +324,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
|
||||
final IChunkGet get = getOrCreateGet();
|
||||
final IChunkSet set = getOrCreateSet();
|
||||
set.setFastMode(fastmode);
|
||||
try {
|
||||
block.filter(this, get, set, filter, region, full);
|
||||
} finally {
|
||||
|
@ -44,12 +44,14 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
private final QueueHandler handler;
|
||||
private final BatchProcessorHolder processor;
|
||||
private int changes;
|
||||
private final boolean fastmode;
|
||||
|
||||
public ParallelQueueExtent(QueueHandler handler, World world) {
|
||||
public ParallelQueueExtent(QueueHandler handler, World world, boolean fastmode) {
|
||||
super(handler.getQueue(world, new BatchProcessorHolder()));
|
||||
this.world = world;
|
||||
this.handler = handler;
|
||||
this.processor = (BatchProcessorHolder) getExtent().getProcessor();
|
||||
this.fastmode = fastmode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +96,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
final Filter newFilter = filter.fork();
|
||||
// Create a chunk that we will reuse/reset for each operation
|
||||
final IQueueExtent<IQueueChunk> queue = getNewQueue();
|
||||
queue.setFastMode(fastmode);
|
||||
synchronized (queue) {
|
||||
ChunkFilterBlock block = null;
|
||||
|
||||
|
@ -49,6 +49,8 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
|
||||
private boolean enabledQueue = true;
|
||||
|
||||
private boolean fastmode = false;
|
||||
|
||||
/**
|
||||
* Safety check to ensure that the thread being used matches the one being initialized on. - Can
|
||||
* be removed later
|
||||
@ -80,6 +82,16 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
return cacheSet.get(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFastMode(boolean fastmode) {
|
||||
this.fastmode = fastmode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFastMode() {
|
||||
return fastmode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the queue.
|
||||
*/
|
||||
|
@ -309,6 +309,11 @@ public class Settings extends Config {
|
||||
})
|
||||
public int DISCARD_AFTER_MS = 60000;
|
||||
|
||||
@Comment({
|
||||
"When using fastmode also do not bother to fix existing ticking blocks"
|
||||
})
|
||||
public boolean NO_TICK_FASTMODE = true;
|
||||
|
||||
public static class PROGRESS {
|
||||
@Comment({"Display constant titles about the progress of a user's edit",
|
||||
" - false = disabled",
|
||||
|
@ -296,7 +296,7 @@ public class EditSessionBuilder {
|
||||
if (unwrapped instanceof IQueueExtent) {
|
||||
extent = queue = (IQueueExtent) unwrapped;
|
||||
} else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1 && threaded) {
|
||||
ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.get().getQueueHandler(), world);
|
||||
ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.get().getQueueHandler(), world, fastmode);
|
||||
queue = parallel.getExtent();
|
||||
extent = parallel;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user