From 13dc028a2f3c7554d4d396958f14a502aa194f3a Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 3 Jul 2024 14:34:58 -0300 Subject: [PATCH] Added check for modded sounds with no sound ?? --- CHANGELOG.md | 4 +- build.gradle | 2 - .../mixins/SoundMixin.java | 2 +- forge/build.gradle | 123 ------------------ .../extremesoundmuffler/ForgeConfig.java | 119 ----------------- .../SoundMufflerForge.java | 79 ----------- forge/src/main/resources/META-INF/MANIFEST.MF | 1 - forge/src/main/resources/META-INF/mods.toml | 29 ----- .../resources/extremesoundmuffler.mixins.json | 15 --- gradle.properties | 5 +- .../resources/META-INF/neoforge.mods.toml | 2 +- settings.gradle | 5 - 12 files changed, 4 insertions(+), 382 deletions(-) delete mode 100644 forge/build.gradle delete mode 100644 forge/src/main/java/com/leobeliik/extremesoundmuffler/ForgeConfig.java delete mode 100644 forge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerForge.java delete mode 100644 forge/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 forge/src/main/resources/META-INF/mods.toml delete mode 100644 forge/src/main/resources/extremesoundmuffler.mixins.json diff --git a/CHANGELOG.md b/CHANGELOG.md index a77f563..3551942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1 @@ -Dragon growl can now be muffled - -Anchors now properly shows its radius (thanks rmnvgr) +Fixed crash with some soundless modded sounds diff --git a/build.gradle b/build.gradle index 6c67ef2..11d7a4d 100644 --- a/build.gradle +++ b/build.gradle @@ -60,8 +60,6 @@ subprojects { "version": modversion, "group": project.group, //Else we target the task's group. "minecraft_version": minecraft_version, - //"forge_version": forge_version, - //"forge_version_range": forge_version, "minecraft_version_range": minecraft_version, "fabric_version": fabric_version, "fabric_loader_version": fabric_loader_version, 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/build.gradle b/forge/build.gradle deleted file mode 100644 index edac453..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,123 +0,0 @@ -plugins { - id 'idea' - id 'maven-publish' - id 'net.minecraftforge.gradle' version '[6.0,6.2)' - id 'org.spongepowered.mixin' version '0.7.+' -} -base { - archivesName = "${mod_name}-${modversion}-forge-${minecraft_version}" -} -java.toolchain.languageVersion = JavaLanguageVersion.of(21) -mixin { - add(sourceSets.main, "${mod_id}.refmap.json") - - config("${mod_id}.mixins.json") -} - -minecraft { - mappings channel: 'official', version: minecraft_version - - copyIdeResources = true //Calls processResources when in dev - - // Automatically enable forge AccessTransformers if the file exists - // This location is hardcoded in Forge and can not be changed. - // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 - if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - } - - runs { - client { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Client' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - property 'forge.enabledGameTestNamespaces', 'extremesoundmuffler' - mods { - modClientRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Server' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - mods { - modServerRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - - data { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - taskName 'Data' - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - mods { - modDataRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - } -} - -sourceSets.main.resources.srcDir 'src/generated/resources' - -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - compileOnly project(":common") - annotationProcessor("org.spongepowered:mixin:0.8.+:processor") - - // Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transtive dependencies request 6.0+ - implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } - -} - -tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.allSource) -} -tasks.withType(Javadoc).configureEach { - source(project(":common").sourceSets.main.allJava) -} -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} - -processResources { - from project(":common").sourceSets.main.resources -} - -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava(MavenPublication) { - artifactId base.archivesName.get() - from components.java - fg.component(it) - } - } - repositories { - maven { - url "file://" + System.getenv("local_maven") - } - } -} - -sourceSets.each { - def dir = layout.buildDirectory.dir("sourcesSets/$it.name") - it.output.resourcesDir = dir - it.java.destinationDirectory = dir -} \ No newline at end of file diff --git a/forge/src/main/java/com/leobeliik/extremesoundmuffler/ForgeConfig.java b/forge/src/main/java/com/leobeliik/extremesoundmuffler/ForgeConfig.java deleted file mode 100644 index 337ca0f..0000000 --- a/forge/src/main/java/com/leobeliik/extremesoundmuffler/ForgeConfig.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.leobeliik.extremesoundmuffler; - -import com.leobeliik.extremesoundmuffler.interfaces.ISoundLists; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.config.ModConfigEvent; -import java.util.Arrays; -import java.util.List; - -@Mod.EventBusSubscriber -class ForgeConfig { - - private static ForgeConfigSpec CLIENT_CONFIG; - private static ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); - private static ForgeConfigSpec.ConfigValue> forbiddenSounds; - private static ForgeConfigSpec.BooleanValue lawfulAllList; - private static ForgeConfigSpec.BooleanValue disableInventoryButton; - private static ForgeConfigSpec.BooleanValue disableCreativeInventoryButton; - private static ForgeConfigSpec.BooleanValue disableAnchors; - private static ForgeConfigSpec.BooleanValue leftButtons; - private static ForgeConfigSpec.BooleanValue showTip; - private static ForgeConfigSpec.BooleanValue useDarkTheme; - private static ForgeConfigSpec.DoubleValue defaultMuteVolume; - private static ForgeConfigSpec.IntValue invButtonHorizontal; - private static ForgeConfigSpec.IntValue invButtonVertical; - private static ForgeConfigSpec.IntValue creativeInvButtonHorizontal; - private static ForgeConfigSpec.IntValue creativeInvButtonVertical; - - static void init() { - buildConfig(); - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.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(); - } - - 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/forge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerForge.java b/forge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerForge.java deleted file mode 100644 index 3891078..0000000 --- a/forge/src/main/java/com/leobeliik/extremesoundmuffler/SoundMufflerForge.java +++ /dev/null @@ -1,79 +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.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.ClientPlayerNetworkEvent; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.client.event.RegisterKeyMappingsEvent; -import net.minecraftforge.client.event.ScreenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.IExtensionPoint; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import static com.leobeliik.extremesoundmuffler.Constants.*; - -@Mod(MOD_ID) -public class SoundMufflerForge { - - public SoundMufflerForge() { - MinecraftForge.EVENT_BUS.register(this); - IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); - //prevent server complain when this mod is clientside only - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, - () -> new IExtensionPoint.DisplayTest(() -> "", (a, b) -> true)); - - ForgeConfig.init(); - MinecraftForge.EVENT_BUS.register(this); - bus.addListener(ForgeConfig::onLoad); - } - - @Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.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 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 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) { - ForgeConfig.setCreativeInvButtonHorizontal(btn.getX()); - ForgeConfig.setCreativeInvButtonVertical(btn.getY()); - } else { - ForgeConfig.setInvButtonHorizontal(btn.getX()); - ForgeConfig.setInvButtonVertical(btn.getY()); - } - break; - } - } - } - } -} \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/MANIFEST.MF b/forge/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 9736cbb..0000000 --- a/forge/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1 +0,0 @@ -MixinConnector: com.leobeliik.extremesoundmuffler.MixinConnector diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 8d48eaf..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,29 +0,0 @@ -modLoader = "javafml" #mandatory -loaderVersion = "51.0.0" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions. -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" -displayURL="https://www.curseforge.com/minecraft/mc-mods/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. -''' -[[dependencies.extremesoundmuffler]] #optional -modId = "forge" #mandatory -mandatory = true #mandatory -versionRange = "[51.0.0,)" #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" -mandatory = true -versionRange = "[1.21]" -ordering = "NONE" -side = "BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/extremesoundmuffler.mixins.json b/forge/src/main/resources/extremesoundmuffler.mixins.json deleted file mode 100644 index 4c33972..0000000 --- a/forge/src/main/resources/extremesoundmuffler.mixins.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "com.leobeliik.extremesoundmuffler.mixins", - "compatibilityLevel": "JAVA_18", - "client": [ - "InventoryScreenMixin", - "CreativeInventoryScreenMixin", - "SoundMixin" - ], - "injectors": { - "defaultRequire": 1 - }, - "refmap": "extremesoundmuffler.refmap.json" -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1fa83a9..daa1c8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project -modversion = 3.47 +modversion = 3.48 group=com.leobeliik.extremesoundmuffler # Common @@ -8,9 +8,6 @@ common_runs_enabled=false common_client_run_name=Common Client common_server_run_name=Common Server -# Forge -forge_version=51.0.0 - # NeoForge neoforge_version=21.0.0-beta diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 8514e40..06dce7b 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -5,7 +5,7 @@ licenseURL = "https://github.com/LeoBeliik/ExtremeSoundMuffler/blob/master/LICEN issueTrackerURL = "https://github.com/LeoBeliik/ExtremeSoundMuffler/issues" [[mods]] #mandatory modId = "extremesoundmuffler" #mandatory -version = "3.46" #mandatory +version = "3.48" #mandatory displayName = "Extreme Sound Muffler" logoFile = "esm_logo.png" #optional authors = "LeoBeliik" diff --git a/settings.gradle b/settings.gradle index b6a7f0a..c8c5a88 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,10 +9,6 @@ pluginManagement { name = 'NeoForge' url = 'https://maven.neoforged.net/releases/' } - maven { - name = 'Forge' - url = 'https://maven.minecraftforge.net/' - } maven { name = 'Sponge Snapshots' url = 'https://repo.spongepowered.org/repository/maven-public/' @@ -28,5 +24,4 @@ plugins { rootProject.name = 'ExtremeSoundMuffler' include("common") include("fabric") -include("forge") include("neoforge")