Skip to content

Commit 569f3ce

Browse files
authored
Fix: Bounce elytra fly on 1.21.11 2b2t (#334)
1 parent 001863a commit 569f3ce

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class BounceElytraFly(
9797

9898
@Group(BOUNCE_OBSTACLE_PASSER_GROUP) override val passerConfig by c.configBlock(PasserSettings(c))
9999

100-
private var jumpThisTick = false
100+
private var wantJump = false
101101
private var prevGliding: Boolean? = null
102102
private val pauseTimer = TickTimer()
103103
private val pingPackets = ConcurrentLinkedQueue<CommonPingS2CPacket>()
@@ -122,6 +122,7 @@ class BounceElytraFly(
122122
init {
123123
listen<TickEvent.Pre> {
124124
pauseTimer.tick()
125+
wantJump = false
125126

126127
if (autoPitch) {
127128
rotationRequest {
@@ -162,8 +163,10 @@ class BounceElytraFly(
162163

163164
if (!player.isGliding) {
164165
if (takeoff && player.canTakeoff) {
165-
if (player.canStartGliding) GlideHandler.onGlide()
166-
else {
166+
if (player.canStartGliding) {
167+
GlideHandler.onGlide()
168+
wantJump = jump
169+
} else {
167170
val yawRad = Math.toRadians(player.yaw.toDouble())
168171
val rightX = -cos(yawRad)
169172
val rightZ = -sin(yawRad)
@@ -172,14 +175,16 @@ class BounceElytraFly(
172175
val sidewaysSpeed = abs(vx * rightX + vz * rightZ)
173176
if (sidewaysSpeed >= 0.001) return@listen
174177

175-
jumpThisTick = true
178+
wantJump = true
176179
}
177180
}
178181
return@listen
179182
}
180183

184+
if (player.isOnGround) wantJump = jump
181185
if (minimizePackets && player.getFlag(Entity.GLIDING_FLAG_INDEX) && !fakeFly && !yMotion) return@listen
182-
186+
if (player.isOnGround) return@listen
187+
183188
flyOrFakeFly()
184189
}
185190

@@ -210,8 +215,7 @@ class BounceElytraFly(
210215
sneakRight = false
211216
return@listen
212217
}
213-
if ((!player.isGliding || !jump) && !jumpThisTick) return@listen
214-
jumpThisTick = false
218+
if (!wantJump) return@listen
215219
if (flightPaused) return@listen
216220
input.jump()
217221
}
@@ -235,7 +239,7 @@ class BounceElytraFly(
235239
onFlag { pauseTimer.reset() }
236240

237241
onDisable {
238-
jumpThisTick = false
242+
wantJump = false
239243
prevGliding = false
240244
flushPackets()
241245
sneakLeft = false

0 commit comments

Comments
 (0)