pub struct CSound {
pub sound_id: i32,
pub source: i32,
pub pos: IVec3,
pub volume: f32,
pub pitch: f32,
pub seed: i64,
}Expand description
Sent to play a sound effect at a specific position.
The position is encoded at 8x precision (divide by 8 to get actual block coordinates). This allows sub-block positioning for more accurate sound placement.
Fields§
§sound_id: i32The holder-encoded sound event ID (VarInt).
Vanilla reserves 0 for direct sound events, so registered sound events
are encoded as registry_id + 1.
source: i32The sound source category (VarInt).
pos: IVec3X position multiplied by 8 (fixed-point).
volume: f32Volume (1.0 = normal).
pitch: f32Pitch (1.0 = normal).
seed: i64Random seed for sound variations.
Implementations§
Source§impl CSound
impl CSound
Sourcepub fn new(
sound: SoundEventRef,
source: SoundSource,
pos: DVec3,
volume: f32,
pitch: f32,
seed: i64,
) -> Self
pub fn new( sound: SoundEventRef, source: SoundSource, pos: DVec3, volume: f32, pitch: f32, seed: i64, ) -> Self
Creates a new sound packet.
§Arguments
sound- Sound event to playsource- Sound source categoryx,y,z- Position in block coordinates (will be scaled by 8)volume- Volume multiplier (1.0 = normal)pitch- Pitch multiplier (1.0 = normal)seed- Random seed for sound variations
Sourcepub fn block_sound(
sound: SoundEventRef,
pos: BlockPos,
volume: f32,
pitch: f32,
seed: i64,
) -> Self
pub fn block_sound( sound: SoundEventRef, pos: BlockPos, volume: f32, pitch: f32, seed: i64, ) -> Self
Creates a block sound packet at the center of a block position.
§Arguments
sound- Sound event to playpos- Block position (will be centered at +0.5)volume- Volume multiplierpitch- Pitch multiplierseed- Random seed
Trait Implementations§
Source§impl ClientPacket for CSound
impl ClientPacket for CSound
Source§fn get_id(&self, protocol: ConnectionProtocol) -> Option<i32>
fn get_id(&self, protocol: ConnectionProtocol) -> Option<i32>
Gets the ID of the packet for the given protocol.
Source§fn write_packet(
&self,
writer: &mut impl Write,
protocol: ConnectionProtocol,
) -> Result<(), PacketError>
fn write_packet( &self, writer: &mut impl Write, protocol: ConnectionProtocol, ) -> Result<(), PacketError>
Writes the packet to the given writer. Read more
Auto Trait Implementations§
impl Freeze for CSound
impl RefUnwindSafe for CSound
impl Send for CSound
impl Sync for CSound
impl Unpin for CSound
impl UnsafeUnpin for CSound
impl UnwindSafe for CSound
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<>>