forked from mirrors/NBTExplorer
Added heightmap rebuilding (for maps with invalid heightmaps), and added it to the relight example. Made a couple level.dat fields auto-create if missing.
This commit is contained in:
parent
0b2db7934d
commit
bb12d60c0c
4 changed files with 24 additions and 2 deletions
|
@ -27,6 +27,7 @@ namespace Relight
|
|||
|
||||
// First blank out all of the lighting in all of the chunks
|
||||
foreach (ChunkRef chunk in cm) {
|
||||
chunk.RebuildHeightMap();
|
||||
chunk.ResetBlockLight();
|
||||
chunk.ResetSkyLight();
|
||||
cm.Save();
|
||||
|
|
|
@ -749,6 +749,21 @@ namespace Substrate
|
|||
|
||||
#endregion
|
||||
|
||||
public void RebuildHeightMap ()
|
||||
{
|
||||
for (int x = 0; x < XDim; x++) {
|
||||
for (int z = 0; z < ZDim; z++) {
|
||||
for (int y = YDim - 1; y >= 0; y--) {
|
||||
BlockInfo info = GetBlockInfo(x, y, z);
|
||||
if (BlockInfo.BlockTable[GetBlockID(x, y, z)].Opacity > BlockInfo.MIN_OPACITY) {
|
||||
_heightMap[z << 4 | x] = (byte)y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetBlockLight ()
|
||||
{
|
||||
_blockLight.Clear();
|
||||
|
|
|
@ -448,6 +448,12 @@ namespace Substrate
|
|||
|
||||
#endregion
|
||||
|
||||
public void RebuildHeightMap ()
|
||||
{
|
||||
GetChunk().RebuildHeightMap();
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
private BitArray _lightbit;
|
||||
private Queue<BlockKey> _update;
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ namespace Substrate
|
|||
new NBTCompoundNode("Data")
|
||||
{
|
||||
new NBTScalerNode("Time", TagType.TAG_LONG),
|
||||
new NBTScalerNode("LastPlayed", TagType.TAG_LONG),
|
||||
new NBTScalerNode("LastPlayed", TagType.TAG_LONG, NBTOptions.CREATE_ON_MISSING),
|
||||
new NBTCompoundNode("Player", Player.PlayerSchema, NBTOptions.OPTIONAL),
|
||||
new NBTScalerNode("SpawnX", TagType.TAG_INT),
|
||||
new NBTScalerNode("SpawnY", TagType.TAG_INT),
|
||||
new NBTScalerNode("SpawnZ", TagType.TAG_INT),
|
||||
new NBTScalerNode("SizeOnDisk", TagType.TAG_LONG),
|
||||
new NBTScalerNode("SizeOnDisk", TagType.TAG_LONG, NBTOptions.CREATE_ON_MISSING),
|
||||
new NBTScalerNode("RandomSeed", TagType.TAG_LONG),
|
||||
new NBTScalerNode("version", TagType.TAG_INT, NBTOptions.OPTIONAL),
|
||||
new NBTScalerNode("LevelName", TagType.TAG_STRING, NBTOptions.OPTIONAL),
|
||||
|
|
Loading…
Reference in a new issue