Search in sources :

Example 6 with SoundHandler

use of net.minecraft.client.audio.SoundHandler in project BetterRain by OreCruncher.

the class Emitter method update.

public void update() {
    final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
    if (this.activeSound != null) {
        if (handler.isSoundPlaying(this.activeSound))
            return;
        ModLog.debug("FADE: " + this.activeSound.toString());
        this.activeSound.fadeAway();
        this.activeSound = null;
        this.repeatDelay = this.effect.getRepeat(RANDOM);
        if (this.repeatDelay > 0)
            return;
    } else if (this.repeatDelay > 0) {
        if (--this.repeatDelay > 0)
            return;
    }
    // down a sound.
    if (SoundSystemConfig.getMasterGain() <= 0)
        return;
    final PlayerSound theSound = new PlayerSound(effect);
    if (this.effect.type == SoundType.PERIODIC) {
        this.repeatDelay = this.effect.getRepeat(RANDOM);
    } else {
        this.activeSound = theSound;
    }
    try {
        SoundManager.playSound(theSound);
    } catch (final Throwable t) {
        ;
    }
}
Also used : SoundHandler(net.minecraft.client.audio.SoundHandler)

Example 7 with SoundHandler

use of net.minecraft.client.audio.SoundHandler in project BetterRain by OreCruncher.

the class DynSurroundConfigGui method generateSoundVolumeList.

protected void generateSoundVolumeList(final ConfigCategory cat) {
    cat.setRequiresMcRestart(false);
    cat.setRequiresWorldRestart(false);
    final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
    final List<String> sounds = new ArrayList<String>();
    for (final Object resource : handler.sndRegistry.getKeys()) sounds.add(resource.toString());
    Collections.sort(sounds);
    for (final String sound : sounds) {
        final Property prop = new Property(sound, "100", Property.Type.INTEGER);
        prop.setMinValue(0);
        prop.setMaxValue(200);
        prop.setDefaultValue(100);
        prop.setRequiresMcRestart(false);
        prop.setRequiresWorldRestart(false);
        prop.set(MathHelper.floor_float(SoundRegistry.getVolumeScale(sound) * 100));
        prop.setConfigEntryClass(NumberSliderEntry.class);
        cat.put(sound, prop);
    }
}
Also used : SoundHandler(net.minecraft.client.audio.SoundHandler) ArrayList(java.util.ArrayList) Property(net.minecraftforge.common.config.Property)

Aggregations

SoundHandler (net.minecraft.client.audio.SoundHandler)7 ArrayList (java.util.ArrayList)3 Property (net.minecraftforge.common.config.Property)2 Minecraft (net.minecraft.client.Minecraft)1 PositionedSoundRecord (net.minecraft.client.audio.PositionedSoundRecord)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 GenerateBlockReport (org.blockartistry.mod.DynSurround.client.footsteps.game.user.GenerateBlockReport)1