Skip to content

Commit

Permalink
Support reading litematic regions' name
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Jan 6, 2025
1 parent b6b42f4 commit dddabe3
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/io/ib67/sfcraft/util/LitematicConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,21 @@ public LitematicConverter(InputStream input, NbtSizeTracker sizeTracker) {

@SneakyThrows
public void read(
BiConsumer<Integer, NbtCompound> schematicOutput
BiConsumer<String, NbtCompound> schematicOutput
) {
if (root != null) throw new IllegalStateException("Litematica file is already read");
root = NbtIo.readCompressed(input, sizeTracker).getCompound(NBT_LITEMATICA_ROOT);
var dataVersion = root.getInt("MinecraftDataVersion");
var regionsNbt = root.getList("Regions", NbtElement.COMPOUND_TYPE);
var regionsNbt = root.getCompound("Regions");
var i = 0;
for (NbtElement nbtElement : regionsNbt) {
var compound = (NbtCompound) nbtElement;
for (String regionName : regionsNbt.getKeys()) {
var compound = regionsNbt.getCompound(regionName);
var j = i++;
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) {
var worldEditTag = new NbtCompound();

Expand Down

0 comments on commit dddabe3

Please sign in to comment.