Skip to content

Commit

Permalink
➕ Add support for base-game-version
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixr-codes committed May 1, 2024
1 parent 7b4f41a commit bbd059e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use std::{collections::HashMap, path::PathBuf};

use crate::localization::{Language, LanguageGroups, OptionallyLocalized};
use crate::{
localization::{Language, LanguageGroups, OptionallyLocalized},
manifest::BaseGameVersion,
};
use serde::Deserialize;

/// A version string.
Expand Down Expand Up @@ -419,6 +422,9 @@ pub struct WT {
#[serde(default)]
pub allow_random_seed: bool,

#[serde(default)]
pub base_game_version: BaseGameVersion,

/// Override name for behavior pack.
#[serde(default)]
pub name: Option<OptionallyLocalized<String>>,
Expand Down
11 changes: 9 additions & 2 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ impl Manifest {
Pack::WorldTemplate => Some(project.config.wt.allow_random_seed),
_ => None,
},
base_game_version: None, // FIXME: this seems to be required for world templates
base_game_version: if pack == Pack::WorldTemplate {
Some(project.config.wt.base_game_version)
} else {
None
},
description: String::from("pack.description"),
lock_template_options: None,
min_engine_version: Some(version_from_string(
Expand Down Expand Up @@ -353,12 +357,15 @@ impl From<BehaviorPackType> for ModuleType {

/// In the header of your world template's manifest, you will need to specify the Minecraft version your
/// world template was created for using the `base_game_version` field.
#[derive(Debug, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub enum BaseGameVersion {
/// If your content is version agnostic (such as a simple survival spawn which
/// is unlikely to break from future updates), you can forgo locking your
/// content to a specific version by using a "wildcard": "base_game_version": "*".
#[default]
#[serde(rename = "*")]
Wild,

#[serde(untagged)]
Version(usize, usize, usize),
}
2 changes: 1 addition & 1 deletion src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Pack {
pub fn bundle_file_extension(&self) -> &'static str {
match self {
Self::Behavior | Self::Resource | Self::Skin => "mcpack",
Self::WorldTemplate => "mctemplate", // TODO: `mcworld`?
Self::WorldTemplate => "mctemplate",
}
}

Expand Down

0 comments on commit bbd059e

Please sign in to comment.