コード例 #1
0
ファイル: PlayerEntity.cs プロジェクト: LiveMC/SharpMC
 public void LoadPlayer()
 {
     string savename = ServerSettings.OnlineMode ? Uuid : Username;
     if (File.Exists("Players/" + savename + ".pdata"))
     {
         byte[] data = File.ReadAllBytes("Players/" + savename + ".pdata");
         data = Globals.Decompress(data);
         DataBuffer reader = new DataBuffer(data);
         double x = reader.ReadDouble();
         double y = reader.ReadDouble();
         double z = reader.ReadDouble();
         float yaw = reader.ReadFloat();
         float pitch = reader.ReadFloat();
         bool onGround = reader.ReadBool();
         KnownPosition = new PlayerLocation(x, y, z) {Yaw = yaw, Pitch = pitch, OnGround = onGround};
         Gamemode = (Gamemode) reader.ReadVarInt();
         int healthLength = reader.ReadVarInt();
         byte[] healthData = reader.Read(healthLength);
         int inventoryLength = reader.ReadVarInt();
         byte[] inventoryData = reader.Read(inventoryLength);
         HealthManager.Import(healthData);
         Inventory.Import(inventoryData);
     }
     else
     {
         KnownPosition = Level.GetSpawnPoint();
     }
     Loaded = true;
 }