Skip to content

Commit e7d4332

Browse files
committed
Fix scaffold raycast, godbridge movement, and silent placement issues/ Add fake spoof autoblock mode and restore scaffold sprint without omni sprint
1 parent 747d6b8 commit e7d4332

2 files changed

Lines changed: 100 additions & 24 deletions

File tree

  • src/main/java/net/ccbluex/liquidbounce/features/module/modules

src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Sprint.kt

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ object Sprint : Module("Sprint", Category.MOVEMENT, Category.SubCategory.MOVEMEN
5252

5353
fun correctSprintState(movementInput: MovementInput, isUsingItem: Boolean) {
5454
val player = mc.thePlayer ?: return
55+
val scaffoldActive = Scaffold.handleEvents()
56+
val scaffoldControlsSprint = scaffoldActive && Scaffold.sprint
5557

5658
if (SuperKnockback.breakSprint()) {
5759
player setSprintSafely false
5860
return
5961
}
6062

61-
if (!handleEvents() || onlyOnSprintPress && !player.isSprinting && !mc.gameSettings.keyBindSprint.isKeyDown && !SuperKnockback.startSprint() && !isSprinting)
62-
return
63-
64-
if (Scaffold.handleEvents()) {
63+
if (scaffoldActive) {
6564
if (!Scaffold.sprint) {
6665
player setSprintSafely false
6766
isSprinting = false
@@ -79,10 +78,28 @@ object Sprint : Module("Sprint", Category.MOVEMENT, Category.SubCategory.MOVEMEN
7978
isSprinting = true
8079
return
8180
}
81+
82+
val ignoreDirectionCheck = scaffoldControlsSprint && mode == "Vanilla"
83+
84+
player setSprintSafely !shouldStopSprinting(movementInput, isUsingItem, ignoreDirectionCheck)
85+
isSprinting = player.isSprinting
86+
87+
if (player.isSprinting && mode != "Legit") {
88+
if (!allDirectionsLimitSpeedGround || player.onGround) {
89+
player.motionX *= allDirectionsLimitSpeed
90+
player.motionZ *= allDirectionsLimitSpeed
91+
}
92+
}
93+
return
8294
}
8395

96+
if (!handleEvents() || onlyOnSprintPress && !player.isSprinting && !mc.gameSettings.keyBindSprint.isKeyDown && !SuperKnockback.startSprint() && !isSprinting)
97+
return
98+
99+
val ignoreDirectionCheck = Scaffold.handleEvents() && Scaffold.sprint && Scaffold.canSprint && mode == "Vanilla"
100+
84101
if (handleEvents() || alwaysCorrect) {
85-
player setSprintSafely !shouldStopSprinting(movementInput, isUsingItem)
102+
player setSprintSafely !shouldStopSprinting(movementInput, isUsingItem, ignoreDirectionCheck)
86103
isSprinting = player.isSprinting
87104

88105
if (player.isSprinting && allDirections && mode != "Legit") {
@@ -94,7 +111,7 @@ object Sprint : Module("Sprint", Category.MOVEMENT, Category.SubCategory.MOVEMEN
94111
}
95112
}
96113

97-
private fun shouldStopSprinting(movementInput: MovementInput, isUsingItem: Boolean): Boolean {
114+
private fun shouldStopSprinting(movementInput: MovementInput, isUsingItem: Boolean, ignoreDirectionCheck: Boolean = false): Boolean {
98115
val player = mc.thePlayer ?: return false
99116

100117
val isLegitModeActive = mode == "Legit"
@@ -129,6 +146,10 @@ object Sprint : Module("Sprint", Category.MOVEMENT, Category.SubCategory.MOVEMEN
129146
return true
130147
}
131148

149+
if (ignoreDirectionCheck) {
150+
return false
151+
}
152+
132153
if (isLegitModeActive) {
133154
return modifiedForward < 0.8
134155
}

src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/scaffolds/Scaffold.kt

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
8989
) { extraClicks }
9090

9191
// Autoblock
92-
private val autoBlock by choices("AutoBlock", arrayOf("Off", "Pick", "Spoof", "Switch"), "Spoof")
92+
private val autoBlock by choices("AutoBlock", arrayOf("Off", "Pick", "Spoof", "FakeSpoof", "Switch"), "Spoof")
9393
private val sortByHighestAmount by boolean("SortByHighestAmount", false) { autoBlock != "Off" }
9494
private val earlySwitch by boolean("EarlySwitch", false) { autoBlock != "Off" && !sortByHighestAmount }
9595
private val amountBeforeSwitch by int(
@@ -352,6 +352,18 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
352352
return isYawDiagonal && (isMovingDiagonal || isStrafing)
353353
}
354354

355+
private fun isHalfBlockLevel(y: Double) = abs(y - floor(y) - 0.5) <= 1E-3
356+
357+
private fun isUsableBlockStack(stack: ItemStack?, fullCubeOnly: Boolean = false): Boolean {
358+
val itemBlock = stack?.item as? ItemBlock ?: return false
359+
val block = itemBlock.block
360+
361+
return stack.stackSize > 0
362+
&& block !in InventoryUtils.BLOCK_BLACKLIST
363+
&& block !is BlockBush
364+
&& (!fullCubeOnly || block.isFullCube)
365+
}
366+
355367
// Telly
356368
private var ticksUntilJump = 0
357369
private var blocksUntilAxisChange = 0
@@ -369,6 +381,10 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
369381

370382
launchY = player.posY.roundToInt()
371383
blocksUntilAxisChange = 0
384+
blocksPlacedUntilJump = 0
385+
blocksToJump = blocksToJumpRange.random()
386+
godBridgeTargetRotation = null
387+
placeRotation = null
372388
}
373389

374390
// Events
@@ -592,7 +608,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
592608
}
593609

594610
raycast.let {
595-
if (!currentRotationsActive || it != null && it.blockPos == target.blockPos && (!raycastProperly || it.sideHit == target.enumFacing)) {
611+
if (!currentRotationsActive || it != null && it.typeOfHit.isBlock && it.blockPos == target.blockPos && (!raycastProperly || it.sideHit == target.enumFacing)) {
596612
val result = if (raycastProperly && it != null) {
597613
PlaceInfo(it.blockPos, it.sideHit, it.hitVec)
598614
} else {
@@ -631,12 +647,24 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
631647

632648
simPlayer.tick()
633649

634-
if (!simPlayer.onGround && !isManualJumpOptionActive || blocksPlacedUntilJump > blocksToJump) {
650+
val shouldTriggerMovement = if (isManualJumpOptionActive) {
651+
blocksPlacedUntilJump >= blocksToJump
652+
} else {
653+
!simPlayer.onGround
654+
}
655+
656+
if (shouldTriggerMovement) {
657+
val shouldAvoidJump = isLookingDiagonally
658+
635659
when (godbridgeMovementMode) {
636-
"Jump" -> event.originalInput.jump = true
660+
"Jump" -> if (shouldAvoidJump) {
661+
event.originalInput.sneak = true
662+
} else {
663+
event.originalInput.jump = true
664+
}
637665
"Sneak" -> event.originalInput.sneak = true
638666
"Both" -> {
639-
if (RandomUtils.nextBoolean()) {
667+
if (!shouldAvoidJump && RandomUtils.nextBoolean()) {
640668
event.originalInput.jump = true
641669
} else {
642670
event.originalInput.sneak = true
@@ -654,6 +682,8 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
654682
val player = mc.thePlayer ?: return
655683
val holdingItem = player.heldItem?.item is ItemBlock
656684

685+
placeRotation = null
686+
657687
if (!holdingItem && (autoBlock == "Off" || InventoryUtils.findBlockInHotbar() == null)) {
658688
return
659689
}
@@ -680,14 +710,14 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
680710
if (!shouldKeepLaunchPosition) launchY = player.posY.roundToInt()
681711

682712
val blockPosition = if (shouldGoDown) {
683-
if (player.posY == player.posY.roundToInt() + 0.5) {
713+
if (isHalfBlockLevel(player.posY)) {
684714
BlockPos(player.posX, player.posY - 0.6, player.posZ)
685715
} else {
686716
BlockPos(player.posX, player.posY - 0.6, player.posZ).down()
687717
}
688718
} else if (shouldKeepLaunchPosition && launchY <= player.posY) {
689719
BlockPos(player.posX, launchY - 1.0, player.posZ)
690-
} else if (player.posY == player.posY.roundToInt() + 0.5) {
720+
} else if (isHalfBlockLevel(player.posY)) {
691721
BlockPos(player)
692722
} else {
693723
BlockPos(player).down()
@@ -740,8 +770,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
740770

741771
var stack = player.hotBarSlot(currentSlot).stack
742772

743-
//TODO: blacklist more blocks than only bushes
744-
if (stack == null || stack.item !is ItemBlock || (stack.item as ItemBlock).block is BlockBush || stack.stackSize <= 0 || sortByHighestAmount || earlySwitch) {
773+
if (!isUsableBlockStack(stack) || sortByHighestAmount || earlySwitch) {
745774
val blockSlot = if (sortByHighestAmount) {
746775
InventoryUtils.findLargestBlockStackInHotbar() ?: return
747776
} else if (earlySwitch) {
@@ -762,7 +791,13 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
762791
}
763792

764793
if (autoBlock != "Off") {
765-
SilentHotbar.selectSlotSilently(this, blockSlot, render = autoBlock == "Pick", resetManually = true)
794+
SilentHotbar.selectSlotSilently(
795+
this,
796+
blockSlot,
797+
render = autoBlock in arrayOf("Pick", "FakeSpoof"),
798+
renderFirstPerson = autoBlock == "Pick",
799+
resetManually = true
800+
)
766801
}
767802
}
768803

@@ -852,6 +887,8 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
852887
}
853888

854889
placeRotation = null
890+
godBridgeTargetRotation = null
891+
blocksPlacedUntilJump = 0
855892
mc.timer.timerSpeed = 1f
856893

857894
SilentHotbar.resetSlot(this)
@@ -915,7 +952,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
915952
val z = if (omniDirectionalExpand) cos(yaw).roundToInt() else player.horizontalFacing.directionVec.z
916953
val blockPos = BlockPos(
917954
player.posX + x * it,
918-
if (shouldKeepLaunchPosition && launchY <= player.posY) launchY - 1.0 else player.posY - (if (player.posY == player.posY + 0.5) 0.0 else 1.0) - if (shouldGoDown) 1.0 else 0.0,
955+
if (shouldKeepLaunchPosition && launchY <= player.posY) launchY - 1.0 else player.posY - (if (isHalfBlockLevel(player.posY)) 0.0 else 1.0) - if (shouldGoDown) 1.0 else 0.0,
919956
player.posZ + z * it
920957
)
921958
val placeInfo = PlaceInfo.get(blockPos)
@@ -1045,8 +1082,15 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
10451082

10461083
val distance = eyes.distanceTo(vec)
10471084

1048-
if (raycast && (distance > maxReach || world.rayTraceBlocks(eyes, vec, false, true, false) != null)) {
1049-
return null
1085+
if (raycast) {
1086+
if (distance > maxReach) {
1087+
return null
1088+
}
1089+
1090+
val visibilityTrace = world.rayTraceBlocks(eyes, vec, false, false, true)
1091+
if (visibilityTrace != null && (!visibilityTrace.typeOfHit.isBlock || visibilityTrace.blockPos != offsetPos || visibilityTrace.sideHit != side.opposite)) {
1092+
return null
1093+
}
10501094
}
10511095

10521096
val diff = vec - eyes
@@ -1065,7 +1109,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
10651109

10661110
// If the current rotation already looks at the target block and side, then return right here
10671111
performBlockRaytrace(currRotation, maxReach)?.let { raytrace ->
1068-
if (raytrace.blockPos == offsetPos && (!raycast || raytrace.sideHit == side.opposite)) {
1112+
if (raytrace.typeOfHit.isBlock && raytrace.blockPos == offsetPos && (!raycast || raytrace.sideHit == side.opposite)) {
10691113
return PlaceRotation(
10701114
PlaceInfo(
10711115
raytrace.blockPos, side.opposite, modifyVec(raytrace.hitVec, side, Vec3(offsetPos), !raycast)
@@ -1078,7 +1122,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
10781122

10791123
val multiplier = if (options.legitimize) 3 else 1
10801124

1081-
if (raytrace.blockPos == offsetPos && (!raycast || raytrace.sideHit == side.opposite) && canUpdateRotation(
1125+
if (raytrace.typeOfHit.isBlock && raytrace.blockPos == offsetPos && (!raycast || raytrace.sideHit == side.opposite) && canUpdateRotation(
10821126
currRotation, rotationForPlacement, multiplier
10831127
)
10841128
) {
@@ -1128,7 +1172,13 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
11281172
InventoryUtils.findBlockInHotbar()
11291173
} ?: return
11301174

1131-
SilentHotbar.selectSlotSilently(this, switchSlot, render = autoBlock == "Pick", resetManually = true)
1175+
SilentHotbar.selectSlotSilently(
1176+
this,
1177+
switchSlot,
1178+
render = autoBlock in arrayOf("Pick", "FakeSpoof"),
1179+
renderFirstPerson = autoBlock == "Pick",
1180+
resetManually = true
1181+
)
11321182
}
11331183

11341184
private fun updatePlacedBlocksForTelly() {
@@ -1150,6 +1200,7 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
11501200
val thePlayer = mc.thePlayer ?: return false
11511201

11521202
val prevSize = stack.stackSize
1203+
val suppressFirstPersonSwitchAnimation = autoBlock == "FakeSpoof" && SilentHotbar.isSlotModified(this)
11531204

11541205
val motionSprintActive = sprint && sprintMode == "MotionSprint" && thePlayer.isMoving
11551206
if (motionSprintActive) {
@@ -1182,15 +1233,19 @@ object Scaffold : Module("Scaffold", Category.PLAYER, Category.SubCategory.PLAYE
11821233
if (stack.stackSize <= 0) {
11831234
thePlayer.inventory.mainInventory[SilentHotbar.currentSlot] = null
11841235
ForgeEventFactory.onPlayerDestroyItem(thePlayer, stack)
1185-
} else if (stack.stackSize != prevSize || mc.playerController.isInCreativeMode) mc.entityRenderer.itemRenderer.resetEquippedProgress()
1236+
} else if (!suppressFirstPersonSwitchAnimation && (stack.stackSize != prevSize || mc.playerController.isInCreativeMode)) {
1237+
mc.entityRenderer.itemRenderer.resetEquippedProgress()
1238+
}
11861239

11871240
placeRotation = null
11881241

11891242
placedBlocksWithoutEagle++
11901243

11911244
onSuccess()
11921245
} else {
1193-
if (thePlayer.sendUseItem(stack)) mc.entityRenderer.itemRenderer.resetEquippedProgress2()
1246+
if (thePlayer.sendUseItem(stack) && !suppressFirstPersonSwitchAnimation) {
1247+
mc.entityRenderer.itemRenderer.resetEquippedProgress2()
1248+
}
11941249
}
11951250

11961251
return clickedSuccessfully

0 commit comments

Comments
 (0)