09-08-2014, 03:25 AM
Hi,
I believe there is some basic form of pathfinding already implemented in the codebase, although I can't point you exactly to the code. I think @tigerw could shed some light here.
As for your questions, first let me note that a jump is a different thing than a spider's wallclimb, and we will need pathfinding for flying mobs, too, so you might want to include that in your analysis.
Also note that blocks in MC aren't just solid / non-solid, there are doors, trapdoors, fences, fencegates, halfslabs, stairs, soulsand, water and other special cases that will need some thinking about. It might be better to get a function that gives you the block's "non-passable bounding box" based on the block's placement. You will need to take into account the non-integral coordinates used.
As for mobs, each entity has its size already defined in cEntity::GetWidth() and cEntity::GetHeight(); the entities use an axis-aligned bounding box with the same dimension in X and Z. The entity position is anchored in the center of the entity's bounding box's bottom side (MidX, LowY, MidZ).
The pathfinding will most likely want to run inside the chunkmap's lock, so that it can directly access the chunk data. You will have to do so using the cWorld::DoWithChunk() method to get you in, and using the callback parameter for the actual calculation. The cBlockLineTracer class should provide an example of doing this. You can then use cChunk::GetBlock() and cChunk::SetBlock() to query and set blocks.
I believe there is some basic form of pathfinding already implemented in the codebase, although I can't point you exactly to the code. I think @tigerw could shed some light here.
As for your questions, first let me note that a jump is a different thing than a spider's wallclimb, and we will need pathfinding for flying mobs, too, so you might want to include that in your analysis.
Also note that blocks in MC aren't just solid / non-solid, there are doors, trapdoors, fences, fencegates, halfslabs, stairs, soulsand, water and other special cases that will need some thinking about. It might be better to get a function that gives you the block's "non-passable bounding box" based on the block's placement. You will need to take into account the non-integral coordinates used.
As for mobs, each entity has its size already defined in cEntity::GetWidth() and cEntity::GetHeight(); the entities use an axis-aligned bounding box with the same dimension in X and Z. The entity position is anchored in the center of the entity's bounding box's bottom side (MidX, LowY, MidZ).
The pathfinding will most likely want to run inside the chunkmap's lock, so that it can directly access the chunk data. You will have to do so using the cWorld::DoWithChunk() method to get you in, and using the callback parameter for the actual calculation. The cBlockLineTracer class should provide an example of doing this. You can then use cChunk::GetBlock() and cChunk::SetBlock() to query and set blocks.