*Actually rename section index everywhere

Dieser Commit ist enthalten in:
dordsor21 2021-09-12 11:40:36 +01:00
Ursprung ce915fe04d
Commit 3ea3bd2a78
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
8 geänderte Dateien mit 87 neuen und 87 gelöschten Zeilen

Datei anzeigen

@ -25,17 +25,17 @@ public class Flood {
private int chunkYLayer;
private int chunkZ;
private final ConcurrentLinkedQueue<int[]> queuePool = new ConcurrentLinkedQueue<>();
private final int minSectionIndex;
private final int maxSectionIndex;
private final int minSectionPosition;
private final int maxSectionPosition;
private final int sectionCount;
public Flood(int maxBranch, int maxDepth, Direction[] directions, int minSectionIndex, int maxSectionIndex) {
public Flood(int maxBranch, int maxDepth, Direction[] directions, int minSectionPosition, int maxSectionPosition) {
this.maxBranch = maxBranch;
this.maxDepth = maxDepth;
this.directions = directions;
this.minSectionIndex = minSectionIndex;
this.maxSectionIndex = maxSectionIndex;
this.sectionCount = maxSectionIndex - minSectionIndex + 1;
this.minSectionPosition = minSectionPosition;
this.maxSectionPosition = maxSectionPosition;
this.sectionCount = maxSectionPosition - minSectionPosition + 1;
this.queues = new int[27][];
this.visits = new long[27][];
@ -70,7 +70,7 @@ public class Flood {
int chunkX = x >> 4;
int chunkZ = z >> 4;
long pair = MathMan.pairInt(chunkX, chunkZ);
int layer = (y >> 4) - minSectionIndex;
int layer = (y >> 4) - minSectionPosition;
int[] section = getOrCreateQueue(pair, layer);
int val = (x & 15) + ((z & 15) << 4) + ((y & 15) << 8) + (depth << 12);
push(section, val);
@ -160,7 +160,7 @@ public class Flood {
if (visit == null || queue == null) {
long pair = MathMan.pairInt(this.chunkX + nextX, this.chunkZ + nextZ);
int layer = this.chunkYLayer + nextY;
if (layer < minSectionIndex || layer > maxSectionIndex) {
if (layer < minSectionPosition || layer > maxSectionPosition) {
continue;
}
queues[sectionIndex] = queue = getOrCreateQueue(pair, layer);

Datei anzeigen

@ -20,21 +20,21 @@ public class BitSetBlocks implements IChunkSet {
private final MemBlockSet.RowZ row;
private final BlockState blockState;
private final int minSectionIndex;
private final int maxSectionIndex;
private final int minSectionPosition;
private final int maxSectionPosition;
private final int layers;
public BitSetBlocks(BlockState blockState, int minSectionIndex, int maxSectionIndex) {
this.row = new MemBlockSet.RowZ(minSectionIndex, maxSectionIndex);
public BitSetBlocks(BlockState blockState, int minSectionPosition, int maxSectionPosition) {
this.row = new MemBlockSet.RowZ(minSectionPosition, maxSectionPosition);
this.blockState = blockState;
this.minSectionIndex = minSectionIndex;
this.maxSectionIndex = maxSectionIndex;
this.layers = maxSectionIndex - minSectionIndex + 1;
this.minSectionPosition = minSectionPosition;
this.maxSectionPosition = maxSectionPosition;
this.layers = maxSectionPosition - minSectionPosition + 1;
}
@Override
public boolean hasSection(int layer) {
layer -= minSectionIndex;
layer -= minSectionPosition;
return row.rows[layer] != MemBlockSet.NULL_ROW_Y;
}
@ -46,21 +46,21 @@ public class BitSetBlocks implements IChunkSet {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T holder) {
y -= minSectionIndex << 4;
row.set(null, x, y, z, minSectionIndex, maxSectionIndex);
y -= minSectionPosition << 4;
row.set(null, x, y, z, minSectionPosition, maxSectionPosition);
return true;
}
@Override
public void setBlocks(int layer, char[] data) {
layer -= minSectionIndex;
layer -= minSectionPosition;
row.reset(layer);
int by = layer << 4;
for (int y = 0, index = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++, index++) {
if (data[index] != 0) {
row.set(null, x, by + y, z, minSectionIndex, maxSectionIndex);
row.set(null, x, by + y, z, minSectionPosition, maxSectionPosition);
}
}
}
@ -123,7 +123,7 @@ public class BitSetBlocks implements IChunkSet {
@Override
public char[] load(int layer) {
layer -= minSectionIndex;
layer -= minSectionPosition;
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
MemBlockSet.IRow nullRowY = row.getRow(layer);
if (nullRowY instanceof MemBlockSet.RowY) {
@ -211,12 +211,12 @@ public class BitSetBlocks implements IChunkSet {
@Override
public int getMaxSectionPosition() {
return minSectionIndex;
return minSectionPosition;
}
@Override
public int getMinSectionPosition() {
return maxSectionIndex;
return maxSectionPosition;
}
@Override

Datei anzeigen

@ -13,8 +13,8 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
/**
* New instance given the min/max section indices
*/
public CharGetBlocks(final int minSectionIndex, final int maxSectionIndex) {
super(minSectionIndex, maxSectionIndex);
public CharGetBlocks(final int minSectionPosition, final int maxSectionPosition) {
super(minSectionPosition, maxSectionPosition);
}
@Override
@ -43,7 +43,7 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
@Override
public synchronized boolean trim(boolean aggressive, int layer) {
layer -= minSectionIndex;
layer -= minSectionPosition;
sections[layer] = empty;
blocks[layer] = null;
return true;

Datei anzeigen

@ -60,10 +60,10 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public BiomeType getBiomeType(int x, int y, int z) {
if (biomes == null || (y >> 4) < minSectionIndex || (y >> 4) > maxSectionIndex) {
if (biomes == null || (y >> 4) < minSectionPosition || (y >> 4) > maxSectionPosition) {
return null;
}
y -= minSectionIndex << 4;
y -= minSectionPosition << 4;
return biomes[(y >> 2) << 4 | (z >> 2) << 2 | x >> 2];
}
@ -95,7 +95,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
updateSectionIndexRange(y >> 4);
y -= minSectionIndex << 4;
y -= minSectionPosition << 4;
if (biomes == null) {
biomes = new BiomeType[64 * sectionCount];
}
@ -114,7 +114,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public void setBlocks(int layer, char[] data) {
updateSectionIndexRange(layer);
layer -= minSectionIndex;
layer -= minSectionPosition;
this.blocks[layer] = data;
this.sections[layer] = data == null ? empty : FULL;
}
@ -141,7 +141,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
if (light == null) {
light = new char[sectionCount][];
}
final int layer = (y >> 4) - minSectionIndex;
final int layer = (y >> 4) - minSectionPosition;
if (light[layer] == null) {
char[] c = new char[4096];
Arrays.fill(c, (char) 16);
@ -157,7 +157,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
if (skyLight == null) {
skyLight = new char[sectionCount][];
}
final int layer = (y >> 4) - minSectionIndex;
final int layer = (y >> 4) - minSectionPosition;
if (skyLight[layer] == null) {
char[] c = new char[4096];
Arrays.fill(c, (char) 16);
@ -181,7 +181,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
if (light == null) {
light = new char[sectionCount][];
}
layer -= minSectionIndex;
layer -= minSectionPosition;
light[layer] = toSet;
}
@ -191,7 +191,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
if (skyLight == null) {
skyLight = new char[sectionCount][];
}
layer -= minSectionIndex;
layer -= minSectionPosition;
skyLight[layer] = toSet;
}
@ -208,7 +208,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public void removeSectionLighting(int layer, boolean sky) {
updateSectionIndexRange(layer);
layer -= minSectionIndex;
layer -= minSectionPosition;
if (light == null) {
light = new char[sectionCount][];
}
@ -230,7 +230,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public void setFullBright(int layer) {
updateSectionIndexRange(layer);
layer -= minSectionIndex;
layer -= minSectionPosition;
if (light == null) {
light = new char[sectionCount][];
}
@ -293,7 +293,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
if (biomes != null || light != null || skyLight != null) {
return false;
}
return IntStream.range(minSectionIndex, maxSectionIndex + 1).noneMatch(this::hasSection);
return IntStream.range(minSectionPosition, maxSectionPosition + 1).noneMatch(this::hasSection);
}
@Override
@ -308,7 +308,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public boolean hasBiomes(int layer) {
layer -= minSectionIndex;
layer -= minSectionPosition;
if (layer < 0 || layer >= sections.length) {
return false;
}
@ -328,21 +328,21 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
@Override
public int getMaxSectionPosition() {
return maxSectionIndex;
return maxSectionPosition;
}
@Override
public int getMinSectionPosition() {
return minSectionIndex;
return minSectionPosition;
}
// Checks and updates the various section arrays against the new layer index
private void updateSectionIndexRange(int layer) {
if (layer >= minSectionIndex && layer <= maxSectionIndex) {
if (layer >= minSectionPosition && layer <= maxSectionPosition) {
return;
}
if (layer < minSectionIndex) {
int diff = minSectionIndex - layer;
if (layer < minSectionPosition) {
int diff = minSectionPosition - layer;
sectionCount += diff;
char[][] tmpBlocks = new char[sectionCount][];
Section[] tmpSections = new Section[sectionCount];
@ -353,7 +353,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
blocks = tmpBlocks;
sections = tmpSections;
minSectionIndex = layer;
minSectionPosition = layer;
if (biomes != null) {
BiomeType[] tmpBiomes = new BiomeType[sectionCount * 64];
System.arraycopy(biomes, 0, tmpBiomes, 64 * diff, biomes.length);
@ -370,7 +370,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
skyLight = tmplight;
}
} else {
int diff = layer - maxSectionIndex;
int diff = layer - maxSectionPosition;
sectionCount += diff;
char[][] tmpBlocks = new char[sectionCount][];
Section[] tmpSections = new Section[sectionCount];
@ -381,7 +381,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
blocks = tmpBlocks;
sections = tmpSections;
maxSectionIndex = layer;
maxSectionPosition = layer;
if (biomes != null) {
BiomeType[] tmpBiomes = new BiomeType[sectionCount * 64];
System.arraycopy(biomes, 0, tmpBiomes, 0, biomes.length);

Datei anzeigen

@ -82,7 +82,7 @@ public final class NullChunkGet implements IChunkGet {
}
@Override
public void setSkyLightingToGet(char[][] lighting, int minSectionIndex, int maxSectionIndex) {
public void setSkyLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) {
}
@Override

Datei anzeigen

@ -165,12 +165,12 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
}
@Override
public void setLightingToGet(char[][] lighting, int minSectionIndex, int maxSectionIndex) {
public void setLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) {
delegate.setLightingToGet(this, lighting);
}
@Override
public void setSkyLightingToGet(char[][] lighting, int minSectionIndex, int maxSectionIndex) {
public void setSkyLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) {
delegate.setSkyLightingToGet(this, lighting);
}

Datei anzeigen

@ -187,11 +187,11 @@ public final class NullChunk implements IQueueChunk {
}
@Override
public void setLightingToGet(char[][] lighting, int minSectionIndex, int maxSectionIndex) {
public void setLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) {
}
@Override
public void setSkyLightingToGet(char[][] lighting, int minSectionIndex, int maxSectionIndex) {
public void setSkyLightingToGet(char[][] lighting, int minSectionPosition, int maxSectionPosition) {
}
@Override

Datei anzeigen

@ -28,17 +28,17 @@ public final class MemBlockSet extends BlockSet {
public static final IRow NULL_ROW_Y = new NullRowY();
public final IRow[] rows;
public final MutableBlockVector3 mutable;
private final int minSectionIndex;
private final int maxSectionIndex;
private final int minSectionPosition;
private final int maxSectionPosition;
public MemBlockSet(int size, int offsetX, int offsetZ, int minSectionIndex, int maxSectionIndex) {
public MemBlockSet(int size, int offsetX, int offsetZ, int minSectionPosition, int maxSectionPosition) {
super(offsetX, offsetZ);
this.rows = new IRow[size];
for (int i = 0; i < size; i++) {
rows[i] = NULL_ROW_X;
}
this.minSectionIndex = minSectionIndex;
this.maxSectionIndex = maxSectionIndex;
this.minSectionPosition = minSectionPosition;
this.maxSectionPosition = maxSectionPosition;
this.mutable = new MutableBlockVector3();
}
@ -53,14 +53,14 @@ public final class MemBlockSet extends BlockSet {
public boolean add(int x, int y, int z) {
x -= getBlockOffsetX();
z -= getBlockOffsetZ();
return rows[x >> 4].add(this.rows, x, y, z - getBlockOffsetZ(), minSectionIndex, maxSectionIndex);
return rows[x >> 4].add(this.rows, x, y, z - getBlockOffsetZ(), minSectionPosition, maxSectionPosition);
}
@Override
public void set(int x, int y, int z) {
x -= getBlockOffsetX();
z -= getBlockOffsetZ();
rows[x >> 4].set(this.rows, x, y, z - getBlockOffsetZ(), minSectionIndex, maxSectionIndex);
rows[x >> 4].set(this.rows, x, y, z - getBlockOffsetZ(), minSectionPosition, maxSectionPosition);
}
@Override
@ -234,7 +234,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public BlockVector3 next() {
mutable.setComponents(
setX + getBlockOffsetX(), setY - (minSectionIndex << 4), setZ + getBlockOffsetX());
setX + getBlockOffsetX(), setY - (minSectionPosition << 4), setZ + getBlockOffsetX());
init();
return mutable;
}
@ -282,7 +282,7 @@ public final class MemBlockSet extends BlockSet {
if (rowx instanceof RowX) {
IRow rowz = ((RowX) rowx).rows[other.getZ()];
if (rowz instanceof RowZ) {
return ((RowZ) rowz).rows[other.getY() - (minSectionIndex << 4) - getChunkOffsetZ()] instanceof RowY;
return ((RowZ) rowz).rows[other.getY() - (minSectionPosition << 4) - getChunkOffsetZ()] instanceof RowY;
}
}
}
@ -293,7 +293,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public int getMinimumY() {
int maxY = maxSectionIndex;
int maxY = maxSectionPosition;
int maxy = 16;
int by = Integer.MAX_VALUE;
for (IRow nullRowX : rows) {
@ -357,7 +357,7 @@ public final class MemBlockSet extends BlockSet {
}
RowZ rowz = (RowZ) nullRowZ;
outer:
for (int Y = maxSectionIndex; Y >= maxY; Y--) {
for (int Y = maxSectionPosition; Y >= maxY; Y--) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) {
continue;
@ -376,8 +376,8 @@ public final class MemBlockSet extends BlockSet {
maxy = y + 1;
}
by = (Y << 4) + y;
if (by == (maxSectionIndex << 4) + 15) {
return (maxSectionIndex << 4) + 15;
if (by == (maxSectionPosition << 4) + 15) {
return (maxSectionPosition << 4) + 15;
}
break outer;
}
@ -582,7 +582,7 @@ public final class MemBlockSet extends BlockSet {
if (!(nullRowY instanceof RowY)) {
continue;
}
int by = ((Y - minSectionIndex) << 4);
int by = ((Y - minSectionPosition) << 4);
RowY rowY = (RowY) nullRowY;
for (int y = 0, i = 0; y < 16; y++) {
for (int z = 0; z < 16; z += 4, i++) {
@ -817,10 +817,10 @@ public final class MemBlockSet extends BlockSet {
return false;
}
void set(IRow[] rows, int x, int y, int z, int minSectionIndex, int maxSectionIndex);
void set(IRow[] rows, int x, int y, int z, int minSectionPosition, int maxSectionPosition);
default boolean add(IRow[] rows, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
set(rows, x, y, z, minSectionIndex, maxSectionIndex);
default boolean add(IRow[] rows, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
set(rows, x, y, z, minSectionPosition, maxSectionPosition);
return true;
}
@ -837,10 +837,10 @@ public final class MemBlockSet extends BlockSet {
public static final class NullRowX implements IRow {
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
IRow row = new RowX(parent.length);
parent[x >> 4] = row;
row.set(parent, x, y, z, minSectionIndex, maxSectionIndex);
row.set(parent, x, y, z, minSectionPosition, maxSectionPosition);
}
}
@ -848,10 +848,10 @@ public final class MemBlockSet extends BlockSet {
public static final class NullRowZ implements IRow {
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
IRow row = new RowZ(minSectionIndex, maxSectionIndex);
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
IRow row = new RowZ(minSectionPosition, maxSectionPosition);
parent[z >> 4] = row;
row.set(parent, x, y, z, minSectionIndex, maxSectionIndex);
row.set(parent, x, y, z, minSectionPosition, maxSectionPosition);
}
}
@ -859,10 +859,10 @@ public final class MemBlockSet extends BlockSet {
public static final class NullRowY implements IRow {
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
IRow row = new RowY();
parent[y >> 4] = row;
row.set(parent, x, y, z, minSectionIndex, maxSectionIndex);
row.set(parent, x, y, z, minSectionPosition, maxSectionPosition);
}
}
@ -884,13 +884,13 @@ public final class MemBlockSet extends BlockSet {
}
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
this.rows[z >> 4].set(this.rows, x, y, z, minSectionIndex, maxSectionIndex);
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
this.rows[z >> 4].set(this.rows, x, y, z, minSectionPosition, maxSectionPosition);
}
@Override
public boolean add(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
return this.rows[z >> 4].add(this.rows, x, y, z, minSectionIndex, maxSectionIndex);
public boolean add(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
return this.rows[z >> 4].add(this.rows, x, y, z, minSectionPosition, maxSectionPosition);
}
@Override
@ -909,8 +909,8 @@ public final class MemBlockSet extends BlockSet {
public final IRow[] rows;
public RowZ(int minSectionIndex, int maxSectionIndex) {
this.rows = new IRow[maxSectionIndex - minSectionIndex + 1];
public RowZ(int minSectionPosition, int maxSectionPosition) {
this.rows = new IRow[maxSectionPosition - minSectionPosition + 1];
reset();
}
@ -924,13 +924,13 @@ public final class MemBlockSet extends BlockSet {
}
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
this.rows[y >> 4].set(this.rows, x, y, z, minSectionIndex, maxSectionIndex);
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
this.rows[y >> 4].set(this.rows, x, y, z, minSectionPosition, maxSectionPosition);
}
@Override
public boolean add(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
return this.rows[y >> 4].add(this.rows, x, y, z, minSectionIndex, maxSectionIndex);
public boolean add(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
return this.rows[y >> 4].add(this.rows, x, y, z, minSectionPosition, maxSectionPosition);
}
@Override
@ -982,13 +982,13 @@ public final class MemBlockSet extends BlockSet {
}
@Override
public void set(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
public void set(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
int i = ((y & 15) << 8) | ((z & 15) << 4) | (x & 15);
bits[i >> 6] |= (1L << (i & 0x3F));
}
@Override
public boolean add(IRow[] parent, int x, int y, int z, int minSectionIndex, int maxSectionIndex) {
public boolean add(IRow[] parent, int x, int y, int z, int minSectionPosition, int maxSectionPosition) {
int i = ((y & 15) << 8) | ((z & 15) << 4) | (x & 15);
int offset = i >> 6;
long value = bits[offset];