aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/features/dungeon
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features/dungeon')
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt14
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt20
-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
6 files changed, 92 insertions, 33 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/CancelInteractions.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt
deleted file mode 100644
index 94626f8..0000000
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/CancelInteractions.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.ambientaddons.features.dungeon
-
-import AmbientAddons.Companion.config
-import AmbientAddons.Companion.mc
-import com.ambientaddons.utils.LocationUtils
-import net.minecraft.init.Blocks
-import net.minecraftforge.event.entity.player.PlayerInteractEvent
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-object CancelInteractions {
- @SubscribeEvent
- fun onPlayerInteract(event: PlayerInteractEvent) {
- if (!config.cancelInteractions || LocationUtils.location == "Private Island") return
- if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
- if (mc.theWorld?.getBlockState(event.pos)?.block == Blocks.hopper) {
- event.isCanceled = true
- }
- }
- }
-} \ No newline at end of file
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