mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 11:10:44 +00:00
Initial commit
This commit is contained in:
parent
817912180b
commit
9609f1261b
4 changed files with 21 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
mc-plain-server
|
node-minecraft-server
|
||||||
==============
|
==============
|
||||||
|
|
||||||
This is mc-plain-server.
|
This is a Minecraft server written in node.js for minecraft 1.8
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ var states = mc.protocol.states;
|
||||||
var World = require('./world');
|
var World = require('./world');
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
motd: 'Vox Industries',
|
motd: 'Minecraft Server',
|
||||||
'max-players': 127,
|
'max-players': 20,
|
||||||
port: 25565,
|
port: 25565,
|
||||||
'online-mode': false,
|
'online-mode': false,
|
||||||
};
|
};
|
||||||
|
|
@ -19,9 +19,9 @@ for (var x = 0; x < 16;x++) {
|
||||||
var server = mc.createServer(options);
|
var server = mc.createServer(options);
|
||||||
|
|
||||||
server.on('login', function(client) {
|
server.on('login', function(client) {
|
||||||
broadcast({ text: client.username+' joined the game.', color: "yellow" });
|
broadcast({ text: client.username + ' joined the game.', color: "yellow" });
|
||||||
var addr = client.socket.remoteAddress + ':' + client.socket.remotePort;
|
var addr = client.socket.remoteAddress + ':' + client.socket.remotePort;
|
||||||
console.log(client.username+' connected', '('+addr+')');
|
console.log(client.username + ' connected', '(' + addr + ')');
|
||||||
|
|
||||||
client.on('end', function() {
|
client.on('end', function() {
|
||||||
broadcast({ text: client.username+' left the game.', color: "yellow" });
|
broadcast({ text: client.username+' left the game.', color: "yellow" });
|
||||||
14
package.json
14
package.json
|
|
@ -1,25 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "mc-plain-server",
|
"name": "node-minecraft-server",
|
||||||
"description": "",
|
"description": "A minecraft server written in node.js",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "./mc-plain-server.js",
|
"main": "app.js",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "roblabla",
|
"name": "roblabla",
|
||||||
"email": "robinlambertz.dev@gmail.com"
|
"email": "robinlambertz.dev@gmail.com"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"licenses": {
|
"licenses": {
|
||||||
"type": "mit"
|
"type": "MIT"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minecraft-protocol": "git://github.com/roblabla/node-minecraft-protocol.git#feature-mc1.7",
|
"minecraft-protocol": "git://github.com/roblabla/node-minecraft-protocol.git",
|
||||||
"buffers": "0.1.1"
|
"buffers": "0.1.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/YOUR_LOGIN/mc-plain-server.git"
|
"url": "git://github.com/mhsjlw/node-minecraft-server.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "http://github.com/YOUR_LOGIN/mc-plain-server/issues"
|
"url": "http://github.com/mhsjlw/node-minecraft-server/issues"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
world.js
16
world.js
|
|
@ -1,6 +1,6 @@
|
||||||
var util = require('util')
|
var util = require('util')
|
||||||
, zlib = require('zlib')
|
var zlib = require('zlib')
|
||||||
, Buffers = require('buffers');
|
var Buffers = require('buffers');
|
||||||
|
|
||||||
module.exports = World;
|
module.exports = World;
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ ChunkColumn.prototype.unpack_section = function(buff, section, mask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkColumn.prototype.pack = function() {
|
ChunkColumn.prototype.pack = function() {
|
||||||
var bufs = new Buffers();
|
var bufs = new Buffers[];
|
||||||
var mask1 = 0;
|
var mask1 = 0;
|
||||||
for (var i = 0; i < 16; i++) {
|
for (var i = 0; i < 16; i++) {
|
||||||
if (this.chunks[i] !== null) {
|
if (this.chunks[i] !== null) {
|
||||||
|
|
@ -155,7 +155,7 @@ ChunkColumn.prototype.pack = function() {
|
||||||
var mask2 = 0;
|
var mask2 = 0;
|
||||||
bufs.push(block_data, block_meta, light_block, light_sky);
|
bufs.push(block_data, block_meta, light_block, light_sky);
|
||||||
return {
|
return {
|
||||||
data: bufs.toBuffer(),
|
data: Buffer.concat(bufs),
|
||||||
mask1: mask1,
|
mask1: mask1,
|
||||||
mask2: mask2,
|
mask2: mask2,
|
||||||
skylight: true
|
skylight: true
|
||||||
|
|
@ -163,12 +163,12 @@ ChunkColumn.prototype.pack = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkColumn.prototype.pack_section = function(section) {
|
ChunkColumn.prototype.pack_section = function(section) {
|
||||||
var bufs = new Buffers();
|
var bufs = new Buffers[];
|
||||||
for (var i = 0; i < 16; i++) {
|
for (var i = 0; i < 16; i++) {
|
||||||
if (this.chunks[i] !== null)
|
if (this.chunks[i] !== null)
|
||||||
bufs.push(this.chunks[i][section].pack());
|
bufs.push(this.chunks[i][section].pack());
|
||||||
}
|
}
|
||||||
return bufs.toBuffer();
|
return Buffer.concat(bufs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function World() {
|
function World() {
|
||||||
|
|
@ -192,7 +192,7 @@ World.prototype.unpack = function(packetData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
World.prototype.packMapChunkBulk = function() {
|
World.prototype.packMapChunkBulk = function() {
|
||||||
var bufs = new Buffers();
|
var bufs = new Buffers[];
|
||||||
var metadatas = [];
|
var metadatas = [];
|
||||||
var cb = arguments[arguments.length - 1];
|
var cb = arguments[arguments.length - 1];
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ World.prototype.packMapChunkBulk = function() {
|
||||||
console.log("error");
|
console.log("error");
|
||||||
cb(err);
|
cb(err);
|
||||||
});
|
});
|
||||||
deflate.write(bufs.toBuffer());
|
deflate.write(Buffer.concat(bufs));
|
||||||
deflate.end();
|
deflate.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue