diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt index c65b48fe4..0a832ce27 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt @@ -159,7 +159,10 @@ abstract class AbstractHudElement( default.valueListeners.add { _, it -> if (it) { - settingList.filter { it != visibleSetting && it != default }.forEach { it.resetValue() } + settingList.filter { it != visibleSetting && it != default }.forEach { + it.resetValue() + updatePreDrag(null) + } default.value = false MessageSendHelper.sendChatMessage("$name Set to defaults!") } diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt index c3659ea21..d6dda1fb9 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt @@ -2,6 +2,7 @@ package com.lambda.client.gui.hudgui import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.SafeClientEvent +import com.lambda.client.module.modules.client.Hud import com.lambda.client.module.modules.client.HudEditor import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.graphics.VertexHelper @@ -23,7 +24,6 @@ abstract class AbstractLabelHud( override val hudWidth: Float get() = displayText.getWidth() + 2.0f override val hudHeight: Float get() = displayText.getHeight(2) - protected val displayText = TextComponent(separator) init { @@ -47,7 +47,8 @@ abstract class AbstractLabelHud( displayText.draw( Vec2d(textPosX.toDouble(), textPosY.toDouble()), horizontalAlign = dockingH, - verticalAlign = dockingV + verticalAlign = dockingV, + drawShadow = Hud.textShadow ) } diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/OnlineTime.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/OnlineTime.kt new file mode 100644 index 000000000..16018eaed --- /dev/null +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/OnlineTime.kt @@ -0,0 +1,20 @@ +package com.lambda.client.gui.hudgui.elements.misc + +import com.lambda.client.event.SafeClientEvent +import com.lambda.client.gui.hudgui.LabelHud +import com.lambda.client.manager.managers.OnlineTimeManager +import kotlin.math.roundToInt +import kotlin.time.DurationUnit +import kotlin.time.toDuration + +internal object OnlineTime: LabelHud( + name = "OnlineTime", + category = Category.MISC, + description = "Displays how long you have been online" +) { + override fun SafeClientEvent.updateText() { + val onlineTime = OnlineTimeManager.getOnlineTime().toDouble(DurationUnit.SECONDS).roundToInt() + displayText.add("Online:", secondaryColor) + displayText.add(onlineTime.toDuration(DurationUnit.SECONDS).toString(), primaryColor) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt index 3ee127185..b08dec35e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt @@ -15,6 +15,7 @@ internal object Time : LabelHud( private val showTime = setting("Show Time", true) private val dateFormat = setting("Date Format", TimeUtils.DateFormat.DDMMYY, { showDate.value }) private val timeFormat = setting("Time Format", TimeUtils.TimeFormat.HHMM, { showTime.value }) + private val cutoffTimeLeadingZero = setting("Cutoff Time Leading Zero", true, { showTime.value }) private val timeUnit = setting("Time Unit", TimeUtils.TimeUnit.H12, { showTime.value }) override fun SafeClientEvent.updateText() { @@ -24,7 +25,8 @@ internal object Time : LabelHud( displayText.addLine("") } if (showTime.value) { - val time = TimeUtils.getTime(timeFormat.value, timeUnit.value) + var time = TimeUtils.getTime(timeFormat.value, timeUnit.value) + if (cutoffTimeLeadingZero.value && time.isNotEmpty() && time[0] == '0') time = time.removeRange(0, 1) time.forEach { displayText.add(it.toString(), if (it.isDigit()) primaryColor else secondaryColor) } } } diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Direction.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Direction.kt index 4afd48324..1516d8764 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Direction.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Direction.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.hudgui.elements.player +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.math.Direction @@ -7,14 +8,21 @@ import com.lambda.client.util.math.Direction internal object Direction : LabelHud( name = "Direction", category = Category.PLAYER, - description = "Direction of player facing to" + description = "Displays the direction you are facing" ) { + private val directionDisplayMode by setting("Direction Format", DirectionFormat.XZ) + + enum class DirectionFormat(override val displayName: String): DisplayEnum { + NAME("Name"), XZ("XZ"), BOTH("Both") + } override fun SafeClientEvent.updateText() { val entity = mc.renderViewEntity ?: player val direction = Direction.fromEntity(entity) - displayText.add(direction.displayName, secondaryColor) - displayText.add("(${direction.displayNameXY})", primaryColor) + if (directionDisplayMode == DirectionFormat.NAME || directionDisplayMode == DirectionFormat.BOTH) + displayText.add(direction.displayName, secondaryColor) + if (directionDisplayMode == DirectionFormat.XZ || directionDisplayMode == DirectionFormat.BOTH) + displayText.add("(${direction.displayNameXY})", primaryColor) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt index 8082a9d49..0585246f8 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt @@ -10,15 +10,20 @@ internal object Rotation : LabelHud( category = Category.PLAYER, description = "Player rotation" ) { + private val yaw by setting("Yaw", true) + private val pitch by setting("Pitch", true) override fun SafeClientEvent.updateText() { - val yaw = MathUtils.round(RotationUtils.normalizeAngle(mc.player?.rotationYaw ?: 0.0f), 1) - val pitch = MathUtils.round(mc.player?.rotationPitch ?: 0.0f, 1) - - displayText.add("Yaw", secondaryColor) - displayText.add(yaw.toString(), primaryColor) - displayText.add("Pitch", secondaryColor) - displayText.add(pitch.toString(), primaryColor) + if (yaw) { + val yawVal = MathUtils.round(RotationUtils.normalizeAngle(mc.player?.rotationYaw ?: 0.0f), 1) + displayText.add("Yaw", secondaryColor) + displayText.add(yawVal.toString(), primaryColor) + } + if (pitch) { + val pitchVal = MathUtils.round(mc.player?.rotationPitch ?: 0.0f, 1) + displayText.add("Pitch", secondaryColor) + displayText.add(pitchVal.toString(), primaryColor) + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt index 7031a56c1..3df781af3 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Coordinates.kt @@ -15,7 +15,10 @@ internal object Coordinates : LabelHud( private val showX by setting("Show X", true) private val showY by setting("Show Y", true) private val showZ by setting("Show Z", true) + private val showXYZText by setting("Show XYZ Text", true) private val showNetherOverworld by setting("Show Nether/Overworld", true) + private val printDimensionName by setting("Print Dimension Name", false) + private val showNetherOverworldMultiline by setting("Show Nether/Overworld Multiline", false, { showNetherOverworld }) private val decimalPlaces by setting("Decimal Places", 1, 0..4, 1) private val thousandsSeparator by setting("Thousands Separator", false) @@ -24,42 +27,48 @@ internal object Coordinates : LabelHud( override fun SafeClientEvent.updateText() { val entity = mc.renderViewEntity ?: player - - displayText.add("XYZ", secondaryColor) - displayText.addLine(getFormattedCoords(entity.positionVector)) - + if (showXYZText) { + displayText.add("XYZ", secondaryColor) + } + if (showNetherOverworldMultiline) + displayText.addLine(getFormattedCoords(entity.positionVector)) + else + displayText.add(getFormattedCoords(entity.positionVector)) if (showNetherOverworld) { - when (entity.dimension) { + when (world.provider.dimension) { -1 -> { // Nether - displayText.add("Overworld", secondaryColor) - displayText.addLine(getFormattedCoords(entity.positionVector * netherToOverworld)) + if (printDimensionName) displayText.add("Nether", secondaryColor) + displayText.add(getFormattedCoords(entity.positionVector * netherToOverworld, true)) } 0 -> { // Overworld - displayText.add("Nether", secondaryColor) - displayText.addLine(getFormattedCoords(entity.positionVector * overworldToNether)) + if (printDimensionName) + displayText.add("Overworld", secondaryColor) + displayText.add(getFormattedCoords(entity.positionVector * overworldToNether, true)) } } } } - private fun getFormattedCoords(pos: Vec3d): TextComponent.TextElement { + private fun getFormattedCoords(pos: Vec3d, brackets: Boolean = false): TextComponent.TextElement { + if (!showX && !showY && !showZ) return TextComponent.TextElement("", primaryColor) val x = roundOrInt(pos.x) val y = roundOrInt(pos.y) val z = roundOrInt(pos.z) return StringBuilder().run { + if (brackets) append("[") if (showX) append(x) if (showY) appendWithComma(y) if (showZ) appendWithComma(z) + if (brackets) append("]") TextComponent.TextElement(toString(), primaryColor) } } private fun roundOrInt(input: Double): String { val separatorFormat = if (thousandsSeparator) "," else "" - return "%$separatorFormat.${decimalPlaces}f".format(input) } - private fun StringBuilder.appendWithComma(string: String) = append(if (length > 0) ", $string" else string) + private fun StringBuilder.appendWithComma(string: String) = append(if (isNotEmpty()) ", $string" else string) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt index 08bb4f8b6..f142a04a5 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt @@ -35,6 +35,7 @@ internal object Radar : HudElement( private val neutral = setting("Neutral Mobs", true) private val hostile = setting("Hostile Mobs", true) private val invisible = setting("Invisible Entities", true) + private val rotation by setting("Rotation", true) override val hudWidth: Float = 130.0f override val hudHeight: Float = 130.0f @@ -56,7 +57,7 @@ internal object Radar : HudElement( glTranslated(radius.toDouble(), radius.toDouble(), 0.0) drawCircleFilled(vertexHelper, radius = radius.toDouble(), color = GuiColors.backGround) drawCircleOutline(vertexHelper, radius = radius.toDouble(), lineWidth = 1.8f, color = primaryColor) - glRotatef(player.rotationYaw + 180, 0f, 0f, -1f) + if (rotation) glRotatef(player.rotationYaw + 180, 0f, 0f, -1f) } private fun SafeClientEvent.drawEntities(vertexHelper: VertexHelper) { diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt index 951a9f3e9..f2d10d173 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt @@ -89,7 +89,7 @@ open class WindowComponent( if (mouseState != MouseState.DRAG) updatePreDrag(mousePos.minus(posX, posY)) } - private fun updatePreDrag(mousePos: Vec2f?) { + protected fun updatePreDrag(mousePos: Vec2f?) { mousePos?.let { preDragMousePos = it } preDragPos = Vec2f(posX, posY) preDragSize = Vec2f(width, height) diff --git a/src/main/kotlin/com/lambda/client/manager/managers/OnlineTimeManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/OnlineTimeManager.kt new file mode 100644 index 000000000..ac5dac590 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/manager/managers/OnlineTimeManager.kt @@ -0,0 +1,22 @@ +package com.lambda.client.manager.managers + +import com.lambda.client.event.events.ConnectionEvent +import com.lambda.client.event.listener.listener +import com.lambda.client.manager.Manager +import kotlin.time.Duration +import kotlin.time.TimeSource + +object OnlineTimeManager: Manager { + + private var connectTime = TimeSource.Monotonic.markNow() + + init { + listener { + connectTime = TimeSource.Monotonic.markNow() + } + } + + fun getOnlineTime(): Duration { + return connectTime.elapsedNow() + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Hud.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Hud.kt index 8887db8ce..260116744 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Hud.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Hud.kt @@ -14,6 +14,7 @@ object Hud : Module( val hudFrame by setting("Hud Frame", false) val primaryColor by setting("Primary Color", ColorHolder(255, 240, 246), false) val secondaryColor by setting("Secondary Color", ColorHolder(108, 0, 43), false) + val textShadow by setting("Text Shadow", true) val chatSnap by setting("Chat Snap", true) val collisionSnapping by setting("Collision Snapping", true) } \ No newline at end of file