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

The bot.dig() function can only mine a block once on a 1.20.1 Folia server. #3579

Open
1 task done
Tangent-90C opened this issue Feb 10, 2025 · 4 comments
Open
1 task done

Comments

@Tangent-90C
Copy link

Tangent-90C commented Feb 10, 2025

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.26.0
  • server: Folia 1.20.1
  • node: v23.7.0

Detailed description of a problem

A clear and concise description of what the problem is, with as much context as possible.
What are you building? What problem are you trying to solve?

What did you try yet?

I use the bot.dig(block, [forceLook = true], [digFace]) API to mine blocks, but it can only mine a block once. After the first mining, although the progress bar completes and the block appears to be mined on the client side, it is not actually mined on the server side. In Prismarine-viewer, the block will only briefly show as being mined before reverting to its original state.
To continue mining blocks, I have to disconnect from the server and reconnect, after which I can mine a block once again.
Throughout this process, there are no error messages reported.

Your current code

const { pathfinder, Movements, goals } = require('mineflayer-pathfinder');
const { Vec3 } = require('vec3');


// Function to find and dig all leaves within reach
async function digLeavesAround2() {
    const leaves = bot.findBlocks({
        matching: block => block.name.includes('leaves'),
        maxDistance: 5, // Adjust the distance as needed
        count: 100
    });

    for (const position of leaves) {
        block = bot.blockAt(position);
        if (block) {

            while (block.name.includes('leaves')) {
                await bot.dig(block, forceLook = false);
                await bot.waitForTicks(10);
                block = bot.blockAt(position);
            }
            // await bot.dig(block, forceLook = true);

            console.log(`Dug2 leaves at ${position}`);
        }
        // Wait a bit before digging the next block

    }
}

async function digLeavesAround() {
    const leaves = bot.findBlocks({
        matching: block => block.name.includes('grass'),
        maxDistance: 5, // Adjust the distance as needed
        count: 100
    });

    for (const position of leaves) {
        const block = bot.blockAt(position);
        if (block) {
            // await bot.dig(block, forceLook = true);
            await bot.dig(block, forceLook = false, digFace='raycast');
            console.log(`Dug leaves at ${position}`);
        }
        // Wait a bit before digging the next block
        await bot.waitForTicks(2);
    }
}


// Function to follow a path and dig leaves at each stop
async function followPathAndDig(path) {
    for (const position of path) {
        await bot.pathfinder.goto(new goals.GoalBlock(position.x, position.y, position.z));
        await digLeavesAround();
    }
}

// Example path (replace with your actual path)
const path = [
    new Vec3(10, 64, 10),
    new Vec3(15, 64, 15),
    new Vec3(20, 64, 20)
];


module.exports = { followPathAndDig, digLeavesAround, digLeavesAround2  };

Expected behavior

Under normal circumstances, calling digLeavesAround or digLeavesAround2 should remove all the surrounding grass and leaves, but after mining one, it fails to continue mining unless I re-enter the server.

Additional context

I'm not sure if this bug can be reproduced on all Folia servers. Here, I'll provide the server where this bug occurs: https://www.bilibili.com/video/BV1MkbFejEgP.
This is its description. To join this server, you need to bind a high-level QQ account. If you haven't used QQ before, don't attempt to connect to this server.

@Tangent-90C Tangent-90C added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Feb 10, 2025
@extremeheat
Copy link
Member

Can you reproduce this on a vanilla server?

@extremeheat extremeheat added waiting info from op and removed possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Feb 10, 2025
@Tangent-90C
Copy link
Author

I set up an official 1.20.1 vanilla server myself, but I haven't been able to reproduce this bug.

@Tangent-90C
Copy link
Author

I built myself a Folia server of version 1.20.6 and haven't been able to reproduce the issue (due to network issues, I failed to compile the Folia of version 1.20.1 and had to use a precompiled version from others).

@Tangent-90C
Copy link
Author

This bug might not be caused by the server itself. It could be due to anti-cheat measures. I just tested on the server where the bug occurred, and I got kicked out, with the message: "FastPlace/FastBreak Hacks".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants