From 6ab320e3bcaf81e8ae1a25326ee4005681b39c40 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sun, 6 Dec 2015 04:39:09 +0100 Subject: [PATCH] sendRelativePositionChange needs to be async because of behavior use not sure if that behavior thingy has its place in that function, I think 'move' is not really a behavior at all. 'letPlayerMove' would be a normal behavior and it would be in sendRelativePositionChange. Making plugins able to break function is not at all a good idea imho. --- src/lib/plugins/updatePositions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/plugins/updatePositions.js b/src/lib/plugins/updatePositions.js index a34f6e3..064a68c 100644 --- a/src/lib/plugins/updatePositions.js +++ b/src/lib/plugins/updatePositions.js @@ -52,10 +52,10 @@ module.exports.player=function(player) }); player.sendRelativePositionChange = (newPosition, onGround) => { - player.behavior('move', { + return player.behavior('move', { onGround: onGround, position: newPosition - }, () => { + }, async () => { if (player.position.distanceTo(new Vec3(0, 0, 0)) != 0) { var diff = newPosition.minus(player.position); if(diff.abs().x>127 || diff.abs().y>127 || diff.abs().z>127) @@ -85,7 +85,7 @@ module.exports.player=function(player) }, () => { player.sendPosition(); }); - } + }; player.sendPosition = () => { player._client.write('position', { @@ -98,8 +98,8 @@ module.exports.player=function(player) }); }; - player.teleport = (position) => { - player.sendRelativePositionChange(position, false); + player.teleport = async (position) => { + await player.sendRelativePositionChange(position, false); player.sendPosition(); } };