Get list of blocks where a mob (e.g. Zombie) can go

Discussion in 'Plugin Development' started by MisterErwin, Jun 13, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    MisterErwin

    Hello together,

    how can I get a list of blocks, where a mob can go to? Has bukkit/craftbukkit entity/creature class a method for this, or do I have to use A* pathfinding?

    thanks,
    MisterErwin
     
  2. Offline

    TheUpdater

  3. Offline

    MisterErwin

    ??
     
  4. Offline

    TheUpdater

    be more detail cus i dont really know what you want to do
     
  5. Offline

    MisterErwin

    Ok... I'm trying to get a list of blocks, that are reachable for a mob(so he "can" go to this block, if he starts walking at his current position).
     
  6. Offline

    TheUpdater

    so he only can walk to that block?
     
  7. Offline

    MisterErwin

    yes
     
  8. Offline

    desht

  9. Offline

    MisterErwin

    Ok... so I've to use A*pathfinding...

    My idea was to check an area of maybe 30x30x10 blocks... (so I onna check if the block & the block ontop is AIR/Water and is underneath that block a solid block, and then I've to use a pathfinding algorithm.

    Should this work, or does it fail... ?
     
  10. Offline

    desht

    So you're looking for any place where a player could stand in a 30x30x10 (9000) block cuboid. You can generally expect around 900 candidate blocks (more if there are caves nearby, fewer if deep water nearby). So ~900 A* searches... possible, but pretty CPU-heavy.

    A multi-threaded approach along with a thread-safe snapshot of the area (http://jd.bukkit.org/dev/apidocs/org/bukkit/ChunkSnapshot.html might be helpful) could work. You'd need to implement your own A* search to run in another thread, and get the list of valid locations back to your main thread somehow (scheduled sync task would be the most straightforward).
     
  11. Offline

    MisterErwin


    Ok.... thank you...

    I think I've a ton of stuff to test ;)
     
Thread Status:
Not open for further replies.

Share This Page