aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/features/dungeon
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
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')
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt4
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt121
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt1
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt67
4 files changed, 191 insertions, 2 deletions
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
index 7c66e1f..279402d 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
@@ -84,8 +84,8 @@ object AutoBuyChest {
fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
if (SkyBlock.area != Area.Dungeon || config.autoBuyChest != 2 || rewardChest == null || hasLookedAtChest) return
val chest = event.gui?.chest ?: return
- if (rewardChest == RewardChest.Wood && !hasOpenedChest) {
- openChest(chest)
+ if (rewardChest == RewardChest.Wood) {
+ if (!hasOpenedChest) openChest(chest)
} else {
val items = chest.lowerChestInventory.items
if (items.last() != null) {
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt
new file mode 100644
index 0000000..50cc00a
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt
@@ -0,0 +1,121 @@
+package com.ambientaddons.features.dungeon
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.Extensions.skyblockID
+import com.ambientaddons.utils.SkyBlock
+import com.ambientaddons.utils.render.EntityUtils
+import gg.essential.universal.UChat
+import net.minecraft.entity.Entity
+import net.minecraft.entity.boss.EntityWither
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.monster.EntityCaveSpider
+import net.minecraft.entity.monster.EntityEnderman
+import net.minecraft.entity.monster.EntitySkeleton
+import net.minecraft.entity.passive.EntityBat
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.ItemArmor
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.*
+
+// modified from Harry282/Skyblock-Client
+object DungeonHighlights {
+ private val markedArmorStands = mutableSetOf<EntityArmorStand>()
+ private val starredMobs = mutableSetOf<Entity>()
+ private var nearIdkmansry = false
+
+ private val idkmansry = UUID.fromString("93ce1cad-833f-46ff-a124-b66d2b99c4fd")
+
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (SkyBlock.area != Area.Dungeon) return
+ nearIdkmansry = false
+ mc.theWorld.loadedEntityList.forEach { entity ->
+ if (entity is EntityArmorStand && entity.customNameTag.contains("✯") && !markedArmorStands.contains(entity)) {
+ if (config.starredHighlight == 0) return@forEach
+ mc.theWorld.getEntitiesInAABBexcluding(
+ entity, entity.entityBoundingBox.offset(0.0, -1.0, 0.0)
+ ) { isValidEntity(it) }.also {
+ if (it.isNotEmpty()) markedArmorStands.add(entity)
+ }.forEach {
+ starredMobs.add(it)
+ }
+ } else if (entity is EntityPlayer) {
+ if (entity.uniqueID == idkmansry) {
+ nearIdkmansry = true
+ }
+ }
+ }
+ mc.theWorld.loadedEntityList.forEach {
+ if (it is EntityArmorStand) return@forEach
+ val wasStarred = renderStarredHighlight(it, event.partialTicks)
+ if (!wasStarred) {
+ when (it) {
+ is EntityBat -> renderBatHighlight(it, event.partialTicks)
+ is EntityCaveSpider -> renderCellarHighlight(it, event.partialTicks)
+ is EntitySkeleton -> renderSniperHighlight(it, event.partialTicks)
+ is EntityPlayer -> renderShadowHighlight(it, event.partialTicks)
+ }
+ }
+
+ }
+ }
+
+ private fun renderStarredHighlight(entity: Entity, partialTicks: Float): Boolean {
+ if (config.starredHighlight == 0) return false
+ if (starredMobs.contains(entity)) {
+ EntityUtils.drawEntityBox(
+ entity, config.starredColor, outline = true, fill = false, config.starredHighlight == 2, partialTicks
+ )
+ return true
+ }
+ return false
+ }
+
+ private fun renderShadowHighlight(entity: EntityPlayer, partialTicks: Float) {
+ if (config.saHighlight == 0) return
+ val boots = entity.getCurrentArmor(0)
+ if (entity.heldItem?.skyblockID != "SILENT DEATH" && (boots?.item as? ItemArmor)?.getColor(boots) != 6029470) return
+ UChat.chat("SA held item: ${entity.heldItem?.skyblockID}")
+ EntityUtils.drawEntityBox(
+ entity, config.saColor, outline = true, fill = false, config.saHighlight == 2, partialTicks
+ )
+ }
+
+
+ private fun renderCellarHighlight(entity: EntityCaveSpider, partialTicks: Float) {
+ if (config.bestiaryHighlight == 0 || nearIdkmansry) return
+ EntityUtils.drawEntityBox(
+ entity, config.bestiaryColor, outline = true, fill = false, config.bestiaryHighlight == 2, partialTicks
+ )
+ }
+
+ private fun renderSniperHighlight(entity: EntitySkeleton, partialTicks: Float) {
+ if (config.bestiaryHighlight == 0 || nearIdkmansry) return
+ if (entity.getCurrentArmor(3)?.skyblockID != "SNIPER_HELMET") return
+ EntityUtils.drawEntityBox(
+ entity, config.bestiaryColor, outline = true, fill = false, config.bestiaryHighlight == 2, partialTicks
+ )
+ }
+
+ private fun renderBatHighlight(entity: EntityBat, partialTicks: Float) {
+ if (config.batHighlight == 0) return
+ if (!listOf(100F, 200F, 400F, 800F).contains(entity.maxHealth)) return
+ EntityUtils.drawEntityBox(
+ entity, config.batColor, outline = true, fill = false, config.batHighlight == 2, partialTicks
+ )
+ }
+
+ private fun isValidEntity(entity: Entity?): Boolean {
+ return when (entity) {
+ is EntityEnderman -> !entity.isInvisible || (config.starredHighlight == 2)
+ is EntityArmorStand -> false
+ is EntityWither -> false
+ is EntityPlayer -> entity.uniqueID.version() == 2 && entity != mc.thePlayer
+ else -> true
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt
index 7c3c286..3defe7c 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt
@@ -8,6 +8,7 @@ import com.ambientaddons.utils.Extensions.stripControlCodes
import com.ambientaddons.utils.Area
import com.ambientaddons.utils.SkyBlock
import com.ambientaddons.utils.dungeon.DungeonPlayers
+import gg.essential.universal.UChat
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
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