mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Begin to implement extended world heights:
- Implemented in Bukkit module (and where required in Core module)
This commit is contained in:
@ -58,6 +58,21 @@ public interface World<T> {
|
||||
*/
|
||||
@NonNull String getName();
|
||||
|
||||
/**
|
||||
* Get the min world height. Inclusive.
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
int getMinHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Get the max world height. Exclusive.
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
int getMaxHeight();
|
||||
|
||||
class NullWorld<T> implements World<T> {
|
||||
|
||||
private NullWorld() {
|
||||
@ -74,6 +89,16 @@ public interface World<T> {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return obj instanceof NullWorld;
|
||||
|
@ -42,6 +42,7 @@ public class LocalChunk {
|
||||
private final QueueCoordinator parent;
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final int minSection;
|
||||
|
||||
private final BaseBlock[][] baseblocks;
|
||||
private final BiomeType[][] biomes;
|
||||
@ -52,8 +53,10 @@ public class LocalChunk {
|
||||
this.parent = parent;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
baseblocks = new BaseBlock[16][];
|
||||
biomes = new BiomeType[16][];
|
||||
this.minSection = parent.getWorld() != null ? (parent.getWorld().getMinY() >> 4) : 0;
|
||||
int sections = parent.getWorld() != null ? (parent.getWorld().getMaxY() >> 4) - minSection : 16;
|
||||
baseblocks = new BaseBlock[sections][];
|
||||
biomes = new BiomeType[sections][];
|
||||
}
|
||||
|
||||
public @NonNull QueueCoordinator getParent() {
|
||||
@ -68,6 +71,13 @@ public class LocalChunk {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum layer position stored (usually -4 or 0).
|
||||
*/
|
||||
public int getMinSection() {
|
||||
return this.minSection;
|
||||
}
|
||||
|
||||
public @NonNull BaseBlock[][] getBaseblocks() {
|
||||
return this.baseblocks;
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
*/
|
||||
public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
||||
|
||||
private final Location min;
|
||||
private final Location max;
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
@ -53,6 +55,8 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
||||
|
||||
public ScopedQueueCoordinator(@Nullable QueueCoordinator parent, @NonNull Location min, @NonNull Location max) {
|
||||
super(parent);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.minX = min.getX();
|
||||
this.minY = min.getY();
|
||||
this.minZ = min.getZ();
|
||||
@ -112,11 +116,11 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
||||
}
|
||||
|
||||
public @NonNull Location getMin() {
|
||||
return Location.at(this.getWorld().getName(), this.minX, this.minY, this.minZ);
|
||||
return min;
|
||||
}
|
||||
|
||||
public @NonNull Location getMax() {
|
||||
return Location.at(this.getWorld().getName(), this.maxX, this.maxY, this.maxZ);
|
||||
return max;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ public class ChunkUtil {
|
||||
* - Used for efficient world generation<br>
|
||||
*/
|
||||
private static final short[] x_loc;
|
||||
private static final short[][] y_loc;
|
||||
private static final short[] y_loc;
|
||||
private static final short[] z_loc;
|
||||
private static final short[][][] CACHE_J;
|
||||
|
||||
static {
|
||||
x_loc = new short[4096];
|
||||
y_loc = new short[16][4096];
|
||||
y_loc = new short[4096];
|
||||
z_loc = new short[4096];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int i4 = i << 4;
|
||||
@ -55,14 +55,14 @@ public class ChunkUtil {
|
||||
int z1 = a >> 4;
|
||||
int x1 = a - (z1 << 4);
|
||||
x_loc[j] = (short) x1;
|
||||
y_loc[i][j] = (short) y;
|
||||
y_loc[j] = (short) y;
|
||||
z_loc[j] = (short) z1;
|
||||
}
|
||||
}
|
||||
CACHE_J = new short[256][16][16];
|
||||
CACHE_J = new short[16][16][16];
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
short j = (short) ((y & 0xF) << 8 | z << 4 | x);
|
||||
CACHE_J[y][x][z] = j;
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class ChunkUtil {
|
||||
* @return J value for xyz position in Array[4096].
|
||||
*/
|
||||
public static int getJ(int x, int y, int z) {
|
||||
return CACHE_J[y][x][z];
|
||||
return CACHE_J[y & 15][x & 15][z & 15];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,14 +97,14 @@ public class ChunkUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the y coordinate for specific I and J values for a Chunk 16x16x16x16 layerxyz Array[16][4096].
|
||||
* Gets the y coordinate for specific I and J values for a Chunk 16x16x16x16 layerxyz Array[N][4096].
|
||||
*
|
||||
* @param i Relative layer of the position in the layerxyz Array[16][4096].
|
||||
* @param i Relative layer of the position in the layerxyz Array[16][4096]. May be negative.
|
||||
* @param j Position in the xyz Array[4096].
|
||||
* @return x coordinate within the chunk
|
||||
*/
|
||||
public static int getY(int i, int j) {
|
||||
return y_loc[i][j];
|
||||
return (i << 4) + y_loc[j];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user