mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fix compile
This commit is contained in:
parent
fb2f6668b4
commit
82f5c4ebed
@ -41,6 +41,15 @@ ext {
|
|||||||
buildNumber = index.toString();
|
buildNumber = index.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
gradle.projectsEvaluated {
|
||||||
|
tasks.withType(JavaCompile::class) {
|
||||||
|
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//def rootVersion = "1.13"
|
//def rootVersion = "1.13"
|
||||||
//def revision = ""
|
//def revision = ""
|
||||||
//def buildNumber = ""
|
//def buildNumber = ""
|
||||||
|
@ -8,7 +8,7 @@ fun Project.applyCommonConfiguration() {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
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://maven.sk89q.com/repo/") }
|
||||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
||||||
maven { url = uri("http://empcraft.com/maven2") }
|
maven { url = uri("http://empcraft.com/maven2") }
|
||||||
|
@ -2,3 +2,8 @@ group=com.sk89q.worldedit
|
|||||||
#version=7.1.0-SNAPSHOT
|
#version=7.1.0-SNAPSHOT
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1G
|
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
|
@ -21,12 +21,10 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
|||||||
import com.sk89q.worldedit.internal.Constants;
|
import com.sk89q.worldedit.internal.Constants;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockTypes;
|
||||||
import net.minecraft.server.v1_14_R1.BiomeBase;
|
import net.minecraft.server.v1_14_R1.BiomeBase;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.Chunk;
|
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.ChunkSection;
|
||||||
import net.minecraft.server.v1_14_R1.DataBits;
|
import net.minecraft.server.v1_14_R1.DataBits;
|
||||||
import net.minecraft.server.v1_14_R1.DataPalette;
|
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.Entity;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
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.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagInt;
|
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.TileEntity;
|
||||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -51,7 +46,6 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Future;
|
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) {
|
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||||
synchronized (get) {
|
synchronized (get) {
|
||||||
if (this.nmsChunk != nmsChunk) {
|
if (this.nmsChunk != nmsChunk) {
|
||||||
@ -271,7 +260,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
|
|
||||||
bitMask |= 1 << layer;
|
bitMask |= 1 << layer;
|
||||||
|
|
||||||
char[] setArr = set.getArray(layer);
|
char[] setArr = set.load(layer);
|
||||||
ChunkSection newSection;
|
ChunkSection newSection;
|
||||||
ChunkSection existingSection = sections[layer];
|
ChunkSection existingSection = sections[layer];
|
||||||
if (existingSection == null) {
|
if (existingSection == null) {
|
||||||
@ -506,7 +495,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized char[] load(int layer, char[] data) {
|
public synchronized char[] update(int layer, char[] data) {
|
||||||
ChunkSection section = getSections()[layer];
|
ChunkSection section = getSections()[layer];
|
||||||
// Section is null, return empty array
|
// Section is null, return empty array
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
|
@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
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()
|
applyPlatformAndCoreConfiguration()
|
||||||
|
@ -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_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<>(() -> {
|
public final CleanableThreadLocal<int[]> BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> {
|
||||||
int[] result = new int[BlockTypesCache.states.length];
|
int[] result = new int[BlockTypesCache.states.length];
|
||||||
Arrays.fill(result, Integer.MAX_VALUE);
|
Arrays.fill(result, Integer.MAX_VALUE);
|
||||||
|
@ -29,7 +29,7 @@ public interface Filter {
|
|||||||
* @param chunk
|
* @param chunk
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
default IChunk applyChunk(IChunk chunk, @Nullable Region region) {
|
default <T extends IChunk> T applyChunk(T chunk, @Nullable Region region) {
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public interface IBatchProcessor {
|
|||||||
for (int layer = 0; layer <= minLayer; layer++) {
|
for (int layer = 0; layer <= minLayer; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
if (layer == minLayer) {
|
if (layer == minLayer) {
|
||||||
char[] arr = set.getArray(layer);
|
char[] arr = set.load(layer);
|
||||||
int index = (minY & 15) << 8;
|
int index = (minY & 15) << 8;
|
||||||
for (int i = 0; i < index; i++) arr[i] = 0;
|
for (int i = 0; i < index; i++) arr[i] = 0;
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
@ -58,7 +58,7 @@ public interface IBatchProcessor {
|
|||||||
for (int layer = maxLayer; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = maxLayer; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
if (layer == minLayer) {
|
if (layer == minLayer) {
|
||||||
char[] arr = set.getArray(layer);
|
char[] arr = set.load(layer);
|
||||||
int index = ((maxY + 1) & 15) << 8;
|
int index = ((maxY + 1) & 15) << 8;
|
||||||
for (int i = index; i < arr.length; i++) arr[i] = 0;
|
for (int i = index; i < arr.length; i++) arr[i] = 0;
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
|
@ -2,19 +2,16 @@ package com.boydti.fawe.beta;
|
|||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.FaweOutputStream;
|
import com.boydti.fawe.object.FaweOutputStream;
|
||||||
import com.boydti.fawe.object.collection.BitArray4096;
|
|
||||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockID;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -26,7 +23,7 @@ public interface IBlocks extends Trimable {
|
|||||||
|
|
||||||
boolean hasSection(int layer);
|
boolean hasSection(int layer);
|
||||||
|
|
||||||
char[] getArray(int layer);
|
char[] load(int layer);
|
||||||
|
|
||||||
BlockState getBlock(int x, int y, int z);
|
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++) {
|
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
||||||
if (!this.hasSection(layer)) continue;
|
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
|
int nonEmpty = 0; // TODO optimize into same loop as toPalette
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
|
@ -7,17 +7,13 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
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;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chunk in the queue {@link IQueueExtent} Used for getting and setting blocks / biomes
|
* Represents a chunk in the queue {@link IQueueExtent} Used for getting and setting blocks / biomes
|
||||||
* / entities
|
* / entities
|
||||||
*/
|
*/
|
||||||
public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChunkGet {
|
public interface IChunk extends Trimable, IChunkGet, IChunkSet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize at the location
|
* Initialize at the location
|
||||||
* (allows for reuse)
|
* (allows for reuse)
|
||||||
@ -26,8 +22,7 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
|
|||||||
* @param x
|
* @param x
|
||||||
* @param z
|
* @param z
|
||||||
*/
|
*/
|
||||||
void init(IQueueExtent extent, int x, int z);
|
default void init(IQueueExtent extent, int x, int z) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get chunkX
|
* Get chunkX
|
||||||
* @return
|
* @return
|
||||||
@ -56,30 +51,6 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T>, IChu
|
|||||||
*/
|
*/
|
||||||
boolean isEmpty();
|
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
|
* 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);
|
void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Flood through all the blocks in the chunk
|
// * Flood through all the blocks in the chunk
|
||||||
* TODO not implemented
|
// * TODO not implemented
|
||||||
* @param flood
|
// * @param flood
|
||||||
* @param mask
|
// * @param mask
|
||||||
* @param block
|
// * @param block
|
||||||
*/
|
// */
|
||||||
void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
|
// void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
|
||||||
|
|
||||||
/* set - queues a change */
|
/* set - queues a change */
|
||||||
boolean setBiome(int x, int y, int z, BiomeType biome);
|
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
|
@Override
|
||||||
CompoundTag getTag(int x, int y, int z);
|
CompoundTag getTag(int x, int y, int z);
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset (defaults to just calling init)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
default IBlocks reset() {
|
default IChunk reset() {
|
||||||
init(null, getX(), getZ());
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ import javax.annotation.Nullable;
|
|||||||
*
|
*
|
||||||
* @param <U> parent class
|
* @param <U> parent class
|
||||||
*/
|
*/
|
||||||
public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
public interface IDelegateChunk<U extends IQueueChunk> extends IQueueChunk {
|
||||||
|
|
||||||
U getParent();
|
U getParent();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IChunk getRoot() {
|
default IQueueChunk getRoot() {
|
||||||
IChunk root = getParent();
|
IQueueChunk root = getParent();
|
||||||
while (root instanceof IDelegateChunk) {
|
while (root instanceof IDelegateChunk) {
|
||||||
root = ((IDelegateChunk) root).getParent();
|
root = ((IDelegateChunk) root).getParent();
|
||||||
}
|
}
|
||||||
@ -49,10 +49,10 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
|||||||
return getParent().hasSection(layer);
|
return getParent().hasSection(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
// default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||||
getParent().flood(flood, mask, block);
|
// getParent().flood(flood, mask, block);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean setTile(int x, int y, int z, CompoundTag tag) {
|
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);
|
return getParent().getFullBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default char[] load(int layer) {
|
|
||||||
return getParent().load(layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void init(IQueueExtent extent, int chunkX, int chunkZ) {
|
default void init(IQueueExtent extent, int chunkX, int chunkZ) {
|
||||||
getParent().init(extent, chunkX, chunkZ);
|
getParent().init(extent, chunkX, chunkZ);
|
||||||
@ -146,8 +141,33 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default char[] getArray(int layer) {
|
default char[] load(int layer) {
|
||||||
return getParent().getArray(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) {
|
default <T extends IChunk> T findParent(Class<T> clazz) {
|
||||||
|
@ -35,9 +35,9 @@ import java.util.concurrent.Future;
|
|||||||
/**
|
/**
|
||||||
* Delegate for IQueueExtent
|
* Delegate for IQueueExtent
|
||||||
*/
|
*/
|
||||||
public interface IDelegateQueueExtent extends IQueueExtent {
|
public interface IDelegateQueueExtent<T extends IQueueChunk> extends IQueueExtent<T> {
|
||||||
|
|
||||||
IQueueExtent getParent();
|
IQueueExtent<T> getParent();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean isQueueEnabled() {
|
default boolean isQueueEnabled() {
|
||||||
@ -70,12 +70,12 @@ public interface IDelegateQueueExtent extends IQueueExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IChunk getOrCreateChunk(int x, int z) {
|
default T getOrCreateChunk(int x, int z) {
|
||||||
return getParent().getOrCreateChunk(x, z);
|
return getParent().getOrCreateChunk(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default <T extends Future<T>> T submit(IChunk<T> chunk) {
|
default <V extends Future<V>> V submit(T chunk) {
|
||||||
return getParent().submit(chunk);
|
return getParent().submit(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,12 +120,12 @@ public interface IDelegateQueueExtent extends IQueueExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IChunk create(boolean isFull) {
|
default T create(boolean isFull) {
|
||||||
return getParent().create(isFull);
|
return getParent().create(isFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IChunk wrap(IChunk root) {
|
default T wrap(T root) {
|
||||||
return getParent().wrap(root);
|
return getParent().wrap(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ import java.util.concurrent.Future;
|
|||||||
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
|
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
|
||||||
* uses chunks
|
* uses chunks
|
||||||
*/
|
*/
|
||||||
public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchProcessorHolder {
|
public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, IChunkExtent<T>, IBatchProcessorHolder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean isQueueEnabled() {
|
default boolean isQueueEnabled() {
|
||||||
@ -78,7 +78,7 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
|
|||||||
* @param chunk
|
* @param chunk
|
||||||
* @return result
|
* @return result
|
||||||
*/
|
*/
|
||||||
<T extends Future<T>> T submit(IChunk<T> chunk);
|
<V extends Future<V>> V submit(T chunk);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockVector3 getMinimumPoint() {
|
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
|
* 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
|
* 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
|
* @param isFull true if a more optimized chunk should be returned
|
||||||
* @return a more optimized chunk object
|
* @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.)
|
* 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
|
* @param root
|
||||||
* @return wrapped chunk
|
* @return wrapped chunk
|
||||||
*/
|
*/
|
||||||
default IChunk wrap(IChunk root) {
|
default T wrap(T root) {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,11 +148,11 @@ public interface IQueueExtent extends Flushable, Trimable, IChunkExtent, IBatchP
|
|||||||
if (!filter.appliesChunk(chunkX, chunkZ)) {
|
if (!filter.appliesChunk(chunkX, chunkZ)) {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
IChunk chunk = this.getOrCreateChunk(chunkX, chunkZ);
|
T chunk = this.getOrCreateChunk(chunkX, chunkZ);
|
||||||
// Initialize
|
// Initialize
|
||||||
chunk.init(this, chunkX, chunkZ);
|
chunk.init(this, chunkX, chunkZ);
|
||||||
|
|
||||||
IChunk newChunk = filter.applyChunk(chunk, region);
|
T newChunk = filter.applyChunk(chunk, region);
|
||||||
if (newChunk != null) {
|
if (newChunk != null) {
|
||||||
chunk = newChunk;
|
chunk = newChunk;
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
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)
|
* 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
|
* @param z
|
||||||
* @return IChunk
|
* @return IChunk
|
||||||
*/
|
*/
|
||||||
IChunk getOrCreateChunk(int chunkX, int chunkZ);
|
T getOrCreateChunk(int chunkX, int chunkZ);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean setBlock(int x, int y, int z, BlockStateHolder state) {
|
default boolean setBlock(int x, int y, int z, BlockStateHolder state) {
|
||||||
|
@ -80,7 +80,7 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getArray(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
||||||
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
||||||
if (nullRowY instanceof MemBlockSet.RowY) {
|
if (nullRowY instanceof MemBlockSet.RowY) {
|
||||||
|
@ -2,16 +2,9 @@ package com.boydti.fawe.beta.implementation.blocks;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.IBlocks;
|
import com.boydti.fawe.beta.IBlocks;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
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.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class CharBlocks implements IBlocks {
|
public abstract class CharBlocks implements IBlocks {
|
||||||
|
|
||||||
public static final Section FULL = new Section() {
|
public static final Section FULL = new Section() {
|
||||||
@ -26,9 +19,9 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
blocks.sections[layer] = FULL;
|
blocks.sections[layer] = FULL;
|
||||||
char[] arr = blocks.blocks[layer];
|
char[] arr = blocks.blocks[layer];
|
||||||
if (arr == null) {
|
if (arr == null) {
|
||||||
arr = blocks.blocks[layer] = blocks.load(layer);
|
arr = blocks.blocks[layer] = blocks.update(layer, null);
|
||||||
} else {
|
} else {
|
||||||
blocks.blocks[layer] = blocks.load(layer, arr);
|
blocks.blocks[layer] = blocks.update(layer, arr);
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@ -74,11 +67,10 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
sections[layer] = EMPTY;
|
sections[layer] = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] load(int layer) {
|
public char[] update(int layer, char[] data) {
|
||||||
|
if (data == null) {
|
||||||
return new char[4096];
|
return new char[4096];
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] load(int layer, char[] data) {
|
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
}
|
}
|
||||||
@ -91,7 +83,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getArray(int layer) {
|
public char[] load(int layer) {
|
||||||
return sections[layer].get(this, layer);
|
return sections[layer].get(this, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ public interface DelegateChunkSet extends IChunkSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default char[] getArray(int layer) {
|
default char[] load(int layer) {
|
||||||
return getParent().getArray(layer);
|
return getParent().load(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.beta.IBlocks;
|
import com.boydti.fawe.beta.IBlocks;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.boydti.fawe.util.MathMan;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
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) {
|
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
|
||||||
for (int layer = 0; layer < 16; layer++) {
|
for (int layer = 0; layer < 16; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
char[] arr = set.getArray(layer);
|
char[] arr = set.load(layer);
|
||||||
int by = layer << 4;
|
int by = layer << 4;
|
||||||
for (int y = 0, i = 0; y < 16; y++) {
|
for (int y = 0, i = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
@ -160,11 +159,6 @@ public class FallbackChunkGet implements IChunkGet {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public char[] getArray(int layer) {
|
|
||||||
return new char[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlocks reset() {
|
public IBlocks reset() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -76,11 +76,6 @@ public enum NullChunkGet implements IChunkGet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public char[] getArray(int layer) {
|
|
||||||
return new char[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlocks reset() {
|
public IBlocks reset() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
package com.boydti.fawe.beta.implementation.chunk;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
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.implementation.filter.block.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.Filter;
|
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.IChunk;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
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
|
* 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);
|
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
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
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
|
@Override
|
||||||
@ -259,10 +283,10 @@ public class ChunkHolder<T extends Future<T>> implements IChunk {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||||
// block.flood(get, set, mask, block, );
|
//// block.flood(get, set, mask, block, );
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
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);
|
return chunkExisting != null && chunkExisting.hasSection(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public char[] getArray(int layer) {
|
|
||||||
return delegate.get(this).getArray(layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
|
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) {
|
||||||
final IChunkGet get = getOrCreateGet();
|
final IChunkGet get = getOrCreateGet();
|
||||||
|
@ -2,11 +2,17 @@ package com.boydti.fawe.beta.implementation.chunk;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IDelegateChunk;
|
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
|
* Implementation of IDelegateChunk
|
||||||
*/
|
*/
|
||||||
public class DelegateChunk<T extends IChunk> implements IDelegateChunk<T> {
|
public class DelegateChunk<T extends IQueueChunk> implements IDelegateChunk<T> {
|
||||||
|
|
||||||
private T parent;
|
private T parent;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
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 com.boydti.fawe.beta.IQueueExtent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,7 +11,7 @@ public class FinalizedChunk extends DelegateChunk {
|
|||||||
|
|
||||||
private final IQueueExtent queueExtent;
|
private final IQueueExtent queueExtent;
|
||||||
|
|
||||||
public FinalizedChunk(IChunk parent, IQueueExtent queueExtent) {
|
public FinalizedChunk(IQueueChunk parent, IQueueExtent queueExtent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.queueExtent = queueExtent;
|
this.queueExtent = queueExtent;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
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.implementation.filter.block.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.FilterBlockMask;
|
import com.boydti.fawe.beta.FilterBlockMask;
|
||||||
@ -23,7 +24,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public enum NullChunk implements IChunk {
|
public enum NullChunk implements IQueueChunk {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,10 +55,10 @@ public enum NullChunk implements IChunk {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
@ -69,11 +70,36 @@ public enum NullChunk implements IChunk {
|
|||||||
return false;
|
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
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlocks(int layer, char[] data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiomeType(int x, int z) {
|
public BiomeType getBiomeType(int x, int z) {
|
||||||
return null;
|
return null;
|
||||||
@ -84,11 +110,6 @@ public enum NullChunk implements IChunk {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public char[] getArray(int layer) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return BlockTypes.__RESERVED__.getDefaultState();
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.chunk;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IDelegateChunk;
|
import com.boydti.fawe.beta.IDelegateChunk;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
|
|
||||||
@ -14,14 +15,14 @@ public abstract class ReferenceChunk implements IDelegateChunk {
|
|||||||
|
|
||||||
private final Reference<FinalizedChunk> reference;
|
private final Reference<FinalizedChunk> reference;
|
||||||
|
|
||||||
public ReferenceChunk(IChunk parent, IQueueExtent queueExtent) {
|
public ReferenceChunk(IQueueChunk parent, IQueueExtent queueExtent) {
|
||||||
this.reference = toReference(new FinalizedChunk(parent, queueExtent));
|
this.reference = toReference(new FinalizedChunk(parent, queueExtent));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Reference<FinalizedChunk> toReference(FinalizedChunk parent);
|
protected abstract Reference<FinalizedChunk> toReference(FinalizedChunk parent);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunk getParent() {
|
public IQueueChunk getParent() {
|
||||||
final FinalizedChunk finalized = reference.get();
|
final FinalizedChunk finalized = reference.get();
|
||||||
return finalized != null ? finalized.getParent() : null;
|
return finalized != null ? finalized.getParent() : null;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
package com.boydti.fawe.beta.implementation.chunk;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
@ -10,7 +11,7 @@ import java.lang.ref.SoftReference;
|
|||||||
*/
|
*/
|
||||||
public class SoftChunk extends ReferenceChunk {
|
public class SoftChunk extends ReferenceChunk {
|
||||||
|
|
||||||
public SoftChunk(IChunk parent, IQueueExtent queueExtent) {
|
public SoftChunk(IQueueChunk parent, IQueueExtent queueExtent) {
|
||||||
super(parent, queueExtent);
|
super(parent, queueExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
package com.boydti.fawe.beta.implementation.chunk;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
|
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
@ -11,7 +12,7 @@ import java.lang.ref.WeakReference;
|
|||||||
*/
|
*/
|
||||||
public class WeakChunk extends ReferenceChunk {
|
public class WeakChunk extends ReferenceChunk {
|
||||||
|
|
||||||
public WeakChunk(IChunk parent, IQueueExtent queueExtent) {
|
public WeakChunk(IQueueChunk parent, IQueueExtent queueExtent) {
|
||||||
super(parent, queueExtent);
|
super(parent, queueExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
this.set = iset;
|
this.set = iset;
|
||||||
getArr = get.sections[layer].get(get, layer);
|
getArr = get.sections[layer].get(get, layer);
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
setArr = set.getArray(layer);
|
setArr = set.load(layer);
|
||||||
delegate = FULL;
|
delegate = FULL;
|
||||||
} else {
|
} else {
|
||||||
delegate = NULL;
|
delegate = NULL;
|
||||||
@ -409,7 +409,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
Set delegate
|
Set delegate
|
||||||
*/
|
*/
|
||||||
private SetDelegate initSet() {
|
private SetDelegate initSet() {
|
||||||
setArr = set.getArray(layer);
|
setArr = set.load(layer);
|
||||||
return delegate = FULL;
|
return delegate = FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.beta.IBatchProcessor;
|
|||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.Trimable;
|
import com.boydti.fawe.beta.Trimable;
|
||||||
import com.boydti.fawe.beta.implementation.cache.ChunkCache;
|
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
|
// if (MemUtil.isMemoryFree()) { TODO NOT IMPLEMENTED - optimize this
|
||||||
// return (T) forkJoinPoolSecondary.submit(chunk);
|
// return (T) forkJoinPoolSecondary.submit(chunk);
|
||||||
// }
|
// }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.beta.implementation.queue;
|
package com.boydti.fawe.beta.implementation.queue;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
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.CharFilterBlock;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.IBatchProcessor;
|
import com.boydti.fawe.beta.IBatchProcessor;
|
||||||
@ -34,12 +35,12 @@ import java.util.concurrent.Future;
|
|||||||
* <p>
|
* <p>
|
||||||
* This queue is reusable {@link #init(IChunkCache)}
|
* 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)
|
// // Pool discarded chunks for reuse (can safely be cleared by another thread)
|
||||||
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
|
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
|
||||||
// Chunks currently being queued / worked on
|
// 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<IChunkGet> cacheGet;
|
||||||
private IChunkCache<IChunkSet> cacheSet;
|
private IChunkCache<IChunkSet> cacheSet;
|
||||||
@ -48,7 +49,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
private Thread currentThread;
|
private Thread currentThread;
|
||||||
private ConcurrentLinkedQueue<Future> submissions = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<Future> submissions = new ConcurrentLinkedQueue<>();
|
||||||
// Last access pointers
|
// Last access pointers
|
||||||
private IChunk lastChunk;
|
private IQueueChunk lastChunk;
|
||||||
private long lastPair = Long.MAX_VALUE;
|
private long lastPair = Long.MAX_VALUE;
|
||||||
|
|
||||||
private boolean enabledQueue = true;
|
private boolean enabledQueue = true;
|
||||||
@ -135,7 +136,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Future<T>> T submit(IChunk<T> chunk) {
|
public <V extends Future<V>> V submit(IQueueChunk chunk) {
|
||||||
if (lastChunk == chunk) {
|
if (lastChunk == chunk) {
|
||||||
lastPair = Long.MAX_VALUE;
|
lastPair = Long.MAX_VALUE;
|
||||||
lastChunk = null;
|
lastChunk = null;
|
||||||
@ -152,18 +153,18 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private <T extends Future<T>> T submitUnchecked(IChunk<T> chunk) {
|
private <V extends Future<V>> V submitUnchecked(IQueueChunk chunk) {
|
||||||
if (chunk.isEmpty()) {
|
if (chunk.isEmpty()) {
|
||||||
chunk.recycle();
|
chunk.recycle();
|
||||||
Future result = Futures.immediateFuture(null);
|
Future result = Futures.immediateFuture(null);
|
||||||
return (T) result;
|
return (V) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
return chunk.call();
|
return (V) chunk.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Fawe.get().getQueueHandler().submit(chunk);
|
return (V) Fawe.get().getQueueHandler().submit(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -195,14 +196,14 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
* @param Z
|
* @param Z
|
||||||
* @return IChunk
|
* @return IChunk
|
||||||
*/
|
*/
|
||||||
private IChunk poolOrCreate(int X, int Z) {
|
private ChunkHolder poolOrCreate(int X, int Z) {
|
||||||
IChunk next = create(false);
|
ChunkHolder next = create(false);
|
||||||
next.init(this, X, Z);
|
next.init(this, X, Z);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
final long pair = (long) x << 32 | z & 0xffffffffL;
|
||||||
if (pair == lastPair) {
|
if (pair == lastPair) {
|
||||||
return lastChunk;
|
return lastChunk;
|
||||||
@ -213,7 +214,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
return NullChunk.INSTANCE;
|
return NullChunk.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IChunk chunk = chunks.get(pair);
|
IQueueChunk chunk = chunks.get(pair);
|
||||||
if (chunk instanceof ReferenceChunk) {
|
if (chunk instanceof ReferenceChunk) {
|
||||||
chunk = ((ReferenceChunk) chunk).getParent();
|
chunk = ((ReferenceChunk) chunk).getParent();
|
||||||
}
|
}
|
||||||
@ -251,7 +252,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunk create(boolean isFull) {
|
public ChunkHolder create(boolean isFull) {
|
||||||
return ChunkHolder.newInstance();
|
return ChunkHolder.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +300,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
public synchronized void flush() {
|
public synchronized void flush() {
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
if (MemUtil.isMemoryLimited()) {
|
if (MemUtil.isMemoryLimited()) {
|
||||||
for (IChunk chunk : chunks.values()) {
|
for (IQueueChunk chunk : chunks.values()) {
|
||||||
final Future future = submitUnchecked(chunk);
|
final Future future = submitUnchecked(chunk);
|
||||||
if (future != null && !future.isDone()) {
|
if (future != null && !future.isDone()) {
|
||||||
pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true);
|
pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true);
|
||||||
@ -307,7 +308,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (IChunk chunk : chunks.values()) {
|
for (IQueueChunk chunk : chunks.values()) {
|
||||||
final Future future = submitUnchecked(chunk);
|
final Future future = submitUnchecked(chunk);
|
||||||
if (future != null && !future.isDone()) {
|
if (future != null && !future.isDone()) {
|
||||||
submissions.add(future);
|
submissions.add(future);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil;
|
package com.boydti.fawe.jnbt.anvil;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
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.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.StreamDelegate;
|
||||||
import com.boydti.fawe.jnbt.streamer.ValueReader;
|
import com.boydti.fawe.jnbt.streamer.ValueReader;
|
||||||
import com.boydti.fawe.object.collection.BitArray4096;
|
import com.boydti.fawe.object.collection.BitArray4096;
|
||||||
@ -15,9 +19,11 @@ import com.sk89q.jnbt.NBTInputStream;
|
|||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
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.BlockID;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
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.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -34,12 +41,13 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
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 final boolean[] hasSections = new boolean[16];
|
||||||
|
|
||||||
public boolean hasBiomes = false;
|
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];
|
public final char[] blocks = new char[65536];
|
||||||
|
|
||||||
@ -92,6 +100,13 @@ public class MCAChunk implements IChunkSet {
|
|||||||
read(nis, readPos);
|
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 {
|
public void read(NBTInputStream nis, boolean readPos) throws IOException {
|
||||||
StreamDelegate root = createDelegate(nis, readPos);
|
StreamDelegate root = createDelegate(nis, readPos);
|
||||||
nis.readNamedTagLazy(root);
|
nis.readNamedTagLazy(root);
|
||||||
@ -153,7 +168,7 @@ public class MCAChunk implements IChunkSet {
|
|||||||
CompoundTag entity = FaweCache.IMP.asTag(value);
|
CompoundTag entity = FaweCache.IMP.asTag(value);
|
||||||
entities.put(entity.getUUID(), entity);
|
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;
|
return root;
|
||||||
}
|
}
|
||||||
@ -177,11 +192,11 @@ public class MCAChunk implements IChunkSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunkSet reset() {
|
public MCAChunk reset() {
|
||||||
return this.reset(true);
|
return this.reset(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IChunkSet reset(boolean full) {
|
public MCAChunk reset(boolean full) {
|
||||||
if (!tiles.isEmpty()) {
|
if (!tiles.isEmpty()) {
|
||||||
tiles.clear();
|
tiles.clear();
|
||||||
}
|
}
|
||||||
@ -226,7 +241,12 @@ public class MCAChunk implements IChunkSet {
|
|||||||
out.writeNamedTag("InhabitedTime", inhabitedTime);
|
out.writeNamedTag("InhabitedTime", inhabitedTime);
|
||||||
out.writeNamedTag("LastUpdate", lastUpdate);
|
out.writeNamedTag("LastUpdate", lastUpdate);
|
||||||
if (hasBiomes) {
|
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;
|
int len = 0;
|
||||||
for (boolean hasSection : hasSections) {
|
for (boolean hasSection : hasSections) {
|
||||||
@ -424,16 +444,12 @@ public class MCAChunk implements IChunkSet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiomeType(int x, int z) {
|
public BiomeType getBiomeType(int x, int z) {
|
||||||
return BiomeTypes.get(this.biomes[(z << 4) | x] & 0xFF);
|
return this.biomes[(z << 4) | x];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType[] getBiomes() {
|
public BiomeType[] getBiomes() {
|
||||||
BiomeType[] tmp = new BiomeType[256];
|
return this.biomes;
|
||||||
for (int i = 0; i < 256; i++) {
|
|
||||||
tmp[i] = BiomeTypes.get(this.biomes[i] & 0xFF);
|
|
||||||
}
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -444,7 +460,7 @@ public class MCAChunk implements IChunkSet {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
setModified();
|
setModified();
|
||||||
biomes[x + (z << 4)] = (byte) biome.getInternalId();
|
biomes[x + (z << 4)] = biome;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,6 +495,16 @@ public class MCAChunk implements IChunkSet {
|
|||||||
return BlockState.getFromOrdinal(ordinal);
|
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() {
|
public Set<UUID> getEntityRemoves() {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
@ -499,7 +525,7 @@ public class MCAChunk implements IChunkSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getArray(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
||||||
int offset = layer << 12;
|
int offset = layer << 12;
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
@ -513,7 +539,7 @@ public class MCAChunk implements IChunkSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBiome(BiomeType biome) {
|
public void setBiome(BiomeType biome) {
|
||||||
Arrays.fill(biomes, (byte) biome.getInternalId());
|
Arrays.fill(this.biomes, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEntity(UUID uuid) {
|
public void removeEntity(UUID uuid) {
|
||||||
@ -524,4 +550,34 @@ public class MCAChunk implements IChunkSet {
|
|||||||
public boolean trim(boolean aggressive) {
|
public boolean trim(boolean aggressive) {
|
||||||
return isEmpty();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1584,7 +1584,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int index;
|
int index;
|
||||||
int maxY = 0;
|
int maxY = 0;
|
||||||
int minY = Integer.MAX_VALUE;
|
int minY = Integer.MAX_VALUE;
|
||||||
byte[] heightMap = chunk.biomes;
|
byte[] heightMap = FaweCache.IMP.BYTE_BUFFER_256.get();
|
||||||
int globalIndex;
|
int globalIndex;
|
||||||
for (int z = csz; z <= cez; z++) {
|
for (int z = csz; z <= cez; z++) {
|
||||||
globalIndex = z * getWidth() + csx;
|
globalIndex = z * getWidth() + csx;
|
||||||
@ -1717,7 +1717,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 256; i++) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,11 +173,11 @@ public abstract class FaweChangeSet implements ChangeSet, IBatchProcessor {
|
|||||||
for (int layer = 0; layer < 16; layer++) {
|
for (int layer = 0; layer < 16; layer++) {
|
||||||
if (!set.hasSection(layer)) continue;
|
if (!set.hasSection(layer)) continue;
|
||||||
// add each block and tile
|
// add each block and tile
|
||||||
char[] blocksGet = get.getArray(layer);
|
char[] blocksGet = get.load(layer);
|
||||||
if (blocksGet == null) {
|
if (blocksGet == null) {
|
||||||
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
|
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
|
||||||
}
|
}
|
||||||
char[] blocksSet = set.getArray(layer);
|
char[] blocksSet = set.load(layer);
|
||||||
|
|
||||||
int by = layer << 4;
|
int by = layer << 4;
|
||||||
for (int y = 0, index = 0; y < 16; y++) {
|
for (int y = 0, index = 0; y < 16; y++) {
|
||||||
|
@ -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 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 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);
|
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
|
||||||
|
|
||||||
Clipboard holder = new BlockArrayClipboard(region, clipboard);
|
Clipboard holder = new BlockArrayClipboard(region, clipboard);
|
||||||
|
@ -630,7 +630,6 @@ public final class PlatformCommandManager {
|
|||||||
Command cmd = optional.get();
|
Command cmd = optional.get();
|
||||||
CommandQueuedCondition queued = cmd.getCondition().as(CommandQueuedCondition.class).orElse(null);
|
CommandQueuedCondition queued = cmd.getCondition().as(CommandQueuedCondition.class).orElse(null);
|
||||||
if (queued != null && !queued.isQueued()) {
|
if (queued != null && !queued.isQueued()) {
|
||||||
System.out.println("Not queued");
|
|
||||||
handleCommandOnCurrentThread(event);
|
handleCommandOnCurrentThread(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
int indexY, index;
|
int indexY, index;
|
||||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
char[] arr = set.getArray(layer);
|
char[] arr = set.load(layer);
|
||||||
if (trimX || trimZ) {
|
if (trimX || trimZ) {
|
||||||
indexY = 0;
|
indexY = 0;
|
||||||
for (int y = 0; y < 16; y++, indexY += 256) {
|
for (int y = 0; y < 16; y++, indexY += 256) {
|
||||||
|
@ -294,7 +294,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
} else {
|
} else {
|
||||||
boolean changed = true;
|
boolean changed = true;
|
||||||
processExtra = true;
|
processExtra = true;
|
||||||
char[] arr = set.getArray(layer);
|
char[] arr = set.load(layer);
|
||||||
for (int y = 0, index = 0; y < 16; y++) {
|
for (int y = 0, index = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 0; x < 16; x++, index++) {
|
for (int x = 0; x < 16; x++, index++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user