From 3a5ca48932cb2c443d8d7dfd024ad56eb93b7845 Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Sun, 3 Mar 2024 16:16:47 +0100 Subject: [PATCH] feat: add clientconfig.misc.disableSpiritFireSuccessSound --- .../occultism/config/OccultismClientConfig.java | 5 +++++ .../handlers/ClientPlayerEventHandler.java | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java b/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java index f58e0ac2c..3590a8dc6 100644 --- a/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java +++ b/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java @@ -97,6 +97,7 @@ public static class MiscSettings { public final BooleanValue syncJeiSearch; public final BooleanValue divinationRodHighlightAllResults; public final IntValue divinationRodScanRange; + public final BooleanValue disableSpiritFireSuccessSound; public MiscSettings(ModConfigSpec.Builder builder) { builder.comment("Misc Settings").push("misc"); @@ -109,6 +110,10 @@ public MiscSettings(ModConfigSpec.Builder builder) { .define("divinationRodHighlightAllResults", false); this.divinationRodScanRange = builder.comment("The scan range in blocks for the divination rod. Too high might cause lags") .defineInRange("divinationRodScanRange", 129, 1, Integer.MAX_VALUE); + this.disableSpiritFireSuccessSound = builder.comment( + "Disables the sound played when a spirit fire successfully crafted an item." + ) + .define("disableSpiritFireSuccessSound", false); builder.pop(); } } diff --git a/src/main/java/com/klikli_dev/occultism/handlers/ClientPlayerEventHandler.java b/src/main/java/com/klikli_dev/occultism/handlers/ClientPlayerEventHandler.java index da15e8ed1..041f5eccd 100644 --- a/src/main/java/com/klikli_dev/occultism/handlers/ClientPlayerEventHandler.java +++ b/src/main/java/com/klikli_dev/occultism/handlers/ClientPlayerEventHandler.java @@ -30,17 +30,21 @@ import com.klikli_dev.occultism.network.messages.MessageOpenSatchel; import com.klikli_dev.occultism.network.messages.MessageOpenStorageRemote; import com.klikli_dev.occultism.network.messages.MessageToggleFamiliarSettings; +import com.klikli_dev.occultism.registry.OccultismBlocks; +import com.klikli_dev.occultism.registry.OccultismSounds; import com.klikli_dev.occultism.util.CuriosUtil; import com.klikli_dev.occultism.util.MovementUtil; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.EntityType; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.client.event.InputEvent; +import net.neoforged.neoforge.event.PlayLevelSoundEvent; import java.util.HashMap; import java.util.Map; @@ -52,6 +56,17 @@ public class ClientPlayerEventHandler { //region Static Methods + @SubscribeEvent + public static void onPlaySoundAt(PlayLevelSoundEvent.AtPosition event){ + //handle spirit fire sound disable config + if(event.getLevel().isClientSide && + Occultism.CLIENT_CONFIG.misc.disableSpiritFireSuccessSound.get() && + event.getSound().value() == OccultismSounds.START_RITUAL.get() && + event.getLevel().getBlockState(BlockPos.containing(event.getPosition())).getBlock() == OccultismBlocks.SPIRIT_FIRE.get()){ + event.setCanceled(true); + } + } + @SubscribeEvent public static void onKeyInput(final InputEvent.Key event) { Minecraft minecraft = Minecraft.getInstance();