Minecraft.World.GetRegionPaths C# (CSharp) Méthode

GetRegionPaths() public méthode

public GetRegionPaths ( Dimension dim = Dimension.Overworld ) : String[]
dim System.Drawing.Dimension
Résultat String[]
        public String[] GetRegionPaths(Dimension dim = Dimension.Overworld)
        {
            String dir = GetRegionDirectory(dim);
            if (Directory.Exists(dir))
            {
                List<String> regions = new List<String>(Directory.GetFiles(dir, "*.mca", SearchOption.TopDirectoryOnly));
                regions.Sort(CompareRegionNames);
                return regions.ToArray();
            }
            else
                return new String[0];
        }

Usage Example

Exemple #1
0
        private void OpenWorld(String path)
        {
            ResetControls();

            try
            {
                world = new World(path);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show(this, String.Format("The file \"{0}\" could not be found. Unable to open world.", path), "Open", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                world = null;
                return;
            }
            catch (Exception)
            {
                MessageBox.Show(this, String.Format("The file \"{0}\" could not be parsed. Please be sure that it is a valid Minecraft level.dat.", path), "Open", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                world = null;
                return;
            }

            lastPath = Path.GetDirectoryName(path);

            String[] regions = world.GetRegionPaths();
            if (regions.Length == 0)
            {
                MessageBox.Show(this, "No region files (*.mca) found in the main, overworld dimension. If the world is older than March 2012 open it in Minecraft 1.2 or later to convert to the Anvil format. Otherwise try switching dimensions from the file menu.", "Open", MessageBoxButtons.OK);
                this.Text = "Biome Painter";
            }
            else
            {
                foreach (String r in regions)
                    lstRegions.Items.Add(RegionFile.ToString(r));
            }

            Settings.AddRecentWorld(path, world.WorldName);
            FillRecentWorldsList();
            this.Text = world.WorldName + " - Biome Painter";
        }