pub struct LevelData {Show 13 fields
pub seed: i64,
pub game_time: i64,
pub(crate) world_clocks: WorldClockManager,
pub spawn: SpawnPoint,
pub respawn: Option<RespawnData>,
pub weather: WeatherState,
pub world_border: WorldBorderData,
pub difficulty: Difficulty,
pub difficulty_locked: bool,
pub game_rules: FxHashMap<String, Value>,
pub game_rules_values: GameRuleValues,
pub initialized: bool,
pub generation: Option<WorldGenerationSettings>,
}Expand description
Persistent level data that gets saved to disk.
Fields§
§seed: i64World seed for terrain generation.
game_time: i64Total game time in ticks.
world_clocks: WorldClockManagerIndependently advancing world-clock instances for this loaded world.
spawn: SpawnPointWorld spawn point.
respawn: Option<RespawnData>Vanilla global respawn data for this domain, stored on the domain default world.
weather: WeatherStateWeather state.
world_border: WorldBorderDataPersistent world border state.
difficulty: DifficultyWorld difficulty.
difficulty_locked: boolWhether the difficulty is locked.
game_rules: FxHashMap<String, Value>Game rules (stored as name -> value pairs for serialization).
game_rules_values: GameRuleValuesRuntime game rule values (not serialized, loaded from game_rules).
initialized: boolWhether the world has been initialized.
generation: Option<WorldGenerationSettings>Generator settings this persisted world was created with.
Implementations§
Source§impl LevelData
impl LevelData
Sourcepub fn new_with_seed(seed: i64) -> Self
pub fn new_with_seed(seed: i64) -> Self
Creates new level data with the given seed.
Sourcepub fn new_with_seed_and_difficulty(seed: i64, difficulty: Difficulty) -> Self
pub fn new_with_seed_and_difficulty(seed: i64, difficulty: Difficulty) -> Self
Creates new level data with the given seed and difficulty.
Sourcepub fn validate_generation_settings(
&mut self,
expected: WorldGenerationSettings,
) -> Result<bool>
pub fn validate_generation_settings( &mut self, expected: WorldGenerationSettings, ) -> Result<bool>
Verifies saved generator metadata against the current config.
Returns whether missing metadata was adopted and should be saved.
Sourcepub fn load_game_rules(&mut self)
pub fn load_game_rules(&mut self)
Loads game rules from the serialized map into the runtime values.
Sourcepub fn save_game_rules(&mut self)
pub fn save_game_rules(&mut self)
Saves game rules from the runtime values to the serialized map.
Sourcepub const fn set_spawn_pos(&mut self, pos: BlockPos)
pub const fn set_spawn_pos(&mut self, pos: BlockPos)
Sets the spawn position from a BlockPos.
Sourcepub fn respawn_data_or_local(&self, dimension: &Identifier) -> RespawnData
pub fn respawn_data_or_local(&self, dimension: &Identifier) -> RespawnData
Returns saved respawn data, or the legacy local spawn as a compatibility default.
Sourcepub fn set_respawn_data(&mut self, respawn_data: RespawnData)
pub fn set_respawn_data(&mut self, respawn_data: RespawnData)
Sets the saved respawn data.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LevelData
impl<'de> Deserialize<'de> for LevelData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !RefUnwindSafe for LevelData
impl !UnwindSafe for LevelData
impl Freeze for LevelData
impl Send for LevelData
impl Sync for LevelData
impl Unpin for LevelData
impl UnsafeUnpin for LevelData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>