fix: fix all known minecraft-protocol issues. Fixed auto-version. Fixed: kick messages are now always displayed!
This commit is contained in:
parent
228039c245
commit
32de8ebacd
3 changed files with 22 additions and 14 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import mcServer from 'flying-squid'
|
||||
import defaultOptions from 'flying-squid/config/default-settings.json' assert { type: 'json' }
|
||||
|
||||
/** @type {Options} */
|
||||
const serverOptions = {
|
||||
...defaultOptions,
|
||||
'online-mode': false,
|
||||
|
|
|
|||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
|
|
@ -138,7 +138,7 @@ importers:
|
|||
version: 2.0.4
|
||||
net-browserify:
|
||||
specifier: github:zardoy/prismarinejs-net-browserify
|
||||
version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070
|
||||
version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434
|
||||
node-gzip:
|
||||
specifier: ^1.1.2
|
||||
version: 1.1.2
|
||||
|
|
@ -6224,8 +6224,8 @@ packages:
|
|||
nested-error-stacks@2.1.1:
|
||||
resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==}
|
||||
|
||||
net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070:
|
||||
resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070}
|
||||
net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434:
|
||||
resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434}
|
||||
version: 0.2.4
|
||||
|
||||
nice-try@1.0.5:
|
||||
|
|
@ -15990,7 +15990,7 @@ snapshots:
|
|||
|
||||
nested-error-stacks@2.1.1: {}
|
||||
|
||||
net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070:
|
||||
net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434:
|
||||
dependencies:
|
||||
body-parser: 1.20.2
|
||||
express: 4.18.2
|
||||
|
|
|
|||
27
src/index.ts
27
src/index.ts
|
|
@ -186,7 +186,7 @@ let lastMouseMove: number
|
|||
const updateCursor = () => {
|
||||
worldInteractions.update()
|
||||
}
|
||||
function onCameraMove (e) {
|
||||
function onCameraMove(e) {
|
||||
if (e.type !== 'touchmove' && !pointerLock.hasPointerLock) return
|
||||
e.stopPropagation?.()
|
||||
const now = performance.now()
|
||||
|
|
@ -212,7 +212,7 @@ contro.on('stickMovement', ({ stick, vector }) => {
|
|||
miscUiState.usingGamepadInput = true
|
||||
})
|
||||
|
||||
function hideCurrentScreens () {
|
||||
function hideCurrentScreens() {
|
||||
activeModalStacks['main-menu'] = [...activeModalStack]
|
||||
insertActiveModalStack('', [])
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ function hideCurrentScreens () {
|
|||
const loadSingleplayer = (serverOverrides = {}, flattenedServerOverrides = {}) => {
|
||||
void connect({ singleplayer: true, username: options.localUsername, password: '', serverOverrides, serverOverridesFlat: flattenedServerOverrides })
|
||||
}
|
||||
function listenGlobalEvents () {
|
||||
function listenGlobalEvents() {
|
||||
window.addEventListener('connect', e => {
|
||||
const options = (e as CustomEvent).detail
|
||||
void connect(options)
|
||||
|
|
@ -261,7 +261,7 @@ const cleanConnectIp = (host: string | undefined, defaultPort: string | undefine
|
|||
}
|
||||
}
|
||||
|
||||
async function connect (connectOptions: ConnectOptions) {
|
||||
async function connect(connectOptions: ConnectOptions) {
|
||||
if (miscUiState.gameLoaded) return
|
||||
miscUiState.hasErrors = false
|
||||
lastConnectOptions.value = connectOptions
|
||||
|
|
@ -444,18 +444,18 @@ async function connect (connectOptions: ConnectOptions) {
|
|||
} : {},
|
||||
...singleplayer ? {
|
||||
version: serverOptions.version,
|
||||
connect () { },
|
||||
connect() { },
|
||||
Client: CustomChannelClient as any,
|
||||
} : {},
|
||||
username,
|
||||
password,
|
||||
viewDistance: renderDistance,
|
||||
checkTimeoutInterval: 240 * 1000,
|
||||
noPongTimeout: 240 * 1000,
|
||||
// noPongTimeout: 240 * 1000,
|
||||
closeTimeout: 240 * 1000,
|
||||
respawn: options.autoRespawn,
|
||||
maxCatchupTicks: 0,
|
||||
async versionSelectedHook (client) {
|
||||
async versionSelectedHook(client) {
|
||||
await downloadMcData(client.version)
|
||||
setLoadingScreenStatus(initialLoadingText)
|
||||
},
|
||||
|
|
@ -484,6 +484,13 @@ async function connect (connectOptions: ConnectOptions) {
|
|||
//@ts-expect-error
|
||||
bot._client.socket._ws.addEventListener('close', () => {
|
||||
console.log('WebSocket connection closed')
|
||||
setTimeout(() => {
|
||||
if (bot) {
|
||||
bot.emit('end', 'WebSocket connection closed with unknown reason')
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
bot._client.socket.on('close', () => {
|
||||
setTimeout(() => {
|
||||
if (bot) {
|
||||
bot.emit('end', 'WebSocket connection closed with unknown reason')
|
||||
|
|
@ -606,7 +613,7 @@ async function connect (connectOptions: ConnectOptions) {
|
|||
dayCycle()
|
||||
|
||||
// Bot position callback
|
||||
function botPosition () {
|
||||
function botPosition() {
|
||||
viewer.world.lastCamUpdate = Date.now()
|
||||
// this might cause lag, but not sure
|
||||
viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
|
||||
|
|
@ -626,7 +633,7 @@ async function connect (connectOptions: ConnectOptions) {
|
|||
bot.entity.yaw -= x
|
||||
}
|
||||
|
||||
function changeCallback () {
|
||||
function changeCallback() {
|
||||
if (notificationProxy.id === 'pointerlockchange') {
|
||||
hideNotification()
|
||||
}
|
||||
|
|
@ -895,7 +902,7 @@ downloadAndOpenFile().then((downloadAction) => {
|
|||
const unsubscribe = subscribe(miscUiState, checkCanDisplay)
|
||||
checkCanDisplay()
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
function checkCanDisplay () {
|
||||
function checkCanDisplay() {
|
||||
if (miscUiState.appConfig) {
|
||||
unsubscribe()
|
||||
openServerEditor()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue