9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 15:09:15 +00:00

修复潜在的数组越界

This commit is contained in:
XiaoMoMi
2025-12-05 23:23:01 +08:00
parent 5003fa4cf2
commit d5bbbc4903
2 changed files with 3 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ public class ClientChunk {
public boolean isOccluding(int x, int y, int z) { public boolean isOccluding(int x, int y, int z) {
if (this.sections == null) return false; if (this.sections == null) return false;
int index = sectionIndex(SectionPos.blockToSectionCoord(y)); int index = sectionIndex(SectionPos.blockToSectionCoord(y));
if (index < 0 || index >= this.sections.length) return false;
ClientSection section = this.sections[index]; ClientSection section = this.sections[index];
if (section == null) return false; if (section == null) return false;
return section.isOccluding((y & 15) << 8 | (z & 15) << 4 | x & 15); return section.isOccluding((y & 15) << 8 | (z & 15) << 4 | x & 15);
@@ -30,6 +31,7 @@ public class ClientChunk {
public void setOccluding(int x, int y, int z, boolean occluding) { public void setOccluding(int x, int y, int z, boolean occluding) {
if (this.sections == null) return; if (this.sections == null) return;
int index = sectionIndex(SectionPos.blockToSectionCoord(y)); int index = sectionIndex(SectionPos.blockToSectionCoord(y));
if (index < 0 || index >= this.sections.length) return;
ClientSection section = this.sections[index]; ClientSection section = this.sections[index];
if (section == null) return; if (section == null) return;
section.setOccluding((y & 15) << 8 | (z & 15) << 4 | x & 15, occluding); section.setOccluding((y & 15) << 8 | (z & 15) << 4 | x & 15, occluding);

View File

@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx1G
# Project settings # Project settings
project_version=0.0.65.17 project_version=0.0.65.18
config_version=60 config_version=60
lang_version=43 lang_version=43
project_group=net.momirealms project_group=net.momirealms