commit 1655a8e54a19c5721b925fa52962e9c3937cb7fd from: TechSupportRed date: Sat Sep 2 15:28:29 2023 UTC 1.20-1.20.1 init commit - 9875ddc150bf43e5ed9d63977316165ffbf0d240 commit + 1655a8e54a19c5721b925fa52962e9c3937cb7fd blob - b420a7bb28d2e28e4fecdf1269525afa020b2774 blob + b4cfe35c79d7c205ef07ada312f3bb64f452e4fa --- build.gradle +++ build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.3-SNAPSHOT' id 'maven-publish' } blob - ffed3a254e91df704a9acc0f2745c0e340d9b582 blob + 15de90249f9d9972adb9760d44c483e329aba6b4 --- gradle/wrapper/gradle-wrapper.properties +++ gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists blob - c6dabddbf811a5c83c8bf4104ebf5b9a99a38620 blob + 554426ffcab5e599aec6dae3ff9a699d8531febf --- gradle.properties +++ gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.28 + minecraft_version=1.20.1 + yarn_mappings=1.20.1+build.10 loader_version=0.14.22 # Mod Properties - mod_version = 1.0.1 + mod_version = 1.2.0 maven_group = com.techsupportred archives_base_name = consolesounds # Dependencies - fabric_version=0.76.1+1.19.2 - cloth_config_version = 8.3.103 \ No newline at end of file + fabric_version=0.87.0+1.20.1 + cloth_config_version = 11.1.106 \ No newline at end of file blob - 4b14d28f7bf8716c77ee2a1318828d06b81e7b8c blob + f3fe9ffb1299f1b44ddc0f5b72d6551a2cdd2761 --- src/main/java/com/hattolo/consolesounds/ConsoleSoundsClient.java +++ src/main/java/com/hattolo/consolesounds/ConsoleSoundsClient.java @@ -3,48 +3,25 @@ package com.hattolo.consolesounds; import me.shedaniel.autoconfig.AutoConfig; import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import net.fabricmc.api.ClientModInitializer; -import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class ConsoleSoundsClient implements ClientModInitializer { - public static final Logger log = LogManager.getLogger("Console Sounds"); + public static final String MOD_ID = "consolemod"; + public static final Logger LOGGER = LogManager.getLogger("Console Sounds"); - public static final Identifier UI_SELECT_ID = new Identifier("consolemod:ui_select"); - public static SoundEvent UI_SELECT_EVENT = new SoundEvent(UI_SELECT_ID); + public static Identifier id(String path) { + return new Identifier(MOD_ID, path); + } - public static final Identifier UI_BACK_ID = new Identifier("consolemod:ui_back"); - public static SoundEvent UI_BACK_EVENT = new SoundEvent(UI_BACK_ID); - public static final Identifier UI_SCROLL_ID = new Identifier("consolemod:ui_scroll"); - public static SoundEvent UI_SCROLL_EVENT = new SoundEvent(UI_SCROLL_ID); - public static final Identifier UI_FAIL_ID = new Identifier("consolemod:ui_fail"); - public static SoundEvent UI_FAIL_EVENT = new SoundEvent(UI_FAIL_ID); - @Override public void onInitializeClient() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - - // register sounds - Registry.register(Registry.SOUND_EVENT, UI_SELECT_ID, UI_SELECT_EVENT); - Registry.register(Registry.SOUND_EVENT, UI_BACK_ID, UI_BACK_EVENT); - Registry.register(Registry.SOUND_EVENT, UI_SCROLL_ID, UI_SCROLL_EVENT); - Registry.register(Registry.SOUND_EVENT, UI_FAIL_ID, UI_FAIL_EVENT); - log.info("Registered all sounds!"); - + ConsoleSoundsSounds.init(); // register config AutoConfig.register(ConsoleSoundsConfig.class, GsonConfigSerializer::new); - log.info("Registered config!"); - - // register and automatically load resource pack - //ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("consolemod", "console_pack"), FabricLoader.getInstance().getModContainer("consolemod").get(), ResourcePackActivationType.ALWAYS_ENABLED); - - log.info("Initialized the mod!"); + LOGGER.info("Registered config..."); } } blob - 0fc07f1a6304cb54a85b5d515cb4a200d5e88206 blob + 056c979152743c66b0cf26df3f14427efbccb6bb --- src/main/java/com/hattolo/consolesounds/ConsoleSoundsConfig.java +++ src/main/java/com/hattolo/consolesounds/ConsoleSoundsConfig.java @@ -2,24 +2,66 @@ package com.hattolo.consolesounds; import me.shedaniel.autoconfig.ConfigData; import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; @Config(name = "consolesounds") public class ConsoleSoundsConfig implements ConfigData { @Comment("Enables the sound you hear when you hover over buttons.") public boolean enableHoverSounds = true; + @Comment("Enables the click sound you hear when you click on a slot on an in-game menu, like a crafting table or your inventory.") public boolean enableInGameClickSounds = true; + @Comment("Enables the pop sound you hear when you craft something.") public boolean enableCraftingSounds = true; + @Comment("Enables the sound you hear when you use a slider.") public boolean enableSliderSounds = true; + @Comment("Plays the click sound whenever you open the pause menu. You might want to disable this if you set the game to auto pause on focus loss.") public boolean playSoundOnPauseMenu = true; + @Comment("Plays the click sound whenever you open an in-game menu, like a crafting table or your inventory.") public boolean playSoundOnInGameMenu = true; + @Comment("Plays the back sound whenever you close a menu.") public boolean playSoundOnMenuExit = true; + @Comment("Plays the back sound whenever you close an in-game menu, like a crafting table or your inventory.") public boolean playSoundOnInGameMenuExit = true; + + + + @Comment("Volume when you hover over buttons.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int hoverVolume = 100; + + @Comment("Volume when you click on a slot on an in-game menu.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int inGameClickVolume = 100; + + @Comment("Volume when you craft something.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int craftingVolume = 100; + + @Comment("Volume when you use a slider.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int sliderVolume = 100; + + @Comment("Volume when you open the pause menu.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int onPauseMenuVolume = 100; + + @Comment("Volume when you open an in-game menu") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int inGameMenuVolume = 100; + + @Comment("Volume when you close a menu.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int menuExitVolume = 100; + + @Comment("Volume when you close an in-game menu.") + @ConfigEntry.BoundedDiscrete(min = 0, max = 100) + public int onInGameMenuExitVolume = 100; } \ No newline at end of file blob - 57677c2aa17bb4cbbc39949598553a15d0dec06f blob + 7a5382d26188afe9c1e05e69bcce4780ce1ada76 --- src/main/java/com/hattolo/consolesounds/mixin/ClickCreativeInventoryScreenMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/ClickCreativeInventoryScreenMixin.java @@ -15,6 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback. public class ClickCreativeInventoryScreenMixin { @Inject(at = @At("HEAD"), method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V") private void onMouseClick(CallbackInfo ci) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableInGameClickSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableInGameClickSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().inGameClickVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK.value(), 1.0F, volume)); + } } -} +} \ No newline at end of file blob - c71f5cdae4d595ff1de447ea2ed026054b4cd20d blob + 8eda49f8baef6611ae7d82b0516d394984056e1e --- src/main/java/com/hattolo/consolesounds/mixin/ClickHandledScreenMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/ClickHandledScreenMixin.java @@ -15,6 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback. public class ClickHandledScreenMixin { @Inject(at = @At("HEAD"), method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V") private void onMouseClick(CallbackInfo ci) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableInGameClickSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableInGameClickSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().inGameClickVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK.value(), 1.0F, volume)); + } } -} +} \ No newline at end of file blob - b46225a681df3b19d1029edc091922137c4d9398 blob + efa034567885193bd0ab9185320604230493c38a --- src/main/java/com/hattolo/consolesounds/mixin/CraftItemStackMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/CraftItemStackMixin.java @@ -15,6 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback. public class CraftItemStackMixin { @Inject(at = @At("HEAD"), method = "onCraft") private void init(CallbackInfo ci) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableCraftingSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableCraftingSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().craftingVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, volume)); + } } -} +} \ No newline at end of file blob - 0e4d48db1f136119af72d4cbf67658a6a5cc1d1f blob + efb2278adc8c06e8092fb51d831cbdf0ede49913 --- src/main/java/com/hattolo/consolesounds/mixin/ExitScreenMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/ExitScreenMixin.java @@ -1,7 +1,8 @@ package com.hattolo.consolesounds.mixin; -import com.hattolo.consolesounds.ConsoleSoundsClient; import com.hattolo.consolesounds.ConsoleSoundsConfig; +import com.hattolo.consolesounds.ConsoleSoundsSounds; + import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; @@ -21,7 +22,11 @@ public class ExitScreenMixin { //System.out.println("Key pressed"); if (keyCode == GLFW.GLFW_KEY_ESCAPE && screen.shouldCloseOnEsc()) { //System.out.println("Play sound"); - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnMenuExit) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsClient.UI_BACK_EVENT, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnMenuExit) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().menuExitVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsSounds.UI_BACK, 1.0F, volume)); + } } } -} +} \ No newline at end of file blob - 63ca11b7a9d2410ba25d3e75cb0f24bc71902705 blob + 1f576ecda7a66ccbf70159e25c1c5601d58091bd --- src/main/java/com/hattolo/consolesounds/mixin/OpenHandledScreenMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/OpenHandledScreenMixin.java @@ -15,6 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback. public class OpenHandledScreenMixin { @Inject(at = @At("HEAD"), method = "init") private void init(CallbackInfo ci) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnInGameMenu) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnInGameMenu) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().inGameMenuVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK.value(), 1.0F, volume)); + } } -} +} \ No newline at end of file blob - ae08a6349ca0b507281b9d7d00dd1dc0d93856b7 blob + 25c7a1ad871716fb5cabb68bd65fcb6a8d74e9fe --- src/main/java/com/hattolo/consolesounds/mixin/OpenPauseMenuMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/OpenPauseMenuMixin.java @@ -11,12 +11,19 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + + @Mixin(MinecraftClient.class) public class OpenPauseMenuMixin { @Inject(at = @At("TAIL"), method = "openPauseMenu") private void init(boolean pause, CallbackInfo ci) { if (MinecraftClient.getInstance().currentScreen instanceof GameMenuScreen) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnPauseMenu) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().playSoundOnPauseMenu) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().onPauseMenuVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK.value(), 1.0F, volume)); + } } } -} +} \ No newline at end of file blob - 8d5a1160f9475ceb05307443338f7a716524ba3b blob + 5ae1d88155d3a353c80e1f7eea28821106d988cd --- src/main/java/com/hattolo/consolesounds/mixin/ScrollSliderWidgetMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/ScrollSliderWidgetMixin.java @@ -1,7 +1,8 @@ package com.hattolo.consolesounds.mixin; -import com.hattolo.consolesounds.ConsoleSoundsClient; import com.hattolo.consolesounds.ConsoleSoundsConfig; +import com.hattolo.consolesounds.ConsoleSoundsSounds; + import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.client.MinecraftClient; import net.minecraft.client.sound.PositionedSoundInstance; @@ -22,7 +23,11 @@ public class ScrollSliderWidgetMixin { double v = MathHelper.clamp(roundDown2(newValue), 0.0D, 1.0D); double ov = MathHelper.clamp(roundDown2(value), 0.0D, 1.0D); - if (v != ov && AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableSliderSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsClient.UI_SCROLL_EVENT, 1.0F)); + if (v != ov && AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableSliderSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().sliderVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsSounds.UI_SCROLL, 1.0F, volume)); + } //System.out.println("value: " + value + " oldvalue: " + oldValue + " v: " + v + " ov: " + ov); } @@ -31,4 +36,4 @@ public class ScrollSliderWidgetMixin { private static double roundDown2(double d) { return Math.floor(d * 1e2) / 1e2; } -} +} \ No newline at end of file blob - 511962601161d9fd0ebd50da90cd577be67d4d0e blob + 05f01c8d867ed1b91390308f9dcf310fc3dbf6ee --- src/main/java/com/hattolo/consolesounds/mixin/SelectClickableWidgetMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/SelectClickableWidgetMixin.java @@ -1,7 +1,8 @@ package com.hattolo.consolesounds.mixin; -import com.hattolo.consolesounds.ConsoleSoundsClient; import com.hattolo.consolesounds.ConsoleSoundsConfig; +import com.hattolo.consolesounds.ConsoleSoundsSounds; + import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.widget.ClickableWidget; @@ -28,7 +29,11 @@ public class SelectClickableWidgetMixin { if (!widget.active) return; if (!selected) { selected = true; - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableHoverSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsClient.UI_SELECT_EVENT, randFloat(0.95f, 1.05f))); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableHoverSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().hoverVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsSounds.UI_SELECT, randFloat(1.05f, 1.15f), volume)); + } } } else { @@ -44,4 +49,4 @@ public class SelectClickableWidgetMixin { MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleModClient.UI_SELECT_EVENT, 1.0F)); } */ -} +} \ No newline at end of file blob - a9271082b74d14fed6e29126456e2ddd8cdd629a blob + 85723aa38056a1520a870068416a08762c0695bc --- src/main/java/com/hattolo/consolesounds/mixin/SlotClickedRecipeBookMixin.java +++ src/main/java/com/hattolo/consolesounds/mixin/SlotClickedRecipeBookMixin.java @@ -1,7 +1,8 @@ package com.hattolo.consolesounds.mixin; -import com.hattolo.consolesounds.ConsoleSoundsClient; import com.hattolo.consolesounds.ConsoleSoundsConfig; +import com.hattolo.consolesounds.ConsoleSoundsSounds; + import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.recipebook.RecipeBookGhostSlots; @@ -26,8 +27,12 @@ public class SlotClickedRecipeBookMixin { private void slotClicked(@Nullable Slot slot, CallbackInfo ci) { if (slot != null && slot.id < craftingScreenHandler.getCraftingSlotCount()) { if (ghostSlots.getSlotCount() > 0) { - if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableCraftingSounds) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsClient.UI_FAIL_EVENT, 1.0F)); + if (AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().enableCraftingSounds) { + float eventVolume = AutoConfig.getConfigHolder(ConsoleSoundsConfig.class).getConfig().craftingVolume; + float volume = eventVolume / 100.0F; + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(ConsoleSoundsSounds.UI_FAIL, 1.0F, volume)); + } } } } -} +} \ No newline at end of file blob - /dev/null blob + 1b8bbffebe1b08f743f6aa52a113f11b715c29e4 (mode 644) --- /dev/null +++ src/main/java/com/hattolo/consolesounds/ConsoleSoundsSounds.java @@ -0,0 +1,27 @@ +package com.hattolo.consolesounds; + +import com.hattolo.consolesounds.ConsoleSoundsClient; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; +import net.minecraft.sound.SoundEvent; + + +public final class ConsoleSoundsSounds { + + public static final SoundEvent UI_SELECT = register("ui_select"); + + public static final SoundEvent UI_BACK = register("ui_back"); + + public static final SoundEvent UI_SCROLL = register("ui_scroll"); + + public static final SoundEvent UI_FAIL = register("ui_fail"); + + private static SoundEvent register(String name) { + Identifier id = ConsoleSoundsClient.id(name); + return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id)); + } + + public static void init() { + } +} \ No newline at end of file blob - 283894abe95a9c8f54d7c1303f479c4e9afc7028 blob + e6fcb7a8f41e0bba6616454631a3d72f37c3bc5f --- src/main/resources/fabric.mod.json +++ src/main/resources/fabric.mod.json @@ -26,9 +26,9 @@ ], "depends": { - "fabricloader": ">=0.14.10", + "fabricloader": ">=0.14.22", "fabric": "*", - "minecraft": "1.19.2", + "minecraft": "1.20.1", "java": ">=17" }, "suggests": {