public static IByteBuffer WriteCompound(this IByteBuffer buffer, NbtCompound compound) { buffer.WriteByte(compound.Id); buffer.WriteShort(0); // empty name using (var stream = new MemoryStream()) { using var writer = new BinaryWriter(stream); compound.Serialize(writer); var serialized = stream.ToArray(); buffer.WriteBytes(serialized); } return(buffer); }