dart_nbt 0.1.2 copy "dart_nbt: ^0.1.2" to clipboard
dart_nbt: ^0.1.2 copied to clipboard

A Dart library for reading and writing Minecraft NBT (Named Binary Tag) data.

example/main.dart

import 'dart:typed_data';
import 'package:dart_nbt/dart_nbt.dart';

void main() {
  final Nbt nbt = Nbt();

  // Create a root NbtCompound and add a few example tags.
  final root = NbtCompound(name: 'SimpleRoot', value: [
    NbtString(name: 'ExampleString', value: 'Hello NBT'),
    NbtInt(name: 'ExampleInt', value: 12),
  ]);

  // Serialize the NBT structure to a Gzip-compressed Uint8List .
  final Uint8List nbtBytes = nbt.write(root, compression: NbtCompression.gzip);

  // Deserialize the Uint8List back into an NbtCompound.
  // The readNbt function automatically handles decompression.
  final NbtCompound nbtCompound = nbt.read(nbtBytes);

  // Print all values in the NbtCompound.
  for (final NbtTag tag in nbtCompound.value) {
    print('${tag.name}: ${tag.value}');
  }
}
1
likes
150
points
24
downloads

Publisher

verified publisherfrogperson.dev

Weekly Downloads

A Dart library for reading and writing Minecraft NBT (Named Binary Tag) data.

Repository (GitHub)
View/report issues

Topics

#minecraft #nbt

Documentation

API reference

License

MIT (license)

Dependencies

archive, buffer, typed_data

More

Packages that depend on dart_nbt