mirror of
https://github.com/zyllian/classics.git
synced 2025-05-10 07:06:39 -07:00
rename level.level_rules to level.rules
This commit is contained in:
parent
7940dbf7d4
commit
b0abc32ca9
3 changed files with 10 additions and 10 deletions
|
@ -671,7 +671,7 @@ impl<'m> Command<'m> {
|
||||||
Command::LevelRule { rule, value } => {
|
Command::LevelRule { rule, value } => {
|
||||||
if rule == "all" {
|
if rule == "all" {
|
||||||
// get all rules
|
// get all rules
|
||||||
if let Some(rules) = data.level.level_rules.get_all_rules_info() {
|
if let Some(rules) = data.level.rules.get_all_rules_info() {
|
||||||
for (name, rule) in rules {
|
for (name, rule) in rules {
|
||||||
messages.push(format!("&f{name}: {rule}"));
|
messages.push(format!("&f{name}: {rule}"));
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ impl<'m> Command<'m> {
|
||||||
}
|
}
|
||||||
} else if let Some(value) = value {
|
} else if let Some(value) = value {
|
||||||
// set a rule
|
// set a rule
|
||||||
match data.level.level_rules.set_rule(rule, value) {
|
match data.level.rules.set_rule(rule, value) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
messages.push(format!("&fUpdated rule {rule}"));
|
messages.push(format!("&fUpdated rule {rule}"));
|
||||||
}
|
}
|
||||||
|
@ -690,7 +690,7 @@ impl<'m> Command<'m> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get a rule
|
// get a rule
|
||||||
if let Some(info) = data.level.level_rules.get_rule(rule) {
|
if let Some(info) = data.level.rules.get_rule(rule) {
|
||||||
messages.push(format!("&f{info}"));
|
messages.push(format!("&f{info}"));
|
||||||
} else {
|
} else {
|
||||||
messages.push(format!("Unknown rule: {rule}"));
|
messages.push(format!("Unknown rule: {rule}"));
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct Level {
|
||||||
pub weather: WeatherType,
|
pub weather: WeatherType,
|
||||||
/// the level's level rules
|
/// the level's level rules
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub level_rules: LevelRules,
|
pub rules: LevelRules,
|
||||||
|
|
||||||
/// index of blocks which need to be updated in the next tick
|
/// index of blocks which need to be updated in the next tick
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -65,7 +65,7 @@ impl Level {
|
||||||
z_size,
|
z_size,
|
||||||
blocks: vec![0; x_size * y_size * z_size],
|
blocks: vec![0; x_size * y_size * z_size],
|
||||||
weather: WeatherType::Sunny,
|
weather: WeatherType::Sunny,
|
||||||
level_rules: Default::default(),
|
rules: Default::default(),
|
||||||
awaiting_update: Default::default(),
|
awaiting_update: Default::default(),
|
||||||
possible_random_updates: Default::default(),
|
possible_random_updates: Default::default(),
|
||||||
updates: Default::default(),
|
updates: Default::default(),
|
||||||
|
|
|
@ -215,7 +215,7 @@ fn tick(data: &mut ServerData, tick: usize) {
|
||||||
// apply random tick updates
|
// apply random tick updates
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
level.possible_random_updates.shuffle(&mut rng);
|
level.possible_random_updates.shuffle(&mut rng);
|
||||||
for _ in 0..level.level_rules.random_tick_updates {
|
for _ in 0..level.rules.random_tick_updates {
|
||||||
if let Some(index) = level.possible_random_updates.pop() {
|
if let Some(index) = level.possible_random_updates.pop() {
|
||||||
level.awaiting_update.insert(index);
|
level.awaiting_update.insert(index);
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,7 @@ fn tick(data: &mut ServerData, tick: usize) {
|
||||||
.is_none_or(|id| id == 0x00)
|
.is_none_or(|id| id == 0x00)
|
||||||
{
|
{
|
||||||
dirt_count += 1;
|
dirt_count += 1;
|
||||||
if rng.gen_range(0..level.level_rules.grass_spread_chance) == 0 {
|
if rng.gen_range(0..level.rules.grass_spread_chance) == 0 {
|
||||||
dirt_count -= 1;
|
dirt_count -= 1;
|
||||||
level.updates.push(BlockUpdate {
|
level.updates.push(BlockUpdate {
|
||||||
index: level.index(nx, ny, nz),
|
index: level.index(nx, ny, nz),
|
||||||
|
@ -255,7 +255,7 @@ fn tick(data: &mut ServerData, tick: usize) {
|
||||||
.is_some_and(|id| id != 0x00)
|
.is_some_and(|id| id != 0x00)
|
||||||
{
|
{
|
||||||
dirt_count += 1;
|
dirt_count += 1;
|
||||||
if rng.gen_range(0..level.level_rules.grass_spread_chance) == 0 {
|
if rng.gen_range(0..level.rules.grass_spread_chance) == 0 {
|
||||||
dirt_count -= 1;
|
dirt_count -= 1;
|
||||||
level.updates.push(BlockUpdate {
|
level.updates.push(BlockUpdate {
|
||||||
index: level.index(x, y, z),
|
index: level.index(x, y, z),
|
||||||
|
@ -278,7 +278,7 @@ fn tick(data: &mut ServerData, tick: usize) {
|
||||||
stationary,
|
stationary,
|
||||||
ticks_to_spread,
|
ticks_to_spread,
|
||||||
} => {
|
} => {
|
||||||
if !level.level_rules.fluid_spread {
|
if !level.rules.fluid_spread {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if tick % ticks_to_spread == 0 {
|
if tick % ticks_to_spread == 0 {
|
||||||
|
@ -328,7 +328,7 @@ fn tick(data: &mut ServerData, tick: usize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockType::FluidStationary { moving } => {
|
BlockType::FluidStationary { moving } => {
|
||||||
if !level.level_rules.fluid_spread {
|
if !level.rules.fluid_spread {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut needs_update = false;
|
let mut needs_update = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue