Support reading litematic regions' name
This commit is contained in:
1 parent
b6b42f4ed0
commit
dddabe30cc
1 file changed
+5
-9
@@ -29,25 +29,21 @@ public class LitematicConverter implements AutoCloseable {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void read(
|
public void read(
|
||||||
BiConsumer<Integer, NbtCompound> schematicOutput
|
BiConsumer<String, NbtCompound> schematicOutput
|
||||||
) {
|
) {
|
||||||
if (root != null) throw new IllegalStateException("Litematica file is already read");
|
if (root != null) throw new IllegalStateException("Litematica file is already read");
|
||||||
root = NbtIo.readCompressed(input, sizeTracker).getCompound(NBT_LITEMATICA_ROOT);
|
root = NbtIo.readCompressed(input, sizeTracker).getCompound(NBT_LITEMATICA_ROOT);
|
||||||
var dataVersion = root.getInt("MinecraftDataVersion");
|
var dataVersion = root.getInt("MinecraftDataVersion");
|
||||||
var regionsNbt = root.getList("Regions", NbtElement.COMPOUND_TYPE);
|
var regionsNbt = root.getCompound("Regions");
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (NbtElement nbtElement : regionsNbt) {
|
for (String regionName : regionsNbt.getKeys()) {
|
||||||
var compound = (NbtCompound) nbtElement;
|
var compound = regionsNbt.getCompound(regionName);
|
||||||
var j = i++;
|
var j = i++;
|
||||||
var schematic = convertRegionToSchematic(dataVersion, compound);
|
var schematic = convertRegionToSchematic(dataVersion, compound);
|
||||||
schematicOutput.accept(j, schematic);
|
schematicOutput.accept(regionName, schematic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param region region
|
|
||||||
* @return a path to temp file.
|
|
||||||
*/
|
|
||||||
private NbtCompound convertRegionToSchematic(int dataVersion, NbtCompound region) {
|
private NbtCompound convertRegionToSchematic(int dataVersion, NbtCompound region) {
|
||||||
var worldEditTag = new NbtCompound();
|
var worldEditTag = new NbtCompound();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user