Trait LevelRandomHost
pub trait LevelRandomHost: LevelHost {
// Provided methods
fn attachments(&mut self) -> &mut dyn AttachmentStore { ... }
fn random(&mut self) -> Option<LegacyRandom> { ... }
fn set_random(&mut self, _random: LegacyRandom) -> bool { ... }
}Expand description
Access vanilla’s Level.random, so draws come in vanilla’s order.
Provided Methods§
fn attachments(&mut self) -> &mut dyn AttachmentStore
fn attachments(&mut self) -> &mut dyn AttachmentStore
The holders’ server-owned attachments; TYPE.get(host, holder) reads one through it.
fn random(&mut self) -> Option<LegacyRandom>
fn random(&mut self) -> Option<LegacyRandom>
A copy of the level’s random stream through native_level_random, or None on a
non-authoritative level. Draw with with_random, which stores it back.
fn set_random(&mut self, _random: LegacyRandom) -> bool
fn set_random(&mut self, _random: LegacyRandom) -> bool
Replace the level’s random stream with random, one random gave and the mod drew from.
False on a non-authoritative level.
Implementations§
§impl dyn LevelRandomHost + '_
impl dyn LevelRandomHost + '_
pub fn with_random<T>(
&mut self,
draw: impl FnOnce(&mut LegacyRandom) -> T,
) -> Option<T>
pub fn with_random<T>( &mut self, draw: impl FnOnce(&mut LegacyRandom) -> T, ) -> Option<T>
Draw from the level’s own random stream, in vanilla’s order: draw gets the
stream and the level keeps it after. None on a non-authoritative level.
Trait Implementations§
§impl AttachmentStore for dyn LevelRandomHost + '_
impl AttachmentStore for dyn LevelRandomHost + '_
§fn holds(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
) -> Result<bool, AttachmentError>
fn holds( &mut self, holder: Holder, namespace: &str, name: &str, ) -> Result<bool, AttachmentError>
Whether
holder keeps a value under namespace:name, saved or decoded.§fn decoded(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
) -> Result<Option<Arc<dyn Any + Send + Sync>>, AttachmentError>
fn decoded( &mut self, holder: Holder, namespace: &str, name: &str, ) -> Result<Option<Arc<dyn Any + Send + Sync>>, AttachmentError>
The value under
namespace:name if it has been decoded.§fn saved(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
) -> Result<Option<BTreeMap<JavaString, Tag>>, AttachmentError>
fn saved( &mut self, holder: Holder, namespace: &str, name: &str, ) -> Result<Option<BTreeMap<JavaString, Tag>>, AttachmentError>
The saved form under
namespace:name if it hasn’t been decoded yet.§fn store(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
value: Arc<dyn Any + Send + Sync>,
form: AttachmentForm,
) -> Result<(), AttachmentError>
fn store( &mut self, holder: Holder, namespace: &str, name: &str, value: Arc<dyn Any + Send + Sync>, form: AttachmentForm, ) -> Result<(), AttachmentError>
Keep
value under namespace:name, with what comes with it.§fn discard(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
sync: bool,
) -> Result<(), AttachmentError>
fn discard( &mut self, holder: Holder, namespace: &str, name: &str, sync: bool, ) -> Result<(), AttachmentError>
Drop the value under
namespace:name, saved or decoded; clients hear of it if sync.§fn queue_sync(
&mut self,
holder: Holder,
namespace: &str,
name: &str,
) -> Result<(), AttachmentError>
fn queue_sync( &mut self, holder: Holder, namespace: &str, name: &str, ) -> Result<(), AttachmentError>
Send the value under
namespace:name to the clients that see the holder again.Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".