mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Improve notes on getting the stored section range/refactor method name
This commit is contained in:
parent
37998ec598
commit
6cbd9631a0
@ -71,7 +71,7 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||
*/
|
||||
public final IChunkSet filter(IChunk chunk, IChunkGet get, IChunkSet set, Filter filter) {
|
||||
initChunk(chunk.getX(), chunk.getZ());
|
||||
for (int layer = get.getMinSectionIndex(); layer <= get.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
initLayer(get, set, layer);
|
||||
filter(filter);
|
||||
@ -87,7 +87,7 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
|
||||
if (region != null) {
|
||||
region.filter(chunk, filter, this, get, set, full);
|
||||
} else {
|
||||
for (int layer = get.getMinSectionIndex(); layer <= get.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
|
||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class HeightmapProcessor implements IBatchProcessor {
|
||||
int skip = 0;
|
||||
int allSkipped = (1 << TYPES.length) - 1; // lowest types.length bits are set
|
||||
layer:
|
||||
for (int layer = set.getMaxSectionIndex(); layer >= set.getMinSectionIndex(); layer--) {
|
||||
for (int layer = set.getMaxSectionPosition(); layer >= set.getMinSectionPosition() >> 4; layer--) {
|
||||
boolean hasSectionSet = set.hasSection(layer);
|
||||
boolean hasSectionGet = get.hasSection(layer);
|
||||
if (!(hasSectionSet || hasSectionGet)) {
|
||||
@ -94,7 +94,7 @@ public class HeightmapProcessor implements IBatchProcessor {
|
||||
// ignore if that position was already set
|
||||
if (!updated[i][j] && type.includes(block)) {
|
||||
// mc requires + 1, heightmaps are normalized internally
|
||||
heightmaps[i][j] = ((layer - set.getMinSectionIndex()) << 4) + y + 1;
|
||||
heightmaps[i][j] = ((layer - get.getMinSectionPosition()) << 4) + y + 1;
|
||||
updated[i][j] = true; // mark as updated
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ public class RelightProcessor implements IBatchProcessor {
|
||||
} else if (Settings.IMP.LIGHTING.MODE == 1) {
|
||||
byte[] fix = new byte[get.getSectionCount()];
|
||||
boolean relight = false;
|
||||
for (int i = get.getMaxSectionIndex(); i >= get.getMinSectionIndex(); i--) {
|
||||
for (int i = get.getMaxSectionPosition(); i >= get.getMinSectionPosition(); i--) {
|
||||
if (!set.hasSection(i)) {
|
||||
// Array index cannot be < 0 so "add" the min
|
||||
fix[i - get.getMinSectionIndex()] = Relighter.SkipReason.AIR;
|
||||
fix[i - get.getMinSectionPosition()] = Relighter.SkipReason.AIR;
|
||||
continue;
|
||||
}
|
||||
relight = true;
|
||||
|
@ -157,7 +157,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
addEntityCreate(tag);
|
||||
}
|
||||
}
|
||||
for (int layer = get.getMinSectionIndex(); layer <= get.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
@ -197,7 +197,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
BiomeType[] biomes = set.getBiomes();
|
||||
if (biomes != null) {
|
||||
int index = 0;
|
||||
for (int layer = get.getMinSectionIndex(); layer <= get.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
|
||||
if (!set.hasBiomes(layer)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public interface IBatchProcessor {
|
||||
*/
|
||||
default boolean trimY(IChunkSet set, int minY, int maxY) {
|
||||
int minLayer = (minY - 1) >> 4;
|
||||
for (int layer = set.getMinSectionIndex(); layer <= minLayer; layer++) {
|
||||
for (int layer = set.getMinSectionPosition(); layer <= minLayer; layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
if (layer == minLayer) {
|
||||
char[] arr = set.load(layer);
|
||||
@ -56,7 +56,7 @@ public interface IBatchProcessor {
|
||||
}
|
||||
}
|
||||
int maxLayer = (maxY + 1) >> 4;
|
||||
for (int layer = maxLayer; layer < set.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = maxLayer; layer < set.getMaxSectionPosition(); layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
if (layer == minLayer) {
|
||||
char[] arr = set.load(layer);
|
||||
|
@ -44,7 +44,7 @@ public interface IBlocks extends Trimable {
|
||||
BiomeType getBiomeType(int x, int y, int z);
|
||||
|
||||
default int getBitMask() {
|
||||
return IntStream.range(getMinSectionIndex(), getMaxSectionIndex() + 1).filter(this::hasSection)
|
||||
return IntStream.range(getMinSectionPosition(), getMaxSectionPosition() + 1).filter(this::hasSection)
|
||||
.map(layer -> (1 << layer)).sum();
|
||||
}
|
||||
|
||||
@ -55,19 +55,23 @@ public interface IBlocks extends Trimable {
|
||||
IBlocks reset();
|
||||
|
||||
/**
|
||||
* Get the number of stores sections
|
||||
* Get the number of stored sections
|
||||
*/
|
||||
int getSectionCount();
|
||||
|
||||
/**
|
||||
* Max ChunkSection array index
|
||||
* Get the highest layer position stored in the internal chunk. For 1.16 and below, always returns 15. For 1.17 and above, may
|
||||
* not return a value correct to the world if this is a {@link IChunkSet} instance, which defaults to 15. For extended
|
||||
* height worlds, this will only return over 15 if blocks are stored outside the default range.
|
||||
*/
|
||||
int getMaxSectionIndex();
|
||||
int getMaxSectionPosition();
|
||||
|
||||
/**
|
||||
* Min ChunkSection array index
|
||||
* Get the lowest layer position stored in the internal chunk. For 1.16 and below, always returns 0. For 1.17 and above, may
|
||||
* not return a value correct to the world if this is a {@link IChunkSet} instance, which defaults to 0. For extended
|
||||
* height worlds, this will only return under 0 if blocks are stored outside the default range.
|
||||
*/
|
||||
int getMinSectionIndex();
|
||||
int getMinSectionPosition();
|
||||
|
||||
default byte[] toByteArray(boolean full, boolean stretched) {
|
||||
return toByteArray(null, getBitMask(), full, stretched);
|
||||
|
@ -210,12 +210,12 @@ public class BitSetBlocks implements IChunkSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSectionIndex() {
|
||||
public int getMaxSectionPosition() {
|
||||
return minSectionIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSectionIndex() {
|
||||
public int getMinSectionPosition() {
|
||||
return maxSectionIndex;
|
||||
}
|
||||
|
||||
|
@ -327,12 +327,12 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSectionIndex() {
|
||||
public int getMaxSectionPosition() {
|
||||
return maxSectionIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSectionIndex() {
|
||||
public int getMinSectionPosition() {
|
||||
return minSectionIndex;
|
||||
}
|
||||
|
||||
|
@ -100,12 +100,12 @@ public final class NullChunkGet implements IChunkGet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSectionIndex() {
|
||||
public int getMaxSectionPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSectionIndex() {
|
||||
public int getMinSectionPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -190,13 +190,13 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSectionIndex() {
|
||||
return getOrCreateGet().getMaxSectionIndex();
|
||||
public int getMaxSectionPosition() {
|
||||
return getOrCreateGet().getMaxSectionPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSectionIndex() {
|
||||
return getOrCreateGet().getMinSectionIndex();
|
||||
public int getMinSectionPosition() {
|
||||
return getOrCreateGet().getMinSectionPosition();
|
||||
}
|
||||
|
||||
public void flushLightToGet() {
|
||||
@ -285,7 +285,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public int getSkyLight(ChunkHolder chunk, int x, int y, int z) {
|
||||
if (chunk.chunkSet.getSkyLight() != null) {
|
||||
int layer = y >> 4;
|
||||
layer -= chunk.chunkSet.getMinSectionIndex();
|
||||
layer -= chunk.chunkSet.getMinSectionPosition();
|
||||
if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) {
|
||||
if (chunk.chunkSet.getSkyLight()[layer] != null) {
|
||||
int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)];
|
||||
@ -302,7 +302,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public int getEmittedLight(ChunkHolder chunk, int x, int y, int z) {
|
||||
if (chunk.chunkSet.getLight() != null) {
|
||||
int layer = y >> 4;
|
||||
layer -= chunk.chunkSet.getMinSectionIndex();
|
||||
layer -= chunk.chunkSet.getMinSectionPosition();
|
||||
if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) {
|
||||
if (chunk.chunkSet.getLight()[layer] != null) {
|
||||
int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)];
|
||||
@ -332,11 +332,11 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
|
||||
@Override
|
||||
public void flushLightToGet(ChunkHolder chunk) {
|
||||
chunk.chunkExisting.setLightingToGet(chunk.chunkSet.getLight(), chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkExisting.setLightingToGet(chunk.chunkSet.getLight(), chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
chunk.chunkExisting.setSkyLightingToGet(chunk.chunkSet.getSkyLight(), chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkExisting.setSkyLightingToGet(chunk.chunkSet.getSkyLight(), chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
}
|
||||
|
||||
@ -344,8 +344,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.chunkExisting.setLightingToGet(
|
||||
lighting,
|
||||
chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
}
|
||||
|
||||
@ -353,8 +353,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setSkyLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.chunkExisting.setSkyLightingToGet(
|
||||
lighting,
|
||||
chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
}
|
||||
|
||||
@ -498,8 +498,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.chunkExisting.setLightingToGet(
|
||||
lighting,
|
||||
chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
}
|
||||
|
||||
@ -507,8 +507,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setSkyLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.chunkExisting.setSkyLightingToGet(
|
||||
lighting,
|
||||
chunk.chunkSet.getMinSectionIndex(),
|
||||
chunk.chunkSet.getMaxSectionIndex()
|
||||
chunk.chunkSet.getMinSectionPosition(),
|
||||
chunk.chunkSet.getMaxSectionPosition()
|
||||
);
|
||||
}
|
||||
|
||||
@ -615,7 +615,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public int getSkyLight(ChunkHolder chunk, int x, int y, int z) {
|
||||
if (chunk.chunkSet.getSkyLight() != null) {
|
||||
int layer = y >> 4;
|
||||
layer -= chunk.chunkSet.getMinSectionIndex();
|
||||
layer -= chunk.chunkSet.getMinSectionPosition();
|
||||
if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) {
|
||||
if (chunk.chunkSet.getSkyLight()[layer] != null) {
|
||||
int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)];
|
||||
@ -634,7 +634,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public int getEmittedLight(ChunkHolder chunk, int x, int y, int z) {
|
||||
if (chunk.chunkSet.getLight() != null) {
|
||||
int layer = y >> 4;
|
||||
layer -= chunk.chunkSet.getMinSectionIndex();
|
||||
layer -= chunk.chunkSet.getMinSectionPosition();
|
||||
if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) {
|
||||
if (chunk.chunkSet.getLight()[layer] != null) {
|
||||
int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)];
|
||||
@ -681,14 +681,14 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.getOrCreateGet();
|
||||
chunk.delegate = BOTH;
|
||||
chunk.setLightingToGet(lighting, chunk.chunkSet.getMinSectionIndex(), chunk.chunkSet.getMaxSectionIndex());
|
||||
chunk.setLightingToGet(lighting, chunk.chunkSet.getMinSectionPosition(), chunk.chunkSet.getMaxSectionPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkyLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.getOrCreateGet();
|
||||
chunk.delegate = BOTH;
|
||||
chunk.setSkyLightingToGet(lighting, chunk.chunkSet.getMinSectionIndex(), chunk.chunkSet.getMaxSectionIndex());
|
||||
chunk.setSkyLightingToGet(lighting, chunk.chunkSet.getMinSectionPosition(), chunk.chunkSet.getMaxSectionPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -846,14 +846,14 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
public void setLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.getOrCreateGet();
|
||||
chunk.delegate = GET;
|
||||
chunk.setLightingToGet(lighting, chunk.chunkSet.getMinSectionIndex(), chunk.chunkSet.getMaxSectionIndex());
|
||||
chunk.setLightingToGet(lighting, chunk.chunkSet.getMinSectionPosition(), chunk.chunkSet.getMaxSectionPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkyLightingToGet(ChunkHolder chunk, char[][] lighting) {
|
||||
chunk.getOrCreateGet();
|
||||
chunk.delegate = GET;
|
||||
chunk.setSkyLightingToGet(lighting, chunk.chunkSet.getMinSectionIndex(), chunk.chunkSet.getMaxSectionIndex());
|
||||
chunk.setSkyLightingToGet(lighting, chunk.chunkSet.getMinSectionPosition(), chunk.chunkSet.getMaxSectionPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,12 +209,12 @@ public final class NullChunk implements IQueueChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSectionIndex() {
|
||||
public int getMaxSectionPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSectionIndex() {
|
||||
public int getMinSectionPosition() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -744,7 +744,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
if (bx >= minX && tx <= maxX && bz >= minZ && tz <= maxZ) {
|
||||
// contains all X/Z
|
||||
if (minY <= set.getMinSectionIndex() << 4 && maxY >= (set.getMaxSectionIndex() << 4) + 15) {
|
||||
if (minY <= set.getMinSectionPosition() << 4 && maxY >= (set.getMaxSectionPosition() << 4) + 15) {
|
||||
return set;
|
||||
}
|
||||
trimY(set, minY, maxY);
|
||||
@ -752,7 +752,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
return set;
|
||||
}
|
||||
if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) {
|
||||
if (minY > set.getMinSectionIndex() << 4 || maxY < (set.getMaxSectionIndex() << 4) + 15) {
|
||||
if (minY > set.getMinSectionPosition() << 4 || maxY < (set.getMaxSectionPosition() << 4) + 15) {
|
||||
trimY(set, minY, maxY);
|
||||
}
|
||||
final int lowerX = Math.max(0, minX - bx);
|
||||
@ -767,7 +767,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
boolean trimX = lowerX != 0 || upperX != 15;
|
||||
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
||||
|
||||
for (int layer = get.getMinSectionIndex(); layer < get.getMaxSectionIndex(); layer++) {
|
||||
for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
char[] arr = set.load(layer);
|
||||
if (trimX || trimZ) {
|
||||
|
@ -244,8 +244,8 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
final IChunkSet set,
|
||||
boolean full
|
||||
) {
|
||||
int minSection = Math.max(get.getMinSectionIndex(), getMinimumY() >> 4);
|
||||
int maxSection = Math.min(get.getMaxSectionIndex(), getMaximumY() >> 4);
|
||||
int minSection = Math.max(get.getMinSectionPosition(), getMinimumY() >> 4);
|
||||
int maxSection = Math.min(get.getMaxSectionPosition(), getMaximumY() >> 4);
|
||||
block = block.initChunk(chunk.getX(), chunk.getZ());
|
||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||
if ((!full && !set.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||
|
Loading…
Reference in New Issue
Block a user