feat: Add auto jump (disabled by default for PC & Gamepad users) (#100)
This commit is contained in:
parent
954169d1b9
commit
10662bcbc0
5 changed files with 442 additions and 145 deletions
|
|
@ -30,6 +30,7 @@
|
|||
"@dimaka/interface": "0.0.3-alpha.0",
|
||||
"@floating-ui/react": "^0.26.1",
|
||||
"@mui/base": "5.0.0-beta.34",
|
||||
"@nxg-org/mineflayer-auto-jump": "^0.7.5",
|
||||
"@nxg-org/mineflayer-tracker": "^1.2.1",
|
||||
"@react-oauth/google": "^0.12.1",
|
||||
"@types/gapi": "^0.0.47",
|
||||
|
|
@ -136,6 +137,7 @@
|
|||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"@nxg-org/mineflayer-physics-util": "1.5.8",
|
||||
"three": "0.154.0",
|
||||
"diamond-square": "github:zardoy/diamond-square",
|
||||
"prismarine-block": "github:zardoy/prismarine-block#next-era",
|
||||
|
|
|
|||
546
pnpm-lock.yaml
generated
546
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,39 @@
|
|||
import { Entity } from 'prismarine-entity'
|
||||
import tracker from '@nxg-org/mineflayer-tracker'
|
||||
import { loader as autoJumpPlugin } from '@nxg-org/mineflayer-auto-jump'
|
||||
import { subscribeKey } from 'valtio/utils'
|
||||
import { options, watchValue } from './optionsStorage'
|
||||
import { miscUiState } from './globalState'
|
||||
|
||||
|
||||
const updateAutoJump = () => {
|
||||
if (!bot?.autoJumper) return
|
||||
const autoJump = options.autoJump === 'auto' ? miscUiState.currentTouch && !miscUiState.usingGamepadInput : options.autoJump === 'always'
|
||||
bot.autoJumper.setOpts({
|
||||
jumpIntoWater: false,
|
||||
jumpOnAllEdges: false,
|
||||
// strictBlockCollision: true,
|
||||
})
|
||||
if (autoJump) {
|
||||
bot.autoJumper.enable()
|
||||
} else {
|
||||
bot.autoJumper.disable()
|
||||
}
|
||||
}
|
||||
subscribeKey(options, 'autoJump', () => {
|
||||
updateAutoJump()
|
||||
})
|
||||
subscribeKey(miscUiState, 'usingGamepadInput', () => {
|
||||
updateAutoJump()
|
||||
})
|
||||
subscribeKey(miscUiState, 'currentTouch', () => {
|
||||
updateAutoJump()
|
||||
})
|
||||
|
||||
customEvents.on('gameLoaded', () => {
|
||||
bot.loadPlugin(tracker)
|
||||
bot.loadPlugin(autoJumpPlugin)
|
||||
updateAutoJump()
|
||||
|
||||
// todo cleanup (move to viewer, also shouldnt be used at all)
|
||||
const playerPerAnimation = {} as Record<string, string>
|
||||
|
|
@ -13,6 +43,7 @@ customEvents.on('gameLoaded', () => {
|
|||
window.debugEntityMetadata[e.username] = e
|
||||
// todo entity spawn timing issue, check perf
|
||||
if (viewer.entities.entities[e.id]?.playerObject) {
|
||||
// todo throttle!
|
||||
bot.tracker.trackEntity(e)
|
||||
const { playerObject } = viewer.entities.entities[e.id]
|
||||
playerObject.backEquipment = e.equipment.some((item) => item?.name === 'elytra') ? 'elytra' : 'cape'
|
||||
|
|
|
|||
|
|
@ -208,6 +208,13 @@ export const guiOptionsScheme: {
|
|||
touchControlsType: {
|
||||
values: [['classic', 'Classic'], ['joystick-buttons', 'New']],
|
||||
},
|
||||
autoJump: {
|
||||
values: [
|
||||
'always',
|
||||
'auto',
|
||||
'never'
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
custom () {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ const defaultOptions = {
|
|||
showCursorBlockInSpectator: false,
|
||||
renderEntities: true,
|
||||
chatSelect: false,
|
||||
autoJump: 'auto' as 'auto' | 'always' | 'never',
|
||||
|
||||
// advanced bot options
|
||||
autoRespawn: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue