Fix compile

This commit is contained in:
Jesse Boyd 2019-11-07 10:28:17 +00:00
parent fb2f6668b4
commit 82f5c4ebed
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
37 changed files with 316 additions and 201 deletions

View File

@ -41,6 +41,15 @@ ext {
buildNumber = index.toString();
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile::class) {
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
}
}
}
//def rootVersion = "1.13"
//def revision = ""
//def buildNumber = ""

View File

@ -8,7 +8,7 @@ fun Project.applyCommonConfiguration() {
repositories {
mavenCentral()
mavenLocal()
maven { url = uri("http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/") }
maven { url = uri("http://ci.athion.net/job/PlotSquared-we/ws/mvn/") }
maven { url = uri("https://maven.sk89q.com/repo/") }
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("http://empcraft.com/maven2") }

View File

@ -2,3 +2,8 @@ group=com.sk89q.worldedit
#version=7.1.0-SNAPSHOT
org.gradle.jvmargs=-Xmx1G
#org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.caching=true

View File

@ -21,12 +21,10 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.internal.Constants;
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.BlockTypes;
import net.minecraft.server.v1_14_R1.BiomeBase;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.ChunkSection;
import net.minecraft.server.v1_14_R1.DataBits;
import net.minecraft.server.v1_14_R1.DataPalette;
@ -36,11 +34,8 @@ import net.minecraft.server.v1_14_R1.DataPaletteLinear;
import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.EntityTypes;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.LightEngineThreaded;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTTagInt;
import net.minecraft.server.v1_14_R1.SectionPosition;
import net.minecraft.server.v1_14_R1.SystemUtils;
import net.minecraft.server.v1_14_R1.TileEntity;
import net.minecraft.server.v1_14_R1.WorldServer;
import org.bukkit.World;
@ -51,7 +46,6 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@ -205,11 +199,6 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
};
}
@Override
public char[] load(int layer) {
return load(layer, null);
}
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
synchronized (get) {
if (this.nmsChunk != nmsChunk) {
@ -271,7 +260,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
bitMask |= 1 << layer;
char[] setArr = set.getArray(layer);
char[] setArr = set.load(layer);
ChunkSection newSection;
ChunkSection existingSection = sections[layer];
if (existingSection == null) {
@ -506,7 +495,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
}
@Override
public synchronized char[] load(int layer, char[] data) {
public synchronized char[] update(int layer, char[] data) {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {

View File

@ -7,7 +7,7 @@ plugins {
}
repositories {
maven { url = uri("http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/") }
maven { url = uri("http://ci.athion.net/job/PlotSquared-we/ws/mvn/") }
}
applyPlatformAndCoreConfiguration()

View File

@ -219,6 +219,8 @@ public enum FaweCache implements Trimable {
public final CleanableThreadLocal<byte[]> BYTE_BUFFER_8192 = new CleanableThreadLocal<>(() -> new byte[8192]);
public final CleanableThreadLocal<byte[]> BYTE_BUFFER_256 = new CleanableThreadLocal<>(() -> new byte[256]);
public final CleanableThreadLocal<int[]> BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> {
int[] result = new int[BlockTypesCache.states.length];
Arrays.fill(result, Integer.MAX_VALUE);

View File

@ -29,7 +29,7 @@ public interface Filter {
* @param chunk
* @return
*/
default IChunk applyChunk(IChunk chunk, @Nullable Region region) {
default <T extends IChunk> T applyChunk(T chunk, @Nullable Region region) {
return chunk;
}

View File

@ -45,7 +45,7 @@ public interface IBatchProcessor {
for (int layer = 0; layer <= minLayer; layer++) {
if (set.hasSection(layer)) {
if (layer == minLayer) {
char[] arr = set.getArray(layer);
char[] arr = set.load(layer);
int index = (minY & 15) << 8;
for (int i = 0; i < index; i++) arr[i] = 0;
set.setBlocks(layer, arr);
@ -58,7 +58,7 @@ public interface IBatchProcessor {
for (int layer = maxLayer; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
if (set.hasSection(layer)) {
if (layer == minLayer) {
char[] arr = set.getArray(layer);
char[] arr = set.load(layer);
int index = ((maxY + 1) & 15) << 8;
for (int i = index; i < arr.length; i++) arr[i] = 0;
set.setBlocks(layer, arr);

View File

@ -2,19 +2,16 @@ package com.boydti.fawe.beta;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
@ -26,7 +23,7 @@ public interface IBlocks extends Trimable {
boolean hasSection(int layer);
char[] getArray(int layer);
char[] load(int layer);
BlockState getBlock(int x, int y, int z);
@ -64,7 +61,7 @@ public interface IBlocks extends Trimable {
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
if (!this.hasSection(layer)) continue;
char[] ids = this.getArray(layer);
char[] ids = this.load(layer);
int nonEmpty = 0; // TODO optimize into same loop as toPalette
for (int i = 0; i < ids.length; i++) {

View File

@ -7,17 +7,13 @@ 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 java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
/**
* Represents a chunk in the queue {@link IQueueExtent} Used for getting and setting blocks / biomes
* / entities
*/
public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChunkGet {
public interface IChunk extends Trimable, IChunkGet, IChunkSet {
/**
* Initialize at the location
* (allows for reuse)
@ -26,8 +22,7 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
* @param x
* @param z
*/
void init(IQueueExtent extent, int x, int z);
default void init(IQueueExtent extent, int x, int z) {}
/**
* Get chunkX
* @return
@ -56,30 +51,6 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
*/
boolean isEmpty();
/**
* Apply the queued changes to the world containing this chunk.
* <p>The future returned may return another future. To ensure completion keep calling {@link
* Future#get()} on each result.</p>
*
* @return Future
*/
@Override
T call();
/**
* Call and join
* - Should be done async, if at all
* @throws ExecutionException
* @throws InterruptedException
*/
default void join() throws ExecutionException, InterruptedException {
T future = call();
while (future != null) {
future = future.get();
}
return;
}
/**
* Filter through all the blocks in the chunk
*
@ -89,14 +60,14 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
*/
void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region);
/**
* Flood through all the blocks in the chunk
* TODO not implemented
* @param flood
* @param mask
* @param block
*/
void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
// /**
// * Flood through all the blocks in the chunk
// * TODO not implemented
// * @param flood
// * @param mask
// * @param block
// */
// void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
/* set - queues a change */
boolean setBiome(int x, int y, int z, BiomeType biome);
@ -117,13 +88,8 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
@Override
CompoundTag getTag(int x, int y, int z);
/**
* Reset (defaults to just calling init)
* @return
*/
@Override
default IBlocks reset() {
init(null, getX(), getZ());
default IChunk reset() {
return this;
}
}

View File

@ -21,13 +21,13 @@ import javax.annotation.Nullable;
*
* @param <U> parent class
*/
public interface IDelegateChunk<U extends IChunk> extends IChunk {
public interface IDelegateChunk<U extends IQueueChunk> extends IQueueChunk {
U getParent();
@Override
default IChunk getRoot() {
IChunk root = getParent();
default IQueueChunk getRoot() {
IQueueChunk root = getParent();
while (root instanceof IDelegateChunk) {
root = ((IDelegateChunk) root).getParent();
}
@ -49,10 +49,10 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
return getParent().hasSection(layer);
}
@Override
default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
getParent().flood(flood, mask, block);
}
// @Override
// default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
// getParent().flood(flood, mask, block);
// }
@Override
default boolean setTile(int x, int y, int z, CompoundTag tag) {
@ -84,11 +84,6 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
return getParent().getFullBlock(x, y, z);
}
@Override
default char[] load(int layer) {
return getParent().load(layer);
}
@Override
default void init(IQueueExtent extent, int chunkX, int chunkZ) {
getParent().init(extent, chunkX, chunkZ);
@ -146,8 +141,33 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
}
@Override
default char[] getArray(int layer) {
return getParent().getArray(layer);
default char[] load(int layer) {
return getParent().load(layer);
}
@Override
default void setBlocks(int layer, char[] data) {
getParent().setBlocks(layer, data);
}
@Override
default void setEntity(CompoundTag tag) {
getParent().setEntity(tag);
}
@Override
default void removeEntity(UUID uuid) {
getParent().removeEntity(uuid);
}
@Override
default Set<UUID> getEntityRemoves() {
return getParent().getEntityRemoves();
}
@Override
default BiomeType[] getBiomes() {
return getParent().getBiomes();
}
default <T extends IChunk> T findParent(Class<T> clazz) {

View File

@ -35,9 +35,9 @@ import java.util.concurrent.Future;
/**
* Delegate for IQueueExtent
*/
public interface IDelegateQueueExtent extends IQueueExtent {
public interface IDelegateQueueExtent<T extends IQueueChunk> extends IQueueExtent<T> {
IQueueExtent getParent();
IQueueExtent<T> getParent();
@Override
default boolean isQueueEnabled() {
@ -70,12 +70,12 @@ public interface IDelegateQueueExtent extends IQueueExtent {
}
@Override
default IChunk getOrCreateChunk(int x, int z) {
default T getOrCreateChunk(int x, int z) {
return getParent().getOrCreateChunk(x, z);
}
@Override
default <T extends Future<T>> T submit(IChunk<T> chunk) {
default <V extends Future<V>> V submit(T chunk) {
return getParent().submit(chunk);
}
@ -120,12 +120,12 @@ public interface IDelegateQueueExtent extends IQueueExtent {
}
@Override
default IChunk create(boolean isFull) {
default T create(boolean isFull) {
return getParent().create(isFull);
}
@Override
default IChunk wrap(IChunk root) {
default T wrap(T root) {
return getParent().wrap(root);
}

View File

@ -0,0 +1,41 @@
package com.boydti.fawe.beta;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
public interface IQueueChunk<T extends Future<T>> extends IChunk, Callable<T> {
/**
* Reset (defaults to just calling init)
* @return
*/
@Override
default IQueueChunk reset() {
init(null, getX(), getZ());
return this;
}
/**
* Apply the queued changes to the world containing this chunk.
* <p>The future returned may return another future. To ensure completion keep calling {@link
* Future#get()} on each result.</p>
*
* @return Future
*/
@Override
T call();
/**
* Call and join
* - Should be done async, if at all
* @throws ExecutionException
* @throws InterruptedException
*/
default void join() throws ExecutionException, InterruptedException {
T future = call();
while (future != null) {
future = future.get();
}
return;
}
}

View File

@ -25,7 +25,7 @@ import java.util.concurrent.Future;
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
* uses chunks
*/
public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchProcessorHolder {
public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, IChunkExtent<T>, IBatchProcessorHolder {
@Override
default boolean isQueueEnabled() {
@ -78,7 +78,7 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
* @param chunk
* @return result
*/
<T extends Future<T>> T submit(IChunk<T> chunk);
<V extends Future<V>> V submit(T chunk);
@Override
default BlockVector3 getMinimumPoint() {
@ -93,12 +93,12 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
/**
* 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
* #wrap(IChunk)}
* #wrap(T)}
*
* @param isFull true if a more optimized chunk should be returned
* @return a more optimized chunk object
*/
IChunk create(boolean isFull);
T create(boolean isFull);
/**
* Wrap the chunk object (i.e. for region restrictions / limits etc.)
@ -106,7 +106,7 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
* @param root
* @return wrapped chunk
*/
default IChunk wrap(IChunk root) {
default T wrap(T root) {
return root;
}
@ -148,11 +148,11 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
if (!filter.appliesChunk(chunkX, chunkZ)) {
return block;
}
IChunk chunk = this.getOrCreateChunk(chunkX, chunkZ);
T chunk = this.getOrCreateChunk(chunkX, chunkZ);
// Initialize
chunk.init(this, chunkX, chunkZ);
IChunk newChunk = filter.applyChunk(chunk, region);
T newChunk = filter.applyChunk(chunk, region);
if (newChunk != null) {
chunk = newChunk;
if (block == null) {

View File

@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public interface IChunkExtent extends Extent {
public interface IChunkExtent<T extends IChunk> extends Extent {
/**
* Get the IChunk at a position (and cache it if it's not already)
*
@ -17,7 +17,7 @@ public interface IChunkExtent extends Extent {
* @param z
* @return IChunk
*/
IChunk getOrCreateChunk(int chunkX, int chunkZ);
T getOrCreateChunk(int chunkX, int chunkZ);
@Override
default boolean setBlock(int x, int y, int z, BlockStateHolder state) {

View File

@ -80,7 +80,7 @@ public class BitSetBlocks implements IChunkSet {
}
@Override
public char[] getArray(int layer) {
public char[] load(int layer) {
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
MemBlockSet.IRow nullRowY = row.getRow(layer);
if (nullRowY instanceof MemBlockSet.RowY) {

View File

@ -2,16 +2,9 @@ package com.boydti.fawe.beta.implementation.blocks;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkSet;
import com.sk89q.jnbt.CompoundTag;
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.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.util.Map;
import java.util.Set;
public abstract class CharBlocks implements IBlocks {
public static final Section FULL = new Section() {
@ -26,9 +19,9 @@ public abstract class CharBlocks implements IBlocks {
blocks.sections[layer] = FULL;
char[] arr = blocks.blocks[layer];
if (arr == null) {
arr = blocks.blocks[layer] = blocks.load(layer);
arr = blocks.blocks[layer] = blocks.update(layer, null);
} else {
blocks.blocks[layer] = blocks.load(layer, arr);
blocks.blocks[layer] = blocks.update(layer, arr);
}
return arr;
}
@ -74,11 +67,10 @@ public abstract class CharBlocks implements IBlocks {
sections[layer] = EMPTY;
}
public char[] load(int layer) {
public char[] update(int layer, char[] data) {
if (data == null) {
return new char[4096];
}
public char[] load(int layer, char[] data) {
for (int i = 0; i < 4096; i++) {
data[i] = 0;
}
@ -91,7 +83,7 @@ public abstract class CharBlocks implements IBlocks {
}
@Override
public char[] getArray(int layer) {
public char[] load(int layer) {
return sections[layer].get(this, layer);
}

View File

@ -54,8 +54,8 @@ public interface DelegateChunkSet extends IChunkSet {
}
@Override
default char[] getArray(int layer) {
return getParent().getArray(layer);
default char[] load(int layer) {
return getParent().load(layer);
}
@Override

View File

@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -90,7 +89,7 @@ public class FallbackChunkGet implements IChunkGet {
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
for (int layer = 0; layer < 16; layer++) {
if (set.hasSection(layer)) {
char[] arr = set.getArray(layer);
char[] arr = set.load(layer);
int by = layer << 4;
for (int y = 0, i = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
@ -160,11 +159,6 @@ public class FallbackChunkGet implements IChunkGet {
return true;
}
@Override
public char[] getArray(int layer) {
return new char[0];
}
@Override
public IBlocks reset() {
return null;

View File

@ -76,11 +76,6 @@ public enum NullChunkGet implements IChunkGet {
return false;
}
@Override
public char[] getArray(int layer) {
return new char[0];
}
@Override
public IBlocks reset() {
return null;

View File

@ -1,10 +1,9 @@
package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.FilterBlockMask;
import com.boydti.fawe.beta.Flood;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
@ -27,7 +26,7 @@ import javax.annotation.Nullable;
/**
* An abstract {@link IChunk} class that implements basic get/set blocks
*/
public class ChunkHolder<T extends Future<T>> implements IChunk {
public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
private static FaweCache.Pool<ChunkHolder> POOL = FaweCache.IMP.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL);
@ -61,7 +60,32 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
return false;
return delegate.set(this).setTile(x, y, z, tag);
}
@Override
public void setEntity(CompoundTag tag) {
delegate.set(this).setEntity(tag);
}
@Override
public void removeEntity(UUID uuid) {
delegate.set(this).removeEntity(uuid);
}
@Override
public Set<UUID> getEntityRemoves() {
return delegate.set(this).getEntityRemoves();
}
@Override
public BiomeType[] getBiomes() {
return delegate.set(this).getBiomes(); // TODO return get?
}
@Override
public void setBlocks(int layer, char[] data) {
delegate.set(this).setBlocks(layer, data);
}
@Override
@ -259,10 +283,10 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
}
};
@Override
public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
// block.flood(get, set, mask, block, );
}
// @Override
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
//// block.flood(get, set, mask, block, );
// }
@Override
public CompoundTag getTag(int x, int y, int z) {
@ -285,11 +309,6 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
return chunkExisting != null && chunkExisting.hasSection(layer);
}
@Override
public char[] getArray(int layer) {
return delegate.get(this).getArray(layer);
}
@Override
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
final IChunkGet get = getOrCreateGet();

View File

@ -2,11 +2,17 @@ package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IDelegateChunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.util.Set;
import java.util.UUID;
/**
* Implementation of IDelegateChunk
*/
public class DelegateChunk<T extends IChunk> implements IDelegateChunk<T> {
public class DelegateChunk<T extends IQueueChunk> implements IDelegateChunk<T> {
private T parent;

View File

@ -1,6 +1,6 @@
package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
/**
@ -11,7 +11,7 @@ public class FinalizedChunk extends DelegateChunk {
private final IQueueExtent queueExtent;
public FinalizedChunk(IChunk parent, IQueueExtent queueExtent) {
public FinalizedChunk(IQueueChunk parent, IQueueExtent queueExtent) {
super(parent);
this.queueExtent = queueExtent;
}

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.FilterBlockMask;
@ -23,7 +24,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Future;
public enum NullChunk implements IChunk {
public enum NullChunk implements IQueueChunk {
INSTANCE;
@Override
@ -54,10 +55,10 @@ public enum NullChunk implements IChunk {
}
@Override
public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
}
// @Override
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
//
// }
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
@ -69,11 +70,36 @@ public enum NullChunk implements IChunk {
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 boolean setBlock(int x, int y, int z, BlockStateHolder block) {
return false;
}
@Override
public void setBlocks(int layer, char[] data) {
}
@Override
public BiomeType getBiomeType(int x, int z) {
return null;
@ -84,11 +110,6 @@ public enum NullChunk implements IChunk {
return false;
}
@Override
public char[] getArray(int layer) {
return null;
}
@Override
public BlockState getBlock(int x, int y, int z) {
return BlockTypes.__RESERVED__.getDefaultState();

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IDelegateChunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import java.lang.ref.Reference;
@ -14,14 +15,14 @@ public abstract class ReferenceChunk implements IDelegateChunk {
private final Reference<FinalizedChunk> reference;
public ReferenceChunk(IChunk parent, IQueueExtent queueExtent) {
public ReferenceChunk(IQueueChunk parent, IQueueExtent queueExtent) {
this.reference = toReference(new FinalizedChunk(parent, queueExtent));
}
protected abstract Reference<FinalizedChunk> toReference(FinalizedChunk parent);
@Override
public IChunk getParent() {
public IQueueChunk getParent() {
final FinalizedChunk finalized = reference.get();
return finalized != null ? finalized.getParent() : null;
}

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
@ -10,7 +11,7 @@ import java.lang.ref.SoftReference;
*/
public class SoftChunk extends ReferenceChunk {
public SoftChunk(IChunk parent, IQueueExtent queueExtent) {
public SoftChunk(IQueueChunk parent, IQueueExtent queueExtent) {
super(parent, queueExtent);
}

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.beta.implementation.chunk;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import java.lang.ref.Reference;
@ -11,7 +12,7 @@ import java.lang.ref.WeakReference;
*/
public class WeakChunk extends ReferenceChunk {
public WeakChunk(IChunk parent, IQueueExtent queueExtent) {
public WeakChunk(IQueueChunk parent, IQueueExtent queueExtent) {
super(parent, queueExtent);
}

View File

@ -94,7 +94,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
this.set = iset;
getArr = get.sections[layer].get(get, layer);
if (set.hasSection(layer)) {
setArr = set.getArray(layer);
setArr = set.load(layer);
delegate = FULL;
} else {
delegate = NULL;
@ -409,7 +409,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
Set delegate
*/
private SetDelegate initSet() {
setArr = set.getArray(layer);
setArr = set.load(layer);
return delegate = FULL;
}

View File

@ -6,6 +6,7 @@ import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.beta.implementation.cache.ChunkCache;
@ -228,7 +229,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
}
}
public <T extends Future<T>> T submit(IChunk<T> chunk) {
public <T extends Future<T>> T submit(IQueueChunk<T> chunk) {
// if (MemUtil.isMemoryFree()) { TODO NOT IMPLEMENTED - optimize this
// return (T) forkJoinPoolSecondary.submit(chunk);
// }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.beta.implementation.queue;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.IBatchProcessor;
@ -34,12 +35,12 @@ import java.util.concurrent.Future;
* <p>
* This queue is reusable {@link #init(IChunkCache)}
*/
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent {
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
// // Pool discarded chunks for reuse (can safely be cleared by another thread)
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
// Chunks currently being queued / worked on
private final Long2ObjectLinkedOpenHashMap<IChunk> chunks = new Long2ObjectLinkedOpenHashMap<>();
private final Long2ObjectLinkedOpenHashMap<IQueueChunk> chunks = new Long2ObjectLinkedOpenHashMap<>();
private IChunkCache<IChunkGet> cacheGet;
private IChunkCache<IChunkSet> cacheSet;
@ -48,7 +49,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
private Thread currentThread;
private ConcurrentLinkedQueue<Future> submissions = new ConcurrentLinkedQueue<>();
// Last access pointers
private IChunk lastChunk;
private IQueueChunk lastChunk;
private long lastPair = Long.MAX_VALUE;
private boolean enabledQueue = true;
@ -135,7 +136,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
@Override
public <T extends Future<T>> T submit(IChunk<T> chunk) {
public <V extends Future<V>> V submit(IQueueChunk chunk) {
if (lastChunk == chunk) {
lastPair = Long.MAX_VALUE;
lastChunk = null;
@ -152,18 +153,18 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
* @param <T>
* @return
*/
private <T extends Future<T>> T submitUnchecked(IChunk<T> chunk) {
private <V extends Future<V>> V submitUnchecked(IQueueChunk chunk) {
if (chunk.isEmpty()) {
chunk.recycle();
Future result = Futures.immediateFuture(null);
return (T) result;
return (V) result;
}
if (Fawe.isMainThread()) {
return chunk.call();
return (V) chunk.call();
}
return Fawe.get().getQueueHandler().submit(chunk);
return (V) Fawe.get().getQueueHandler().submit(chunk);
}
@Override
@ -195,14 +196,14 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
* @param Z
* @return IChunk
*/
private IChunk poolOrCreate(int X, int Z) {
IChunk next = create(false);
private ChunkHolder poolOrCreate(int X, int Z) {
ChunkHolder next = create(false);
next.init(this, X, Z);
return next;
}
@Override
public final IChunk getOrCreateChunk(int x, int z) {
public final IQueueChunk getOrCreateChunk(int x, int z) {
final long pair = (long) x << 32 | z & 0xffffffffL;
if (pair == lastPair) {
return lastChunk;
@ -213,7 +214,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
return NullChunk.INSTANCE;
}
IChunk chunk = chunks.get(pair);
IQueueChunk chunk = chunks.get(pair);
if (chunk instanceof ReferenceChunk) {
chunk = ((ReferenceChunk) chunk).getParent();
}
@ -251,7 +252,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
@Override
public IChunk create(boolean isFull) {
public ChunkHolder create(boolean isFull) {
return ChunkHolder.newInstance();
}
@ -299,7 +300,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
public synchronized void flush() {
if (!chunks.isEmpty()) {
if (MemUtil.isMemoryLimited()) {
for (IChunk chunk : chunks.values()) {
for (IQueueChunk chunk : chunks.values()) {
final Future future = submitUnchecked(chunk);
if (future != null && !future.isDone()) {
pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true);
@ -307,7 +308,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
}
} else {
for (IChunk chunk : chunks.values()) {
for (IQueueChunk chunk : chunks.values()) {
final Future future = submitUnchecked(chunk);
if (future != null && !future.isDone()) {
submissions.add(future);

View File

@ -1,7 +1,11 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.jnbt.streamer.StreamDelegate;
import com.boydti.fawe.jnbt.streamer.ValueReader;
import com.boydti.fawe.object.collection.BitArray4096;
@ -15,9 +19,11 @@ import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -25,6 +31,7 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -34,12 +41,13 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Future;
public class MCAChunk implements IChunkSet {
public class MCAChunk implements IChunk {
public final boolean[] hasSections = new boolean[16];
public boolean hasBiomes = false;
public final byte[] biomes = new byte[256];
public final BiomeType[] biomes = new BiomeType[256];
public final char[] blocks = new char[65536];
@ -92,6 +100,13 @@ public class MCAChunk implements IChunkSet {
read(nis, readPos);
}
@Override
public void init(IQueueExtent extent, int x, int z) {
if (x != chunkX || z != chunkZ) {
throw new UnsupportedOperationException("Not reuse capable");
}
}
public void read(NBTInputStream nis, boolean readPos) throws IOException {
StreamDelegate root = createDelegate(nis, readPos);
nis.readNamedTagLazy(root);
@ -153,7 +168,7 @@ public class MCAChunk implements IChunkSet {
CompoundTag entity = FaweCache.IMP.asTag(value);
entities.put(entity.getUUID(), entity);
});
level.add("Biomes").withInt((index, value) -> biomes[index] = (byte) value);
level.add("Biomes").withInt((index, value) -> biomes[index] = BiomeTypes.getLegacy(value));
return root;
}
@ -177,11 +192,11 @@ public class MCAChunk implements IChunkSet {
}
@Override
public IChunkSet reset() {
public MCAChunk reset() {
return this.reset(true);
}
public IChunkSet reset(boolean full) {
public MCAChunk reset(boolean full) {
if (!tiles.isEmpty()) {
tiles.clear();
}
@ -226,7 +241,12 @@ public class MCAChunk implements IChunkSet {
out.writeNamedTag("InhabitedTime", inhabitedTime);
out.writeNamedTag("LastUpdate", lastUpdate);
if (hasBiomes) {
out.writeNamedTag("Biomes", biomes);
int type = NBTConstants.TYPE_BYTE_ARRAY;
out.writeNamedTagName("Biomes", type);
out.writeInt(biomes.length);
for (int i = 0; i < biomes.length; i++) {
out.write(biomes[i].getLegacyId());
}
}
int len = 0;
for (boolean hasSection : hasSections) {
@ -424,16 +444,12 @@ public class MCAChunk implements IChunkSet {
@Override
public BiomeType getBiomeType(int x, int z) {
return BiomeTypes.get(this.biomes[(z << 4) | x] & 0xFF);
return this.biomes[(z << 4) | x];
}
@Override
public BiomeType[] getBiomes() {
BiomeType[] tmp = new BiomeType[256];
for (int i = 0; i < 256; i++) {
tmp[i] = BiomeTypes.get(this.biomes[i] & 0xFF);
}
return tmp;
return this.biomes;
}
@Override
@ -444,7 +460,7 @@ public class MCAChunk implements IChunkSet {
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
setModified();
biomes[x + (z << 4)] = (byte) biome.getInternalId();
biomes[x + (z << 4)] = biome;
return true;
}
@ -479,6 +495,16 @@ public class MCAChunk implements IChunkSet {
return BlockState.getFromOrdinal(ordinal);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
return null;
}
@Override
public CompoundTag getTag(int x, int y, int z) {
return null;
}
public Set<UUID> getEntityRemoves() {
return new HashSet<>();
}
@ -499,7 +525,7 @@ public class MCAChunk implements IChunkSet {
}
@Override
public char[] getArray(int layer) {
public char[] load(int layer) {
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
int offset = layer << 12;
for (int i = 0; i < 4096; i++) {
@ -513,7 +539,7 @@ public class MCAChunk implements IChunkSet {
}
public void setBiome(BiomeType biome) {
Arrays.fill(biomes, (byte) biome.getInternalId());
Arrays.fill(this.biomes, biome);
}
public void removeEntity(UUID uuid) {
@ -524,4 +550,34 @@ public class MCAChunk implements IChunkSet {
public boolean trim(boolean aggressive) {
return isEmpty();
}
@Override
public CompoundTag getEntity(UUID uuid) {
return this.entities.get(uuid);
}
@Override
public Future call(IChunkSet set, Runnable finalize) {
return null;
}
@Override
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
try {
if (region != null) {
region.filter(this, filter, block, this, this);
} else {
block = block.init(chunkX, chunkZ, this);
for (int layer = 0; layer < 16; layer++) {
if (!this.hasSection(layer) || !filter.appliesLayer(this, layer)) {
continue;
}
block.init(this, this, layer);
block.filter(filter);
}
}
} finally {
filter.finishChunk(this);
}
}
}

View File

@ -1584,7 +1584,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int index;
int maxY = 0;
int minY = Integer.MAX_VALUE;
byte[] heightMap = chunk.biomes;
byte[] heightMap = FaweCache.IMP.BYTE_BUFFER_256.get();
int globalIndex;
for (int z = csz; z <= cez; z++) {
globalIndex = z * getWidth() + csx;
@ -1717,7 +1717,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
for (int i = 0; i < 256; i++) {
chunk.biomes[i] = biomes[indexes[i]];
byte biomeId = biomes[indexes[i]];
if (biomeId != 0) {
chunk.biomes[i] = BiomeTypes.get(biomeId);
}
}

View File

@ -173,11 +173,11 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor {
for (int layer = 0; layer < 16; layer++) {
if (!set.hasSection(layer)) continue;
// add each block and tile
char[] blocksGet = get.getArray(layer);
char[] blocksGet = get.load(layer);
if (blocksGet == null) {
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
}
char[] blocksSet = set.getArray(layer);
char[] blocksSet = set.load(layer);
int by = layer << 4;
for (int y = 0, index = 0; y < 16; y++) {

View File

@ -54,10 +54,6 @@ public class FaweSchematicHandler extends SchematicHandler {
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
final int mx = pos1.getX();
final int my = pos1.getY();
final int mz = pos1.getZ();
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
Clipboard holder = new BlockArrayClipboard(region, clipboard);

View File

@ -630,7 +630,6 @@ public final class PlatformCommandManager {
Command cmd = optional.get();
CommandQueuedCondition queued = cmd.getCondition().as(CommandQueuedCondition.class).orElse(null);
if (queued != null && !queued.isQueued()) {
System.out.println("Not queued");
handleCommandOnCurrentThread(event);
return;
}

View File

@ -741,7 +741,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
int indexY, index;
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
if (set.hasSection(layer)) {
char[] arr = set.getArray(layer);
char[] arr = set.load(layer);
if (trimX || trimZ) {
indexY = 0;
for (int y = 0; y < 16; y++, indexY += 256) {

View File

@ -294,7 +294,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
} else {
boolean changed = true;
processExtra = true;
char[] arr = set.getArray(layer);
char[] arr = set.load(layer);
for (int y = 0, index = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++, index++) {