Код: Выделить всё
if (is == null) {
throw new IOException("Schematic file not found");
}
Код: Выделить всё
CompoundTag root;
try (InputStream byteStream = new ByteArrayInputStream(data);
DataInputStream dataStream = new DataInputStream(byteStream)) {
root = NbtIo.read(dataStream);
} catch (ZipException e) {
throw new IOException("Failed to read NBT data", e);
}
System.out.println("Root Tag:");
System.out.println(root);
short width = root.getShort("Width");
short height = root.getShort("Height");
short length = root.getShort("Length");
ListTag blocks = root.getList("BlockEntities", Tag.TAG_INT);
ListTag blocksdata = root.getList("Palette", Tag.TAG_BYTE);
Код: Выделить всё
System.out.println("Blocks list size: " + blocks.size());
System.out.println("Palette data list size: " + blocksdata.size());
Подробнее здесь: https://stackoverflow.com/questions/788 ... n-throwing
Мобильная версия