From a3da8350333c7a00a7c8b9358cac5fb78e412c36 Mon Sep 17 00:00:00 2001 From: oneqxz Date: Mon, 16 Dec 2024 18:46:10 +0800 Subject: [PATCH 01/30] baritone settings --- build.gradle | 10 + gradle.properties | 2 + .../features/module/ModuleManager.kt | 10 +- .../module/modules/client/ModuleBaritone.kt | 211 ++++++++++++++++++ .../liquidbounce/render/engine/RenderTasks.kt | 4 + .../liquidbounce/utils/client/BaritoneUtil.kt | 23 ++ .../assets/liquidbounce/lang/en_us.json | 3 +- 7 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt diff --git a/build.gradle b/build.gradle index b36543ba5db..f6c638d0300 100644 --- a/build.gradle +++ b/build.gradle @@ -69,6 +69,14 @@ repositories { name = "Lenni0451" url = "https://maven.lenni0451.net/everything" } + maven { + name = "meteor-maven-snapshots" + url = "https://maven.meteordev.org/snapshots" + } + maven { + name = 'babbaj-maven' + url = 'https://babbaj.github.io/maven/' + } } loom { @@ -89,6 +97,8 @@ dependencies { modRuntimeOnly "com.terraformersmc:modmenu:${project.mod_menu_version}" modImplementation "maven.modrinth:sodium:${project.sodium_version}" modCompileOnly "de.florianmichael:ViaFabricPlus:${project.viafabricplus_version}" + modImplementation "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT" + implementation 'dev.babbaj:nether-pathfinder:1.5' // Minecraft Authlib includeDependency ("com.github.CCBlueX:mc-authlib:${project.mc_authlib_version}") { diff --git a/gradle.properties b/gradle.properties index 99028aa7019..3b650fa6cd0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,6 +25,8 @@ yarn_mappings=1.21.1+build.3 loader_version=0.16.9 min_loader_version=0.15.10 +# https://github.com/cabaletta/baritone +baritone_version=1.21.1 # Fabric API fabric_version=0.107.0+1.21.1 # Loom diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt index 708d20e26dd..7fdab8068cf 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt @@ -25,10 +25,7 @@ import net.ccbluex.liquidbounce.event.events.KeyboardKeyEvent import net.ccbluex.liquidbounce.event.events.MouseButtonEvent import net.ccbluex.liquidbounce.event.events.WorldChangeEvent import net.ccbluex.liquidbounce.event.handler -import net.ccbluex.liquidbounce.features.module.modules.client.ModuleAutoConfig -import net.ccbluex.liquidbounce.features.module.modules.client.ModuleLiquidChat -import net.ccbluex.liquidbounce.features.module.modules.client.ModuleRichPresence -import net.ccbluex.liquidbounce.features.module.modules.client.ModuleTargets +import net.ccbluex.liquidbounce.features.module.modules.client.* import net.ccbluex.liquidbounce.features.module.modules.combat.* import net.ccbluex.liquidbounce.features.module.modules.combat.autoarmor.ModuleAutoArmor import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.ModuleCriticals @@ -81,6 +78,7 @@ import net.ccbluex.liquidbounce.features.module.modules.world.packetmine.ModuleP import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold import net.ccbluex.liquidbounce.features.module.modules.world.traps.ModuleAutoTrap import net.ccbluex.liquidbounce.script.ScriptApiRequired +import net.ccbluex.liquidbounce.utils.client.BaritoneUtil import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.input.InputBind import net.ccbluex.liquidbounce.utils.kotlin.mapArray @@ -364,6 +362,10 @@ object ModuleManager : EventListener, Iterable by modules { builtin += ModuleDebugRecorder } + if (BaritoneUtil.isAvailable) { + builtin += ModuleBaritone + } + builtin.forEach { addModule(it) it.walkKeyPath() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt new file mode 100644 index 00000000000..15836bab901 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -0,0 +1,211 @@ +package net.ccbluex.liquidbounce.features.module.modules.client + +import baritone.api.BaritoneAPI +import baritone.api.Settings +import net.ccbluex.liquidbounce.config.types.Configurable +import net.ccbluex.liquidbounce.config.types.Value +import net.ccbluex.liquidbounce.features.module.Category +import net.ccbluex.liquidbounce.features.module.ClientModule +import net.ccbluex.liquidbounce.features.module.modules.client.ModuleBaritone.Movement.Parkour +import net.ccbluex.liquidbounce.render.engine.toColor +import net.ccbluex.liquidbounce.render.engine.toColor4b +import net.ccbluex.liquidbounce.utils.client.BaritoneUtil +import java.awt.Color + +/** + * Baritone settings in GUI + * + * @author sqlerrorthing + */ +object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivation = true, hide = true) { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Break", allowBreak) + createSetting("Place", allowPlace) + } + + treeAll( + Movement, + Penalties, + Mining, + Items, + Elytra + ) + } + } + + private object Mining : Configurable("Mining") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("MinMineYLevel", minYLevelWhileMining, maxRangedValue = 2031) + createSetting("MaxMineYLevel", maxYLevelWhileMining, maxRangedValue = 2031) + createSetting("MineGoalUpdateInterval", mineGoalUpdateInterval, maxRangedValue = 20) + createSetting("MineMaxOreLocationsCount", mineGoalUpdateInterval, maxRangedValue = 64) + createSetting("PauseMiningForFallingBlocks", pauseMiningForFallingBlocks) + createSetting("ForceInternalMining", forceInternalMining) + createSetting("OnlyExposedOres", allowOnlyExposedOres) + createSetting("UseSword", useSwordToMine) + createSetting("NotificationOnMineFail", notificationOnMineFail) + } + + treeAll( + LegitMine + ) + } + } + + private object LegitMine : Configurable("LegitMine") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Allow", legitMine) + createSetting("IncludeDiagonals", legitMineIncludeDiagonals) + createSetting("YLevel", legitMineYLevel, -64, 320) + } + } + } + } + } + + private object Movement : Configurable("Movement") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Sprint", allowSprint) + createSetting("JumpAt256", allowJumpAt256) + } + + treeAll( + Parkour + ) + } + } + + private object Parkour : Configurable("Parkour") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Allow", allowParkour) + createSetting("Place", allowParkourPlace) + createSetting("Ascend", allowParkourAscend) + } + } + } + } + } + + private object Penalties : Configurable("Penalties") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("BlockPlacement", blockPlacementPenalty, maxRangedValue = 300) + createSetting("BlockBreakAdditionalPenalty", blockBreakAdditionalPenalty) + createSetting("BreakCorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) + createSetting("PlaceIncorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier) + createSetting("WalkOnWaterOnePenalty", walkOnWaterOnePenalty) + createSetting("JumpPenalty", jumpPenalty) + } + } + } + } + + private object Elytra : Configurable("Elytra") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("SimulationTicks", elytraSimulationTicks, 1, 100) + createSetting("PitchRange", elytraPitchRange, 1, 100) + createSetting("MinimumAvoidance", elytraMinimumAvoidance, -10) + createSetting("PredictTerrain", elytraPredictTerrain) + createSetting("EmergencyLand", elytraAllowEmergencyLand) + createSetting("LandOnNetherFortress", elytraAllowLandOnNetherFortress) + } + + treeAll( + Auto, + Firework, + Render + ) + } + } + + private object Auto : Configurable("Auto") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("AutoJump", elytraAutoJump) + createSetting("Swap", elytraAutoSwap) + } + } + } + } + + private object Firework : Configurable("Firework") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Speed", elytraFireworkSpeed) + createSetting("SetbackUseDelay", elytraFireworkSetbackUseDelay) + createSetting("Conserve", elytraConserveFireworks) + } + } + } + } + + private object Render : Configurable("Render") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Raytraces", elytraRenderRaytraces) + createSetting("HitboxRaytraces", elytraRenderHitboxRaytraces) + createSetting("Simulation", elytraRenderSimulation) + } + } + } + } + } + + private object Items : Configurable("Items") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Inventory", allowInventory) + createSetting("AutoTool", autoTool) + } + } + } + } +} + +@Suppress("unchecked_cast") +private fun Configurable.createSetting( + name: String, + setting: Settings.Setting, + minRangedValue: Int = 0, + maxRangedValue: Int = 10 +): Value<*> = when (val value = setting.value) { + is Boolean -> boolean(name, value) + .onChanged { setting.value = it as T } + + is Double -> float(name, value.toFloat(), minRangedValue.toFloat()..maxRangedValue.toFloat()) + .onChanged { setting.value = it.toDouble() as T } + + is Float -> float(name, value, minRangedValue.toFloat()..maxRangedValue.toFloat()) + .onChanged { setting.value = it as T } + + is Int -> int(name, value, 0..maxRangedValue) + .onChanged { setting.value = it as T } + + is Long -> int(name, value.toInt(), minRangedValue..maxRangedValue) + .onChanged { setting.value = it.toLong() as T } + + is String -> text(name, value) + .onChanged { setting.value = it as T } + + is Color -> color(name, value.toColor4b()) + .onChanged { setting.value = it.toColor() as T } + + else -> throw NotImplementedError("Undefined baritone setting class!") +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/RenderTasks.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/RenderTasks.kt index 8b76767aef3..3264342d4a1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/RenderTasks.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/RenderTasks.kt @@ -187,3 +187,7 @@ data class Color4b(val r: Int, val g: Int, val b: Int, val a: Int) { private fun darkerChannel(value: Int) = (value * 0.7).toInt().coerceAtLeast(0) } + +fun Color.toColor4b(): Color4b = Color4b(this) + +fun Color4b.toColor(): Color = Color(r, g, b, a) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt new file mode 100644 index 00000000000..56ea40a948b --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt @@ -0,0 +1,23 @@ +package net.ccbluex.liquidbounce.utils.client + +import baritone.api.BaritoneAPI +import baritone.api.process.IBaritoneProcess +import baritone.api.process.ICustomGoalProcess +import baritone.api.process.IMineProcess + +object BaritoneUtil { + val isAvailable = runCatching { + Class.forName("baritone.api.BaritoneAPI") + true + }.getOrDefault(false) + + val baritone get() = BaritoneAPI.getProvider().primaryBaritone + ?: throw IllegalStateException("Called baritone but it is not available, please make sure to check isBaritoneAvailable") + + val isMining get() = mostResentInControl is IMineProcess + + val isWalking get() = mostResentInControl is ICustomGoalProcess +} + +private val mostResentInControl: IBaritoneProcess? + get() = BaritoneUtil.baritone.pathingControlManager.mostRecentInControl().orElse(null) diff --git a/src/main/resources/assets/liquidbounce/lang/en_us.json b/src/main/resources/assets/liquidbounce/lang/en_us.json index 6ccde95780c..b6cf334ed6b 100644 --- a/src/main/resources/assets/liquidbounce/lang/en_us.json +++ b/src/main/resources/assets/liquidbounce/lang/en_us.json @@ -616,5 +616,6 @@ "liquidbounce.module.dupe.description": "Attempts to Auto-Dupe items from your inventory by using exploits.", "liquidbounce.module.surround.description": "Builds holes that protect you from explosion damage.", "liquidbounce.module.packetMine.description": "Allows you to mine blocks by clicking them once.", - "liquidbounce.module.fastExp.description": "Automatically repairs your armor." + "liquidbounce.module.fastExp.description": "Automatically repairs your armor.", + "liquidbounce.module.baritone.description": "Baritone settings." } From 1f954e91da7e42600016de640d390ee935c130cc Mon Sep 17 00:00:00 2001 From: oneqxz Date: Mon, 16 Dec 2024 20:11:23 +0800 Subject: [PATCH 02/30] AutoWalk: Mode: Smart (Baritone) & refactor --- .../features/module/ModuleManager.kt | 2 +- .../module/modules/client/ModuleBaritone.kt | 3 +- .../module/modules/player/ModuleAutoWalk.kt | 48 +++++++++++++++++-- .../client/{ => baritone}/BaritoneUtil.kt | 2 +- .../client/baritone/goals/GoalDirection.kt | 43 +++++++++++++++++ 5 files changed, 91 insertions(+), 7 deletions(-) rename src/main/kotlin/net/ccbluex/liquidbounce/utils/client/{ => baritone}/BaritoneUtil.kt (93%) create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt index 7fdab8068cf..6bbf2cb3615 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt @@ -78,7 +78,7 @@ import net.ccbluex.liquidbounce.features.module.modules.world.packetmine.ModuleP import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold import net.ccbluex.liquidbounce.features.module.modules.world.traps.ModuleAutoTrap import net.ccbluex.liquidbounce.script.ScriptApiRequired -import net.ccbluex.liquidbounce.utils.client.BaritoneUtil +import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.input.InputBind import net.ccbluex.liquidbounce.utils.kotlin.mapArray diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 15836bab901..cdcacb45812 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -6,10 +6,9 @@ import net.ccbluex.liquidbounce.config.types.Configurable import net.ccbluex.liquidbounce.config.types.Value import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule -import net.ccbluex.liquidbounce.features.module.modules.client.ModuleBaritone.Movement.Parkour import net.ccbluex.liquidbounce.render.engine.toColor import net.ccbluex.liquidbounce.render.engine.toColor4b -import net.ccbluex.liquidbounce.utils.client.BaritoneUtil +import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil import java.awt.Color /** diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt index cce14c2e120..bf2337b8c8b 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt @@ -18,10 +18,18 @@ */ package net.ccbluex.liquidbounce.features.module.modules.player +import baritone.api.pathing.goals.GoalStrictDirection +import net.ccbluex.liquidbounce.config.types.Choice +import net.ccbluex.liquidbounce.config.types.ChoiceConfigurable import net.ccbluex.liquidbounce.event.events.MovementInputEvent +import net.ccbluex.liquidbounce.event.events.NotificationEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule +import net.ccbluex.liquidbounce.lang.translation +import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil +import net.ccbluex.liquidbounce.utils.client.baritone.goals.GoalDirection +import net.ccbluex.liquidbounce.utils.client.notification import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention.FIRST_PRIORITY /** @@ -31,9 +39,43 @@ import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention.FIRST_PRIOR */ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { - @Suppress("unused") - private val moveInputHandler = handler(priority = FIRST_PRIORITY) { event -> - event.directionalInput = event.directionalInput.copy(forwards = true) + private val modes = choices(this, "Mode", Smart, arrayOf(Smart, Simple)) + + private object Smart : Choice("Smart") { + override val parent: ChoiceConfigurable<*> + get() = modes + + override fun enable() { + if(!BaritoneUtil.isAvailable) { + notification( + this.name, + "Baritone is not installed! Install it first.", + NotificationEvent.Severity.ERROR + ) + + ModuleAutoWalk.enabled = false + return + } + + BaritoneUtil.baritone.customGoalProcess.setGoalAndPath(GoalDirection(player.yaw)) + } + + override fun disable() { + if(!BaritoneUtil.isAvailable) { + return + } + + BaritoneUtil.baritone.pathingBehavior.cancelEverything() + } } + private object Simple : Choice("Simple") { + override val parent: ChoiceConfigurable<*> + get() = modes + + @Suppress("unused") + private val moveInputHandler = handler(priority = FIRST_PRIORITY) { event -> + event.directionalInput = event.directionalInput.copy(forwards = true) + } + } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt similarity index 93% rename from src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt rename to src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt index 56ea40a948b..b81fd16509e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/BaritoneUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt @@ -1,4 +1,4 @@ -package net.ccbluex.liquidbounce.utils.client +package net.ccbluex.liquidbounce.utils.client.baritone import baritone.api.BaritoneAPI import baritone.api.process.IBaritoneProcess diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt new file mode 100644 index 00000000000..21738bc057b --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt @@ -0,0 +1,43 @@ +package net.ccbluex.liquidbounce.utils.client.baritone.goals + +import baritone.api.BaritoneAPI +import baritone.api.pathing.goals.Goal +import net.ccbluex.liquidbounce.utils.client.mc +import net.ccbluex.liquidbounce.utils.client.player +import net.ccbluex.liquidbounce.utils.client.world +import net.minecraft.world.tick.TickManager +import java.lang.Math.toRadians +import kotlin.math.* + +private val SQRT_2: Double = sqrt(2.0) + +class GoalDirection ( + private val yaw: Float +) : Goal { + + private val destination: Pair get() { + val theta = toRadians(yaw.toDouble()).toFloat() + val pos = player.pos + + return floor(pos.x - sin(theta) * 100).toInt() to floor(pos.z + cos(theta) * 100).toInt() + } + + fun calculate(xDiff: Int, zDiff: Int): Double { + val x = abs(xDiff) + val z = abs(zDiff) + + val (straight, diagonal) = if (x < z) { + (z - x) to x + } else { + (x - z) to z + } + + return ((diagonal * SQRT_2) + straight) * BaritoneAPI.getSettings().costHeuristic.value + } + + override fun isInGoal(x: Int, y: Int, z: Int): Boolean = + x == this.destination.first && z == this.destination.second + + override fun heuristic(x: Int, y: Int, z: Int): Double = + calculate(x - this.destination.first, z - this.destination.second) +} From c307c256a404c7eb38dcd9ace4031521e569162c Mon Sep 17 00:00:00 2001 From: oneqxz Date: Mon, 16 Dec 2024 20:29:09 +0800 Subject: [PATCH 03/30] detekt'ions fix --- .../features/module/modules/client/ModuleBaritone.kt | 3 ++- .../ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index cdcacb45812..442d5649995 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -101,7 +101,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat with(BaritoneAPI.getSettings()) { createSetting("BlockPlacement", blockPlacementPenalty, maxRangedValue = 300) createSetting("BlockBreakAdditionalPenalty", blockBreakAdditionalPenalty) - createSetting("BreakCorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) + createSetting("BreakCorrectBlockPenaltyMultiplier", + breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) createSetting("PlaceIncorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier) createSetting("WalkOnWaterOnePenalty", walkOnWaterOnePenalty) createSetting("JumpPenalty", jumpPenalty) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt index b81fd16509e..afd2579b7a3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt @@ -12,7 +12,7 @@ object BaritoneUtil { }.getOrDefault(false) val baritone get() = BaritoneAPI.getProvider().primaryBaritone - ?: throw IllegalStateException("Called baritone but it is not available, please make sure to check isBaritoneAvailable") + ?: error("Called baritone but it is not available, please make sure to check isBaritoneAvailable") val isMining get() = mostResentInControl is IMineProcess From 371e6c1be61121538b3cbe77344ec786d688fc0a Mon Sep 17 00:00:00 2001 From: oneqxz Date: Mon, 16 Dec 2024 21:47:39 +0800 Subject: [PATCH 04/30] Refactoring & PathManager for safety baritone api use --- .../module/modules/client/ModuleBaritone.kt | 3 +- .../module/modules/player/ModuleAutoWalk.kt | 15 +- .../utils/client/baritone/PathManager.kt | 129 ++++++++++++++++++ 3 files changed, 134 insertions(+), 13 deletions(-) create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 442d5649995..27cc767a674 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -179,8 +179,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } } -@Suppress("unchecked_cast") -private fun Configurable.createSetting( +private inline fun Configurable.createSetting( name: String, setting: Settings.Setting, minRangedValue: Int = 0, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt index bf2337b8c8b..86585052920 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt @@ -18,7 +18,6 @@ */ package net.ccbluex.liquidbounce.features.module.modules.player -import baritone.api.pathing.goals.GoalStrictDirection import net.ccbluex.liquidbounce.config.types.Choice import net.ccbluex.liquidbounce.config.types.ChoiceConfigurable import net.ccbluex.liquidbounce.event.events.MovementInputEvent @@ -26,9 +25,7 @@ import net.ccbluex.liquidbounce.event.events.NotificationEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule -import net.ccbluex.liquidbounce.lang.translation -import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil -import net.ccbluex.liquidbounce.utils.client.baritone.goals.GoalDirection +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager import net.ccbluex.liquidbounce.utils.client.notification import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention.FIRST_PRIORITY @@ -46,7 +43,7 @@ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { get() = modes override fun enable() { - if(!BaritoneUtil.isAvailable) { + if(!PathManager) { notification( this.name, "Baritone is not installed! Install it first.", @@ -57,15 +54,11 @@ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { return } - BaritoneUtil.baritone.customGoalProcess.setGoalAndPath(GoalDirection(player.yaw)) + PathManager.moveInDirection(player.yaw) } override fun disable() { - if(!BaritoneUtil.isAvailable) { - return - } - - BaritoneUtil.baritone.pathingBehavior.cancelEverything() + PathManager.stop() } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt new file mode 100644 index 00000000000..c67b5109871 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt @@ -0,0 +1,129 @@ +package net.ccbluex.liquidbounce.utils.client.baritone + +import baritone.api.pathing.goals.GoalGetToBlock +import baritone.api.pathing.goals.GoalXZ +import baritone.api.process.IBaritoneProcess +import baritone.api.process.PathingCommand +import baritone.api.process.PathingCommandType +import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil.baritone +import net.ccbluex.liquidbounce.utils.client.baritone.goals.GoalDirection +import net.minecraft.util.math.BlockPos + +/** + * PathManager for baritone use safety. + * + * If [net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil.isAvailable] is true, + * then the PathManager in the singleton will be [BaritonePathManager], otherwise [UnknownPathManager] as a placeholder. + * + * #### Usage tips: + * ``` + * if (!PathManager) { ... } + * ``` + * and + * ``` + * if (!PathManager.isBaritone) { ... } + * ``` + * are exactly the same. + */ +interface PathManager { + val isPathing: Boolean + get() = false + + val isBaritone: Boolean + get() = false + + fun moveTo(pos: BlockPos, ignoreY: Boolean = false) {} + fun moveInDirection(yaw: Float) {} + + fun pause() {} + fun resume() {} + fun stop() {} + + companion object : PathManager { + private val Default by lazy { + if (BaritoneUtil.isAvailable) { + BaritonePathManager + } else { + UnknownPathManager + } + } + + override val isPathing: Boolean + get() = Default.isPathing + + override val isBaritone: Boolean + get() = Default.isBaritone + + override fun moveTo(pos: BlockPos, ignoreY: Boolean) = + Default.moveTo(pos, ignoreY) + + override fun moveInDirection(yaw: Float) = + Default.moveInDirection(yaw) + + override fun pause() = + Default.pause() + + override fun resume() = + Default.resume() + + override fun stop() = + Default.stop() + + operator fun not(): Boolean = !this.isBaritone + } +} + +object UnknownPathManager : PathManager + +object BaritonePathManager : PathManager { + init { + if (BaritoneUtil.isAvailable) { + baritone.pathingControlManager.registerProcess(BaritoneProcess) + } + } + + private var pathingPaused = false + + override val isBaritone = true + + override val isPathing: Boolean + get() = baritone.pathingBehavior.isPathing + + override fun moveTo(pos: BlockPos, ignoreY: Boolean) = if(ignoreY) { + baritone.customGoalProcess.setGoalAndPath(GoalXZ(pos.x, pos.z)) + } else { + baritone.customGoalProcess.setGoalAndPath(GoalGetToBlock(pos)) + } + + override fun moveInDirection(yaw: Float) { + baritone.customGoalProcess.setGoalAndPath(GoalDirection(yaw)) + } + + override fun pause() { + pathingPaused = true + } + + override fun resume() { + pathingPaused = false + } + + override fun stop() { + baritone.pathingBehavior.cancelEverything() + } + + private object BaritoneProcess : IBaritoneProcess { + override fun isActive() = pathingPaused + + override fun onTick(calcFailed: Boolean, isSafeToCancel: Boolean): PathingCommand { + baritone.inputOverrideHandler.clearAllKeys() + return PathingCommand(null, PathingCommandType.REQUEST_PAUSE) + } + + override fun isTemporary() = true + + @Suppress("EmptyFunctionBlock") + override fun onLostControl() {} + + override fun displayName0() = "LiquidBounce" + } +} From 5d33c657a4cf361277d2b59c7e5d69144fe2c354 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Mon, 16 Dec 2024 21:51:53 +0800 Subject: [PATCH 05/30] refactoring --- .../module/modules/client/ModuleBaritone.kt | 23 ++++++++++--------- .../utils/client/baritone/BaritoneUtil.kt | 2 ++ .../utils/client/baritone/PathManager.kt | 15 ++++-------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 27cc767a674..d7db8e5dfb9 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -9,6 +9,7 @@ import net.ccbluex.liquidbounce.features.module.ClientModule import net.ccbluex.liquidbounce.render.engine.toColor import net.ccbluex.liquidbounce.render.engine.toColor4b import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil +import net.ccbluex.liquidbounce.utils.client.baritone.not import java.awt.Color /** @@ -18,7 +19,7 @@ import java.awt.Color */ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivation = true, hide = true) { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Break", allowBreak) createSetting("Place", allowPlace) @@ -36,7 +37,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Mining : Configurable("Mining") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("MinMineYLevel", minYLevelWhileMining, maxRangedValue = 2031) createSetting("MaxMineYLevel", maxYLevelWhileMining, maxRangedValue = 2031) @@ -57,7 +58,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object LegitMine : Configurable("LegitMine") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Allow", legitMine) createSetting("IncludeDiagonals", legitMineIncludeDiagonals) @@ -70,7 +71,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Movement : Configurable("Movement") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Sprint", allowSprint) createSetting("JumpAt256", allowJumpAt256) @@ -84,7 +85,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Parkour : Configurable("Parkour") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Allow", allowParkour) createSetting("Place", allowParkourPlace) @@ -97,7 +98,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Penalties : Configurable("Penalties") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("BlockPlacement", blockPlacementPenalty, maxRangedValue = 300) createSetting("BlockBreakAdditionalPenalty", blockBreakAdditionalPenalty) @@ -113,7 +114,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Elytra : Configurable("Elytra") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("SimulationTicks", elytraSimulationTicks, 1, 100) createSetting("PitchRange", elytraPitchRange, 1, 100) @@ -133,7 +134,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Auto : Configurable("Auto") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("AutoJump", elytraAutoJump) createSetting("Swap", elytraAutoSwap) @@ -144,7 +145,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Firework : Configurable("Firework") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Speed", elytraFireworkSpeed) createSetting("SetbackUseDelay", elytraFireworkSetbackUseDelay) @@ -156,7 +157,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Render : Configurable("Render") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Raytraces", elytraRenderRaytraces) createSetting("HitboxRaytraces", elytraRenderHitboxRaytraces) @@ -169,7 +170,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Items : Configurable("Items") { init { - if (BaritoneUtil.isAvailable) { + if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { createSetting("Inventory", allowInventory) createSetting("AutoTool", autoTool) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt index afd2579b7a3..355054cc8b6 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt @@ -19,5 +19,7 @@ object BaritoneUtil { val isWalking get() = mostResentInControl is ICustomGoalProcess } +operator fun BaritoneUtil.not(): Boolean = !isAvailable + private val mostResentInControl: IBaritoneProcess? get() = BaritoneUtil.baritone.pathingControlManager.mostRecentInControl().orElse(null) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt index c67b5109871..78476c15cd7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt @@ -54,20 +54,15 @@ interface PathManager { override val isBaritone: Boolean get() = Default.isBaritone - override fun moveTo(pos: BlockPos, ignoreY: Boolean) = - Default.moveTo(pos, ignoreY) + override fun moveTo(pos: BlockPos, ignoreY: Boolean) = Default.moveTo(pos, ignoreY) - override fun moveInDirection(yaw: Float) = - Default.moveInDirection(yaw) + override fun moveInDirection(yaw: Float) = Default.moveInDirection(yaw) - override fun pause() = - Default.pause() + override fun pause() = Default.pause() - override fun resume() = - Default.resume() + override fun resume() = Default.resume() - override fun stop() = - Default.stop() + override fun stop() = Default.stop() operator fun not(): Boolean = !this.isBaritone } From f95f7f135a2d960191867676923e57bdca0e5adc Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Mon, 16 Dec 2024 21:53:47 +0800 Subject: [PATCH 06/30] AutoWalk tag --- .../features/module/modules/player/ModuleAutoWalk.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt index 86585052920..cc0c635b1db 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt @@ -36,7 +36,7 @@ import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention.FIRST_PRIOR */ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { - private val modes = choices(this, "Mode", Smart, arrayOf(Smart, Simple)) + private val modes = choices(this, "Mode", Smart, arrayOf(Smart, Simple)).apply { tagBy(this) } private object Smart : Choice("Smart") { override val parent: ChoiceConfigurable<*> From 474d3d8ec43b4bca35ebb09e66df797dd0d3e3eb Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Mon, 16 Dec 2024 21:56:15 +0800 Subject: [PATCH 07/30] mini fix --- .../features/module/modules/client/ModuleBaritone.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index d7db8e5dfb9..47f88261350 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -136,7 +136,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (!BaritoneUtil) { with(BaritoneAPI.getSettings()) { - createSetting("AutoJump", elytraAutoJump) + createSetting("Jump", elytraAutoJump) createSetting("Swap", elytraAutoSwap) } } From 0f99074ecb3516a078d51b68c5f0550e02f89cf8 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 06:53:43 +0800 Subject: [PATCH 08/30] MixinPlayerMovementInput & Freecam no view bob when baritone goal process is active --- .../baritone/MixinPlayerMovementInput.java | 19 ++++++++++ .../mixins/minecraft/client/MixinInput.java | 36 +++++++++++++++++++ .../minecraft/client/MixinKeyboardInput.java | 33 ++--------------- .../minecraft/render/MixinGameRenderer.java | 4 ++- .../module/modules/render/ModuleFreeCam.kt | 1 + .../utils/client/baritone/PathManager.kt | 9 ++--- src/main/resources/liquidbounce.mixins.json | 1 + 7 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java new file mode 100644 index 00000000000..7bb3973a67c --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java @@ -0,0 +1,19 @@ +package net.ccbluex.liquidbounce.injection.mixins.baritone; + +import baritone.utils.PlayerMovementInput; +import net.ccbluex.liquidbounce.injection.mixins.minecraft.client.MixinInput; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(PlayerMovementInput.class) +public class MixinPlayerMovementInput extends MixinInput { + + @Inject(method = "tick", at = @At("HEAD")) + public void hookTick(boolean par1, float par2, CallbackInfo ci) { + // TODO: Fill the DirectionalInput +// this.proceedKeyboardTick(new DirectionalInput(), () -> {}); + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java index b6d62f643ae..1c34eb0ca9d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java @@ -19,11 +19,17 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; +import net.ccbluex.liquidbounce.event.EventManager; +import net.ccbluex.liquidbounce.event.events.MovementInputEvent; +import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSuperKnockback; import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.ModuleCriticals; import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint; +import net.ccbluex.liquidbounce.utils.movement.DirectionalInput; import net.minecraft.client.input.Input; +import net.minecraft.client.input.KeyboardInput; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -59,4 +65,34 @@ private void hookOmnidirectionalSprintA(final CallbackInfoReturnable ca callbackInfoReturnable.setReturnValue(!ModuleSprint.INSTANCE.shouldPreventSprint() && (ModuleSprint.INSTANCE.shouldSprintOmnidirectionally() ? hasMovement : callbackInfoReturnable.getReturnValue())); } + @Unique + public void proceedKeyboardTick(DirectionalInput baseDirectionalInput, boolean jumping, boolean sneaking, Runnable additive) { + var event = new MovementInputEvent(baseDirectionalInput, jumping, sneaking); + + EventManager.INSTANCE.callEvent(event); + + var directionalInput = event.getDirectionalInput(); + + this.pressingForward = directionalInput.getForwards(); + this.pressingBack = directionalInput.getBackwards(); + this.pressingLeft = directionalInput.getLeft(); + this.pressingRight = directionalInput.getRight(); + this.movementForward = KeyboardInput.getMovementMultiplier(directionalInput.getForwards(), directionalInput.getBackwards()); + this.movementSideways = KeyboardInput.getMovementMultiplier(directionalInput.getLeft(), directionalInput.getRight()); + + additive.run(); + + if (ModuleSuperKnockback.INSTANCE.shouldStopMoving()) { + this.movementForward = 0f; + + ModuleSprint sprint = ModuleSprint.INSTANCE; + + if (sprint.shouldSprintOmnidirectionally()) { + this.movementSideways = 0f; + } + } + + this.jumping = event.getJumping(); + this.sneaking = event.getSneaking(); + } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java index 8c06f236c89..f20accf1bd8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java @@ -19,11 +19,8 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; import net.ccbluex.liquidbounce.event.EventManager; -import net.ccbluex.liquidbounce.event.events.MovementInputEvent; import net.ccbluex.liquidbounce.event.events.RotatedMovementInputEvent; -import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSuperKnockback; import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleInventoryMove; -import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint; import net.ccbluex.liquidbounce.utils.aiming.AimPlan; import net.ccbluex.liquidbounce.utils.aiming.Rotation; import net.ccbluex.liquidbounce.utils.aiming.RotationManager; @@ -38,6 +35,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -68,35 +66,10 @@ private void hookInventoryMoveSprint(boolean slowDown, float f, CallbackInfo ci) @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;sneaking:Z", shift = At.Shift.AFTER), allow = 1) private void injectMovementInputEvent(boolean slowDown, float f, CallbackInfo ci) { - var event = new MovementInputEvent(new DirectionalInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight), this.jumping, this.sneaking); - - EventManager.INSTANCE.callEvent(event); - - var directionalInput = event.getDirectionalInput(); - - this.pressingForward = directionalInput.getForwards(); - this.pressingBack = directionalInput.getBackwards(); - this.pressingLeft = directionalInput.getLeft(); - this.pressingRight = directionalInput.getRight(); - this.movementForward = KeyboardInput.getMovementMultiplier(directionalInput.getForwards(), directionalInput.getBackwards()); - this.movementSideways = KeyboardInput.getMovementMultiplier(directionalInput.getLeft(), directionalInput.getRight()); - - this.fixStrafeMovement(); - - if (ModuleSuperKnockback.INSTANCE.shouldStopMoving()) { - this.movementForward = 0f; - - ModuleSprint sprint = ModuleSprint.INSTANCE; - - if (sprint.shouldSprintOmnidirectionally()) { - this.movementSideways = 0f; - } - } - - this.jumping = event.getJumping(); - this.sneaking = event.getSneaking(); + this.proceedKeyboardTick(new DirectionalInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight), this.jumping, this.sneaking, this::fixStrafeMovement); } + @Unique private void fixStrafeMovement() { ClientPlayerEntity player = MinecraftClient.getInstance().player; RotationManager rotationManager = RotationManager.INSTANCE; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java index 04e93ab8bf5..a8a12ab244f 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java @@ -36,6 +36,7 @@ import net.ccbluex.liquidbounce.utils.aiming.RaytracingExtensionsKt; import net.ccbluex.liquidbounce.utils.aiming.Rotation; import net.ccbluex.liquidbounce.utils.aiming.RotationManager; +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gl.PostEffectProcessor; import net.minecraft.client.gui.DrawContext; @@ -164,7 +165,8 @@ private void injectHurtCam(MatrixStack matrixStack, float f, CallbackInfo callba @Inject(method = "bobView", at = @At("HEAD"), cancellable = true) private void injectBobView(MatrixStack matrixStack, float f, CallbackInfo callbackInfo) { - if (ModuleNoBob.INSTANCE.getRunning() || ModuleTracers.INSTANCE.getRunning()) { + if ((ModuleNoBob.INSTANCE.getRunning() || ModuleTracers.INSTANCE.getRunning()) + || (ModuleFreeCam.INSTANCE.getRunning() && PathManager.Companion.isPathing())) { callbackInfo.cancel(); return; } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt index 4dbc69005f6..9b9236080c4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt @@ -89,6 +89,7 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = super.disable() } + @Suppress("unused") val inputHandler = handler { event -> val speed = this.speed.toDouble() val yAxisMovement = when { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt index 78476c15cd7..c82ca0f48f3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt @@ -48,11 +48,9 @@ interface PathManager { } } - override val isPathing: Boolean - get() = Default.isPathing + override val isPathing get() = Default.isPathing - override val isBaritone: Boolean - get() = Default.isBaritone + override val isBaritone get() = Default.isBaritone override fun moveTo(pos: BlockPos, ignoreY: Boolean) = Default.moveTo(pos, ignoreY) @@ -81,8 +79,7 @@ object BaritonePathManager : PathManager { override val isBaritone = true - override val isPathing: Boolean - get() = baritone.pathingBehavior.isPathing + override val isPathing get() = baritone.pathingBehavior.isPathing override fun moveTo(pos: BlockPos, ignoreY: Boolean) = if(ignoreY) { baritone.customGoalProcess.setGoalAndPath(GoalXZ(pos.x, pos.z)) diff --git a/src/main/resources/liquidbounce.mixins.json b/src/main/resources/liquidbounce.mixins.json index cc94b011e8e..95b9829bf83 100644 --- a/src/main/resources/liquidbounce.mixins.json +++ b/src/main/resources/liquidbounce.mixins.json @@ -7,6 +7,7 @@ "mixinPriority": 1337, "client": [ "authlib.MixinMinecraftClient", + "baritone.MixinPlayerMovementInput", "minecraft.block.MixinBlock", "minecraft.block.MixinBlockCollisionSpliterator", "minecraft.block.MixinBlockView", From 337dd4b5a65d32f437c05a6c4e3dd18a4f41211b Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 07:22:13 +0800 Subject: [PATCH 09/30] fix(freecam) movement while baritone goal --- .../baritone/MixinPlayerMovementInput.java | 12 +++++-- .../mixins/minecraft/client/MixinInput.java | 36 ++++++++++--------- .../minecraft/client/MixinKeyboardInput.java | 2 +- .../utils/entity/EntityExtensions.kt | 10 ++++-- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java index 7bb3973a67c..cb46da836cc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java @@ -2,6 +2,8 @@ import baritone.utils.PlayerMovementInput; import net.ccbluex.liquidbounce.injection.mixins.minecraft.client.MixinInput; +import net.ccbluex.liquidbounce.utils.movement.DirectionalInput; +import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +14,14 @@ public class MixinPlayerMovementInput extends MixinInput { @Inject(method = "tick", at = @At("HEAD")) public void hookTick(boolean par1, float par2, CallbackInfo ci) { - // TODO: Fill the DirectionalInput -// this.proceedKeyboardTick(new DirectionalInput(), () -> {}); + var options = MinecraftClient.getInstance().options; + + this.proceedKeyboardTick(new DirectionalInput( + options.forwardKey.isPressed(), + options.backKey.isPressed(), + options.leftKey.isPressed(), + options.rightKey.isPressed() + ), options.jumpKey.isPressed(), options.sneakKey.isPressed(), false, () -> {}); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java index 1c34eb0ca9d..8203a751a8a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java @@ -66,33 +66,35 @@ private void hookOmnidirectionalSprintA(final CallbackInfoReturnable ca } @Unique - public void proceedKeyboardTick(DirectionalInput baseDirectionalInput, boolean jumping, boolean sneaking, Runnable additive) { + public void proceedKeyboardTick(DirectionalInput baseDirectionalInput, boolean jumping, boolean sneaking, boolean update, Runnable additive) { var event = new MovementInputEvent(baseDirectionalInput, jumping, sneaking); EventManager.INSTANCE.callEvent(event); - var directionalInput = event.getDirectionalInput(); + if (update) { + var directionalInput = event.getDirectionalInput(); - this.pressingForward = directionalInput.getForwards(); - this.pressingBack = directionalInput.getBackwards(); - this.pressingLeft = directionalInput.getLeft(); - this.pressingRight = directionalInput.getRight(); - this.movementForward = KeyboardInput.getMovementMultiplier(directionalInput.getForwards(), directionalInput.getBackwards()); - this.movementSideways = KeyboardInput.getMovementMultiplier(directionalInput.getLeft(), directionalInput.getRight()); + this.pressingForward = directionalInput.getForwards(); + this.pressingBack = directionalInput.getBackwards(); + this.pressingLeft = directionalInput.getLeft(); + this.pressingRight = directionalInput.getRight(); + this.movementForward = KeyboardInput.getMovementMultiplier(directionalInput.getForwards(), directionalInput.getBackwards()); + this.movementSideways = KeyboardInput.getMovementMultiplier(directionalInput.getLeft(), directionalInput.getRight()); - additive.run(); + additive.run(); - if (ModuleSuperKnockback.INSTANCE.shouldStopMoving()) { - this.movementForward = 0f; + if (ModuleSuperKnockback.INSTANCE.shouldStopMoving()) { + this.movementForward = 0f; - ModuleSprint sprint = ModuleSprint.INSTANCE; + ModuleSprint sprint = ModuleSprint.INSTANCE; - if (sprint.shouldSprintOmnidirectionally()) { - this.movementSideways = 0f; + if (sprint.shouldSprintOmnidirectionally()) { + this.movementSideways = 0f; + } } - } - this.jumping = event.getJumping(); - this.sneaking = event.getSneaking(); + this.jumping = event.getJumping(); + this.sneaking = event.getSneaking(); + } } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java index f20accf1bd8..736ff725b82 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java @@ -66,7 +66,7 @@ private void hookInventoryMoveSprint(boolean slowDown, float f, CallbackInfo ci) @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;sneaking:Z", shift = At.Shift.AFTER), allow = 1) private void injectMovementInputEvent(boolean slowDown, float f, CallbackInfo ci) { - this.proceedKeyboardTick(new DirectionalInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight), this.jumping, this.sneaking, this::fixStrafeMovement); + this.proceedKeyboardTick(new DirectionalInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight), this.jumping, this.sneaking, true, this::fixStrafeMovement); } @Unique diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt index 0160ff9c58e..4d75998afc9 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt @@ -23,6 +23,7 @@ import net.ccbluex.liquidbounce.utils.aiming.Rotation import net.ccbluex.liquidbounce.utils.block.DIRECTIONS_EXCLUDING_UP import net.ccbluex.liquidbounce.utils.block.isBlastResistant import net.ccbluex.liquidbounce.utils.block.raycast +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.client.network import net.ccbluex.liquidbounce.utils.client.player @@ -116,8 +117,13 @@ fun ClientPlayerEntity.isCloseToEdge( return wouldBeCloseToFallOff(pos) || wouldBeCloseToFallOff(playerPosInTwoTicks) } -val ClientPlayerEntity.pressingMovementButton - get() = input.pressingForward || input.pressingBack || input.pressingLeft || input.pressingRight +val ClientPlayerEntity.pressingMovementButton get() = if(PathManager.isPathing) { + with(mc.options) { + forwardKey.isPressed || backKey.isPressed || leftKey.isPressed || rightKey.isPressed + } + } else { + input.pressingForward || input.pressingBack || input.pressingLeft || input.pressingRight + } val Entity.exactPosition get() = Vec3d(x, y, z) From 9585b2a0c6a285dffbc4d600a557052d34a27711 Mon Sep 17 00:00:00 2001 From: sqlerrorthing <148702857+sqlerrorthing@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:50:48 +0800 Subject: [PATCH 10/30] remove semicolon --- .../injection/mixins/baritone/MixinPlayerMovementInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java index cb46da836cc..e155d84e5f3 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java @@ -14,7 +14,7 @@ public class MixinPlayerMovementInput extends MixinInput { @Inject(method = "tick", at = @At("HEAD")) public void hookTick(boolean par1, float par2, CallbackInfo ci) { - var options = MinecraftClient.getInstance().options; + var options = MinecraftClient.getInstance().options this.proceedKeyboardTick(new DirectionalInput( options.forwardKey.isPressed(), From c4756d8e38ee3030fa4d1d051a26efcc3faca907 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 15:02:50 +0800 Subject: [PATCH 11/30] custom baritone behavior process & rotation fixes --- .../mixins/baritone/MixinBaritone.java | 38 +++++++++ .../features/module/ClientModule.kt | 2 +- .../module/modules/client/ModuleBaritone.kt | 27 ++++--- .../module/modules/render/ModuleFreeCam.kt | 9 ++- .../liquidbounce/utils/aiming/RotationData.kt | 8 ++ .../utils/client/baritone/BaritoneUtil.kt | 2 - .../utils/client/baritone/PathManager.kt | 57 +++++++++++++ .../behaviors/LiquidBounceLookBehavior.kt | 81 +++++++++++++++++++ src/main/resources/liquidbounce.mixins.json | 1 + 9 files changed, 206 insertions(+), 19 deletions(-) create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java create mode 100644 src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java new file mode 100644 index 00000000000..fdd6838414f --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java @@ -0,0 +1,38 @@ +package net.ccbluex.liquidbounce.injection.mixins.baritone; + +import baritone.Baritone; +import baritone.api.IBaritone; +import baritone.api.behavior.ILookBehavior; +import baritone.api.event.listener.IEventBus; +import net.ccbluex.liquidbounce.utils.client.baritone.behaviors.LiquidBounceLookBehavior; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * @author 00101110001100010111000101111 + * @since 12/17/2024 + **/ +@Mixin(Baritone.class) +public abstract class MixinBaritone implements IBaritone { + + @Shadow + public abstract IEventBus getGameEventHandler(); + + @Unique + private LiquidBounceLookBehavior lookBehavior; + + @Inject(method = "getLookBehavior", at = @At("HEAD"), cancellable = true, remap = false) + public void hookLookBehavior(CallbackInfoReturnable cir) { + if(lookBehavior == null) { + lookBehavior = new LiquidBounceLookBehavior(); + getGameEventHandler().registerEventListener(lookBehavior); + } + + cir.setReturnValue(lookBehavior); + } + +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ClientModule.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ClientModule.kt index 92536dcd8c2..dd6af621f54 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ClientModule.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ClientModule.kt @@ -132,7 +132,7 @@ open class ClientModule( * If the module is running and in game. Can be overridden to add additional checks. */ override val running: Boolean - get() = super.running && inGame && enabled + get() = (super.running && inGame && enabled) || disableActivation val bind by bind("Bind", InputBind(InputUtil.Type.KEYSYM, bind, bindAction)) .doNotIncludeWhen { !AutoConfig.includeConfiguration.includeBinds } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 47f88261350..8a0467ab46f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -8,8 +8,8 @@ import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule import net.ccbluex.liquidbounce.render.engine.toColor import net.ccbluex.liquidbounce.render.engine.toColor4b +import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable import net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil -import net.ccbluex.liquidbounce.utils.client.baritone.not import java.awt.Color /** @@ -19,13 +19,14 @@ import java.awt.Color */ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivation = true, hide = true) { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Break", allowBreak) createSetting("Place", allowPlace) } treeAll( + Rotations, Movement, Penalties, Mining, @@ -35,9 +36,11 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } } + object Rotations : RotationsConfigurable(this) + private object Mining : Configurable("Mining") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("MinMineYLevel", minYLevelWhileMining, maxRangedValue = 2031) createSetting("MaxMineYLevel", maxYLevelWhileMining, maxRangedValue = 2031) @@ -58,7 +61,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object LegitMine : Configurable("LegitMine") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Allow", legitMine) createSetting("IncludeDiagonals", legitMineIncludeDiagonals) @@ -71,7 +74,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Movement : Configurable("Movement") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Sprint", allowSprint) createSetting("JumpAt256", allowJumpAt256) @@ -85,7 +88,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Parkour : Configurable("Parkour") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Allow", allowParkour) createSetting("Place", allowParkourPlace) @@ -98,7 +101,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Penalties : Configurable("Penalties") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("BlockPlacement", blockPlacementPenalty, maxRangedValue = 300) createSetting("BlockBreakAdditionalPenalty", blockBreakAdditionalPenalty) @@ -114,7 +117,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Elytra : Configurable("Elytra") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("SimulationTicks", elytraSimulationTicks, 1, 100) createSetting("PitchRange", elytraPitchRange, 1, 100) @@ -134,7 +137,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Auto : Configurable("Auto") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Jump", elytraAutoJump) createSetting("Swap", elytraAutoSwap) @@ -145,7 +148,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Firework : Configurable("Firework") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Speed", elytraFireworkSpeed) createSetting("SetbackUseDelay", elytraFireworkSetbackUseDelay) @@ -157,7 +160,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Render : Configurable("Render") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Raytraces", elytraRenderRaytraces) createSetting("HitboxRaytraces", elytraRenderHitboxRaytraces) @@ -170,7 +173,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat private object Items : Configurable("Items") { init { - if (!BaritoneUtil) { + if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Inventory", allowInventory) createSetting("AutoTool", autoTool) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt index 9b9236080c4..e3925b0ea8e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.event.events.MovementInputEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager import net.ccbluex.liquidbounce.utils.entity.eyes import net.ccbluex.liquidbounce.utils.entity.getMovementDirectionOfInput import net.ccbluex.liquidbounce.utils.entity.strafe @@ -80,7 +81,7 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = pos = null // Reset player rotation - if (!allowRotationChange) { + if (!allowRotationChange && !PathManager.isPathing) { val rotation = ModuleRotations.displayRotations() player.yaw = rotation.yaw @@ -131,16 +132,16 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = * Modify the raycast position */ fun modifyRaycast(original: Vec3d, entity: Entity, tickDelta: Float): Vec3d { - if (!running || entity != mc.player || !allowCameraInteract) { + if (!running || entity != mc.player || (!allowCameraInteract && !PathManager.isPathing)) { return original } return pos?.interpolate(tickDelta) ?: original } - fun shouldDisableCrosshair() = running && !allowCameraInteract + fun shouldDisableCrosshair() = running && (!allowCameraInteract && !PathManager.isPathing) - fun shouldDisableRotations() = running && !allowRotationChange + fun shouldDisableRotations() = running && (!allowRotationChange && !PathManager.isPathing) private fun updatePosition(velocity: Vec3d) { pos = (pos ?: PositionPair(player.eyes, player.eyes)).apply { this += velocity } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt index 39d3e3100c7..6b67ee1dc39 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt @@ -24,6 +24,8 @@ import net.minecraft.util.math.MathHelper import net.minecraft.util.math.Vec3d import kotlin.math.roundToInt +import baritone.api.utils.Rotation as BRotation + data class Rotation( var yaw: Float, var pitch: Float, @@ -75,3 +77,9 @@ data class Rotation( } data class VecRotation(val rotation: Rotation, val vec: Vec3d) + +fun Rotation.toBaritoneRotation() = + BRotation(yaw, pitch) + +fun BRotation.toClientRotation() = + Rotation(yaw, pitch) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt index 355054cc8b6..afd2579b7a3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/BaritoneUtil.kt @@ -19,7 +19,5 @@ object BaritoneUtil { val isWalking get() = mostResentInControl is ICustomGoalProcess } -operator fun BaritoneUtil.not(): Boolean = !isAvailable - private val mostResentInControl: IBaritoneProcess? get() = BaritoneUtil.baritone.pathingControlManager.mostRecentInControl().orElse(null) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt index c82ca0f48f3..3931f536086 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt @@ -15,6 +15,11 @@ import net.minecraft.util.math.BlockPos * If [net.ccbluex.liquidbounce.utils.client.baritone.BaritoneUtil.isAvailable] is true, * then the PathManager in the singleton will be [BaritonePathManager], otherwise [UnknownPathManager] as a placeholder. * + * #### Keep in mind! + * You can use any method from this interface UNLESS it causes + * the game to crash due to a missing baritone. + * Be vigilant, and if you need a strict check for a Baritone, use [PathManager.isBaritone]. + * * #### Usage tips: * ``` * if (!PathManager) { ... } @@ -24,19 +29,71 @@ import net.minecraft.util.math.BlockPos * if (!PathManager.isBaritone) { ... } * ``` * are exactly the same. + * - This interface supports basic pathing operations such as moving to a specific position, pausing, resuming, + * and stopping an active path. */ interface PathManager { + /** + * Indicates whether the system is currently executing a pathfinding operation. + * + * By default, returns `false` as no pathing operation is active unless overridden by an implementation. + * + * @return `true` if there is an active pathing operation, `false` otherwise. + */ val isPathing: Boolean get() = false + /** + * Indicates whether the current implementation of the PathManager is [BaritonePathManager] + * + * This is useful to determine if advanced pathfinding features (provided by Baritone) are available. + * By default, this is `false` unless overridden by an implementation that integrates with Baritone. + * + * @return `true` if Baritone is being used, `false` otherwise. + */ val isBaritone: Boolean get() = false + /** + * Initiates movement to a specified position in the world. + * + * The movement can optionally ignore the Y-coordinate (elevation) if `ignoreY` is set to `true`. + * This is useful for scenarios where only horizontal movement is desired. + * + * @param pos The target position [BlockPos] to move to. + * @param ignoreY A flag indicating whether to ignore the Y-coordinate during movement. Defaults to `false`. + */ fun moveTo(pos: BlockPos, ignoreY: Boolean = false) {} + + /** + * Initiates movement in a specific direction based on the provided yaw angle. + * + * @param yaw The yaw angle (in degrees) representing the direction to move in. `-180 <= yaw <= 180` + */ fun moveInDirection(yaw: Float) {} + /** + * Pauses the currently active pathing operation, if any. + * + * This temporarily halts movement without completely stopping the path. Useful for scenarios where + * movement needs to be suspended but may be resumed later. + */ fun pause() {} + + /** + * Resumes a previously paused pathing operation, if any. + * + * This continues movement along the path that was paused. If there is no paused path, this method + * has no effect. + */ fun resume() {} + + /** + * Stops the currently active pathing operation and clears the path. + * + * This completely halts movement and discards any active or paused paths. This is useful when the + * current pathing task is no longer needed. + */ fun stop() {} companion object : PathManager { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt new file mode 100644 index 00000000000..8a305aadeeb --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt @@ -0,0 +1,81 @@ +package net.ccbluex.liquidbounce.utils.client.baritone.behaviors + +import baritone.api.behavior.ILookBehavior +import baritone.api.behavior.look.IAimProcessor +import baritone.api.behavior.look.ITickableAimProcessor +import baritone.api.event.events.PlayerUpdateEvent +import baritone.api.event.events.WorldEvent +import baritone.api.event.events.type.EventState +import net.ccbluex.liquidbounce.features.module.modules.client.ModuleBaritone +import net.ccbluex.liquidbounce.utils.aiming.* +import net.ccbluex.liquidbounce.utils.kotlin.Priority +import baritone.api.utils.Rotation as BRotation + + +/** + * @author 00101110001100010111000101111 + * @since 12/17/2024 + **/ +class LiquidBounceLookBehavior : ILookBehavior { + + /** + * The current look target, may be `null`. + */ + private var target: Rotation? = null + private val processor: CustomBaritoneAimProcessor = CustomBaritoneAimProcessor() + + override fun updateTarget(rotation: BRotation, blockInteract: Boolean) { + target = rotation.toClientRotation() + } + + override fun getAimProcessor(): IAimProcessor = processor + + override fun onWorldEvent(event: WorldEvent?) { + target = null + } + + override fun onPlayerUpdate(event: PlayerUpdateEvent) { + if (target == null) { + return + } + + when (event.state) { + EventState.PRE -> { + if (target != null) { + processor.nextRotation(target!!.toBaritoneRotation()) + } + } + EventState.POST -> { + target = null + } + else -> {} + } + } +} + +private class CustomBaritoneAimProcessor : ITickableAimProcessor { + override fun peekRotation(desired: BRotation): BRotation { + return RotationManager.currentRotation?.toBaritoneRotation() ?: desired + } + + override fun fork(): ITickableAimProcessor { + return CustomBaritoneAimProcessor() + } + + @Suppress("EmptyFunctionBlock") + override fun tick() {} + + @Suppress("EmptyFunctionBlock") + override fun advance(ticks: Int) {} + + override fun nextRotation(rotation: BRotation): BRotation { + RotationManager.aimAt( + ModuleBaritone.Rotations.toAimPlan(rotation.toClientRotation()), + Priority.IMPORTANT_FOR_USAGE_3, + ModuleBaritone + ) + + return peekRotation(rotation) + } + +} diff --git a/src/main/resources/liquidbounce.mixins.json b/src/main/resources/liquidbounce.mixins.json index 95b9829bf83..fa4889acfdc 100644 --- a/src/main/resources/liquidbounce.mixins.json +++ b/src/main/resources/liquidbounce.mixins.json @@ -7,6 +7,7 @@ "mixinPriority": 1337, "client": [ "authlib.MixinMinecraftClient", + "baritone.MixinBaritone", "baritone.MixinPlayerMovementInput", "minecraft.block.MixinBlock", "minecraft.block.MixinBlockCollisionSpliterator", From e1adb814bc95d496ca3ba73a890bcb0f387ad9e3 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 15:09:05 +0800 Subject: [PATCH 12/30] add semicolon OOPS --- .../injection/mixins/baritone/MixinPlayerMovementInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java index e155d84e5f3..16256dad286 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPlayerMovementInput.java @@ -14,7 +14,7 @@ public class MixinPlayerMovementInput extends MixinInput { @Inject(method = "tick", at = @At("HEAD")) public void hookTick(boolean par1, float par2, CallbackInfo ci) { - var options = MinecraftClient.getInstance().options + var options = MinecraftClient.getInstance().options; this.proceedKeyboardTick(new DirectionalInput( options.forwardKey.isPressed(), From 2a87252b5f466029a1eee65e1c0efcceb3a843e5 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 15:33:29 +0800 Subject: [PATCH 13/30] remove useless check --- .../client/baritone/behaviors/LiquidBounceLookBehavior.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt index 8a305aadeeb..11b3735ed31 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/behaviors/LiquidBounceLookBehavior.kt @@ -41,9 +41,7 @@ class LiquidBounceLookBehavior : ILookBehavior { when (event.state) { EventState.PRE -> { - if (target != null) { - processor.nextRotation(target!!.toBaritoneRotation()) - } + processor.nextRotation(target!!.toBaritoneRotation()) } EventState.POST -> { target = null From 04f7e01e88b16c9bfa1230d4dce7a3accdcb9fce Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 18:01:22 +0800 Subject: [PATCH 14/30] Baritone path control events & KillAura: Pause baritone (when target != null) & auto walk disables when path is canceled --- .../baritone/MixinCustomGoalProcess.java | 27 +++++++++++++++++++ .../mixins/baritone/MixinPathingBehavior.java | 23 ++++++++++++++++ .../liquidbounce/event/EventManager.kt | 4 ++- .../liquidbounce/event/events/GameEvents.kt | 7 +++++ .../modules/combat/killaura/ModuleKillAura.kt | 21 ++++++++++----- .../module/modules/player/ModuleAutoWalk.kt | 10 ++++++- .../utils/client/baritone/PathManager.kt | 14 ++++++++++ .../utils/combat/TargetTracker.kt | 21 ++++++++++----- src/main/resources/liquidbounce.mixins.json | 2 ++ 9 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java new file mode 100644 index 00000000000..593ad8dbb89 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java @@ -0,0 +1,27 @@ +package net.ccbluex.liquidbounce.injection.mixins.baritone; + +import baritone.api.pathing.goals.Goal; +import baritone.process.CustomGoalProcess; +import net.ccbluex.liquidbounce.event.EventManager; +import net.ccbluex.liquidbounce.event.events.BaritoneCustomGoalProcessCreatedEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** + * @author 00101110001100010111000101111 + * @since 12/17/2024 + **/ +@Mixin(CustomGoalProcess.class) +public class MixinCustomGoalProcess { + + @Inject(method = "setGoal", at = @At("HEAD"), cancellable = true, remap = false) + public void hookSetGoal(Goal goal, CallbackInfo ci) { + var event = new BaritoneCustomGoalProcessCreatedEvent(goal); + EventManager.INSTANCE.callEvent(event); + + if(event.isCancelled()) ci.cancel(); + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java new file mode 100644 index 00000000000..1ae71e3fc23 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java @@ -0,0 +1,23 @@ +package net.ccbluex.liquidbounce.injection.mixins.baritone; + +import baritone.behavior.PathingBehavior; +import net.ccbluex.liquidbounce.event.EventManager; +import net.ccbluex.liquidbounce.event.events.BaritonePathCancelEverythingEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * @author 00101110001100010111000101111 + * @since 12/17/2024 + **/ +@Mixin(PathingBehavior.class) +public class MixinPathingBehavior { + + @Inject(method = "cancelEverything", at = @At("TAIL"), remap = false) + public void hookCancelEverything(CallbackInfoReturnable cir) { + EventManager.INSTANCE.callEvent(new BaritonePathCancelEverythingEvent()); + } + +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt index c2c3df8bf39..9ecd11b37f0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt @@ -133,7 +133,9 @@ val ALL_EVENT_CLASSES: Array> = arrayOf( PlayerEquipmentChangeEvent::class, ClickGuiValueChangeEvent::class, BlockAttackEvent::class, - QueuePacketEvent::class + QueuePacketEvent::class, + BaritoneCustomGoalProcessCreatedEvent::class, + BaritonePathCancelEverythingEvent::class ) /** diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt index 6f19bcf721f..f972f73fb8b 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.event.events +import baritone.api.pathing.goals.Goal import net.ccbluex.liquidbounce.event.CancellableEvent import net.ccbluex.liquidbounce.event.Event import net.ccbluex.liquidbounce.integration.interop.protocol.event.WebSocketEvent @@ -71,6 +72,12 @@ class CancelBlockBreakingEvent : CancellableEvent() * All events which are related to the minecraft client */ +@Nameable("baritonePathCancelEverythingEvent") +class BaritonePathCancelEverythingEvent : Event() + +@Nameable("baritoneCustomGoalProcessCreated") +class BaritoneCustomGoalProcessCreatedEvent(val goal: Goal) : CancellableEvent() + @Nameable("session") @WebSocketEvent class SessionEvent(val session: Session) : Event() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt index a96da506a27..fe7af41cbd7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt @@ -45,6 +45,7 @@ import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug import net.ccbluex.liquidbounce.render.engine.Color4b import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld import net.ccbluex.liquidbounce.utils.aiming.* +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager import net.ccbluex.liquidbounce.utils.combat.* import net.ccbluex.liquidbounce.utils.entity.boxedDistanceTo import net.ccbluex.liquidbounce.utils.entity.isBlockAction @@ -117,6 +118,14 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { internal val ignoreOpenInventory by boolean("IgnoreOpenInventory", true) internal val simulateInventoryClosing by boolean("SimulateInventoryClosing", true) + private val pauseBaritone by boolean("PauseBaritone", true).onChanged { + if(it && targetTracker.lockedOnTarget != null && PathManager.isPathing) { + PathManager.pause() + } else if (!it && targetTracker.lockedOnTarget != null) { + PathManager.resume() + } + } + init { tree(KillAuraAutoBlock) } @@ -130,7 +139,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { } override fun disable() { - targetTracker.cleanup() + targetTracker.cleanup(unpauseBaritone = pauseBaritone) failedHits.clear() KillAuraAutoBlock.stopBlocking() KillAuraNotifyWhenFail.failedHitsIncrement = 0 @@ -165,7 +174,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { if (isInInventoryScreen && !ignoreOpenInventory || shouldCleanUpTracker) { // Cleanup current target tracker - targetTracker.cleanup() + targetTracker.cleanup(unpauseBaritone = pauseBaritone) return@handler } @@ -231,7 +240,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { // Swap enemy if there is a better enemy (closer to the player crosshair) if (chosenEntity is LivingEntity && chosenEntity.shouldBeAttacked() && chosenEntity != target) { - targetTracker.lock(chosenEntity) + targetTracker.lock(chosenEntity, pauseBaritone = pauseBaritone) } } else { chosenEntity = target @@ -325,7 +334,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { * Update enemy on target tracker */ private fun updateEnemySelection() { - targetTracker.validateLock { it.shouldBeAttacked() && it.boxedDistanceTo(player) <= range } + targetTracker.validateLock(pauseBaritone) { it.shouldBeAttacked() && it.boxedDistanceTo(player) <= range } // Update target tracker, since we want to access // the maximumDistance in the next step @@ -359,7 +368,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { val spot = getSpot(target, range.toDouble(), situation) ?: continue // lock on target tracker - targetTracker.lock(target) + targetTracker.lock(target, pauseBaritone = pauseBaritone) // aim at target val ticks = rotations.howLongToReach(spot.rotation) @@ -397,7 +406,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { priority = Priority.IMPORTANT_FOR_USAGE_2, provider = this@ModuleKillAura ) - targetTracker.lock(targetByPriority) + targetTracker.lock(targetByPriority, pauseBaritone = pauseBaritone) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt index cc0c635b1db..42d7d6efedc 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.features.module.modules.player import net.ccbluex.liquidbounce.config.types.Choice import net.ccbluex.liquidbounce.config.types.ChoiceConfigurable +import net.ccbluex.liquidbounce.event.events.BaritonePathCancelEverythingEvent import net.ccbluex.liquidbounce.event.events.MovementInputEvent import net.ccbluex.liquidbounce.event.events.NotificationEvent import net.ccbluex.liquidbounce.event.handler @@ -57,8 +58,15 @@ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { PathManager.moveInDirection(player.yaw) } + @Suppress("unused") + private val cancelHandler = handler { _ -> + ModuleAutoWalk.enabled = false + } + override fun disable() { - PathManager.stop() + if(PathManager.hasPath) { + PathManager.stop() + } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt index 3931f536086..acb65eed23c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/PathManager.kt @@ -39,10 +39,20 @@ interface PathManager { * By default, returns `false` as no pathing operation is active unless overridden by an implementation. * * @return `true` if there is an active pathing operation, `false` otherwise. + * This will be false if there's currently a pause. */ val isPathing: Boolean get() = false + /** + * If there is a current path. Note that the path is not necessarily being executed, + * for example when there is a pause in effect. + * + * @return `true` if there is an active pathing operation, `false` otherwise. + */ + val hasPath: Boolean + get() = false + /** * Indicates whether the current implementation of the PathManager is [BaritonePathManager] * @@ -107,6 +117,8 @@ interface PathManager { override val isPathing get() = Default.isPathing + override val hasPath: Boolean get() = Default.hasPath + override val isBaritone get() = Default.isBaritone override fun moveTo(pos: BlockPos, ignoreY: Boolean) = Default.moveTo(pos, ignoreY) @@ -138,6 +150,8 @@ object BaritonePathManager : PathManager { override val isPathing get() = baritone.pathingBehavior.isPathing + override val hasPath get() = baritone.pathingBehavior.hasPath() + override fun moveTo(pos: BlockPos, ignoreY: Boolean) = if(ignoreY) { baritone.customGoalProcess.setGoalAndPath(GoalXZ(pos.x, pos.z)) } else { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/TargetTracker.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/TargetTracker.kt index e66e6b5c717..ff04d73fe43 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/TargetTracker.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/TargetTracker.kt @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.event.EventManager import net.ccbluex.liquidbounce.event.events.TargetChangeEvent import net.ccbluex.liquidbounce.integration.interop.protocol.rest.v1.game.PlayerData import net.ccbluex.liquidbounce.utils.aiming.RotationManager +import net.ccbluex.liquidbounce.utils.client.baritone.PathManager import net.ccbluex.liquidbounce.utils.client.player import net.ccbluex.liquidbounce.utils.client.world import net.ccbluex.liquidbounce.utils.entity.boxedDistanceTo @@ -104,27 +105,35 @@ open class TargetTracker( return entities } - fun cleanup() { - unlock() + fun cleanup(unpauseBaritone: Boolean = false) { + unlock(unpauseBaritone = unpauseBaritone) } - fun lock(entity: LivingEntity, reportToUI: Boolean = true) { + fun lock(entity: LivingEntity, reportToUI: Boolean = true, pauseBaritone: Boolean = false) { lockedOnTarget = entity + if (pauseBaritone && PathManager.isPathing) { + PathManager.pause() + } + if (entity is PlayerEntity && reportToUI) { EventManager.callEvent(TargetChangeEvent(PlayerData.fromPlayer(entity))) } } - private fun unlock() { + private fun unlock(unpauseBaritone: Boolean = false) { lockedOnTarget = null + + if (unpauseBaritone && PathManager.hasPath) { + PathManager.resume() + } } - fun validateLock(validator: (Entity) -> Boolean) { + fun validateLock(unpauseBaritone: Boolean = false, validator: (Entity) -> Boolean) { val lockedOnTarget = lockedOnTarget ?: return if (!validate(lockedOnTarget) || !validator(lockedOnTarget)) { - this.lockedOnTarget = null + unlock(unpauseBaritone) } } diff --git a/src/main/resources/liquidbounce.mixins.json b/src/main/resources/liquidbounce.mixins.json index fa4889acfdc..e2404195a5c 100644 --- a/src/main/resources/liquidbounce.mixins.json +++ b/src/main/resources/liquidbounce.mixins.json @@ -8,6 +8,8 @@ "client": [ "authlib.MixinMinecraftClient", "baritone.MixinBaritone", + "baritone.MixinCustomGoalProcess", + "baritone.MixinPathingBehavior", "baritone.MixinPlayerMovementInput", "minecraft.block.MixinBlock", "minecraft.block.MixinBlockCollisionSpliterator", From 237911a29cf472ba5b311946120c45aaf7113a94 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:25:08 +0800 Subject: [PATCH 15/30] more settings --- .../module/modules/client/ModuleBaritone.kt | 129 +++++++++++++++++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 8a0467ab46f..51b8ac56cb4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -28,16 +28,117 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat treeAll( Rotations, Movement, + Assumptions, Penalties, Mining, Items, - Elytra + Elytra, + Waypoints, + Colors ) } } object Rotations : RotationsConfigurable(this) + private object Colors : Configurable("Colors") { + init { + if (BaritoneUtil.isAvailable) { + treeAll( + Path, + Blocks, + Goal, + Section + ) + } + } + + private object Path : Configurable("Path") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Current", colorCurrentPath) + createSetting("Next", colorNextPath) + createSetting("BestPathSoFar", colorBestPathSoFar) + createSetting("MostRecentConsidered", colorMostRecentConsidered) + } + } + } + } + + private object Blocks : Configurable("Blocks") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("ToBreak", colorBlocksToBreak) + createSetting("Next", colorBlocksToPlace) + createSetting("ToWalkInto", colorBlocksToWalkInto) + } + } + } + } + + private object Goal : Configurable("Goal") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Box", colorGoalBox) + createSetting("InvertedBox", colorInvertedGoalBox) + } + } + } + } + + private object Section : Configurable("Section") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Color", colorSelection) + createSetting("PosFirst", colorSelectionPos1) + createSetting("PosSecond", colorSelectionPos2) + } + } + } + } + } + + private object Waypoints : Configurable("Waypoints") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Bed", doBedWaypoints) + createSetting("Death", doDeathWaypoints) + } + } + } + } + + private object Assumptions : Configurable("Assumptions") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Step", assumeStep) + } + + treeAll( + Walk + ) + } + } + + private object Walk : Configurable("Walk") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Water", assumeWalkOnWater) + createSetting("Lava", assumeWalkOnLava) + createSetting("Safe", assumeSafeWalk) + } + } + } + } + } + private object Mining : Configurable("Mining") { init { if (BaritoneUtil.isAvailable) { @@ -81,18 +182,42 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } treeAll( + Ascends, + Descends, Parkour ) } } + private object Ascends : Configurable("Ascends") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Diagonal", allowDiagonalAscend) + createSetting("WithSprint", sprintAscends) + createSetting("Parkour", allowParkourAscend) + } + } + } + } + + private object Descends : Configurable("Descends") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Diagonal", allowDiagonalDescend) + createSetting("OvershootDiagonal", allowOvershootDiagonalDescend) + } + } + } + } + private object Parkour : Configurable("Parkour") { init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Allow", allowParkour) createSetting("Place", allowParkourPlace) - createSetting("Ascend", allowParkourAscend) } } } From 0c4b66ed29a58a9c7f4b179dee84434b4596faf6 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:27:59 +0800 Subject: [PATCH 16/30] small refactoring --- .../features/module/modules/client/ModuleBaritone.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 51b8ac56cb4..0e4355f21e5 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -155,12 +155,12 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } treeAll( - LegitMine + Legit ) } } - private object LegitMine : Configurable("LegitMine") { + private object Legit : Configurable("Legit") { init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { From 182e8a4037da09dd3727cff47d3719387fac68bd Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:35:15 +0800 Subject: [PATCH 17/30] small refactoring --- .../module/modules/client/ModuleBaritone.kt | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 0e4355f21e5..3bbbb956077 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -228,14 +228,27 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("BlockPlacement", blockPlacementPenalty, maxRangedValue = 300) - createSetting("BlockBreakAdditionalPenalty", blockBreakAdditionalPenalty) - createSetting("BreakCorrectBlockPenaltyMultiplier", - breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) - createSetting("PlaceIncorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier) createSetting("WalkOnWaterOnePenalty", walkOnWaterOnePenalty) createSetting("JumpPenalty", jumpPenalty) } + + treeAll( + Blocks + ) + } + } + + private object Blocks : Configurable("Blocks") { + init { + if (BaritoneUtil.isAvailable) { + with(BaritoneAPI.getSettings()) { + createSetting("Placement", blockPlacementPenalty, maxRangedValue = 300) + createSetting("BreakAdditionalPenalty", blockBreakAdditionalPenalty) + createSetting("BreakCorrectBlockPenaltyMultiplier", + breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) + createSetting("PlaceIncorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier) + } + } } } } From 3942d1ccd5469ceabfaf1c0d64c6ca086ffbe813 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:39:58 +0800 Subject: [PATCH 18/30] small refactoring --- .../features/module/modules/client/ModuleBaritone.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 3bbbb956077..ac5505618e6 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -48,7 +48,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat Path, Blocks, Goal, - Section + Selection ) } } @@ -82,14 +82,14 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Box", colorGoalBox) - createSetting("InvertedBox", colorInvertedGoalBox) + createSetting("Color", colorGoalBox) + createSetting("Inverted", colorInvertedGoalBox) } } } } - private object Section : Configurable("Section") { + private object Selection : Configurable("Selection") { init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { From d6e86ceb90e15907fd37c29d4c52d83a6dc42747 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:46:43 +0800 Subject: [PATCH 19/30] small refactoring --- .../features/module/modules/client/ModuleBaritone.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index ac5505618e6..f399a30da92 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -228,8 +228,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("WalkOnWaterOnePenalty", walkOnWaterOnePenalty) - createSetting("JumpPenalty", jumpPenalty) + createSetting("WalkOnWater", walkOnWaterOnePenalty) + createSetting("Jump", jumpPenalty) } treeAll( @@ -243,10 +243,10 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("Placement", blockPlacementPenalty, maxRangedValue = 300) - createSetting("BreakAdditionalPenalty", blockBreakAdditionalPenalty) - createSetting("BreakCorrectBlockPenaltyMultiplier", + createSetting("BreakAdditional", blockBreakAdditionalPenalty) + createSetting("BreakCorrectBlockMultiplier", breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) - createSetting("PlaceIncorrectBlockPenaltyMultiplier", breakCorrectBlockPenaltyMultiplier) + createSetting("PlaceIncorrectBlockMultiplier", breakCorrectBlockPenaltyMultiplier) } } } From 5c33c28a61f04e28ba5e4ab54ed7f751902e8dd1 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:47:38 +0800 Subject: [PATCH 20/30] fix --- .../features/module/modules/client/ModuleBaritone.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index f399a30da92..f5e4c064694 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -246,7 +246,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat createSetting("BreakAdditional", blockBreakAdditionalPenalty) createSetting("BreakCorrectBlockMultiplier", breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) - createSetting("PlaceIncorrectBlockMultiplier", breakCorrectBlockPenaltyMultiplier) + createSetting("PlaceIncorrectBlockMultiplier", placeIncorrectBlockPenaltyMultiplier) } } } From f8f96c3a4ce2a7598d9cd6fddc40a701b14d5ae1 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Tue, 17 Dec 2024 21:52:28 +0800 Subject: [PATCH 21/30] fix --- .../module/modules/client/ModuleBaritone.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index f5e4c064694..7c1aabe9815 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -143,15 +143,15 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("MinMineYLevel", minYLevelWhileMining, maxRangedValue = 2031) - createSetting("MaxMineYLevel", maxYLevelWhileMining, maxRangedValue = 2031) - createSetting("MineGoalUpdateInterval", mineGoalUpdateInterval, maxRangedValue = 20) - createSetting("MineMaxOreLocationsCount", mineGoalUpdateInterval, maxRangedValue = 64) - createSetting("PauseMiningForFallingBlocks", pauseMiningForFallingBlocks) - createSetting("ForceInternalMining", forceInternalMining) + createSetting("MinYLevel", minYLevelWhileMining, maxRangedValue = 2031) + createSetting("MaxYLevel", maxYLevelWhileMining, maxRangedValue = 2031) + createSetting("GoalUpdateInterval", mineGoalUpdateInterval, maxRangedValue = 20) + createSetting("MaxOreLocationsCount", mineMaxOreLocationsCount, maxRangedValue = 64) + createSetting("PauseForFallingBlocks", pauseMiningForFallingBlocks) + createSetting("ForceInternal", forceInternalMining) createSetting("OnlyExposedOres", allowOnlyExposedOres) createSetting("UseSword", useSwordToMine) - createSetting("NotificationOnMineFail", notificationOnMineFail) + createSetting("NotificationOnFail", notificationOnMineFail) } treeAll( From c45d7f270bf644637ab4914f477dcec33046daa7 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 13:44:08 +0800 Subject: [PATCH 22/30] changes by ManInMyVan review --- .../mixins/baritone/MixinBaritone.java | 2 +- .../baritone/MixinCustomGoalProcess.java | 2 +- .../liquidbounce/event/EventManager.kt | 2 +- .../module/modules/client/ModuleBaritone.kt | 16 ++------- .../modules/combat/killaura/ModuleKillAura.kt | 2 +- .../module/modules/player/ModuleAutoWalk.kt | 4 +-- .../module/modules/render/ModuleFreeCam.kt | 4 +-- .../liquidbounce/utils/aiming/RotationData.kt | 6 ++-- .../client/baritone/goals/GoalDirection.kt | 34 +++++++++++++++---- 9 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java index fdd6838414f..cf107a90081 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java @@ -27,7 +27,7 @@ public abstract class MixinBaritone implements IBaritone { @Inject(method = "getLookBehavior", at = @At("HEAD"), cancellable = true, remap = false) public void hookLookBehavior(CallbackInfoReturnable cir) { - if(lookBehavior == null) { + if (lookBehavior == null) { lookBehavior = new LiquidBounceLookBehavior(); getGameEventHandler().registerEventListener(lookBehavior); } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java index 593ad8dbb89..87976c952bf 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java @@ -21,7 +21,7 @@ public void hookSetGoal(Goal goal, CallbackInfo ci) { var event = new BaritoneCustomGoalProcessCreatedEvent(goal); EventManager.INSTANCE.callEvent(event); - if(event.isCancelled()) ci.cancel(); + if (event.isCancelled()) ci.cancel(); } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt index 9ecd11b37f0..b419aa15c6d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt @@ -135,7 +135,7 @@ val ALL_EVENT_CLASSES: Array> = arrayOf( BlockAttackEvent::class, QueuePacketEvent::class, BaritoneCustomGoalProcessCreatedEvent::class, - BaritonePathCancelEverythingEvent::class + BaritonePathCancelEverythingEvent::class, ) /** diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 7c1aabe9815..6caa33e949f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -71,7 +71,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createSetting("ToBreak", colorBlocksToBreak) - createSetting("Next", colorBlocksToPlace) + createSetting("ToPlace", colorBlocksToPlace) createSetting("ToWalkInto", colorBlocksToWalkInto) } } @@ -263,27 +263,17 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat createSetting("PredictTerrain", elytraPredictTerrain) createSetting("EmergencyLand", elytraAllowEmergencyLand) createSetting("LandOnNetherFortress", elytraAllowLandOnNetherFortress) + createSetting("AutoJump", elytraAutoJump) + createSetting("AutoSwap", elytraAutoSwap) } treeAll( - Auto, Firework, Render ) } } - private object Auto : Configurable("Auto") { - init { - if (BaritoneUtil.isAvailable) { - with(BaritoneAPI.getSettings()) { - createSetting("Jump", elytraAutoJump) - createSetting("Swap", elytraAutoSwap) - } - } - } - } - private object Firework : Configurable("Firework") { init { if (BaritoneUtil.isAvailable) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt index fe7af41cbd7..4e8fc6edc7d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt @@ -119,7 +119,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { internal val simulateInventoryClosing by boolean("SimulateInventoryClosing", true) private val pauseBaritone by boolean("PauseBaritone", true).onChanged { - if(it && targetTracker.lockedOnTarget != null && PathManager.isPathing) { + if (it && targetTracker.lockedOnTarget != null && PathManager.isPathing) { PathManager.pause() } else if (!it && targetTracker.lockedOnTarget != null) { PathManager.resume() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt index 42d7d6efedc..ab9ad456ca2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoWalk.kt @@ -44,7 +44,7 @@ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { get() = modes override fun enable() { - if(!PathManager) { + if (!PathManager) { notification( this.name, "Baritone is not installed! Install it first.", @@ -64,7 +64,7 @@ object ModuleAutoWalk : ClientModule("AutoWalk", Category.PLAYER) { } override fun disable() { - if(PathManager.hasPath) { + if (PathManager.hasPath) { PathManager.stop() } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt index e3925b0ea8e..707ced487c8 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt @@ -139,9 +139,9 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = return pos?.interpolate(tickDelta) ?: original } - fun shouldDisableCrosshair() = running && (!allowCameraInteract && !PathManager.isPathing) + fun shouldDisableCrosshair() = running && !allowCameraInteract && !PathManager.isPathing - fun shouldDisableRotations() = running && (!allowRotationChange && !PathManager.isPathing) + fun shouldDisableRotations() = running && !allowRotationChange && !PathManager.isPathing private fun updatePosition(velocity: Vec3d) { pos = (pos ?: PositionPair(player.eyes, player.eyes)).apply { this += velocity } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt index 6b67ee1dc39..8e23f2b93f8 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationData.kt @@ -78,8 +78,6 @@ data class Rotation( data class VecRotation(val rotation: Rotation, val vec: Vec3d) -fun Rotation.toBaritoneRotation() = - BRotation(yaw, pitch) +fun Rotation.toBaritoneRotation() = BRotation(yaw, pitch) -fun BRotation.toClientRotation() = - Rotation(yaw, pitch) +fun BRotation.toClientRotation() = Rotation(yaw, pitch) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt index 21738bc057b..e3e8e4c0cc1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/baritone/goals/GoalDirection.kt @@ -2,19 +2,31 @@ package net.ccbluex.liquidbounce.utils.client.baritone.goals import baritone.api.BaritoneAPI import baritone.api.pathing.goals.Goal -import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.client.player -import net.ccbluex.liquidbounce.utils.client.world -import net.minecraft.world.tick.TickManager import java.lang.Math.toRadians import kotlin.math.* private val SQRT_2: Double = sqrt(2.0) -class GoalDirection ( - private val yaw: Float -) : Goal { - +/** + * A goal implementation that calculates destination based on player's yaw (look direction). + * + * This class determines a destination point 100 blocks away from the player's current position + * in the direction they are looking (yaw angle). + * + * @property yaw The yaw angle of player's look direction in degrees + * * (-180 <= yaw <= 180) + * + * @constructor Creates a goal with specified yaw angle + */ +class GoalDirection(private val yaw: Float) : Goal { + + /** + * Calculates the destination coordinates based on player's position and yaw. + * Uses trigonometry to find a point 100 blocks away in the look direction. + * + * @return Pair of x,z coordinates for the destination + */ private val destination: Pair get() { val theta = toRadians(yaw.toDouble()).toFloat() val pos = player.pos @@ -22,6 +34,14 @@ class GoalDirection ( return floor(pos.x - sin(theta) * 100).toInt() to floor(pos.z + cos(theta) * 100).toInt() } + /** + * Calculates the heuristic cost between two points using a combination of + * diagonal and straight line distances. + * + * @param xDiff The x-axis difference between points + * @param zDiff The z-axis difference between points + * @return The calculated movement cost multiplied by the cost heuristic setting + */ fun calculate(xDiff: Int, zDiff: Int): Double { val x = abs(xDiff) val z = abs(zDiff) From d53784ee022b7e46dbb589c9a4e11199bb450c60 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 14:31:28 +0800 Subject: [PATCH 23/30] ToggleableConfigurable support to baritone settings --- .../config/types/ToggleableConfigurable.kt | 8 +- .../module/modules/client/ModuleBaritone.kt | 76 +++++++++++-------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/config/types/ToggleableConfigurable.kt b/src/main/kotlin/net/ccbluex/liquidbounce/config/types/ToggleableConfigurable.kt index 7a897e33752..4d8245cd550 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/config/types/ToggleableConfigurable.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/config/types/ToggleableConfigurable.kt @@ -36,8 +36,14 @@ abstract class ToggleableConfigurable( enabled: Boolean ) : EventListener, Configurable(name, valueType = ValueType.TOGGLEABLE), MinecraftShortcuts { + var onChangedListener: (Boolean) -> Unit = {} + // TODO: Make enabled change also call newState - internal var enabled by boolean("Enabled", enabled) + internal var enabled by boolean("Enabled", enabled).onChanged { + onChangedListener.invoke(it) + } + + fun newState(state: Boolean) { if (!enabled) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 6caa33e949f..98d7cb42939 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -3,6 +3,7 @@ package net.ccbluex.liquidbounce.features.module.modules.client import baritone.api.BaritoneAPI import baritone.api.Settings import net.ccbluex.liquidbounce.config.types.Configurable +import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable import net.ccbluex.liquidbounce.config.types.Value import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule @@ -21,8 +22,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Break", allowBreak) createSetting("Place", allowPlace) + createToggleableConfigurableSetting(Mining, allowBreak) } treeAll( @@ -30,7 +31,6 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat Movement, Assumptions, Penalties, - Mining, Items, Elytra, Waypoints, @@ -139,7 +139,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } } - private object Mining : Configurable("Mining") { + private object Mining : ToggleableConfigurable(this, "Mining", false /* no matter. */) { init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { @@ -152,19 +152,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat createSetting("OnlyExposedOres", allowOnlyExposedOres) createSetting("UseSword", useSwordToMine) createSetting("NotificationOnFail", notificationOnMineFail) - } - - treeAll( - Legit - ) - } - } - - private object Legit : Configurable("Legit") { - init { - if (BaritoneUtil.isAvailable) { - with(BaritoneAPI.getSettings()) { - createSetting("Allow", legitMine) + createToggleableConfigurableSetting("LegitMine", legitMine) { createSetting("IncludeDiagonals", legitMineIncludeDiagonals) createSetting("YLevel", legitMineYLevel, -64, 320) } @@ -179,12 +167,14 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat with(BaritoneAPI.getSettings()) { createSetting("Sprint", allowSprint) createSetting("JumpAt256", allowJumpAt256) + createToggleableConfigurableSetting("Parkour", allowParkour) { + createSetting("Place", allowParkourPlace) + } } treeAll( Ascends, - Descends, - Parkour + Descends ) } } @@ -205,19 +195,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Diagonal", allowDiagonalDescend) - createSetting("OvershootDiagonal", allowOvershootDiagonalDescend) - } - } - } - } - - private object Parkour : Configurable("Parkour") { - init { - if (BaritoneUtil.isAvailable) { - with(BaritoneAPI.getSettings()) { - createSetting("Allow", allowParkour) - createSetting("Place", allowParkourPlace) + createToggleableConfigurableSetting("Diagonal", allowDiagonalDescend) { + createSetting("Overshoot", allowOvershootDiagonalDescend) + } } } } @@ -290,8 +270,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Raytraces", elytraRenderRaytraces) - createSetting("HitboxRaytraces", elytraRenderHitboxRaytraces) + createToggleableConfigurableSetting("Raytraces", elytraRenderRaytraces) { + createSetting("Hitbox", elytraRenderHitboxRaytraces) + } createSetting("Simulation", elytraRenderSimulation) } } @@ -311,6 +292,35 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } } +private fun Configurable.createToggleableConfigurableSetting( + reference: ToggleableConfigurable, + setting: Settings.Setting, + addToTree: Boolean = true +) { + reference.enabled = setting.value + reference.onChangedListener = { + setting.value = it + } + + if (addToTree) { + this.tree(reference) + } +} + +private inline fun Configurable.createToggleableConfigurableSetting( + name: String, + setting: Settings.Setting, + crossinline block: ToggleableConfigurable.() -> Unit +) { + val reference = object : ToggleableConfigurable(ModuleBaritone, name, setting.value) { + init { + block(this) + } + } + + this.createToggleableConfigurableSetting(reference, setting) +} + private inline fun Configurable.createSetting( name: String, setting: Settings.Setting, From 7fa8b8ea1e3c14fb7689c4ca3f836826a1535dd4 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 15:49:07 +0800 Subject: [PATCH 24/30] baritone settings sync (#set ...) --- .../mixins/baritone/MixinSetCommand.java | 26 +++++++++ .../module/modules/client/ModuleBaritone.kt | 56 +++++++++++++++++++ src/main/resources/liquidbounce.mixins.json | 1 + 3 files changed, 83 insertions(+) create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java new file mode 100644 index 00000000000..63ce92c7ef4 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java @@ -0,0 +1,26 @@ +package net.ccbluex.liquidbounce.injection.mixins.baritone; + +import baritone.api.Settings; +import baritone.api.command.argument.IArgConsumer; +import baritone.command.defaults.SetCommand; +import com.llamalad7.mixinextras.sugar.Local; +import net.ccbluex.liquidbounce.features.module.modules.client.ModuleBaritoneKt; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(SetCommand.class) +public class MixinSetCommand { + + @Inject(method = "execute", at = @At(value = "INVOKE", target = "Lbaritone/command/defaults/SetCommand;logDirect(Ljava/lang/String;)V", ordinal = 9), remap = false) + private void hookSetSetting(String par1, IArgConsumer par2, CallbackInfo ci, @Local(ordinal = 0) Settings.Setting setting) { + var onChangeListener = ModuleBaritoneKt.getControlledBaritoneSettings() + .getOrDefault(setting, null); + + if(onChangeListener != null) { + onChangeListener.invoke(setting.value); + } + } + +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 98d7cb42939..74b54cc89c2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -7,6 +7,7 @@ import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable import net.ccbluex.liquidbounce.config.types.Value import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule +import net.ccbluex.liquidbounce.injection.mixins.baritone.MixinSetCommand import net.ccbluex.liquidbounce.render.engine.toColor import net.ccbluex.liquidbounce.render.engine.toColor4b import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable @@ -292,6 +293,36 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat } } +/** + * A mutable map for controlling Baritone settings through client-side wrapper ([ModuleBaritone]) settings. + * + * The map key represents a Baritone setting ([Settings.Setting]), + * and the value is a lambda function that serves as a setter for updating the setting's value. + * + * The lambda accepts the current setting value of type [Any], corresponding to + * the generic type T of the original [Settings.Setting.value]. + * + * Used for dynamic management and synchronization of Baritone settings + * through intermediate client-side settings. + * + * @see Settings.Setting + * @see MixinSetCommand + */ +private val controlledBaritoneSettingsMutableMap = mutableMapOf, (Any) -> Unit>() + +/** + * Provides read-only access to the controlled Baritone settings map. + * + * This getter exposes the internal [controlledBaritoneSettingsMutableMap] + * as an immutable [Map], preventing direct modifications from outside the class. + * + * Contains Baritone settings mapped to their respective setter lambdas, + * where each lambda can update the corresponding setting's value. + * + * @return An immutable map of Baritone settings and their setter functions + */ +val controlledBaritoneSettings: Map, (Any) -> Unit> get() = controlledBaritoneSettingsMutableMap + private fun Configurable.createToggleableConfigurableSetting( reference: ToggleableConfigurable, setting: Settings.Setting, @@ -305,6 +336,10 @@ private fun Configurable.createToggleableConfigurableSetting( if (addToTree) { this.tree(reference) } + + controlledBaritoneSettingsMutableMap[setting] = { + reference.enabled = it as Boolean + } } private inline fun Configurable.createToggleableConfigurableSetting( @@ -329,24 +364,45 @@ private inline fun Configurable.createSetting( ): Value<*> = when (val value = setting.value) { is Boolean -> boolean(name, value) .onChanged { setting.value = it as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set(it as Boolean) + } } is Double -> float(name, value.toFloat(), minRangedValue.toFloat()..maxRangedValue.toFloat()) .onChanged { setting.value = it.toDouble() as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set((it as Double).toFloat()) + } } is Float -> float(name, value, minRangedValue.toFloat()..maxRangedValue.toFloat()) .onChanged { setting.value = it as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set(it as Float) + } } is Int -> int(name, value, 0..maxRangedValue) .onChanged { setting.value = it as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set(it as Int) + } } is Long -> int(name, value.toInt(), minRangedValue..maxRangedValue) .onChanged { setting.value = it.toLong() as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set((it as Long).toInt()) + } } is String -> text(name, value) .onChanged { setting.value = it as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set(it as String) + } } is Color -> color(name, value.toColor4b()) .onChanged { setting.value = it.toColor() as T } + .apply { controlledBaritoneSettingsMutableMap[setting] = { + set((it as Color).toColor4b()) + } } else -> throw NotImplementedError("Undefined baritone setting class!") } diff --git a/src/main/resources/liquidbounce.mixins.json b/src/main/resources/liquidbounce.mixins.json index e2404195a5c..80fab779621 100644 --- a/src/main/resources/liquidbounce.mixins.json +++ b/src/main/resources/liquidbounce.mixins.json @@ -11,6 +11,7 @@ "baritone.MixinCustomGoalProcess", "baritone.MixinPathingBehavior", "baritone.MixinPlayerMovementInput", + "baritone.MixinSetCommand", "minecraft.block.MixinBlock", "minecraft.block.MixinBlockCollisionSpliterator", "minecraft.block.MixinBlockView", From b0087a017d0a88187cb98f7fdd6925c15147b838 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 16:07:05 +0800 Subject: [PATCH 25/30] kdoc --- .../module/modules/client/ModuleBaritone.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 74b54cc89c2..2a363a5ebbd 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -20,6 +20,19 @@ import java.awt.Color * @author sqlerrorthing */ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivation = true, hide = true) { + + /** + * This `init` block initializes settings and configurations related to Baritone. + * The check `BaritoneUtil.isAvailable` is **mandatory** to prevent potential errors + * if Baritone is not present (e.g class baritone.api.BaritoneAPI not found error (CNDF)). + * + * Without this check, the code within this block will still + * execute, potentially causing `(C)lass (N)ot (D)ef (F)ound` or other issues due to + * the absence of the Baritone API. + * + * If `BaritoneUtil.isAvailable` evaluates to `false`, this entire block will be skipped, + * preventing attempts to interact with the Baritone API when it is not loaded. + */ init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { From 432d33dd0e2a79d4e02e5479b0477a7b9308426a Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 18:21:00 +0800 Subject: [PATCH 26/30] fully fixed freecam with baritone --- .../features/module/modules/client/ModuleBaritone.kt | 2 +- .../features/module/modules/render/ModuleFreeCam.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 2a363a5ebbd..6ae8a650441 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -417,5 +417,5 @@ private inline fun Configurable.createSetting( set((it as Color).toColor4b()) } } - else -> throw NotImplementedError("Undefined baritone setting class!") + else -> throw NotImplementedError("Undefined baritone setting class! ${T::class.java.name}") } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt index 707ced487c8..019e253bed0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt @@ -132,7 +132,7 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = * Modify the raycast position */ fun modifyRaycast(original: Vec3d, entity: Entity, tickDelta: Float): Vec3d { - if (!running || entity != mc.player || (!allowCameraInteract && !PathManager.isPathing)) { + if (!running || entity != mc.player || !allowCameraInteract || PathManager.isPathing) { return original } From a76f779c308c313790f4c35ad3e467b20f0953f8 Mon Sep 17 00:00:00 2001 From: sqlerrorthing Date: Thu, 19 Dec 2024 18:47:18 +0800 Subject: [PATCH 27/30] mini refactoring --- .../liquidbounce/injection/mixins/baritone/MixinBaritone.java | 4 ---- .../injection/mixins/baritone/MixinCustomGoalProcess.java | 4 ---- .../injection/mixins/baritone/MixinPathingBehavior.java | 4 ---- 3 files changed, 12 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java index cf107a90081..919da39631e 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinBaritone.java @@ -12,10 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -/** - * @author 00101110001100010111000101111 - * @since 12/17/2024 - **/ @Mixin(Baritone.class) public abstract class MixinBaritone implements IBaritone { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java index 87976c952bf..f3caf6a86b1 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinCustomGoalProcess.java @@ -9,10 +9,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -/** - * @author 00101110001100010111000101111 - * @since 12/17/2024 - **/ @Mixin(CustomGoalProcess.class) public class MixinCustomGoalProcess { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java index 1ae71e3fc23..51c51345558 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinPathingBehavior.java @@ -8,10 +8,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -/** - * @author 00101110001100010111000101111 - * @since 12/17/2024 - **/ @Mixin(PathingBehavior.class) public class MixinPathingBehavior { From 067161346dca050db29e56720fcbeeeb4768ad17 Mon Sep 17 00:00:00 2001 From: yaraksan Date: Thu, 19 Dec 2024 21:46:28 +0100 Subject: [PATCH 28/30] Improved setting implementation --- .../module/modules/client/ModuleBaritone.kt | 236 ++++++++++-------- 1 file changed, 130 insertions(+), 106 deletions(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt index 6ae8a650441..29537e5493f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/client/ModuleBaritone.kt @@ -8,6 +8,7 @@ import net.ccbluex.liquidbounce.config.types.Value import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule import net.ccbluex.liquidbounce.injection.mixins.baritone.MixinSetCommand +import net.ccbluex.liquidbounce.render.engine.Color4b import net.ccbluex.liquidbounce.render.engine.toColor import net.ccbluex.liquidbounce.render.engine.toColor4b import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable @@ -36,7 +37,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Place", allowPlace) + createValSetting("Place", allowPlace) createToggleableConfigurableSetting(Mining, allowBreak) } @@ -71,10 +72,10 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Current", colorCurrentPath) - createSetting("Next", colorNextPath) - createSetting("BestPathSoFar", colorBestPathSoFar) - createSetting("MostRecentConsidered", colorMostRecentConsidered) + createValSetting("Current", colorCurrentPath) + createValSetting("Next", colorNextPath) + createValSetting("BestPathSoFar", colorBestPathSoFar) + createValSetting("MostRecentConsidered", colorMostRecentConsidered) } } } @@ -84,9 +85,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("ToBreak", colorBlocksToBreak) - createSetting("ToPlace", colorBlocksToPlace) - createSetting("ToWalkInto", colorBlocksToWalkInto) + createValSetting("ToBreak", colorBlocksToBreak) + createValSetting("ToPlace", colorBlocksToPlace) + createValSetting("ToWalkInto", colorBlocksToWalkInto) } } } @@ -96,8 +97,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Color", colorGoalBox) - createSetting("Inverted", colorInvertedGoalBox) + createValSetting("Color", colorGoalBox) + createValSetting("Inverted", colorInvertedGoalBox) } } } @@ -107,9 +108,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Color", colorSelection) - createSetting("PosFirst", colorSelectionPos1) - createSetting("PosSecond", colorSelectionPos2) + createValSetting("Color", colorSelection) + createValSetting("PosFirst", colorSelectionPos1) + createValSetting("PosSecond", colorSelectionPos2) } } } @@ -120,8 +121,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Bed", doBedWaypoints) - createSetting("Death", doDeathWaypoints) + createValSetting("Bed", doBedWaypoints) + createValSetting("Death", doDeathWaypoints) } } } @@ -131,7 +132,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Step", assumeStep) + createValSetting("Step", assumeStep) } treeAll( @@ -144,9 +145,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Water", assumeWalkOnWater) - createSetting("Lava", assumeWalkOnLava) - createSetting("Safe", assumeSafeWalk) + createValSetting("Water", assumeWalkOnWater) + createValSetting("Lava", assumeWalkOnLava) + createValSetting("Safe", assumeSafeWalk) } } } @@ -157,18 +158,18 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("MinYLevel", minYLevelWhileMining, maxRangedValue = 2031) - createSetting("MaxYLevel", maxYLevelWhileMining, maxRangedValue = 2031) - createSetting("GoalUpdateInterval", mineGoalUpdateInterval, maxRangedValue = 20) - createSetting("MaxOreLocationsCount", mineMaxOreLocationsCount, maxRangedValue = 64) - createSetting("PauseForFallingBlocks", pauseMiningForFallingBlocks) - createSetting("ForceInternal", forceInternalMining) - createSetting("OnlyExposedOres", allowOnlyExposedOres) - createSetting("UseSword", useSwordToMine) - createSetting("NotificationOnFail", notificationOnMineFail) + createNumSetting("MinYLevel", minYLevelWhileMining, 0..2031) + createNumSetting("MaxYLevel", maxYLevelWhileMining, 0..2031) + createNumSetting("GoalUpdateInterval", mineGoalUpdateInterval, 0..20) + createNumSetting("MaxOreLocationsCount", mineMaxOreLocationsCount, 0..64) + createValSetting("PauseForFallingBlocks", pauseMiningForFallingBlocks) + createValSetting("ForceInternal", forceInternalMining) + createValSetting("OnlyExposedOres", allowOnlyExposedOres) + createValSetting("UseSword", useSwordToMine) + createValSetting("NotificationOnFail", notificationOnMineFail) createToggleableConfigurableSetting("LegitMine", legitMine) { - createSetting("IncludeDiagonals", legitMineIncludeDiagonals) - createSetting("YLevel", legitMineYLevel, -64, 320) + createValSetting("IncludeDiagonals", legitMineIncludeDiagonals) + createNumSetting("YLevel", legitMineYLevel, -64..320) } } } @@ -179,10 +180,10 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Sprint", allowSprint) - createSetting("JumpAt256", allowJumpAt256) + createValSetting("Sprint", allowSprint) + createValSetting("JumpAt256", allowJumpAt256) createToggleableConfigurableSetting("Parkour", allowParkour) { - createSetting("Place", allowParkourPlace) + createValSetting("Place", allowParkourPlace) } } @@ -197,9 +198,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Diagonal", allowDiagonalAscend) - createSetting("WithSprint", sprintAscends) - createSetting("Parkour", allowParkourAscend) + createValSetting("Diagonal", allowDiagonalAscend) + createValSetting("WithSprint", sprintAscends) + createValSetting("Parkour", allowParkourAscend) } } } @@ -210,7 +211,7 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createToggleableConfigurableSetting("Diagonal", allowDiagonalDescend) { - createSetting("Overshoot", allowOvershootDiagonalDescend) + createValSetting("Overshoot", allowOvershootDiagonalDescend) } } } @@ -222,8 +223,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("WalkOnWater", walkOnWaterOnePenalty) - createSetting("Jump", jumpPenalty) + createNumSetting("WalkOnWater", walkOnWaterOnePenalty, 0..10) + createNumSetting("Jump", jumpPenalty, 0..10) } treeAll( @@ -236,11 +237,11 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Placement", blockPlacementPenalty, maxRangedValue = 300) - createSetting("BreakAdditional", blockBreakAdditionalPenalty) - createSetting("BreakCorrectBlockMultiplier", - breakCorrectBlockPenaltyMultiplier, maxRangedValue = 20) - createSetting("PlaceIncorrectBlockMultiplier", placeIncorrectBlockPenaltyMultiplier) + createNumSetting("Placement", blockPlacementPenalty, 0..300) + createNumSetting("BreakAdditional", blockBreakAdditionalPenalty, 0..10) + createNumSetting("BreakCorrectBlockMultiplier", + breakCorrectBlockPenaltyMultiplier, 0..20) + createNumSetting("PlaceIncorrectBlockMultiplier", placeIncorrectBlockPenaltyMultiplier, 0..10) } } } @@ -251,14 +252,14 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("SimulationTicks", elytraSimulationTicks, 1, 100) - createSetting("PitchRange", elytraPitchRange, 1, 100) - createSetting("MinimumAvoidance", elytraMinimumAvoidance, -10) - createSetting("PredictTerrain", elytraPredictTerrain) - createSetting("EmergencyLand", elytraAllowEmergencyLand) - createSetting("LandOnNetherFortress", elytraAllowLandOnNetherFortress) - createSetting("AutoJump", elytraAutoJump) - createSetting("AutoSwap", elytraAutoSwap) + createNumSetting("SimulationTicks", elytraSimulationTicks, 1..100) + createNumSetting("PitchRange", elytraPitchRange, 1..100) + createNumSetting("MinimumAvoidance", elytraMinimumAvoidance, -10..0) + createValSetting("PredictTerrain", elytraPredictTerrain) + createValSetting("EmergencyLand", elytraAllowEmergencyLand) + createValSetting("LandOnNetherFortress", elytraAllowLandOnNetherFortress) + createValSetting("AutoJump", elytraAutoJump) + createValSetting("AutoSwap", elytraAutoSwap) } treeAll( @@ -272,9 +273,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Speed", elytraFireworkSpeed) - createSetting("SetbackUseDelay", elytraFireworkSetbackUseDelay) - createSetting("Conserve", elytraConserveFireworks) + createNumSetting("Speed", elytraFireworkSpeed, 0..10) + createNumSetting("SetbackUseDelay", elytraFireworkSetbackUseDelay, 0..10) + createValSetting("Conserve", elytraConserveFireworks) } } } @@ -285,9 +286,9 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { createToggleableConfigurableSetting("Raytraces", elytraRenderRaytraces) { - createSetting("Hitbox", elytraRenderHitboxRaytraces) + createValSetting("Hitbox", elytraRenderHitboxRaytraces) } - createSetting("Simulation", elytraRenderSimulation) + createValSetting("Simulation", elytraRenderSimulation) } } } @@ -298,8 +299,8 @@ object ModuleBaritone : ClientModule("Baritone", Category.CLIENT, disableActivat init { if (BaritoneUtil.isAvailable) { with(BaritoneAPI.getSettings()) { - createSetting("Inventory", allowInventory) - createSetting("AutoTool", autoTool) + createValSetting("Inventory", allowInventory) + createValSetting("AutoTool", autoTool) } } } @@ -369,53 +370,76 @@ private inline fun Configurable.createToggleableConfigurableSetting( this.createToggleableConfigurableSetting(reference, setting) } -private inline fun Configurable.createSetting( +private inline fun Configurable.createNumSetting( name: String, setting: Settings.Setting, - minRangedValue: Int = 0, - maxRangedValue: Int = 10 -): Value<*> = when (val value = setting.value) { - is Boolean -> boolean(name, value) - .onChanged { setting.value = it as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set(it as Boolean) - } } - - is Double -> float(name, value.toFloat(), minRangedValue.toFloat()..maxRangedValue.toFloat()) - .onChanged { setting.value = it.toDouble() as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set((it as Double).toFloat()) - } } - - is Float -> float(name, value, minRangedValue.toFloat()..maxRangedValue.toFloat()) - .onChanged { setting.value = it as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set(it as Float) - } } - - is Int -> int(name, value, 0..maxRangedValue) - .onChanged { setting.value = it as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set(it as Int) - } } - - is Long -> int(name, value.toInt(), minRangedValue..maxRangedValue) - .onChanged { setting.value = it.toLong() as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set((it as Long).toInt()) - } } - - is String -> text(name, value) - .onChanged { setting.value = it as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set(it as String) - } } - - is Color -> color(name, value.toColor4b()) - .onChanged { setting.value = it.toColor() as T } - .apply { controlledBaritoneSettingsMutableMap[setting] = { - set((it as Color).toColor4b()) - } } - - else -> throw NotImplementedError("Undefined baritone setting class! ${T::class.java.name}") + range: IntRange +): Value<*> { + return when (setting.value) { + is Double -> createGenericBaritoneSetting( + { n, v -> float(n, v, range.first.toFloat()..range.last.toFloat()) }, + name, setting, Double::toFloat, Float::toDouble + ) + is Float -> createGenericBaritoneSettingOfSharedType( + { n, v -> float(n, v, range.first.toFloat()..range.last.toFloat()) }, + name, setting + ) + is Long -> createGenericBaritoneSetting( + { n, v -> int(n, v, range) }, + name, setting, Long::toInt, Int::toLong, + ) + is Int -> createGenericBaritoneSettingOfSharedType( + { n, v -> int(n, v, range) }, + name, setting + ) + else -> throw NotImplementedError("Unknown number value type! ${T::class.java.name}") + } +} + +private inline fun Configurable.createValSetting(name: String, setting: Settings.Setting): Value<*> { + return when (setting.value) { + is Boolean -> createGenericBaritoneSettingOfSharedType(this::boolean, name, setting) + is String -> createGenericBaritoneSettingOfSharedType(this::text, name, setting) + is Color -> createGenericBaritoneSetting(this::color, name, setting, Color::toColor4b, Color4b::toColor) + else -> throw NotImplementedError("Unknown non-number value type! ${T::class.java.name}") + } +} + +/** + * [createGenericBaritoneSetting] for the case when the type is shared between baritone and LiquidBounce. + */ +private inline fun createGenericBaritoneSettingOfSharedType( + configurableGenerator: (String, T) -> Value, + name: String, + setting: Settings.Setting<*>, +): Value { + return createGenericBaritoneSetting(configurableGenerator, name, setting, { it }, { it }) +} + +/** + * Generates a preconfigured LiquidBounce-configurable for a given baritone setting + * + * @param L The type of the value in LiquidBounce's type system + * @param B The type of the value in Baritone's type system + * + * @param toLiquidBounceConverter translates the given type from the baritone type system to the LB type system + * @param toBaritoneConverter translates the given type from the LB type system to the baritone type system + */ +private inline fun createGenericBaritoneSetting( + configurableGenerator: (String, L) -> Value, + name: String, + setting: Settings.Setting<*>, + crossinline toLiquidBounceConverter: (B) -> L, + crossinline toBaritoneConverter: (L) -> B +): Value { + @Suppress("UNCHECKED_CAST") + val castedSetting = setting as Settings.Setting + + return configurableGenerator(name, toLiquidBounceConverter(setting.value!!)) + .onChanged { castedSetting.value = toBaritoneConverter(it) } + .apply { + controlledBaritoneSettingsMutableMap[setting] = { + set(toLiquidBounceConverter(it as B)) + } + } } From 578f2cbaa67f3e9691b5ef1e0bfcb5592ca55ef7 Mon Sep 17 00:00:00 2001 From: 1zuna <1zuna@ccbluex.net> Date: Sat, 21 Dec 2024 21:25:56 +0100 Subject: [PATCH 29/30] Apply suggestions from code review Co-authored-by: ManInMyVan <113963219+ManInMyVan@users.noreply.github.com> --- .../net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt index 4d75998afc9..9f2b14514bc 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt @@ -117,7 +117,7 @@ fun ClientPlayerEntity.isCloseToEdge( return wouldBeCloseToFallOff(pos) || wouldBeCloseToFallOff(playerPosInTwoTicks) } -val ClientPlayerEntity.pressingMovementButton get() = if(PathManager.isPathing) { +val ClientPlayerEntity.pressingMovementButton get() = if (PathManager.isPathing) { with(mc.options) { forwardKey.isPressed || backKey.isPressed || leftKey.isPressed || rightKey.isPressed } From 7c674951990bdf7939af2c9796c0149fc9288bfc Mon Sep 17 00:00:00 2001 From: 1zuna <1zuna@ccbluex.net> Date: Sat, 21 Dec 2024 21:26:05 +0100 Subject: [PATCH 30/30] Apply suggestions from code review Co-authored-by: ManInMyVan <113963219+ManInMyVan@users.noreply.github.com> --- .../liquidbounce/injection/mixins/baritone/MixinSetCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java index 63ce92c7ef4..3fff847d3c6 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/baritone/MixinSetCommand.java @@ -18,7 +18,7 @@ private void hookSetSetting(String par1, IArgConsumer par2, CallbackInfo ci, @Lo var onChangeListener = ModuleBaritoneKt.getControlledBaritoneSettings() .getOrDefault(setting, null); - if(onChangeListener != null) { + if (onChangeListener != null) { onChangeListener.invoke(setting.value); } }