import 'package:libac_flutter/nbt/Stream.dart'; import 'UUID.dart'; class NbtUUID { final int MSB; final int LSB; const NbtUUID(this.MSB, this.LSB); static final NbtUUID ZERO = NbtUUID.fromUUID(UUID.ZERO); factory NbtUUID.fromUUID(UUID id) { ByteLayer layer = ByteLayer(); layer.writeBytes(id.getBytes()); layer.resetPosition(); int MSB = layer.readLong(); int LSB = layer.readLong(); return NbtUUID(MSB, LSB); } /// Returns the Most Significant Bits (MSB) long value of the UUID. int getMostSignificantBits() => MSB; /// Returns the Least Significant Bits (LSB) long value of the UUID. int getLeastSignificantBits() => LSB; UUID toUUID() { ByteLayer layer = ByteLayer(); layer.writeLong(MSB); layer.writeLong(LSB); return UUID(layer.readBytes(16)); } @override String toString() { return toUUID().toString(); } }