Skip to content

Commit 8bf358d

Browse files
committed
should fix a couple major bounce efly bugs. Prevents jump glide spam when correcting y motion and flagging when gliding after flagging once due to desynced pitch. Should also un-sneak when stuck on an edge to drop down for a tick
1 parent 95270ce commit 8bf358d

5 files changed

Lines changed: 34 additions & 16 deletions

File tree

src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@
5050
import org.spongepowered.asm.mixin.Mixin;
5151
import org.spongepowered.asm.mixin.injection.At;
5252
import org.spongepowered.asm.mixin.injection.Inject;
53+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
5354
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
5455

5556
import java.util.Objects;
5657

5758
import static com.lambda.Lambda.getMc;
59+
import static com.lambda.interaction.managers.rotating.Rotation.dist;
5860

5961
@Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE)
6062
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity {
@@ -131,6 +133,12 @@ private void wrapSendPacket(ClientPlayNetworkHandler instance, Packet<?> packet,
131133
original.call(instance, event.getPacket());
132134
}
133135

136+
@ModifyVariable(method = "sendMovementPackets", at = @At(value = "STORE"), ordinal = 1)
137+
private boolean modifyBl2(boolean original) {
138+
boolean rotationMismatch = dist(RotationManager.getActiveRotation(), RotationManager.getServerRotation()) > 0.00001;
139+
return original || rotationMismatch;
140+
}
141+
134142
@Inject(method = "sendMovementPackets", at = @At("TAIL"))
135143
private void injectSendMovementPacketsReturn(CallbackInfo ci) {
136144
if (!BaritoneHandler.isActive()) { RotationManager.onRotationSend(); }

src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import kotlin.math.cos
3636
import kotlin.math.hypot
3737
import kotlin.math.sin
3838

39+
@Suppress("unused")
3940
data class Rotation(val yaw: Double, val pitch: Double) {
4041
constructor(yaw: Float, pitch: Float) : this(yaw.toDouble(), pitch.toDouble())
4142

@@ -158,6 +159,7 @@ data class Rotation(val yaw: Double, val pitch: Double) {
158159
return Rotation(yaw, pitch)
159160
}
160161

162+
@JvmStatic
161163
infix fun Rotation.dist(b: Rotation) =
162164
hypot(
163165
wrap(yaw - b.yaw),

src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ object RotationManager : Manager<RotationRequest>(
102102
mc.crosshairTarget = blockHit
103103
}
104104

105-
listen<PacketEvent.Receive.Post>({ Int.MIN_VALUE }) { event ->
105+
//FixMe: PacketEvent.Receive.Post doesn't work here for some reason, it just never triggers
106+
listen<PacketEvent.Receive.Pre>({ Int.MIN_VALUE }) { event ->
106107
val packet = event.packet
107108
if (packet !is PlayerPositionLookS2CPacket) return@listen
108109

src/main/kotlin/com/lambda/module/modules/movement/elytrafly/modes/BounceElytraFly.kt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.lambda.util.PacketUtils.handlePacketSilently
3939
import com.lambda.util.PacketUtils.sendPacketSilently
4040
import com.lambda.util.SpeedUnit
4141
import com.lambda.util.TickTimer
42+
import com.lambda.util.math.dist
4243
import com.lambda.util.math.distSq
4344
import com.lambda.util.math.minus
4445
import com.lambda.util.player.PlayerUtils.canStartGliding
@@ -67,7 +68,7 @@ class BounceElytraFly(
6768

6869
private val takeoff by c.setting("Takeoff", true, "Automatically jumps and initiates gliding")
6970
private val autoPitch by c.setting("Auto Pitch", true, "Automatically pitches the players rotation down to bounce at faster speeds")
70-
private val pitch by c.setting("Pitch", 80.0, -90.0..90.0, 0.000001) { autoPitch }
71+
private val pitch by c.setting("Pitch", 72.0, -90.0..90.0, 0.000001) { autoPitch }
7172
private val jump by c.setting("Jump", true, "Automatically jumps")
7273
private val flagPause by c.setting("FlagPause Pause", 5, 0..100, 1, "How long to pause if the server flags you for a movement check", "ticks")
7374
private val minimizePackets by c.setting("Minimize Packets", true, "Shrinks the amount of start fly packets sent to the server as much as possible")
@@ -104,6 +105,9 @@ class BounceElytraFly(
104105
private var sneakRight = false
105106
private var interrupting = false
106107

108+
private val paused
109+
get() = !pauseTimer.hasSurpassed(flagPause)
110+
107111
private val SafeContext.queuePackets
108112
get() = fakeLag && player.isGliding && (!yMotionSetting || !onYMotionAngle) &&
109113
player.y - startPos.y < if (passerConfig.passObstacles) passerConfig.minObstacleHeight + 0.1 else 0.163
@@ -122,16 +126,20 @@ class BounceElytraFly(
122126

123127
if (handlePassingObstacles()) return@listen
124128

125-
if (yMotionSetting && strictYMotionRange && onYMotionAngle && player.isOnGround) {
129+
if (yMotionSetting && strictYMotionRange && onYMotionAngle) run yMotionCorrection@ {
130+
val playerPos = player.pos
131+
val validDistanceFromStart = Vec3d(playerPos.x, startPos.y, playerPos.z) dist startPos > 0.1
132+
if (!validDistanceFromStart) return@yMotionCorrection
133+
126134
val snappedDir = getSnappedDir()
127-
val closestLinePoint = player.pos.findClosestPointOnLine(snappedDir)
135+
val closestLinePoint = playerPos.findClosestPointOnLine(snappedDir)
128136
val xz = Vec3d(player.x, closestLinePoint.y, player.z)
129137
if (xz distSq closestLinePoint > acceptableYMotionRange.pow(2)) {
130138
if (player.isGliding) {
131139
interrupt()
132140
return@listen
133141
}
134-
val offset = player.pos - startPos
142+
val offset = playerPos - startPos
135143
val cross = snappedDir.x * offset.z - snappedDir.z * offset.x
136144
val rotationRequest = rotationRequest {
137145
val yawAndPitch = snappedDir.yawAndPitch
@@ -144,7 +152,7 @@ class BounceElytraFly(
144152
}
145153
}
146154

147-
if (!pauseTimer.hasSurpassed(flagPause)) return@listen
155+
if (paused) return@listen
148156

149157
if (!player.isGliding) {
150158
if (takeoff && player.canTakeoff) {
@@ -176,9 +184,9 @@ class BounceElytraFly(
176184
listen<MovementEvent.InputUpdate> { event ->
177185
val input = event.input
178186
val playerInput = input.playerInput
179-
val sneak = player.velocity.horizontal.length() > 0.001 || !player.isSneaking
180187

181188
if (sneakLeft || sneakRight) {
189+
val sneak = player.velocity.horizontal.length() > 0.001 || !player.isSneaking
182190
input.playerInput = PlayerInput(
183191
playerInput.forward,
184192
playerInput.backward,
@@ -196,10 +204,10 @@ class BounceElytraFly(
196204
sneakRight = false
197205
return@listen
198206
}
199-
if ((player.isGliding && !interrupting && jump) || jumpThisTick) {
200-
input.jump()
201-
jumpThisTick = false
202-
}
207+
if ((!player.isGliding || !jump) && !jumpThisTick) return@listen
208+
jumpThisTick = false
209+
if (paused || interrupting) return@listen
210+
input.jump()
203211
}
204212

205213
listen<PacketEvent.Send.Pre>({ 1 }) { event ->
@@ -255,7 +263,7 @@ class BounceElytraFly(
255263
val original: Boolean = player.getFlag(Entity.GLIDING_FLAG_INDEX)
256264
if (prevGliding == true &&
257265
!interrupting &&
258-
pauseTimer.hasSurpassed(flagPause) &&
266+
!paused &&
259267
!BaritoneHandler.isActive) true
260268
else {
261269
prevGliding = original

src/main/kotlin/com/lambda/module/modules/player/EndermanLook.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ object EndermanLook : Module(
5252
}
5353

5454
listen<TickEvent.Pre> {
55-
if (player.getEquippedStack(EquipmentSlot.HEAD).isOf(Items.CARVED_PUMPKIN)
56-
|| player.abilities.creativeMode
57-
|| (disableWhileGliding && player.isGliding)
58-
) return@listen
55+
if (player.getEquippedStack(EquipmentSlot.HEAD).isOf(Items.CARVED_PUMPKIN) ||
56+
player.abilities.creativeMode ||
57+
(disableWhileGliding && player.isGliding)) return@listen
5958

6059
val endermen = world.entities
6160
.filterIsInstance<EndermanEntity>()

0 commit comments

Comments
 (0)