MineDojo / Voyager

An Open-Ended Embodied Agent with Large Language Models
https://voyager.minedojo.org/
MIT License
5.4k stars 493 forks source link

Inventory not updating stuck mining wood endlessly #25

Closed atx-barnes closed 1 year ago

atx-barnes commented 1 year ago

The bot seems to be mining wood logs but nothing seems to register in the inventory. I've been running it for about an hour.

Here is the output message

Chat log: No wood log found in inventory. Mining a wood log...
Collect finish!
Wood log mined.
Inventory: No wood log found.

Biome: plains

Time: day

Nearby blocks: grass_block, grass, oak_leaves, oak_log, dirt, stone

Nearby entities (nearest to farthest): bee, sheep

Health: 20.0/20

Hunger: 20.0/20

Position: x=1.5, y=68.0, z=23.5

Equipment: [None, None, None, None, None, None]

Inventory (0/36): Empty

Chests: None

Task: Craft 4 wooden planks

Context: Question: How to craft 4 wooden planks in Minecraft?
Answer: To craft 4 wooden planks in Minecraft, you need to place one wooden log in any square of the crafting grid. This will give you 4 wooden planks.

Critique: None

Action Agent ai message Explain: The code failed to find the mined wood log in the inventory after mining it. This might be due to the bot not waiting long enough to pick up the dropped item.

Plan: 1) Increase the waiting time after mining the wood log to ensure the bot picks up the dropped item. 2) Check the inventory for the wood log again after waiting. 3) If the wood log is still not found, mine another wood log and repeat the process. 4) Craft 4 wooden planks from the wood log.

Code:

async function mineWoodLog(bot) {
  // Find a wood log block nearby
  const logBlock = bot.findBlock({
    matching: block => {
      return block.name.endsWith("_log");
    },
    maxDistance: 32
  });
  if (!logBlock) {
    bot.chat("No wood log found nearby. Exploring...");
    await exploreUntil(bot, new Vec3(1, 0, 1), 60, () => {
      const logBlock = bot.findBlock({
        matching: block => {
          return block.name.endsWith("_log");
        },
        maxDistance: 32
      });
      return logBlock;
    });
  }

  // Mine the wood log block
  await mineBlock(bot, logBlock.name, 1);
  bot.chat("Wood log mined.");

  // Move to the position where the wood log was mined and wait for a moment to pick up the dropped item
  await bot.pathfinder.goto(new GoalNear(logBlock.position.x, logBlock.position.y, logBlock.position.z, 1));
  await bot.waitForTicks(200); // Wait for 10 seconds (200 ticks)

  // Check the inventory for the mined wood log
  let logItem = bot.inventory.items().find(item => item.name === logBlock.name);

  // Chat the inventory information
  if (logItem) {
    bot.chat(`Inventory: ${logItem.name} x${logItem.count}`);
  } else {
    bot.chat("Inventory: No wood log found.");
  }
}

async function craftWoodenPlanks(bot) {
  // Check if there is a wood log in the inventory
  let woodLog = bot.inventory.items().find(item => item.name.endsWith("_log"));

  // If not, mine a wood log
  while (!woodLog) {
    bot.chat("No wood log found in inventory. Mining a wood log...");
    await mineWoodLog(bot);
    woodLog = bot.inventory.items().find(item => item.name.endsWith("_log"));
  }

  // Craft 4 wooden planks from the wood log
  const logName = woodLog.name;
  const plankName = logName.replace("_log", "_planks");
  bot.chat(`Crafting 4 ${plankName} from ${logName}...`);
  await craftItem(bot, plankName, 1);
  bot.chat(`Crafted 4 ${plankName}.`);
}
atx-barnes commented 1 year ago

Fixed it

go-maple commented 1 year ago

How to fix it?

atx-barnes commented 1 year ago

How to fix it?

When starting the LAN connection to the server make sure that mode is set to survival or blocks won't drop items for the bot to pick up for its inventory.

theblazehen commented 1 year ago

https://github.com/MineDojo/Voyager/blob/main/installation/minecraft_instance_install.md#option-2-minecraft-official-launcher Interesting, as this says it should be creative