mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-04 02:30:36 +00:00
Players can now spawn and walk around
This commit is contained in:
parent
5ce8a0ea0a
commit
def7426fc5
2 changed files with 20 additions and 13 deletions
28
app.js
28
app.js
|
|
@ -1,7 +1,7 @@
|
||||||
var mc = require('minecraft-protocol');
|
var mc = require('minecraft-protocol');
|
||||||
var states = mc.states;
|
var states = mc.states;
|
||||||
var settings = require('./config/settings');
|
var settings = require('./config/settings');
|
||||||
var World = require('./world/world');
|
var World = require('prismarine-chunk');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var timeStarted = Math.floor(new Date() / 1000).toString();
|
var timeStarted = Math.floor(new Date() / 1000).toString();
|
||||||
|
|
||||||
|
|
@ -16,7 +16,10 @@ var options = {
|
||||||
var world = new World();
|
var world = new World();
|
||||||
for (var x = 0; x < 16;x++) {
|
for (var x = 0; x < 16;x++) {
|
||||||
for (var z = 0; z < 16; z++) {
|
for (var z = 0; z < 16; z++) {
|
||||||
world.put(x, 50, z, "block_data", 2);
|
world.setBlockType(x, 50, z, 2);
|
||||||
|
for (var y = 0; y < 256; y++) {
|
||||||
|
world.setSkyLight(x, y, z, 15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,13 +58,16 @@ server.on('login', function(client) {
|
||||||
maxPlayers: server.maxPlayers
|
maxPlayers: server.maxPlayers
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunkBulk = world.packMapChunkBulk([0,0], function(err, packetData) {
|
var packetData = {
|
||||||
|
x: 0,
|
||||||
|
z: 0,
|
||||||
|
groundUp: true,
|
||||||
|
bitMap: 0xffff,
|
||||||
|
chunkData: world.dump()
|
||||||
|
};
|
||||||
|
client.write('map_chunk', packetData);
|
||||||
|
|
||||||
if (err) {
|
//client.write('map_chunk', packetData);
|
||||||
console.log(err.stack);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
client.write('map_chunk_bulk', packetData);
|
|
||||||
|
|
||||||
client.write('position', {
|
client.write('position', {
|
||||||
x: 6,
|
x: 6,
|
||||||
|
|
@ -83,7 +89,6 @@ server.on('login', function(client) {
|
||||||
reason: 3,
|
reason: 3,
|
||||||
gameMode: 1
|
gameMode: 1
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
client.on([states.PLAY, 'chat'], function(data) {
|
client.on([states.PLAY, 'chat'], function(data) {
|
||||||
var message = '<'+client.username+'>' + ' ' + data.message;
|
var message = '<'+client.username+'>' + ' ' + data.message;
|
||||||
|
|
@ -93,8 +98,9 @@ server.on('login', function(client) {
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('packet', function(packet) {
|
client.on('packet', function(packet) {
|
||||||
console.log("[INFO] " + packet);
|
// we don't really need to see the server pass an object every 10nth of a second so I will just disable this
|
||||||
log("[INFO] " + message);
|
//console.log("[INFO] " + packet);
|
||||||
|
//log("[INFO] " + packet);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
"minecraft-protocol": "^0.14.0",
|
"minecraft-protocol": "^0.14.0",
|
||||||
"buffers": "0.1.1",
|
"buffers": "0.1.1",
|
||||||
"mocha": "~2.2.5",
|
"mocha": "~2.2.5",
|
||||||
"chai": "~3.2.0"
|
"chai": "~3.2.0",
|
||||||
|
"prismarine-chunk": "~0.1.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue