voxel / voxel-clientmc

Minecraft client using WebSockets and voxel-engine (voxel.js plugin)
57 stars 13 forks source link

Client not updating for sapling growth into tree #30

Closed deathcap closed 8 years ago

deathcap commented 8 years ago

Other clients playing blocks correctly updates the web client, but not when a sapling grows into a tree:

screen shot 2016-02-07 at 8 12 08 pm
deathcap commented 8 years ago

multi_block_change http://wiki.vg/Protocol#Multi_Block_Change packet (vs single block_change)

screen shot 2016-02-07 at 8 34 29 pm

voxel-clientmc/chunks.js

  clientmc.handlers.setBlock = (event) => {
    clientmc.game.setBlock(event.position, event.value);
  };

voxel-clientmc/mfworker.js

  let pos = [0,0,0];
  self.bot.on('blockUpdate', function(oldBlock, newBlock) {
    console.log('blockUpdate', oldBlock, newBlock);
    const position = newBlock.position;
    pos[0] = position.x; 
    pos[1] = position.y;
    pos[2] = position.z;
    const val = self.translateBlockID((newBlock.type << 4) | newBlock.metadata);
    self.postMessage({cmd: 'setBlock', position: pos, value: val});
    //self.game.setBlock(pos, val);
  });
  // TODO: also handle mass block update (event? would like to optimize multi_block_change, but..)
deathcap commented 8 years ago

Oh this was already fixed in mineflayer: https://github.com/PrismarineJS/mineflayer/pull/364 Corrected multi_block_change https://github.com/PrismarineJS/mineflayer/commit/0fc7d0a5154b3c116917855496d77a93d4fc498f, just needed to update wsmc:

https://github.com/deathcap/wsmc/commit/d1cf6252ae27c95eb0a010dc8407b375c2f61ade Update to latest mineflayer