Fix remapping from pmmp
This commit is contained in:
parent
9a45b364f6
commit
a61e1fa96a
@ -491,7 +491,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
public void run(Path path, BasicFileAttributes attr) {
|
||||
try {
|
||||
String name = path.getFileName().toString();
|
||||
if (!name.endsWith(".mca")) {
|
||||
if (!name.endsWith(".mca") && !name.endsWith(".mcapm")) {
|
||||
return;
|
||||
}
|
||||
if (!filter.appliesFile(path, attr)) {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.jnbt.anvil.filters;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFile;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||
import com.boydti.fawe.jnbt.anvil.MutableMCABackedBaseBlock;
|
||||
import com.boydti.fawe.object.clipboard.ClipboardRemapper;
|
||||
@ -11,6 +12,7 @@ import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -18,6 +20,7 @@ import java.util.Map;
|
||||
public class RemapFilter extends MCAFilterCounter {
|
||||
private final ClipboardRemapper remapper;
|
||||
private final ClipboardRemapper.RemapPlatform from;
|
||||
private boolean skipRemap;
|
||||
|
||||
public RemapFilter(ClipboardRemapper remapper) {
|
||||
this.remapper = remapper;
|
||||
@ -29,8 +32,16 @@ public class RemapFilter extends MCAFilterCounter {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAFile applyFile(MCAFile mca) {
|
||||
File file = mca.getFile();
|
||||
this.skipRemap = file.getName().endsWith(".mcapm");
|
||||
return super.applyFile(mca);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||
if (skipRemap) return null;
|
||||
return super.applyChunk(chunk, cache);
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,14 @@ public class ConvertCommands extends MethodCommands {
|
||||
@Command(
|
||||
aliases = {"anvil2leveldb"},
|
||||
usage = "<folder>",
|
||||
help = "Convert the world between MCPE/PC values\n",
|
||||
desc = "Convert the world between MCPE/PC values\n",
|
||||
desc = "Convert the world between MCPE/PC values",
|
||||
help = "Convert the world between MCPE/PC values\n" +
|
||||
"The -r filter will skip block remapping",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.anvil2leveldb")
|
||||
public void anvil2leveldb(Player player, String folder, @Switch('f') boolean force) throws WorldEditException {
|
||||
public void anvil2leveldb(Player player, String folder, @Switch('f') boolean force, @Switch('r') boolean skipRemap) throws WorldEditException {
|
||||
ClipboardRemapper mapper;
|
||||
RemapFilter filter = new RemapFilter(ClipboardRemapper.RemapPlatform.PC, ClipboardRemapper.RemapPlatform.PE);
|
||||
|
||||
@ -49,7 +50,7 @@ public class ConvertCommands extends MethodCommands {
|
||||
@Override
|
||||
public void run(MCAChunk value) {
|
||||
try {
|
||||
converter.write(value);
|
||||
converter.write(value, !skipRemap);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ public class MCAFile2LevelDB implements Closeable {
|
||||
private boolean closed;
|
||||
private LongAdder submitted = new LongAdder();
|
||||
|
||||
private boolean remap;
|
||||
|
||||
public MCAFile2LevelDB(File folder) {
|
||||
try {
|
||||
this.folder = folder;
|
||||
@ -102,7 +104,7 @@ public class MCAFile2LevelDB implements Closeable {
|
||||
@Override
|
||||
public void run(MCAChunk value) {
|
||||
try {
|
||||
write(value);
|
||||
write(value, !file.getFile().getName().endsWith(".mcapm"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -204,7 +206,7 @@ public class MCAFile2LevelDB implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
public void write(MCAChunk chunk) throws IOException {
|
||||
public void write(MCAChunk chunk, boolean remap) throws IOException {
|
||||
submitted.add(1);
|
||||
if ((submitted.longValue() & 127) == 0) {
|
||||
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
@ -271,10 +273,17 @@ public class MCAFile2LevelDB implements Closeable {
|
||||
byte[] skyLight = chunk.skyLight[layer];
|
||||
byte[] blockLight = chunk.blockLight[layer];
|
||||
|
||||
copySection(ids, value, 1);
|
||||
copySection(data, value, 1 + 4096);
|
||||
copySection(skyLight, value, 1 + 4096 + 2048);
|
||||
copySection(blockLight, value, 1 + 4096 + 2048 + 2048);
|
||||
if (remap) {
|
||||
copySection(ids, value, 1);
|
||||
copySection(data, value, 1 + 4096);
|
||||
copySection(skyLight, value, 1 + 4096 + 2048);
|
||||
copySection(blockLight, value, 1 + 4096 + 2048 + 2048);
|
||||
} else {
|
||||
System.arraycopy(ids, 0, value, 1, ids.length);
|
||||
System.arraycopy(data, 0, value, 1 + 4096, data.length);
|
||||
System.arraycopy(skyLight, 0, value, 1 + 4096 + 2048, skyLight.length);
|
||||
System.arraycopy(blockLight, 0, value, 1 + 4096 + 2048 + 2048, blockLight.length);
|
||||
}
|
||||
}
|
||||
update(key, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user