Detect if player can walk to spot

Discussion in 'Spigot Plugin Development' started by Cosmicluck, Apr 15, 2017.

  1. Strange title I know, but I couldn't think of a better way to phrase it.

    Here's the scenario:

    - On a server with a pre-built lobby, I run a command
    - This command first picks a random spot in the map where air touches a block, but not on the top or bottom.
    - I want to spawn an item frame here, but I don't want it to be inaccessible to players
    - Is there a possible way where I can detect if a player can walk close to that spot and interact with the item frame, from the spawn point?

    I hope that makes sense, it's a bit difficult to explain but it seems possible. Is this at all possible?
  2. You could get all blocks between the frame and a player and check to see if the blocks are solid and check to see if there's no more than one block up or down I suppose. Otherwise you might be getting into some pretty complex pathfinding.

    Another solution might be to pick maybe 30+ locations you Know are good and add them to a list. Then randomly select one.

    Or a min/max x/z coordinate to get your general area then check to make sure the block below is grass (or whatever your floor blocks are) so it won't spawn on top of a building.

    Sent from my iPhone using Tapatalk