From 791a2f9a645d7e7e53a3cbdac39aa1e49983ab49 Mon Sep 17 00:00:00 2001 From: ayunami2000 Date: Thu, 21 Jul 2022 19:23:51 -0400 Subject: [PATCH] Fix proximity --- .../lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index e26c365..8faad70 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -2215,7 +2215,7 @@ public class EaglerAdapterImpl2 { panner.setOrientation(0f, 1f, 0f); panner.setPosition(0, 0, 0); float vol = getVoiceListenVolume(); - panner.setMaxDistance(vol * getVoiceProximity() + 0.1f); + panner.setMaxDistance(vol * 2 * getVoiceProximity() + 0.1f); GainNode gain = audioctx.createGain(); gain.getGain().setValue(vol); analyser.connect(gain); @@ -2280,6 +2280,7 @@ public class EaglerAdapterImpl2 { private static int proximity = 16; public static final void setVoiceProximity(int prox) { + for (PannerNode panner : voicePanners.values()) panner.setMaxDistance(getVoiceListenVolume() * 2 * prox + 0.1f); proximity = prox; } public static final int getVoiceProximity() { @@ -2288,12 +2289,14 @@ public class EaglerAdapterImpl2 { private static float volumeListen = 0.5f; public static final void setVoiceListenVolume(float f) { - for (GainNode gain : voiceGains.values()) { + for (String username : voiceGains.keySet()) { + GainNode gain = voiceGains.get(username); float val = f; if(val > 0.5f) val = 0.5f + (val - 0.5f) * 3.0f; if(val > 2.0f) val = 2.0f; if(val < 0.0f) val = 0.0f; gain.getGain().setValue(val * 2.0f); + if (voicePanners.containsKey(username)) voicePanners.get(username).setMaxDistance(f * 2 * getVoiceProximity() + 0.1f); } volumeListen = f; }