Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Room-Scanning-Refactor' into Roo…
Browse files Browse the repository at this point in the history
…m-Scanning-Refactor
  • Loading branch information
odtheking committed Oct 25, 2024
2 parents 43118fe + 8eba927 commit f83e87e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 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
Expand Up @@ -7,9 +7,6 @@ import me.odinmain.features.Module
import me.odinmain.features.impl.floor7.p3.TerminalSolver
import me.odinmain.features.impl.floor7.p3.TerminalTypes
import me.odinmain.utils.skyblock.PlayerUtils.windowClick
import me.odinmain.utils.skyblock.devMessage
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent

Expand All @@ -36,6 +33,7 @@ object QueueTerms : Module(

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
TerminalSolver.currentTerm.solution = TerminalSolver.currentTerm.solution.filter { it !in queue.map { it.slot } }
if (
event.phase != TickEvent.Phase.START ||
System.currentTimeMillis() - lastClickTime < 140 ||
Expand All @@ -44,39 +42,22 @@ object QueueTerms : Module(
clickedThisWindow
) return
val click = queue.removeFirst()
windowClick(slotId = click.slot, button = click.button, mode = click.mode)
lastClickTime = System.currentTimeMillis()
clickedThisWindow = true
}

@SubscribeEvent(priority = EventPriority.LOW)
fun onMouseClick(event: GuiEvent.GuiMouseClickEvent) {
if (TerminalSolver.currentTerm.type == TerminalTypes.NONE || event.isCanceled) return
if (!clickedThisWindow) {
clickedThisWindow = true
return
}
val slot = (event.gui as? GuiContainer)?.slotUnderMouse?.slotIndex ?: return
event.isCanceled = true
handleWindowClick(slot, 0, event.button)
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 (!clickedThisWindow) {
clickedThisWindow = true
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
clickedThisWindow = true
queue.add(Click(slot = slot, mode = mode, button = button))
devMessage("added ${queue.last()}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ abstract class TermGui {
protected val itemIndexMap: MutableMap<Int, Box> = mutableMapOf()

fun mouseClicked(x: Int, y: Int, button: Int) {
itemIndexMap.entries.find {
it.value.isPointWithin(x, y)
}?.let {
itemIndexMap.entries.find { it.value.isPointWithin(x, y) }?.let {
if (System.currentTimeMillis() - currentTerm.timeOpened < 300) return
if (GuiEvent.CustomTermGuiClick(it.key, if (button == 0) 3 else 0, button).postAndCatch()) return
windowClick(it.key, if (button == 0) PlayerUtils.ClickType.Middle else PlayerUtils.ClickType.Right, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import net.minecraftforge.common.util.Constants
val ItemStack?.extraAttributes: NBTTagCompound?
get() = this?.getSubCompound("ExtraAttributes", false)

fun ItemStack.displayName(): String =
this.tagCompound?.getCompoundTag("display")?.takeIf { it.hasKey("Name", 8) }?.getString("Name") ?: this.item.getItemStackDisplayName(this)

/**
* Returns displayName without control codes.
*/
val ItemStack?.unformattedName: String
get() = this?.displayName?.noControlCodes ?: ""
get() = this?.displayName()?.noControlCodes ?: ""

/**
* Returns the lore for an Item
Expand Down

0 comments on commit f83e87e

Please sign in to comment.