Still alive? (Also sharing some work I did re: pathfinding, maybe I can help)
cosmicdan opened this issue ยท 2 comments
Howdy,
I've been eye-ing that "multithreaded pathfinding" planned feature for quite a while now, haha.
I did a pathfinder tweak mod for 1.7.10 ages ago which was never released, it was called "Pathfinder Tweaks" - maybe something here could be of use to you. I'm modding and building a pack on 1.12.2 now, though - I think some of these things have since been fixed in vanilla.
So here is a raw copy of the readme.md from this unreleased Pathfinder Tweaks for you to peruse, let me know if anything seems interesting and relevant to the 1.12.2 version of AI Improvements.
#PathfinderTweaks
A coremod that fixes some annoying bugs in Minecraft 1.7.10 pathfinding. It's not perfect, but it does a decent enough job of fixing serious annoyances that exist in modded (and vanilla) Minecraft 1.7.10.
###Features
- Fixes "fence hopping". Entities will no longer try to path over tall blocks, such as mod-added walls and gates, unless they can do so confidently via a nearby block. Technical: If the block extends BlockWall, BlockFence, BlockFenceGate, or reports a maxY > 1.0, or has a collision box or bounding box greater than 1.0, then the pathfinder will treat it the same as a vanilla fence/wall.
- Fixes "fence sticking". Entities should no longer get stuck with their NW corner in things anymore. Happens most often in animal farms, but can happen anywhere when entities are up against a block on their NW corner. Technical: Vanilla game calculates the point of origin from the minX/minY bounding boxes of the entity, which - in the event of non-whole-cube blocks like fences - can result in the "nearest" block actually being a fence, and the entity wrongly considers this impassable block as the origin. This coremod will first try to get the block at the center-point of the entity bounding box, if it fails to find free space then it checks the four corners, falling back to NW corner in the event of complete failure (and likely remaining stuck - shouldn't happen).
- Fixes "slab hopping". Entities should no longer think they are capable of jumping higher than possible when standing on slabs or other partial-height blocks. Technical - Minecraft incorrectly rounds-up the block height position when calculating the origin point of a path, so e.g. 64.5 becomes 70; which makes entities think they can jump more than 1.0 blocks high.
- Fixes "pogo-sticking". Entities can wrongly believe a flat "tile-like" block they're pathing over is a solid block, giving them a pogostick-like behavior. Countless mod-added 'tile-like' blocks cause this issue. *Technical - Related to the fence hopping problem; the vanilla pathfinder does no attempt at calculating the actual height of a given block - it just compared it to known blocks (in this case a rail) to decide if it's a "flat" block. So we also do a bounding box check as the very last check before returning "there's a solid block here", and only return it as solid if it's height is greater than 0.5. *
- Entities actually compare bounding boxes to see if they can path through blocks; sheep/cows/etc can now pass open double doors (but still not single doors because they're apparently too fat). Credits to Funwayguy for this code.
- For mod developers, adds a few custom events for modifying the path building process on a per-entity and per-block basis. I made this so my AncientWarfare2 and Epic Siege Mod forks didn't have to brute-force pathfinding enhancements.
###What this mod does NOT and WILL NOT fix
- Any kind of pathing that depends on a "partial block traversal." This includes pathing through slab gaps, i.e. a slab, 2x air-block-worth of space above it, and another slab; and pathing between two unconnected fence/wall posts. The player can move through these obstacles, and technically so can most entities, but it would require a complete replacement of the vanilla pathfinding (to use floating-point precision).
###Tested OK:
- Carpenter's Blocks gates
- Et Futurum gates
- Vanilla slabs
- Cows and chickens in NW fence corners
- "Grave Plate" blocks from Gravestone Mod and "Stone Path" from MrCrayfish Furniture Mod (both these blocks previously caused pogo-sticking).
###Caveats
- This is a coremod. If there is a crash in any of the "net.minecraft.pathfinding.*" classes, it's likely an incompatibility with some other mod that also modifies the vanilla pathfinder.
- There could be a performance impact, but it would be negligible. Most of the logic is only performed on origin calculations (i.e. the starting point of a path) and I have done my best to use optimized code. If you have a lot of entities though, you might notice some additional CPU time from the Pathfinder class (use WarmRoast or similar to check that out).
- Only patches vanilla PathFinder class. Mods can use their own pathfinder AI and they will not be automatically supported - Ancient Warfare 2 and Epic Siege Mod are two examples (I have my own forks of these mods that do take advantage of it though).
- Entities which have an increased jump height or some other non-flying vertical movement behavior, yet keep the vanilla pathfinder (if this is even a possible thing?) might have a derped-up navigator. Please report if you find any entities that have issues.
- Probably more things. It is very likely that in implementing these fixes, I have in fact introduced more bugs. Please do report any bugs you find, as long as you're sure it's a bug with this mod and can be reproduced.
I think almost all of those things actually have been fixed in vanilla code these days, so maybe don't worry about that :)
I'll have to think about it, but I think the goal with multi-threading was to move the pathing from the main thread to a worker thread set. This way we pathfaster without slowing down the main thread. On top of this I was planning on changing how pathing was done to reduce how often we needed to path. As well try to implement some pathing I use in AA games I use to help with to do chunk based pathing over long distances. The main goal would be to improve zombies as these can have a large impact in mobs.