Skip to content

Commit

Permalink
Merge pull request #282 from kolbytn/return_death
Browse files Browse the repository at this point in the history
Return to death
  • Loading branch information
MaxRobinsonTheGreat authored Nov 4, 2024
2 parents b465af9 + f2bb0d9 commit 0a21561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/agent/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ export class Agent {
this.bot.on('messagestr', async (message, _, jsonMsg) => {
if (jsonMsg.translate && jsonMsg.translate.startsWith('death') && message.startsWith(this.name)) {
console.log('Agent died: ', message);
this.handleMessage('system', `You died with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`);
let death_pos = this.bot.entity.position;
this.memory_bank.rememberPlace('last_death_position', death_pos.x, death_pos.y, death_pos.z);
let death_pos_text = null;
if (death_pos) {
death_pos_text = `x: ${death_pos.x.toFixed(2)}, y: ${death_pos.y.toFixed(2)}, z: ${death_pos.x.toFixed(2)}`;
}
let dimention = this.bot.game.dimension;
this.handleMessage('system', `You died at position ${death_pos_text || "unknown"} in the ${dimention} dimension with the final message: '${message}'. Your place of death is saved as 'last_death_position' if you want to return. Previous actions were stopped and you have respawned.`);
}
});
this.bot.on('idle', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/modes.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const modes = [
update: async function (agent) {
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16);
if (enemy && await world.isClearPath(agent.bot, enemy)) {
say(agent, `Aaa! A ${enemy.name}!`);
say(agent, `Aaa! A ${enemy.name.replace("_", " ")}!`);
execute(this, agent, async () => {
await skills.avoidEnemies(agent.bot, 24);
});
Expand Down

0 comments on commit 0a21561

Please sign in to comment.