Skip poi folders for snapshot restores.

New to 1.14, Mojang stores .mca files which don't contain chunks in the
poi folder.

Note: we explicitly filter *out* the poi folder, instead of filtering
*to* the regions folder, since old versions of minecraft had regions
directly in the world folder (instead of a regions subfolder).
This commit is contained in:
wizjany 2019-06-12 21:51:22 -04:00
parent efb7650d6f
commit 6f7927bc5a
4 changed files with 12 additions and 6 deletions

View File

@ -1307,14 +1307,16 @@ public class EditSession implements Extent, AutoCloseable {
checkNotNull(origin); checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required"); checkArgument(radius >= 0, "radius >= 0 required");
Mask waterloggedMask = null;
if (waterlogged) {
Map<String, String> stateMap = new HashMap<>();
stateMap.put("waterlogged", "true");
waterloggedMask = new BlockStateMask(this, stateMap, true);
}
MaskIntersection mask = new MaskIntersection( MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, getWorld().getMaxY()), new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
waterlogged ? new MaskUnion( waterlogged ? new MaskUnion(getWorld().createLiquidMask(), waterloggedMask)
getWorld().createLiquidMask(),
new BlockStateMask(this, new HashMap<String, String>() {{
put("waterlogged", "true");
}}, true))
: getWorld().createLiquidMask()); : getWorld().createLiquidMask());
BlockReplace replace; BlockReplace replace;

View File

@ -133,7 +133,9 @@ public class SnapshotUtilCommands {
if (restore.hadTotalFailure()) { if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage(); String error = restore.getLastErrorMessage();
if (error != null) { if (!restore.getMissingChunks().isEmpty()) {
player.printError("Chunks were not present in snapshot.");
} else if (error != null) {
player.printError("Errors prevented any blocks from being restored."); player.printError("Errors prevented any blocks from being restored.");
player.printError("Last error: " + error); player.printError("Last error: " + error);
} else { } else {

View File

@ -101,6 +101,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
// Check for file // Check for file
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name; name = folder + "/" + name;
break; break;
} }

View File

@ -87,6 +87,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
if (testEntry.getName().startsWith(worldName + "/")) { if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name; name = folder + "/" + name;
break; break;
} }