summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp16
-rw-r--r--src/WorldStorage/NBTChunkSerializer.h2
-rw-r--r--src/WorldStorage/WSSAnvil.cpp39
3 files changed, 52 insertions, 5 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 1962d42ff..09225dd90 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -765,6 +765,22 @@ void cNBTChunkSerializer::LightIsValid(bool a_IsLightValid)
+void cNBTChunkSerializer::HeightMap(const cChunkDef::HeightMap * a_HeightMap)
+{
+ for (int RelX = 0; RelX < cChunkDef::Width; RelX++)
+ {
+ for (int RelZ = 0; RelZ < cChunkDef::Width; RelZ++)
+ {
+ int Height = cChunkDef::GetHeight(*a_HeightMap, RelX, RelZ);
+ m_VanillaHeightMap[(RelZ << 4) | RelX] = Height;
+ }
+ }
+}
+
+
+
+
+
void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
{
memcpy(m_Biomes, a_BiomeMap, sizeof(m_Biomes));
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 4c229a65c..5ffab8cc5 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -59,6 +59,7 @@ class cNBTChunkSerializer :
public:
cChunkDef::BiomeMap m_Biomes;
unsigned char m_VanillaBiomes[cChunkDef::Width * cChunkDef::Width];
+ int m_VanillaHeightMap[cChunkDef::Width * cChunkDef::Width];
bool m_BiomesAreValid;
@@ -125,6 +126,7 @@ protected:
// cChunkDataSeparateCollector overrides:
virtual void LightIsValid(bool a_IsLightValid) override;
+ virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) override;
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) override;
virtual void Entity(cEntity * a_Entity) override;
virtual void BlockEntity(cBlockEntity * a_Entity) override;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index e132a0c26..62f5ef9c0 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -96,10 +96,26 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
if (!cFile::Exists(fnam))
{
cFastNBTWriter Writer;
- Writer.BeginCompound("");
- Writer.AddInt("SpawnX", (int)(a_World->GetSpawnX()));
- Writer.AddInt("SpawnY", (int)(a_World->GetSpawnY()));
- Writer.AddInt("SpawnZ", (int)(a_World->GetSpawnZ()));
+ Writer.BeginCompound("Data");
+ Writer.AddByte("allowCommands", 1);
+ Writer.AddByte("Difficulty", 2);
+ Writer.AddByte("hardcore", 0);
+ Writer.AddByte("initialized", 1);
+ Writer.AddByte("MapFeatures", 1);
+ Writer.AddByte("raining", a_World->IsWeatherRain() ? 1 : 0);
+ Writer.AddByte("thundering", a_World->IsWeatherStorm() ? 1 : 0);
+ Writer.AddInt("GameType", (int)a_World->GetGameMode());
+ Writer.AddInt("generatorVersion", 1);
+ Writer.AddInt("SpawnX", (int)a_World->GetSpawnX());
+ Writer.AddInt("SpawnY", (int)a_World->GetSpawnY());
+ Writer.AddInt("SpawnZ", (int)a_World->GetSpawnZ());
+ Writer.AddInt("version", 19133);
+ Writer.AddLong("DayTime", (Int64)a_World->GetTimeOfDay());
+ Writer.AddLong("Time", a_World->GetWorldAge());
+ Writer.AddLong("SizeOnDisk", 0);
+ Writer.AddString("generatorName", "default");
+ Writer.AddString("generatorOptions", "");
+ Writer.AddString("LevelName", a_World->GetName());
Writer.EndCompound();
Writer.Finish();
@@ -440,6 +456,13 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
a_Writer.BeginCompound("Level");
a_Writer.AddInt("xPos", a_Chunk.m_ChunkX);
a_Writer.AddInt("zPos", a_Chunk.m_ChunkZ);
+
+ // Add "Entities" and "TileEntities". MCEdit can't load the chunk if one of these lists doesn't exists.
+ a_Writer.BeginList("Entities", TAG_Compound);
+ a_Writer.EndList();
+ a_Writer.BeginList("TileEntities", TAG_Compound);
+ a_Writer.EndList();
+
cNBTChunkSerializer Serializer(a_Writer);
if (!m_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, Serializer))
{
@@ -454,7 +477,10 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
a_Writer.AddByteArray("Biomes", (const char *)(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
a_Writer.AddIntArray ("MCSBiomes", (const int *)(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
}
-
+
+ // Save heightmap (Vanilla require this):
+ a_Writer.AddIntArray("HeightMap", (const int *)Serializer.m_VanillaHeightMap, ARRAYCOUNT(Serializer.m_VanillaHeightMap));
+
// Save blockdata:
a_Writer.BeginList("Sections", TAG_Compound);
size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
@@ -485,6 +511,9 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
{
a_Writer.AddByte("MCSIsLightValid", 1);
}
+
+ // Save the world age to the chunk data. Required by vanilla and mcedit.
+ a_Writer.AddLong("LastUpdate", m_World->GetWorldAge());
// Store the flag that the chunk has all the ores, trees, dungeons etc. MCS chunks are always complete.
a_Writer.AddByte("TerrainPopulated", 1);