generated from MrSphay/codex-agent-repository-kit
59 lines
2.0 KiB
Java
59 lines
2.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.vinlanx.explosionoverhaul.mixin;
|
|
|
|
import com.mojang.blaze3d.audio.Channel;
|
|
import com.vinlanx.explosionoverhaul.client.LowPassConcussionEffect;
|
|
import com.vinlanx.explosionoverhaul.client.SoundEngineAudioQueue;
|
|
import com.vinlanx.explosionoverhaul.client.SoundPhysicsCompatibility;
|
|
import org.spongepowered.asm.mixin.Final;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
@Mixin(value={Channel.class})
|
|
public class ChannelLowpassMixin {
|
|
@Shadow
|
|
@Final
|
|
private int f_83642_;
|
|
|
|
@Inject(method={"play"}, at={@At(value="HEAD")})
|
|
private void onPlay(CallbackInfo ci) {
|
|
try {
|
|
boolean active = LowPassConcussionEffect.isActive();
|
|
if ("Sound engine".equals(Thread.currentThread().getName())) {
|
|
SoundEngineAudioQueue.drainNow();
|
|
}
|
|
if (active) {
|
|
SoundEngineAudioQueue.enqueueAudio(() -> LowPassConcussionEffect.attachFilterToSource(this.f_83642_));
|
|
if ("Sound engine".equals(Thread.currentThread().getName())) {
|
|
SoundEngineAudioQueue.drainNow();
|
|
}
|
|
}
|
|
}
|
|
catch (Throwable throwable) {
|
|
// empty catch block
|
|
}
|
|
}
|
|
|
|
@Inject(method={"stop"}, at={@At(value="HEAD")})
|
|
private void onStop(CallbackInfo ci) {
|
|
if (SoundPhysicsCompatibility.isCompatibilityEnabled()) {
|
|
SoundPhysicsCompatibility.onSourceStop(this.f_83642_);
|
|
}
|
|
try {
|
|
SoundEngineAudioQueue.enqueueAudio(() -> LowPassConcussionEffect.detachFilterFromSource(this.f_83642_));
|
|
if ("Sound engine".equals(Thread.currentThread().getName())) {
|
|
SoundEngineAudioQueue.drainNow();
|
|
}
|
|
}
|
|
catch (Throwable throwable) {
|
|
// empty catch block
|
|
}
|
|
}
|
|
}
|
|
|