mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-21 21:52:07 +02:00
Add files via upload
This commit is contained in:
parent
e8e3cb7116
commit
648d4f8255
2 changed files with 30 additions and 1 deletions
|
@ -28,6 +28,8 @@ export class Agent {
|
||||||
|
|
||||||
initModes(this);
|
initModes(this);
|
||||||
|
|
||||||
|
let last_death_pos = null;
|
||||||
|
|
||||||
let save_data = null;
|
let save_data = null;
|
||||||
if (load_mem) {
|
if (load_mem) {
|
||||||
save_data = this.history.load();
|
save_data = this.history.load();
|
||||||
|
@ -260,7 +262,21 @@ export class Agent {
|
||||||
this.bot.on('messagestr', async (message, _, jsonMsg) => {
|
this.bot.on('messagestr', async (message, _, jsonMsg) => {
|
||||||
if (jsonMsg.translate && jsonMsg.translate.startsWith('death') && message.startsWith(this.name)) {
|
if (jsonMsg.translate && jsonMsg.translate.startsWith('death') && message.startsWith(this.name)) {
|
||||||
console.log('Agent died: ', message);
|
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);
|
||||||
|
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 inventory = this.bot.inventory.slots;
|
||||||
|
let death_items = "";
|
||||||
|
for (let i=0; i<inventory.length; i++) {
|
||||||
|
if (inventory[i]) {
|
||||||
|
death_items += `${inventory[i].name} x${inventory[i].count}, `;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.history.add('system', `You died at position ${death_pos_text || "unknown"} with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`);
|
||||||
|
this.handleMessage('system', `You died at position ${death_pos_text || "unknown"} and droped the items ${death_items} at your death position with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions. you can retrieve your items by doing the action !goToDeath.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.bot.on('idle', () => {
|
this.bot.on('idle', () => {
|
||||||
|
|
|
@ -295,6 +295,19 @@ export const actionsList = [
|
||||||
await skills.goToBed(agent.bot);
|
await skills.goToBed(agent.bot);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "!goToDeath",
|
||||||
|
description: "Go to the location of your bot's last death position and retrieve any lost items.",
|
||||||
|
perform: wrapExecution(async (agent) => {
|
||||||
|
let death_pos = agent.memory_bank.recallPlace('last death position')[0]; // <- dont even ask why this is an array
|
||||||
|
if (death_pos !== null) {
|
||||||
|
await skills.goToPosition(agent.bot, death_pos.x, death_pos.y, death_pos.z, 1);
|
||||||
|
console.log('going to death');
|
||||||
|
} else {
|
||||||
|
skills.log(agent.bot, "No death location saved.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '!activate',
|
name: '!activate',
|
||||||
description: 'Activate the nearest object of a given type.',
|
description: 'Activate the nearest object of a given type.',
|
||||||
|
|
Loading…
Add table
Reference in a new issue