public static void Save(World world, string filename, bool resetTime = false)
        {
            try
            {
                OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
                world.Validate();
            }
            catch (ArgumentOutOfRangeException err)
            {
                string msg = "There is a problem in your world.\r\n" +
                             $"{err.ParamName}\r\nThis world will not open in Terraria\r\n" +
                             "Would you like to save anyways??\r\n";
                if (MessageBox.Show(msg, "World Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
                    MessageBoxResult.Yes)
                {
                    return;
                }
            }
            lock (_fileLock)
            {
                if (resetTime)
                {
                    OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
                    world.ResetTime();
                }

                if (filename == null)
                {
                    return;
                }

                string temp = filename + ".tmp";
                using (var fs = new FileStream(temp, FileMode.Create))
                {
                    using (var bw = new BinaryWriter(fs))
                    {
                        if (world.Version > 87)
                        {
                            SaveV2(world, bw);
                        }
                        else
                        {
                            SaveV1(world, bw);
                        }

                        bw.Close();
                        fs.Close();

                        // make a backup of current file if it exists
                        if (File.Exists(filename))
                        {
                            string backup = filename + "." + DateTime.Now.ToString("yyyyMMddHHmmss") + ".TEdit";
                            File.Copy(filename, backup, true);
                        }
                        // replace actual file with temp save file
                        File.Copy(temp, filename, true);
                        // delete temp save file
                        File.Delete(temp);
                        OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
                    }
                }

                world._lastSave = File.GetLastWriteTimeUtc(filename);
            }
        }