Package etithespirit.orimod.event
Class EntityEmittedSoundEvent
java.lang.Object
etithespirit.orimod.event.EntityEmittedSoundEvent
An implementation of Forge PR #7941, this event is used
to intercept when a sound is played by a specific entity (as opposed to in general, which is what Forge's existing event does)
and potentially modify it using the context as to who/what played it.
- Author:
- Eti
-
Constructor Summary
ConstructorsConstructorDescriptionEntityEmittedSoundEvent
(net.minecraft.world.entity.Entity source, net.minecraft.world.phys.Vec3 position, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource category, float volume, float pitch) Create a new event describing that an entity has just played a sound. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.sounds.SoundSource
net.minecraft.sounds.SoundSource
float
net.minecraft.sounds.SoundEvent
float
net.minecraft.world.entity.Entity
float
getPitch()
net.minecraft.world.phys.Vec3
net.minecraft.sounds.SoundEvent
getSound()
float
boolean
void
setCanceled
(boolean cancel) Set whether or not to cancel this sound and stop it from playingvoid
setCategory
(net.minecraft.sounds.SoundSource category) Change the type of sound associated with this event.void
setPitch
(float value) Change the pitch of this sound.void
setSound
(net.minecraft.sounds.SoundEvent value) Change the sound associated with this event.void
setVolume
(float value) Change the volume of this sound.boolean
-
Constructor Details
-
EntityEmittedSoundEvent
public EntityEmittedSoundEvent(net.minecraft.world.entity.Entity source, net.minecraft.world.phys.Vec3 position, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource category, float volume, float pitch) Create a new event describing that an entity has just played a sound.- Parameters:
source
- The entity responsible for the sound.position
- The position at which this sound played in the world.sound
- The sound that is playing.category
- The category that this sound is a part of.volume
- The volume of this sound.pitch
- The pitch of this sound.
-
-
Method Details
-
wasModified
public boolean wasModified()- Returns:
- Whether or not some data was modified in this event, which determines if it should override vanilla sound playing behaviors. The cancellation state does not affect this return value.
-
getPosition
public net.minecraft.world.phys.Vec3 getPosition()- Returns:
- The position at which this sound will be played.
-
getSound
public net.minecraft.sounds.SoundEvent getSound()- Returns:
- The sound that should be played.
-
getCategory
public net.minecraft.sounds.SoundSource getCategory()- Returns:
- The category of the sound that should be played.
-
getVolume
public float getVolume()- Returns:
- The current override volume for this sound.
-
getPitch
public float getPitch()- Returns:
- The current override pitch for this sound.
-
getEntity
public net.minecraft.world.entity.Entity getEntity()- Returns:
- The entity that is responsible for playing this sound.
-
isCanceled
public boolean isCanceled()- Returns:
- True if this sound should no longer play.
-
getDefaultSound
public net.minecraft.sounds.SoundEvent getDefaultSound()- Returns:
- The sound that this event had when the event was first constructed.
-
getDefaultCategory
public net.minecraft.sounds.SoundSource getDefaultCategory()- Returns:
- The sound category that this sound started with when the event was constructed.
-
getDefaultVolume
public float getDefaultVolume()- Returns:
- The volume that this sound started with when the event was constructed.
-
getDefaultPitch
public float getDefaultPitch()- Returns:
- The pitch that this sound started with when the event was constructed.
-
setSound
public void setSound(net.minecraft.sounds.SoundEvent value) Change the sound associated with this event.- Parameters:
value
- The new sound.
-
setCategory
public void setCategory(net.minecraft.sounds.SoundSource category) Change the type of sound associated with this event.- Parameters:
category
- The new category this sound should play in.
-
setVolume
public void setVolume(float value) Change the volume of this sound.- Parameters:
value
- The new volume.
-
setPitch
public void setPitch(float value) Change the pitch of this sound.- Parameters:
value
- The new pitch.
-
setCanceled
public void setCanceled(boolean cancel) Set whether or not to cancel this sound and stop it from playing- Parameters:
cancel
- Whether or not this sound should be canceled.
-