@@ -39,6 +39,7 @@ import com.lambda.util.PacketUtils.handlePacketSilently
3939import com.lambda.util.PacketUtils.sendPacketSilently
4040import com.lambda.util.SpeedUnit
4141import com.lambda.util.TickTimer
42+ import com.lambda.util.math.dist
4243import com.lambda.util.math.distSq
4344import com.lambda.util.math.minus
4445import 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
0 commit comments