Skip to content

Commit

Permalink
fix section y
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna0x01 committed Dec 30, 2024
1 parent 6579543 commit 8535653
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public void onSectionRemoved(int x, int y, int z) {
long sectionPos = SectionPos.asLong(x, y, z);
RenderSection section = this.sectionByPosition.remove(sectionPos);



if (section == null) {
return;
}
Expand Down Expand Up @@ -688,13 +690,13 @@ public boolean isSectionBuilt(int x, int y, int z) {
}

public void onChunkAdded(int x, int z) {
for (int y = 1; y < 16; y++) {
for (int y = 0; y < 16; y++) {
this.onSectionAdded(x, y, z);
}
}

public void onChunkRemoved(int x, int z) {
for (int y = 1; y < 16; y++) {
for (int y = 0; y < 16; y++) {
this.onSectionRemoved(x, y, z);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ private ClonedChunkSection clone(int x, int y, int z) {

@Nullable ChunkSection section = null;

if (SectionPos.sectionToBlockCoord(y) < 256) {
section = chunk.getBlockStorage()[y];
if (!withinBuildHeight(SectionPos.sectionToBlockCoord(y))) {
section = chunk.getBlockStorage()[SectionPos.blockToSectionCoord(SectionPos.sectionToBlockCoord(y))];
}

return new ClonedChunkSection(this.level, chunk, section, SectionPos.of(x, y, z));
}

private static boolean withinBuildHeight(int y) {
return y < 0 || y >= 256;
}

public void invalidate(int x, int y, int z) {
this.positionToEntry.remove(SectionPos.asLong(x, y, z));
}
Expand Down

0 comments on commit 8535653

Please sign in to comment.