pub struct HealthSyncState {
pub last_health: f32,
pub last_food: i32,
pub saturation_zero: bool,
}Expand description
Tracks the last health/food/saturation values sent to the client.
Fields§
§last_health: f32Last health value sent to the client.
last_food: i32Last food level sent to the client.
saturation_zero: boolWhether saturation was zero last time we sent health.
Implementations§
Source§impl HealthSyncState
impl HealthSyncState
Sourcepub fn needs_update(
&self,
health: f32,
food: i32,
saturation_zero: bool,
) -> bool
pub fn needs_update( &self, health: f32, food: i32, saturation_zero: bool, ) -> bool
Returns true if the given values differ from what was last sent.
Sourcepub const fn record_sent(
&mut self,
health: f32,
food: i32,
saturation_zero: bool,
)
pub const fn record_sent( &mut self, health: f32, food: i32, saturation_zero: bool, )
Records that we just sent the given values to the client.
Sourcepub const fn invalidate(&mut self)
pub const fn invalidate(&mut self)
Invalidates the state so the next tick will re-send.
Vanilla: resetSentInfo.
Sourcepub const fn reset_for_respawn(&mut self)
pub const fn reset_for_respawn(&mut self)
Resets to respawn defaults (forces re-send on next tick).
Auto Trait Implementations§
impl Freeze for HealthSyncState
impl RefUnwindSafe for HealthSyncState
impl Send for HealthSyncState
impl Sync for HealthSyncState
impl Unpin for HealthSyncState
impl UnsafeUnpin for HealthSyncState
impl UnwindSafe for HealthSyncState
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
Mutably borrows from an owned value. Read more
§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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>