From 6f7927bc5aa3936322de8d02cc49c9ffae0f417d Mon Sep 17 00:00:00 2001 From: wizjany Date: Wed, 12 Jun 2019 21:51:22 -0400 Subject: [PATCH] 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). --- .../main/java/com/sk89q/worldedit/EditSession.java | 12 +++++++----- .../worldedit/command/SnapshotUtilCommands.java | 4 +++- .../world/storage/TrueZipMcRegionChunkStore.java | 1 + .../world/storage/ZippedMcRegionChunkStore.java | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 43843e8a3..a0b0a1150 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1307,14 +1307,16 @@ public class EditSession implements Extent, AutoCloseable { checkNotNull(origin); checkArgument(radius >= 0, "radius >= 0 required"); + Mask waterloggedMask = null; + if (waterlogged) { + Map 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() {{ - put("waterlogged", "true"); - }}, true)) + waterlogged ? new MaskUnion(getWorld().createLiquidMask(), waterloggedMask) : getWorld().createLiquidMask()); BlockReplace replace; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java index 14a90e2fe..0b9ba7cfe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java @@ -133,7 +133,9 @@ public class SnapshotUtilCommands { 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 { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java index 80e2f814d..a653844a9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java @@ -101,6 +101,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { // 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; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java index afb9cff72..f83ad89da 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java @@ -87,6 +87,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { 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; }