net.minecraft.client.audio.ISound Java Examples

The following examples show how to use net.minecraft.client.audio.ISound. 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: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void onPlaySoundEvent(PlaySoundEvent event) {
    if (Minecraft.getMinecraft().world != null) {
        ISound sound = event.getSound();
        BlockPos pos = new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());

        Optional<PhysicsObject> physicsObject = ValkyrienUtils
            .getPhysicsObject(Minecraft.getMinecraft().world, pos);
        if (physicsObject.isPresent()) {
            Vector newSoundLocation = new Vector(sound.getXPosF(), sound.getYPosF(),
                sound.getZPosF());
            physicsObject.get()
                .getShipTransformationManager()
                .getCurrentTickTransform()
                .transform(newSoundLocation, TransformType.SUBSPACE_TO_GLOBAL);

            SoundFixWrapper soundFix = new SoundFixWrapper(sound, newSoundLocation);

            event.setResultSound(soundFix);
        }
    }
}
 
Example #3
Source File: YouCouldMakeAReligionOutOfThis.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onClientTick(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.START) {
        Minecraft client = Minecraft.getMinecraft();
        if (client.world != null && !client.isGamePaused()) {
            RANDOM.setSeed((client.world.getTotalWorldTime() * M) ^ client.world.getSeed());
            if (RANDOM.nextInt(CHANCE) == 0) {
                ISound sound = PositionedSoundRecord.getMasterRecord(YOU_COULD_MAKE_A_RELIGION_OUT_OF_THIS, 1.0F);
                client.getSoundHandler().playSound(sound);
            }
        }
    }
}
 
Example #4
Source File: HyperiumSoundManager.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void playSound(ISound sound, CallbackInfo ci) {
    if (Settings.SMART_SOUNDS && !Display.isActive()) {
        ci.cancel(); // does not stop music from being played but whatever
        return;
    }

    SoundPlayEvent e = new SoundPlayEvent(sound);
    EventBus.INSTANCE.post(e);

    if (e.isCancelled()) ci.cancel();
}
 
Example #5
Source File: SoundPlayEvent.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SoundPlayEvent(@NotNull ISound sound) {
    Preconditions.checkNotNull(sound, "sound");

    this.sound = sound;
}
 
Example #6
Source File: SoundPlayEvent.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@NotNull
public final ISound getSound() {
    return sound;
}
 
Example #7
Source File: SoundFixWrapper.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public SoundFixWrapper(ISound wrappedSound, Vector soundLocation) {
    this.wrappedSound = wrappedSound;
    this.soundLocation = soundLocation;
}
 
Example #8
Source File: MixinSoundManager.java    From Hyperium with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sound will not play unless the window is active while the out of
 * focus sounds option is disabled
 *
 * @param sound the sound
 * @param ci    callback
 */
@Inject(method = "playSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/audio/SoundHandler;getSound(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/audio/SoundEventAccessorComposite;"), cancellable = true)
private void playSound(ISound sound, CallbackInfo ci) {
    hyperiumSoundManager.playSound(sound, ci);
}