mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 14:25:43 +02:00
Merge branch 'kolbytn:main' into patch-1
This commit is contained in:
commit
c7feb2cea9
14 changed files with 62 additions and 46 deletions
|
@ -10,7 +10,7 @@ This project allows an AI model to write/execute code on your computer that may
|
|||
|
||||
## Requirements
|
||||
|
||||
- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.20.4)
|
||||
- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.1)
|
||||
- [Node.js](https://nodejs.org/) (at least v14)
|
||||
- One of these: [OpenAI API Key](https://openai.com/blog/openai-api) | [Gemini API Key](https://aistudio.google.com/app/apikey) |[Anthropic API Key](https://docs.anthropic.com/claude/docs/getting-access-to-claude) | [Replicate API Key](https://replicate.com/) | [Hugging Face API Key](https://huggingface.co/) | [Groq API Key](https://console.groq.com/keys) | [Ollama Installed](https://ollama.com/download)
|
||||
|
||||
|
@ -34,7 +34,7 @@ Then, clone/download this repository
|
|||
|
||||
Run `npm install` from the installed directory
|
||||
|
||||
Install the minecraft version specified in `settings.js`, currently supports up to 1.20.4
|
||||
Install the minecraft version specified in `settings.js`, currently supports up to 1.21.1
|
||||
|
||||
### Running Locally
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
"modes": {
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": true,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"@huggingface/inference": "^2.8.1",
|
||||
"google-translate-api-x": "^10.7.1",
|
||||
"groq-sdk": "^0.5.0",
|
||||
"minecraft-data": "^3.46.2",
|
||||
"mineflayer": "^4.20.0",
|
||||
"minecraft-data": "^3.78.0",
|
||||
"mineflayer": "^4.23.0",
|
||||
"mineflayer-armor-manager": "^2.0.1",
|
||||
"mineflayer-auto-eat": "^3.3.6",
|
||||
"mineflayer-collectblock": "^1.4.1",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"mineflayer-pvp": "^1.3.2",
|
||||
"openai": "^4.4.0",
|
||||
"patch-package": "^8.0.0",
|
||||
"prismarine-item": "^1.14.0",
|
||||
"prismarine-item": "^1.15.0",
|
||||
"prismarine-viewer": "^1.28.0",
|
||||
"replicate": "^0.29.4",
|
||||
"vec3": "^0.1.10",
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
diff --git a/node_modules/mineflayer-pathfinder/index.js b/node_modules/mineflayer-pathfinder/index.js
|
||||
index b38bd30..cfaa677 100644
|
||||
index b38bd30..bf16a63 100644
|
||||
--- a/node_modules/mineflayer-pathfinder/index.js
|
||||
+++ b/node_modules/mineflayer-pathfinder/index.js
|
||||
@@ -541,7 +541,7 @@ function inject (bot) {
|
||||
let canPlace = true
|
||||
if (placingBlock.jump) {
|
||||
bot.setControlState('jump', true)
|
||||
- canPlace = placingBlock.y + 1 < bot.entity.position.y
|
||||
+ canPlace = placingBlock.y + 1.8 < bot.entity.position.y
|
||||
}
|
||||
if (canPlace) {
|
||||
if (!lockEquipItem.tryAcquire()) return
|
||||
@@ -557,6 +557,7 @@ function inject (bot) {
|
||||
@@ -550,6 +550,7 @@ function inject (bot) {
|
||||
lockEquipItem.release()
|
||||
const refBlock = bot.blockAt(new Vec3(placingBlock.x, placingBlock.y, placingBlock.z), false)
|
||||
if (!lockPlaceBlock.tryAcquire()) return
|
||||
+ bot.world.setBlockStateId(refBlock.position.offset(placingBlock.dx, placingBlock.dy, placingBlock.dz), 1)
|
||||
if (interactableBlocks.includes(refBlock.name)) {
|
||||
bot.setControlState('sneak', true)
|
||||
}
|
||||
@@ -557,6 +558,7 @@ function inject (bot) {
|
||||
.then(function () {
|
||||
// Dont release Sneak if the block placement was not successful
|
||||
bot.setControlState('sneak', false)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
"modes": {
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": true,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "claude",
|
||||
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
|
||||
"embedding": "openai",
|
||||
|
||||
|
@ -15,14 +15,15 @@
|
|||
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"torch_placing": true,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
"cheat": false
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
"modes": {
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": true,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
|
|
|
@ -12,14 +12,15 @@
|
|||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"torch_placing": true,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
"cheat": false
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
|
|
|
@ -10,14 +10,15 @@
|
|||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"torch_placing": true,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
"cheat": false
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"self_preservation": true,
|
||||
"unstuck": true,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"torch_placing": true,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
"cheat": false
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
|
|
11
settings.js
11
settings.js
|
@ -1,15 +1,18 @@
|
|||
export default
|
||||
{
|
||||
"minecraft_version": "1.20.4", // supports up to 1.20.4
|
||||
"minecraft_version": "1.20.4", // supports up to 1.21.1
|
||||
"host": "127.0.0.1", // or "localhost", "your.ip.address.here"
|
||||
"port": 55916,
|
||||
"auth": "offline", // or "microsoft"
|
||||
|
||||
"profiles": [
|
||||
"./andy.json",
|
||||
|
||||
// add more profiles here, check ./profiles/ for more
|
||||
// more than 1 profile will require you to /msg each bot indivually
|
||||
// "./profiles/gpt.json",
|
||||
// "./profiles/claude.json",
|
||||
// "./profiles/gemini.json",
|
||||
// "./profiles/llama.json",
|
||||
|
||||
// using more than 1 profile requires you to /msg each bot indivually
|
||||
],
|
||||
"load_memory": false, // load memory from previous session
|
||||
"init_message": "Say hello world and your name", // sends to all on spawn
|
||||
|
|
|
@ -306,8 +306,9 @@ export const actionsList = [
|
|||
{
|
||||
name: '!stay',
|
||||
description: 'Stay in the current location no matter what. Pauses all modes.',
|
||||
perform: wrapExecution(async (agent) => {
|
||||
await skills.stay(agent.bot);
|
||||
params: {'type': { type: 'int', description: 'The number of seconds to stay. -1 for forever.', domain: [-1, Number.MAX_SAFE_INTEGER] }},
|
||||
perform: wrapExecution(async (agent, seconds) => {
|
||||
await skills.stay(agent.bot, seconds);
|
||||
})
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ export function getCommand(name) {
|
|||
return commandMap[name];
|
||||
}
|
||||
|
||||
const commandRegex = /!(\w+)(?:\(((?:[^)(]+|'[^']*'|"[^"]*")*)\))?/
|
||||
const commandRegex = /!(\w+)(?:\(([\s\S]*)\))?/
|
||||
const argRegex = /(?:"[^"]*"|'[^']*'|[^,])+/g;
|
||||
|
||||
export function containsCommand(message) {
|
||||
|
|
|
@ -716,6 +716,9 @@ export async function equip(bot, itemName) {
|
|||
else if (itemName.includes('chestplate') || itemName.includes('elytra')) {
|
||||
await bot.equip(item, 'torso');
|
||||
}
|
||||
else if (itemName.includes('shield')) {
|
||||
await bot.equip(item, 'off-hand');
|
||||
}
|
||||
else {
|
||||
await bot.equip(item, 'hand');
|
||||
}
|
||||
|
@ -1082,10 +1085,11 @@ export async function avoidEnemies(bot, distance=16) {
|
|||
return true;
|
||||
}
|
||||
|
||||
export async function stay(bot) {
|
||||
export async function stay(bot, seconds=30) {
|
||||
/**
|
||||
* Stay in the current position until interrupted. Disables all modes.
|
||||
* @param {MinecraftBot} bot, reference to the minecraft bot.
|
||||
* @param {number} seconds, the number of seconds to stay. Defaults to 30. -1 for indefinite.
|
||||
* @returns {Promise<boolean>} true if the bot stayed, false otherwise.
|
||||
* @example
|
||||
* await skills.stay(bot);
|
||||
|
@ -1097,9 +1101,11 @@ export async function stay(bot) {
|
|||
bot.modes.pause('hunting');
|
||||
bot.modes.pause('torch_placing');
|
||||
bot.modes.pause('item_collecting');
|
||||
while (!bot.interrupt_code) {
|
||||
let start = Date.now();
|
||||
while (!bot.interrupt_code && (seconds === -1 || Date.now() - start < seconds*1000)) {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
}
|
||||
log(bot, `Stayed for ${(Date.now() - start)/1000} seconds.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue