mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-29 09:18:31 +02:00
add new feature:
show position , health ,weather and food
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export default (socket) => {
|
||||
|
||||
let ondeath = () => {
|
||||
var pos = socket.mcbot.entity.position;
|
||||
socket.emit('buffer:info', `You have been dead in X:${pos.x}, Y:${pos.y}, Z:${pos.z} `);
|
||||
};
|
||||
|
||||
socket.mcbot.on('death', ondeath);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
export default (socket) => {
|
||||
|
||||
let onHealth = () => {
|
||||
var health = socket.mcbot.health || 0;
|
||||
var food = socket.mcbot.food||0;
|
||||
var foodSaturation = socket.mcbot.foodSaturation||0;
|
||||
socket.emit('bot:health', {health:health,food:food,foodSaturation:foodSaturation});
|
||||
};
|
||||
|
||||
socket.mcbot.on('health', onHealth);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
export default (socket) => {
|
||||
|
||||
let onRain = () => {
|
||||
if (socket.mcbot.entity.isRaining){
|
||||
socket.emit('buffer:info', `It started raining.`);
|
||||
}else{
|
||||
socket.emit('buffer:info', `It stopped raining. `);
|
||||
}
|
||||
};
|
||||
|
||||
socket.mcbot.on('spawn', onRain);
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user