mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-08 12:40:52 +00:00
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:
parent
bb75c6c1a0
commit
6ab320e3bc
1 changed files with 5 additions and 5 deletions
|
|
@ -52,10 +52,10 @@ module.exports.player=function(player)
|
||||||
});
|
});
|
||||||
|
|
||||||
player.sendRelativePositionChange = (newPosition, onGround) => {
|
player.sendRelativePositionChange = (newPosition, onGround) => {
|
||||||
player.behavior('move', {
|
return player.behavior('move', {
|
||||||
onGround: onGround,
|
onGround: onGround,
|
||||||
position: newPosition
|
position: newPosition
|
||||||
}, () => {
|
}, async () => {
|
||||||
if (player.position.distanceTo(new Vec3(0, 0, 0)) != 0) {
|
if (player.position.distanceTo(new Vec3(0, 0, 0)) != 0) {
|
||||||
var diff = newPosition.minus(player.position);
|
var diff = newPosition.minus(player.position);
|
||||||
if(diff.abs().x>127 || diff.abs().y>127 || diff.abs().z>127)
|
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.sendPosition = () => {
|
player.sendPosition = () => {
|
||||||
player._client.write('position', {
|
player._client.write('position', {
|
||||||
|
|
@ -98,8 +98,8 @@ module.exports.player=function(player)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
player.teleport = (position) => {
|
player.teleport = async (position) => {
|
||||||
player.sendRelativePositionChange(position, false);
|
await player.sendRelativePositionChange(position, false);
|
||||||
player.sendPosition();
|
player.sendPosition();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue