Package net.minecraft.client.sounds
Class SoundManager
java.lang.Object
net.neoforged.neoforge.resource.ContextAwareReloadListener
net.minecraft.server.packs.resources.SimplePreparableReloadListener<SoundManager.Preparations>
net.minecraft.client.sounds.SoundManager
- All Implemented Interfaces:
PreparableReloadListener
The SoundManager class is responsible for managing sound events and playing sounds.
It handles sound event registrations, caching of sound resources, and sound playback.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe Preparations class represents the prepared sound event registrations and caches for applying to the sound manager.Nested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
PreparableReloadListener.PreparationBarrier -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Soundstatic final ResourceLocationprivate static final Gsonstatic final Soundstatic final WeighedSoundEventsstatic final ResourceLocation(package private) static final org.slf4j.Loggerprivate final Map<ResourceLocation, WeighedSoundEvents> private static final TypeToken<Map<String, SoundEventRegistration>> private final Map<ResourceLocation, Resource> private final SoundEngineprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(SoundEventListener pListener) protected voidapply(SoundManager.Preparations pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler) Applies the prepared sound event registrations and caches to the sound manager.voiddestroy()voidgetSoundEvent(ResourceLocation pLocation) Returns The sound event associated with the specific ResourceLocation, ornullif not found.booleanisActive(SoundInstance pSound) Checks if the specified sound is active (playing or scheduled to be played).voidpauseAllExcept(SoundSource... pSoundSources) play(SoundInstance pSound) voidplayDelayed(SoundInstance pSound, int pDelay) Plays a sound with a delay in ticks.protected SoundManager.Preparationsprepare(ResourceManager pResourceManager, ProfilerFiller pProfiler) Performs any reloading that can be done off-thread, such as file IOvoidqueueTickingSound(TickableSoundInstance pTickableSound) Queues a ticking sound to be played.voidreload()voidremoveListener(SoundEventListener pListener) voidresume()voidsetVolume(SoundInstance pSound, float pVolume) voidstop()voidstop(SoundInstance pSound) voidstop(ResourceLocation pId, SoundSource pCategory) Stops all sounds associated with the specified ID and category.voidtick(boolean pIsGamePaused) Updates the sound manager's tick state.voidupdateSource(Camera pActiveRenderInfo) Updates the sound source position based on the active render info.voidupdateSourceVolume(SoundSource pCategory, float pVolume) Updates the volume of the specified sound source category.(package private) static booleanvalidateSoundResource(Sound pSound, ResourceLocation pLocation, ResourceProvider pResourceProvider) Validates a sound resourceMethods inherited from class net.minecraft.server.packs.resources.SimplePreparableReloadListener
reloadMethods inherited from class net.neoforged.neoforge.resource.ContextAwareReloadListener
getContext, getRegistryLookup, injectContext, makeConditionalOps, makeConditionalOpsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
getName
-
Field Details
-
EMPTY_SOUND_LOCATION
-
EMPTY_SOUND
-
INTENTIONALLY_EMPTY_SOUND_LOCATION
-
INTENTIONALLY_EMPTY_SOUND_EVENT
-
INTENTIONALLY_EMPTY_SOUND
-
LOGGER
static final org.slf4j.Logger LOGGER -
SOUNDS_PATH
- See Also:
-
GSON
-
SOUND_EVENT_REGISTRATION_TYPE
-
registry
-
soundEngine
-
soundCache
-
-
Constructor Details
-
SoundManager
-
-
Method Details
-
prepare
protected SoundManager.Preparations prepare(ResourceManager pResourceManager, ProfilerFiller pProfiler) Performs any reloading that can be done off-thread, such as file IO- Specified by:
preparein classSimplePreparableReloadListener<SoundManager.Preparations>- Parameters:
pResourceManager- The resource manager in-charge of loading sound filespProfiler- The sound profiler
-
apply
protected void apply(SoundManager.Preparations pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler) Applies the prepared sound event registrations and caches to the sound manager.- Specified by:
applyin classSimplePreparableReloadListener<SoundManager.Preparations>- Parameters:
pObject- The prepared sound event registrations and cachespResourceManager- The resource managerpProfiler- The profiler
-
getAvailableSoundDevices
-
getListenerTransform
-
validateSoundResource
static boolean validateSoundResource(Sound pSound, ResourceLocation pLocation, ResourceProvider pResourceProvider) Validates a sound resource- Parameters:
pSound- The sound to validatepLocation- The location of the sound eventpResourceProvider- The resource provider- Returns:
trueif the sound resource is valid,falseotherwise
-
getSoundEvent
Returns The sound event associated with the specific ResourceLocation, ornullif not found.- Parameters:
pLocation- The location of the sound event- Returns:
- The sound event associated with the specific ResourceLocation, or
nullif not found
-
getAvailableSounds
-
queueTickingSound
Queues a ticking sound to be played.- Parameters:
pTickableSound- The ticking sound instance
-
play
-
playDelayed
Plays a sound with a delay in ticks.- Parameters:
pSound- The sound instance to playpDelay- The delay in ticks before playing the sound
-
updateSource
Updates the sound source position based on the active render info.- Parameters:
pActiveRenderInfo- The active render info
-
pauseAllExcept
-
stop
public void stop() -
destroy
public void destroy() -
emergencyShutdown
public void emergencyShutdown() -
tick
public void tick(boolean pIsGamePaused) Updates the sound manager's tick state.- Parameters:
pIsGamePaused-trueif the game is paused,falseotherwise
-
resume
public void resume() -
updateSourceVolume
Updates the volume of the specified sound source category.- Parameters:
pCategory- The sound source categorypVolume- The new volume
-
stop
-
setVolume
-
isActive
Checks if the specified sound is active (playing or scheduled to be played).- Parameters:
pSound- The sound instance to check- Returns:
trueif the sound is active,falseotherwise
-
addListener
-
removeListener
-
stop
Stops all sounds associated with the specified ID and category.- Parameters:
pId- The ID of the sounds to stop, or null to stop all soundspCategory- The category of the sounds to stop, or null to stop sounds from all categories
-
getDebugString
-
reload
public void reload()
-