diff options
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features')
8 files changed, 274 insertions, 5 deletions
diff --git a/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt b/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt new file mode 100644 index 0000000..fa210aa --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt @@ -0,0 +1,41 @@ +package com.ambientaddons.features.display + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.Alignment +import com.ambientaddons.utils.render.OverlayUtils +import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.dungeon.TextStyle +import net.minecraft.client.gui.ScaledResolution +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.math.ceil +import kotlin.math.roundToInt + +object WitherShieldOverlay { + private var witherImpactEndTime = 0L + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent) { + if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return + if (!SkyBlock.inSkyblock || config.witherShieldDisplay == 0) return + val diff = ((witherImpactEndTime - System.currentTimeMillis()) / 1000.0).takeIf { it >= 0 } ?: return + val display = ceil(diff).roundToInt().toString() + val resolution = ScaledResolution(mc) + val x = resolution.scaledWidth / 2 + 1 + val y = resolution.scaledHeight / 2 + 10 + val style = TextStyle.fromInt(config.witherShieldDisplay - 1) ?: return + OverlayUtils.drawString(x, y, display, style, Alignment.Center) + } + + @SubscribeEvent + fun onChat(event: ClientChatReceivedEvent) { + if (!SkyBlock.inSkyblock || config.witherShieldDisplay == 0) return + if (event.type == 2.toByte() && event.message.unformattedText.contains("Wither Impact")) { + if (((witherImpactEndTime - System.currentTimeMillis()) / 1000.0) < 0) { + witherImpactEndTime = System.currentTimeMillis() + 5000 + } + } + } +}
\ No newline at end of file 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 diff --git a/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt index cbf4cd9..b7e5fad 100644 --- a/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt +++ b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt @@ -14,7 +14,9 @@ object SendLastMessageKeybind { fun onSendChat(event: MessageSentEvent) { if (!SkyBlock.onHypixel) return if (event.message.startsWith("/pc", ignoreCase = true)) { - lastMessage = event.message.substring(4 until event.message.length) + lastMessage = event.message.runCatching { + substring(4 until event.message.length) + }.getOrNull() } else if (!event.message.startsWith("/")) { lastMessage = event.message } diff --git a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt index db45e93..b0689c4 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt @@ -6,7 +6,7 @@ import com.ambientaddons.events.ItemOverlayEvent import com.ambientaddons.utils.Extensions.skyblockID import com.ambientaddons.utils.Extensions.stripControlCodes import com.ambientaddons.utils.SkyBlock -import com.ambientaddons.utils.RenderUtils +import com.ambientaddons.utils.render.OverlayUtils import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -52,7 +52,7 @@ object BonzoMask { else -> 1.0 } if (durability < 1.0) { - RenderUtils.renderDurabilityBar(event.x, event.y, durability) + OverlayUtils.renderDurabilityBar(event.x, event.y, durability) } } diff --git a/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt b/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt new file mode 100644 index 0000000..469d6fe --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt @@ -0,0 +1,37 @@ +package com.ambientaddons.features.misc + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.Area +import com.ambientaddons.utils.Extensions.chest +import com.ambientaddons.utils.Extensions.items +import com.ambientaddons.utils.Extensions.lore +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.dungeon.DungeonPlayers +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object KuudraReady { + private var hasClickedReady = false + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + hasClickedReady = false + } + + @SubscribeEvent + fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { + if (!config.kuudraReady || SkyBlock.area != Area.Kuudra) return + val chest = event.gui?.chest ?: return + val chestName = chest.lowerChestInventory.name + if (chestName == "Ready Up" && !hasClickedReady) { + val clickIndex = chest.lowerChestInventory.items.takeIf { it.last() != null }?.indexOfFirst { + it?.lore?.getOrNull(0)?.stripControlCodes()?.startsWith("Click to mark yourself") == true + } ?: return + hasClickedReady = true + mc.playerController.windowClick(chest.windowId, clickIndex, 2, 3, mc.thePlayer) + } + } +}
\ No newline at end of file |