uosodfsjfid

This commit is contained in:
Ethan Stubbs 2021-08-12 01:44:18 +01:00
parent ba7618a17a
commit c50328818f
3 changed files with 41 additions and 17 deletions

View file

@ -1,20 +1,8 @@
const server = new (require('net').Server)();
const config = require("./config.json");
server.listen(config.port, function() {
const mcServer = require("./server/server.js");
});
server.listen(config.port, () => mcServer.init(config));
server.on('connection', function(socket) {
socket.on('data', function(chunk) {
});
socket.on('end', function() {
});
socket.on('error', function(err) {
});
});
server.on('connection', mcServer.connection);

View file

@ -1,5 +1,25 @@
module.exports = class {
constructor() {
this.chunks = [];
this.chunks = {};
this.createChunk(0, 0);
}
createChunk(x = 0, z = 0) {
this.chunks[x] = {};
this.chunks[x][z] = {};
const chunk = this.chunks[x][z];
for (let y = 0; y < 128; y++) {
chunk[y] = {};
for (let x = 0; x < 16; x++) {
chunk[y][x] = {};
for (let z = 0; z < 16; z++) {
chunk[y][x][z] = 0;
}
}
}
console.log(chunk);
}
}

View file

@ -1,5 +1,21 @@
const bufferStuff = require("./bufferStuff.js")
module.exports = function() {
const Socket = require("net").Socket;
module.exports.init = function(config) {
console.log(`Up! Running at 0.0.0.0:${config.port}`);
}
module.exports.connection = function(socket = new Socket) {
socket.on('data', function(chunk) {
console.log(chunk);
});
socket.on('end', function() {
console.log("Connection closed");
});
socket.on('error', function(err) {
console.log("Connection error!");
});
}