Solved Check if player is inside something?

Discussion in 'Plugin Development' started by WHQ, Oct 21, 2015.

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

    WHQ

    Hey guys,

    i was wondering if someone would know a way to check if a player is standing inside something, for example grass or sugarcane.

    I haven't found any thread yet that shows this (there are a lot where you check the block that a player is standing on, but that's not what i need)
     
  2. @WHQ Check if the block at the players feet is air.
     
    WHQ likes this.
  3. Offline

    WHQ

    @bwfcwalshy

    Would that also work if i have a dirt block, with sugar cane standing on it, and i stand inside the sugar cane?
     
  4. Offline

    Xerox262

    It would work no matter what block it is, even if it's a block they're not supposed to be inside.

    I believe Player#getLocation(); returns the location of their legs (However I could be wrong, need confirmation). So just use that with Location#getBlock(); then just make sure it's not null and not air, and after that you can check to see if it's whatever you want.
     
  5. Offline

    WHQ

    @Xerox262 Ah okay cool, thanks for helping me out!

    @Xerox262

    -------

    Never mind

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Oct 21, 2015
Thread Status:
Not open for further replies.

Share This Page