Package dev.jaxydog.astral.content.sound
Record Class SoundContext
java.lang.Object
java.lang.Record
dev.jaxydog.astral.content.sound.SoundContext
- Record Components:
event- The sound event.category- The sound category.volume- The sound volume.pitch- The sound pitch.pitchVariance- The amount of variation in the sound pitch.
public record SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float volume, float pitch, float pitchVariance)
extends Record
A sound context.
This is most useful for playing sounds that generally share the same traits without repeating code.
- Since:
- 2.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category) A sound context.SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float pitch) A sound context.SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float volume, float pitch) A sound context.SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float volume, float pitch, float pitchVariance) Creates an instance of aSoundContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.sound.SoundCategorycategory()Returns the value of thecategoryrecord component.final booleanIndicates whether some other object is "equal to" this one.net.minecraft.sound.SoundEventevent()Returns the value of theeventrecord component.final inthashCode()Returns a hash code value for this object.floatpitch()Returns the value of thepitchrecord component.floatpitch(net.minecraft.util.math.random.Random random) Returns the sound pitch with a random variance applied.floatReturns the value of thepitchVariancerecord component.voidplay(net.minecraft.world.World world, double x, double y, double z) Plays a sound at the provided position within the world.voidplay(net.minecraft.world.World world, net.minecraft.entity.Entity entity) Plays a sound centered on the provided entity.voidplay(net.minecraft.world.World world, net.minecraft.util.math.BlockPos blockPos) Plays a sound centered on the provided block position.voidplay(net.minecraft.world.World world, net.minecraft.util.math.BlockPos blockPos, boolean useDistance) Plays a sound centered on the provided block position.voidplay(net.minecraft.world.World world, net.minecraft.util.math.Vec3d position) Plays a sound at the provided position within the world.final StringtoString()Returns a string representation of this record class.floatvolume()Returns the value of thevolumerecord component.
-
Field Details
-
BURP
A player's burping sound.- Since:
- 2.0.0
-
-
Constructor Details
-
SoundContext
public SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float volume, float pitch) A sound context.This is most useful for playing sounds that generally share the same traits without repeating code.
By default, a pitch variance of
0.625Fis used.- Parameters:
event- The sound event.category- The sound category.volume- The sound volume.pitch- The sound pitch.- Since:
- 2.0.0
-
SoundContext
public SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float pitch) A sound context.This is most useful for playing sounds that generally share the same traits without repeating code.
By default, a volume of
1Fand a pitch variance of0.625Fis used.- Parameters:
event- The sound event.category- The sound category.pitch- The sound pitch.- Since:
- 2.0.0
-
SoundContext
public SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category) A sound context.This is most useful for playing sounds that generally share the same traits without repeating code.
By default, a volume of
1F, a pitch of1F, and a pitch variance of0.625Fis used.- Parameters:
event- The sound event.category- The sound category.- Since:
- 2.0.0
-
SoundContext
public SoundContext(net.minecraft.sound.SoundEvent event, net.minecraft.sound.SoundCategory category, float volume, float pitch, float pitchVariance) Creates an instance of aSoundContextrecord class.- Parameters:
event- the value for theeventrecord componentcategory- the value for thecategoryrecord componentvolume- the value for thevolumerecord componentpitch- the value for thepitchrecord componentpitchVariance- the value for thepitchVariancerecord component
-
-
Method Details
-
pitch
public float pitch(net.minecraft.util.math.random.Random random) Returns the sound pitch with a random variance applied.- Parameters:
random- A random number generator.- Returns:
- A varied pitch.
- Since:
- 2.0.0
-
play
public void play(net.minecraft.world.World world, double x, double y, double z) Plays a sound at the provided position within the world.- Parameters:
world- The world.x- The X position.y- The Y position.z- The Z position.- Since:
- 2.0.0
-
play
public void play(net.minecraft.world.World world, net.minecraft.util.math.Vec3d position) Plays a sound at the provided position within the world.- Parameters:
world- The world.position- The position.- Since:
- 2.0.0
-
play
public void play(net.minecraft.world.World world, net.minecraft.entity.Entity entity) Plays a sound centered on the provided entity.- Parameters:
world- The world.entity- The entity.- Since:
- 2.0.0
-
play
public void play(net.minecraft.world.World world, net.minecraft.util.math.BlockPos blockPos, boolean useDistance) Plays a sound centered on the provided block position.- Parameters:
world- The world.blockPos- The position.useDistance- Whether to use distance to determine if the sound should be played.- Since:
- 2.0.0
-
play
public void play(net.minecraft.world.World world, net.minecraft.util.math.BlockPos blockPos) Plays a sound centered on the provided block position.- Parameters:
world- The world.blockPos- The position.- Since:
- 2.0.0
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
event
public net.minecraft.sound.SoundEvent event()Returns the value of theeventrecord component.- Returns:
- the value of the
eventrecord component
-
category
public net.minecraft.sound.SoundCategory category()Returns the value of thecategoryrecord component.- Returns:
- the value of the
categoryrecord component
-
volume
public float volume()Returns the value of thevolumerecord component.- Returns:
- the value of the
volumerecord component
-
pitch
public float pitch()Returns the value of thepitchrecord component.- Returns:
- the value of the
pitchrecord component
-
pitchVariance
public float pitchVariance()Returns the value of thepitchVariancerecord component.- Returns:
- the value of the
pitchVariancerecord component
-