generated from MrSphay/codex-agent-repository-kit
62 lines
2.0 KiB
Java
62 lines
2.0 KiB
Java
package com.vinlanx.explosionoverhaul.client;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
public class DeafnessConcussionEffect {
|
|
public static boolean debugShowChat = false;
|
|
public static volatile boolean enabled = true;
|
|
private static int ticksRemaining;
|
|
private static int totalTicks;
|
|
private static float intensity;
|
|
|
|
public static boolean start(float intensity, double silentSeconds, double effectivePercent, String visibility, int intensityPercent) {
|
|
if (!enabled) {
|
|
return false;
|
|
}
|
|
DeafnessConcussionEffect.intensity = Math.max(DeafnessConcussionEffect.intensity, intensity);
|
|
totalTicks = Math.max(1, (int)Math.round(Math.max(1.0, silentSeconds) * 20.0));
|
|
ticksRemaining = Math.max(ticksRemaining, totalTicks);
|
|
LowPassConcussionEffect.setDeafnessGain((float)Math.max(0.12, 1.0 - intensity * 0.82));
|
|
return true;
|
|
}
|
|
|
|
public static void stop() {
|
|
ticksRemaining = 0;
|
|
intensity = 0.0f;
|
|
resetVolume();
|
|
}
|
|
|
|
public static boolean isActive() {
|
|
return enabled && ticksRemaining > 0 && intensity > 0.01f;
|
|
}
|
|
|
|
public static void resetVolume() {
|
|
LowPassConcussionEffect.setDeafnessGain(1.0f);
|
|
}
|
|
|
|
public static void applyMasterVolume(Minecraft mc, double volume) {
|
|
}
|
|
|
|
public static void onClientTick() {
|
|
if (ticksRemaining <= 0) {
|
|
stop();
|
|
return;
|
|
}
|
|
--ticksRemaining;
|
|
double remaining = ticksRemaining / Math.max(1.0, totalTicks);
|
|
LowPassConcussionEffect.setDeafnessGain((float)Math.max(0.12, lerp(1.0, 1.0 - intensity * 0.82, easeOutQuad(remaining))));
|
|
}
|
|
|
|
public static double lerp(double a, double b, double t) {
|
|
return a + (b - a) * t;
|
|
}
|
|
|
|
public static double easeOutQuad(double t) {
|
|
return 1.0 - (1.0 - t) * (1.0 - t);
|
|
}
|
|
|
|
public static double easeInOutQuad(double t) {
|
|
return t < 0.5 ? 2.0 * t * t : 1.0 - Math.pow(-2.0 * t + 2.0, 2.0) / 2.0;
|
|
}
|
|
}
|