Skip to content

Commit

Permalink
Added expand to EtherWarpHelper
Browse files Browse the repository at this point in the history
Changed PuzzleTimer to be on room complete instead of leave
Cleanup
  • Loading branch information
odtheking committed Nov 12, 2024
1 parent 390df61 commit e9f1fa9
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 91 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

version = 1.2.5.beta13
version = 1.2.5.beta14
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object EtherWarpHelper : Module(
private val style by SelectorSetting("Style", Renderer.DEFAULT_STYLE, Renderer.styles, description = Renderer.STYLE_DESCRIPTION)
private val lineWidth by NumberSetting("Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.")
private val depthCheck by BooleanSetting("Depth check", false, description = "Boxes show through walls.")
private val expand by NumberSetting("Expand", 0.0, -1, 1, 0.01, description = "Expands the box by this amount.")
private val useServerPosition by DualSetting("Positioning", "Server Pos", "Player Pos", description = "If etherwarp guess should use your server position or real position.").withDependency { render }

private val dropdown by DropdownSetting("Sounds", false)
Expand All @@ -59,15 +60,13 @@ object EtherWarpHelper : Module(

etherPos = EtherWarpHelper.getEtherPos(positionLook)
if (etherPos.succeeded || renderFail)
Renderer.drawStyledBlock(etherPos.pos ?: return, if (etherPos.succeeded) color else wrongColor, style, lineWidth, depthCheck)
Renderer.drawStyledBlock(etherPos.pos ?: return, if (etherPos.succeeded) color else wrongColor, style, lineWidth, depthCheck, true, expand)
}

@SubscribeEvent
fun onSoundPacket(event: PacketReceivedEvent) {
with(event.packet) {
if (this !is S29PacketSoundEffect || soundName != "mob.enderdragon.hit" || !sounds || volume != 1f || pitch != 0.53968257f || customSound == "mob.enderdragon.hit") return
playLoudSound(if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound], soundVolume, soundPitch, positionVector)
event.isCanceled = true
}
fun onSoundPacket(event: PacketReceivedEvent) = with(event.packet) {
if (this !is S29PacketSoundEffect || soundName != "mob.enderdragon.hit" || !sounds || volume != 1f || pitch != 0.53968257f || customSound == "mob.enderdragon.hit") return
playLoudSound(if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound], soundVolume, soundPitch, positionVector)
event.isCanceled = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ object EtherWarpHelper : Module(
private val style by SelectorSetting("Style", Renderer.DEFAULT_STYLE, Renderer.styles, description = Renderer.STYLE_DESCRIPTION).withDependency { render }
private val lineWidth by NumberSetting("Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { render }
private val depthCheck by BooleanSetting("Depth check", false, description = "Boxes show through walls.").withDependency { render }
private val expand by NumberSetting("Expand", 0.0, -1, 1, 0.01, description = "Expands the box by this amount.").withDependency { render }
private val useServerPosition by DualSetting("Positioning", "Server Pos", "Player Pos", description = "If etherwarp guess should use your server position or real position.").withDependency { render }

private val etherwarpTBDropDown by DropdownSetting("Trigger Bot")
Expand Down Expand Up @@ -87,7 +88,7 @@ object EtherWarpHelper : Module(

etherPos = EtherWarpHelper.getEtherPos(positionLook)
if (render && (etherPos.succeeded || renderFail))
Renderer.drawStyledBlock(etherPos.pos ?: return, if (etherPos.succeeded) color else wrongColor, style, lineWidth, depthCheck)
Renderer.drawStyledBlock(etherPos.pos ?: return, if (etherPos.succeeded) color else wrongColor, style, lineWidth, depthCheck, true, expand)
}

@SubscribeEvent
Expand Down Expand Up @@ -127,11 +128,9 @@ object EtherWarpHelper : Module(
}

@SubscribeEvent
fun onSoundPacket(event: PacketReceivedEvent) {
with(event.packet) {
if (this !is S29PacketSoundEffect || soundName != "mob.enderdragon.hit" || !sounds || volume != 1f || pitch != 0.53968257f || customSound == "mob.enderdragon.hit") return
playLoudSound(if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound], soundVolume, soundPitch, positionVector)
event.isCanceled = true
}
fun onSoundPacket(event: PacketReceivedEvent) = with(event.packet) {
if (this !is S29PacketSoundEffect || soundName != "mob.enderdragon.hit" || !sounds || volume != 1f || pitch != 0.53968257f || customSound == "mob.enderdragon.hit") return
playLoudSound(if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound], soundVolume, soundPitch, positionVector)
event.isCanceled = true
}
}
15 changes: 6 additions & 9 deletions src/main/kotlin/me/odinmain/events/EventDispatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ object EventDispatcher {
* Dispatches [SecretPickupEvent.Item]
*/
@SubscribeEvent
fun onRemoveEntity(event: EntityLeaveWorldEvent) {
if (!inDungeons || event.entity !is EntityItem || event.entity.entityItem?.unformattedName?.containsOneOf(dungeonItemDrops, true) == false || mc.thePlayer.getDistanceToEntity(event.entity) > 6) return
SecretPickupEvent.Item(event.entity).postAndCatch()
fun onRemoveEntity(event: EntityLeaveWorldEvent) = with(event.entity) {
if (inDungeons && this is EntityItem && this.entityItem?.unformattedName?.containsOneOf(dungeonItemDrops, true) != false && mc.thePlayer.getDistanceToEntity(this) <= 6)
SecretPickupEvent.Item(this).postAndCatch()
}

/**
* Dispatches [SecretPickupEvent.Interact]
*/
@SubscribeEvent
fun onPacket(event: PacketSentEvent) {
with(event.packet) {
if (inDungeons && this is C08PacketPlayerBlockPlacement && position != null &&
isSecret(mc.theWorld?.getBlockState(position) ?: return, position))
SecretPickupEvent.Interact(position, mc.theWorld?.getBlockState(position) ?: return).postAndCatch()
}
fun onPacket(event: PacketSentEvent) = with(event.packet) {
if (inDungeons && this is C08PacketPlayerBlockPlacement && position != null)
SecretPickupEvent.Interact(position, mc.theWorld?.getBlockState(position)?.takeIf { isSecret(it, position) } ?: return).postAndCatch()
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ object Mimic : Module(
}

@SubscribeEvent
fun onEntityDeath(event: LivingDeathEvent) {
with(event.entity) {
if (!DungeonUtils.inDungeons || this !is EntityZombie || !this.isChild || !(0..3).all { this.getCurrentArmor(it) == null }) return
}
fun onEntityDeath(event: LivingDeathEvent) = with(event.entity) {
if (!DungeonUtils.inDungeons || this !is EntityZombie || !this.isChild || !(0..3).all { this.getCurrentArmor(it) == null }) return
mimicKilled()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.odinmain.features.impl.dungeon.puzzlesolvers
import me.odinmain.OdinMain.mc
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeHeight
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeWidth
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.puzzleTimersMap
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete
import me.odinmain.utils.*
import me.odinmain.utils.render.RenderUtils.renderBoundingBox
import me.odinmain.utils.render.RenderUtils.renderVec
Expand All @@ -18,6 +18,7 @@ object BlazeSolver {
private var blazes = mutableListOf<EntityArmorStand>()
private var roomType = 0
private var lastBlazeCount = 10
private val blazeHealthRegex = Regex("^\\[Lv15] Blaze [\\d,]+/([\\d,]+)❤$")

fun getBlaze() {
val room = DungeonUtils.currentRoom ?: return
Expand All @@ -26,7 +27,7 @@ object BlazeSolver {
blazes.clear()
mc.theWorld?.loadedEntityList?.forEach { entity ->
if (entity !is EntityArmorStand || entity in blazes) return@forEach
val hp = Regex("^\\[Lv15] Blaze [\\d,]+/([\\d,]+)❤$").find(entity.name.noControlCodes)?.groups?.get(1)?.value?.replace(",", "")?.toIntOrNull() ?: return@forEach
val hp = blazeHealthRegex.find(entity.name.noControlCodes)?.groups?.get(1)?.value?.replace(",", "")?.toIntOrNull() ?: return@forEach
hpMap[entity] = hp
blazes.add(entity)
}
Expand All @@ -43,8 +44,8 @@ object BlazeSolver {
if (blazes.isEmpty() && lastBlazeCount == 1) {
LocationUtils.currentDungeon?.puzzles?.find { it.name == Puzzle.Blaze.name }?.status = PuzzleStatus.Completed
if (PuzzleSolvers.blazeSendComplete) partyMessage("Blaze puzzle solved!")
puzzleTimersMap["Higher Blaze"]?.hasCompleted = true
puzzleTimersMap["Lower Blaze"]?.hasCompleted = true
onPuzzleComplete("Higher Blaze")
onPuzzleComplete("Lower Blaze")
lastBlazeCount = 0
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ object IceFillSolver {
}
}

fun transformTo(vec: Vec3i, rotation: Rotations): Vec3 {
return with(transform(vec.x, vec.z, rotation)) {
Vec3(x.toDouble(), vec.y.toDouble(), z.toDouble())
}
fun transformTo(vec: Vec3i, rotation: Rotations): Vec3 = with(transform(vec.x, vec.z, rotation)) {
Vec3(x.toDouble(), vec.y.toDouble(), z.toDouble())
}

fun reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ object PuzzleSolvers : Module(

private val puzzleTimers by BooleanSetting("Puzzle Timers", true, description = "Shows the time it took to solve each puzzle.").withDependency { enabled }
private val puzzleToIntMap = mapOf("Creeper Beams" to 0, "Blaze Lower" to 1, "Blaze Higher" to 2, "Boulder" to 3, "Ice FIll" to 4, "Quiz" to 5, "Teleport Maze" to 6, "Water Board" to 7, "Three Weirdos" to 8)
data class PuzzleTimer(val timeEntered: Long = System.currentTimeMillis(), var hasCompleted: Boolean = false, var sentMessage: Boolean = false)
val puzzleTimersMap = hashMapOf<String, PuzzleTimer>()
val puzzleTimersMap = hashMapOf<String, Long>()

init {
execute(500) {
Expand Down Expand Up @@ -145,38 +144,36 @@ object PuzzleSolvers : Module(
val room = DungeonUtils.currentRoom ?: return@onPacket

when (room.data.name) {
"Water Board" -> room.getRealCoords(15, 56, 22) == it.blockPosition
"Creeper Beams" -> room.getRealCoords(15, 69, 15) == it.blockPosition
"Boulder" -> room.getRealCoords(15, 66, 29) == it.blockPosition
"Three Weirdos" -> it.blockPosition.equalsOneOf(room.getRealCoords(18, 69, 24), room.getRealCoords(16, 69, 25), room.getRealCoords(14, 69, 24))
"Teleport Maze" -> room.getRealCoords(15, 70, 20) == it.blockPosition
"Ice Fill" -> it.blockPosition.equalsOneOf(room.getRealCoords(14, 75, 29), room.getRealCoords(16, 75, 29))
else -> false
}.takeIf { it } ?: return@onPacket

puzzleTimersMap[room.data.name]?.hasCompleted = true
"Ice Fill" -> it.blockPosition.equalsOneOf(room.getRealCoords(14, 75, 29), room.getRealCoords(16, 75, 29))
"Creeper Beams" -> it.blockPosition == room.getRealCoords(15, 69, 15)
"Teleport Maze" -> it.blockPosition == room.getRealCoords(15, 70, 20)
"Water Board" -> it.blockPosition == room.getRealCoords(15, 56, 22)
"Boulder" -> it.blockPosition == room.getRealCoords(15, 66, 29)
else -> false
}.takeIf { !it } ?: onPuzzleComplete(room.data.name)
}

onWorldLoad {
WaterSolver.reset()
TPMazeSolver.reset()
puzzleTimersMap.clear()
IceFillSolver.reset()
WeirdosSolver.reset()
BoulderSolver.reset()
TPMazeSolver.reset()
WaterSolver.reset()
BlazeSolver.reset()
BeamsSolver.reset()
WeirdosSolver.reset()
QuizSolver.reset()
BoulderSolver.reset()
TTTSolver.reset()
puzzleTimersMap.clear()
}
}

@SubscribeEvent
fun onWorldRender(event: RenderWorldLastEvent) {
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return
profile("Puzzle Solvers Render") {
if (waterSolver) WaterSolver.waterRender()
if (tpMaze) TPMazeSolver.tpRender()
if (waterSolver) WaterSolver.onRenderWorld()
if (tpMaze) TPMazeSolver.onRenderWorld()
if (iceFillSolver) IceFillSolver.onRenderWorld(iceFillColor)
if (blazeSolver) BlazeSolver.onRenderWorld()
if (beamsSolver) BeamsSolver.onRenderWorld()
Expand All @@ -196,17 +193,18 @@ object PuzzleSolvers : Module(
BoulderSolver.onRoomEnter(event)
TPMazeSolver.onRoomEnter(event)
if (!puzzleTimers) return
if (event.room?.data?.type == RoomType.PUZZLE && puzzleTimersMap.none { it.key == event.room.data.name }) puzzleTimersMap[event.room.data.name] = PuzzleTimer()
puzzleTimersMap.forEach {
if (!it.value.hasCompleted || it.value.sentMessage) return@forEach
puzzlePBs.time(puzzleToIntMap[it.key] ?: return@forEach, (System.currentTimeMillis() - it.value.timeEntered) / 1000.0, "s§7!", "§a${it.key} §7solved in §6", addPBString = true, addOldPBString = true, sendOnlyPB = true)
it.value.sentMessage = true
}
if (event.room?.data?.type == RoomType.PUZZLE && puzzleTimersMap.none { it.key == event.room.data.name }) puzzleTimersMap[event.room.data.name] = System.currentTimeMillis()
}

@SubscribeEvent
fun blockUpdateEvent(event: BlockChangeEvent) {
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return
if (beamsSolver) BeamsSolver.onBlockChange(event)
}

fun onPuzzleComplete(puzzleName: String) {
puzzleTimersMap[puzzleName]?.let {
puzzlePBs.time(puzzleToIntMap[puzzleName] ?: return@let, (System.currentTimeMillis() - it) / 1000.0, "s§7!", "§a${puzzleName} §7solved in §6", addPBString = true, addOldPBString = true, sendOnlyPB = false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object TPMazeSolver {
}
}

fun tpRender() {
fun onRenderWorld() {
if (DungeonUtils.currentRoomName != "Teleport Maze") return
tpPads.forEach {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object WaterSolver {
}
}

fun waterRender() {
fun onRenderWorld() {
if (variant == -1 || DungeonUtils.currentRoomName != "Water Board") return

val solutionList = solutions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,20 @@ object TerminalSounds : Module(
private var lastPlayed = System.currentTimeMillis()

@SubscribeEvent
fun onPacket(event: PacketReceivedEvent){
with(event.packet) {
if (
this is S29PacketSoundEffect &&
soundName == "note.pling" &&
volume == 8f &&
pitch == 4.047619f &&
shouldReplaceSounds
) event.isCanceled = true
}
fun onPacket(event: PacketReceivedEvent) = with(event.packet) {
if (this is S29PacketSoundEffect && soundName == "note.pling" && volume == 8f && pitch == 4.047619f && shouldReplaceSounds)
event.isCanceled = true
}

@SubscribeEvent
fun onSlotClick(event: GuiEvent.GuiMouseClickEvent) {
if (!shouldReplaceSounds) return
val slot = (event.gui as? GuiChest)?.slotUnderMouse?.slotIndex ?: return
clickSlot(slot)
clickSlot((event.gui as? GuiChest)?.slotUnderMouse?.slotIndex ?: return)
}

@SubscribeEvent
fun onCustomSlotClick(event: GuiEvent.CustomTermGuiClick) {
if (!shouldReplaceSounds) return
clickSlot(event.slot)
if (shouldReplaceSounds) clickSlot(event.slot)
}

@SubscribeEvent
Expand Down Expand Up @@ -94,14 +85,12 @@ object TerminalSounds : Module(
}

fun playCompleteSound() {
val sound = if (completedSound == defaultSounds.size - 1) customCompleteSound else defaultSounds[completedSound]
PlayerUtils.playLoudSound(sound, completeVolume, completePitch)
PlayerUtils.playLoudSound( if (completedSound == defaultSounds.size - 1) customCompleteSound else defaultSounds[completedSound], completeVolume, completePitch)
}

private fun playTerminalSound() {
if (System.currentTimeMillis() - lastPlayed <= 2) return
val sound = if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound]
PlayerUtils.playLoudSound(sound, clickVolume, clickPitch)
PlayerUtils.playLoudSound(if (sound == defaultSounds.size - 1) customSound else defaultSounds[sound], clickVolume, clickPitch)
lastPlayed = System.currentTimeMillis()
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/me/odinmain/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ fun writeToClipboard(text: String, successMessage: String = "§aCopied to clipbo
}

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)
private val numberRegex = Regex("^[0-9]+$")
fun romanToInt(s: String): Int {
return if (s.matches(Regex("^[0-9]+$"))) s.toInt()
return if (s.matches(numberRegex)) s.toInt()
else {
var result = 0
for (i in 0 until s.length - 1) {
Expand Down
14 changes: 8 additions & 6 deletions src/main/kotlin/me/odinmain/utils/render/Renderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ object Renderer {
outlineAlpha: Number = 1,
fillAlpha: Number = 1,
depth: Boolean = false,
lineSmoothing: Boolean = true
lineSmoothing: Boolean = true,
expand: Double = 0.0
) {
val block = getBlockAt(pos)
block.setBlockBoundsBasedOnState(mc.theWorld, pos)
drawBox(block.getSelectedBoundingBox(mc.theWorld, pos).outlineBounds(), color, outlineWidth, outlineAlpha, fillAlpha, depth, lineSmoothing)
drawBox(block.getSelectedBoundingBox(mc.theWorld, pos).outlineBounds().expand(expand, expand, expand), color, outlineWidth, outlineAlpha, fillAlpha, depth, lineSmoothing)
}

fun drawStyledBlock(
Expand All @@ -79,12 +80,13 @@ object Renderer {
style: Int,
width: Number = 3,
depth: Boolean = false,
lineSmoothing: Boolean = true
lineSmoothing: Boolean = true,
expand: Double = 0.0
) {
when (style) {
0 -> drawBlock(pos, color, width, 0, color.alpha, depth, lineSmoothing)
1 -> drawBlock(pos, color, width, color.alpha, 0, depth, lineSmoothing)
2 -> drawBlock(pos, color, width, color.alpha, color.multiplyAlpha(.75f).alpha, depth, lineSmoothing)
0 -> drawBlock(pos, color, width, 0, color.alpha, depth, lineSmoothing, expand)
1 -> drawBlock(pos, color, width, color.alpha, 0, depth, lineSmoothing, expand)
2 -> drawBlock(pos, color, width, color.alpha, color.multiplyAlpha(.75f).alpha, depth, lineSmoothing, expand)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/me/odinmain/utils/skyblock/ItemUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ enum class ItemRarity(
VERY_SPECIAL("VERY SPECIAL", "§c", Color.RED);
}

private val rarityRegex: Regex = Regex("§l(?<rarity>${ItemRarity.entries.joinToString("|") { it.loreName }}) ?(?<type>[A-Z ]+)?(?:§[0-9a-f]§l§ka)?$")
private val rarityRegex = Regex("§l(?<rarity>${ItemRarity.entries.joinToString("|") { it.loreName }}) ?(?<type>[A-Z ]+)?(?:§[0-9a-f]§l§ka)?$")

/**
* Gets the rarity of an item
Expand Down
Loading

0 comments on commit e9f1fa9

Please sign in to comment.