diff options
author | inglettronald <inglettronald@gmail.com> | 2023-04-28 05:11:30 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-04-28 05:11:30 -0500 |
commit | 2cb65fda1d48b51d288444d14fd94cf40f42a85e (patch) | |
tree | 1c20ab996b97d907500ff0a718cda0f2a462d3d8 /src/main/kotlin/dulkirmod | |
parent | 23c431419fa15bf4dab905fe1cecc37a98334175 (diff) | |
download | DulkirMod-2cb65fda1d48b51d288444d14fd94cf40f42a85e.tar.gz DulkirMod-2cb65fda1d48b51d288444d14fd94cf40f42a85e.tar.bz2 DulkirMod-2cb65fda1d48b51d288444d14fd94cf40f42a85e.zip |
some sound handling changes that should make volume better
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt | 13 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/MatchoAlert.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/SecretSounds.kt | 71 |
3 files changed, 70 insertions, 25 deletions
diff --git a/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt index 0bf6bbe..32ec350 100644 --- a/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt +++ b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt @@ -1,10 +1,12 @@ package dulkirmod.features import dulkirmod.DulkirMod +import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig import dulkirmod.utils.TabListUtils import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils +import net.minecraft.client.audio.SoundCategory object GardenVisitorAlert { private var hasSentAlert = false @@ -21,9 +23,14 @@ object GardenVisitorAlert { if (TabListUtils.maxVisitors && !hasSentAlert) { val color = Utils.getColorString(DulkirConfig.bestiaryNotifColor) TitleUtils.drawStringForTime("${color}Max Visitors", 5000) - DulkirMod.mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .3f) - DulkirMod.mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .6f) - DulkirMod.mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .9f) + + + val prevNote = mc.gameSettings.getSoundLevel(SoundCategory.RECORDS) + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, 1f) + mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .3f) + mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .6f) + mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.bestiaryNotifVol, .9f) + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, prevNote) hasSentAlert = true lastAlert = System.currentTimeMillis().toInt() } else if (!TabListUtils.maxVisitors) hasSentAlert = false diff --git a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt index 54abc99..1b2bb7a 100644 --- a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt +++ b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt @@ -1,10 +1,11 @@ package dulkirmod.features -import dulkirmod.DulkirMod +import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig import dulkirmod.utils.TabListUtils import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils +import net.minecraft.client.audio.SoundCategory object MatchoAlert { @@ -21,8 +22,12 @@ object MatchoAlert { if (TabListUtils.explosivity && !hasSentAlert) { val color = Utils.getColorString(DulkirConfig.bestiaryNotifColor) TitleUtils.drawStringForTime("${color}Matcho", 5000) - if (DulkirConfig.bestiaryAlertSounds) - DulkirMod.mc.thePlayer.playSound("mob.villager.yes", 1f * DulkirConfig.bestiaryNotifVol, 0f) + if (DulkirConfig.bestiaryAlertSounds) { + val prevVol = mc.gameSettings.getSoundLevel(SoundCategory.MOBS) + mc.gameSettings.setSoundLevel(SoundCategory.MOBS, 1f) + mc.thePlayer.playSound("mob.villager.yes", 1f * DulkirConfig.bestiaryNotifVol, 0f) + mc.gameSettings.setSoundLevel(SoundCategory.MOBS, prevVol) + } hasSentAlert = true } else if (!TabListUtils.explosivity) hasSentAlert = false } diff --git a/src/main/kotlin/dulkirmod/features/SecretSounds.kt b/src/main/kotlin/dulkirmod/features/SecretSounds.kt index 5bbbb48..993c44f 100644 --- a/src/main/kotlin/dulkirmod/features/SecretSounds.kt +++ b/src/main/kotlin/dulkirmod/features/SecretSounds.kt @@ -2,26 +2,31 @@ package dulkirmod.features import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig -import dulkirmod.utils.TabListUtils.isInDungeons +import dulkirmod.events.EntityRemovedEvent +import dulkirmod.utils.TabListUtils import net.minecraft.block.Block +import net.minecraft.client.audio.SoundCategory +import net.minecraft.entity.item.EntityItem import net.minecraft.init.Blocks +import net.minecraft.item.ItemStack import net.minecraft.tileentity.TileEntitySkull import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object SecretSounds { private var lastSound: Long = 0L + + enum class Secrets(val value: String) { + SPIRIT_LEAP("Spirit Leap"), + DECOY("Decoy"), + INFLATABLE_JERRY("Inflatable Jerry"), + TREASURE_TALISMAN("Treasure Talisman") + } @SubscribeEvent fun onInteract(event: PlayerInteractEvent) { - if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - return - } - if (!DulkirConfig.secretClickSounds) { - return - } - if (!isInDungeons) { - return - } + if (!DulkirConfig.secretClickSounds) return + if (TabListUtils.area != "Dungeon") return + if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return val blockType: Block = mc.theWorld.getBlockState(event.pos).block ?: return // get the type of block @@ -35,26 +40,54 @@ object SecretSounds { try { skullId = (mc.theWorld.getTileEntity(event.pos) as TileEntitySkull).playerProfile.id.toString() - } catch (ignored: NullPointerException) {} // it doesn't have a playerID - if (skullId == null || skullId != "26bb1a8d-7c66-31c6-82d5-a9c04c94fb02") { // check if it is a wither essence player head return } - } playSound() } - private fun playSound() { + // Inspiration: AtonAddons - https://github.com/FloppaCoding/AtonAddons/blob/main/src/main/kotlin/atonaddons/module/impl/dungeon/SecretChime.kt + private var drops = listOf( + "Health Potion VIII Splash Potion", //"§5Health Potion VIII Splash Potion" + "Healing Potion 8 Splash Potion", + "Healing Potion VIII Splash Potion", + "Decoy", //"§aDecoy" + "Inflatable Jerry", // "§fInflatable Jerry" + "Spirit Leap", // "§9Spirit Leap" + "Trap", // "§aTrap" + "Training Weights", // "§aTraining Weights" + "Defuse Kit", // "§aDefuse Kit" + "Dungeon Chest Key", // "§9Dungeon Chest Key" + "Treasure Talisman", // Name: "§9Treasure Talisman" + "Revive Stone", + ) + @SubscribeEvent + fun onRemoveEntity(event: EntityRemovedEvent) { + if (!DulkirConfig.secretClickSounds) return + if (TabListUtils.area != "Dungeon") return + if (event.entity !is EntityItem) return + if (mc.thePlayer.getDistanceToEntity(event.entity) > 6) return + val item: ItemStack = event.entity.entityItem + + var secretFlag = false + for (d in drops) { + if (item.displayName.contains(d)) + secretFlag = true + } + if (secretFlag) + playSound() + } + + fun playSound() { if (System.currentTimeMillis() - lastSound > 50) { // don't kill ears - mc.thePlayer.playSound( - "random.break", - 1f * DulkirConfig.secretSoundVolume, - 1f - ) + val prevNote = mc.gameSettings.getSoundLevel(SoundCategory.MASTER) + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, 1f) + mc.thePlayer.playSound("note.pling", 1f * DulkirConfig.secretSoundVolume, 1f) lastSound = System.currentTimeMillis() + mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, prevNote) } } }
\ No newline at end of file |