diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-03-28 17:46:45 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-03-28 17:46:45 -0400 |
commit | 57e5469f651610a4f07bf8e5266b789d7ca1fe34 (patch) | |
tree | 269182a8c643b6ce197e12c35b8253b6eb9bb019 /src | |
parent | 786efa0ea48daffb075d2d6482a677571e136a1b (diff) | |
download | SkyblockMod-57e5469f651610a4f07bf8e5266b789d7ca1fe34.tar.gz SkyblockMod-57e5469f651610a4f07bf8e5266b789d7ca1fe34.tar.bz2 SkyblockMod-57e5469f651610a4f07bf8e5266b789d7ca1fe34.zip |
Change /dsmmusic volume to percentage from decibels
Also fix custom music not cancelling note block music
Diffstat (limited to 'src')
4 files changed, 31 insertions, 31 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 17def9a..0d6dbac 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -62,7 +62,7 @@ import java.util.Map; @Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true) public class DankersSkyblockMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.8.6-beta5"; + public static final String VERSION = "1.8.6-beta6"; public static int titleTimer = -1; public static boolean showTitle = false; public static String titleText = ""; diff --git a/src/main/java/me/Danker/commands/CustomMusicCommand.java b/src/main/java/me/Danker/commands/CustomMusicCommand.java index 6412474..0e80dd3 100644 --- a/src/main/java/me/Danker/commands/CustomMusicCommand.java +++ b/src/main/java/me/Danker/commands/CustomMusicCommand.java @@ -24,7 +24,7 @@ public class CustomMusicCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <stop/reload/volume> [dungeonboss/bloodroom/dungeon] [#]"; + return "/" + getCommandName() + " <stop/reload/volume> [dungeonboss/bloodroom/dungeon] [1-100]"; } public static String usage(ICommandSender arg0) { @@ -75,7 +75,7 @@ public class CustomMusicCommand extends CommandBase { return; } - float volume = Float.parseFloat(arg1[2]); + int volume = Integer.parseInt(arg1[2]); boolean success; switch (arg1[1].toLowerCase()) { @@ -85,8 +85,8 @@ public class CustomMusicCommand extends CommandBase { return; } - CustomMusic.dungeonbossDecibels = volume; - ConfigHandler.writeIntConfig("music", "DungeonBossDecibels", (int) volume); + CustomMusic.dungeonbossVolume = volume; + ConfigHandler.writeIntConfig("music", "DungeonBossVolume", volume); break; case "bloodroom": success = CustomMusic.bloodroom.setVolume(volume); @@ -94,8 +94,8 @@ public class CustomMusicCommand extends CommandBase { return; } - CustomMusic.bloodroomDecibels = volume; - ConfigHandler.writeIntConfig("music", "BloodRoomDecibels", (int) volume); + CustomMusic.bloodroomVolume = volume; + ConfigHandler.writeIntConfig("music", "BloodRoomVolume", volume); break; case "dungeon": success = CustomMusic.dungeon.setVolume(volume); @@ -103,15 +103,15 @@ public class CustomMusicCommand extends CommandBase { return; } - CustomMusic.dungeonDecibels = volume; - ConfigHandler.writeIntConfig("music", "DungeonDecibels", (int) volume); + CustomMusic.dungeonVolume = volume; + ConfigHandler.writeIntConfig("music", "DungeonVolume", volume); break; default: player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); return; } - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.SECONDARY_COLOUR + arg1[1] + DankersSkyblockMod.MAIN_COLOUR + " was set to " + DankersSkyblockMod.SECONDARY_COLOUR + volume + "db")); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.SECONDARY_COLOUR + arg1[1] + DankersSkyblockMod.MAIN_COLOUR + " was set to " + DankersSkyblockMod.SECONDARY_COLOUR + volume + "%")); break; default: player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java index 342913f..4b1f6bb 100644 --- a/src/main/java/me/Danker/features/CustomMusic.java +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -28,11 +28,11 @@ public class CustomMusic { static boolean prevInDungeonBossRoom = false; public static boolean inDungeonBossRoom = false; public static Song dungeonboss; - public static float dungeonbossDecibels; + public static int dungeonbossVolume; public static Song bloodroom; - public static float bloodroomDecibels; + public static int bloodroomVolume; public static Song dungeon; - public static float dungeonDecibels; + public static int dungeonVolume; @SubscribeEvent public void onWorldChange(WorldEvent.Load event) { @@ -66,9 +66,6 @@ public class CustomMusic { if (!prevInDungeonBossRoom) { dungeonboss.start(); } - } else { - inDungeonBossRoom = false; - dungeonboss.stop(); } } } @@ -100,8 +97,8 @@ public class CustomMusic { @SubscribeEvent public void onSound(PlaySoundEvent event) { - if (cancelNotes) { - if (event.isCancelable() && event.name.startsWith("note.")) event.setCanceled(true); + if (cancelNotes && event.name.startsWith("note.")) { + event.result = null; } } @@ -114,19 +111,18 @@ public class CustomMusic { File dungeonBossFile = new File(directory + "/dungeonboss.wav"); System.out.println("dungeonboss.wav exists?: " + dungeonBossFile.exists()); - dungeonboss = new Song(dungeonBossFile, dungeonbossDecibels); + dungeonboss = new Song(dungeonBossFile, dungeonbossVolume); File bloodRoomFile = new File(directory + "/bloodroom.wav"); System.out.println("bloodroom.wav exists?: " + bloodRoomFile.exists()); - bloodroom = new Song(bloodRoomFile, bloodroomDecibels); + bloodroom = new Song(bloodRoomFile, bloodroomVolume); File dungeonFile = new File(directory + "/dungeon.wav"); System.out.println("dungeon.wav exists?: " + dungeonFile.exists()); - dungeon = new Song(dungeonFile, dungeonDecibels); + dungeon = new Song(dungeonFile, dungeonVolume); } public static void reset() { - cancelNotes = false; if (dungeonboss != null) dungeonboss.stop(); if (bloodroom != null) bloodroom.stop(); if (dungeon != null) dungeon.stop(); @@ -136,20 +132,20 @@ public class CustomMusic { public Clip music; - public Song(File file, float decibels) throws IOException, UnsupportedAudioFileException, LineUnavailableException { + public Song(File file, int volume) throws IOException, UnsupportedAudioFileException, LineUnavailableException { if (file.exists()) { music = AudioSystem.getClip(); AudioInputStream ais = AudioSystem.getAudioInputStream(file); music.open(ais); - setVolume(decibels); + setVolume(volume); } } public void start() { reset(); - cancelNotes = true; if (music != null) { + cancelNotes = true; music.setMicrosecondPosition(0); music.start(); music.loop(Clip.LOOP_CONTINUOUSLY); @@ -161,13 +157,17 @@ public class CustomMusic { if (music != null) music.stop(); } - public boolean setVolume(float decibels) { + public boolean setVolume(int volume) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; if (music == null) return false; + if (volume <= 0 || volume > 100) { + if (player != null) player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Volume can only be set between 0% and 100%.")); + return false; + } + float decibels = (float) (20 * Math.log(volume / 100.0)); FloatControl control = (FloatControl) music.getControl(FloatControl.Type.MASTER_GAIN); if (decibels <= control.getMinimum() || decibels >= control.getMaximum()) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player != null) player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Volume can only be set between " + control.getMinimum() + " and " + control.getMaximum() + ".")); return false; } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 6d474d4..1551a3e 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -277,9 +277,9 @@ public class ConfigHandler { ToggleCommand.bloodRoomMusic = initBoolean("toggles", "BloodRoomMusic", false); ToggleCommand.dungeonMusic = initBoolean("toggles", "DungeonMusic", false); // Music Volume - CustomMusic.dungeonbossDecibels = (float) initInt("music", "DungeonBossDecibels", -20); - CustomMusic.bloodroomDecibels = (float) initInt("music", "BloodRoomDecibels", -20); - CustomMusic.dungeonDecibels = (float) initInt("music", "DungeonDecibels", -20); + CustomMusic.dungeonbossVolume = initInt("music", "DungeonBossVolume", 50); + CustomMusic.bloodroomVolume = initInt("music", "BloodRoomVolume", 50); + CustomMusic.dungeonVolume = initInt("music", "DungeonVolume", 50); // API if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); |