pub struct Experience {
level: i32,
progress: f32,
total_points: i32,
pub dirty: bool,
}Expand description
Vanilla player experience state.
These three fields are intentionally independent. Vanilla commands and save
data can change one without recomputing the others. The player’s score is
synchronized entity data and is owned by super::Player, not experience.
Fields§
§level: i32§progress: f32§total_points: i32§dirty: boolWhether the client experience packet needs to be sent.
Implementations§
Source§impl Experience
impl Experience
Sourcepub fn new(total_points: i32) -> Self
pub fn new(total_points: i32) -> Self
Builds a coherent experience state from a total point count.
Sourcepub const fn from_parts(level: i32, progress: f32, total_points: i32) -> Self
pub const fn from_parts(level: i32, progress: f32, total_points: i32) -> Self
Restores the three independent vanilla experience fields without normalizing them.
Sourcepub const fn points_for_level(level: i32) -> i32
pub const fn points_for_level(level: i32) -> i32
Points required to advance from level to level + 1.
Sourcepub const fn total_points_at_level(level: i32) -> i32
pub const fn total_points_at_level(level: i32) -> i32
Returns a coherent cumulative point count at the start of level.
This is a Steel construction helper, not a field vanilla derives at runtime.
Sourcepub const fn total_points(&self) -> i32
pub const fn total_points(&self) -> i32
Vanilla totalExperience.
Sourcepub const fn add_levels(&mut self, additional_levels: i32)
pub const fn add_levels(&mut self, additional_levels: i32)
Adds levels like vanilla Player.giveExperienceLevels.
Sourcepub fn add_points(&mut self, additional_points: i32)
pub fn add_points(&mut self, additional_points: i32)
Adds raw points like vanilla Player.giveExperiencePoints.
Sourcepub const fn set_levels(&mut self, level: i32)
pub const fn set_levels(&mut self, level: i32)
Sets the current level without changing progress or total experience.
Sourcepub const fn can_set_points(&self, points: i32) -> bool
pub const fn can_set_points(&self, points: i32) -> bool
Whether /experience set ... points accepts points at the current level.
Sourcepub fn set_points(&mut self, points: i32)
pub fn set_points(&mut self, points: i32)
Sets points within the current level like ServerPlayer.setExperiencePoints.
Sourcepub const fn death_xp_reward(&self) -> i32
pub const fn death_xp_reward(&self) -> i32
Base XP reward dropped on death: min(level * 7, 100).
Trait Implementations§
Source§impl Clone for Experience
impl Clone for Experience
Source§fn clone(&self) -> Experience
fn clone(&self) -> Experience
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Experience
Source§impl Debug for Experience
impl Debug for Experience
Source§impl Default for Experience
impl Default for Experience
Source§fn default() -> Experience
fn default() -> Experience
Auto Trait Implementations§
impl Freeze for Experience
impl RefUnwindSafe for Experience
impl Send for Experience
impl Sync for Experience
impl Unpin for Experience
impl UnsafeUnpin for Experience
impl UnwindSafe for Experience
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> 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<>>