Example usage for net.minecraftforge.client.event.sound PlaySoundEvent getSound

List of usage examples for net.minecraftforge.client.event.sound PlaySoundEvent getSound

Introduction

In this page you can find the example usage for net.minecraftforge.client.event.sound PlaySoundEvent getSound.

Prototype

public ISound getSound() 

Source Link

Usage

From source file:com.masl.mp3Jukebox.Player.java

License:Open Source License

@SubscribeEvent
@SideOnly(Side.CLIENT)//ww w. j av  a 2 s .  c  om
public void PlaySoundEvent(PlaySoundEvent event) {

    if (event.getSound().getCategory() == SoundCategory.MUSIC && soundPlaying) {

        mp3Jukebox.logger.log(Level.DEBUG, "Stoped Streamed Sound:  " + event.getSound().getCategory());

        event.setResultSound(null);
    } else if (event.getSound().getCategory() == SoundCategory.MUSIC) {
        currentMusic = event.getSound();
    }
}

From source file:jayavery.accesstweaks.Sounds.java

License:Open Source License

/** Play or prevent sound and subtitle according to settings.
 * This event catches some entity & all other sounds */
@SubscribeEvent/*from   w w w  . j a v  a 2  s  .  c om*/
public static void playSound(PlaySoundEvent event) {

    ISound sound = event.getSound();
    SoundCategory category = SoundCategory.categorise(sound);
    SoundResult result = categoryResults.get(category);

    if (!result.playSound()) {

        event.setResultSound(null);
    }

    if (result.showSubtitle()) {

        guiSubtitles.addSubtitle(sound,
                Minecraft.getMinecraft().getSoundHandler().getAccessor(event.getSound().getSoundLocation()),
                result.getColour());
    }
}

From source file:org.blockartistry.DynSurround.client.handlers.SoundCullHandler.java

License:MIT License

@SubscribeEvent(priority = EventPriority.LOWEST)
public void soundEvent(final PlaySoundEvent event) {
    if (event.getSound() == null || event.getSound() instanceof ConfigSound)
        return;/*from   w w  w.ja va 2 s. c o  m*/

    final String resource = event.getSound().getSoundLocation().toString();
    if (this.soundsToBlock.contains(resource)) {
        event.setResultSound(null);
        return;
    }

    if (ModOptions.soundCullingThreshold <= 0)
        return;

    // Get the last time the sound was seen
    final int lastOccurance = this.soundCull.get(resource);
    if (lastOccurance == 0)
        return;

    final int currentTick = EnvironState.getTickCounter();
    if ((currentTick - lastOccurance) < ModOptions.soundCullingThreshold) {
        event.setResultSound(null);
    } else {
        this.soundCull.put(resource, currentTick);
    }
}

From source file:org.blockartistry.DynSurround.client.handlers.SoundEffectHandler.java

License:MIT License

@SubscribeEvent
public void soundPlay(@Nonnull final PlaySoundEvent e) {
    if (e.getName().equals("entity.lightning.thunder")) {
        final ISound sound = e.getSound();
        final BlockPos pos = new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
        final ISound newSound = Sounds.THUNDER.createSound(pos).setVolume(ModOptions.thunderVolume);
        e.setResultSound(newSound);/*from  w w  w. j a  va  2  s  .  c o m*/
    }
}

From source file:org.blockartistry.mod.DynSurround.client.PlayerSoundEffectHandler.java

License:MIT License

@SubscribeEvent
public void soundEvent(final PlaySoundEvent event) {
    if (event.getSound() == null)
        return;//from ww  w.  j  a va 2 s .c o m

    if ((ModOptions.alwaysOverrideSound || !StormProperties.doVanilla()) && replaceRainSound(event.getName())) {
        final ISound sound = event.getSound();
        event.setResultSound(new PositionedSoundRecord(StormProperties.getCurrentStormSound(),
                SoundCategory.WEATHER, StormProperties.getCurrentVolume(), sound.getPitch(), sound.getXPosF(),
                sound.getYPosF(), sound.getZPosF()));
        return;
    }
}

