@SubscribeEvent public static void clientTick(final TickEvent.ClientTickEvent event) { // Make sure that the display is created. OpenEye says that sometimes it isn't. if (ModOptions.muteWhenBackground && Display.isCreated()) { final SoundManager mgr = Minecraft.getMinecraft().getSoundHandler().sndManager; if (mgr instanceof SoundManagerReplacement) { final SoundManagerReplacement sm = (SoundManagerReplacement) mgr; final boolean active = Display.isActive(); final boolean muted = sm.isMuted(); if (active && muted) { sm.setMuted(false); DSurround.log().info("Unmuting sounds"); } else if (!active && !muted) { sm.setMuted(true); DSurround.log().info("Muting sounds"); } } } }
@Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { boolean keepLines = false; if (mc.thePlayer != null) { ItemStack helmet = mc.thePlayer.getCurrentItemOrArmor(4); if (helmet != null && helmet.getItem() instanceof ItemSmartHelmet) { keepLines = true; } } if (!keepLines) ItemSmartHelmet.clientLines = new String[ItemSmartHelmet.LINES]; while (speechQueue.size() > 0) { ThreadSpeechProvider thread = speechQueue.remove(0); try { SoundManager.sndSystem.newSource(false, thread.source, thread.file.toURI().toURL(), thread.source, false, (float)thread.x, (float)thread.y, (float)thread.z, 2, 16.0F); SoundManager.sndSystem.play(thread.source); } catch (Throwable e) {} thread.unlock(); } }
public PlaySoundEvent(SoundManager manager, ISound sound) { super(manager); this.sound = sound; this.name = sound.getSoundLocation().getResourcePath(); this.setResultSound(sound); }
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager); this.name = sound.getSoundLocation().getResourcePath(); this.sound = sound; this.uuid = uuid; }
public static boolean canAddSound(final ISound sound) { if (Sounds.playingSounds == null) { Sounds.playingSounds = ReflectionHelper.findField((Class)SoundManager.class, new String[] { "playingSounds", "field_148629_h" }); Sounds.soundMgr = ReflectionHelper.findField((Class)SoundHandler.class, new String[] { "sndManager", "field_147694_f" }); } try { final SoundManager manager = (SoundManager)Sounds.soundMgr.get(Minecraft.getMinecraft().getSoundHandler()); final Map map = (Map)Sounds.playingSounds.get(manager); return !map.containsValue(sound); } catch (IllegalAccessException e) { return false; } }
public static ISound playSound(SoundManager manager, ISound sound) { SoundEventAccessorComposite accessor = manager.field_148622_c.func_147680_a(sound.func_147650_b()); PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.func_148728_d())); MinecraftForge.EVENT_BUS.post(e); return e.result; }
public PlaySoundEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z, float volume, float pitch) { super(manager, source, name, volume, pitch); this.x = x; this.y = y; this.z = z; }
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager); this.name = sound.func_147650_b().func_110623_a(); this.sound = sound; this.uuid = uuid; }
public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) { super(manager); this.manager = manager; this.source = source; this.name = name; this.volume = volume; this.pitch = pitch; this.result = source; }
public PlayStreamingEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z) { super(manager, source, name, 0.0f, 0.0f); this.x = x; this.y = y; this.z = z; }
public PlaySoundEvent17(SoundManager manager, ISound sound, SoundCategory category) { super(manager); this.sound = sound; this.category = category; this.name = sound.func_147650_b().func_110623_a(); this.result = sound; }
@Deprecated public PlaySoundSourceEvent(SoundManager manager, String name, float x, float y, float z) { super(manager, null, null); this.manager = manager; this.name = name; this.x = x; this.y = y; this.z = z; }
public PlaySoundSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager, sound, uuid); this.name = sound.func_147650_b().func_110623_a(); this.manager = manager; this.x = this.y = this.z = 0; }
@Deprecated public PlayStreamingSourceEvent(SoundManager manager, String name, float x, float y, float z) { super(manager, null, null); this.manager = manager; this.name = name; this.x = x; this.y = y; this.z = z; }
public PlayStreamingSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager, sound, uuid); this.x = this.y = this.z = 0; this.manager = null; this.name = sound.func_147650_b().func_110623_a(); }
@Nullable public String playSound(@Nonnull final BasicSound<?> sound) { if (!canFitSound()) { if (ModOptions.enableDebugLogging) DSurround.log().debug("> NO ROOM: [%s]", sound.toString()); return null; } final SoundManager manager = getManager(); if (!StringUtils.isEmpty(sound.getId())) manager.stopSound(sound); manager.playSound(sound); if (ModOptions.enableDebugLogging) { if (StringUtils.isEmpty(sound.getId())) { DSurround.log().debug("> NOT QUEUED: [%s]", sound.toString()); } else { final StringBuilder builder = new StringBuilder(); builder.append("> QUEUED: [").append(sound.toString()).append(']'); if (DSurround.log().testTrace(ModOptions.Trace.TRUE_SOUND_VOLUME)) { final SoundSystem ss = manager.sndSystem; // Force a flush of all commands so we can get // the actual volume and pitch used within the // sound library. ss.CommandQueue(null); final float v = ss.getVolume(sound.getId()); final float p = ss.getPitch(sound.getId()); builder.append("; v: ").append(v).append(", p: ").append(p); } DSurround.log().debug(builder.toString()); } } return sound.getId(); }
public static ISound playSound(SoundManager manager, ISound sound) { SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation()); PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory())); MinecraftForge.EVENT_BUS.post(e); return e.result; }
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager); this.name = sound.getPositionedSoundLocation().getResourcePath(); this.sound = sound; this.uuid = uuid; }
public PlaySoundEvent17(SoundManager manager, ISound sound, SoundCategory category) { super(manager); this.sound = sound; this.category = category; this.name = sound.getPositionedSoundLocation().getResourcePath(); this.result = sound; }
public PlaySoundSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager, sound, uuid); this.name = sound.getPositionedSoundLocation().getResourcePath(); this.manager = manager; this.x = this.y = this.z = 0; }
public PlayStreamingSourceEvent(SoundManager manager, ISound sound, String uuid) { super(manager, sound, uuid); this.x = this.y = this.z = 0; this.manager = null; this.name = sound.getPositionedSoundLocation().getResourcePath(); }
public static SoundManager getSoundManager() { try { return (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager); } catch(Exception e) { return null; } }
public static Map<ISound, String> getSoundMap() { if(invPlayingSounds == null) { try { invPlayingSounds = (Map<ISound, String>)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds); } catch(Exception e) { invPlayingSounds = null; } } return invPlayingSounds; }
private void initialize() { try { soundManager = (SoundManager) ReflectionHelper.findField(net.minecraft.client.audio.SoundHandler.class, SOUND_MANAGER_MAPPING).get(Minecraft.getMinecraft().getSoundHandler()); soundSystem = (SoundSystem) ReflectionHelper.findField(SoundManager.class, SOUND_SYSTEM_MAPPING).get(soundManager); } catch (Exception e) { e.printStackTrace(); } }