diff --git a/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index c7dfc114..d96727dc 100644 --- a/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -39,7 +39,7 @@ public class AnvilCommands { } @Command( - aliases = { "/replaceall", "/rea", "/repall" }, + aliases = {"/replaceall", "/rea", "/repall"}, usage = " [from-block] ", desc = "Replace all blocks in the selection with another", flags = "d", @@ -73,7 +73,7 @@ public class AnvilCommands { } @Command( - aliases = { "/replaceallpattern", "/reap", "/repallpat" }, + aliases = {"/replaceallpattern", "/reap", "/repallpat"}, usage = " [from-block] ", desc = "Replace all blocks in the selection with another", flags = "d", @@ -96,6 +96,7 @@ public class AnvilCommands { final LongAdder count = new LongAdder(); queue.filterWorld(new MCAFilter() { private final Vector mutable = new Vector(0, 0, 0); + @Override public void applyBlock(int x, int y, int z, BaseBlock block) { if (matchFrom.apply(block)) { @@ -117,7 +118,7 @@ public class AnvilCommands { } @Command( - aliases = { "/countall" }, + aliases = {"/countall"}, usage = " [hasSky] ", desc = "Count all blocks in a world", flags = "d", diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index b9e6c97c..8ac538d9 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -191,7 +191,10 @@ public class MCAChunk extends FaweChunk { streamer.readFully(); } - + public void setDeleted(boolean deleted) { + setModified(); + this.deleted = deleted; + } public boolean isModified() { return modified; diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index 84c7f2b4..caff1dda 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -49,6 +49,8 @@ public class MCAFile { private byte[] buffer2 = new byte[Settings.HISTORY.BUFFER_SIZE]; private byte[] buffer3 = new byte[720]; + private final int X, Z; + private Map chunks = new HashMap<>(); public MCAFile(FaweQueue parent, File file) throws Exception { @@ -57,6 +59,9 @@ public class MCAFile { if (!file.exists()) { throw new FaweException.FaweChunkLoadException(); } + String[] split = file.getName().split("\\."); + X = Integer.parseInt(split[1]); + Z = Integer.parseInt(split[2]); this.locations = new byte[4096]; this.raf = new BufferedRandomAccessFile(file, "rw", Settings.HISTORY.BUFFER_SIZE); raf.readFully(locations); @@ -78,6 +83,18 @@ public class MCAFile { this(parent, new File(parent.getSaveFolder(), "r." + mcrX + "." + mcrZ + ".mca")); } + public int getX() { + return X; + } + + public int getZ() { + return Z; + } + + public File getFile() { + return file; + } + public MCAChunk getCachedChunk(int cx, int cz) { int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31)); return chunks.get(pair); diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFilter.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFilter.java index 4b9d70dc..4834f303 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFilter.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFilter.java @@ -2,22 +2,62 @@ package com.boydti.fawe.jnbt.anvil; import com.sk89q.worldedit.blocks.BaseBlock; +/** + * MCAQueue.filterWorld(MCAFilter)
+ * - Read and modify the world + */ public class MCAFilter { + + /** + * Check whether a .mca file should be read + * @param mcaX + * @param mcaZ + * @return + */ public boolean appliesFile(int mcaX, int mcaZ) { return true; } + /** + * Do something with the MCAFile
+ * - Return null if you don't want to filter chunks
+ * - Return the same file if you do want to filter chunks
+ * @param file + * @return file or null + */ public MCAFile applyFile(MCAFile file) { return file; } + /** + * Check whether a chunk should be read + * @param cx + * @param cz + * @return + */ public boolean appliesChunk(int cx, int cz) { return true; } + /** + * Do something with the MCAChunk
+ * - Return null if you don't want to filter blocks
+ * - Return the chunk if you do want to filter blocks
+ * @param chunk + * @return + */ public MCAChunk applyChunk(MCAChunk chunk) { return chunk; } + /** + * Make changes to the block here
+ * - e.g. block.setId(...)
+ * - Note: Performance is critical here
+ * @param x + * @param y + * @param z + * @param block + */ public void applyBlock(int x, int y, int z, BaseBlock block) {} }