Skip to content

Commit

Permalink
Fixed NPE in KuudraUtils
Browse files Browse the repository at this point in the history
Made CratePriority easier to use
  • Loading branch information
odtheking committed Nov 5, 2024
1 parent 054cb91 commit 5306d4f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ object BeamsSolver {

currentLanternPairs.clear()
lanternPairs.forEach {
val pos = getRealCoords(it[0], it[1], it[2])
val pos2 = getRealCoords(it[3], it[4], it[5])
val pos = getRealCoords(it[0], it[1], it[2]).takeIf { getBlockIdAt(it) == 169 } ?: return@forEach
val pos2 = getRealCoords(it[3], it[4], it[5]).takeIf { getBlockIdAt(it) == 169 } ?: return@forEach

if (getBlockIdAt(pos) == 169 && getBlockIdAt(pos2) == 169)
currentLanternPairs[pos] = pos2 to colors[currentLanternPairs.size]
currentLanternPairs[pos] = pos2 to colors[currentLanternPairs.size]
}
}

Expand All @@ -58,8 +57,8 @@ object BeamsSolver {
currentLanternPairs.entries.forEach { positions ->
val color = positions.value.second

Renderer.drawBox(positions.key.toAABB(), color, depth = false, outlineAlpha = if (PuzzleSolvers.beamStyle == 0) 0 else color.alpha, fillAlpha = if (PuzzleSolvers.beamStyle == 1) 0 else beamsAlpha)
Renderer.drawBox(positions.value.first.toAABB(), color, depth = false, outlineAlpha = if (PuzzleSolvers.beamStyle == 0) 0 else color.alpha, fillAlpha = if (PuzzleSolvers.beamStyle == 1) 0 else beamsAlpha)
Renderer.drawStyledBox(positions.key.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle)
Renderer.drawStyledBox(positions.value.first.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle)

if (PuzzleSolvers.beamsTracer)
Renderer.draw3DLine(listOf(positions.key.toVec3().addVec(0.5, 0.5, 0.5), positions.value.first.toVec3().addVec(0.5, 0.5, 0.5)), color = color.withAlpha(beamsAlpha), depth = false, lineWidth = 2f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ object BlazeSolver {
hpMap[entity] = hp
blazes.add(entity)
}

if (room.data.name == "Lower Blaze") blazes.sortBy { hpMap[it] }
else blazes.sortByDescending { hpMap[it] }
if (room.data.name == "Lower Blaze") blazes.sortByDescending { hpMap[it] }
else blazes.sortBy { hpMap[it] }
}

fun onRenderWorld() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ object IceFillSolver {
(if (PuzzleSolvers.useOptimizedPatterns) IceFillFloors.advanced[floorIndex][patternIndex] else IceFillFloors.IceFillFloors[floorIndex][patternIndex]).toMutableList().let {
currentPatterns.addAll(it.map { startPosition.addVec(x = 0.5, y = 0.1, z = 0.5).add(transformTo(it, rotation)) })
}

return@forEachIndexed
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ object TPMazeSolver {
val color = if (correctPortals.size == 1) mazeColorOne else mazeColorMultiple
tpPads.forEach {
when (it) {
in visited -> Renderer.drawBlock(it, mazeColorVisited, outlineAlpha = 0, fillAlpha = mazeColorVisited.alpha, depth = true)
in correctPortals -> Renderer.drawBlock(it, color, outlineAlpha = 0, fillAlpha = color.alpha, depth = false)
in visited -> Renderer.drawBlock(it, mazeColorVisited, outlineAlpha = 0, depth = true)
in correctPortals -> Renderer.drawBlock(it, color, outlineAlpha = 0, depth = false)
else -> Renderer.drawBlock(it, Color.WHITE.withAlpha(0.5f), outlineAlpha = 0, fillAlpha = 0.5f, depth = true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ object WaterSolver {
private var openedWater = -1L

fun scan() = with (DungeonUtils.currentRoom) {
if (this?.data?.name != "Water Board" || variant != -1) return
solve(this)
if (this?.data?.name == "Water Board" && variant == -1) solve(this)
}

private fun solve(room: Room) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ object WitherDragons : Module(
val selected by SelectorSetting("Color", "Green", colors, description = "The color of your relic.").withDependency { relicAnnounce && relicDropDown}
val relicAnnounceTime by BooleanSetting("Relic Time", true, description = "Sends how long it took you to get that relic.").withDependency { relicDropDown }
val relicSpawnTicks by NumberSetting("Relic Spawn Ticks", 42, 0, 100, description = "The amount of ticks for the relic to spawn.").withDependency { relicDropDown }
val cauldronHighlight by BooleanSetting("Cauldron Highlight", false, description = "Highlights the cauldron for held relic.").withDependency { relicDropDown }
val cauldronHighlight by BooleanSetting("Cauldron Highlight", true, description = "Highlights the cauldron for held relic.").withDependency { relicDropDown }

private val relicHud by HudSetting("Relic Hud", 10f, 10f, 1f, true) {
if (it) return@HudSetting mcTextAndWidth("§3Relics: 4.30s", 2, 5f, 1, Color.WHITE, center = false) + 2f to 16f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import me.odinmain.ui.util.MouseUtils
import me.odinmain.utils.equalsOneOf
import me.odinmain.utils.postAndCatch
import me.odinmain.utils.render.*
import me.odinmain.utils.skyblock.PlayerUtils
import me.odinmain.utils.skyblock.PlayerUtils.windowClick
import me.odinmain.utils.skyblock.modMessage
import me.odinmain.utils.skyblock.unformattedName
import net.minecraft.client.gui.Gui
Expand Down Expand Up @@ -42,8 +44,9 @@ object TerminalSolver : Module(
val customScale by NumberSetting("Custom Scale", 1f, .8f, 2.5f, .1f, description = "Size of the Custom Terminal Gui.").withDependency { renderType == 3 }
val textShadow by BooleanSetting("Text Shadow", true, description = "Adds a shadow to the text.")
private val lockRubixSolution by BooleanSetting("Lock Rubix Solution", true, description = "Locks the 'correct' color of the rubix terminal to the one that was scanned first, should make the solver less 'jumpy'.")
private val cancelToolTip by BooleanSetting("Stop Tooltips", true, description = "Stops rendering tooltips in terminals.")
private val blockIncorrectClicks by BooleanSetting("Block Incorrect Clicks", true, description = "Blocks incorrect clicks in terminals.")
private val cancelToolTip by BooleanSetting("Stop Tooltips", true, description = "Stops rendering tooltips in terminals.").withDependency { renderType != 3 }
private val blockIncorrectClicks by BooleanSetting("Block Incorrect Clicks", true, description = "Blocks incorrect clicks in terminals.").withDependency { renderType != 3 }
private val middleClickGUI by BooleanSetting("Middle Click GUI", true, description = "Opens the custom gui when middle clicking in the terminal.").withDependency { renderType != 3 }
private val cancelMelodySolver by BooleanSetting("Stop Melody Solver", false, description = "Stops rendering the melody solver.")

private val showRemoveWrongSettings by DropdownSetting("Render Wrong Settings").withDependency { renderType == 1 }
Expand Down Expand Up @@ -215,6 +218,12 @@ object TerminalSolver : Module(
@SubscribeEvent(receiveCanceled = true)
fun onGuiClick(event: GuiEvent.GuiMouseClickEvent) {
val gui = event.gui as? GuiChest ?: return
val needed = currentTerm.solution.count { it == gui.slotUnderMouse?.slotIndex }

if (renderType != 3 && currentTerm.type == TerminalTypes.NONE && middleClickGUI) {
event.isCanceled = true
windowClick(gui.slotUnderMouse?.slotIndex ?: return, if (needed >= 3) PlayerUtils.ClickType.Right else PlayerUtils.ClickType.Middle)
}
if (currentTerm.type == TerminalTypes.NONE || !enabled || (currentTerm.type == TerminalTypes.MELODY && cancelMelodySolver)) return
if (renderType == 3) {
CustomTermGui.mouseClicked(MouseUtils.mouseX.toInt(), MouseUtils.mouseY.toInt(), event.button)
Expand All @@ -223,8 +232,7 @@ object TerminalSolver : Module(
}

if (blockIncorrectClicks && currentTerm.type != TerminalTypes.MELODY) {
val needed = currentTerm.solution.count { it == gui.slotUnderMouse?.slotIndex }


event.isCanceled = when {
gui.slotUnderMouse?.slotIndex !in currentTerm.solution -> true
currentTerm.type == TerminalTypes.RUBIX && ((needed < 3 && event.button != 0) || (needed >= 3 && event.button != 1)) -> true
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/me/odinmain/features/impl/nether/NoPre.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.settings.Setting.Companion.withDependency
import me.odinmain.features.settings.impl.BooleanSetting
import me.odinmain.features.settings.impl.NumberSetting
import me.odinmain.utils.skyblock.*
import me.odinmain.utils.skyblock.KuudraUtils.SupplyPickUpSpot
import me.odinmain.utils.skyblock.KuudraUtils.giantZombies
Expand All @@ -14,8 +15,9 @@ object NoPre : Module(
description = "Alerts the party about the state of a pre spot.",
category = Category.NETHER
) {
private val showAlert by BooleanSetting("Show Alert", false, description = "Shows an alert when you miss a pre spot.")

private val showCratePriority by BooleanSetting("Show Crate Priority", false, description = "Shows the crate priority alert.")
private val cratePriorityTitleTime by NumberSetting("Title Time", 30, 1, 60, description = "The time the crate priority alert will be displayed for.").withDependency { showCratePriority }
private val advanced by BooleanSetting("Advanced Mode", false, description = "Enables pro mode for the crate priority alert.").withDependency { showCratePriority }

private var preSpot = SupplyPickUpSpot.None
Expand Down Expand Up @@ -62,14 +64,13 @@ object NoPre : Module(
}
if (msg.isEmpty()) return@onMessage
partyMessage(msg)
if (showAlert) PlayerUtils.alert(msg, time = 10)
}

onMessage(partyChatRegex) {
missing = SupplyPickUpSpot.valueOf(partyChatRegex.find(it)?.groupValues?.lastOrNull() ?: return@onMessage)
if (!showCratePriority) return@onMessage
val cratePriority = cratePriority(missing).ifEmpty { return@onMessage }
if (showAlert) PlayerUtils.alert(cratePriority, time = 15)
PlayerUtils.alert(cratePriority, time = cratePriorityTitleTime)
modMessage("Crate Priority: $cratePriority")
}

Expand Down
12 changes: 5 additions & 7 deletions src/main/kotlin/me/odinmain/features/impl/skyblock/FarmKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ object FarmKeys: Module(
private val jumpKey by KeybindSetting("Jump", Keyboard.KEY_NONE, "Changes the keybind for jumping.")
private val previousSensitivity by NumberSetting("Previous Sensitivity", 100f, 0f, 200f, description = "The sensitivity before enabling the module.")

private val gameSettings = mc.gameSettings

override fun onEnable() {
updateKeyBindings(blockBreakKey.key, jumpKey.key, -1 / 3f)
super.onEnable()
Expand All @@ -28,11 +26,11 @@ object FarmKeys: Module(
}

private fun updateKeyBindings(breakKeyCode: Int, jumpKeyCode: Int, sensitivity: Float) {
setKeyBindingState(gameSettings.keyBindAttack, breakKeyCode)
setKeyBindingState(gameSettings.keyBindJump, jumpKeyCode)
gameSettings.mouseSensitivity = sensitivity
gameSettings.saveOptions()
gameSettings.loadOptions()
setKeyBindingState(mc.gameSettings.keyBindAttack, breakKeyCode)
setKeyBindingState(mc.gameSettings.keyBindJump, jumpKeyCode)
mc.gameSettings.mouseSensitivity = sensitivity
mc.gameSettings.saveOptions()
mc.gameSettings.loadOptions()
}

private fun setKeyBindingState(keyBinding: KeyBinding, keyCode: Int) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/me/odinmain/utils/skyblock/KuudraUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ object KuudraUtils {
val (_, name) = tablistRegex.find(text)?.destructured ?: continue

previousTeammates.find { it.playerName == name }?.let { kuudraPlayer ->
kuudraPlayer.entity = mc.theWorld?.getPlayerEntityByName(name)
} ?: previousTeammates.add(KuudraPlayer(name, entity = mc.theWorld?.getPlayerEntityByName(name)))
kuudraPlayer.entity = mc.theWorld?.getPlayerEntityByName(name) ?: kuudraPlayer.entity
} ?: previousTeammates.add(KuudraPlayer(name, entity = mc.theWorld?.getPlayerEntityByName(name) ?: continue))
}
return previousTeammates
}
Expand Down

0 comments on commit 5306d4f

Please sign in to comment.