cweckerl/simplefarming

Fruit tree trunk pathfinding problem (and solution)

Closed this issue · 0 comments

desht commented

Forge Version

36.1.0

Mod list (optional)

n/a

Log file (optional)

n/a

Describe the issue

Hi, I'm the author of PneumaticCraft: Repressurized. Just wanted to bring a subtle problem with one of your blocks to your attention...

Your fruit tree trunks (ThinBlock) don't override Block#allowsMovement() (isPathfindable() in official mappings). Specifically, this method is intended to determine whether or not an entity can pathfind through the block; the default for land-based and flying entities is to allow pathfinding if the block doesn't have an opaque collision shape. Unfortunately, because the tree trunks have a movement-blocking collision box, entities will get stuck (forever) when trying to pathfind through them.

See the screenshot below:

2021-04-19_08 12 24

As you can see, the chicken is attempting to path through the tree there instead of walking around it to reach me. It is a subtle problem which many (most?) modders miss, and generally isn't very noticeable since vanilla entities aren't often around these blocks. However, PneumaticCraft drones often are, and drones getting stuck is a very common source of issues for me :) In particular I had a player unable to use drone to automate harvesting fruit from these trees, since they get stuck so often on the trunks.

Fortunately, it's very easy to fix: simply override allowsMovement() to return false in those blocks of yours which are not a full cube, but do have a movement-blocking collision shape. You will notice that vanilla does this for many of its blocks.