Detecting if player is inside building

Discussion in 'Plugin Development' started by LanteanKnight, Jan 16, 2014.

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

    LanteanKnight

    I'm working on remaking my temperature plugin, but I want to make it a little more extensive than last time. For it to properly work I need to find out if a player is inside a building or not.
    I had a few ideas about how to do this but they're all either insufficient, flawed or very CPU or RAM intensive.
    • Scanning the surroundings for walls: too intensive if this has to be done every second
    • Looking at the ground block: easily fooled by placing that block outside
    • Looking if there's a ceiling: easily fooled as well and possibly intensive in cases of high ceilings
    I'm wondering if any of you have any ideas on how to tackle this problem?
    Thanks!
     
  2. Offline

    NoLiver92

    create a region for the building which is classed as "inside" when player moves then check if they are inside the region.

    simple and easy to do.
     
  3. Offline

    metalhedd


    That would require pre-defining every potential building, which isn't really possible. 'inside a building' could be as simple as digging a hole and placing a block over your head. this should count as inside. There really isn't an easy way to do this. Just look at the villager mechanics in vanilla minecraft, they have a heck of a time finding homes even though the houses were generated FOR them. The can only look for a door with a 'cieling' over it and decide which side of that door is 'inside' based on the number of ceiling blocks on either side of the door.
     
  4. Offline

    NoLiver92

    metalhedd I agree that all buildings would need to be defined, but it depends what the OP defines as inside.

    The villager mechanics from your post actually looks like a better way of doing it, this has also helped me for an idea for my server.
     
  5. Offline

    LanteanKnight

    Hmm yeah, I can take a look at the minecraft mechanics, that's a good suggestion.
    I can't pre-define buildings and I can't have players define their own either because it'd allow for exploitation of the system.

    Digging a hole with a block above your head would indeed count as a 'building', because I basically mean an enclosed space.
     
  6. Offline

    metalhedd


    I was actually using the minecraft mechanics as a way of explaining why this isn't really possible. you probalby wont find much help there. first of all, because they require a door (or some other identifiable block in your case). and secondly, because they don't work well at all, they don't actually care if there are walls or that the villager is actually under the cieling, only that he's on a specific side of the door.
     
Thread Status:
Not open for further replies.

Share This Page