core/metadata_writer: add enabled features to metadata

Only consider sign support enabled when at least one pattern is
configured.
This commit is contained in:
Matthias Schiffer 2024-01-07 20:05:39 +01:00
parent 7daddd6bbc
commit 625f2a13a3
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -44,6 +44,13 @@ struct Spawn {
z: i32,
}
/// Keeps track of enabled MinedMap features
#[derive(Debug, Serialize)]
struct Features {
/// Sign layer
signs: bool,
}
/// Viewer metadata JSON data structure
#[derive(Debug, Serialize)]
struct Metadata<'t> {
@ -51,6 +58,8 @@ struct Metadata<'t> {
mipmaps: Vec<Mipmap<'t>>,
/// Initial spawn point for new players
spawn: Spawn,
/// Enabled MinedMap features
features: Features,
}
/// Viewer entity JSON data structure
@ -159,9 +168,14 @@ impl<'a> MetadataWriter<'a> {
pub fn run(self) -> Result<()> {
let level_dat = self.read_level_dat()?;
let features = Features {
signs: !self.config.sign_patterns.is_empty(),
};
let mut metadata = Metadata {
mipmaps: Vec::new(),
spawn: Self::spawn(&level_dat),
features,
};
for tile_map in self.tiles.iter() {