up mcraft-fun-mineflayer support
This commit is contained in:
parent
71f63a3be0
commit
585b19d8dc
6 changed files with 46 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ For building the project yourself / contributing, see [Development, Debugging &
|
|||
|
||||
### Big Features
|
||||
|
||||
- Official Mineflayer [plugin integration](https://github.com/zardoy/mcraft-fun-mineflayer-plugin)! View / Control your bot remotely.
|
||||
- Open any zip world file or even folder in read-write mode!
|
||||
- Connect to Java servers running in both offline (cracked) and online mode* (it's possible because of proxy servers, see below)
|
||||
- Integrated JS server clone capable of opening Java world saves in any way (folders, zip, web chunks streaming, etc)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@
|
|||
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",
|
||||
"jszip": "^3.10.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mcraft-fun-mineflayer": "^0.1.14",
|
||||
"mcraft-fun-mineflayer": "^0.1.21",
|
||||
"minecraft-data": "3.83.1",
|
||||
"minecraft-protocol": "github:PrismarineJS/node-minecraft-protocol#master",
|
||||
"mineflayer-item-map-downloader": "github:zardoy/mineflayer-item-map-downloader",
|
||||
|
|
|
|||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
|
|
@ -132,8 +132,8 @@ importers:
|
|||
specifier: ^4.17.21
|
||||
version: 4.17.21
|
||||
mcraft-fun-mineflayer:
|
||||
specifier: ^0.1.14
|
||||
version: 0.1.14(encoding@0.1.13)(mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/d459d2ed76a997af1a7c94718ed7d5dee4478b8a(encoding@0.1.13))
|
||||
specifier: ^0.1.21
|
||||
version: 0.1.21(encoding@0.1.13)(mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/d459d2ed76a997af1a7c94718ed7d5dee4478b8a(encoding@0.1.13))
|
||||
minecraft-data:
|
||||
specifier: 3.83.1
|
||||
version: 3.83.1
|
||||
|
|
@ -6459,9 +6459,9 @@ packages:
|
|||
resolution: {integrity: sha512-Ucsu2pDLr/cs8bxbxU9KTszdf/vPTLphYgEHUEWxuYlMkPQUCpsQwkn3YgyykJ7RXaca7zZGlZXaTPXBAqJT6A==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
mcraft-fun-mineflayer@0.1.14:
|
||||
resolution: {integrity: sha512-q/qXQaNbkGJIvXjRvudUT7/k0EsJgphFcvYjrSRWYyGDJeb61MKRVqq1hhMjqx7UK7FMfBKvjfPSxq/QlAP7WQ==}
|
||||
version: 0.1.14
|
||||
mcraft-fun-mineflayer@0.1.21:
|
||||
resolution: {integrity: sha512-FtzebYMvLvunApQy9ilF1RGqiX01DJn8y7q4xAONiIhBrIT7BrHK3O63IA50YgklldvdgVxn7s3m4QANvsH2JA==}
|
||||
version: 0.1.21
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
peerDependencies:
|
||||
'@roamhq/wrtc': '*'
|
||||
|
|
@ -16993,7 +16993,7 @@ snapshots:
|
|||
maxrects-packer: '@zardoy/maxrects-packer@2.7.4'
|
||||
zod: 3.24.2
|
||||
|
||||
mcraft-fun-mineflayer@0.1.14(encoding@0.1.13)(mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/d459d2ed76a997af1a7c94718ed7d5dee4478b8a(encoding@0.1.13)):
|
||||
mcraft-fun-mineflayer@0.1.21(encoding@0.1.13)(mineflayer@https://codeload.github.com/GenerelSchwerz/mineflayer/tar.gz/d459d2ed76a997af1a7c94718ed7d5dee4478b8a(encoding@0.1.13)):
|
||||
dependencies:
|
||||
'@zardoy/flying-squid': 0.0.49(encoding@0.1.13)
|
||||
exit-hook: 2.2.1
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ import packetsPatcher from './mineflayer/plugins/packetsPatcher'
|
|||
import { mainMenuState } from './react/MainMenuRenderApp'
|
||||
import './mobileShim'
|
||||
import { parseFormattedMessagePacket } from './botUtils'
|
||||
import { getViewerVersionData, getWsProtocolStream, handleCustomChannel } from './viewerConnector'
|
||||
import { getViewerVersionData, getWsProtocolStream, onBotCreatedViewerHandler } from './viewerConnector'
|
||||
import { getWebsocketStream } from './mineflayer/websocket-core'
|
||||
import { appQueryParams, appQueryParamsArray } from './appParams'
|
||||
import { playerState } from './mineflayer/playerState'
|
||||
|
|
@ -552,8 +552,7 @@ export async function connect (connectOptions: ConnectOptions) {
|
|||
}) as unknown as typeof __type_bot
|
||||
window.bot = bot
|
||||
if (connectOptions.viewerWsConnect) {
|
||||
void handleCustomChannel()
|
||||
bot.physicsEnabled = false
|
||||
void onBotCreatedViewerHandler()
|
||||
}
|
||||
customEvents.emit('mineflayerBotCreated')
|
||||
if (singleplayer || p2pMultiplayer || localReplaySession) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export const mineflayerConsoleState = proxy({
|
|||
messages: [] as ConsoleMessage[],
|
||||
replEnabled: false,
|
||||
consoleEnabled: false,
|
||||
takeoverMode: false
|
||||
})
|
||||
|
||||
const MessageLine = ({ message }: { message: ConsoleMessage }) => {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { CustomChannelPacketFromClient, CustomChannelPacketFromServer, UIDefinit
|
|||
import { activeModalStack } from './globalState'
|
||||
import { mineflayerPluginHudState } from './react/MineflayerPluginHud'
|
||||
import { mineflayerConsoleState } from './react/MineflayerPluginConsole'
|
||||
import { showNotification } from './react/NotificationProvider'
|
||||
|
||||
export const viewerVersionState = proxy({
|
||||
forwardChat: true,
|
||||
|
|
@ -43,6 +44,7 @@ export const getViewerVersionData = async (url: string) => {
|
|||
requiresPass: boolean,
|
||||
forwardChat: boolean,
|
||||
clientIgnoredPackets?: string[]
|
||||
takeoverMode?: boolean
|
||||
}>((resolve, reject) => {
|
||||
ws.addEventListener('message', async (message) => {
|
||||
const { data } = message
|
||||
|
|
@ -67,6 +69,7 @@ export const getViewerVersionData = async (url: string) => {
|
|||
})
|
||||
mineflayerConsoleState.consoleEnabled = result.consoleEnabled
|
||||
mineflayerConsoleState.replEnabled = result.replEnabled
|
||||
mineflayerConsoleState.takeoverMode = result.takeoverMode ?? false
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +128,7 @@ export const getWsProtocolStream = async (url: string) => {
|
|||
|
||||
const CHANNEL_NAME = 'minecraft-web-client:data'
|
||||
|
||||
export const handleCustomChannel = async () => {
|
||||
const handleCustomChannel = () => {
|
||||
bot._client.registerChannel(CHANNEL_NAME, ['string', []])
|
||||
const toCleanup = [] as Array<() => void>
|
||||
subscribe(activeModalStack, () => {
|
||||
|
|
@ -288,4 +291,35 @@ export const handleCustomChannel = async () => {
|
|||
// No default
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
send
|
||||
}
|
||||
}
|
||||
|
||||
export const onBotCreatedViewerHandler = async () => {
|
||||
const { send } = handleCustomChannel()
|
||||
bot.physicsEnabled = false
|
||||
|
||||
await new Promise<void>(resolve => {
|
||||
bot.once('inject_allowed', resolve)
|
||||
})
|
||||
|
||||
const originalSetControlState = bot.setControlState.bind(bot)
|
||||
bot.setControlState = (control, state) => {
|
||||
if (bot.controlState[control] === state) {
|
||||
return
|
||||
}
|
||||
if (!mineflayerConsoleState.takeoverMode) {
|
||||
showNotification('Remote control is not enabled', 'Enable takeoverMode in bot plugin settings first')
|
||||
return
|
||||
}
|
||||
// send command to viewer
|
||||
send({
|
||||
type: 'setControlState',
|
||||
control,
|
||||
value: state
|
||||
})
|
||||
originalSetControlState(control, state)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue