diff --git a/MinecraftMod/core/build.gradle b/MinecraftMod/core/build.gradle index 83f556e..566a64f 100644 --- a/MinecraftMod/core/build.gradle +++ b/MinecraftMod/core/build.gradle @@ -4,7 +4,7 @@ plugins { id 'application' } -version = 3.0 +version = '3.1.0' group = 'com.mosadie.effectmc' archivesBaseName = "EffectMC-Core" diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectExecutor.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectExecutor.java index 0d08c86..8afedd9 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectExecutor.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectExecutor.java @@ -65,4 +65,6 @@ public interface EffectExecutor { String getSPWorldName(); String getServerIP(); + + void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume); } diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectMCCore.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectMCCore.java index 3e467f3..b301345 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectMCCore.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/EffectMCCore.java @@ -79,6 +79,7 @@ public EffectMCCore(File configFile, File trustFile, EffectExecutor executor) { registerEffect(new SetRenderDistanceEffect()); registerEffect(new RejoinEffect()); registerEffect(new ShowItemToastEffect()); + registerEffect(new SetVolumeEffect()); effectHandler = new EffectHandler(this, effectMap); } diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SetVolumeEffect.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SetVolumeEffect.java new file mode 100644 index 0000000..77f4f6c --- /dev/null +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SetVolumeEffect.java @@ -0,0 +1,79 @@ +package com.mosadie.effectmc.core.effect; + +import com.mosadie.effectmc.core.EffectMCCore; +import com.mosadie.effectmc.core.effect.internal.Effect; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class SetVolumeEffect extends Effect { + + private final static int MAX_VOLUME = 100; + private final static int MIN_VOLUME = 0; + + public SetVolumeEffect() { + super(); + getPropertyManager().addIntegerProperty("volume", 100, true, "Volume", "100"); + getPropertyManager().addCommentProperty("Use whole numbers between 0 and 100."); + getPropertyManager().addSelectionProperty("category", VOLUME_CATEGORIES.MASTER.toString(), true, "Category", VOLUME_CATEGORIES.toStringArray()); + getPropertyManager().lock(); + } + @Override + public String getEffectName() { + return "Set Volume"; + } + + @Override + public String getEffectTooltip() { + return "Set the volume of a specific category."; + } + + @Override + public EffectResult execute(EffectMCCore core, Map args) { + if (!getPropertyManager().argumentCheck(args)) { + return new EffectResult("Invalid Arguments", EffectResult.Result.ERROR); + } + + int volume = getPropAsInt(args, "volume"); + VOLUME_CATEGORIES category = VOLUME_CATEGORIES.getFromName(getPropAsString(args, "category")); + + if (category == null) { + return new EffectResult("Invalid category", EffectResult.Result.ERROR); + } + + volume = Math.min(MAX_VOLUME, Math.max(MIN_VOLUME, volume)); + + core.getExecutor().setVolume(category, volume); + return new EffectResult("Set volume of " + category + " to " + volume, EffectResult.Result.SUCCESS); + } + + public enum VOLUME_CATEGORIES { + MASTER, + MUSIC, + RECORDS, + WEATHER, + BLOCKS, + HOSTILE, + NEUTRAL, + PLAYERS, + AMBIENT, + VOICE; + + public static VOLUME_CATEGORIES getFromName(String name) { + try { + return VOLUME_CATEGORIES.valueOf(name); + } catch (IllegalArgumentException e) { + return null; + } + } + + public static String[] toStringArray() { + List list = new ArrayList<>(); + for (VOLUME_CATEGORIES category : VOLUME_CATEGORIES.values()) { + list.add(category.name()); + } + return list.toArray(new String[0]); + } + } +} diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SkinLayerEffect.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SkinLayerEffect.java index 140c442..e10687a 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SkinLayerEffect.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/SkinLayerEffect.java @@ -33,16 +33,16 @@ public EffectResult execute(EffectMCCore core, Map args) { return new EffectResult("Invalid Arguments", EffectResult.Result.ERROR); } - VISIBILITY visibility = VISIBILITY.valueOf(getPropAsString(args, "visibility")); - SKIN_SECTION section = SKIN_SECTION.valueOf(getPropAsString(args, "section")); + VISIBILITY visibility = VISIBILITY.getFromName(getPropAsString(args, "visibility")); + SKIN_SECTION section = SKIN_SECTION.getFromName(getPropAsString(args, "section")); if (visibility == VISIBILITY.TOGGLE) { - if (core.getExecutor().toggleSkinLayer(section)) + if (section != null && core.getExecutor().toggleSkinLayer(section)) return new EffectResult("Toggled " + section + " skin section", EffectResult.Result.SUCCESS); else return new EffectResult("Failed to toggle skin section.", EffectResult.Result.ERROR); } else { - if (core.getExecutor().setSkinLayer(section, visibility == VISIBILITY.SHOW)) + if (section != null && core.getExecutor().setSkinLayer(section, visibility == VISIBILITY.SHOW)) return new EffectResult("Set " + section + " to " + visibility, EffectResult.Result.SUCCESS); else return new EffectResult("Failed to set skin section visibility.", EffectResult.Result.ERROR); @@ -89,5 +89,13 @@ public static String[] toStringArray() { } return list.toArray(new String[0]); } + + public static VISIBILITY getFromName(String name) { + try { + return VISIBILITY.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return null; + } + } } } \ No newline at end of file diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/internal/Effect.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/internal/Effect.java index d3cd2ee..4abf4cb 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/internal/Effect.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/effect/internal/Effect.java @@ -27,6 +27,7 @@ public enum Result { SKIPPED, UNAUTHORIZED, ERROR, + UNSUPPORTED, UNKNOWN } @@ -42,7 +43,7 @@ public boolean isSuccess() { } public boolean isError() { - return result == Result.ERROR || result == Result.UNAUTHORIZED || result == Result.SKIPPED; + return result == Result.ERROR || result == Result.UNAUTHORIZED || result == Result.SKIPPED || result == Result.UNKNOWN || result == Result.UNSUPPORTED; } } diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/EffectHandler.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/EffectHandler.java index e7b3fc2..1783a39 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/EffectHandler.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/EffectHandler.java @@ -70,7 +70,9 @@ public Effect.EffectResult handleRequest(Device device, EffectRequest request) { } // Execute the effect - return effect.execute(core, request.getArgs()); + Effect.EffectResult result = effect.execute(core, request.getArgs()); + core.getExecutor().log("Effect Result: (" + result.result.name() + ") " + result.message); + return result; } public static class EffectTranslatableComponent { diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRawRequestHandler.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRawRequestHandler.java index 6fbc75d..bfc2ee0 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRawRequestHandler.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRawRequestHandler.java @@ -115,6 +115,9 @@ public void handle(HttpExchange exchange) throws IOException { case SUCCESS: status = 200; break; + case UNSUPPORTED: + status = 501; + break; } // Send response diff --git a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRequestHandler.java b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRequestHandler.java index 7d6c113..5d0214f 100644 --- a/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRequestHandler.java +++ b/MinecraftMod/core/src/main/java/com/mosadie/effectmc/core/handler/http/EffectRequestHandler.java @@ -123,6 +123,9 @@ public void handle(HttpExchange exchange) throws IOException { case SUCCESS: status = 200; break; + case UNSUPPORTED: + status = 501; + break; } // Send response diff --git a/MinecraftMod/fabric/1.16.4/gradle.properties b/MinecraftMod/fabric/1.16.4/gradle.properties index 88e1c50..d1bbfa5 100644 --- a/MinecraftMod/fabric/1.16.4/gradle.properties +++ b/MinecraftMod/fabric/1.16.4/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.8 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.16.4 @@ -16,4 +16,4 @@ org.gradle.jvmargs=-Xmx1G # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api fabric_version=0.42.0+1.16 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.16.4/src/main/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.16.4/src/main/java/com/mosadie/effectmc/EffectMC.java index a563611..2fd81f3 100644 --- a/MinecraftMod/fabric/1.16.4/src/main/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.16.4/src/main/java/com/mosadie/effectmc/EffectMC.java @@ -681,6 +681,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.setSoundVolume(mcCategory, (volume / 100.0f)); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.17.1/gradle.properties b/MinecraftMod/fabric/1.17.1/gradle.properties index 760396f..8da7b05 100644 --- a/MinecraftMod/fabric/1.17.1/gradle.properties +++ b/MinecraftMod/fabric/1.17.1/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.8 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.17.1 # Dependencies fabric_version=0.46.1+1.17 - effectmc_core_version=3.0 \ No newline at end of file + effectmc_core_version=3.1.0 \ No newline at end of file diff --git a/MinecraftMod/fabric/1.17.1/src/main/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.17.1/src/main/java/com/mosadie/effectmc/EffectMC.java index 2f8129b..0099702 100644 --- a/MinecraftMod/fabric/1.17.1/src/main/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.17.1/src/main/java/com/mosadie/effectmc/EffectMC.java @@ -685,6 +685,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.setSoundVolume(mcCategory, (volume / 100.0f)); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.18.2/gradle.properties b/MinecraftMod/fabric/1.18.2/gradle.properties index ae7616d..067b87d 100644 --- a/MinecraftMod/fabric/1.18.2/gradle.properties +++ b/MinecraftMod/fabric/1.18.2/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.8 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.18.2 # Dependencies fabric_version=0.56.1+1.18.2 - effectmc_core_version=3.0 \ No newline at end of file + effectmc_core_version=3.1.0 \ No newline at end of file diff --git a/MinecraftMod/fabric/1.18.2/src/main/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.18.2/src/main/java/com/mosadie/effectmc/EffectMC.java index 639e830..5b31a95 100644 --- a/MinecraftMod/fabric/1.18.2/src/main/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.18.2/src/main/java/com/mosadie/effectmc/EffectMC.java @@ -682,6 +682,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.setSoundVolume(mcCategory, (volume / 100.0f)); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.19.4/gradle.properties b/MinecraftMod/fabric/1.19.4/gradle.properties index f0294b2..7fc82db 100644 --- a/MinecraftMod/fabric/1.19.4/gradle.properties +++ b/MinecraftMod/fabric/1.19.4/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.19 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.19.4 # Dependencies fabric_version=0.81.0+1.19.4 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.19.4/src/main/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.19.4/src/main/java/com/mosadie/effectmc/EffectMC.java index 1ece3dc..96bfbed 100644 --- a/MinecraftMod/fabric/1.19.4/src/main/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.19.4/src/main/java/com/mosadie/effectmc/EffectMC.java @@ -721,6 +721,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.20.1/gradle.properties b/MinecraftMod/fabric/1.20.1/gradle.properties index c89f4d0..8884bfb 100644 --- a/MinecraftMod/fabric/1.20.1/gradle.properties +++ b/MinecraftMod/fabric/1.20.1/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.21 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.20.1 # Dependencies fabric_version=0.85.0+1.20.1 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.20.1/src/main/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.20.1/src/main/java/com/mosadie/effectmc/EffectMC.java index 216a155..70799dd 100644 --- a/MinecraftMod/fabric/1.20.1/src/main/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.20.1/src/main/java/com/mosadie/effectmc/EffectMC.java @@ -720,6 +720,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.20.6/gradle.properties b/MinecraftMod/fabric/1.20.6/gradle.properties index 1d38f59..8730ed0 100644 --- a/MinecraftMod/fabric/1.20.6/gradle.properties +++ b/MinecraftMod/fabric/1.20.6/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.15.11 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.20.6 # Dependencies fabric_version=0.100.0+1.20.6 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.20.6/src/client/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.20.6/src/client/java/com/mosadie/effectmc/EffectMC.java index 187f0c5..9abeb88 100644 --- a/MinecraftMod/fabric/1.20.6/src/client/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.20.6/src/client/java/com/mosadie/effectmc/EffectMC.java @@ -765,6 +765,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.21.3/gradle.properties b/MinecraftMod/fabric/1.21.3/gradle.properties index 6664341..96c3e2f 100644 --- a/MinecraftMod/fabric/1.21.3/gradle.properties +++ b/MinecraftMod/fabric/1.21.3/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.16.7 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.21.3 # Dependencies fabric_version=0.106.1+1.21.3 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.21.3/src/client/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.21.3/src/client/java/com/mosadie/effectmc/EffectMC.java index a87f49b..c263f7a 100644 --- a/MinecraftMod/fabric/1.21.3/src/client/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.21.3/src/client/java/com/mosadie/effectmc/EffectMC.java @@ -779,6 +779,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/fabric/1.21/gradle.properties b/MinecraftMod/fabric/1.21/gradle.properties index 213cb2f..17417d8 100644 --- a/MinecraftMod/fabric/1.21/gradle.properties +++ b/MinecraftMod/fabric/1.21/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.15.11 # Mod Properties - mod_version = 3.0.0 + mod_version = 3.1.0 maven_group = com.mosadie.effectmc archives_base_name = effectmc-fabric-1.21 # Dependencies fabric_version=0.100.1+1.21 - effectmc_core_version=3.0 + effectmc_core_version=3.1.0 diff --git a/MinecraftMod/fabric/1.21/src/client/java/com/mosadie/effectmc/EffectMC.java b/MinecraftMod/fabric/1.21/src/client/java/com/mosadie/effectmc/EffectMC.java index 8f4942c..432bed8 100644 --- a/MinecraftMod/fabric/1.21/src/client/java/com/mosadie/effectmc/EffectMC.java +++ b/MinecraftMod/fabric/1.21/src/client/java/com/mosadie/effectmc/EffectMC.java @@ -775,6 +775,62 @@ public String getServerIP() { return null; } + @Override + public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) { + MinecraftClient.getInstance().execute(() -> { + SoundCategory mcCategory; + + switch (category) { + case MASTER: + mcCategory = SoundCategory.MASTER; + break; + + case MUSIC: + mcCategory = SoundCategory.MUSIC; + break; + + case RECORDS: + mcCategory = SoundCategory.RECORDS; + break; + + case WEATHER: + mcCategory = SoundCategory.WEATHER; + break; + + case BLOCKS: + mcCategory = SoundCategory.BLOCKS; + break; + + case HOSTILE: + mcCategory = SoundCategory.HOSTILE; + break; + + case NEUTRAL: + mcCategory = SoundCategory.NEUTRAL; + break; + + case PLAYERS: + mcCategory = SoundCategory.PLAYERS; + break; + + case AMBIENT: + mcCategory = SoundCategory.AMBIENT; + break; + + case VOICE: + mcCategory = SoundCategory.VOICE; + break; + + default: + LOGGER.error("Unknown volume category!"); + return; + } + + MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d); + MinecraftClient.getInstance().options.write(); + }); + } + private void connectIfTrue(boolean connect) { if (connect) { joinServer(serverInfo.address); diff --git a/MinecraftMod/forge/1.16.4/.idea/modules/1.16.4.main.iml b/MinecraftMod/forge/1.16.4/.idea/modules/1.16.4.main.iml index e2ca040..af5b3e5 100644 --- a/MinecraftMod/forge/1.16.4/.idea/modules/1.16.4.main.iml +++ b/MinecraftMod/forge/1.16.4/.idea/modules/1.16.4.main.iml @@ -19,4 +19,8 @@