Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
SubAt0m1c committed Nov 2, 2024
2 parents 359bf11 + 38927d6 commit 27c3296
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Ghosts : Module(
val bracketsColor = if (isRunic) "&5" else "&8"
val lvlColor = if (isRunic) "&d" else "&7"
val nameColor = if (isRunic) "&5" else "&c"
val currentHealthColor = if (isRunic) "&d" else if ( creeper.health < creeper.getSBMaxHealth() / 2) "&e" else "&a"
val currentHealthColor = if (isRunic) "&d" else if (creeper.health < creeper.getSBMaxHealth() / 2) "&e" else "&a"
val maxHealthColor = if (isRunic) "&5" else "&a"
val name = "${bracketsColor}[${lvlColor}Lv250${bracketsColor}] ${nameColor + if (isRunic) "Runic " else ""}Ghost ${currentHealthColor + transformToSuffixedNumber(creeper.health) + "&f"}/${maxHealthColor + transformToSuffixedNumber(creeper.getSBMaxHealth()) + "&c" + ""}".replace("&", "§")

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ val devCommand = commodore("oddev") {
|currentDungeonPlayer: ${DungeonUtils.currentDungeonPlayer.name}, ${DungeonUtils.currentDungeonPlayer.clazz}, ${DungeonUtils.currentDungeonPlayer.isDead}, ${DungeonUtils.isGhost}
|doorOpener: ${DungeonUtils.doorOpener}
|currentRoom: ${DungeonUtils.currentFullRoom?.room?.data?.name}, roomsPassed: ${DungeonUtils.passedRooms.map { it.room.data.name }}
|Teammates: ${DungeonUtils.dungeonTeammates.joinToString { "§${it.clazz.colorCode}${it.name} (${it.clazz}[${it.clazzLvl}])" }}
|Teammates: ${DungeonUtils.dungeonTeammates.joinToString { "§${it.clazz.colorCode}${it.name} (${it.clazz} [${it.clazzLvl}])" }}
|TeammatesNoSelf: ${DungeonUtils.dungeonTeammatesNoSelf.map { it.name }}
|LeapTeammates: ${DungeonUtils.leapTeammates.map { it.name }}
|Blessings: ${Blessing.entries.joinToString { "${it.name}: ${it.current}" }}
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/me/odinmain/commands/impl/OdinCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import me.odinmain.features.impl.render.ClickGUIModule
import me.odinmain.features.impl.render.ServerHud.colorizeFPS
import me.odinmain.features.impl.render.ServerHud.colorizePing
import me.odinmain.features.impl.render.ServerHud.colorizeTps
import me.odinmain.features.impl.skyblock.DianaHelper
import me.odinmain.ui.clickgui.ClickGUI
import me.odinmain.ui.hud.EditHUDGui
import me.odinmain.utils.*
Expand Down Expand Up @@ -88,7 +87,7 @@ val mainCommand = commodore("od", "odin") {

literal("dianareset").runs {
modMessage("Resetting all active diana waypoints.")
DianaHelper.burrowsRender.clear()
DianaBurrowEstimate.activeBurrows.clear()
}

literal("sendcoords").runs { message: GreedyString? ->
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/me/odinmain/features/Module.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.odinmain.features

import me.odinmain.OdinMain
import me.odinmain.features.ModuleManager.executors
import me.odinmain.features.impl.render.ClickGUIModule
import me.odinmain.features.settings.AlwaysActive
import me.odinmain.features.settings.Setting
Expand All @@ -10,6 +9,7 @@ import me.odinmain.features.settings.impl.Keybinding
import me.odinmain.utils.clock.Executable
import me.odinmain.utils.clock.Executor
import me.odinmain.utils.clock.Executor.Companion.register
import me.odinmain.utils.clock.Executor.LimitedExecutor
import me.odinmain.utils.skyblock.modMessage
import net.minecraft.network.Packet
import net.minecraftforge.common.MinecraftForge
Expand Down Expand Up @@ -145,15 +145,15 @@ abstract class Module(
}

fun execute(delay: Long, repeats: Int, profileName: String = "${this.name} Executor", shouldRun: () -> Boolean = { this.enabled || this.alwaysActive }, func: Executable) {
executors.add(this to Executor.LimitedExecutor(delay, repeats, profileName, shouldRun, func).apply { register() })
LimitedExecutor(delay, repeats, profileName, shouldRun, func).register()
}

fun execute(delay: () -> Long, profileName: String = "${this.name} Executor", shouldRun: () -> Boolean = { this.enabled || this.alwaysActive }, func: Executable) {
executors.add(this to Executor(delay, profileName, shouldRun, func).apply { register() })
Executor(delay, profileName, shouldRun, func).register()
}

fun execute(delay: Long, profileName: String = "${this.name} Executor", shouldRun: () -> Boolean = { this.enabled || this.alwaysActive }, func: Executable) {
executors.add(this to Executor(delay, profileName, shouldRun, func).apply { register() })
Executor(delay, profileName, shouldRun, func).register()
}

enum class TagType {
Expand Down
13 changes: 5 additions & 8 deletions src/main/kotlin/me/odinmain/features/ModuleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import me.odinmain.features.settings.impl.KeybindSetting
import me.odinmain.ui.hud.EditHUDGui
import me.odinmain.ui.hud.HudElement
import me.odinmain.utils.capitalizeFirst
import me.odinmain.utils.clock.Executor
import me.odinmain.utils.profile
import me.odinmain.utils.render.getTextWidth
import me.odinmain.utils.skyblock.modMessage
import net.minecraft.network.Packet
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.event.world.WorldEvent
Expand All @@ -45,7 +43,6 @@ object ModuleManager {
val worldLoadFunctions = mutableListOf<() -> Unit>()
val tickTasks = mutableListOf<TickTask>()
val huds = arrayListOf<HudElement>()
val executors = ArrayList<Pair<Module, Executor>>()

val modules: ArrayList<Module> = arrayListOf(
// dungeon
Expand Down Expand Up @@ -87,13 +84,13 @@ object ModuleManager {
}
}

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

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onServerTick(event: RealServerTick) {
tickTaskTick(true)
}
Expand All @@ -110,21 +107,21 @@ object ModuleManager {
}
}

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onReceivePacket(event: PacketReceivedEvent) {
packetFunctions.forEach {
if (it.type.isInstance(event.packet) && it.shouldRun.invoke()) it.function(event.packet)
}
}

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onSendPacket(event: PacketSentEvent) {
packetFunctions.forEach {
if (it.type.isInstance(event.packet) && it.shouldRun.invoke()) it.function(event.packet)
}
}

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onChatPacket(event: ChatPacketEvent) {
messageFunctions.forEach {
if (event.message matches it.filter && it.shouldRun()) it.function(event.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ object TerminalSolver : Module(
if (cancelToolTip && currentTerm.type != TerminalTypes.NONE && enabled) event.toolTip.clear()
}

@SubscribeEvent
@SubscribeEvent(receiveCanceled = true)
fun onGuiClick(event: GuiEvent.GuiMouseClickEvent) {
val gui = event.gui as? GuiChest ?: return
if (currentTerm.type == TerminalTypes.NONE || !enabled || (currentTerm.type == TerminalTypes.MELODY && cancelMelodySolver)) return
Expand Down
49 changes: 20 additions & 29 deletions src/main/kotlin/me/odinmain/features/impl/skyblock/DianaHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.settings.Setting.Companion.withDependency
import me.odinmain.features.settings.impl.*
import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha
import me.odinmain.utils.*
import me.odinmain.utils.clock.Clock
import me.odinmain.utils.render.Color
import me.odinmain.utils.render.Renderer
import me.odinmain.utils.skyblock.*
import me.odinmain.utils.skyblock.DianaBurrowEstimate.activeBurrows
import net.minecraft.network.play.client.C07PacketPlayerDigging
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
import net.minecraft.network.play.server.S29PacketSoundEffect
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.util.Vec3
import net.minecraft.util.Vec3i
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.input.Keyboard
import java.util.concurrent.ConcurrentHashMap

object DianaHelper : Module(
name = "Diana Helper",
Expand All @@ -47,23 +47,16 @@ object DianaHelper : Module(
warpLocation = null
}
private val autoWarp by BooleanSetting("Auto Warp", description = "Automatically warps you to the nearest warp location 2 seconds after you activate the spade ability.").withDependency { !isLegitVersion }
private val resetBurrows by ActionSetting("Reset Burrows", description = "Removes all the current burrows.") { activeBurrows.clear() }
private var warpLocation: WarpPoint? = null

private val cmdCooldown = Clock(3_000)
var renderPos: Vec3? = null
val burrowsRender = ConcurrentHashMap<Vec3i, BurrowType>()
private val hasSpade: Boolean
get() = mc.thePlayer?.inventory?.mainInventory?.find { it.skyblockID == "ANCESTRAL_SPADE" } != null
private val isDoingDiana: Boolean
get() = hasSpade && LocationUtils.currentArea.isArea(Island.Hub) && enabled

enum class BurrowType(val text: String, val color: Color) {
START("§aStart", Color.GREEN),
MOB("§cMob", Color.RED),
TREASURE("§6Treasure", Color.ORANGE),
UNKNOWN("§fUnknown?!", Color.WHITE),
}

init {
onPacket(S29PacketSoundEffect::class.java, { isDoingDiana }) {
DianaBurrowEstimate.handleSoundPacket(it)
Expand All @@ -75,18 +68,16 @@ object DianaHelper : Module(
}

onPacket(C08PacketPlayerBlockPlacement::class.java, { isDoingDiana }) {
DianaBurrowEstimate.blockEvent(it.position.toVec3i())
DianaBurrowEstimate.blockEvent(it.position)
}

onPacket(C07PacketPlayerDigging::class.java, { isDoingDiana }) {
DianaBurrowEstimate.blockEvent(it.position.toVec3i(), it.status == C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK)
DianaBurrowEstimate.blockEvent(it.position)
}

onWorldLoad {
DianaBurrowEstimate.reset()
burrowsRender.clear()
DianaBurrowEstimate.onWorldLoad()
renderPos = null
DianaBurrowEstimate.recentBurrows.clear()
}

onMessage(Regex("^(Uh oh!|Woah!|Yikes!|Oi!|Danger!|Good Grief!|Oh!) You dug out a Minos Inquisitor!\$")) {
Expand All @@ -101,12 +92,12 @@ object DianaHelper : Module(

@SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
if (!isDoingDiana || (renderPos == null && burrowsRender.isEmpty())) return
if (!isDoingDiana || (renderPos == null && activeBurrows.isEmpty())) return
renderPos?.let { guess ->
val distance = mc.thePlayer.positionVector.distanceTo(guess)
if (guess.yCoord == 110.0 && distance < 64) {
renderPos = findNearestGrassBlock(guess)
return
return@let
}
warpLocation = WarpPoint.entries.filter { it.unlocked() }.minBy { warp ->
warp.location.distanceTo(guess)
Expand All @@ -115,18 +106,18 @@ object DianaHelper : Module(
if (tracer && distance > 15)
Renderer.drawTracer(guess.addVec(.5, .5, .5), color = tracerColor, lineWidth = tracerWidth, depth = false)

Renderer.drawCustomBeacon("§6Guess${warpLocation?.displayName ?: ""}§r", guess, guessColor, increase = true, style = style)
Renderer.drawCustomBeacon("§6Guess ${warpLocation?.displayName ?: ""}§r", guess, guessColor, increase = true, style = style)
}

burrowsRender.forEach { (location, type) ->
if (tracerBurrows) Renderer.drawTracer(Vec3(location).addVec(.5, .5, .5), color = type.color, lineWidth = tracerWidth, depth = false)
Renderer.drawCustomBeacon(type.text, Vec3(location), type.color, style = style)
activeBurrows.forEach { (location, burrow) ->
if (tracerBurrows) Renderer.drawTracer(location.toVec3().addVec(.5, .5, .5), color = burrow.type.color, lineWidth = tracerWidth, depth = false)
Renderer.drawCustomBeacon(burrow.type.text, location.toVec3(), burrow.type.color.withAlpha(0.75f), style = style)
}
}

@SubscribeEvent
fun onRightClick(event: ClickEvent.RightClickEvent) {
if (!isHolding("ANCESTRAL_SPADE") || !autoWarp || isLegitVersion) return
if (!isDoingDiana || !autoWarp || isLegitVersion) return
runIn(40) {
if (!cmdCooldown.hasTimePassed()) return@runIn
modMessage("§6Warping to ${warpLocation?.displayName ?: return@runIn}")
Expand All @@ -140,12 +131,12 @@ object DianaHelper : Module(
val location: Vec3,
var unlocked: () -> Boolean
) {
HUB (displayName = " §8(§fHub§8)", Vec3(-3.0, 70.0, -70.0), { true }),
CASTLE (displayName = " §8(§fCastle§8)", Vec3(-250.0, 130.0, 45.0), { castle }),
CRYPT (displayName = " §8(§fCrypt§8)", Vec3(-190.0, 74.0, -88.0), { crypt }),
STONKS (displayName = " §8(§fStonks§8)", Vec3(-52.5, 70.0, -49.5), { stonks }),
DA (displayName = " §8(§fDark Auction§8)", Vec3(91.0, 75.0, 173.0), { darkAuction }),
MUSEUM (displayName = " §8(§fMuseum§8)", Vec3(-75.0, 76.0, 81.0), { museum }),
WIZARD (displayName = " §8(§fWizard§8)", Vec3(42.5, 122.0, 69.0), { wizard })
HUB (displayName = "§8(§fHub§8)", Vec3(-3.0, 70.0, -70.0), { true }),
CASTLE (displayName = "§8(§fCastle§8)", Vec3(-250.0, 130.0, 45.0), { castle }),
CRYPT (displayName = "§8(§fCrypt§8)", Vec3(-190.0, 74.0, -88.0), { crypt }),
STONKS (displayName = "§8(§fStonks§8)", Vec3(-52.5, 70.0, -49.5), { stonks }),
DA (displayName = "§8(§fDark Auction§8)", Vec3(91.0, 75.0, 173.0), { darkAuction }),
MUSEUM (displayName = "§8(§fMuseum§8)", Vec3(-75.0, 76.0, 81.0), { museum }),
WIZARD (displayName = "§8(§fWizard§8)", Vec3(42.5, 122.0, 69.0), { wizard })
}
}
16 changes: 9 additions & 7 deletions src/main/kotlin/me/odinmain/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package me.odinmain.utils
import me.odinmain.OdinMain
import me.odinmain.OdinMain.logger
import me.odinmain.OdinMain.mc
import me.odinmain.features.Module
import me.odinmain.features.ModuleManager
import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha
import me.odinmain.utils.render.Color
Expand Down Expand Up @@ -326,13 +325,16 @@ fun writeToClipboard(text: String) {

private val romanMap = mapOf('I' to 1, 'V' to 5, 'X' to 10, 'L' to 50, 'C' to 100, 'D' to 500, 'M' to 1000)
fun romanToInt(s: String): Int {
var result = 0
for (i in 0 until s.length - 1) {
val current = romanMap[s[i]] ?: 0
val next = romanMap[s[i + 1]] ?: 0
result += if (current < next) -current else current
return if (s.matches(Regex("^[0-9]+$"))) s.toInt()
else {
var result = 0
for (i in 0 until s.length - 1) {
val current = romanMap[s[i]] ?: 0
val next = romanMap[s[i + 1]] ?: 0
result += if (current < next) -current else current
}
result + (romanMap[s.last()] ?: 0)
}
return result + (romanMap[s.last()] ?: 0)
}

fun fillItemFromSack(amount: Int, itemId: String, sackName: String, sendMessage: Boolean) {
Expand Down
Loading

0 comments on commit 27c3296

Please sign in to comment.