package com.tiedup.remake.core;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

/**
 * ModSounds - Registry for custom sound effects.
 *
 * <p>Contains all original 1.12.2 sound effects ported to 1.20.1.
 * Sounds are defined in assets/tiedup/sounds.json.</p>
 */
public class ModSounds {

    public static final DeferredRegister<SoundEvent> SOUND_EVENTS =
        DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, TiedUpMod.MOD_ID);

    /** Plays when a shock collar is triggered. */
    public static final RegistryObject<SoundEvent> ELECTRIC_SHOCK =
        registerSound("electric_shock");
    /** Plays when a remote controller or locator is used. */
    public static final RegistryObject<SoundEvent> SHOCKER_ACTIVATED =
        registerSound("shocker_activated");
    /** Plays when a collar is successfully put on a player. */
    public static final RegistryObject<SoundEvent> COLLAR_PUT = registerSound(
        "collar_put"
    );
    /** Plays when a collar key unlocks a padlock. */
    public static final RegistryObject<SoundEvent> COLLAR_KEY_OPEN =
        registerSound("collar_key_open");
    /** Plays when a collar key locks a padlock. */
    public static final RegistryObject<SoundEvent> COLLAR_KEY_CLOSE =
        registerSound("collar_key_close");
    /** Generic heavy chain sound. */
    public static final RegistryObject<SoundEvent> CHAIN = registerSound(
        "chain"
    );
    /** Slap sound for the paddle tool. */
    public static final RegistryObject<SoundEvent> SLAP = registerSound("slap");
    /** Whip sound for the whip tool. */
    public static final RegistryObject<SoundEvent> WHIP = registerSound("whip");

    private static RegistryObject<SoundEvent> registerSound(String name) {
        return SOUND_EVENTS.register(name, () ->
            SoundEvent.createVariableRangeEvent(
                ResourceLocation.fromNamespaceAndPath(TiedUpMod.MOD_ID, name)
            )
        );
    }
}
