Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build-mod.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ kotlin {

languageVersion = KotlinVersion.KOTLIN_2_0
apiVersion = KotlinVersion.KOTLIN_2_0

val args = listOf(
"-Xjvm-default=all",
"-Xcontext-recievers"
)
freeCompilerArgs.addAll(args)
}
}

Expand Down
36 changes: 34 additions & 2 deletions src/main/kotlin/net/llvg/exec/ExeClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,47 @@ package net.llvg.exec

import net.llvg.exec.config.ExeClientConfig
import net.llvg.exec.features.FeatureManager
import net.llvg.exec.utils.loggerTypeNamed
import net.llvg.exec.utils.chat_component.ChatComponentBuildScope
import net.llvg.exec.utils.chat_component.buildChatComponent
import net.llvg.exec.utils.classNameLogger
import net.llvg.exec.utils.player
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.IChatComponent

object ExeClient {
@JvmField
val logger = loggerTypeNamed<ExeClient>()
val logger = classNameLogger<ExeClient>()

@JvmStatic
fun initialize() {
FeatureManager
ExeClientConfig
}

fun send(
message: IChatComponent
) {
buildChatComponent {
empty +
combine {
empty {
bold = true
color = EnumChatFormatting.WHITE
} +
text("[") +
text("Exe Client") {
color = EnumChatFormatting.AQUA
} +
text("]")
} +
space +
message
}.run(player::addChatMessage)
}

fun send(
builder: ChatComponentBuildScope.() -> IChatComponent
) {
send(ChatComponentBuildScope.builder())
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/net/llvg/exec/config/ExeClientConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import cc.polyfrost.oneconfig.config.annotations.SubConfig
import cc.polyfrost.oneconfig.config.data.Mod
import cc.polyfrost.oneconfig.config.data.ModType
import net.llvg.exec.config.freecam.FreeCamConfig
import net.llvg.exec.utils.loggerTypeNamed
import net.llvg.exec.utils.classNameLogger

object ExeClientConfig : Config(Mod("Exe Client", ModType.SKYBLOCK), "exec-config.json", false) {
@Transient
val logger = loggerTypeNamed<ExeClientConfig>()
val logger = classNameLogger<ExeClientConfig>()

@SubConfig
@Suppress("UNUSED")
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/net/llvg/exec/features/ExeFeature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ package net.llvg.exec.features

import net.llvg.exec.config.ExeFeatureConfig
import net.llvg.exec.event.ExeCEventListenable
import net.llvg.exec.utils.chat_component.withChatStyle
import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.IChatComponent

interface ExeFeature : ExeCEventListenable {
fun initialize()
Expand All @@ -33,4 +37,18 @@ interface ExeFeature : ExeCEventListenable {

override val active: Boolean
get() = config.active()

companion object {
val MESSAGE_ENABLED: IChatComponent =
ChatComponentText("Enabled")
.withChatStyle {
color = EnumChatFormatting.GREEN
}

val MESSAGE_DISABLED: IChatComponent =
ChatComponentText("Disabled")
.withChatStyle {
color = EnumChatFormatting.RED
}
}
}
43 changes: 34 additions & 9 deletions src/main/kotlin/net/llvg/exec/features/freecam/FreeCam.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,46 @@
package net.llvg.exec.features.freecam

import kotlinx.coroutines.Dispatchers
import net.llvg.exec.ExeClient
import net.llvg.exec.config.ExeFeatureConfig
import net.llvg.exec.config.freecam.FreeCamConfig
import net.llvg.exec.event.events.ServerCameraChangeEvent
import net.llvg.exec.event.events.UserHealthChangeEvent
import net.llvg.exec.event.events.WorldLoadEvent
import net.llvg.exec.event.onEvent
import net.llvg.exec.features.ExeFeature
import net.llvg.exec.utils.chat_component.buildChatComponent
import net.llvg.exec.utils.mc
import net.llvg.exec.utils.player
import net.llvg.exec.utils.sendToUser
import net.llvg.exec.utils.world
import net.llvg.loliutils.exception.asNotNull
import net.minecraft.entity.Entity
import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.MovementInput
import net.minecraft.util.MovementInputFromOptions

object FreeCam : ExeFeature {
init {
onEvent(dispatcher = Dispatchers.Default) { e: UserHealthChangeEvent ->
if (FreeCamConfig.disableOnDamage && e.instance.health > e.health) {
if (FreeCamConfig.sendMessage) ExeClient.send {
text("You took damage!") {
color = EnumChatFormatting.YELLOW
}
}

disable()
}
}

onEvent(dispatcher = Dispatchers.Default) { e: ServerCameraChangeEvent ->
if (FreeCamConfig.sendMessage) {
sendToUser(ChatComponentText("[Exe Client] Server tries to change your camera!"))
}

if (FreeCamConfig.disableOnSeverCameraChange) {
if (FreeCamConfig.sendMessage) ExeClient.send {
text("Server is trying to change your camera entity!") {
color = EnumChatFormatting.YELLOW
}
}

disable()
} else {
previousEntity = e.entity
Expand Down Expand Up @@ -146,6 +155,13 @@ object FreeCam : ExeFeature {
}
}

private val MESSAGE_ENABLED = buildChatComponent {
empty +
text("Free Camera") +
space +
ExeFeature.MESSAGE_ENABLED
}

@Synchronized
private fun enable() {
if (enabled) return
Expand Down Expand Up @@ -175,10 +191,17 @@ object FreeCam : ExeFeature {
}
// send message
if (FreeCamConfig.sendMessage) {
sendToUser(ChatComponentText("[Exe Client] Free Camera Enabled"))
ExeClient.send(MESSAGE_ENABLED)
}
}

private val MESSAGE_DISABLED = buildChatComponent {
empty +
text("Free Camera") +
space +
ExeFeature.MESSAGE_DISABLED
}

@Synchronized
private fun disable() {
if (!enabled) return
Expand All @@ -198,14 +221,16 @@ object FreeCam : ExeFeature {
mc.renderViewEntity = previousEntity
previousEntity = null
// reload shader
mc.entityRenderer.loadEntityShader(if (mc.gameSettings.thirdPersonView == 0) previousEntity else null)
mc.entityRenderer.loadEntityShader(
if (mc.gameSettings.thirdPersonView == 0) previousEntity else null
)
mc.renderGlobal.setDisplayListEntitiesDirty()
// set disabled
enabled = false
}
// send message
if (FreeCamConfig.sendMessage) {
sendToUser(ChatComponentText("[Exe Client] Free Camera Disabled"))
ExeClient.send(MESSAGE_DISABLED)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package net.llvg.exec.preload.vanilla_tweaker

import cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker
import java.io.File
import net.llvg.exec.utils.loggerTypeNamed
import net.llvg.exec.utils.classNameLogger
import net.llvg.loliutils.exception.uncheckedCast
import net.minecraft.launchwrapper.ITweaker
import net.minecraft.launchwrapper.Launch
Expand Down Expand Up @@ -76,4 +76,4 @@ class ExeCTweaker : ITweaker {
}
}

private val logger = loggerTypeNamed<ExeCTweaker>()
private val logger = classNameLogger<ExeCTweaker>()
11 changes: 2 additions & 9 deletions src/main/kotlin/net/llvg/exec/utils/LoggerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@

package net.llvg.exec.utils

import net.minecraft.util.IChatComponent
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger

inline fun <reified T> loggerTypeNamed(
): Logger = LogManager.getLogger(T::class.java.simpleName)

fun sendToUser(
message: IChatComponent
) {
player.addChatMessage(message)
}
inline fun <reified T> classNameLogger(
): Logger = LogManager.getLogger(T::class.java.simpleName)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2025-2025 Water-OR
*
* This file is part of ExeClient
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.llvg.exec.utils.chat_component

import net.minecraft.util.ChatComponentText
import net.minecraft.util.ChatStyle
import net.minecraft.util.IChatComponent

object ChatComponentBuildScope {
val empty: IChatComponent
get() = ChatComponentEmpty()

@Suppress("UNUSED")
fun ChatComponentBuildScope.empty(
configure: ChatStyle.() -> Unit
): IChatComponent = empty withChatStyle configure

val space: IChatComponent
get() = ChatComponentText(" ")

@Suppress("UNUSED")
fun ChatComponentBuildScope.space(
configure: ChatStyle.() -> Unit
): IChatComponent = space withChatStyle configure

val endl: IChatComponent
get() = ChatComponentText("\n")

@Suppress("UNUSED")
fun ChatComponentBuildScope.endl(
configure: ChatStyle.() -> Unit
): IChatComponent = endl withChatStyle configure

fun text(
text: String
): IChatComponent = ChatComponentText(text)

@Suppress("UNUSED")
fun ChatComponentBuildScope.text(
text: String,
configure: ChatStyle.() -> Unit
): IChatComponent = text(text) withChatStyle configure

@Suppress("UNUSED", "UnusedReceiverParameter")
fun ChatComponentBuildScope.combine(
builder: () -> IChatComponent
): IChatComponent = builder()

infix operator fun <C : IChatComponent> C.plus(
o: IChatComponent
): C = apply { appendSibling(o) }

inline infix operator fun <C : IChatComponent> C.plus(
configure: (C) -> Unit
): C = apply(configure)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2025-2025 Water-OR
*
* This file is part of ExeClient
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.llvg.exec.utils.chat_component

import net.minecraft.util.ChatComponentStyle
import net.minecraft.util.IChatComponent

class ChatComponentEmpty : ChatComponentStyle() {
override fun getUnformattedTextForChat(
): String? = ""

override fun createCopy(
): IChatComponent? {
val result = ChatComponentEmpty()
result.chatStyle = chatStyle.createShallowCopy()
siblings.forEach {
result + it.createCopy()
}
return result
}

override fun toString(): String {
return "EmptyComponent{siblings=$siblings, style=$chatStyle}"
}
}
Loading