Exemple #1
0
        public void SavePlayer()
        {
            var health = HealthManager.Export();
            var inv    = Inventory.GetBytes();
            var buffer = new DataBuffer(new byte[0]);

            ConsoleFunctions.WriteInfoLine("Position Saving... (X: " + KnownPosition.X + " Y: " + KnownPosition.Y + " Z: " + KnownPosition.Z + " Yaw: " + KnownPosition.Yaw + " Pitch: " + KnownPosition.Pitch + " OnGround: " + KnownPosition.OnGround + ")");
            buffer.WriteDouble(KnownPosition.X);
            buffer.WriteDouble(KnownPosition.Y);
            buffer.WriteDouble(KnownPosition.Z);
            buffer.WriteFloat(KnownPosition.Yaw);
            buffer.WriteFloat(KnownPosition.Pitch);
            buffer.WriteBool(KnownPosition.OnGround);
            buffer.WriteVarInt((int)Gamemode);
            buffer.WriteVarInt(health.Length);
            foreach (var b in health)
            {
                buffer.WriteByte(b);
            }
            buffer.WriteVarInt(inv.Length);
            foreach (var b in inv)
            {
                buffer.WriteByte(b);
            }
            buffer.WriteBool(IsOperator);

            var data = buffer.ExportWriter;

            data = FileCompression.Compress(data);
            var savename = Server.ServerSettings.OnlineMode ? Uuid : Username;

            File.WriteAllBytes("Players/" + savename + ".pdata", data);
        }
Exemple #2
0
        public void SavePlayer()
        {
            byte[]     health = HealthManager.Export();
            byte[]     inv    = Inventory.GetBytes();
            DataBuffer buffer = new DataBuffer(new byte[0]);

            buffer.WriteDouble(KnownPosition.X);
            buffer.WriteDouble(KnownPosition.Y);
            buffer.WriteDouble(KnownPosition.Z);
            buffer.WriteFloat(KnownPosition.Yaw);
            buffer.WriteFloat(KnownPosition.Pitch);
            buffer.WriteBool(KnownPosition.OnGround);
            buffer.WriteVarInt((int)Gamemode);
            buffer.WriteVarInt(health.Length);
            foreach (byte b in health)
            {
                buffer.WriteByte(b);
            }
            buffer.WriteVarInt(inv.Length);
            foreach (byte b in inv)
            {
                buffer.WriteByte(b);
            }
            byte[] data = buffer.ExportWriter;
            data = Globals.Compress(data);
            string savename = ServerSettings.OnlineMode ? Uuid : Username;

            File.WriteAllBytes("Players/" + savename + ".pdata", data);
        }