Skip to content

Commit

Permalink
Made TerminalSolver render numbers
Browse files Browse the repository at this point in the history
Added right-click functionality to SelectorSetting
Implemented od reset hud command
Fixed generateFeatureList command
Made DungeonWaypointCommand color work
Added hex TextInput functionality to ColorSetting
Fixed inverted scrolling in ClickGUI
  • Loading branch information
odtheking committed Dec 7, 2024
1 parent b5e8743 commit 9facbe5
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 118 deletions.
15 changes: 7 additions & 8 deletions odin/src/main/kotlin/me/odin/ModCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,23 @@ class ModCore {
MinecraftForge.EVENT_BUS.register(this)
}

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START) return
OdinMain.onTick()
}

@EventHandler
fun postInit(event: FMLPostInitializationEvent) {
ModuleManager.addModules(SimonSays, ArrowsDevice, EtherWarpHelper, Camera, HidePlayers)
OdinMain.postInit()
}

@EventHandler
fun loadComplete(event: FMLLoadCompleteEvent) {
ModuleManager.addModules(SimonSays, ArrowsDevice, EtherWarpHelper, Camera, HidePlayers)

OdinMain.loadComplete()
}

@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START) return
OdinMain.onTick()
}

companion object {
const val MOD_ID = "od"
const val NAME = "Odin"
Expand Down
12 changes: 6 additions & 6 deletions odinclient/src/main/kotlin/me/odinclient/ModCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class ModCore {

@EventHandler
fun postInit(event: FMLPostInitializationEvent) {
OdinMain.postInit()
}

@EventHandler
fun loadComplete(event: FMLLoadCompleteEvent) {
ModuleManager.addModules(
AutoGFS, /*AutoIceFill,*/ AutoSell, CancelInteract, CloseChest, SecretHitboxes,
AutoGFS, AutoSell, CancelInteract, CloseChest, SecretHitboxes,
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
)
OdinMain.postInit()
}

@EventHandler
fun loadComplete(event: FMLLoadCompleteEvent) {
OdinMain.loadComplete()
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/me/odinmain/OdinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import me.odinmain.utils.skyblock.PlayerUtils
import me.odinmain.utils.skyblock.SkyblockPlayer
import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.ScanUtils
import me.odinmain.utils.ui.regularFont
import me.odinmain.utils.ui.renderer.NVGRenderer.textWidth
import me.odinmain.utils.ui.screens.UIScreen
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package me.odinmain.commands.impl

import com.github.stivais.aurora.color.Color
import com.github.stivais.aurora.utils.hexToRGBA
import com.github.stivais.aurora.utils.toHexString
import com.github.stivais.commodore.utils.GreedyString
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.launch
Expand All @@ -23,11 +26,10 @@ import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRelativeCoords
import me.odinmain.utils.skyblock.dungeon.ScanUtils
import me.odinmain.utils.skyblock.dungeon.ScanUtils.getRoomCenter
import me.odinmain.utils.ui.screens.UIScreen.Companion.open
import net.minecraft.network.play.server.S02PacketChat
import net.minecraft.util.ChatComponentText


@OptIn(DelicateCoroutinesApi::class)
val devCommand = commodore("oddev") {

literal("drags") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.odinmain.commands.impl

import com.github.stivais.aurora.color.Color
import kotlinx.coroutines.launch
import me.odinmain.OdinMain.scope
import me.odinmain.commands.commodore
Expand All @@ -16,6 +17,8 @@ import me.odinmain.utils.skyblock.modMessage
import me.odinmain.utils.writeToClipboard
import net.minecraft.client.gui.GuiScreen
import net.minecraft.util.BlockPos
import com.github.stivais.aurora.utils.hexToRGBA
import com.github.stivais.aurora.utils.toHSB

val dungeonWaypointsCommand = commodore("dwp", "dungeonwaypoints") {
runs {
Expand Down Expand Up @@ -77,7 +80,7 @@ val dungeonWaypointsCommand = commodore("dwp", "dungeonwaypoints") {

literal("color").runs { hex: String ->
if (hex.length != 8 || hex.any { !it.isHexaDecimal }) return@runs modMessage("Color hex not properly formatted! Use format RRGGBBAA")
// DungeonWaypoints.color = colorFrom(hex)
DungeonWaypoints.color = Color.RGB(hexToRGBA(hex)).toHSB()
modMessage("Color changed to: $hex")
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/me/odinmain/commands/impl/OdinCommand.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package me.odinmain.commands.impl

import com.github.stivais.aurora.utils.loop
import com.github.stivais.commodore.utils.GreedyString
import me.odinmain.commands.commodore
import me.odinmain.features.huds.HUDManager
import me.odinmain.features.huds.HUDManager.HUDs
import me.odinmain.features.impl.dungeon.dungeonwaypoints.DungeonWaypoints
import me.odinmain.features.impl.render.ClickGUI
import me.odinmain.features.impl.render.ClickGUI.clickGUI
Expand Down Expand Up @@ -47,11 +49,11 @@ val mainCommand = commodore("od", "odin") {
value.y = value.defaultY
value.extended = true // default is always true
}
modMessage("Reset ClickGUI panel positions")
modMessage("§aReset ClickGUI panel positions")
}
literal("hud").runs {
// EditHUDGui.resetHUDs() TODO: Implement this
modMessage("Reset HUD positions.")
HUDManager.resetHUDs()
modMessage("§aReset HUD positions.")
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/me/odinmain/features/Category.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package me.odinmain.features

enum class Category {
DUNGEON, FLOOR7, RENDER, SKYBLOCK, NETHER
enum class Category(val displayName: String) {
DUNGEON("Dungeon"),
FLOOR7("Floor 7"),
RENDER("Render"),
SKYBLOCK("Skyblock"),
NETHER("Nether")
}
15 changes: 8 additions & 7 deletions src/main/kotlin/me/odinmain/features/ModuleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import me.odinmain.features.impl.nether.*
import me.odinmain.features.impl.render.*
import me.odinmain.features.impl.skyblock.*
import me.odinmain.features.settings.impl.KeybindSetting
import me.odinmain.utils.capitalizeFirst
import me.odinmain.utils.ui.regularFont
import me.odinmain.utils.ui.renderer.NVGRenderer
import me.odinmain.utils.ui.renderer.NVGRenderer.textWidth
import net.minecraft.network.Packet
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -157,20 +161,17 @@ object ModuleManager {
fun getModuleByName(name: String?): Module? = modules.firstOrNull { it.name.equals(name, true) }

fun generateFeatureList(): String {
/* val sortedCategories = modules.sortedByDescending { getTextWidth(it.name, 18f) }.groupBy { it.category }.entries
.sortedBy{ Category.entries.associateWith { it.ordinal }[it.key] }
val sortedCategories = modules.sortedByDescending { textWidth(it.name, 18f, font = regularFont) }.groupBy { it.category }.entries
.sortedBy { Category.entries.associateWith { it.ordinal }[it.key] }

val featureList = StringBuilder()
return featureList.toString()
for ((category, modulesInCategory) in sortedCategories) {
val displayName = category.name.capitalizeFirst()
featureList.appendLine("Category: ${if (displayName == "Floor7") "Floor 7" else displayName}")
featureList.appendLine("Category: ${category.displayName}")
for (module in modulesInCategory) {
featureList.appendLine("- ${module.name}: ${module.description}")
}
featureList.appendLine()
}
return featureList.toString()*/
return ""
return featureList.toString()
}
}
8 changes: 8 additions & 0 deletions src/main/kotlin/me/odinmain/features/huds/HUDManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ object HUDManager {
UI!!.open()
}

fun resetHUDs() {
HUDs.loop { hud ->
hud.settings.loop {
it.reset()
}
}
}

fun makeHUDEditor() = Aurora(renderer = NVGRenderer) {

var hudOptions: Popup? = null
Expand Down
100 changes: 39 additions & 61 deletions src/main/kotlin/me/odinmain/features/impl/dungeon/LeapMenu.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package me.odinmain.features.impl.dungeon

import com.github.stivais.aurora.color.Color
import com.github.stivais.aurora.dsl.*
import com.github.stivais.aurora.elements.Layout.Companion.divider
import com.github.stivais.aurora.elements.impl.Block.Companion.outline
import com.github.stivais.aurora.elements.impl.layout.Grid
import com.github.stivais.aurora.utils.withAlpha
import io.github.moulberry.notenoughupdates.NEUApi
import me.odinmain.features.Module
Expand All @@ -17,13 +21,14 @@ import me.odinmain.utils.skyblock.getItemIndexInContainerChest
import me.odinmain.utils.skyblock.modMessage
import me.odinmain.utils.skyblock.partyMessage
import me.odinmain.utils.ui.Colors
import me.odinmain.utils.ui.renderer.NVGRenderer
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.input.Keyboard
import me.odinmain.features.impl.render.ClickGUI.`gray 38`

object LeapMenu : Module(
name = "Leap Menu",
Expand All @@ -46,31 +51,17 @@ object LeapMenu : Module(
private val leapAnnounce by BooleanSetting("Leap Announce", false, description = "Announces when you leap to a player.")

private val EMPTY = DungeonPlayer("Empty", DungeonClass.Unknown)
private val keybindList = listOf(topLeftKeybind, topRightKeybind, bottomLeftKeybind, bottomRightKeybind)


// fun leapMenu() = UI {
// fun leapMenu() = Aurora(renderer = NVGRenderer) {
// Grid(copies()).scope {
// leapTeammates.forEachIndexed { index, it ->
// if (it == EMPTY) return@forEachIndexed
// val x = when (index) {
// 0, 2 -> 16.percent
// else -> 6.percent
// }
//
// val y = when (index) {
// 0, 1 -> 38.percent
// else -> 10.percent
// }
// val sizeX = Animatable(from = 80.percent, to = 83.percent) // this keeps the starting x and y while enlarging the width and height which isnt what we want
// val sizeY = Animatable(from = 50.percent, to = 53.percent)
// group(size(50.percent, 50.percent)) {
// group {
// val block = block(
// constraints = constrain(x, y, sizeX, sizeY),
// constraints = constrain(0.px, 0.px, 50.percent, 50.percent),
// color = `gray 38`,
// radius = 12.radius()
// ) {
//
// image(
// it.skinImage,
// constraints = constrain(5.percent, 10.percent, 30.percent, 80.percent),
Expand All @@ -82,20 +73,37 @@ object LeapMenu : Module(
// text(if (it.isDead) "§cDEAD" else it.clazz.name, size = 10.percent, color = Color.WHITE)
// }
// }
// onClick { // make it possible to click any mouse button
// handleMouseClick(index)
// onClick(nonSpecific = true) {
// if (type != 0 && leapTeammates.size < index) return@onClick
//
// val playerToLeap = leapTeammates[index - 1]
// if (playerToLeap == EMPTY) return@onClick
// if (playerToLeap.isDead) return@onClick modMessage("This player is dead, can't leap.")
// modMessage("Teleporting to ${playerToLeap.name}.")
// leapTo(playerToLeap.name)
// true
// }
// onKeycodePressed { (code) ->
// if (!useNumberKeys || leapTeammates.isEmpty()) return@onKeycodePressed false
//
// val keybindIndex = listOf(topLeftKeybind, topRightKeybind, bottomLeftKeybind, bottomRightKeybind).indexOfFirst { it.key == code }.takeIf { it != -1 } ?: return@onKeycodePressed false
// if (keybindIndex >= leapTeammates.size) return@onKeycodePressed false
//
// val playerToLeap = leapTeammates[keybindIndex]
// if (playerToLeap == EMPTY || playerToLeap.isDead) {
// modMessage("This player is dead, can't leap.")
// return@onKeycodePressed false
// }
//
// leapTo(playerToLeap.name)
// true
// }
// onMouseEnter {
// sizeX.animate(0.25.seconds, Animations.EaseInOutQuint)
// sizeY.animate(0.25.seconds, Animations.EaseInOutQuint)
// block.outline(color = Color.WHITE)
// block.outline(color = Color.WHITE, thickness = 2.px)
// redraw()
// }
// onMouseExit {
// sizeX.animate(0.25.seconds, Animations.EaseInOutQuint)
// sizeY.animate(0.25.seconds, Animations.EaseInOutQuint)
// block.outline(color = Color.TRANSPARENT)
// block.outline(color = Color.TRANSPARENT, thickness = 0.px)
// redraw()
// }
// }
Expand All @@ -110,39 +118,9 @@ object LeapMenu : Module(
if (Loader.instance().activeModList.any { it.modId == "notenoughupdates" }) NEUApi.setInventoryButtonsToDisabled()
}

private fun handleMouseClick(quadrant: Int) {
if ((type.equalsOneOf(1,2,3)) && leapTeammates.size < quadrant) return

val playerToLeap = leapTeammates[quadrant - 1]
if (playerToLeap == EMPTY) return
if (playerToLeap.isDead) return modMessage("This player is dead, can't leap.")
modMessage("Teleporting to ${playerToLeap.name}.")
//leapTo(playerToLeap.name, containerChest)
}

@SubscribeEvent
fun keyTyped(event: GuiScreenEvent.KeyboardInputEvent.Pre) {
val gui = event.gui as? GuiChest ?: return
if (
gui.inventorySlots !is ContainerChest ||
gui.inventorySlots.name != "Spirit Leap" ||
keybindList.none { it.isDown() } ||
leapTeammates.isEmpty() ||
!useNumberKeys
) return

val index = keybindList.indexOfFirst { it.isDown() }
val playerToLeap = if (index + 1 > leapTeammates.size) return else leapTeammates[index]
if (playerToLeap == EMPTY) return
if (playerToLeap.isDead) return modMessage("This player is dead, can't leap.")

leapTo(playerToLeap.name, gui.inventorySlots as ContainerChest)

event.isCanceled = true
}

private fun leapTo(name: String, containerChest: ContainerChest) {
val index = getItemIndexInContainerChest(containerChest, name, 11..16) ?: return modMessage("Cant find player $name. This shouldn't be possible! are you nicked?")
private fun leapTo(name: String) {
val containerChest = mc.thePlayer?.openContainer as? ContainerChest ?: return modMessage("You need to be in the leap menu to leap.")
val index = getItemIndexInContainerChest(containerChest, name, 11..16) ?: return modMessage("Can't find player $name. This shouldn't be possible! are you nicked?")
modMessage("Teleporting to $name.")
if (leapAnnounce) partyMessage("Leaped to $name!")
mc.playerController.windowClick(containerChest.windowId, index, 2, 3, mc.thePlayer)
Expand All @@ -154,12 +132,12 @@ object LeapMenu : Module(
onWorldLoad { worldLoad() }
}

/*private val leapTeammates: MutableList<DungeonPlayer> = mutableListOf(
private val leapTeammates: MutableList<DungeonPlayer> = mutableListOf(
DungeonPlayer("Stivais", DungeonClass.Healer),
DungeonPlayer("Odtheking", DungeonClass.Archer),
DungeonPlayer("freebonsai", DungeonClass.Mage),
DungeonPlayer("Cezar", DungeonClass.Tank)
)*/
)

/**
* Sorts the list of players based on their default quadrant and class priority.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ object SecretClicked : Module(
private val boxesDropdown by DropdownSetting("Secret Boxes Dropdown")
private val boxes by BooleanSetting("Secret Boxes", true, description = "Whether or not to render boxes around clicked secrets.").withDependency { boxesDropdown }
private val style by SelectorSetting("Style", Renderer.DEFAULT_STYLE, Renderer.styles, description = Renderer.STYLE_DESCRIPTION).withDependency { boxesDropdown && boxes }
private val color by ColorSetting("Color", color = Colors.MINECRAFT_GOLD.withAlpha(.4f), allowAlpha = true, description = "The color of the box.").withDependency { boxesDropdown && boxes }
private val color by ColorSetting("Color", Colors.MINECRAFT_GOLD.withAlpha(.4f), allowAlpha = true, description = "The color of the box.").withDependency { boxesDropdown && boxes }
private val lineWidth by NumberSetting("Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { boxesDropdown && boxes }
private val depthCheck by BooleanSetting("Depth check", false, description = "Boxes show through walls.").withDependency { boxesDropdown && boxes }
private val lockedColor by ColorSetting("Locked Color", color = Color.RED.withAlpha(.4f), allowAlpha = true, description = "The color of the box when the chest is locked.").withDependency { boxesDropdown && boxes }
private val lockedColor by ColorSetting("Locked Color", Color.RED.withAlpha(.4f), allowAlpha = true, description = "The color of the box when the chest is locked.").withDependency { boxesDropdown && boxes }
private val timeToStay by NumberSetting("Time To Stay (seconds)", 7, 1, 60, 1, description = "The time the chests should remain highlighted.").withDependency { boxesDropdown && boxes }
private val useRealSize by BooleanSetting("Use Real Size", true, description = "Whether or not to use the real size of the block.").withDependency { boxesDropdown && boxes }
private val boxInBoss by BooleanSetting("Box In Boss", false, description = "Highlight clicks in boss.").withDependency { boxesDropdown && boxes }
Expand Down
Loading

0 comments on commit 9facbe5

Please sign in to comment.