Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ Returns a `Client` instance and perform login.
* id : a numeric client id used for referring to multiple clients in a server
* validateChannelProtocol (optional) : whether or not to enable protocol validation for custom protocols using plugin channels. Defaults to true
* disableChatSigning (optional) : Don't try obtaining chat signing keys from Mojang (1.19+)
* clientSettings (optional) : Client Information (settings) sent to the server during the configuration phase (1.20.2+). All fields are optional and default to vanilla-safe values:
* locale : language/locale string, default `'en_us'`
* viewDistance : view distance in chunks, default `10`
* chatFlags : chat mode, `0` = enabled, `1` = commands only, `2` = hidden, default `0`
* chatColors : whether chat colors are enabled, default `true`
* skinParts : displayed skin parts bitmask, default `127`
* mainHand : `0` = left, `1` = right, default `1`
* enableTextFiltering : default `false`
* enableServerListing : whether the player appears in server status player samples, default `true`
* realms : An object which should contain one of the following properties: `realmId` or `pickRealm`. When defined will attempt to join a Realm without needing to specify host/port. **The authenticated account must either own the Realm or have been invited to it**
* realmId : The id of the Realm to join.
* pickRealm(realms) : A function which will have an array of the user Realms (joined/owned) passed to it. The function should return a Realm.
Expand Down
18 changes: 18 additions & 0 deletions src/client/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ module.exports = function (client, options) {
client.write('configuration_acknowledged', {})
}
client.state = states.CONFIGURATION
// Mirror the vanilla client, which sends Client Information during the
// configuration phase. Some servers (e.g. Hypixel) wait for it before
// sending finish_configuration and will close the socket otherwise.
// Defaults are vanilla-safe and can be overridden per-field via the
// `clientSettings` option. A client that also sends Client Information in
// the play state (e.g. mineflayer on its 'login' event) still takes
// precedence there, exactly as the vanilla client re-sends settings. (#3623)
const clientSettings = options.clientSettings || {}
client.write('settings', {
locale: clientSettings.locale ?? 'en_us',
viewDistance: clientSettings.viewDistance ?? 10,
chatFlags: clientSettings.chatFlags ?? 0,
chatColors: clientSettings.chatColors ?? true,
skinParts: clientSettings.skinParts ?? 127,
mainHand: clientSettings.mainHand ?? 1,
enableTextFiltering: clientSettings.enableTextFiltering ?? false,
enableServerListing: clientSettings.enableServerListing ?? true
})
Comment on lines +64 to +73

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be configurable parameters

client.once('select_known_packs', () => {
client.write('select_known_packs', { packs: [] })
})
Expand Down
Loading