make sure that scoreboards get registered before all other functions
This commit is contained in:
parent
cf8c922704
commit
c36c87c3db
|
@ -7,7 +7,7 @@ fn main() {
|
|||
// create a new datapack
|
||||
let mut dp = Datapack::new("example", 16).with_supported_formats(16..=20);
|
||||
|
||||
dp.register_scoreboard("example_scoreboard", Some("dummy"), None);
|
||||
dp.register_scoreboard("example_scoreboard", None::<&str>, None::<&str>);
|
||||
|
||||
// get the namespace "example"
|
||||
let namespace = dp.namespace_mut("example");
|
||||
|
|
|
@ -195,10 +195,14 @@ impl Datapack {
|
|||
minecraft_namespace
|
||||
.to_mut()
|
||||
.tag_mut("load", tag::TagType::Function)
|
||||
.add_value(tag::TagValue::Simple(format!(
|
||||
.values_mut()
|
||||
.insert(
|
||||
0,
|
||||
tag::TagValue::Simple(format!(
|
||||
"{}:sb/register_scoreboards",
|
||||
self.main_namespace_name
|
||||
)));
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(uninstall_commands) = uninstall_commands {
|
||||
|
|
|
@ -37,10 +37,16 @@ impl Tag {
|
|||
|
||||
/// Get the values of the tag.
|
||||
#[must_use]
|
||||
pub fn get_values(&self) -> &Vec<TagValue> {
|
||||
pub fn values(&self) -> &[TagValue] {
|
||||
&self.values
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the values of the tag.
|
||||
#[must_use]
|
||||
pub fn values_mut(&mut self) -> &mut Vec<TagValue> {
|
||||
&mut self.values
|
||||
}
|
||||
|
||||
/// Add a value to the tag.
|
||||
pub fn add_value(&mut self, value: TagValue) {
|
||||
self.values.push(value);
|
||||
|
@ -186,7 +192,7 @@ mod tests {
|
|||
required: true,
|
||||
});
|
||||
|
||||
assert_eq!(tag.get_values().len(), 2);
|
||||
assert_eq!(tag.values().len(), 2);
|
||||
|
||||
let compiled = tag.compile(&CompileOptions::default(), &MutCompilerState::default());
|
||||
|
||||
|
|
Loading…
Reference in New Issue