From 5b831dfb61a2d64c025204036651646e33124b84 Mon Sep 17 00:00:00 2001 From: "Dr. Rubisco" <76263371+thedocruby@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:14:04 -0500 Subject: [PATCH] Critical Bugfix Fixed failure to start sound engine when reseting config. --- .../resounding/config/BlueTapePack/ConfigManager.java | 7 +++---- .../dev/thedocruby/resounding/mixin/SoundEngineMixin.java | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/dev/thedocruby/resounding/config/BlueTapePack/ConfigManager.java b/src/main/java/dev/thedocruby/resounding/config/BlueTapePack/ConfigManager.java index b1076c61..00983c86 100644 --- a/src/main/java/dev/thedocruby/resounding/config/BlueTapePack/ConfigManager.java +++ b/src/main/java/dev/thedocruby/resounding/config/BlueTapePack/ConfigManager.java @@ -10,7 +10,6 @@ import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; import net.minecraft.util.ActionResult; import org.jetbrains.annotations.NotNull; @@ -85,12 +84,12 @@ public static void handleUnstableConfig( ResoundingConfig c ){ public static ActionResult onSave(ResoundingConfig c) { if (ResoundingEngine.env == EnvType.CLIENT && (c.materials.materialProperties == null || c.materials.materialProperties.get("DEFAULT") == null)) handleBrokenMaterials(c); if (ResoundingEngine.env == EnvType.CLIENT && c.preset != ConfigPresets.LOAD_SUCCESS) c.preset.configChanger.accept(c); - if (c.version == null || !Objects.equals(c.version, configVersion)) handleUnstableConfig(c); + if ((c.version == null || !Objects.equals(c.version, configVersion)) && !resetOnReload) handleUnstableConfig(c); if (PrecomputedConfig.pC != null) PrecomputedConfig.pC.deactivate(); try {PrecomputedConfig.pC = new PrecomputedConfig(c);} catch (CloneNotSupportedException e) {e.printStackTrace(); return ActionResult.FAIL;} - if (ResoundingEngine.env == EnvType.CLIENT && MinecraftClient.getInstance().getSoundManager() != null) { + if (ResoundingEngine.env == EnvType.CLIENT && !ResoundingEngine.isOff) { ResoundingEngine.updateRays(); - MinecraftClient.getInstance().getSoundManager().reloadSounds(); + ResoundingEngine.mc.getSoundManager().reloadSounds(); } return ActionResult.SUCCESS; } diff --git a/src/main/java/dev/thedocruby/resounding/mixin/SoundEngineMixin.java b/src/main/java/dev/thedocruby/resounding/mixin/SoundEngineMixin.java index e08e2c66..8e5c3f74 100644 --- a/src/main/java/dev/thedocruby/resounding/mixin/SoundEngineMixin.java +++ b/src/main/java/dev/thedocruby/resounding/mixin/SoundEngineMixin.java @@ -20,15 +20,15 @@ public class SoundEngineMixin { @Inject(method = "init", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/sound/AlUtil;checkErrors(Ljava/lang/String;)Z", ordinal = 0)) private void resoundingStartInjector(CallbackInfo ci){ if (!ResoundingEngine.isOff) throw new IllegalStateException("ResoundingEngine has already been started! You may need to reload the sound system using SoundManager.reloadSounds()"); - ResoundingEngine.isOff = !pC.enabled; - if (ResoundingEngine.isOff){ + if (!pC.enabled){ ResoundingEngine.LOGGER.info("Skipped starting Resounding engine: disabled in config."); + ResoundingEngine.isOff = true; return; } ResoundingEngine.LOGGER.info("Starting Resounding engine..."); - ResoundingEngine.isOff = !ResoundingEFX.setUpEXTEfx(); - if (ResoundingEngine.isOff) { + if (!ResoundingEFX.setUpEXTEfx()) { ResoundingEngine.LOGGER.info("Failed to prime OpenAL EFX for Resounding effects. ResoundingEngine will not be active."); + ResoundingEngine.isOff = true; return; } ResoundingEngine.LOGGER.info("OpenAL EFX successfully primed for Resounding effects");