fixed volume sliders

This commit is contained in:
LAX1DUDE 2022-07-21 16:30:00 -07:00
parent 188e36c2a2
commit 6b88a73b78
4 changed files with 21 additions and 15 deletions

View File

@ -1127,7 +1127,7 @@ public class Minecraft implements Runnable {
EntityPlayer player = (EntityPlayer) playerObject;
if (player == this.thePlayer) continue;
if (EaglerAdapter.getVoiceChannel() == Voice.VoiceChannel.PROXIMITY) EaglerAdapter.updateVoicePosition(player.username, player.posX, player.posY + player.getEyeHeight(), player.posZ);
int prox = EaglerAdapter.getVoiceProximity();
int prox = 22;
// cube
if (Math.abs(thePlayer.posX - player.posX) <= prox && Math.abs(thePlayer.posY - player.posY) <= prox && Math.abs(thePlayer.posZ - player.posZ) <= prox) {
if (EaglerAdapter.getVoiceChannel() == Voice.VoiceChannel.PROXIMITY) {

View File

@ -548,6 +548,7 @@ public class GameSettings {
}
KeyBinding.resetKeyBindingArrayAndHash();
mc.sndManager.onSoundOptionsChanged();
}
}

View File

@ -77,7 +77,7 @@ public class SoundManager {
* Called when one of the sound level options has changed.
*/
public void onSoundOptionsChanged() {
EaglerAdapter.setMasterVolume(options.soundVolume);
}
/**
@ -215,8 +215,7 @@ public class SoundManager {
return;
}
}
float v = par3 * this.options.soundVolume;
if(v > 0.0F) {
if(this.options.soundVolume > 0.0F && par3 > 0.0F) {
Integer ct = this.sounddefinitions.get(par1Str);
if(ct != null) {
int c = ct.intValue();
@ -228,7 +227,7 @@ public class SoundManager {
path = "/sounds/"+par1Str.replace('.', '/')+r+".mp3";
}
int id = 0;
soundevents.add(new EntitySoundEvent(par2Entity, id = EaglerAdapter.beginPlayback(path, 0f, 0f, 0f, v, par4)));
soundevents.add(new EntitySoundEvent(par2Entity, id = EaglerAdapter.beginPlayback(path, 0f, 0f, 0f, par3, par4)));
EaglerAdapter.moveSound(id, (float)par2Entity.posX, (float)par2Entity.posY, (float)par2Entity.posZ, (float)par2Entity.motionX, (float)par2Entity.motionY, (float)par2Entity.motionZ);
}else {
System.err.println("unregistered sound effect: "+par1Str);
@ -240,8 +239,7 @@ public class SoundManager {
* Plays a sound. Args: soundName, x, y, z, volume, pitch
*/
public void playSound(String par1Str, float par2, float par3, float par4, float par5, float par6) {
float v = par5 * this.options.soundVolume;
if(v > 0.0F) {
if(this.options.soundVolume > 0.0F && par5 > 0.0F) {
Integer ct = this.sounddefinitions.get(par1Str);
if(ct != null) {
int c = ct.intValue();
@ -252,7 +250,7 @@ public class SoundManager {
int r = soundrandom.nextInt(c) + 1;
path = "/sounds/"+par1Str.replace('.', '/')+r+".mp3";
}
EaglerAdapter.beginPlayback(path, par2, par3, par4, v, par6);
EaglerAdapter.beginPlayback(path, par2, par3, par4, par5, par6);
}else {
System.err.println("unregistered sound effect: "+par1Str);
}
@ -265,8 +263,7 @@ public class SoundManager {
* balanced)
*/
public void playSoundFX(String par1Str, float par2, float par3) {
float v = par3 * this.options.soundVolume;
if(v > 0.0F) {
if(this.options.soundVolume > 0.0F && par2 > 0.0F) {
Integer ct = this.sounddefinitions.get(par1Str);
if(ct != null) {
int c = ct.intValue();
@ -277,7 +274,7 @@ public class SoundManager {
int r = soundrandom.nextInt(c) + 1;
path = "/sounds/"+par1Str.replace('.', '/')+r+".mp3";
}
EaglerAdapter.beginPlaybackStatic(path, v, par3);
EaglerAdapter.beginPlaybackStatic(path, par2, par3);
}else {
System.err.println("unregistered sound effect: "+par1Str);
}

View File

@ -326,6 +326,9 @@ public class EaglerAdapterImpl2 {
}
audioctx = AudioContext.create();
masterVolumeNode = audioctx.createGain();
masterVolumeNode.getGain().setValue(1.0f);
masterVolumeNode.connect(audioctx.getDestination());
mouseEvents.clear();
keyEvents.clear();
@ -1053,7 +1056,7 @@ public class EaglerAdapterImpl2 {
currentVideoAudioSource = audioctx.createMediaElementSource(currentVideo);
if(currentVideoAudioGainValue < 0.0f) {
currentVideoAudioSource.connect(audioctx.getDestination());
currentVideoAudioSource.connect(masterVolumeNode);
}else {
if(currentVideoAudioGain == null) {
currentVideoAudioGain = audioctx.createGain();
@ -1151,7 +1154,7 @@ public class EaglerAdapterImpl2 {
if(v < 0.0f) {
if(currentVideoAudioGainValue >= 0.0f && currentVideoAudioSource != null) {
currentVideoAudioSource.disconnect();
currentVideoAudioSource.connect(audioctx.getDestination());
currentVideoAudioSource.connect(masterVolumeNode);
}
currentVideoAudioGainValue = v;
}else {
@ -1848,12 +1851,17 @@ public class EaglerAdapterImpl2 {
private static int playbackId = 0;
private static final HashMap<String,AudioBufferX> loadedSoundFiles = new HashMap();
private static AudioContext audioctx = null;
private static GainNode masterVolumeNode = null;
private static float playbackOffsetDelay = 0.03f;
public static final void setPlaybackOffsetDelay(float f) {
playbackOffsetDelay = f;
}
public static final void setMasterVolume(float f) {
masterVolumeNode.getGain().setValue(f);
}
@Async
public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer);
@ -1924,7 +1932,7 @@ public class EaglerAdapterImpl2 {
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
s.connect(g);
g.connect(p);
p.connect(audioctx.getDestination());
p.connect(masterVolumeNode);
s.start(0.0d, playbackOffsetDelay);
final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
@ -1947,7 +1955,7 @@ public class EaglerAdapterImpl2 {
GainNode g = audioctx.createGain();
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
s.connect(g);
g.connect(audioctx.getDestination());
g.connect(masterVolumeNode);
s.start(0.0d, playbackOffsetDelay);
final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g));