mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-24 11:36:52 +01:00
Chunk deletion through API
This commit is contained in:
parent
b261a5c8b8
commit
05125ac664
@ -39,7 +39,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/replaceall", "/rea", "/repall" },
|
||||
aliases = {"/replaceall", "/rea", "/repall"},
|
||||
usage = "<folder> [from-block] <to-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 = "<folder> [from-block] <to-pattern>",
|
||||
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 = "<folder> [hasSky] <id>",
|
||||
desc = "Count all blocks in a world",
|
||||
flags = "d",
|
||||
|
@ -191,7 +191,10 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
streamer.readFully();
|
||||
}
|
||||
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
setModified();
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return modified;
|
||||
|
@ -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<Integer, MCAChunk> 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);
|
||||
|
@ -2,22 +2,62 @@ package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* MCAQueue.filterWorld(MCAFilter)<br>
|
||||
* - 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<br>
|
||||
* - Return null if you don't want to filter chunks<br>
|
||||
* - Return the same file if you do want to filter chunks<br>
|
||||
* @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<br>
|
||||
* - Return null if you don't want to filter blocks<br>
|
||||
* - Return the chunk if you do want to filter blocks<br>
|
||||
* @param chunk
|
||||
* @return
|
||||
*/
|
||||
public MCAChunk applyChunk(MCAChunk chunk) {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make changes to the block here<br>
|
||||
* - e.g. block.setId(...)<br>
|
||||
* - Note: Performance is critical here<br>
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
*/
|
||||
public void applyBlock(int x, int y, int z, BaseBlock block) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user