Player in a closed room

Discussion in 'Plugin Development' started by user_91277742, Dec 29, 2018.

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

    user_91277742

    hello there!
    So i want to detect if a player is in a closed room but i dont really have an idea to do that..
    any ideas? D:
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Ahrigumi How often will you be checking this?
     
  3. Offline

    user_91277742

    @timtower every second if is possible, Im working on an space plugin hehe
     
  4. Offline

    Zombie_Striker

    @Ahrigumi
    I would recommend doing a flood-fill to scan for walls. When the player tries to enter a new room, check in all directions of a block to find air, and map out the entire room. If it exceeds a certain distance or amount of blocks, (e.g., if it has to travel over 100 blocks to find another wall, or if there are more than 100x100x100 blocks that if found full of air, you can safely assume that it is not an eclosed room)

    Now, doing this every second can be taxing on your system, so I would recommend you only do this once for an area, and store this area in memory. Then, before doing the calculations, check to see if the location the player is in has already been calculated, and use that value to determine if it was or was not an enclosed room.
     
  5. Offline

    user_91277742

Thread Status:
Not open for further replies.

Share This Page