Minor changes

This commit is contained in:
MattBDev
2020-02-14 14:29:08 -05:00
parent 647665c3b0
commit 49dbd4b76b
17 changed files with 49 additions and 70 deletions

View File

@ -1,11 +1,13 @@
package com.boydti.fawe.beta;
import org.jetbrains.annotations.Range;
/**
* IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple
* IQueueExtents - avoids conversion between a palette and raw data on every block get
*/
public interface IChunkCache<T> extends Trimable {
T get(int chunkX, int chunkZ);
T get(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
@Override
default boolean trim(boolean aggressive) {

View File

@ -13,6 +13,7 @@ import java.io.Flushable;
import java.util.Set;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
@ -53,15 +54,15 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
* @param z
* @return
*/
IChunkGet getCachedGet(int x, int z);
IChunkGet getCachedGet(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
/**
* Get the cached chunk set object
* @param x
* @param z
* @param chunkX
* @param chunkZ
* @return
*/
IChunkSet getCachedSet(int x, int z);
IChunkSet getCachedSet(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
/**
* Submit the chunk so that it's changes are applied to the world

View File

@ -105,7 +105,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return delegate.get(this).getEntity(uuid);
}
public static final IBlockDelegate BOTH = new IBlockDelegate() {
private static final IBlockDelegate BOTH = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -144,7 +144,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate GET = new IBlockDelegate() {
private static final IBlockDelegate GET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -189,7 +190,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate SET = new IBlockDelegate() {
private static final IBlockDelegate SET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet();
@ -235,7 +237,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate NULL = new IBlockDelegate() {
private static final IBlockDelegate NULL = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet();
@ -287,11 +290,6 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
}
};
// @Override
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
//// block.flood(get, set, mask, block, );
// }
@Override
public Map<BlockVector3, CompoundTag> getTiles() {
return delegate.get(this).getTiles();

View File

@ -23,27 +23,17 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public class CharFilterBlock extends ChunkFilterBlock {
private static final SetDelegate FULL = new SetDelegate() {
@Override
public final void set(CharFilterBlock block, char value) {
block.setArr[block.index] = value;
}
};
private static final SetDelegate NULL = new SetDelegate() {
@Override
public void set(CharFilterBlock block, char value) {
block.initSet().set(block, value);
}
};
private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
private CharGetBlocks get;
private IChunkSet set;
private char[] getArr;
private @Nullable
char[] setArr;
private @Nullable char[] setArr;
private SetDelegate delegate;
// local
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
@ -65,11 +55,10 @@ public class CharFilterBlock extends ChunkFilterBlock {
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
this.get = (CharGetBlocks) iget;
this.layer = layer;
final IBlocks get = (CharGetBlocks) iget;
if (!get.hasSection(layer)) {
if (!iget.hasSection(layer)) {
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
} else {
getArr = get.load(layer);
getArr = iget.load(layer);
}
this.set = iset;
if (set.hasSection(layer)) {
@ -445,6 +434,6 @@ public class CharFilterBlock extends ChunkFilterBlock {
private interface SetDelegate {
void set(CharFilterBlock block, char value);
void set(@NotNull CharFilterBlock block, char value);
}
}

View File

@ -72,13 +72,13 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
@Override
public IChunkGet getCachedGet(int x, int z) {
return cacheGet.get(x, z);
public IChunkGet getCachedGet(int chunkX, int chunkZ) {
return cacheGet.get(chunkX, chunkZ);
}
@Override
public IChunkSet getCachedSet(int x, int z) {
return cacheSet.get(x, z);
public IChunkSet getCachedSet(int chunkX, int chunkZ) {
return cacheSet.get(chunkX, chunkZ);
}
/**