Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
minecraft-protocol
Advanced tools
Parse and serialize minecraft packets, plus authentication and encryption.
Parse and serialize minecraft packets, plus authentication and encryption.
Want to contribute on something important for PrismarineJS ? go to https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects
node-minecraft-protocol is pluggable.
npm install minecraft-protocol
var mc = require('minecraft-protocol');
var client = mc.createClient({
host: "localhost", // optional
port: 25565, // optional
username: "email@example.com",
password: "12345678",
auth: 'mojang' // optional; by default uses mojang, if using a microsoft account, set to 'microsoft'
});
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.with[0].text;
var msg = jsonMsg.with[1];
if(username === client.username) return;
client.write('chat', {message: msg.text});
}
});
If the server is in offline mode, you may leave out the password
option.
You can also leave out password
when using a Microsoft account. If provided, password based auth will be attempted first which may fail. Note: if using a Microsoft account, your account age must be >= 18 years old.
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
version: '1.16.3'
});
const mcData = require('minecraft-data')(server.version)
server.on('login', function(client) {
let loginPacket = mcData.loginPacket
client.write('login', {
entityId: client.id,
isHardcore: false,
gameMode: 0,
previousGameMode: 255,
worldNames: loginPacket.worldNames,
dimensionCodec: loginPacket.dimensionCodec,
dimension: loginPacket.dimension,
worldName: 'minecraft:overworld',
hashedSeed: [0, 0],
maxPlayers: server.maxPlayers,
viewDistance: 10,
reducedDebugInfo: false,
enableRespawnScreen: true,
isDebug: false,
isFlat: false
});
client.write('position', {
x: 0,
y: 1.62,
z: 0,
yaw: 0,
pitch: 0,
flags: 0x00
});
var msg = {
translate: 'chat.type.announcement',
"with": [
'Server',
'Hello, world!'
]
};
client.write("chat", { message: JSON.stringify(msg), position: 0, sender: '0' });
});
java
executable in PATH
.MC_SERVER_JAR_DIR=some/path/to/store/minecraft/server/ MC_USERNAME=email@example.com MC_PASSWORD=password npm test
You can enable some protocol debugging output using DEBUG
environment variable:
DEBUG="minecraft-protocol" node [...]
On windows :
set DEBUG=minecraft-protocol
node your_script.js
Please read https://github.com/PrismarineJS/prismarine-contribute
See history
FAQs
Parse and serialize minecraft packets, plus authentication and encryption.
The npm package minecraft-protocol receives a total of 14,567 weekly downloads. As such, minecraft-protocol popularity was classified as popular.
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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.