Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MindServer Development #484

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6bc751d
update gemini model version to 2.0-flash
uukelele-scratch Mar 9, 2025
4a9bcad
Merge branch 'main' of https://github.com/kolbytn/mindcraft
uukelele-scratch Mar 19, 2025
2d1346d
Merge branch 'main' of https://github.com/uukelele-scratch/mindcraft-…
uukelele-scratch Mar 19, 2025
dde02d8
Merge branch 'develop' of https://github.com/kolbytn/mindcraft
uukelele-scratch Mar 19, 2025
8a00fed
add function to update settings dynamically
uukelele-scratch Mar 19, 2025
ee08e64
create a styles.css file as I plan to add more html files to the mind…
uukelele-scratch Mar 19, 2025
b236f20
Added settings frontend, mostly complete, excluding profile and only …
uukelele-scratch Mar 19, 2025
23ad726
rename label for vision permission in settings
uukelele-scratch Mar 19, 2025
8934f59
added lists for profile and only chat with
uukelele-scratch Mar 19, 2025
14d5f0b
added get settings function from mindserver
uukelele-scratch Mar 20, 2025
937d050
refactor get-settings handling to return settings object directly
uukelele-scratch Mar 20, 2025
61c1310
added settings viewing from actual settings data
uukelele-scratch Mar 20, 2025
e029c64
improved button styling
uukelele-scratch Mar 20, 2025
c1e292f
show/hide settings toggle
uukelele-scratch Mar 20, 2025
3763fab
added function to get modified settings + enhanced button styling sli…
uukelele-scratch Mar 20, 2025
2b42f3f
added edit settings feature with save/reset buttons
uukelele-scratch Mar 20, 2025
066848b
added functionality to load and save user-modified settings from a JS…
uukelele-scratch Mar 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'develop' of https://github.com/kolbytn/mindcraft
uukelele-scratch committed Mar 19, 2025
commit dde02d8753dd2f579e1371ba6939b9ee2d3def78
56 changes: 41 additions & 15 deletions src/agent/commands/actions.js
Original file line number Diff line number Diff line change
@@ -407,25 +407,51 @@ export const actionsList = [
return `Converstaion with ${player_name} ended.`;
}
},
{
name: '!lookAtPlayer',
description: 'Look at a player or look in the same direction as the player.',
params: {
'player_name': { type: 'string', description: 'Name of the target player' },
'direction': {
type: 'string',
description: 'How to look ("at": look at the player, "with": look in the same direction as the player)',
}
},
perform: async function(agent, player_name, direction) {
if (direction !== 'at' && direction !== 'with') {
return "Invalid direction. Use 'at' or 'with'.";
}
let result = "";
const actionFn = async () => {
result = await agent.vision_interpreter.lookAtPlayer(player_name, direction);
};
await agent.actions.runAction('action:lookAtPlayer', actionFn);
return result;
}
},
{
name: '!lookAtPosition',
description: 'Look at specified coordinates.',
params: {
'x': { type: 'int', description: 'x coordinate' },
'y': { type: 'int', description: 'y coordinate' },
'z': { type: 'int', description: 'z coordinate' }
},
perform: async function(agent, x, y, z) {
let result = "";
const actionFn = async () => {
result = await agent.vision_interpreter.lookAtPosition(x, y, z);
};
await agent.actions.runAction('action:lookAtPosition', actionFn);
return result;
}
},
{
name: '!digDown',
description: 'Digs down a specified distance.',
params: {'distance': { type: 'int', description: 'Distance to dig down'}},
description: 'Digs down a specified distance. Will stop if it reaches lava, water, or a fall of >=4 blocks below the bot.',
params: {'distance': { type: 'int', description: 'Distance to dig down', domain: [1, Number.MAX_SAFE_INTEGER] }},
perform: runAsAction(async (agent, distance) => {
await skills.digDown(agent.bot, distance)
})
},
// { // commented for now, causes confusion with goal command
// name: '!npcGoal',
// description: 'Set a simple goal for an item or building to automatically work towards. Do not use for complex goals.',
// params: {
// 'name': { type: 'string', description: 'The name of the goal to set. Can be item or building name. If empty will automatically choose a goal.' },
// 'quantity': { type: 'int', description: 'The quantity of the goal to set. Default is 1.', domain: [1, Number.MAX_SAFE_INTEGER] }
// },
// perform: async function (agent, name=null, quantity=1) {
// await agent.npc.setGoal(name, quantity);
// agent.bot.emit('idle'); // to trigger the goal
// return 'Set npc goal: ' + agent.npc.data.curr_goal.name;
// }
// },
];
59 changes: 32 additions & 27 deletions src/agent/library/skills.js
Original file line number Diff line number Diff line change
@@ -1423,54 +1423,59 @@ export async function activateNearestBlock(bot, type) {
return true;
}


