Skip to main content

yog_formats/
manifest.rs

1//! `yog.toml` — a mod project's manifest (TOML, read into Yog Data).
2
3use yog_data::{Ordered, Schema, Text, Value};
4
5/// `[mod]`.
6#[derive(Schema)]
7pub struct ModSection {
8    /// The mod's id — its namespace (`mymod`).
9    pub id: String,
10    /// Shown name: text or a `.yres` text (`@Strings.mod_name`).
11    pub name: Option<Text>,
12    pub version: Option<String>,
13    pub description: Option<Text>,
14    /// An image source or a `.yres` image (`@Icons.logo`).
15    pub icon: Option<yog_data::Image>,
16    #[data(default)]
17    pub authors: Vec<String>,
18    pub license: Option<String>,
19    /// License of the generated exports crate (default MIT OR Apache-2.0).
20    pub exports_license: Option<String>,
21    /// The Minecraft version whose vanilla content the mod names (its
22    /// datapack: `1.21.1`) — the newest Yog supports by default. On other
23    /// versions renamed content is mapped (`short_grass` is `grass` on 1.20.1).
24    pub datapack: Option<String>,
25    /// Rust edition (default 2024).
26    pub edition: Option<String>,
27}
28
29/// `[dev]`.
30#[derive(Schema)]
31pub struct DevSection {
32    /// A local yog-api checkout to build against.
33    pub yog_api_path: Option<String>,
34}
35
36/// `[external.<namespace>]`: the other mods' content this mod names.
37#[derive(Schema)]
38pub struct ExternalSection {
39    #[data(default)]
40    pub items: Vec<String>,
41    #[data(default)]
42    pub blocks: Vec<String>,
43    #[data(default)]
44    pub entities: Vec<String>,
45    #[data(default)]
46    pub recipes: Vec<String>,
47}
48
49/// A whole `yog.toml`.
50#[derive(Schema)]
51pub struct ManifestFile {
52    #[data(rename = "mod")]
53    pub module: ModSection,
54    pub dev: Option<DevSection>,
55    /// Crates as Cargo writes them; `exports` is the other Yog mods'.
56    #[data(default)]
57    pub dependencies: Ordered<Value>,
58    #[data(rename = "dev-dependencies", default)]
59    pub dev_dependencies: Ordered<Value>,
60    #[data(default)]
61    pub external: Ordered<ExternalSection>,
62}
63
64/// What a built `.yog` says about its mod (`yog_ids::archive::MANIFEST`):
65/// what the loader shows of it and orders the mods by, without the project.
66#[derive(Schema, Debug, Clone, Default, PartialEq)]
67pub struct Built {
68    pub id: String,
69    pub name: String,
70    pub version: String,
71    #[data(default)]
72    pub description: String,
73    #[data(default)]
74    pub authors: Vec<String>,
75    #[data(default)]
76    pub license: String,
77    /// The platforms it has natives for.
78    #[data(default)]
79    pub platforms: Vec<String>,
80    /// The translation keys of `name` and `description`, when they're `.yres` texts.
81    pub name_key: Option<String>,
82    pub description_key: Option<String>,
83    /// Its icon, an image source.
84    pub icon: Option<String>,
85    /// The Yog mods it needs loaded before it, by id.
86    #[data(default)]
87    pub dependencies: Vec<String>,
88}