generated from MrSphay/codex-agent-repository-kit
90 lines
2.8 KiB
Java
90 lines
2.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.vinlanx.explosionoverhaul.client;
|
|
|
|
import com.sonicether.soundphysics.SoundPhysics;
|
|
import com.vinlanx.explosionoverhaul.client.LowPassConcussionEffect;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import net.neoforged.fml.ModList;
|
|
import org.lwjgl.openal.AL10;
|
|
|
|
public class SoundPhysicsCompatibility {
|
|
private static boolean sprLoaded = false;
|
|
private static final Map<Integer, SprParams> sourceParams = new ConcurrentHashMap<Integer, SprParams>();
|
|
|
|
public static void init() {
|
|
sprLoaded = ModList.get().isLoaded("sound_physics_remastered");
|
|
if (sprLoaded) {
|
|
LowPassConcussionEffect.setCompatibilityMode(true);
|
|
}
|
|
}
|
|
|
|
public static boolean isCompatibilityEnabled() {
|
|
return sprLoaded;
|
|
}
|
|
|
|
public static void cacheParams(int sourceID, float sg0, float sg1, float sg2, float sg3, float sc0, float sc1, float sc2, float sc3, float dc, float dg) {
|
|
sourceParams.put(sourceID, new SprParams(sg0, sg1, sg2, sg3, sc0, sc1, sc2, sc3, dc, dg));
|
|
}
|
|
|
|
public static void onSourceStop(int sourceID) {
|
|
sourceParams.remove(sourceID);
|
|
}
|
|
|
|
public static void reapplyDirectFilterParameters() {
|
|
if (!sprLoaded || sourceParams.isEmpty()) {
|
|
return;
|
|
}
|
|
sourceParams.entrySet().removeIf(entry -> {
|
|
int id = (Integer)entry.getKey();
|
|
if (!AL10.alIsSource((int)id)) {
|
|
return true;
|
|
}
|
|
SprParams p = (SprParams)entry.getValue();
|
|
try {
|
|
SoundPhysics.setEnvironment((int)id, (float)p.sg0, (float)p.sg1, (float)p.sg2, (float)p.sg3, (float)p.sc0, (float)p.sc1, (float)p.sc2, (float)p.sc3, (float)p.dc, (float)p.dg);
|
|
}
|
|
catch (Throwable t) {
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
|
|
public static float combineGain(float sprGain) {
|
|
return sprGain * LowPassConcussionEffect.getCurrentGainMultiplier();
|
|
}
|
|
|
|
public static float combineHF(float sprHF) {
|
|
return Math.min(sprHF, LowPassConcussionEffect.getCurrentHfMultiplier());
|
|
}
|
|
|
|
private static class SprParams {
|
|
float sg0;
|
|
float sg1;
|
|
float sg2;
|
|
float sg3;
|
|
float sc0;
|
|
float sc1;
|
|
float sc2;
|
|
float sc3;
|
|
float dc;
|
|
float dg;
|
|
|
|
SprParams(float sg0, float sg1, float sg2, float sg3, float sc0, float sc1, float sc2, float sc3, float dc, float dg) {
|
|
this.sg0 = sg0;
|
|
this.sg1 = sg1;
|
|
this.sg2 = sg2;
|
|
this.sg3 = sg3;
|
|
this.sc0 = sc0;
|
|
this.sc1 = sc1;
|
|
this.sc2 = sc2;
|
|
this.sc3 = sc3;
|
|
this.dc = dc;
|
|
this.dg = dg;
|
|
}
|
|
}
|
|
}
|