From source file:org.blockartistry.mod.DynSurround.client.SoundBlockHandler.java

License:MIT License

@SubscribeEvent(priority = EventPriority.LOWEST)
public void soundEvent(final PlaySoundEvent event) {
    if (event.getSound() == null)
        return;// ww  w  . ja  va2 s . c o  m

    final String resource = event.getSound().getSoundLocation().toString();
    if (this.soundsToBlock.contains(resource)) {
        event.setResult(null);
        return;
    }

    if (ModOptions.soundCullingThreshold <= 0)
        return;

    // Get the last time the sound was seen
    final int lastOccurance = this.soundCull.get(resource);
    if (lastOccurance == 0)
        return;

    final int currentTick = EnvironState.getTickCounter();
    if ((currentTick - lastOccurance) < ModOptions.soundCullingThreshold) {
        event.setResult(null);
    } else {
        this.soundCull.put(resource, currentTick);
    }
}

From source file:org.blockartistry.mod.DynSurround.client.SoundControlHandler.java

License:MIT License

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void soundEvent(final PlaySoundEvent event) {
    if (event.getSound() == null)
        return;//w  w  w  .  j  ava 2s .  c  o m

    final String resource = event.getSound().getSoundLocation().toString();
    if (this.soundsToBlock.contains(resource)) {
        event.setResultSound(null);
        return;
    }

    if (ModOptions.soundCullingThreshold <= 0)
        return;

    // Get the last time the sound was seen
    final int lastOccurance = this.soundCull.get(resource);
    if (lastOccurance == 0)
        return;

    final int currentTick = EnvironState.getTickCounter();
    if ((currentTick - lastOccurance) < ModOptions.soundCullingThreshold) {
        event.setResultSound(null);
        return;
    } else {
        this.soundCull.put(resource, currentTick);
    }
}

From source file:org.blockartistry.mod.DynSurround.client.SoundControlHandler.java

License:MIT License

@SubscribeEvent(priority = EventPriority.LOWEST)
public void soundEventLast(final PlaySoundEvent event) {
    if (event.getSound() == null)
        return;//from w w w . j a va 2  s  .  co  m

    final String resource = event.getSound().getSoundLocation().toString();
    if (SoundRegistry.hasCustomVolumeScale(resource))
        event.setResultSound(new SoundShim(event.getSound(), SoundRegistry.getCustomVolumeScale(resource)));
}

From source file:valkyrienwarfare.mod.event.EventsClient.java

License:Open Source License

@SubscribeEvent
public void onPlaySoundEvent(PlaySoundEvent event) {
    ISound sound = event.getSound();
    BlockPos pos = new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager
            .getObjectManagingPos(Minecraft.getMinecraft().world, pos);

    if (wrapper != null) {
        Vector newSoundLocation = new Vector(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, newSoundLocation);

        SoundFixWrapper soundFix = new SoundFixWrapper(sound, wrapper, newSoundLocation);

        event.setResultSound(soundFix);/*from   ww  w.j  a  v a  2s.  c  om*/
    }
}

From source file:vazkii.quark.world.feature.OceanGuardians.java

License:Creative Commons License

@SubscribeEvent
@SideOnly(Side.CLIENT)//from   ww w .  ja v a2  s .  com
public void onSound(PlaySoundEvent event) {
    if (!tweakSound)
        return;

    ISound sound = event.getSound();
    if (sound instanceof GuardianSound) {
        GuardianSound gsound = (GuardianSound) sound;
        EntityGuardian guardian = ReflectionHelper.getPrivateValue(GuardianSound.class, gsound,
                LibObfuscation.GUARDIAN);
        event.setResultSound(new GuardianSound2UnderwaterBoogaloo(guardian));
    }
}