From b2419d1ee8cec07af00b378e7df68aed666d7725 Mon Sep 17 00:00:00 2001 From: deathcap Date: Tue, 24 Mar 2015 21:39:25 -0700 Subject: [PATCH] Update workerstream dependency for Buffer conversion PR for https://github.com/maxogden/workerstream/pull/11 Emit data event data as a Buffer --- clientmc.js | 7 ++++++- mf-worker.js | 16 ++++++++++++---- package.json | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/clientmc.js b/clientmc.js index 2f1bbb9..d7d2ebc 100644 --- a/clientmc.js +++ b/clientmc.js @@ -252,16 +252,20 @@ ClientMC.prototype.enable = function() { }); */ - // create bot + // create bot TODO: fully move to mf-worker + /* this.bot = mineflayer.createBot({ username: username, stream: this.websocketStream, }); + */ this.game.voxels.on('missingChunk', this.missingChunk.bind(this)); this.voxelChunks = {}; + /* TODO + // WebSocket to server proxy (wsmc) var self = this; this.bot.on('error', function(err) { @@ -314,6 +318,7 @@ ClientMC.prototype.enable = function() { self.commands.isConnectedToServer = true; }); + */ var maxId = 255; // TODO: 4096? diff --git a/mf-worker.js b/mf-worker.js index 9cb7d05..f761e8c 100644 --- a/mf-worker.js +++ b/mf-worker.js @@ -5,22 +5,30 @@ var mineflayer = require('wsmc/mineflayer-stream'); module.exports = function(self) { console.log('mf-worker initializing',self); - console.log('Object=',Object.prototype); + debugger; self.parentStream = ParentStream(); - /* self.bot = mineflayer.createBot({ username: 'user1', // TODO stream: self.parentStream, }); console.log('mf-worker bot',self.bot); - */ + self.bot.on('game', function() { + console.log('Spawn position: '+JSON.stringify(self.bot.spawnPoint)); + }); + + self.bot.on('kicked', function(reason) { + console.log('mf-worker bot kicked because:',reason); + }); + + /* self.onmessage = function(event) { console.log('mf-worker onmessage',event); - //self.postMessage({whats: 'up'}); + self.postMessage({whats: 'up'}); }; + */ }; diff --git a/package.json b/package.json index 0d86bd0..ee6b36e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "vec3": "^0.1.3", "websocket-stream": "^1.4.0", "webworkify": "^1.0.2", - "workerstream": "^1.2.1", + "workerstream": "git://github.com/deathcap/workerstream.git#buffer", "wsmc": "git://github.com/deathcap/wsmc.git#master" }, "scripts": {