mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-20 05:13:27 +02:00
fdc031e660
show position , health ,weather and food
25 lines
627 B
JavaScript
25 lines
627 B
JavaScript
export default (socket) => {
|
|
|
|
let onmove = () => {
|
|
var pos = socket.mcbot.entity.position;
|
|
if(movingornot(socket.mcbot.entity.velocity)){
|
|
socket.emit('bot:move', {x:pos.x.toFixed(2),y:pos.y.toFixed(2),z:pos.z.toFixed(2)});
|
|
}
|
|
};
|
|
|
|
socket.mcbot.on('move', onmove);
|
|
|
|
let onforcedMove = () => {
|
|
var pos = socket.mcbot.entity.position;
|
|
socket.emit('bot:forcedMove', {x:pos.x.toFixed(2),y:pos.y.toFixed(2),z:pos.z.toFixed(2)});
|
|
};
|
|
|
|
socket.mcbot.on('forcedMove', onforcedMove);
|
|
|
|
function movingornot(v){
|
|
if(v.x!=0) return true;
|
|
if(v.y!=0) return true;
|
|
if(v.z!=0) return true;
|
|
}
|
|
};
|