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:
@@ -11,7 +11,7 @@ public interface IHeadless extends Closeable {
|
||||
|
||||
void saveAll();
|
||||
|
||||
@RegionCoordinates
|
||||
@ChunkCoordinates
|
||||
boolean exists(int x, int z);
|
||||
|
||||
@RegionCoordinates
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user