![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
minecraft-protocol
Advanced tools
Parse and serialize minecraft packets, plus authentication and encryption.
Parse and serialize minecraft packets, plus authentication and encryption.
var mc = require('minecraft-protocol');
var client = mc.createClient({
host: "localhost", // optional
port: 25565, // optional
username: "email@example.com",
password: "12345678",
});
client.on('chat', function(packet) {
// Listen for chat messages and echo them back.
var jsonMsg = JSON.parse(packet.message);
if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
var username = jsonMsg.using[0];
var msg = jsonMsg.using[1];
if (username === client.username) return;
client.write(0x03, {
message: msg
});
}
});
If the server is in offline mode, you may leave out the password
option.
var mc = require('minecraft-protocol');
var server = mc.createServer({
'online-mode': true, // optional
encryption: true, // optional
host: '0.0.0.0', // optional
port: 25565, // optional
});
server.on('login', function(client) {
client.write('login', {
entityId: client.id,
levelType: 'default',
gameMode: 0,
dimension: 0,
difficulty: 2,
maxPlayers: server.maxPlayers
});
client.write('position', {
x: 0,
y: 1.62,
z: 0,
yaw: 0,
pitch: 0,
onGround: true
});
var msg = { translate: 'chat.type.announcement', using: [
'Server',
'Hello, ' + client.username
]};
client.write(0x03, { message: JSON.stringify(msg) });
});
npm install minecraft-protocol
On Windows, first follow the Windows instructions from Obvious/ursa
callback(err, pingResults)
pingResults
:
prefix
protocol
version
motd
playerCount
maxPlayers
Returns a Server
instance and starts listening.
This is a plain old JavaScript object. Add a key with the username you want to be exempt from online mode or offline mode (whatever mode the server is in).
Make sure the entries in this object are all lower case.
Javascript object mapping a Client
from a clientId.
The amount of players currently present on the server.
The maximum amount of players allowed on the server.
The motd that is sent to the player when he is pinging the server
A base64 data string representing the favicon that will appear next to the server on the mojang client's multiplayer list.
Returns a Client
instance and perform login
The internal state that is used to figure out which protocol state we are in during packet parsing. This is one of the protocol.states.
True if this is a connection going from the server to the client, False if it is a connection from client to server.
Returns the internal nodejs Socket used to communicate with this client.
A string representation of the client's UUID. Note that UUIDs are unique for each players, while playerNames, as of 1.7.7, are not unique and can change.
The user's username.
The user's session, as returned by the Yggdrasil system.
Note : almost all data formats can be understood by looking at the packet structure in lib/protocol.js
Value looks like this:
[
{type: 'slot', value: slot, key: 3},
{type: 'int', value: value, key: 4},
...
]
Where the key is the numeric metadata key and the value is the value of the correct data type.
java
executable in PATH
.minecraft_server.jar
.MC_SERVER_JAR=path/to/minecraft_server.jar MC_USERNAME=email@example.com MC_PASSWORD=password npm test
packets
√ handshaking,ServerBound,0x00
√ status,ServerBound,0x00
√ status,ServerBound,0x01
√ status,ClientBound,0x00
√ status,ClientBound,0x01
√ login,ServerBound,0x00
√ login,ServerBound,0x01
√ login,ClientBound,0x00
√ login,ClientBound,0x01
√ login,ClientBound,0x02
√ play,ServerBound,0x00
√ play,ServerBound,0x01
√ play,ServerBound,0x02
√ play,ServerBound,0x03
√ play,ServerBound,0x04
√ play,ServerBound,0x05
√ play,ServerBound,0x06
√ play,ServerBound,0x07
√ play,ServerBound,0x08
√ play,ServerBound,0x09
√ play,ServerBound,0x0a
√ play,ServerBound,0x0b
√ play,ServerBound,0x0c
√ play,ServerBound,0x0d
√ play,ServerBound,0x0e
√ play,ServerBound,0x0f
√ play,ServerBound,0x10
√ play,ServerBound,0x11
√ play,ServerBound,0x12
√ play,ServerBound,0x13
√ play,ServerBound,0x14
√ play,ServerBound,0x15
√ play,ServerBound,0x16
√ play,ServerBound,0x17
√ play,ClientBound,0x00
√ play,ClientBound,0x01
√ play,ClientBound,0x02
√ play,ClientBound,0x03
√ play,ClientBound,0x04
√ play,ClientBound,0x05
√ play,ClientBound,0x06
√ play,ClientBound,0x07
√ play,ClientBound,0x08
√ play,ClientBound,0x09
√ play,ClientBound,0x0a
√ play,ClientBound,0x0b
√ play,ClientBound,0x0c
√ play,ClientBound,0x0d
√ play,ClientBound,0x0e
√ play,ClientBound,0x0f
√ play,ClientBound,0x10
√ play,ClientBound,0x11
√ play,ClientBound,0x12
√ play,ClientBound,0x13
√ play,ClientBound,0x14
√ play,ClientBound,0x15
√ play,ClientBound,0x16
√ play,ClientBound,0x17
√ play,ClientBound,0x18
√ play,ClientBound,0x19
√ play,ClientBound,0x1a
√ play,ClientBound,0x1b
√ play,ClientBound,0x1c
√ play,ClientBound,0x1d
√ play,ClientBound,0x1e
√ play,ClientBound,0x1f
√ play,ClientBound,0x20
√ play,ClientBound,0x21
√ play,ClientBound,0x22
√ play,ClientBound,0x23
√ play,ClientBound,0x24
√ play,ClientBound,0x25
√ play,ClientBound,0x26
√ play,ClientBound,0x27
√ play,ClientBound,0x28
√ play,ClientBound,0x29
√ play,ClientBound,0x2a
√ play,ClientBound,0x2b
√ play,ClientBound,0x2c
√ play,ClientBound,0x2d
√ play,ClientBound,0x2e
√ play,ClientBound,0x2f
√ play,ClientBound,0x30
√ play,ClientBound,0x31
√ play,ClientBound,0x32
√ play,ClientBound,0x33
√ play,ClientBound,0x34
√ play,ClientBound,0x35
√ play,ClientBound,0x36
√ play,ClientBound,0x37
√ play,ClientBound,0x38
√ play,ClientBound,0x39
√ play,ClientBound,0x3a
√ play,ClientBound,0x3b
√ play,ClientBound,0x3c
√ play,ClientBound,0x3d
√ play,ClientBound,0x3e
√ play,ClientBound,0x3f
√ play,ClientBound,0x40
client
√ pings the server (32734ms)
√ connects successfully - online mode (23367ms)
√ connects successfully - offline mode (10261ms)
√ gets kicked when no credentials supplied in online mode (18400ms)
√ does not crash for 10000ms (24780ms)
mc-server
√ starts listening and shuts down cleanly (73ms)
√ kicks clients that do not log in (295ms)
√ kicks clients that do not send keepalive packets (266ms)
√ responds to ping requests (168ms)
√ clients can log in and chat (158ms)
√ kicks clients when invalid credentials (680ms)
√ gives correct reason for kicking clients when shutting down (123ms)
111 tests complete (3 minutes)
You can enable some protocol debugging output using NODE_DEBUG
environment variable:
NODE_DEBUG="minecraft-protocol" node [...]
elementList
and added 0x85 Tile Editor Open packetsshift
renamed to mode
and changed from bool to bytemotd
and maxPlayers
playerCount
onlineModeExceptions
. When server is in:
createServer
: rename encryption-enabled
option to encryption
to stay
consistent with the examples. (thanks Robin Lambertz)createClient
: don't require both email
and username
.
username
and password
arguments are used to authenticate with the
official minecraft servers and determine the case-correct username. If
you have migrated your user account to a mojang login, username
looks
like an email address.password
argument, username
is used to connect
directly to the server. In this case you will get kicked if the server is
in online mode.Emit 'error' event instead of crashing when other computers abuse the minecraft protocol.
Big thanks to Robin Lambertz for this release.
FAQs
Parse and serialize minecraft packets, plus authentication and encryption.
We found that minecraft-protocol demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.