Skip to content

Commit

Permalink
sound pool crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Apr 8, 2024
1 parent 0941654 commit ed76036
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/mega/blendtronic/config/MinecraftConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public final class MinecraftConfig {
@Config.DefaultBoolean(true)
public static boolean openALNativeCrashFix;

@Config.Comment("[CLIENT] Fixes an occasional game crash caused by the sound pool becoming inconsistent")
@Config.DefaultBoolean(true)
public static boolean soundManagerCrashFix;

@Config.Comment("[BOTH] Makes entity netcode more precise, fixing some rubber-banding and bouncing items.\n" +
"NOTE: This needs to be enabled both serverside and clientside, otherwise it leads to a crash when trying to join multiplayer!")
@Config.DefaultBoolean(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mega.blendtronic.mixin.mixins.client.misc;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.client.audio.SoundManager;
import net.minecraft.client.audio.SoundPoolEntry;

@Mixin(SoundManager.class)
public class SoundManagerCrashFix {
@Redirect(method = "getNormalizedPitch",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/audio/SoundPoolEntry;getPitch()D"),
require = 1)
private double nullSafeGetPitch(SoundPoolEntry instance) {
return instance != null ? instance.getPitch() : 0;
}

@Redirect(method = "getNormalizedVolume",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/audio/SoundPoolEntry;getVolume()D"),
require = 1)
private double nullSafeGetVolume(SoundPoolEntry instance) {
return instance != null ? instance.getVolume() : 0;
}
}
1 change: 1 addition & 0 deletions src/main/java/mega/blendtronic/mixin/plugin/Mixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum Mixin implements IMixin {

client_misc_GameOverFullscreenFix(CLIENT, condition(() -> guiGameOverInitGuiMixin), "misc.GameOverFullscreenFix"),
client_misc_OpenALNativeCrashFix(CLIENT, condition(() -> openALNativeCrashFix), "misc.OpenALNativeCrashFix"),
client_misc_SoundManagerCrashFix(CLIENT, condition(() -> soundManagerCrashFix), "misc.SoundManagerCrashFix"),
// endregion

// region Netcode
Expand Down

0 comments on commit ed76036

Please sign in to comment.