Skip to content

Commit

Permalink
Fixed CME in Puzzles updating
Browse files Browse the repository at this point in the history
Added clickThisWindow to HoverTerms might fix missclicking
Added extremely poorly coded QueueTerms
  • Loading branch information
odtheking committed Oct 25, 2024
1 parent fe9d576 commit 1fb1e4f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 32 deletions.
2 changes: 1 addition & 1 deletion odinclient/src/main/kotlin/me/odinclient/ModCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ModCore {
HoverTerms, LightsDevice, SimonSays, ArrowsDevice, FuckDiorite, RelicAura,
Trajectories, Ghosts, NoDebuff, ChocolateFactory, AutoExperiments, AutoHarp,
FarmingHitboxes, NoBlock, AutoClicker, Triggerbot, GhostBlocks, FreezeGame, EtherWarpHelper, ChestEsp,
EscrowFix, TerminalAura, AutoTerms, Camera, DungeonAbilities/*, QueueTerms*/, HidePlayers
EscrowFix, TerminalAura, AutoTerms, Camera, DungeonAbilities, QueueTerms, HidePlayers

)
OdinMain.loadComplete()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.odinclient.features.impl.floor7.p3

import me.odinmain.events.impl.GuiEvent
import me.odinmain.events.impl.TerminalClosedEvent
import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.impl.floor7.p3.TerminalSolver
Expand All @@ -14,8 +15,6 @@ import me.odinmain.ui.util.MouseUtils.mouseY
import me.odinmain.utils.clock.Clock
import me.odinmain.utils.skyblock.PlayerUtils
import me.odinmain.utils.skyblock.PlayerUtils.windowClick
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object HoverTerms : Module(
Expand All @@ -27,58 +26,73 @@ object HoverTerms : Module(
private val triggerDelay by NumberSetting("Delay", 200L, 50, 800, unit = "ms", description = "Delay between clicks.")
private val firstClickDelay by NumberSetting("First Click Delay", 200L, 50, 500, unit = "ms", description = "Delay before first click.")
private val middleClick by DualSetting("Click Type", "Left", "Middle", default = true, description = "What Click type to use.")
private val previouslyClicked = mutableSetOf<Int>()
private val triggerBotClock = Clock(triggerDelay)
private var clickedThisWindow = false

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onDrawGuiContainer(event: GuiEvent.DrawGuiContainerScreenEvent) {
if (
TerminalSolver.currentTerm.solution.isEmpty() ||
mc.currentScreen !is GuiChest ||
!enabled ||
!triggerBotClock.hasTimePassed(triggerDelay) ||
System.currentTimeMillis() - currentTerm.timeOpened <= firstClickDelay
System.currentTimeMillis() - currentTerm.timeOpened <= firstClickDelay ||
clickedThisWindow
) return
val gui = mc.currentScreen as GuiChest
if (gui.inventorySlots !is ContainerChest) return

val hoveredItem =
when {
TerminalSolver.renderType == 3 && TerminalSolver.enabled -> TermGui.getHoveredItem(mouseX.toInt(), mouseY.toInt())
else -> {
if (gui.slotUnderMouse?.inventory == mc.thePlayer?.inventory) return
gui.slotUnderMouse?.slotIndex
if (event.gui.slotUnderMouse?.inventory == mc.thePlayer?.inventory) return
event.gui.slotUnderMouse?.slotIndex
}
} ?: return

if (hoveredItem !in TerminalSolver.currentTerm.solution) return
if (hoveredItem !in TerminalSolver.currentTerm.solution || hoveredItem in previouslyClicked) return

when (currentTerm.type) {
TerminalTypes.RUBIX -> {
val needed = TerminalSolver.currentTerm.solution.count { it == hoveredItem }
if (needed >= 3) {
windowClick(hoveredItem, PlayerUtils.ClickType.Right)
triggerBotClock.update()
return
}
clickedThisWindow = true
windowClick(hoveredItem, if (TerminalSolver.currentTerm.solution.count { it == hoveredItem } >= 3) PlayerUtils.ClickType.Right else if (middleClick) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Left)
triggerBotClock.update()
if (TerminalSolver.currentTerm.solution.count { it == hoveredItem } < 1) previouslyClicked += hoveredItem
}

TerminalTypes.ORDER -> {
if (TerminalSolver.currentTerm.solution.first() == hoveredItem) {
clickedThisWindow = true
windowClick(hoveredItem, if (middleClick) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Left)
triggerBotClock.update()
previouslyClicked += hoveredItem
}
return
}

TerminalTypes.MELODY ->
if (hoveredItem % 9 == 7) {
clickedThisWindow = true
windowClick(hoveredItem, if (middleClick) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Left)
triggerBotClock.update()
previouslyClicked += hoveredItem
}
TerminalTypes.PANES, TerminalTypes.STARTS_WITH, TerminalTypes.SELECT -> windowClick(hoveredItem, if (middleClick) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Left)

TerminalTypes.PANES, TerminalTypes.STARTS_WITH, TerminalTypes.SELECT -> {
clickedThisWindow = true
windowClick(hoveredItem, if (middleClick) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Left)
triggerBotClock.update()
previouslyClicked += hoveredItem
}
else -> return
}
}

triggerBotClock.update()
@SubscribeEvent
fun onTerminalLeft(event: TerminalClosedEvent) {
clickedThisWindow = false
previouslyClicked.clear()
}

@SubscribeEvent
fun onGuiOpen(event: GuiEvent.GuiLoadedEvent) {
clickedThisWindow = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.impl.floor7.p3.TerminalSolver
import me.odinmain.features.impl.floor7.p3.TerminalTypes
import me.odinmain.features.settings.impl.NumberSetting
import me.odinmain.utils.equalsOneOf
import me.odinmain.utils.skyblock.PlayerUtils.windowClick
import me.odinmain.utils.skyblock.devMessage
import me.odinmain.utils.skyblock.modMessage
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent

object QueueTerms : Module(
name = "Queue Terms",
category = Category.FLOOR7,
description = "Queues clicks in terminals to ensure every click is registered."
description = "Queues clicks in terminals to ensure every click is registered (only works in custom term gui)."
) {
private val dispatchDelay by NumberSetting("Dispatch Delay", 140L, 140L, 300L, unit = "ms", description = "The delay between each click.")
private data class Click(val slot: Int, val mode: Int, val button: Int)
private var clickedThisWindow = false
private val previouslyClicked = mutableSetOf<Int>()
private val queue = mutableListOf<Click>()
private var clickedThisWindow = false
private var lastClickTime = 0L

@SubscribeEvent
Expand All @@ -28,36 +34,42 @@ object QueueTerms : Module(
@SubscribeEvent
fun onTerminalLeft(event: TerminalClosedEvent) {
clickedThisWindow = false
previouslyClicked.clear()
queue.clear()
}

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
TerminalSolver.currentTerm.solution = TerminalSolver.currentTerm.solution.filter { it !in queue.map { it.slot } }
if (TerminalSolver.currentTerm.type == TerminalTypes.NONE || TerminalSolver.renderType == 3) return
TerminalSolver.currentTerm.solution = TerminalSolver.currentTerm.solution.filter { it !in previouslyClicked }
if (
event.phase != TickEvent.Phase.START ||
System.currentTimeMillis() - lastClickTime < 140 ||
TerminalSolver.currentTerm.type == TerminalTypes.NONE ||
System.currentTimeMillis() - lastClickTime < dispatchDelay ||
queue.isEmpty() ||
clickedThisWindow
) return
val click = queue.removeFirst()
clickedThisWindow = true

windowClick(slotId = click.slot, button = click.button, mode = click.mode)
lastClickTime = System.currentTimeMillis()
}

@SubscribeEvent
fun onCustomTermClick(event: GuiEvent.CustomTermGuiClick) {
if (TerminalSolver.currentTerm.type == TerminalTypes.NONE) return
if (TerminalSolver.currentTerm.type == TerminalTypes.NONE || TerminalSolver.renderType == 3) return
event.isCanceled = true
handleWindowClick(event.slot, event.mode, event.button)
}

fun handleWindowClick(slot: Int, mode: Int, button: Int) {
if (slot !in TerminalSolver.currentTerm.solution) return
if (TerminalSolver.currentTerm.type == TerminalTypes.ORDER && slot != TerminalSolver.currentTerm.solution.first()) return
queue.add(Click(slot = slot, mode = mode, button = button))
if ((TerminalSolver.currentTerm.type == TerminalTypes.ORDER && slot != TerminalSolver.currentTerm.solution.first()) || TerminalSolver.renderType == 3) return
if (slot in previouslyClicked) return modMessage("Already clicked slot $slot")
if (TerminalSolver.currentTerm.type == TerminalTypes.RUBIX) {
if ((TerminalSolver.currentTerm.solution.count { it == slot } < 3 && button != 0) ||
(TerminalSolver.currentTerm.solution.count { it == slot } >= 3 && button != 1)) return modMessage("Wrong button for this slot")
if (TerminalSolver.currentTerm.solution.count { it == slot }.equalsOneOf(1, 4)) previouslyClicked += slot
} else previouslyClicked += slot
queue.takeIf { it.count { click -> click.slot == slot } < 2 }?.add(Click(slot = slot, mode = mode, button = button))
devMessage("Queued click on slot $slot")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class Dungeon(val floor: Floor) {
}

updateDungeonTeammates(packet.entries)
puzzles = getDungeonPuzzles(getTabList) // transfer to packet based
runOnMCThread {
puzzles = getDungeonPuzzles(getTabList) // transfer to packet based
}
}

private val timeRegex = Regex("§r Time: §r§6((?:\\d+h ?)?(?:\\d+m ?)?\\d+s)§r")
Expand Down

0 comments on commit 1fb1e4f

Please sign in to comment.