Example #1
0
        private void Save()
        {
            using (var fs = File.OpenWrite("map0.ssmap"))
            {
                var payload = new ByteBufferWriter(0);

                var floats = new List <float>();

                var count = 0;
                for (; count < _boxes.Count; count++)
                {
                    var box = _boxes[count];

                    floats.Add(box.Min.X);
                    floats.Add(box.Min.Y);
                    floats.Add(box.Max.X);
                    floats.Add(box.Max.Y);
                }

                payload.WriteInt32(count);

                foreach (var f in floats)
                {
                    payload.WriteFloat(f);
                }

                var data = payload.ToArray();

                fs.Write(data, 0, data.Length);
            }
        }
Example #2
0
        private void SaveTileEntityData(BlockPos localPos)
        {
            if (!_tileEntities.TryGetValue(localPos, out var te))
            {
                return;
            }

            var dir = $"{World.SaveRoot}/{World.Dimension}/te";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var file =
                $"{dir}/te_{Pos.WorldSpaceX() + localPos.X}.{localPos.Y}.{Pos.WorldSpaceZ() + localPos.Z}.te";

            ByteBufferWriter bbw = new ByteBufferWriter(0);

            te.WriteData(bbw);

            File.WriteAllBytes(file, bbw.ToArray());
        }