aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/features
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-12 20:48:51 -0700
committerAppability <appable@icloud.com>2022-10-12 20:48:51 -0700
commitc599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8 (patch)
treef362a5f60f31e27f1567c7319a78d861b19430a7 /src/main/kotlin/com/ambientaddons/features
parent03728b81851af00cd265fadd4ce6eaa3a8066dcb (diff)
downloadAmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.tar.gz
AmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.tar.bz2
AmbientAddons-c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8.zip
uh a lot of things
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features')
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt14
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt5
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt46
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt8
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt32
-rw-r--r--src/main/kotlin/com/ambientaddons/features/keybinds/PerspectiveKeybind.kt18
-rw-r--r--src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt30
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt60
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt (renamed from src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt)8
9 files changed, 205 insertions, 16 deletions
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
index 3c67c4d..7c66e1f 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
@@ -4,7 +4,6 @@ import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
import AmbientAddons.Companion.persistentData
import com.ambientaddons.events.GuiContainerEvent
-import com.ambientaddons.events.ReceivePacketEvent
import com.ambientaddons.utils.Extensions.chest
import com.ambientaddons.utils.Extensions.enchants
import com.ambientaddons.utils.Extensions.items
@@ -12,12 +11,11 @@ import com.ambientaddons.utils.Extensions.lore
import com.ambientaddons.utils.Extensions.skyblockID
import com.ambientaddons.utils.Extensions.stripControlCodes
import com.ambientaddons.utils.Extensions.withModPrefix
-import com.ambientaddons.utils.LocationUtils
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.SkyBlock
import gg.essential.universal.UChat
import net.minecraft.inventory.ContainerChest
import net.minecraft.item.ItemStack
-import net.minecraft.network.play.client.C0DPacketCloseWindow
-import net.minecraft.network.play.server.S2DPacketOpenWindow
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.event.world.WorldEvent
@@ -37,7 +35,7 @@ object AutoBuyChest {
@SubscribeEvent
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
- if (LocationUtils.location != "Catacombs" || rewardChest == null) return
+ if (SkyBlock.area != Area.Dungeon || rewardChest == null) return
if (event.slotId == BUY_SLOT_INDEX) {
hasOpenedChest = true
if (rewardChest == RewardChest.Wood) {
@@ -45,7 +43,7 @@ object AutoBuyChest {
event.isCanceled = true
}
} else if (event.slotId == KISMET_SLOT_INDEX) {
- if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || LocationUtils.dungeonFloor.toString() != "M4")) {
+ if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || SkyBlock.dungeonFloor.toString() != "M4")) {
UChat.chat("§cBlocked reroll! This low-tier chest should not be rerolled.".withModPrefix())
event.isCanceled = true
return
@@ -64,7 +62,7 @@ object AutoBuyChest {
@SubscribeEvent
fun onGuiOpen(event: GuiOpenEvent) {
- if (LocationUtils.location != "Catacombs") return
+ if (SkyBlock.area != Area.Dungeon) return
if (event.gui == null) return
val chest = event.gui.chest
val chestName = chest?.lowerChestInventory?.name
@@ -84,7 +82,7 @@ object AutoBuyChest {
@SubscribeEvent
fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
- if (LocationUtils.location != "Catacombs" || config.autoBuyChest != 2 || rewardChest == null || hasLookedAtChest) return
+ 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)
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt
index ffaab8d..571cd7f 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt
@@ -3,7 +3,8 @@ package com.ambientaddons.features.dungeon
import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
import com.ambientaddons.events.ReceivePacketEvent
-import com.ambientaddons.utils.LocationUtils
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.SkyBlock
import net.minecraft.network.play.client.C0DPacketCloseWindow
import net.minecraft.network.play.server.S2DPacketOpenWindow
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -11,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object CloseChest {
@SubscribeEvent
fun onOpenWindow(event: ReceivePacketEvent) {
- if (!config.closeSecretChests || LocationUtils.location != "Catacombs") return
+ if (!config.closeSecretChests || SkyBlock.area != Area.Dungeon) return
if (event.packet !is S2DPacketOpenWindow) return
if (event.packet.windowTitle.unformattedText == "Chest") {
mc.netHandler.networkManager.sendPacket(C0DPacketCloseWindow(event.packet.windowId))
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt
new file mode 100644
index 0000000..7c3c286
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt
@@ -0,0 +1,46 @@
+package com.ambientaddons.features.dungeon
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.utils.Extensions.chest
+import com.ambientaddons.utils.Extensions.items
+import com.ambientaddons.utils.Extensions.stripControlCodes
+import com.ambientaddons.utils.Area
+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 DungeonReady {
+ private const val START_SLOT_INDEX = 13
+ private val READY_SLOTS = listOf(2, 3, 4, 5, 6)
+
+ private var hasClickedReady = false
+ private var hasClickedStart = false
+
+ @SubscribeEvent
+ fun onWorldUnload(event: WorldEvent.Unload) {
+ hasClickedReady = false
+ hasClickedStart = false
+ }
+
+ @SubscribeEvent
+ fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
+ if (config.autoReady == 0 || SkyBlock.area != Area.Dungeon) return
+ val chest = event.gui?.chest ?: return
+ val chestName = chest.lowerChestInventory.name
+ if (chestName == "Start Dungeon?" && !hasClickedStart) {
+ if (config.autoReady == 1 && DungeonPlayers.playerCount != 5) return
+ hasClickedStart = true
+ mc.playerController.windowClick(chest.windowId, START_SLOT_INDEX, 2, 3, mc.thePlayer)
+ } else if (chestName.startsWith("Catacombs - ") && !hasClickedReady) {
+ val username = mc.thePlayer.name
+ val clickIndex = chest.lowerChestInventory.items.takeIf { it.last() != null }?.indexOfFirst {
+ username == it?.displayName?.stripControlCodes()?.substringAfter(" ")
+ }.takeIf { it != -1 } ?: return
+ hasClickedReady = true
+ mc.playerController.windowClick(chest.windowId, clickIndex + 9, 2, 3, mc.thePlayer)
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt
index 6283b9c..6f2281e 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt
@@ -1,9 +1,11 @@
package com.ambientaddons.features.dungeon
import AmbientAddons.Companion.config
+import com.ambientaddons.utils.SkyBlock
object IgnoreCarpet {
- fun shouldIgnoreCarpet(): Boolean = if (AmbientAddons.isInitialized()) {
- config.ignoreCarpet
- } else false
+ fun shouldIgnoreCarpet(): Boolean {
+ if (!SkyBlock.inSkyblock) return false
+ return if (AmbientAddons.isInitialized()) config.ignoreCarpet else false
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt
new file mode 100644
index 0000000..9ff5d48
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt
@@ -0,0 +1,32 @@
+package com.ambientaddons.features.dungeon
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.utils.Extensions.skyblockID
+import com.ambientaddons.utils.SkyBlock
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.roundToLong
+
+// credit Floppa
+object ShortbowClicker {
+ private var lastClickTime = System.currentTimeMillis()
+ private val shortbows = listOf("TERMINATOR", "JUJU_SHORTBOW", "ITEM_SPIRIT_BOW")
+
+ @SubscribeEvent
+ fun onRender(event: RenderWorldLastEvent) {
+ if (!SkyBlock.inSkyblock) return
+ if (config.terminatorCps == 0) return
+ if (!mc.gameSettings.keyBindUseItem.isKeyDown) return
+ val itemStack = mc.thePlayer?.inventory?.getCurrentItem()
+ if (itemStack?.skyblockID?.let { shortbows.contains(it) } != true) return
+ val delay = (1000.0 / config.terminatorCps).roundToLong()
+ val currentTime = System.currentTimeMillis()
+ if ((currentTime - lastClickTime) >= delay) {
+ lastClickTime = currentTime - (currentTime - lastClickTime) % delay
+ if (mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, itemStack)) {
+ mc.entityRenderer.itemRenderer.resetEquippedProgress2()
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/keybinds/PerspectiveKeybind.kt b/src/main/kotlin/com/ambientaddons/features/keybinds/PerspectiveKeybind.kt
new file mode 100644
index 0000000..3ee1564
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/keybinds/PerspectiveKeybind.kt
@@ -0,0 +1,18 @@
+package com.ambientaddons.features.keybinds
+
+import AmbientAddons.Companion.keyBinds
+import AmbientAddons.Companion.mc
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent
+
+object PerspectiveKeybind {
+ @SubscribeEvent
+ fun onKey(event: KeyInputEvent) {
+ val settings = mc.gameSettings
+ if (keyBinds["thirdPersonKey"]!!.isPressed) {
+ settings.thirdPersonView = if (settings.thirdPersonView == 0) 1 else 0
+ } else if (keyBinds["secondPersonKey"]!!.isPressed) {
+ settings.thirdPersonView = if (settings.thirdPersonView == 0) 2 else 0
+ }
+ }
+}
diff --git a/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt
new file mode 100644
index 0000000..cbf4cd9
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt
@@ -0,0 +1,30 @@
+package com.ambientaddons.features.keybinds
+
+import AmbientAddons.Companion.keyBinds
+import AmbientAddons.Companion.mc
+import com.ambientaddons.events.MessageSentEvent
+import com.ambientaddons.utils.SkyBlock
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.InputEvent
+
+object SendLastMessageKeybind {
+ var lastMessage: String? = null
+
+ @SubscribeEvent
+ fun onSendChat(event: MessageSentEvent) {
+ if (!SkyBlock.onHypixel) return
+ if (event.message.startsWith("/pc", ignoreCase = true)) {
+ lastMessage = event.message.substring(4 until event.message.length)
+ } else if (!event.message.startsWith("/")) {
+ lastMessage = event.message
+ }
+ }
+
+ @SubscribeEvent
+ fun onKey(event: InputEvent.KeyInputEvent) {
+ if (!SkyBlock.onHypixel) return
+ if (keyBinds["spamKey"]!!.isPressed && lastMessage != null) {
+ mc.thePlayer.sendChatMessage("/pc $lastMessage")
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt
new file mode 100644
index 0000000..db45e93
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt
@@ -0,0 +1,60 @@
+package com.ambientaddons.features.misc
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+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 net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object BonzoMask {
+ private var spiritMaskProc = 0L
+ private var bonzoMaskProc = 0L
+ private var fraggedBonzoMaskProc = 0L
+
+ private const val secondWindString = "Second Wind Activated! Your Spirit Mask saved your life!"
+ private const val bonzoString = "Your Bonzo's Mask saved your life!"
+ private const val fraggedBonzoString = "Your ⚚ Bonzo's Mask saved your life!"
+
+ @SubscribeEvent
+ fun onChat(event: ClientChatReceivedEvent) {
+ if (!SkyBlock.inSkyblock) return
+ val didMaskProc = when (event.message.unformattedText.stripControlCodes()) {
+ secondWindString -> {
+ spiritMaskProc = System.currentTimeMillis()
+ true
+ }
+ bonzoString -> {
+ bonzoMaskProc = System.currentTimeMillis()
+ true
+ }
+ fraggedBonzoString -> {
+ fraggedBonzoMaskProc = System.currentTimeMillis()
+ true
+ }
+ else -> false
+ }
+ if (config.maskWarning && didMaskProc) {
+ mc.ingameGUI.displayTitle("§cMask!", null, 5, 20, 5)
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderItemOverlay(event: ItemOverlayEvent) {
+ if (!SkyBlock.inSkyblock) return
+ val durability = when (event.item?.skyblockID) {
+ "BONZO_MASK" -> (System.currentTimeMillis() - bonzoMaskProc) / 180000.0
+ "STARRED_BONZO_MASK" -> (System.currentTimeMillis() - fraggedBonzoMaskProc) / 180000.0
+ "SPIRIT_MASK" -> (System.currentTimeMillis() - spiritMaskProc) / 30000.0
+ else -> 1.0
+ }
+ if (durability < 1.0) {
+ RenderUtils.renderDurabilityBar(event.x, event.y, durability)
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt
index 94626f8..60f0f8f 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt
+++ b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt
@@ -1,8 +1,9 @@
-package com.ambientaddons.features.dungeon
+package com.ambientaddons.features.misc
import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
-import com.ambientaddons.utils.LocationUtils
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.SkyBlock
import net.minecraft.init.Blocks
import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -10,7 +11,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object CancelInteractions {
@SubscribeEvent
fun onPlayerInteract(event: PlayerInteractEvent) {
- if (!config.cancelInteractions || LocationUtils.location == "Private Island") return
+ if (!SkyBlock.inSkyblock) return
+ if (!config.cancelInteractions || SkyBlock.area == Area.PrivateIsland) return
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
if (mc.theWorld?.getBlockState(event.pos)?.block == Blocks.hopper) {
event.isCanceled = true