export async function digDown(bot, distance = 10) {
/**
* Digs down a specified distance.
* Digs down a specified distance. Will stop if it reaches lava, water, or a fall of >=4 blocks below the bot.
* @param {MinecraftBot} bot, reference to the minecraft bot.
* @param {int} distance, distance to dig down.
* @returns {Promise<boolean>} true if successfully dug down.
* @returns {Promise<boolean>} true if successfully dug all the way down.
* @example
* await skills.digDown(bot, 10);
**/

for (let i = 0; i < distance; i++) {
const targetBlock = bot.blockAt(bot.entity.position.offset(0, -1, 0));
const belowBlock = bot.blockAt(bot.entity.position.offset(0, -2, 0));
let start_block_pos = bot.blockAt(bot.entity.position).position;
for (let i = 1; i <= distance; i++) {
const targetBlock = bot.blockAt(start_block_pos.offset(0, -i, 0));
let belowBlock = bot.blockAt(start_block_pos.offset(0, -i-1, 0));

if (!targetBlock || !belowBlock) {
log(bot, `Dug down ${i-1} blocks, but reached the end of the world.`);
return true;
}

// Check for lava, water
if (!targetBlock || targetBlock.name === 'lava' || targetBlock.name === 'water' ||
(belowBlock && (belowBlock.name === 'lava' || belowBlock.name === 'water'))) {
console.log(`Dug down ${i} blocks, but reached ${belowBlock ? belowBlock.name : '(lava/water)'}`);
log(bot, `Dug down ${i} blocks, but reached ${belowBlock ? belowBlock.name : '(lava/water)'}`)
if (targetBlock.name === 'lava' || targetBlock.name === 'water' ||
belowBlock.name === 'lava' || belowBlock.name === 'water') {
log(bot, `Dug down ${i-1} blocks, but reached ${belowBlock ? belowBlock.name : '(lava/water)'}`)
return false;
}

// Check for a fall of more than 5 blocks below the bot
let isSafe = false;
for (let j = 1; j <= 5; j++) {
const belowBlock = bot.blockAt(bot.entity.position.offset(0, -j-1, 0));
if (!belowBlock || belowBlock.name !== 'air') {
isSafe = true;
const MAX_FALL_BLOCKS = 2;
let num_fall_blocks = 0;
for (let j = 0; j <= MAX_FALL_BLOCKS; j++) {
if (!belowBlock || (belowBlock.name !== 'air' && belowBlock.name !== 'cave_air')) {
break;
}
num_fall_blocks++;
belowBlock = bot.blockAt(belowBlock.position.offset(0, -1, 0));
}

if (!targetBlock || !isSafe) {
console.log(`Dug down ${i} blocks, but reached fall`);
log(bot, `Dug down ${i} blocks, but reached fall`);
if (num_fall_blocks > MAX_FALL_BLOCKS) {
log(bot, `Dug down ${i-1} blocks, but reached a drop below the next block.`);
return false;
}

if (bot.canDigBlock(targetBlock)) {
await breakBlockAt(bot, bot.entity.position.x, bot.entity.position.y - 1, bot.entity.position.z);
await bot.waitForTicks(10); // wait for a short period to avoid issues
await bot.entity.position.offset(0, -1, 0);
} else {
console.log('Cannot dig block at position:', bot.entity.position.offset(0, -1, 0));
log(bot, 'Cannot dig block at position:' + bot.entity.position.offset(0, -1, 0))
if (targetBlock.name === 'air' || targetBlock.name === 'cave_air') {
log(bot, 'Skipping air block');
console.log(targetBlock.position);
continue;
}

let dug = await breakBlockAt(bot, targetBlock.position.x, targetBlock.position.y, targetBlock.position.z);
if (!dug) {
log(bot, 'Failed to dig block at position:' + targetBlock.position);
return false;
}
}
log(bot, `Dug down ${distance} blocks.`);
return true;
}
You are viewing a condensed version of this merge commit. You can view the full changes here.