2024-01-25 13:25:36 -08:00
|
|
|
import * as world from '../library/world.js';
|
|
|
|
import * as mc from '../../utils/mcdata.js';
|
|
|
|
|
2023-11-07 09:44:56 -06:00
|
|
|
|
|
|
|
const pad = (str) => {
|
|
|
|
return '\n' + str + '\n';
|
|
|
|
}
|
|
|
|
|
2024-01-09 22:50:22 -06:00
|
|
|
// queries are commands that just return strings and don't affect anything in the world
|
|
|
|
export const queryList = [
|
2023-11-07 09:44:56 -06:00
|
|
|
{
|
|
|
|
name: "!stats",
|
2024-01-14 14:35:23 -06:00
|
|
|
description: "Get your bot's location, health, hunger, and time of day.",
|
2023-11-07 12:00:55 -06:00
|
|
|
perform: function (agent) {
|
2023-12-28 09:20:26 -08:00
|
|
|
let bot = agent.bot;
|
|
|
|
let res = 'STATS';
|
2024-01-14 14:35:23 -06:00
|
|
|
let pos = bot.entity.position;
|
|
|
|
// display position to 2 decimal places
|
|
|
|
res += `\n- Position: x: ${pos.x.toFixed(2)}, y: ${pos.y.toFixed(2)}, z: ${pos.z.toFixed(2)}`;
|
2024-05-14 21:05:39 -05:00
|
|
|
res += `\n- Gamemode: ${bot.game.gameMode}`;
|
2024-01-14 14:35:23 -06:00
|
|
|
res += `\n- Health: ${Math.round(bot.health)} / 20`;
|
|
|
|
res += `\n- Hunger: ${Math.round(bot.food)} / 20`;
|
2024-01-25 13:25:36 -08:00
|
|
|
res += `\n- Biome: ${world.getBiomeName(bot)}`;
|
2024-05-14 21:05:39 -05:00
|
|
|
let weather = "Clear";
|
2024-01-24 17:24:52 -06:00
|
|
|
if (bot.rainState > 0)
|
|
|
|
weather = "Rain";
|
|
|
|
if (bot.thunderState > 0)
|
|
|
|
weather = "Thunderstorm";
|
|
|
|
res += `\n- Weather: ${weather}`;
|
2024-01-14 14:35:23 -06:00
|
|
|
// let block = bot.blockAt(pos);
|
|
|
|
// res += `\n- Artficial light: ${block.skyLight}`;
|
|
|
|
// res += `\n- Sky light: ${block.light}`;
|
|
|
|
// light properties are bugged, they are not accurate
|
|
|
|
|
2023-12-28 09:20:26 -08:00
|
|
|
if (bot.time.timeOfDay < 6000) {
|
2024-01-14 14:35:23 -06:00
|
|
|
res += '\n- Time: Morning';
|
2023-12-28 09:20:26 -08:00
|
|
|
} else if (bot.time.timeOfDay < 12000) {
|
2024-01-14 14:35:23 -06:00
|
|
|
res += '\n- Time: Afternoon';
|
2023-12-28 09:20:26 -08:00
|
|
|
} else {
|
2024-01-14 14:35:23 -06:00
|
|
|
res += '\n- Time: Night';
|
2023-12-28 09:20:26 -08:00
|
|
|
}
|
2024-02-25 14:21:44 -06:00
|
|
|
|
|
|
|
let other_players = world.getNearbyPlayerNames(bot);
|
|
|
|
if (other_players.length > 0) {
|
|
|
|
res += '\n- Other Players: ' + other_players.join(', ');
|
|
|
|
}
|
2023-12-28 09:20:26 -08:00
|
|
|
return pad(res);
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "!inventory",
|
|
|
|
description: "Get your bot's inventory.",
|
2023-11-07 12:00:55 -06:00
|
|
|
perform: function (agent) {
|
2023-12-28 09:20:26 -08:00
|
|
|
let bot = agent.bot;
|
2024-01-25 13:25:36 -08:00
|
|
|
let inventory = world.getInventoryCounts(bot);
|
2023-12-28 09:20:26 -08:00
|
|
|
let res = 'INVENTORY';
|
|
|
|
for (const item in inventory) {
|
|
|
|
if (inventory[item] && inventory[item] > 0)
|
|
|
|
res += `\n- ${item}: ${inventory[item]}`;
|
|
|
|
}
|
|
|
|
if (res == 'INVENTORY') {
|
|
|
|
res += ': none';
|
|
|
|
}
|
2024-05-14 21:05:39 -05:00
|
|
|
if (agent.bot.game.gameMode === 'creative') {
|
|
|
|
res += '\n(You have infinite items in creative mode)';
|
|
|
|
}
|
2023-12-28 09:20:26 -08:00
|
|
|
return pad(res);
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-02-16 11:57:48 -06:00
|
|
|
name: "!nearbyBlocks",
|
2023-11-07 09:44:56 -06:00
|
|
|
description: "Get the blocks near the bot.",
|
2023-11-07 12:00:55 -06:00
|
|
|
perform: function (agent) {
|
2023-12-28 09:20:26 -08:00
|
|
|
let bot = agent.bot;
|
|
|
|
let res = 'NEARBY_BLOCKS';
|
2024-01-25 13:25:36 -08:00
|
|
|
let blocks = world.getNearbyBlockTypes(bot);
|
2023-12-28 09:20:26 -08:00
|
|
|
for (let i = 0; i < blocks.length; i++) {
|
|
|
|
res += `\n- ${blocks[i]}`;
|
|
|
|
}
|
|
|
|
if (blocks.length == 0) {
|
|
|
|
res += ': none';
|
|
|
|
}
|
|
|
|
return pad(res);
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "!craftable",
|
|
|
|
description: "Get the craftable items with the bot's inventory.",
|
2023-11-07 12:00:55 -06:00
|
|
|
perform: function (agent) {
|
2023-12-28 09:20:26 -08:00
|
|
|
const bot = agent.bot;
|
2024-01-25 13:25:36 -08:00
|
|
|
const table = world.getNearestBlock(bot, 'crafting_table');
|
2023-12-28 09:20:26 -08:00
|
|
|
let res = 'CRAFTABLE_ITEMS';
|
2024-01-25 13:25:36 -08:00
|
|
|
for (const item of mc.getAllItems()) {
|
2023-12-28 09:20:26 -08:00
|
|
|
let recipes = bot.recipesFor(item.id, null, 1, table);
|
|
|
|
if (recipes.length > 0) {
|
|
|
|
res += `\n- ${item.name}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (res == 'CRAFTABLE_ITEMS') {
|
|
|
|
res += ': none';
|
|
|
|
}
|
|
|
|
return pad(res);
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "!entities",
|
|
|
|
description: "Get the nearby players and entities.",
|
2023-11-07 12:00:55 -06:00
|
|
|
perform: function (agent) {
|
2023-12-28 09:20:26 -08:00
|
|
|
let bot = agent.bot;
|
|
|
|
let res = 'NEARBY_ENTITIES';
|
2024-01-25 13:25:36 -08:00
|
|
|
for (const entity of world.getNearbyPlayerNames(bot)) {
|
2023-12-28 09:20:26 -08:00
|
|
|
res += `\n- player: ${entity}`;
|
|
|
|
}
|
2024-01-25 13:25:36 -08:00
|
|
|
for (const entity of world.getNearbyEntityTypes(bot)) {
|
2023-12-28 09:20:26 -08:00
|
|
|
res += `\n- mob: ${entity}`;
|
|
|
|
}
|
|
|
|
if (res == 'NEARBY_ENTITIES') {
|
|
|
|
res += ': none';
|
|
|
|
}
|
|
|
|
return pad(res);
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
|
|
|
},
|
2024-01-23 18:01:38 -06:00
|
|
|
{
|
|
|
|
name: "!modes",
|
|
|
|
description: "Get all available modes and see which are on/off.",
|
|
|
|
perform: function (agent) {
|
2024-01-25 13:25:36 -08:00
|
|
|
return agent.bot.modes.getStr();
|
2024-01-23 18:01:38 -06:00
|
|
|
}
|
2024-04-27 23:28:34 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '!savedPlaces',
|
|
|
|
description: 'List all saved locations.',
|
|
|
|
perform: async function (agent) {
|
2024-04-27 23:36:58 -05:00
|
|
|
return "Saved place names: " + agent.memory_bank.getKeys();
|
2024-04-27 23:28:34 -05:00
|
|
|
}
|
2024-01-25 15:52:07 -08:00
|
|
|
}
|
2024-01-25 13:25:36 -08:00
|
|
|
];
|