You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 15, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/API.md
+56-8Lines changed: 56 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,11 +104,13 @@ Returns a `Client` instance and perform login.
104
104
* connect : a function taking the client as parameter and that should client.setSocket(socket)
105
105
and client.emit('connect') when appropriate (see the proxy examples for an example of use)
106
106
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm)
107
+
* fakeHost : (optional) hostname to send to the server in the set_protocol packet
107
108
* profilesFolder : optional
108
109
* (mojang account) the path to the folder that contains your `launcher_profiles.json`. defaults to your minecraft folder if it exists, otherwise the local directory. set to `false` to disable managing profiles
109
110
* (microsoft account) the path to store authentication caches, defaults to .minecraft
110
111
* onMsaCode(data) : (optional) callback called when signing in with a microsoft account
111
112
with device code auth. `data` is an object documented [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#device-authorization-response)
113
+
* id : a numeric client id used for referring to multiple clients in a server
112
114
113
115
114
116
## mc.Client(isServer,version,[customPackets])
@@ -120,13 +122,37 @@ Takes a minecraft `version` as second argument.
120
122
121
123
write a packet
122
124
125
+
### client.writeRaw(buffer)
126
+
127
+
write a raw buffer as a packet
128
+
123
129
### client.end(reason, fullReason)
124
130
125
131
Ends the connection with `reason` or `fullReason`
126
132
If `fullReason` is not defined, then the `reason` will be used.
127
133
128
134
`fullReason` is a JSON object, which represents [chat](https://wiki.vg/Chat) message.
129
135
136
+
### client.connect(port, host)
137
+
138
+
Used by the [Client Class](https://github.com/PrismarineJS/node-minecraft-protocol/blob/d9d01c8be4921bb38e7b59d9c18afd771615ba22/src/client.js) to connect to a server, done by createClient automatically
Registers a plugin channel with the given `name` and protodef `typeDefinition`
147
+
148
+
### client.unregisterChannel(name)
149
+
150
+
Unregisters a plugin channel.
151
+
152
+
### client.writeChannel(channel, params)
153
+
154
+
Write to [Plugin Channels](https://wiki.vg/Plugin_channels)
155
+
130
156
### client.state
131
157
132
158
The internal state that is used to figure out which protocol state we are in during
@@ -137,7 +163,6 @@ packet parsing. This is one of the protocol.states.
137
163
True if this is a connection going from the server to the client,
138
164
False if it is a connection from client to server.
139
165
140
-
141
166
### client.socket
142
167
143
168
Returns the internal nodejs Socket used to communicate with this client.
@@ -163,24 +188,47 @@ The player's profile, as returned by the Yggdrasil system. (only server-side)
163
188
164
189
The latency of the client, in ms. Updated at each keep alive.
165
190
191
+
### client.customPackets
192
+
193
+
An object index by version/state/direction/name, see client_custom_packet for an example
194
+
195
+
### client.protocolVersion
196
+
197
+
The client's protocol version
198
+
199
+
### client.version
200
+
201
+
The client's version
202
+
166
203
### `packet` event
167
204
168
-
Called with every packet parsed. Takes three params, the JSON data we parsed,
169
-
, the packet metadata (name, state) and the initial buffer
205
+
Called with every packet parsed. Takes four paramaters, the JSON data we parsed, the packet metadata (name, state), the buffer (raw data) and the full buffer (includes surplus data and may include the data of following packets on versions below 1.8)
170
206
171
207
### `raw` event
172
208
173
209
Called with every packet, but as a buffer. Takes two params, the buffer
174
210
and the packet metadata (name, state)
175
211
212
+
### `connect` event
213
+
214
+
when the socket connects to the server, this is emitted
215
+
216
+
### `end` event
217
+
218
+
Called when the client's connection is disconnected. Takes the reason as parameter
219
+
220
+
### `session` event
221
+
222
+
Called when user authentication is resolved. Takes session data as parameter.
223
+
176
224
### `state` event
177
225
178
226
Called when the protocol changes state. Takes the new state and old state as
179
227
parameters.
180
228
181
-
### `session` event
229
+
### `error` event
182
230
183
-
Called when user authentication is resolved. Takes session data as parameter.
231
+
Called when an error occurs within the client. Takes an Error as parameter.
184
232
185
233
### per-packet events
186
234
@@ -228,9 +276,9 @@ correct data type. You can figure out the types [here](http://wiki.vg/Entities#E
228
276
## mc.ping(options, callback)
229
277
230
278
`options` is an object containing the following:
231
-
* host : default too locahost
232
-
* port : default too 25565
233
-
* version: default too most recent version
279
+
* host : default to localhost
280
+
* port : default to 25565
281
+
* version: default to most recent version
234
282
235
283
Ping a minecraft server and return a promise or use an optional callback containing the information about it
servers with a high level API, also a minecraft server by itself.
54
-
*[pakkit](https://github.com/Heath123/pakkit) To monitor your packets
55
-
*[minecraft-packet-debugger](https://github.com/wvffle/minecraft-packet-debugger) to easily debug your minecraft packets
54
+
*[pakkit](https://github.com/Heath123/pakkit) - A GUI tool to monitor Minecraft packets in real time, allowing you to view their data and interactively edit and resend them
55
+
*[minecraft-packet-debugger](https://github.com/wvffle/minecraft-packet-debugger) - A tool to capture Minecraft packets in a buffer then view them in a browser
56
+
*[aresrpg](https://github.com/aresrpg/aresrpg) - An open-source mmorpg minecraft server
57
+
* and [several thousands others](https://github.com/PrismarineJS/node-minecraft-protocol/network/dependents?package_id=UGFja2FnZS0xODEzMDk0OQ%3D%3D)
58
+
59
+
## Installation
60
+
61
+
`npm install minecraft-protocol`
62
+
63
+
## Documentation
64
+
65
+
*[API doc](API.md)
66
+
*[faq](FAQ.md)
67
+
*[protocol doc](https://minecraft-data.prismarine.js.org/?d=protocol) and [wiki.vg/Protocol](https://wiki.vg/Protocol)
username: process.argv[4],// your microsoft account email
14
-
password: process.argv[5],// your microsoft account password
12
+
host,
13
+
port: parseInt(port),
14
+
username: userOrEmail,// your microsoft account email
15
+
password: password,// your microsoft account password
15
16
auth: 'microsoft'// This option must be present and set to 'microsoft' to use Microsoft Account Authentication. Failure to do so will result in yggdrasil throwing invalid account information.
0 commit comments