public void Save(Stream stream, Game game) { using (GZipStream wrapper = new GZipStream(stream, CompressionMode.Compress)) { BinaryWriter writer = new BinaryWriter(wrapper); NbtFile nbt = new NbtFile(writer); World map = game.World; nbt.Write(NbtTagType.Compound); nbt.Write("Schematic"); nbt.Write(NbtTagType.String); nbt.Write("Materials"); nbt.Write("Classic"); nbt.Write(NbtTagType.Int16); nbt.Write("Width"); nbt.WriteInt16((short)map.Width); nbt.Write(NbtTagType.Int16); nbt.Write("Height"); nbt.WriteInt16((short)map.Height); nbt.Write(NbtTagType.Int16); nbt.Write("Length"); nbt.WriteInt16((short)map.Length); WriteBlocks(nbt, map.blocks1); WriteBlockData(nbt, map.blocks1.Length); nbt.Write(NbtTagType.List); nbt.Write("Entities"); nbt.Write(NbtTagType.Compound); nbt.WriteInt32(0); nbt.Write(NbtTagType.List); nbt.Write("TileEntities"); nbt.Write(NbtTagType.Compound); nbt.WriteInt32(0); nbt.Write(NbtTagType.End); } }
void WriteSpawnCompoundTag() { nbt.Write(NbtTagType.Compound); nbt.Write("Spawn"); LocalPlayer p = game.LocalPlayer; Vector3 spawn = p.Position; // TODO: Maybe also keep real spawn too? nbt.Write(NbtTagType.Int16); nbt.Write("X"); nbt.WriteInt16((short)spawn.X); nbt.Write(NbtTagType.Int16); nbt.Write("Y"); nbt.WriteInt16((short)spawn.Y); nbt.Write(NbtTagType.Int16); nbt.Write("Z"); nbt.WriteInt16((short)spawn.Z); nbt.Write(NbtTagType.Int8); nbt.Write("H"); nbt.WriteUInt8(Utils.DegreesToPacked(p.SpawnRotY)); nbt.Write(NbtTagType.Int8); nbt.Write("P"); nbt.WriteUInt8(Utils.DegreesToPacked(p.SpawnHeadX)); nbt.Write(NbtTagType.End); }
public void Save(Stream stream, Game game) { using (GZipStream wrapper = new GZipStream(stream, CompressionMode.Compress)) { writer = new BinaryWriter(wrapper); nbt = new NbtFile(writer); this.game = game; map = game.World; nbt.Write(NbtTagType.Compound); nbt.Write("ClassicWorld"); nbt.Write(NbtTagType.Int8); nbt.Write("FormatVersion"); nbt.WriteInt8(1); nbt.Write(NbtTagType.Int8Array); nbt.Write("UUID"); nbt.WriteInt32(16); nbt.WriteBytes(map.Uuid.ToByteArray()); nbt.Write(NbtTagType.Int16); nbt.Write("X"); nbt.WriteInt16((short)map.Width); nbt.Write(NbtTagType.Int16); nbt.Write("Y"); nbt.WriteInt16((short)map.Height); nbt.Write(NbtTagType.Int16); nbt.Write("Z"); nbt.WriteInt16((short)map.Length); WriteSpawnCompoundTag(); nbt.Write(NbtTagType.Int8Array); nbt.Write("BlockArray"); nbt.WriteInt32(map.blocks.Length); #if USE16_BIT nbt.WriteBytes(Utils.UInt16sToUInt8s(map.blocks)); #else nbt.WriteBytes(map.blocks); #endif WriteMetadata(); nbt.Write(NbtTagType.End); } }
public void Save( Stream stream, Game game ) { using( GZipStream wrapper = new GZipStream( stream, CompressionMode.Compress ) ) { writer = new BinaryWriter( wrapper ); nbt = new NbtFile( writer ); this.game = game; map = game.World; nbt.Write( NbtTagType.Compound ); nbt.Write( "ClassicWorld" ); nbt.Write( NbtTagType.Int8 ); nbt.Write( "FormatVersion" ); nbt.WriteInt8( 1 ); nbt.Write( NbtTagType.Int8Array ); nbt.Write( "UUID" ); nbt.WriteInt32( 16 ); nbt.WriteBytes( map.Uuid.ToByteArray() ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "X" ); nbt.WriteInt16( (short)map.Width ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "Y" ); nbt.WriteInt16( (short)map.Height ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "Z" ); nbt.WriteInt16( (short)map.Length ); WriteSpawnCompoundTag(); nbt.Write( NbtTagType.Int8Array ); nbt.Write( "BlockArray" ); nbt.WriteInt32( map.blocks.Length ); nbt.WriteBytes( map.blocks ); WriteMetadata(); nbt.Write( NbtTagType.End ); } }
public void Save(Stream stream, Game game) { using (GZipStream s = new GZipStream(stream, CompressionMode.Compress)) { writer = new BinaryWriter(s); nbt = new NbtFile(writer); this.game = game; map = game.World; nbt.Write(NbtTagType.Compound, "ClassicWorld"); nbt.Write(NbtTagType.Int8, "FormatVersion"); nbt.WriteUInt8(1); nbt.Write(NbtTagType.Int8Array, "UUID"); nbt.WriteInt32(16); nbt.WriteBytes(map.Uuid.ToByteArray()); nbt.Write(NbtTagType.Int16, "X"); nbt.WriteInt16((short)map.Width); nbt.Write(NbtTagType.Int16, "Y"); nbt.WriteInt16((short)map.Height); nbt.Write(NbtTagType.Int16, "Z"); nbt.WriteInt16((short)map.Length); WriteSpawnCompoundTag(); nbt.Write(NbtTagType.Int8Array, "BlockArray"); nbt.WriteInt32(map.blocks.Length); nbt.WriteBytes(map.blocks); WriteMetadata(); nbt.Write(NbtTagType.End); } }
public void Save( Stream stream, Game game ) { using( GZipStream wrapper = new GZipStream( stream, CompressionMode.Compress ) ) { BinaryWriter writer = new BinaryWriter( wrapper ); NbtFile nbt = new NbtFile( writer ); World map = game.World; nbt.Write( NbtTagType.Compound ); nbt.Write( "Schematic" ); nbt.Write( NbtTagType.String ); nbt.Write( "Materials" ); nbt.Write( "Classic" ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "Width" ); nbt.WriteInt16( (short)map.Width ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "Height" ); nbt.WriteInt16( (short)map.Height ); nbt.Write( NbtTagType.Int16 ); nbt.Write( "Length" ); nbt.WriteInt16( (short)map.Length ); WriteBlocks( nbt, map.blocks ); WriteBlockData( nbt, map.blocks ); nbt.Write( NbtTagType.List ); nbt.Write( "Entities" ); nbt.Write( NbtTagType.Compound ); nbt.WriteInt32( 0 ); nbt.Write( NbtTagType.List ); nbt.Write( "TileEntities" ); nbt.Write( NbtTagType.Compound ); nbt.WriteInt32( 0 ); nbt.Write( NbtTagType.End ); } }