Skip to content

Commit

Permalink
Skip poi folders for snapshot restores.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
wizjany committed Jun 13, 2019
1 parent efb7650 commit 6f7927b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1307,14 +1307,16 @@ public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) th
checkNotNull(origin);
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(
new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
waterlogged ? new MaskUnion(
getWorld().createLiquidMask(),
new BlockStateMask(this, new HashMap<String, String>() {{
put("waterlogged", "true");
}}, true))
waterlogged ? new MaskUnion(getWorld().createLiquidMask(), waterloggedMask)
: getWorld().createLiquidMask());

BlockReplace replace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public void restore(Player player, LocalSession session, EditSession editSession

if (restore.hadTotalFailure()) {
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("Last error: " + error);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc
// Check for file
if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc
if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name;
break;
}
Expand Down

0 comments on commit 6f7927b

Please sign in to comment.