Skip to content

Commit

Permalink
feat: add clientconfig.misc.disableSpiritFireSuccessSound
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Mar 3, 2024
1 parent 39b526f commit 3a5ca48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 3a5ca48

Please sign in to comment.