From def7426fc58d3ff21714f068a39028ea4a0b94ba Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Mon, 24 Aug 2015 18:41:01 -0400 Subject: [PATCH] Players can now spawn and walk around --- app.js | 30 ++++++++++++++++++------------ package.json | 3 ++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app.js b/app.js index b1ac305..8f6b911 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,7 @@ var mc = require('minecraft-protocol'); var states = mc.states; var settings = require('./config/settings'); -var World = require('./world/world'); +var World = require('prismarine-chunk'); var fs = require('fs'); var timeStarted = Math.floor(new Date() / 1000).toString(); @@ -16,7 +16,10 @@ var options = { var world = new World(); for (var x = 0; x < 16;x++) { 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 }); - var chunkBulk = world.packMapChunkBulk([0,0], function(err, packetData) { - - if (err) { - console.log(err.stack); - return; - } - client.write('map_chunk_bulk', packetData); + var packetData = { + x: 0, + z: 0, + groundUp: true, + bitMap: 0xffff, + chunkData: world.dump() + }; + client.write('map_chunk', packetData); + + //client.write('map_chunk', packetData); client.write('position', { x: 6, @@ -83,7 +89,6 @@ server.on('login', function(client) { reason: 3, gameMode: 1 }); - }); client.on([states.PLAY, 'chat'], function(data) { var message = '<'+client.username+'>' + ' ' + data.message; @@ -93,8 +98,9 @@ server.on('login', function(client) { }); client.on('packet', function(packet) { - console.log("[INFO] " + packet); - log("[INFO] " + message); + // we don't really need to see the server pass an object every 10nth of a second so I will just disable this + //console.log("[INFO] " + packet); + //log("[INFO] " + packet); }) }); diff --git a/package.json b/package.json index 9dda767..6a09bed 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "minecraft-protocol": "^0.14.0", "buffers": "0.1.1", "mocha": "~2.2.5", - "chai": "~3.2.0" + "chai": "~3.2.0", + "prismarine-chunk": "~0.1.0" }, "repository": { "type": "git",