pull/12/head
valoeghese 2020-02-28 19:42:04 +13:00
parent f4f49cdac7
commit f8cf2772ae
2 changed files with 22 additions and 1 deletions

View File

@ -184,6 +184,14 @@ public class Chunk implements BlockAccess, WorldGenConstants, DataStorage
}
}
}
//
DataSection properties = data.get("properties");
try
{
this.fullyGenerated = properties.readBoolean(0); // index 0 is the "fully generated" property
}
catch (Throwable e)
{ System.out.println("An exception occurred reading properties for a chunk! This could be a benign error due to updates to chunk properties.");}
}
private int nextId; // for saving
@ -219,6 +227,10 @@ public class Chunk implements BlockAccess, WorldGenConstants, DataStorage
//
data.put("palette", paletteData);
data.put("block", blockData);
//
DataSection properties = new DataSection();
properties.writeBoolean(this.fullyGenerated);
data.put("properties", properties);
dirty = true;
}
}

View File

@ -57,7 +57,7 @@ public class World implements BlockAccess, WorldGenConstants
for (int i = (0 - (size / 2)); i < (size / 2); i++)
for (int k = (0 - (size / 2)); k < (size / 2); k++)
for (int y = -2; y < 0; ++y)
this.getChunk(i, y, k).setRender(true);
this.loadChunk(i, y, k).setRender(true);
System.out.println("Generated world in " + (System.currentTimeMillis() - time) + " milliseconds");
}
@ -74,6 +74,15 @@ public class World implements BlockAccess, WorldGenConstants
return chunk;
}
public Chunk loadChunk(int chunkX, int chunkY, int chunkZ)
{
return this.chunks.computeIfAbsent(posHash(chunkX, chunkY, chunkZ), pos ->
{
Chunk readChunk = save.readChunk(chunkX, chunkY, chunkZ, this.dimension);
return readChunk == null ? this.chunkGenerator.generateChunk(chunkX, chunkY, chunkZ) : readChunk;
});
}
/** @return whether the chunk was unloaded without errors. Will often, but not always, be equal to whether the chunk was already in memory. */
public boolean unloadChunk(int chunkX, int chunkY, int chunkZ)
{