net.minecraft.client.audio.SoundManager Java Examples

The following examples show how to use net.minecraft.client.audio.SoundManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoundManagerHook.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public static float getNormalizedVolume(SoundManager soundManager, ISound sound, SoundPoolEntry entry, SoundCategory category) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main != null && main.getUtils() != null && main.getUtils().isPlayingSound()) {
        return 1;
    } else {
        if (SkyblockAddonsTransformer.isLabymodClient()) { // There are no access transformers in labymod.
            try {
                if (getNormalizedVolume == null) {
                    getNormalizedVolume = soundManager.getClass().getDeclaredMethod("a", ISound.class, SoundPoolEntry.class, SoundCategory.class);
                    getNormalizedVolume.setAccessible(true);
                }
                if (getNormalizedVolume != null) {
                    return (float)getNormalizedVolume.invoke(soundManager, sound, entry, category);
                }
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
        } else {
            return soundManager.getNormalizedVolume(sound, entry, category);
        }
    }

    return 0.5F; // A good middle ground in case the labymod reflection fails.
}
 
Example #2
Source File: MoCSounds.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event)
{
    SoundManager manager = event.manager;

    for (String soundName : soundNames)
    {
        manager.soundPoolSounds.addSound(soundName, this.getClass().getResource("/drzhark/mocreatures/client/resources/newsound/" + soundName));
    }
    manager.soundPoolStreaming.addSound("shuffling.ogg", this.getClass().getResource("/drzhark/mocreatures/client/resources/streaming/shuffling.ogg"));
}