9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

improve chunk existing check

This commit is contained in:
CrazyDev22
2024-05-17 16:45:59 +02:00
parent 79f86ca87d
commit dafb59e5a8
2 changed files with 4 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ public interface IHeadless extends Closeable {
void saveAll();
@RegionCoordinates
@ChunkCoordinates
boolean exists(int x, int z);
@RegionCoordinates

View File

@@ -76,7 +76,8 @@ public class Headless implements IHeadless, LevelHeightAccessor {
public boolean exists(int x, int z) {
if (closed) return false;
try {
return storage.getRegionFile(new ChunkPos(x << 5, z << 5), true) != null;
CompoundTag tag = storage.read(new ChunkPos(x, z));
return tag != null && !"empty".equals(tag.getString("Status"));
} catch (IOException e) {
return false;
}
@@ -137,16 +138,9 @@ public class Headless implements IHeadless, LevelHeightAccessor {
@Override
public void generateChunk(int x, int z) {
if (closed) return;
if (closed || exists(x, z)) return;
try {
var pos = new ChunkPos(x, z);
try {
CompoundTag tag = storage.read(pos);
if (tag != null && !"empty".equals(tag.getString("Status"))) {
return;
}
} catch (Throwable ignored) {}
ProtoChunk chunk = binding.createProtoChunk(pos, this);
var tc = new MCATerrainChunk(chunk);