Skip to content

Commit

Permalink
fix: deactivate mouse buttons when window loses focus (edge case)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 29, 2025
1 parent 1f5404b commit a628f64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/worldInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,16 @@ class WorldInteraction {
}
}

beforeUpdateChecks () {
if (!document.hasFocus()) {
// deactive all buttson
this.buttons.fill(false)
}
}

// todo this shouldnt be done in the render loop, migrate the code to dom events to avoid delays on lags
update () {
this.beforeUpdateChecks()
const inSpectator = bot.game.gameMode === 'spectator'
const inAdventure = bot.game.gameMode === 'adventure'
const entity = getEntityCursor()
Expand Down

0 comments on commit a628f64

Please sign in to comment.