Skip to content

Commit 2da6ef5

Browse files
committed
FIX CLIENT fix flying state desync issue
1 parent 4c22d6a commit 2da6ef5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/controls.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ document.addEventListener('keydown', (e) => {
751751
capture: true,
752752
})
753753

754-
const isFlying = () => (bot.entity as any).flying
754+
const isFlying = () => (bot as any).physicsEngineCtx?.state?.flying ?? false
755755

756756
const startFlying = (sendAbilities = true) => {
757757
if (sendAbilities) {
@@ -783,9 +783,16 @@ const toggleFly = (newState = !isFlying(), sendAbilities?: boolean) => {
783783
} else {
784784
endFlying(sendAbilities)
785785
}
786-
gameAdditionalState.isFlying = isFlying()
787786
}
788787

788+
const physicsFlyingCheck = () => {
789+
bot.on('physicsTick', () => {
790+
gameAdditionalState.isFlying = isFlying()
791+
})
792+
}
793+
794+
customEvents.on('gameLoaded', physicsFlyingCheck)
795+
789796
const selectItem = async () => {
790797
const block = bot.blockAtCursor(5)
791798
if (!block) return

0 commit comments

Comments
 (0)