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.
This commit is contained in:
Romain Beaumont 2015-12-06 04:39:09 +01:00
parent bb75c6c1a0
commit 6ab320e3bc

View file

@ -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();
}
};