aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/dungeon/SecretChimeConfig.java40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ClickedBlockType.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/DungeonClickedBlockEvent.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt48
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt59
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonSecretChime.kt38
7 files changed, 156 insertions, 49 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java
index 60809f44f..ec2bc0c4b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java
@@ -16,6 +16,11 @@ public class DungeonConfig {
public HighlightClickedBlocksConfig clickedBlocks = new HighlightClickedBlocksConfig();
@Expose
+ @ConfigOption(name = "Secret Chime", desc = "Play a sound effect when levers, chests, and wither essence are clicked in dungeons.")
+ @Accordion
+ public SecretChimeConfig secretChime = new SecretChimeConfig();
+
+ @Expose
@ConfigOption(name = "Milestones Display", desc = "Show the current milestone in Dungeons.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/SecretChimeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/SecretChimeConfig.java
new file mode 100644
index 000000000..99a1e103d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/SecretChimeConfig.java
@@ -0,0 +1,40 @@
+package at.hannibal2.skyhanni.config.features.dungeon;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.features.dungeon.DungeonSecretChime;
+import at.hannibal2.skyhanni.utils.OSUtils;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class SecretChimeConfig {
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Play a sound effect when levers, chests, and wither essence are clicked in dungeons.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Secret Chime Sound", desc = "The sound played for the secret chime.")
+ @ConfigEditorText
+ public String soundName = "random.orb";
+
+ @Expose
+ @ConfigOption(name = "Pitch", desc = "The pitch of the secret chime sound.")
+ @ConfigEditorSlider(minValue = 0.5f, maxValue = 2.0f, minStep = 0.1f)
+ public float soundPitch = 1.0f;
+
+ @ConfigOption(name = "Sounds",
+ desc = "Click to open the list of available sounds.\n" +
+ "§l§cWarning: Clicking this will open a webpage in your browser."
+ )
+ @ConfigEditorButton(buttonText = "OPEN")
+ public Runnable soundsListURL = () -> OSUtils.openBrowser("https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/2213619-1-8-all-playsound-sound-arguments");
+
+ @ConfigOption(name = "Play Sound", desc = "Plays current secret chime sound.")
+ @ConfigEditorButton(buttonText = "Play")
+ public Runnable checkSound = DungeonSecretChime::playSound;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ClickedBlockType.kt b/src/main/java/at/hannibal2/skyhanni/data/ClickedBlockType.kt
new file mode 100644
index 000000000..e69c9b516
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/ClickedBlockType.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.data
+
+enum class ClickedBlockType {
+ LEVER,
+ CHEST,
+ TRAPPED_CHEST,
+ WITHER_ESSENCE
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/DungeonClickedBlockEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DungeonClickedBlockEvent.kt
new file mode 100644
index 000000000..9a7f5119a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/DungeonClickedBlockEvent.kt
@@ -0,0 +1,7 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.api.event.SkyHanniEvent
+import at.hannibal2.skyhanni.data.ClickedBlockType
+import at.hannibal2.skyhanni.utils.LorenzVec
+
+class DungeonBlockClickEvent(val position: LorenzVec, val blockType: ClickedBlockType) : SkyHanniEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
index 50a3ff8f6..f95c846b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
@@ -1,9 +1,13 @@
package at.hannibal2.skyhanni.features.dungeon
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.data.ClickedBlockType
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
+import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
+import at.hannibal2.skyhanni.events.DungeonBlockClickEvent
import at.hannibal2.skyhanni.events.DungeonBossRoomEnterEvent
import at.hannibal2.skyhanni.events.DungeonCompleteEvent
import at.hannibal2.skyhanni.events.DungeonEnterEvent
@@ -14,6 +18,8 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.TablistFooterUpdateEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.BlockUtils
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -30,6 +36,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -37,13 +44,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object DungeonAPI {
private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?<floor>.*)\\)".toPattern()
- private val uniqueClassBonus =
- "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex()
+ private val uniqueClassBonus = "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex()
- private val bossPattern =
- "View all your (?<name>\\w+) Collection".toPattern()
- private val levelPattern =
- " +(?<kills>\\d+).*".toPattern()
+ private val bossPattern = "View all your (?<name>\\w+) Collection".toPattern()
+ private val levelPattern = " +(?<kills>\\d+).*".toPattern()
private val killPattern = " +☠ Defeated (?<boss>\\w+).*".toPattern()
private val totalKillsPattern = "§7Total Kills: §e(?<kills>.*)".toPattern()
@@ -58,6 +62,8 @@ object DungeonAPI {
val bossStorage: MutableMap<DungeonFloor, Int>? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses
private val patternGroup = RepoPattern.group("dungeon")
+ private const val WITHER_ESSENCE_TEXTURE =
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRkYjRhZGZhOWJmNDhmZjVkNDE3MDdhZTM0ZWE3OGJkMjM3MTY1OWZjZDhjZDg5MzQ3NDlhZjRjY2U5YiJ9fX0="
/**
* REGEX-TEST: Time Elapsed: §a01m 17s
@@ -173,10 +179,9 @@ object DungeonAPI {
}
}
if (dungeonFloor != null && playerClass == null) {
- val playerTeam =
- TabListData.getTabList().firstOrNull {
- it.contains(LorenzUtils.getPlayerName())
- }?.removeColor() ?: ""
+ val playerTeam = TabListData.getTabList().firstOrNull {
+ it.contains(LorenzUtils.getPlayerName())
+ }?.removeColor() ?: ""
for (dungeonClass in DungeonClass.entries) {
if (playerTeam.contains("(${dungeonClass.scoreboardName} ")) {
@@ -354,4 +359,27 @@ object DungeonAPI {
fun getByInventoryName(inventory: String) = entries.firstOrNull { it.inventory == inventory }
}
}
+
+ @SubscribeEvent
+ fun onBlockClick(event: BlockClickEvent) {
+ if (!inDungeon() || event.clickType != ClickType.RIGHT_CLICK) return
+
+ val position = event.position
+ val blockType: ClickedBlockType = when (position.getBlockAt()) {
+ Blocks.chest -> ClickedBlockType.CHEST
+ Blocks.trapped_chest -> ClickedBlockType.TRAPPED_CHEST
+ Blocks.lever -> ClickedBlockType.LEVER
+ Blocks.skull -> {
+ val blockTexture = BlockUtils.getTextureFromSkull(position.toBlockPos())
+ if (blockTexture == WITHER_ESSENCE_TEXTURE) {
+ ClickedBlockType.WITHER_ESSENCE
+ } else {
+ return
+ }
+ }
+
+ else -> return
+ }
+ DungeonBlockClickEvent(position, blockType).post()
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt
index e58672734..4d494567d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt
@@ -1,14 +1,13 @@
package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.data.ClickType
-import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.data.ClickedBlockType
+import at.hannibal2.skyhanni.events.DungeonBlockClickEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.utils.BlockUtils
-import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
import at.hannibal2.skyhanni.utils.ExtendedChatColor
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -18,7 +17,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.TimeLimitedCache
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import net.minecraft.init.Blocks
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color
import kotlin.time.Duration.Companion.seconds
@@ -40,7 +38,7 @@ object DungeonHighlightClickedBlocks {
private val blocks = TimeLimitedCache<LorenzVec, ClickedBlock>(3.seconds)
private var colorIndex = 0
- val undesirableColors = listOf(
+ private val undesirableColors = listOf(
LorenzColor.BLACK,
LorenzColor.WHITE,
LorenzColor.CHROMA,
@@ -69,45 +67,27 @@ object DungeonHighlightClickedBlocks {
}
}
- @SubscribeEvent
- fun onBlockClick(event: BlockClickEvent) {
+ @HandleEvent
+ fun onDungeonClickedBlock(event: DungeonBlockClickEvent) {
if (!isEnabled()) return
- if (event.clickType != ClickType.RIGHT_CLICK) return
+ val isWaterRoom = DungeonAPI.getRoomID() == "-60,-60"
+ if (isWaterRoom && event.blockType == ClickedBlockType.LEVER) return
- val position = event.position
- if (blocks.containsKey(position)) return
+ val type = event.blockType
- val type: ClickedBlockType = when (position.getBlockAt()) {
- Blocks.chest -> ClickedBlockType.CHEST
- Blocks.trapped_chest -> ClickedBlockType.TRAPPED_CHEST
- Blocks.lever -> ClickedBlockType.LEVER
- Blocks.skull -> ClickedBlockType.WITHER_ESSENCE
- else -> return
- }
+ val color = if (config.randomColor) getRandomColor().toColor() else getBlockProperties(type).color.toChromaColor()
+ val displayText = ExtendedChatColor(color.rgb, false).toString() + "Clicked " + getBlockProperties(type).name
+ blocks[event.position] = ClickedBlock(displayText, color)
- if (type == ClickedBlockType.WITHER_ESSENCE) {
- val text = BlockUtils.getTextureFromSkull(position.toBlockPos())
- if (text != "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQ" +
- "ubmV0L3RleHR1cmUvYzRkYjRhZGZhOWJmNDhmZjVkNDE3M" +
- "DdhZTM0ZWE3OGJkMjM3MTY1OWZjZDhjZDg5MzQ3NDlhZjRjY2U5YiJ9fX0="
- ) {
- return
- }
- }
-
- val inWaterRoom = DungeonAPI.getRoomID() == "-60,-60"
- if (inWaterRoom && type == ClickedBlockType.LEVER) return
-
- val color = if (config.randomColor) getRandomColor().toColor() else type.color().toChromaColor()
- val displayText = ExtendedChatColor(color.rgb, false).toString() + "Clicked " + type.display
- blocks[position] = ClickedBlock(displayText, color)
}
- enum class ClickedBlockType(val display: String, val color: () -> String) {
- LEVER("Lever", { config.leverColor }),
- CHEST("Chest", { config.chestColor }),
- TRAPPED_CHEST("Trapped Chest", { config.trappedChestColor }),
- WITHER_ESSENCE("Wither Essence", { config.witherEssenceColor }),
+ private fun getBlockProperties(type: ClickedBlockType): BlockProperties {
+ return when (type) {
+ ClickedBlockType.LEVER -> BlockProperties("Lever", config.leverColor)
+ ClickedBlockType.CHEST -> BlockProperties("Chest", config.chestColor)
+ ClickedBlockType.TRAPPED_CHEST -> BlockProperties("Trapped Chest", config.trappedChestColor)
+ ClickedBlockType.WITHER_ESSENCE -> BlockProperties("Wither Essence", config.witherEssenceColor)
+ }
}
@SubscribeEvent
@@ -128,6 +108,7 @@ object DungeonHighlightClickedBlocks {
}
class ClickedBlock(val displayText: String, var color: Color)
+ class BlockProperties(val name: String, val color: String)
fun isEnabled() = !DungeonAPI.inBossRoom && DungeonAPI.inDungeon() && config.enabled
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonSecretChime.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonSecretChime.kt
new file mode 100644
index 000000000..a19b60a13
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonSecretChime.kt
@@ -0,0 +1,38 @@
+package at.hannibal2.skyhanni.features.dungeon
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.event.HandleEvent
+import at.hannibal2.skyhanni.data.ClickedBlockType
+import at.hannibal2.skyhanni.events.DungeonBlockClickEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.SoundUtils.playSound
+
+@SkyHanniModule
+object DungeonSecretChime {
+ private val config get() = SkyHanniMod.feature.dungeon.secretChime
+
+ @HandleEvent
+ fun onDungeonClickedBlock(event: DungeonBlockClickEvent) {
+ if (!isEnabled()) return
+ val isWaterRoom = DungeonAPI.getRoomID() == "-60,-60"
+ if (isWaterRoom && event.blockType == ClickedBlockType.LEVER) return
+
+ when (event.blockType) {
+ ClickedBlockType.CHEST,
+ ClickedBlockType.TRAPPED_CHEST,
+ ClickedBlockType.LEVER,
+ ClickedBlockType.WITHER_ESSENCE,
+ -> playSound()
+ }
+ }
+
+ fun isEnabled() = !DungeonAPI.inBossRoom && DungeonAPI.inDungeon() && config.enabled
+
+ @JvmStatic
+ fun playSound() {
+ with(config) {
+ SoundUtils.createSound(soundName, soundPitch, 100f).playSound()
+ }
+ }
+}