aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/features/dungeon/terminals
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-13 18:58:00 -0700
committerAppability <appable@icloud.com>2022-10-13 18:58:00 -0700
commitd0cbc11018c8126575117aaeb2b861957386fa9a (patch)
treec5419fb1f00b147604bded231c1388d6b391d27e /src/main/kotlin/com/ambientaddons/features/dungeon/terminals
parentc599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8 (diff)
downloadAmbientAddons-d0cbc11018c8126575117aaeb2b861957386fa9a.tar.gz
AmbientAddons-d0cbc11018c8126575117aaeb2b861957386fa9a.tar.bz2
AmbientAddons-d0cbc11018c8126575117aaeb2b861957386fa9a.zip
steal a bunch of code from sbc! +melodyhelper, kuudra ready, wither shield overlay
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features/dungeon/terminals')
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt
new file mode 100644
index 0000000..468a6a9
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt
@@ -0,0 +1,67 @@
+package com.ambientaddons.features.dungeon.terminals
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.events.GuiContainerEvent
+import com.ambientaddons.utils.Extensions.chest
+import com.ambientaddons.utils.Extensions.items
+import com.ambientaddons.utils.Extensions.stripControlCodes
+import com.ambientaddons.utils.SkyBlock
+import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.client.event.GuiOpenEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object MelodyHelper {
+ private val completedStageRegex = Regex("/^[A-za-z0-9_]{3,16} (?:completed|activated) a (?:lever|terminal|device)! \\((?:[07]\\/7|[08]\\/8)\\)/")
+ private var hasSaidMeowlody = false
+ private var hasSaidThrottled = false
+ private var isThrottled = false
+
+ @SubscribeEvent
+ fun onChat(event: ClientChatReceivedEvent) {
+ if (SkyBlock.dungeonFloor?.floor != 7) return
+ val unformatted = event.message.unformattedText.stripControlCodes()
+ if (completedStageRegex.matches(unformatted)) {
+ hasSaidMeowlody = false
+ hasSaidThrottled = false
+ isThrottled = false
+ } else if (unformatted.startsWith("This menu has been throttled!")) {
+ isThrottled = true
+ if (!hasSaidThrottled && config.throttledAnnouncement.isNotBlank()) {
+ mc.thePlayer.sendChatMessage("/pc ${config.throttledAnnouncement}")
+ hasSaidThrottled = true
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onGuiOpen(event: GuiOpenEvent) {
+ if (SkyBlock.dungeonFloor?.floor != 7) return
+ if (event.gui == null) return
+ if (event.gui.chest?.lowerChestInventory?.name == "Click the button on time!") {
+ if (!hasSaidMeowlody && config.melodyAnnouncement.isNotBlank()) {
+ mc.thePlayer.sendChatMessage("/pc ${config.melodyAnnouncement}")
+ hasSaidMeowlody = true
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
+ if (SkyBlock.dungeonFloor?.floor != 7) return
+ val chest = event.gui.chest?.lowerChestInventory
+ if (chest?.name != "Click the button on time!" || isThrottled) return
+ val colors = chest.items.map { it?.itemDamage }
+ val targetPaneCol = colors.indexOf(10)
+ val movingPaneIndex = colors.indexOf(5)
+ val movingPaneCol = movingPaneIndex % 9
+ val clickSlot = (movingPaneIndex / 9) * 9 + 7
+ if (targetPaneCol != movingPaneCol) {
+ event.isCanceled = true
+ mc.thePlayer.playSound("random.pop", 1f, 0f)
+ } else if (clickSlot != event.slot?.slotIndex){
+ event.isCanceled = true
+ mc.thePlayer.playSound("random.pop", 1f, 10f)
+ }
+ }
+} \ No newline at end of file