cabaletta / baritone

google maps for block game
GNU Lesser General Public License v3.0
7.29k stars 1.46k forks source link

Pathfinding can fail with `IllegalStateException` when sneaking off a block #4528

Closed ZacSharp closed 1 month ago

ZacSharp commented 1 month ago

Some information

Operating system: Linux Java version: 21 Minecraft version: 1.20.6 Baritone version: fd8af9ba6722096b80d6e993854293cd22864486 Other mods (if used): Litematica 1.18.1 + Malilib 1.19.0

(i.e. the workspace I used to test #4527)

Exception, error or logs

[16:31:28] [Render thread/INFO]: [CHAT] [Baritone] > path
[16:31:28] [Render thread/INFO]: [CHAT] [Baritone] Now pathing
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]: java.lang.IllegalStateException: Path doubles back on itself, making a loop
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at baritone.api.pathing.calc.IPath.sanityCheck(IPath.java:174)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at baritone.pathing.calc.Path.postProcess(Path.java:156)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at java.base/java.util.Optional.map(Optional.java:260)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at baritone.pathing.calc.AbstractNodeCostSearch.calculate(AbstractNodeCostSearch.java:106)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at baritone.behavior.PathingBehavior.lambda$findPathInNewThread$2(PathingBehavior.java:506)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[16:31:28] [pool-6-thread-3/INFO]: [STDERR]:    at java.base/java.lang.Thread.run(Thread.java:1583)

How to reproduce

Sneak off of an edge and set a goal such that the shortest path from the supporting block to the goal leads through your current position, then start the pathfinder. E.g. like this: 2024-10-20_16 31 28

Modified settings

None

Final checklist

babbaj commented 1 month ago

Couldn't reproduce. Do you have baritone somehow configured so that it walks over the hole? I don't get an error if it parkours over the hole or falls into it.

ZacSharp commented 1 month ago

Yes, I used default settings (i.e. no parkour) and had a dirt block in my hand so it would scaffold back over the hole.

leijurv commented 1 month ago

This is indeed a tricky case because the "correct" path here does indeed double back on itself!

babbaj commented 1 month ago

I think we can either fix the sanity check so it runs before we add the new node or only add the node if A* returned nothing (should be equal to checking if pathStart = goal like in the original solution)

leijurv commented 1 month ago

only add the node if A* returned nothing

not sure if that works, wouldn't that make it fall into the hole in this example without placing the block? or no?

ZacSharp commented 1 month ago

The pathfinder would still start above the supporting block so no, unless it also did so for the last couple years.

babbaj commented 1 month ago

It would just make it walk onto the supporting block(pathStart()) which should be the goal if A* returned nothing