add most of server login sequence in server example
This commit is contained in:
parent
d17c62307a
commit
eee1fe6aa7
3 changed files with 53 additions and 4 deletions
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
var pmp = require('../');
|
||||
|
||||
if(process.argv.length !=4) {
|
||||
|
|
@ -12,9 +14,46 @@ var server = pmp.createServer({
|
|||
});
|
||||
|
||||
server.on('connection', function(client) {
|
||||
client.on("mcpe_login",packet => {
|
||||
|
||||
|
||||
client.on("mcpe",packet => {
|
||||
console.log(packet);
|
||||
});
|
||||
client.on("mcpe_login",packet => {
|
||||
client.writeMCPE("mcpe_player_status",{
|
||||
status:0
|
||||
});
|
||||
client.writeMCPE("mcpe_start_game",{
|
||||
seed:0,
|
||||
dimension:0,
|
||||
generator:0,
|
||||
gamemode:0,
|
||||
entity_id:0,
|
||||
spawn_x:0,
|
||||
spawn_y:64,
|
||||
spawn_z:0,
|
||||
x:0,
|
||||
y:64,
|
||||
z:0,
|
||||
unknown:0
|
||||
});
|
||||
client.writeMCPE("mcpe_set_time",{
|
||||
time:0,
|
||||
started:0
|
||||
})
|
||||
});
|
||||
|
||||
client.on("mcpe_request_chunk_radius",packet => {
|
||||
const chunkRadius=packet.chunk_radius;
|
||||
// TODO : to fix, no idea what to send
|
||||
client.writeMCPE("mcpe_full_chunk_data",{
|
||||
chunk_x:0,
|
||||
chunk_z:0,
|
||||
order:0,
|
||||
chunk_data_length:8,
|
||||
chunk_data:new Buffer([0,1])
|
||||
});
|
||||
});
|
||||
|
||||
client.on('error', function(err) {
|
||||
console.log(err.stack);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ function createClient(options) {
|
|||
var client=raknet.createClient(options);
|
||||
client.username = options.username;
|
||||
client.on("mcpe",packet => client.emit(packet.name,packet.params))
|
||||
client.writeMCPE=(name,packet) => {
|
||||
client.writeEncapsulated("mcpe",{
|
||||
name:name,
|
||||
params:packet
|
||||
});
|
||||
};
|
||||
|
||||
return client;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,13 @@ function createServer(options) {
|
|||
server.playerCount = 0;
|
||||
|
||||
server.on("connection", function (client) {
|
||||
client.on("mcpe",packet => client.emit(packet.name,packet.params))
|
||||
|
||||
|
||||
client.on("mcpe",packet => client.emit(packet.name,packet.params));
|
||||
client.writeMCPE=(name,packet) => {
|
||||
client.writeEncapsulated("mcpe",{
|
||||
name:name,
|
||||
params:packet
|
||||
});
|
||||
};
|
||||
});
|
||||
return server;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue