Skip to content

Commit

Permalink
feat: add zoom keybinding (Key - C)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Dec 18, 2024
1 parent bf676cd commit db7a9b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const contro = new ControMax({
chat: [['KeyT', 'Enter']],
command: ['Slash'],
swapHands: ['KeyF'],
zoom: ['KeyC'],
selectItem: ['KeyH'] // default will be removed
},
ui: {
Expand Down Expand Up @@ -282,6 +283,9 @@ const onTriggerOrReleased = (command: Command, pressed: boolean) => {
case 'general.interactPlace':
document.dispatchEvent(new MouseEvent(pressed ? 'mousedown' : 'mouseup', { button: 2 }))
break
case 'general.zoom':
gameAdditionalState.isZooming = pressed
break
}
}
}
Expand Down Expand Up @@ -415,6 +419,8 @@ contro.on('trigger', ({ command }) => {
case 'general.prevHotbarSlot':
cycleHotbarSlot(-1)
break
case 'general.zoom':
break
}
}

Expand Down
1 change: 1 addition & 0 deletions src/globalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const gameAdditionalState = proxy({
isFlying: false,
isSprinting: false,
isSneaking: false,
isZooming: false,
warps: [] as WorldWarp[]
})

Expand Down
3 changes: 2 additions & 1 deletion src/rendererUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { options } from './optionsStorage'
export const watchFov = () => {
const updateFov = () => {
if (!bot) return
let fovSetting = options.fov
let fovSetting = gameAdditionalState.isZooming ? 30 : options.fov
// todo check values and add transition
if (bot.controlState.sprint && !bot.controlState.sneak) {
fovSetting += 5
Expand All @@ -20,6 +20,7 @@ export const watchFov = () => {
subscribeKey(options, 'fov', updateFov)
subscribeKey(gameAdditionalState, 'isFlying', updateFov)
subscribeKey(gameAdditionalState, 'isSprinting', updateFov)
subscribeKey(gameAdditionalState, 'isZooming', updateFov)
subscribeKey(gameAdditionalState, 'isSneaking', () => {
viewer.isSneaking = gameAdditionalState.isSneaking
viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
Expand Down

0 comments on commit db7a9b9

Please sign in to comment.