diff --git a/CHANGELOG.md b/CHANGELOG.md index 369960f..a8b6e91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1 @@ -Backported features / bugfixes to 1.20.1: -Dragon growl and thunder can now be muffled -Minecart sound when player inside now respect anchors -Anchors now properly shows its radius (thanks rmnvgr) \ No newline at end of file +Fixed crash with some soundless modded sounds \ No newline at end of file diff --git a/common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java b/common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java index 16d8811..53dfb01 100644 --- a/common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java +++ b/common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java @@ -44,7 +44,7 @@ private void esm_captureTickableSoundVolume(SoundInstance sound, CallbackInfo ci private float esm_setVolume(float volume) { SoundInstance tempSound = esmSound; //don't care about forbidden sounds or from the psb - if (tempSound != null && !esm_isForbidden(tempSound) && !PlaySoundButton.isFromPSB()) { + if (tempSound != null && tempSound.getSound() != null && !esm_isForbidden(tempSound) && !PlaySoundButton.isFromPSB()) { ResourceLocation soundLocation = tempSound.getLocation(); //remove sound to prevent repeated sounds and maintains the desired order diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 8b6794e..eeb2cb2 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ licenseURL= "https://github.com/LeoBeliik/ExtremeSoundMuffler/blob/master/LICENS issueTrackerURL="https://github.com/LeoBeliik/ExtremeSoundMuffler/issues" [[mods]] #mandatory modId = "extremesoundmuffler" #mandatory -version = "3.47" #mandatory +version = "3.48" #mandatory displayName="Extreme Sound Muffler" displayURL="https://www.curseforge.com/minecraft/mc-mods/extreme-sound-muffler" logoFile= "esm_logo.png" #optional diff --git a/gradle.properties b/gradle.properties index ff727ef..d29a805 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project -modversion = 3.47 +modversion = 3.48 group=com.leobeliik.extremesoundmuffler # Common diff --git a/neoforge/build.gradle b/neoforge/build.gradle deleted file mode 100644 index b8b7efa..0000000 --- a/neoforge/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -plugins { - id 'idea' - id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.140' - id 'java-library' -} -base { - archivesName = "${mod_name}-${modversion}-neoforge-${minecraft_version}" -} -// Automatically enable neoforge AccessTransformers if the file exists -// This location is hardcoded in FML and can not be changed. -// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118 -if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { - minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg') -} -runs { - configureEach { - modSource project.sourceSets.main - } - client { - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - } - server { - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - programArgument '--nogui' - } - - gameTestServer { - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - } - - data { - programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() - } -} - -sourceSets.main.resources { srcDir 'src/generated/resources' } - -dependencies { - implementation "net.neoforged:neoforge:${neoforge_version}" - compileOnly project(":common") -} - -// NeoGradle compiles the game, but we don't want to add our common code to the game's code -Spec notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec - -tasks.withType(JavaCompile).matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.allSource) -} - -tasks.withType(Javadoc).matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.allJava) -} - -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} - -tasks.withType(ProcessResources).matching(notNeoTask).configureEach { - from project(":common").sourceSets.main.resources -} - -tasks.named("test").configure { - enabled = false -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifactId base.archivesName.get() - from components.java - } - } - repositories { - maven { - url "file://" + System.getenv("local_maven") - } - } -} \ No newline at end of file diff --git a/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/NeoForgeConfig.java b/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/NeoForgeConfig.java deleted file mode 100644 index 23d4813..0000000 --- a/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/NeoForgeConfig.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.leobeliik.extremesoundmuffler; - -import com.leobeliik.extremesoundmuffler.interfaces.ISoundLists; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModContainer; -import net.neoforged.fml.ModLoadingContext; -import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.fml.config.ModConfig; -import net.neoforged.fml.event.config.ModConfigEvent; -import net.neoforged.neoforge.common.ModConfigSpec; - -import java.util.Arrays; -import java.util.List; - -@EventBusSubscriber(modid = Constants.MOD_ID, bus = EventBusSubscriber.Bus.MOD) -class NeoForgeConfig { - - private static ModConfigSpec CLIENT_CONFIG; - private static ModConfigSpec.Builder CLIENT_BUILDER = new ModConfigSpec.Builder(); - private static ModConfigSpec.ConfigValue> forbiddenSounds; - private static ModConfigSpec.BooleanValue lawfulAllList; - private static ModConfigSpec.BooleanValue disableInventoryButton; - private static ModConfigSpec.BooleanValue disableCreativeInventoryButton; - private static ModConfigSpec.BooleanValue disableAnchors; - private static ModConfigSpec.BooleanValue leftButtons; - private static ModConfigSpec.BooleanValue showTip; - private static ModConfigSpec.BooleanValue useDarkTheme; - private static ModConfigSpec.DoubleValue defaultMuteVolume; - private static ModConfigSpec.IntValue invButtonHorizontal; - private static ModConfigSpec.IntValue invButtonVertical; - private static ModConfigSpec.IntValue creativeInvButtonHorizontal; - private static ModConfigSpec.IntValue creativeInvButtonVertical; - - static void init(ModContainer container) { - buildConfig(); - container.registerConfig(ModConfig.Type.CLIENT, NeoForgeConfig.CLIENT_CONFIG); - CommonConfig.set(new CommonConfig.ConfigAccess( - forbiddenSounds, - lawfulAllList, - disableInventoryButton, - disableCreativeInventoryButton, - disableAnchors, - leftButtons, - showTip, - useDarkTheme, - defaultMuteVolume, - invButtonHorizontal, - invButtonVertical, - creativeInvButtonHorizontal, - creativeInvButtonVertical - )); - } - - private static void buildConfig() { - String CATEGORY_GENERAL = "general"; - String CATEGORY_INVENTORY_BUTTON = "inventory_button"; - String CATEGORY_ANCHORS = "Anchors"; - - CLIENT_BUILDER.comment("General settings").push(CATEGORY_GENERAL); - forbiddenSounds = CLIENT_BUILDER.comment("Blacklisted Sounds - add the name of the sounds to blacklist, separated with comma") - .defineList("forbiddenSounds", Arrays.asList("ui.", "music.", "ambient."), o -> o instanceof String); - lawfulAllList = CLIENT_BUILDER.comment("Allow the \"ALL\" sounds list to include the blacklisted sounds?") - .define("lawfulAllList", false); - defaultMuteVolume = CLIENT_BUILDER.comment("Volume set when pressed the mute button by default") - .defineInRange("defaultMuteVolume", 0, 0, 0.9); - leftButtons = CLIENT_BUILDER.comment("Set to true to move the muffle and play buttons to the left side of the GUI") - .define("leftButtons", false); - showTip = CLIENT_BUILDER.comment("Show tips in the Muffler screen?") - .define("showTip", true); - useDarkTheme = CLIENT_BUILDER.comment("Whether or not use the dark theme") - .define("useDarkTheme", false); - CLIENT_BUILDER.pop(); - - CLIENT_BUILDER.comment("Inventory button settings").push(CATEGORY_INVENTORY_BUTTON); - - disableInventoryButton = CLIENT_BUILDER.comment("Disable the Muffle button in the player inventory?") - .define("disableInventoryButton", false); - invButtonHorizontal = CLIENT_BUILDER.comment("Coordinates for the Muffler button in the player inventory.\n " + - "You can change this in game by holding the RMB over the button and draging it around") - .defineInRange("invButtonX", 75, Integer.MIN_VALUE, Integer.MAX_VALUE); - invButtonVertical = CLIENT_BUILDER.comment("Coordinates for the Muffler button in the player inventory. \n" + - "You can change this in game by holding the RMB over the button and draging it around") - .defineInRange("invButtonY", 7, Integer.MIN_VALUE, Integer.MAX_VALUE); - disableCreativeInventoryButton = CLIENT_BUILDER.comment("Disable the Muffle button in the creative player inventory?") - .define("disableCreativeInventoryButton", false); - creativeInvButtonHorizontal = CLIENT_BUILDER.comment("Coordinates for the Muffler button in the creative player inventory.\n " + - "You can change this in game by holding the RMB over the button and draging it around") - .defineInRange("creativeInvButtonX", 2, Integer.MIN_VALUE, Integer.MAX_VALUE); - creativeInvButtonVertical = CLIENT_BUILDER.comment("Coordinates for the Muffler button in the creative player inventory. \n" + - "You can change this in game by holding the RMB over the button and draging it around") - .defineInRange("creativeInvButtonY", 2, Integer.MIN_VALUE, Integer.MAX_VALUE); - CLIENT_BUILDER.pop(); - - CLIENT_BUILDER.comment("Anchor settings").push(CATEGORY_ANCHORS); - - disableAnchors = CLIENT_BUILDER.comment("Disable the Anchors?") - .define("disableAnchors", false); - - CLIENT_BUILDER.pop(); - CLIENT_CONFIG = CLIENT_BUILDER.build(); - } - - @SubscribeEvent - static void onLoad(ModConfigEvent.Loading event) { - ISoundLists.forbiddenSounds.addAll(forbiddenSounds.get()); - } - - static void setInvButtonHorizontal(int x) { - invButtonHorizontal.set(x); - } - - static void setInvButtonVertical(int y) { - invButtonVertical.set(y); - } - - static void setCreativeInvButtonHorizontal(int x) { - creativeInvButtonHorizontal.set(x); - } - - static void setCreativeInvButtonVertical(int y) { - creativeInvButtonVertical.set(y); - } -} diff --git a/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerNeoForge.java b/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerNeoForge.java deleted file mode 100644 index abf53af..0000000 --- a/neoforge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerNeoForge.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.leobeliik.extremesoundmuffler; - -import com.leobeliik.extremesoundmuffler.gui.buttons.InvButton; -import com.leobeliik.extremesoundmuffler.utils.DataManager; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModContainer; -import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent; -import net.neoforged.neoforge.client.event.InputEvent; -import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; -import net.neoforged.neoforge.client.event.ScreenEvent; -import net.neoforged.neoforge.common.NeoForge; - -import static com.leobeliik.extremesoundmuffler.Constants.soundMufflerKey; - -@Mod(Constants.MOD_ID) -public class SoundMufflerNeoForge { - - public SoundMufflerNeoForge(IEventBus modEventBus, ModContainer container) { - NeoForge.EVENT_BUS.register(this); - //prevent server complain when this mod is clientside only - /*ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, - () -> new IExtensionPoint.DisplayTest(() -> "", (a, b) -> true));*/ - NeoForgeConfig.init(container); - } - - @EventBusSubscriber(modid = Constants.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) - public class ClientModListener { - @SubscribeEvent - public static void keyRegistry(final RegisterKeyMappingsEvent event) { - event.register(soundMufflerKey); - } - } - - @OnlyIn(Dist.CLIENT) - @SubscribeEvent //on mod keybind press - public void onKeyInput(InputEvent.Key event) { - if (soundMufflerKey.consumeClick()) { - SoundMufflerCommon.openMainScreen(); - } - } - - @OnlyIn(Dist.CLIENT) - @SubscribeEvent //load data when player joins the world - public void onPlayerJoin(ClientPlayerNetworkEvent.LoggingIn event) { - DataManager.loadData(); - } - - @OnlyIn(Dist.CLIENT) - @SubscribeEvent //save the new coordinates for the inv button - public void onMouseRelease(ScreenEvent.MouseButtonReleased.Post event) { - if (event.getButton() == 1) { - Screen screen = event.getScreen(); - for (GuiEventListener widget : screen.children()) { - if (widget instanceof InvButton btn && btn.isHovered()) { - if (screen instanceof CreativeModeInventoryScreen) { - NeoForgeConfig.setCreativeInvButtonHorizontal(btn.getX()); - NeoForgeConfig.setCreativeInvButtonVertical(btn.getY()); - } else { - NeoForgeConfig.setInvButtonHorizontal(btn.getX()); - NeoForgeConfig.setInvButtonVertical(btn.getY()); - } - break; - } - } - } - } - -} \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/MANIFEST.MF b/neoforge/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 9736cbb..0000000 --- a/neoforge/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1 +0,0 @@ -MixinConnector: com.leobeliik.extremesoundmuffler.MixinConnector diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml deleted file mode 100644 index 8514e40..0000000 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ /dev/null @@ -1,30 +0,0 @@ -modLoader = "javafml" #mandatory -loaderVersion = "21.0.0" #mandatory -license = "GNU LESSER GENERAL PUBLIC LICENSE" # Review your options at https://choosealicense.com/. -licenseURL = "https://github.com/LeoBeliik/ExtremeSoundMuffler/blob/master/LICENSE.txt" -issueTrackerURL = "https://github.com/LeoBeliik/ExtremeSoundMuffler/issues" -[[mods]] #mandatory -modId = "extremesoundmuffler" #mandatory -version = "3.46" #mandatory -displayName = "Extreme Sound Muffler" -logoFile = "esm_logo.png" #optional -authors = "LeoBeliik" -description = ''' -This mod allows you to muffle (almost) any sound selectively, -allowing you to choose the volume of the sound you want between mute and 90%. -This mod also works Clientside only. -''' -[[mixins]] -config = "extremesoundmuffler.mixins.json" -[[dependencies.extremesoundmuffler]] #optional -modId = "neoforge" #mandatory -type = "required" #mandatory -versionRange = "[21.0.0-beta,)" #mandatory -ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory -side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER' -[[dependencies.extremesoundmuffler]] -modId = "minecraft" -type = "required" -versionRange = "[1.21]" -ordering = "NONE" -side = "BOTH" \ No newline at end of file diff --git a/neoforge/src/main/resources/extremesoundmuffler.mixins.json b/neoforge/src/main/resources/extremesoundmuffler.mixins.json deleted file mode 100644 index 92f73c6..0000000 --- a/neoforge/src/main/resources/extremesoundmuffler.mixins.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "com.leobeliik.extremesoundmuffler.mixins", - "compatibilityLevel": "JAVA_21", - "client": [ - "InventoryScreenMixin", - "CreativeInventoryScreenMixin", - "SoundMixin" - ], - "injectors": { - "defaultRequire": 1 - }, - "refmap": "extremesoundmuffler.refmap.json" -} - \ No newline at end of file