Changed method for finding region folder (used by Fill and Trim) to hopefully support custom world types such as Twilight Forest and Mystcraft... untested, but hopefully working

This commit is contained in:
Brettflan 2013-03-29 19:18:58 -05:00
parent 6b4a0be0b2
commit f6388102f9

View File

@ -34,18 +34,22 @@ public class WorldFileData
newData.regionFolder = new File(newData.world.getWorldFolder(), "region");
if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory())
{
String mainRegionFolder = newData.regionFolder.getPath();
newData.regionFolder = new File(newData.world.getWorldFolder(), "DIM-1"+File.separator+"region"); // nether worlds
if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory())
// check for region folder inside a DIM* folder (DIM-1 for nether, DIM1 for end, DIMwhatever for custom world types)
File[] possibleDimFolders = newData.world.getWorldFolder().listFiles(new DimFolderFileFilter());
for (int i = 0; i < possibleDimFolders.length; i++)
{
String subRegionFolder = newData.regionFolder.getPath();
newData.regionFolder = new File(newData.world.getWorldFolder(), "DIM1"+File.separator+"region"); // "the end" worlds; not sure why "DIM1" vs "DIM-1", but that's how it is
if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory())
File possible = new File(newData.world.getWorldFolder(), possibleDimFolders[i].getName()+File.separator+"region");
if (possible.exists() && possible.isDirectory())
{
newData.sendMessage("Could not validate folder for world's region files. Looked in: "+mainRegionFolder+" -and- "+subRegionFolder+" -and- "+newData.regionFolder.getPath());
return null;
newData.regionFolder = possible;
continue;
}
}
if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory())
{
newData.sendMessage("Could not validate folder for world's region files. Looked in "+newData.world.getWorldFolder().getPath()+" for valid DIM* folder with a region folder in it.");
return null;
}
}
// Accepted region file formats: MCR is from late beta versions through 1.1, MCA is from 1.2+
@ -240,6 +244,19 @@ public class WorldFileData
}
}
// file filter used for DIM* folders (for nether, End, and custom world types)
private static class DimFolderFileFilter implements FileFilter
{
@Override
public boolean accept(File file)
{
return (
file.exists()
&& file.isDirectory()
&& file.getName().toLowerCase().startsWith("dim")
);
}
}
// crude chunk map PNG image output, for debugging