public void TEST002_SaveMap() { if (Directory.Exists("002")) Directory.Delete("002", true); Directory.CreateDirectory("002"); // Saves map here. InfdevHandler mh = new InfdevHandler(); mh.Save("002/level.dat"); mh.SetDimension(0); Chunk cnkA = mh.NewChunk(0, 0); cnkA.Blocks[0, 0, 0] = 0x01; cnkA.Blocks[0, 0, 1] = 0x02; cnkA.Blocks[0, 0, 2] = 0x03; cnkA.Blocks[0, 0, 3] = 0x04; cnkA.Save(); FileInfo fA = new FileInfo(cnkA.Filename); Assert.Greater(fA.Length, 0, "System writing zero-length chunks."); Chunk cnkB = mh.GetChunk(0, 0); Assert.AreEqual(cnkB.Blocks[0, 0, 0], 0x01); Assert.AreEqual(cnkB.Blocks[0, 0, 1], 0x02); Assert.AreEqual(cnkB.Blocks[0, 0, 2], 0x03); Assert.AreEqual(cnkB.Blocks[0, 0, 3], 0x04); Directory.Delete("002", true); }
public void TEST002_SaveMap() { if (Directory.Exists("002")) Directory.Delete("002", true); Directory.CreateDirectory("002"); // Saves map here. InfdevHandler mh = new InfdevHandler(); mh.Save("002/level.dat"); mh.SetDimension(0); Chunk cnkA = mh.NewChunk(0, 0); cnkA.Blocks[0, 0, 0] = 0x01; cnkA.Blocks[0, 0, 1] = 0x02; cnkA.Blocks[0, 0, 2] = 0x03; cnkA.Blocks[0, 0, 3] = 0x04; cnkA.Save(); FileInfo fA = new FileInfo(cnkA.Filename); Assert.Greater(fA.Length, 0, "System writing zero-length chunks."); Chunk cnkB = mh.GetChunk(0, 0); Assert.AreEqual(cnkB.Blocks[0, 0, 0], 0x01); Assert.AreEqual(cnkB.Blocks[0, 0, 1], 0x02); Assert.AreEqual(cnkB.Blocks[0, 0, 2], 0x03); Assert.AreEqual(cnkB.Blocks[0, 0, 3], 0x04); Console.WriteLine("Opening {0}...", cnkB.Filename); NbtFile chunkFile = new NbtFile(cnkB.Filename); chunkFile.LoadFile(); NbtCompound level = chunkFile.RootTag.Get<NbtCompound>("Level"); // Listed from a Minecraft-generated chunk. string[] reqdEntries = new string[]{ "xPos", "zPos", "LastUpdate", "Blocks", "Data", "SkyLight", "BlockLight", "HeightMap", "TerrainPopulated", "Entities", "TileEntities" }; foreach (string entry in reqdEntries) { if (level.Get(entry)==null) { Console.WriteLine(chunkFile.RootTag.ToString()); Assert.Fail(string.Format("\"{0}\" is not included", entry)); } else { Console.WriteLine(" * Has {0}...", entry); } } Directory.Delete("002", true); }