diff --git a/config.json b/config.json index b1103ed8b..6d8284a5c 100644 --- a/config.json +++ b/config.json @@ -7,9 +7,8 @@ "peerJsServerFallback": "https://p2p.mcraft.fun", "promoteServers": [ { - "ip": "kaboom.pw", - "version": "1.20.3", - "description": "Very nice a polite server. Must try for everyone!" + "ip": "grim.mcraft.fun", + "version": "1.19.4" } ] } diff --git a/package.json b/package.json index 1d2eb0625..3ef77437a 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "https-browserify": "^1.0.0", "mc-assets": "^0.2.28", "minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next", - "mineflayer": "github:zardoy/mineflayer", + "mineflayer": "github:GenerelSchwerz/mineflayer", "mineflayer-pathfinder": "^2.4.4", "npm-run-all": "^4.1.5", "os-browserify": "^0.3.0", @@ -169,8 +169,8 @@ }, "pnpm": { "overrides": { + "@nxg-org/mineflayer-physics-util": "latest", "buffer": "^6.0.3", - "@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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b6d752117..b196414cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,8 +5,8 @@ settings: excludeLinksFromLockfile: false overrides: + '@nxg-org/mineflayer-physics-util': latest buffer: ^6.0.3 - '@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 @@ -352,8 +352,8 @@ importers: specifier: github:zardoy/minecraft-inventory-gui#next version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/75e940a4cd50d89e0ba03db3733d5d704917a3c8(@types/react@18.2.20)(react@18.2.0) mineflayer: - specifier: github:zardoy/mineflayer - version: https://codeload.github.com/zardoy/mineflayer/tar.gz/54f8c2282d822ad02967a197bda36302a4e7b4a5(encoding@0.1.13) + specifier: github:GenerelSchwerz/mineflayer + version: https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/400ceb2bd0ff8d67d488d48c9dc94da5e6fcdc1a(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -1899,8 +1899,8 @@ packages: '@nxg-org/mineflayer-auto-jump@0.7.12': resolution: {integrity: sha512-F5vX/lerlWx/5HVlkDNbvrtQ19PL6iG8i4ItPTIRtjGiFzusDefP7DI226zSFR8Wlaw45qHv0jn814p/4/qVdQ==} - '@nxg-org/mineflayer-physics-util@1.5.8': - resolution: {integrity: sha512-KmCkAqpUo8BbuRdIBs6+V2hWHehz++PRz3lRwIsb47CuG0u4sgLYh37RY3ifAznC6uWvmPK+q3B4ZXwJzPy1MQ==} + '@nxg-org/mineflayer-physics-util@1.7.11': + resolution: {integrity: sha512-IUgIIEqopXuirM2ZI1+iPFdZQMs8/ckfsHS6634nEG4DpavnxG5NsfewJQgvVr+xxtndJ+eJpnrfMQul2d42iw==} '@nxg-org/mineflayer-tracker@1.2.1': resolution: {integrity: sha512-SI1ffF8zvg3/ZNE021Ja2W0FZPN+WbQDZf8yFqOcXtPRXAtM9W6HvoACdzXep8BZid7WYgYLIgjKpB+9RqvCNQ==} @@ -6479,8 +6479,8 @@ packages: resolution: {integrity: sha512-q7cmpZFaSI6sodcMJxc2GkV8IO84HbsUP+xNipGKfGg+FMISKabzdJ838Axb60qRtZrp6ny7LluQE7lesHvvxQ==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/54f8c2282d822ad02967a197bda36302a4e7b4a5: - resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/54f8c2282d822ad02967a197bda36302a4e7b4a5} + mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/400ceb2bd0ff8d67d488d48c9dc94da5e6fcdc1a: + resolution: {tarball: https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/400ceb2bd0ff8d67d488d48c9dc94da5e6fcdc1a} version: 4.25.0 engines: {node: '>=18'} @@ -7175,6 +7175,9 @@ packages: prismarine-entity@2.3.1: resolution: {integrity: sha512-HOv8l7IetHNf4hwZ7V/W4vM3GNl+e6VCtKDkH9h02TRq7jWngsggKtJV+VanCce/sNwtJUhJDjORGs728ep4MA==} + prismarine-entity@2.5.0: + resolution: {integrity: sha512-nRPCawUwf9r3iKqi4I7mZRlir1Ix+DffWYdWq6p/KNnmiXve+xHE5zv8XCdhZlUmOshugHv5ONl9o6ORAkCNIA==} + prismarine-item@1.16.0: resolution: {integrity: sha512-88Tz+/6HquYIsDuseae5G3IbqLeMews2L+ba2gX+p6K6soU9nuFhCfbwN56QuB7d/jZFcWrCYAPE5+UhwWh67w==} @@ -10926,10 +10929,10 @@ snapshots: '@nxg-org/mineflayer-auto-jump@0.7.12': dependencies: - '@nxg-org/mineflayer-physics-util': 1.5.8 + '@nxg-org/mineflayer-physics-util': 1.7.11 strict-event-emitter-types: 2.0.0 - '@nxg-org/mineflayer-physics-util@1.5.8': + '@nxg-org/mineflayer-physics-util@1.7.11': dependencies: '@nxg-org/mineflayer-util-plugin': 1.8.3 @@ -17027,15 +17030,16 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/54f8c2282d822ad02967a197bda36302a4e7b4a5(encoding@0.1.13): + mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/400ceb2bd0ff8d67d488d48c9dc94da5e6fcdc1a(encoding@0.1.13): dependencies: + '@nxg-org/mineflayer-physics-util': 1.7.11 minecraft-data: 3.83.1 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/e9eb551ba30ec2e742c49e6927be6402b413bb76(patch_hash=dkeyukcqlupmk563gwxsmjr3yu)(encoding@0.1.13) prismarine-biome: 1.3.0(minecraft-data@3.83.1)(prismarine-registry@1.11.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/853c559bff2b402863ee9a75b125a3ca320838f9(prismarine-registry@1.11.0) prismarine-chat: 1.10.1 prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/e68e9a423b5b1907535878fb636f12c28a1a9374(minecraft-data@3.83.1) - prismarine-entity: 2.3.1 + prismarine-entity: 2.5.0 prismarine-item: 1.16.0 prismarine-nbt: 2.5.0 prismarine-physics: https://codeload.github.com/zardoy/prismarine-physics/tar.gz/353e25b800149393f40539ec381218be44cbb03b @@ -17843,6 +17847,13 @@ snapshots: prismarine-registry: 1.11.0 vec3: 0.1.8 + prismarine-entity@2.5.0: + dependencies: + prismarine-chat: 1.10.1 + prismarine-item: 1.16.0 + prismarine-registry: 1.11.0 + vec3: 0.1.8 + prismarine-item@1.16.0: dependencies: prismarine-nbt: 2.5.0 diff --git a/src/controls.ts b/src/controls.ts index 0352a7e58..cc643bcc9 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -165,10 +165,10 @@ let lastCommandTrigger = null as { command: string, time: number } | null const secondActionActivationTimeout = 300 const secondActionCommands = { - 'general.jump' () { - // if (bot.game.gameMode === 'spectator') return - toggleFly() - }, + // 'general.jump' () { + // // if (bot.game.gameMode === 'spectator') return + // toggleFly() + // }, 'general.forward' () { setSprinting(true) } @@ -680,135 +680,135 @@ const makeInterval = (fn, interval) => { return cleanup } -const isFlying = () => bot.physics.gravity === 0 -let endFlyLoop: ReturnType | undefined +// const isFlying = () => bot.physics.gravity === 0 +// let endFlyLoop: ReturnType | undefined -const currentFlyVector = new Vec3(0, 0, 0) -window.currentFlyVector = currentFlyVector +// const currentFlyVector = new Vec3(0, 0, 0) +// window.currentFlyVector = currentFlyVector // todo cleanup -const flyingPressedKeys = { - down: false, - up: false -} +// const flyingPressedKeys = { +// down: false, +// up: false +// } -const startFlyLoop = () => { - if (!isFlying()) return - endFlyLoop?.() +// const startFlyLoop = () => { +// if (!isFlying()) return +// endFlyLoop?.() - endFlyLoop = makeInterval(() => { - if (!bot) { - endFlyLoop?.() - return - } +// endFlyLoop = makeInterval(() => { +// if (!bot) { +// endFlyLoop?.() +// return +// } - bot.entity.position.add(currentFlyVector.clone().multiply(new Vec3(0, 0.5, 0))) - }, 50) -} +// bot.entity.position.add(currentFlyVector.clone().multiply(new Vec3(0, 0.5, 0))) +// }, 50) +// } // todo we will get rid of patching it when refactor controls -let originalSetControlState -const patchedSetControlState = (action, state) => { - if (!isFlying()) { - return originalSetControlState(action, state) - } - - const actionPerFlyVector = { - jump: new Vec3(0, 1, 0), - sneak: new Vec3(0, -1, 0), - } - - const changeVec = actionPerFlyVector[action] - if (!changeVec) { - return originalSetControlState(action, state) - } - if (flyingPressedKeys[state === 'jump' ? 'up' : 'down'] === state) return - const toAddVec = changeVec.scaled(state ? 1 : -1) - for (const coord of ['x', 'y', 'z']) { - if (toAddVec[coord] === 0) continue - if (currentFlyVector[coord] === toAddVec[coord]) return - } - currentFlyVector.add(toAddVec) - flyingPressedKeys[state === 'jump' ? 'up' : 'down'] = state -} - -const startFlying = (sendAbilities = true) => { - bot.entity['creativeFly'] = true - if (sendAbilities) { - bot._client.write('abilities', { - flags: 2, - }) - } - // window.flyingSpeed will be removed - bot.physics['airborneAcceleration'] = window.flyingSpeed ?? 0.1 // todo use abilities - bot.entity.velocity = new Vec3(0, 0, 0) - bot.creative.startFlying() - startFlyLoop() -} - -const endFlying = (sendAbilities = true) => { - bot.entity['creativeFly'] = false - if (bot.physics.gravity !== 0) return - if (sendAbilities) { - bot._client.write('abilities', { - flags: 0, - }) - } - Object.assign(flyingPressedKeys, { - up: false, - down: false - }) - currentFlyVector.set(0, 0, 0) - bot.physics['airborneAcceleration'] = standardAirborneAcceleration - bot.creative.stopFlying() - endFlyLoop?.() -} - -let allowFlying = false +// let originalSetControlState +// const patchedSetControlState = (action, state) => { +// if (!isFlying()) { +// return originalSetControlState(action, state) +// } + +// const actionPerFlyVector = { +// jump: new Vec3(0, 1, 0), +// sneak: new Vec3(0, -1, 0), +// } + +// const changeVec = actionPerFlyVector[action] +// if (!changeVec) { +// return originalSetControlState(action, state) +// } +// if (flyingPressedKeys[state === 'jump' ? 'up' : 'down'] === state) return +// const toAddVec = changeVec.scaled(state ? 1 : -1) +// for (const coord of ['x', 'y', 'z']) { +// if (toAddVec[coord] === 0) continue +// if (currentFlyVector[coord] === toAddVec[coord]) return +// } +// currentFlyVector.add(toAddVec) +// flyingPressedKeys[state === 'jump' ? 'up' : 'down'] = state +// } + +// const startFlying = (sendAbilities = true) => { +// bot.entity['creativeFly'] = true +// if (sendAbilities) { +// bot._client.write('abilities', { +// flags: 2, +// }) +// } +// // window.flyingSpeed will be removed +// bot.physics['airborneAcceleration'] = window.flyingSpeed ?? 0.1 // todo use abilities +// bot.entity.velocity = new Vec3(0, 0, 0) +// bot.creative.startFlying() +// startFlyLoop() +// } + +// const endFlying = (sendAbilities = true) => { +// bot.entity['creativeFly'] = false +// if (bot.physics.gravity !== 0) return +// if (sendAbilities) { +// bot._client.write('abilities', { +// flags: 0, +// }) +// } +// Object.assign(flyingPressedKeys, { +// up: false, +// down: false +// }) +// currentFlyVector.set(0, 0, 0) +// bot.physics['airborneAcceleration'] = standardAirborneAcceleration +// bot.creative.stopFlying() +// endFlyLoop?.() +// } + +const allowFlying = false export const onBotCreate = () => { - let wasSpectatorFlying = false - bot._client.on('abilities', ({ flags }) => { - if (flags & 2) { // flying - toggleFly(true, false) - } else { - toggleFly(false, false) - } - allowFlying = !!(flags & 4) - }) - const gamemodeCheck = () => { - if (bot.game.gameMode === 'spectator') { - toggleFly(true, false) - wasSpectatorFlying = true - } else if (wasSpectatorFlying) { - toggleFly(false, false) - wasSpectatorFlying = false - } - } - bot.on('game', () => { - gamemodeCheck() - }) - bot.on('login', () => { - gamemodeCheck() - }) + // let wasSpectatorFlying = false + // bot._client.on('abilities', ({ flags }) => { + // if (flags & 2) { // flying + // toggleFly(true, false) + // } else { + // toggleFly(false, false) + // } + // allowFlying = !!(flags & 4) + // }) + // const gamemodeCheck = () => { + // if (bot.game.gameMode === 'spectator') { + // toggleFly(true, false) + // wasSpectatorFlying = true + // } else if (wasSpectatorFlying) { + // toggleFly(false, false) + // wasSpectatorFlying = false + // } + // } + // bot.on('game', () => { + // gamemodeCheck() + // }) + // bot.on('login', () => { + // gamemodeCheck() + // }) } -const standardAirborneAcceleration = 0.02 -const toggleFly = (newState = !isFlying(), sendAbilities?: boolean) => { - // if (bot.game.gameMode !== 'creative' && bot.game.gameMode !== 'spectator') return - if (!allowFlying) return - if (bot.setControlState !== patchedSetControlState) { - originalSetControlState = bot.setControlState - bot.setControlState = patchedSetControlState - } - - if (newState) { - startFlying(sendAbilities) - } else { - endFlying(sendAbilities) - } - gameAdditionalState.isFlying = isFlying() -} +// const standardAirborneAcceleration = 0.02 +// const toggleFly = (newState = !isFlying(), sendAbilities?: boolean) => { +// // if (bot.game.gameMode !== 'creative' && bot.game.gameMode !== 'spectator') return +// if (!allowFlying) return +// if (bot.setControlState !== patchedSetControlState) { +// originalSetControlState = bot.setControlState +// bot.setControlState = patchedSetControlState +// } + +// if (newState) { +// startFlying(sendAbilities) +// } else { +// endFlying(sendAbilities) +// } +// gameAdditionalState.isFlying = isFlying() +// } // #endregion const selectItem = async () => { diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index 12188a17b..005edfb38 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -53,7 +53,7 @@ const defaultOptions = { serverResourcePacks: 'prompt' as 'prompt' | 'always' | 'never', handDisplay: false, packetsLoggerPreset: 'all' as 'all' | 'no-buffers', - serversAutoVersionSelect: 'auto' as 'auto' | 'latest' | '1.20.4' | string, + serversAutoVersionSelect: '1.19.4' as 'auto' | 'latest' | '1.20.4' | string, // TODO! revert // antiAliasing: false, diff --git a/src/react/components/LibraryVersions.tsx b/src/react/components/LibraryVersions.tsx new file mode 100644 index 000000000..4ab76d09a --- /dev/null +++ b/src/react/components/LibraryVersions.tsx @@ -0,0 +1,38 @@ +import React from 'react' +import physicsUtilPkg from '@nxg-org/mineflayer-physics-util/package.json' +import mineflayerPkg from 'mineflayer/package.json' +import mcProtocolPkg from 'minecraft-protocol/package.json' +import packageJson from '../../../package.json' + +const LibraryVersions: React.FC = () => { + const versions = { + '@nxg-org/mineflayer-physics-util': physicsUtilPkg.version, + 'mineflayer': packageJson.devDependencies['mineflayer'], + 'minecraft-protocol': mcProtocolPkg.version + } + + return ( +
+
Library Versions:
+ {Object.entries(versions).map(([lib, version]) => ( +
+ {lib}: {version} +
+ ))} +
+ ) +} + +export default LibraryVersions diff --git a/src/reactUi.tsx b/src/reactUi.tsx index aa2f8fe42..54da8bd03 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -46,6 +46,7 @@ import BookProvider from './react/BookProvider' import { options } from './optionsStorage' import BossBarOverlayProvider from './react/BossBarOverlayProvider' import DebugEdges from './react/DebugEdges' +import LibraryVersions from './react/components/LibraryVersions' import GameInteractionOverlay from './react/GameInteractionOverlay' const RobustPortal = ({ children, to }) => { @@ -176,6 +177,7 @@ const App = () => {
+