mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
More Kotlin
This commit is contained in:
@ -84,7 +84,7 @@ public class BitSetBlocks implements IChunkSet {
|
||||
|
||||
@Override
|
||||
public char[] load(int layer) {
|
||||
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
||||
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
||||
if (nullRowY instanceof MemBlockSet.RowY) {
|
||||
char value = blockState.getOrdinalChar();
|
||||
|
@ -24,7 +24,7 @@ import java.util.UUID;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
private static Pool<CharSetBlocks> POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
||||
private static Pool<CharSetBlocks> POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
||||
public static CharSetBlocks newInstance() {
|
||||
return POOL.poll();
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class FallbackChunkGet implements IChunkGet {
|
||||
|
||||
@Override
|
||||
public char[] load(int layer) {
|
||||
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
||||
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||
int by = layer << 4;
|
||||
for (int y = 0, i = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
|
@ -55,7 +55,7 @@ object NullChunkGet : IChunkGet {
|
||||
}
|
||||
|
||||
override fun load(layer: Int): CharArray {
|
||||
return FaweCache.IMP.EMPTY_CHAR_4096
|
||||
return FaweCache.EMPTY_CHAR_4096
|
||||
}
|
||||
|
||||
override fun hasSection(layer: Int): Boolean {
|
||||
|
@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
|
||||
private static Pool<ChunkHolder> POOL = FaweCache.IMP.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL);
|
||||
private static Pool<ChunkHolder> POOL = FaweCache.INSTANCE.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL);
|
||||
|
||||
public static ChunkHolder newInstance() {
|
||||
return POOL.poll();
|
||||
|
@ -1,150 +0,0 @@
|
||||
package com.boydti.fawe.beta.implementation.chunk;
|
||||
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.beta.IQueueChunk;
|
||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum NullChunk implements IQueueChunk {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future call() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntity(CompoundTag tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getEntityRemoves() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType[] getBiomes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlocks(int layer, char[] data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSection(int layer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return BlockTypes.__RESERVED__.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getTile(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<CompoundTag> getEntities() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] load(int layer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getEntity(UUID uuid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future call(IChunkSet set, Runnable finalize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,121 @@
|
||||
package com.boydti.fawe.beta.implementation.chunk
|
||||
|
||||
import com.boydti.fawe.beta.Filter
|
||||
import com.boydti.fawe.beta.IChunkSet
|
||||
import com.boydti.fawe.beta.IQueueChunk
|
||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock
|
||||
import com.sk89q.jnbt.CompoundTag
|
||||
import com.sk89q.worldedit.math.BlockVector3
|
||||
import com.sk89q.worldedit.regions.Region
|
||||
import com.sk89q.worldedit.world.biome.BiomeType
|
||||
import com.sk89q.worldedit.world.block.BaseBlock
|
||||
import com.sk89q.worldedit.world.block.BlockState
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder
|
||||
import com.sk89q.worldedit.world.block.BlockTypes
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.Future
|
||||
|
||||
object NullChunk : IQueueChunk<Nothing> {
|
||||
|
||||
override fun getX(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getZ(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun call(): Nothing? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun filterBlocks(filter: Filter, block: ChunkFilterBlock, region: Region?, full: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||
//
|
||||
// }
|
||||
|
||||
override fun setBiome(x: Int, y: Int, z: Int, biome: BiomeType): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setTile(x: Int, y: Int, z: Int, tag: CompoundTag): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setEntity(tag: CompoundTag) {
|
||||
|
||||
}
|
||||
|
||||
override fun removeEntity(uuid: UUID) {
|
||||
|
||||
}
|
||||
|
||||
override fun getEntityRemoves(): Set<UUID>? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getBiomes(): Array<BiomeType>? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun <B : BlockStateHolder<B>> setBlock(x: Int, y: Int, z: Int, block: B): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setBlocks(layer: Int, data: CharArray) {
|
||||
|
||||
}
|
||||
|
||||
override fun getBiomeType(x: Int, y: Int, z: Int): BiomeType? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun hasSection(layer: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun getBlock(x: Int, y: Int, z: Int): BlockState {
|
||||
return BlockTypes.__RESERVED__!!.defaultState
|
||||
}
|
||||
|
||||
override fun getFullBlock(x: Int, y: Int, z: Int): BaseBlock {
|
||||
return BlockTypes.__RESERVED__!!.defaultState.toBaseBlock()
|
||||
}
|
||||
|
||||
override fun getTiles(): Map<BlockVector3, CompoundTag> {
|
||||
return emptyMap()
|
||||
}
|
||||
|
||||
override fun getTile(x: Int, y: Int, z: Int): CompoundTag? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getEntities(): Set<CompoundTag> {
|
||||
return emptySet()
|
||||
}
|
||||
|
||||
override fun load(layer: Int): CharArray? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getEntity(uuid: UUID): CompoundTag? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun <T : Future<T>?> call(set: IChunkSet?, finalize: Runnable?): T? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun trim(aggressive: Boolean): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
this.layer = layer;
|
||||
final IBlocks get = (CharGetBlocks) iget;
|
||||
if (!get.hasSection(layer)) {
|
||||
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
||||
getArr = FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||
} else {
|
||||
getArr = get.load(layer);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ChunkPacket implements Function<byte[], byte[]>, Supplier<byte[]> {
|
||||
synchronized (this) {
|
||||
if (sectionBytes == null) {
|
||||
IBlocks tmpChunk = getChunk();
|
||||
byte[] buf = FaweCache.IMP.BYTE_BUFFER_8192.get();
|
||||
byte[] buf = FaweCache.INSTANCE.getBYTE_BUFFER_8192().get();
|
||||
sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full);
|
||||
}
|
||||
tmp = sectionBytes;
|
||||
@ -83,13 +83,13 @@ public class ChunkPacket implements Function<byte[], byte[]>, Supplier<byte[]> {
|
||||
@Override
|
||||
@Deprecated
|
||||
public byte[] get() {
|
||||
return apply(FaweCache.IMP.BYTE_BUFFER_8192.get());
|
||||
return apply(FaweCache.INSTANCE.getBYTE_BUFFER_8192().get());
|
||||
}
|
||||
|
||||
public CompoundTag getHeightMap() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("MOTION_BLOCKING", new long[36]);
|
||||
CompoundTag tag = FaweCache.IMP.asTag(map);
|
||||
CompoundTag tag = FaweCache.INSTANCE.asTag(map);
|
||||
// TODO
|
||||
return tag;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -132,7 +132,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||
} catch (FaweException e) {
|
||||
@ -145,7 +145,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -158,7 +158,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
@ -171,7 +171,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -184,7 +184,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||
} catch (FaweException e) {
|
||||
@ -197,7 +197,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||
} catch (FaweException e) {
|
||||
@ -210,7 +210,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
|
@ -9,11 +9,9 @@ import com.boydti.fawe.beta.implementation.filter.CountFilter;
|
||||
import com.boydti.fawe.beta.implementation.filter.DistrFilter;
|
||||
import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
||||
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
@ -60,7 +58,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
if (super.cancel()) {
|
||||
processor.setProcessor(new NullExtent(this, FaweCache.MANUAL));
|
||||
processor.setProcessor(new NullExtent(this, FaweCache.INSTANCE.getMANUAL()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -77,11 +75,6 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent enableHistory(AbstractChangeSet changeSet) {
|
||||
return super.enableHistory(changeSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||
// The chunks positions to iterate over
|
||||
@ -187,10 +180,6 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
return apply(region, new DistrFilter(), false).getTypeDistribution();
|
||||
}
|
||||
|
||||
/**
|
||||
* To optimize
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lazily copy a region
|
||||
*
|
||||
@ -199,7 +188,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
*/
|
||||
@Override
|
||||
public Clipboard lazyCopy(Region region) {
|
||||
WorldCopyClipboard clipboard = new WorldCopyClipboard(() -> this, region);
|
||||
Clipboard clipboard = new WorldCopyClipboard(() -> this, region);
|
||||
clipboard.setOrigin(region.getMinimumPoint());
|
||||
return clipboard;
|
||||
}
|
||||
@ -213,7 +202,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
||||
*/
|
||||
@Override
|
||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||
BlockMask mask = new BlockMask(this, searchBlocks);
|
||||
Mask mask = new BlockMask(this, searchBlocks);
|
||||
return countBlocks(region, mask);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
||||
|
||||
private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool();
|
||||
private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool();
|
||||
private ThreadPoolExecutor blockingExecutor = FaweCache.IMP.newBlockingExecutor();
|
||||
private ThreadPoolExecutor blockingExecutor = FaweCache.INSTANCE.newBlockingExecutor();
|
||||
private ConcurrentLinkedQueue<FutureTask> syncTasks = new ConcurrentLinkedQueue<>();
|
||||
private ConcurrentLinkedQueue<FutureTask> syncWhenFree = new ConcurrentLinkedQueue<>();
|
||||
|
||||
|
@ -209,7 +209,6 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
lastChunk = NullChunk.INSTANCE;
|
||||
return NullChunk.INSTANCE;
|
||||
}
|
||||
|
||||
IQueueChunk chunk = chunks.get(pair);
|
||||
if (chunk instanceof ReferenceChunk) {
|
||||
chunk = ((ReferenceChunk) chunk).getParent();
|
||||
|
Reference in New Issue
Block a user