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

blocksToAvoid doesnt work? #24

Closed
Pleezon opened this issue Jul 12, 2020 · 13 comments
Closed

blocksToAvoid doesnt work? #24

Pleezon opened this issue Jul 12, 2020 · 13 comments

Comments

@Pleezon
Copy link

Pleezon commented Jul 12, 2020

Hello!
So, in my code, i have these lines:
var defaultMove = new Movements(this.botInstance, mcData);
defaultMove.blocksToAvoid.add(mcData.blocksByName.iron_trapdoor.id);

But the bot still just moves right through open trapdoors. (i use SetGoal(x,y,z))
Anyone have an idea, why?
Thanks!
PS: sorry for bad english

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

You added only iron_trapdoor, maybe you want to also add the other types of trapdoors (oak_trapdoor, spruce_trapdoor, birch_trapdoor, jungle_trapdoor, etc...)

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

image

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

shouldnt he avoid that trapdoor?

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

yes it should avoid it, I'll have a look

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

my complete code regarding creating the bot:
connect() {
logger.reconnect("Connecting ..");
main.updateConnectionStatus(true);
var botOptions = {
host: "",
port: "25565",
username: this.username,
password: this.password,
version: "1.8.8"
}

    this.botInstance = mineflayer.createBot(botOptions); 
    this.botInstance.loadPlugin(pathfinder);
    const mcData = require('minecraft-data')(this.botInstance.version);
    var defaultMove = new Movements(this.botInstance, mcData);
    defaultMove.blocksToAvoid.add(mcData.blocksByName.iron_trapdoor.id);
    pathfinder(this.botInstance)
    this.botInstance.pathfinder.setMovements(defaultMove);
    bindEvents(this.botInstance)
}

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

It seems that the path goes above the trapdoor, but because the trapdoor is open, gravity makes the bot goes through it. There is a plan to fix that (and more generally all semi-solid blocks) but that is not done yet. It's not a bug with you code or with blocksToAvoid (if you add a block 2 blocks on top of the trapdoor, you'll see it doesn't go through it) but we need a function that tells us if a block is safe to walk on (and where).

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

ummm soooo, is there a way for me to quick-fix this?
just randomly let the bot wiggle a bit every second while not at goal?

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

A very hacky way to solve it would be to override the boundingBox property in mcData to be "empty" instead of "block" https://github.com/PrismarineJS/minecraft-data/blob/master/data/pc/1.15.2/blocks.json#L6315 that way the movement generator will know it can't walk on a trapdoor.

You could also add some extra conditions here https://github.com/Karang/mineflayer-pathfinder/blob/master/lib/movements.js#L82 (the block.physical condition controls if the bot can walk on the block)

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

I'll have a look if I can improve that.

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

thanks :)

@Pleezon
Copy link
Author

Pleezon commented Jul 12, 2020

so, it would be the same with cobwebs, i guess.
would a function, that tells us if a block is safe to walk on (given the block pos) that returns true or false help?
Isnt that just a ton of hardcoding (checking the state of a trapdoor, having cobwebs and fluids on a no-go list etc)
Id help if i knew how prismarine worked. For now, ill just make a list of stuff one cant really walk on, if that helps in any way.

@Karang
Copy link
Collaborator

Karang commented Jul 12, 2020

cobwebs already have boundingBox="empty" so it should be ok. We already have a good description of the block shapes, I'm writing a function to use them properly. For instance, for the trapdoors, it is ok to jump on it, but only on a certain part of it. Having the block shape it is possible to compute the area on top of the block the bot is allowed to walk on. We should also be able to deduce if the bot can traverse the block in a certain direction.

@Karang
Copy link
Collaborator

Karang commented Jul 14, 2020

Should be fixed in the latest release. The bot can now stand on open trapdoors.

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

No branches or pull requests

2 participants