Layer index utility method in LocalChunk

This commit is contained in:
dordsor21 2022-02-09 14:25:02 +00:00 committed by Jordan
parent c5ff743c9e
commit 7c48fe198d

View File

@ -93,7 +93,7 @@ public class LocalChunk {
} }
public void setBiome(final int x, final int y, final int z, final @NonNull BiomeType biomeType) { public void setBiome(final int x, final int y, final int z, final @NonNull BiomeType biomeType) {
final int i = (y >> 4) - minSection; final int i = getLayerIndex(y);
final int j = ChunkUtil.getJ(x, y, z); final int j = ChunkUtil.getJ(x, y, z);
BiomeType[] array = this.biomes[i]; BiomeType[] array = this.biomes[i];
if (array == null) { if (array == null) {
@ -108,7 +108,7 @@ public class LocalChunk {
} }
public void setBlock(final int x, final int y, final int z, final @NonNull BaseBlock baseBlock) { public void setBlock(final int x, final int y, final int z, final @NonNull BaseBlock baseBlock) {
final int i = (y >> 4) - minSection; final int i = getLayerIndex(y);
final int j = ChunkUtil.getJ(x, y, z); final int j = ChunkUtil.getJ(x, y, z);
BaseBlock[] array = baseblocks[i]; BaseBlock[] array = baseblocks[i];
if (array == null) { if (array == null) {
@ -129,4 +129,8 @@ public class LocalChunk {
return this.entities; return this.entities;
} }
private int getLayerIndex(final int y) {
return (y >> 4) - minSection;
}
} }