pub struct GameRuleValues {
values: Vec<GameRuleValue>,
}Expand description
Stores per-world game rule values.
Fields§
§values: Vec<GameRuleValue>Implementations§
Source§impl GameRuleValues
impl GameRuleValues
Sourcepub fn new(registry: &GameRuleRegistry) -> Self
pub fn new(registry: &GameRuleRegistry) -> Self
Creates values initialized from every registered game rule’s default.
Sourcepub fn get<T: GameRuleValueType>(
&self,
rule: &GameRule<T>,
registry: &GameRuleRegistry,
) -> T
pub fn get<T: GameRuleValueType>( &self, rule: &GameRule<T>, registry: &GameRuleRegistry, ) -> T
Gets the typed value of a game rule.
Sourcepub fn set<T: GameRuleValueType>(
&mut self,
rule: &GameRule<T>,
value: T,
registry: &GameRuleRegistry,
) -> bool
pub fn set<T: GameRuleValueType>( &mut self, rule: &GameRule<T>, value: T, registry: &GameRuleRegistry, ) -> bool
Sets the typed value of a game rule.
Sourcepub fn get_erased(
&self,
rule: &dyn ErasedGameRule,
registry: &GameRuleRegistry,
) -> &GameRuleValue
pub fn get_erased( &self, rule: &dyn ErasedGameRule, registry: &GameRuleRegistry, ) -> &GameRuleValue
Gets a type-erased value for a dynamically selected rule.
Sourcepub fn set_erased(
&mut self,
rule: &dyn ErasedGameRule,
value: GameRuleValue,
registry: &GameRuleRegistry,
) -> bool
pub fn set_erased( &mut self, rule: &dyn ErasedGameRule, value: GameRuleValue, registry: &GameRuleRegistry, ) -> bool
Sets a type-erased value for a dynamically selected rule.
Sourcepub fn set_serialized_by_name(
&mut self,
name: &str,
value: &Value,
registry: &GameRuleRegistry,
) -> bool
pub fn set_serialized_by_name( &mut self, name: &str, value: &Value, registry: &GameRuleRegistry, ) -> bool
Loads a serialized value for a game rule selected by name.
fn rule_id(rule: &dyn ErasedGameRule, registry: &GameRuleRegistry) -> usize
Trait Implementations§
Source§impl Clone for GameRuleValues
impl Clone for GameRuleValues
Source§fn clone(&self) -> GameRuleValues
fn clone(&self) -> GameRuleValues
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GameRuleValues
impl Debug for GameRuleValues
Source§impl Default for GameRuleValues
impl Default for GameRuleValues
Source§fn default() -> GameRuleValues
fn default() -> GameRuleValues
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for GameRuleValues
impl !UnwindSafe for GameRuleValues
impl Freeze for GameRuleValues
impl Send for GameRuleValues
impl Sync for GameRuleValues
impl Unpin for GameRuleValues
impl UnsafeUnpin for GameRuleValues
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
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> ⓘ
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<>>