public void Deserialize(NbtTag value) { IsModified = true; var compound = value as NbtCompound; var chunk = (Chunk)Serializer.Deserialize(value, true); this._TileEntities = chunk._TileEntities; this.Biomes = chunk.Biomes; this.HeightMap = chunk.HeightMap; this.LastUpdate = chunk.LastUpdate; this.Sections = chunk.Sections; this.TerrainPopulated = chunk.TerrainPopulated; this.X = chunk.X; this.Z = chunk.Z; // Entities var entities = compound["Entities"] as NbtList; Entities = new List <IDiskEntity>(); for (int i = 0; i < entities.Count; i++) { var id = entities[i]["id"].StringValue; IDiskEntity entity; if (EntityTypes.ContainsKey(id.ToUpper())) { entity = (IDiskEntity)Activator.CreateInstance(EntityTypes[id]); } else { entity = new UnrecognizedEntity(id); } entity.Deserialize(entities[i]); Entities.Add(entity); } var serializer = new NbtSerializer(typeof(Section)); foreach (var section in compound["Sections"] as NbtList) { int index = section["Y"].IntValue; Sections[index] = (Section)serializer.Deserialize(section); Sections[index].ProcessSection(); } }
public void Deserialize(NbtTag value) { var compound = value as NbtCompound; var chunk = (Chunk)Serializer.Deserialize(value, true); this._TileEntities = chunk._TileEntities; this.Biomes = chunk.Biomes; this.HeightMap = chunk.HeightMap; this.LastUpdate = chunk.LastUpdate; this.Sections = chunk.Sections; this.TerrainPopulated = chunk.TerrainPopulated; this.X = chunk.X; this.Z = chunk.Z; // Entities var entities = compound["Entities"] as NbtList; Entities = new List<IDiskEntity>(); for (int i = 0; i < entities.Count; i++) { var id = entities[i]["id"].StringValue; IDiskEntity entity; if (EntityTypes.ContainsKey(id.ToUpper())) entity = (IDiskEntity)Activator.CreateInstance(EntityTypes[id]); else entity = new UnrecognizedEntity(id); entity.Deserialize(entities[i]); Entities.Add(entity); } var serializer = new NbtSerializer(typeof(Section)); foreach (var section in compound["Sections"] as NbtList) { int index = section["Y"].IntValue; Sections[index] = (Section)serializer.Deserialize(section); Sections[index].ProcessSection(); } }