diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-03-24 14:59:29 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-03-24 14:59:29 -0400 |
commit | e499665f275c324bcbf4c3c78b6ef40c20ba611b (patch) | |
tree | 8b521054c8f188ae0cf0606b3e3f968b2b512319 /src/main/java/me/Danker/features | |
parent | 68a5e182ae5ad4760a2d1cd3974a6bfe4090c625 (diff) | |
download | SkyblockMod-e499665f275c324bcbf4c3c78b6ef40c20ba611b.tar.gz SkyblockMod-e499665f275c324bcbf4c3c78b6ef40c20ba611b.tar.bz2 SkyblockMod-e499665f275c324bcbf4c3c78b6ef40c20ba611b.zip |
Add dungeon and blood room custom music
Diffstat (limited to 'src/main/java/me/Danker/features')
-rw-r--r-- | src/main/java/me/Danker/features/ArachneESP.java | 10 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/CustomMusic.java | 111 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/SlayerESP.java | 1 |
3 files changed, 86 insertions, 36 deletions
diff --git a/src/main/java/me/Danker/features/ArachneESP.java b/src/main/java/me/Danker/features/ArachneESP.java index 1a9b0b2..491c42a 100644 --- a/src/main/java/me/Danker/features/ArachneESP.java +++ b/src/main/java/me/Danker/features/ArachneESP.java @@ -1,27 +1,17 @@ package me.Danker.features; -import me.Danker.DankersSkyblockMod; import me.Danker.commands.ToggleCommand; import me.Danker.handlers.ScoreboardHandler; import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.EntitySpider; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.passive.EntityWolf; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StringUtils; import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.player.AttackEntityEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - import java.util.List; diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java index ee0a2cc..342913f 100644 --- a/src/main/java/me/Danker/features/CustomMusic.java +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -6,6 +6,8 @@ import me.Danker.handlers.ScoreboardHandler; import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.StringUtils; import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -22,10 +24,15 @@ import java.util.List; public class CustomMusic { + static boolean cancelNotes; static boolean prevInDungeonBossRoom = false; - static boolean inDungeonBossRoom = false; - public static Clip dungeonboss; + public static boolean inDungeonBossRoom = false; + public static Song dungeonboss; public static float dungeonbossDecibels; + public static Song bloodroom; + public static float bloodroomDecibels; + public static Song dungeon; + public static float dungeonDecibels; @SubscribeEvent public void onWorldChange(WorldEvent.Load event) { @@ -56,30 +63,44 @@ public class CustomMusic { firstLine.contains("necron")) { // F7 inDungeonBossRoom = true; - if (!prevInDungeonBossRoom && dungeonboss != null) { - start(); + if (!prevInDungeonBossRoom) { + dungeonboss.start(); } } else { - reset(); + inDungeonBossRoom = false; + dungeonboss.stop(); } } } } } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void onChat(ClientChatReceivedEvent event) { - if (!Utils.inDungeons) return; String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); - if (message.contains("EXTRA STATS ")) { - if (dungeonboss != null) dungeonboss.stop(); + if (ToggleCommand.dungeonMusic && Utils.inDungeons) { + if (message.contains("[NPC] Mort: Here, I found this map when I first entered the dungeon.")) { + dungeon.start(); + } + } + + if (message.contains(":")) return; + + if (Utils.inDungeons) { + if (message.contains("EXTRA STATS ")) { + dungeonboss.stop(); + bloodroom.stop(); + dungeon.stop(); + } else if (ToggleCommand.bloodRoomMusic && message.contains("The BLOOD DOOR has been opened!")) { + bloodroom.start(); + } } } @SubscribeEvent public void onSound(PlaySoundEvent event) { - if (ToggleCommand.dungeonBossMusic && Utils.inDungeons && inDungeonBossRoom) { + if (cancelNotes) { if (event.isCancelable() && event.name.startsWith("note.")) event.setCanceled(true); } } @@ -91,29 +112,69 @@ public class CustomMusic { reset(); - dungeonboss = AudioSystem.getClip(); - File dungeonBossFile = new File(configDirectory + "/dsmmusic/dungeonboss.wav"); + File dungeonBossFile = new File(directory + "/dungeonboss.wav"); System.out.println("dungeonboss.wav exists?: " + dungeonBossFile.exists()); - if (dungeonBossFile.exists()) { - AudioInputStream ais = AudioSystem.getAudioInputStream(dungeonBossFile); - dungeonboss.open(ais); + dungeonboss = new Song(dungeonBossFile, dungeonbossDecibels); - FloatControl volume = (FloatControl) dungeonboss.getControl(FloatControl.Type.MASTER_GAIN); - volume.setValue(dungeonbossDecibels); - } + File bloodRoomFile = new File(directory + "/bloodroom.wav"); + System.out.println("bloodroom.wav exists?: " + bloodRoomFile.exists()); + bloodroom = new Song(bloodRoomFile, bloodroomDecibels); + + File dungeonFile = new File(directory + "/dungeon.wav"); + System.out.println("dungeon.wav exists?: " + dungeonFile.exists()); + dungeon = new Song(dungeonFile, dungeonDecibels); } - static void reset() { - inDungeonBossRoom = false; + public static void reset() { + cancelNotes = false; if (dungeonboss != null) dungeonboss.stop(); + if (bloodroom != null) bloodroom.stop(); + if (dungeon != null) dungeon.stop(); } - public static void start() { - if (dungeonboss != null && inDungeonBossRoom) { - dungeonboss.setMicrosecondPosition(0); - dungeonboss.start(); - dungeonboss.loop(Clip.LOOP_CONTINUOUSLY); + public static class Song { + + public Clip music; + + public Song(File file, float decibels) throws IOException, UnsupportedAudioFileException, LineUnavailableException { + if (file.exists()) { + music = AudioSystem.getClip(); + AudioInputStream ais = AudioSystem.getAudioInputStream(file); + music.open(ais); + + setVolume(decibels); + } } + + public void start() { + reset(); + cancelNotes = true; + if (music != null) { + music.setMicrosecondPosition(0); + music.start(); + music.loop(Clip.LOOP_CONTINUOUSLY); + } + } + + public void stop() { + cancelNotes = false; + if (music != null) music.stop(); + } + + public boolean setVolume(float decibels) { + if (music == null) return false; + + 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; + } + + control.setValue(decibels); + return true; + } + } } diff --git a/src/main/java/me/Danker/features/SlayerESP.java b/src/main/java/me/Danker/features/SlayerESP.java index 17a1c0e..51537ba 100644 --- a/src/main/java/me/Danker/features/SlayerESP.java +++ b/src/main/java/me/Danker/features/SlayerESP.java @@ -11,7 +11,6 @@ import net.minecraft.util.StringUtils; import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; |