Skip to content

Commit

Permalink
Critical Bugfix
Browse files Browse the repository at this point in the history
Fixed failure to start sound engine when reseting config.
  • Loading branch information
thedocruby committed Feb 22, 2022
1 parent a3ac1d8 commit 5b831df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 5b831df

Please sign in to comment.