Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Scaffold): GodBridge input backwards mode #5215

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,14 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) {
}

var currentOptimalLine: Line? = null
var rawInput = DirectionalInput.NONE

@Suppress("unused")
private val handleMovementInput = handler<MovementInputEvent> { event ->
private val handleMovementInput = handler<MovementInputEvent>(
priority = EventPriorityConvention.MODEL_STATE
) { event ->
this.currentOptimalLine = null
this.rawInput = event.directionalInput

val currentInput = event.directionalInput

Expand All @@ -373,6 +377,7 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) {

@Suppress("unused")
private val movementInputHandler = handler<MovementInputEvent>(
// Runs after the model state
priority = EventPriorityConvention.SAFETY_FEATURE
) { event ->
if (forceSneak > 0) {
Expand All @@ -388,26 +393,30 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) {
technique.activeChoice
}

val (jump, sneak, stepStop) = ledge(
val ledgeAction = ledge(
this.currentTarget,
RotationManager.currentRotation ?: player.rotation,
technique as? ScaffoldLedgeExtension
)
ModuleDebug.debugParameter(this, "Jump", jump.toString())
ModuleDebug.debugParameter(this, "Sneak", sneak.toString())
ModuleDebug.debugParameter(this, "StepStop", stepStop.toString())

if (jump) {
if (ledgeAction.jump) {
event.jump = true
}

if (stepStop) {
if (ledgeAction.stopInput) {
event.directionalInput = DirectionalInput.NONE
}

if (sneak > forceSneak) {
if (ledgeAction.stepBack) {
event.directionalInput = event.directionalInput.copy(
forwards = false,
backwards = true
)
}

if (ledgeAction.sneakTime > forceSneak) {
event.sneak = true
forceSneak = sneak
forceSneak = ledgeAction.sneakTime
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import kotlin.math.max
data class LedgeAction(
val jump: Boolean = false,
val sneakTime: Int = 0,
val stopInput: Boolean = false
val stopInput: Boolean = false,
val stepBack: Boolean = false
) {
companion object {
val NO_LEDGE = LedgeAction(jump = false, sneakTime = 0, stopInput = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import net.ccbluex.liquidbounce.config.types.NamedChoice
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold.getTargetedPosition
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold.rawInput
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.features.LedgeAction
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.features.ScaffoldLedgeExtension
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.techniques.ScaffoldNormalTechnique.NORMAL_INVESTIGATION_OFFSETS
Expand Down Expand Up @@ -54,6 +55,7 @@ object ScaffoldGodBridgeTechnique : ScaffoldTechnique("GodBridge"), ScaffoldLedg
* Might not be as consistent as the other modes.
*/
STOP_INPUT("StopInput"),
BACKWARDS("Backwards"),
RANDOM("Random")
}

Expand Down Expand Up @@ -106,6 +108,7 @@ object ScaffoldGodBridgeTechnique : ScaffoldTechnique("GodBridge"), ScaffoldLedg
mode == Mode.JUMP -> LedgeAction(jump = true)
mode == Mode.SNEAK -> LedgeAction(sneakTime = [email protected])
mode == Mode.STOP_INPUT -> LedgeAction(stopInput = true)
mode == Mode.BACKWARDS -> LedgeAction(stepBack = true)
mode == Mode.RANDOM -> if (Random.nextBoolean()) {
LedgeAction(jump = true, sneakTime = 0)
} else {
Expand Down Expand Up @@ -140,15 +143,13 @@ object ScaffoldGodBridgeTechnique : ScaffoldTechnique("GodBridge"), ScaffoldLedg
}

override fun getRotations(target: BlockPlacementTarget?): Rotation? {
val dirInput = DirectionalInput(player.input)

if (dirInput == DirectionalInput.NONE) {
if (rawInput == DirectionalInput.NONE) {
target ?: return null

return getRotationForNoInput(target)
}

val direction = getMovementDirectionOfInput(player.yaw, dirInput) + 180
val direction = getMovementDirectionOfInput(player.yaw, rawInput) + 180

// Round to 45°-steps (NORTH, NORTH_EAST, etc.)
val movingYaw = round(direction / 45) * 45
Expand Down
Loading