janispritzkau / mcproto Goto Github PK
View Code? Open in Web Editor NEWA lightweight implementation of the Minecraft protocol. Supports most newer versions of Minecraft
A lightweight implementation of the Minecraft protocol. Supports most newer versions of Minecraft
Current keep alive implementation (server, client) assumes the id is Int64
, but that's not the case for old versions.
Data extracted from https://github.com/PrismarineJS/minecraft-data:
keepAliveC {
'1.7': '1.7.2 / 4 / i32',
'1.8': '1.8 / 47 / varint',
'1.12': '1.12.2 / 340 / i64'
}
keepAliveS {
'1.7': '1.7.2 / 4 / i32',
'1.8': '1.8 / 47 / varint',
'1.12': '1.12.2 / 340 / i64'
}
Not sure of a proper implementation, maybe methods in packet.ts
to read/write keep alive ids or PacketReader.readKeepAliveID
+ PacketWriter.writeKeepAliveID
Version 1.16 keep alive packet IDs are wrong, leading to client disconnects when automatic keep alive is enabled.
Pull request to follow.
For some reason it's not logging all packets. Not sure if it's something I've done wrong or not.
It logs when I join the server (0x0) but thats that.
const { PacketWriter, Server, Client } = require('mcproto');
const server = new Server(async client => {
client.on('error', error => {
console.log(error);
});
const handshake = await client.nextPacket();
const protocol = handshake.readVarInt();
client.pause();
let player;
try {
player = await Client.connect('3b3t.uk', 10014);
} catch (e) {
console.log(e);
return client.end();
}
player.send(new PacketWriter(0x0).writeVarInt(protocol).writeString('3b3t.uk').writeUInt16(10014).writeVarInt(client.state));
player.on('error', error => {
console.log(error);
});
client.on('packet', packet => {
player.send(packet);
console.log(`[S] 0x${packet.id.toString(16)}`);
});
player.on('packet', packet => {
console.log(`[C] 0x${packet.id.toString(16)}`);
});
await client.resume();
client.unpipe();
player.unpipe();
client.socket.pipe(player.socket, { end: true });
player.socket.pipe(client.socket, { end: true });
});
server.listen(25561).then(() => {
console.log('Server Started.');
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.