pub struct GameRuleValues {
values: Vec<GameRuleValue>,
}Expand description
Stores per-world game rule values.
This is separate from the registry - the registry holds static definitions,
while GameRuleValues holds the actual mutable values for a specific world.
Fields§
§values: Vec<GameRuleValue>Values indexed by game rule registry ID.
Implementations§
Source§impl GameRuleValues
impl GameRuleValues
Sourcepub fn new(registry: &GameRuleRegistry) -> Self
pub fn new(registry: &GameRuleRegistry) -> Self
Creates a new GameRuleValues with all default values from the registry.
Sourcepub fn get(
&self,
rule: GameRuleRef,
_registry: &GameRuleRegistry,
) -> GameRuleValue
pub fn get( &self, rule: GameRuleRef, _registry: &GameRuleRegistry, ) -> GameRuleValue
Gets the value of a game rule.
Sourcepub fn set(
&mut self,
rule: GameRuleRef,
value: GameRuleValue,
_registry: &GameRuleRegistry,
) -> bool
pub fn set( &mut self, rule: GameRuleRef, value: GameRuleValue, _registry: &GameRuleRegistry, ) -> bool
Sets the value of a game rule.
Returns true if the value was set, false if the type didn’t match
or the value is out of bounds.
Sourcepub fn get_by_name(
&self,
name: &str,
registry: &GameRuleRegistry,
) -> Option<GameRuleValue>
pub fn get_by_name( &self, name: &str, registry: &GameRuleRegistry, ) -> Option<GameRuleValue>
Gets a game rule value by name.
Sourcepub fn set_by_name(
&mut self,
name: &str,
value: GameRuleValue,
registry: &GameRuleRegistry,
) -> bool
pub fn set_by_name( &mut self, name: &str, value: GameRuleValue, registry: &GameRuleRegistry, ) -> bool
Sets a game rule value by name.
Returns true if the game rule was found and set, false if the rule
doesn’t exist, the value type doesn’t match, or the value is out of bounds.
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 Freeze for GameRuleValues
impl RefUnwindSafe for GameRuleValues
impl Send for GameRuleValues
impl Sync for GameRuleValues
impl Unpin for GameRuleValues
impl UnsafeUnpin for GameRuleValues
impl UnwindSafe 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