Trait LevelWriteHost
pub trait LevelWriteHost: LevelTicksHost + LevelRandomHost {
// Provided methods
fn set_block(
&mut self,
_pos: [i32; 3],
_state: BlockState,
_flags: BlockUpdateFlags,
) -> bool { ... }
fn remove_block(&mut self, _pos: [i32; 3], _moved: bool) -> bool { ... }
fn set_block_property(
&mut self,
_pos: [i32; 3],
_key: &str,
_value: &str,
_flags: i32,
) -> bool { ... }
fn play_sound(
&mut self,
_sound: &str,
_at: [f64; 3],
_source: usize,
_volume: f32,
_pitch: f32,
) -> bool { ... }
fn send_particles(
&mut self,
_options: &ParticleOptions,
_state: Option<BlockState>,
_at: [f64; 3],
_spread: [f64; 3],
_speed: f64,
_count: i32,
) -> bool { ... }
fn level_event(&mut self, _id: i32, _pos: [i32; 3], _data: i32) -> bool { ... }
}Expand description
Mutable level services, like vanilla’s ServerLevel.
Provided Methods§
fn set_block(
&mut self,
_pos: [i32; 3],
_state: BlockState,
_flags: BlockUpdateFlags,
) -> bool
fn set_block( &mut self, _pos: [i32; 3], _state: BlockState, _flags: BlockUpdateFlags, ) -> bool
Replace the block at pos with state through Level.setBlock(pos, state, flags), as
LevelRef::set_block does: the old block’s block entity goes and the new block’s is
created in the write, its neighbour and shape updates run per flags, and its level events
queue in order with the caller’s. A mod block entity starts with the data its
block_entity hook gives, which gets this level. True when the block changed; false off an
authoritative server, for a position that is not loaded or outside the build height, an
invalid state, or the state it already is. It never loads a chunk.
fn remove_block(&mut self, _pos: [i32; 3], _moved: bool) -> bool
fn remove_block(&mut self, _pos: [i32; 3], _moved: bool) -> bool
Remove a block through Level.removeBlock, preserving its fluid. moved marks a piston move.
fn set_block_property(
&mut self,
_pos: [i32; 3],
_key: &str,
_value: &str,
_flags: i32,
) -> bool
fn set_block_property( &mut self, _pos: [i32; 3], _key: &str, _value: &str, _flags: i32, ) -> bool
Change a block property through native_set_block_property.
fn play_sound(
&mut self,
_sound: &str,
_at: [f64; 3],
_source: usize,
_volume: f32,
_pitch: f32,
) -> bool
fn play_sound( &mut self, _sound: &str, _at: [f64; 3], _source: usize, _volume: f32, _pitch: f32, ) -> bool
Play a sound for nearby players through native_play_sound.
fn send_particles(
&mut self,
_options: &ParticleOptions,
_state: Option<BlockState>,
_at: [f64; 3],
_spread: [f64; 3],
_speed: f64,
_count: i32,
) -> bool
fn send_particles( &mut self, _options: &ParticleOptions, _state: Option<BlockState>, _at: [f64; 3], _spread: [f64; 3], _speed: f64, _count: i32, ) -> bool
ServerLevel.sendParticles through native_send_particles.
Item particles require options.item_stack; invalid stacks return false.
Implementations§
§impl dyn LevelWriteHost + '_
impl dyn LevelWriteHost + '_
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 LevelWriteHost + '_
impl AttachmentStore for dyn LevelWriteHost + '_
§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>
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>
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>
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>
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>
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>
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".