Checking for an entity standing on a block

Discussion in 'Plugin Development' started by Crash, Apr 9, 2011.

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

    Crash

    I'm having trouble, I have a block which I need to know if any player/entity is standing on, for now I just check if the above block has a player in it, but there's a problem if somebody is sneaking which allows their origin to go further off into another block while still standing on a block.

    I need a way to know that the entity is standing on the block :\

    EDIT : It would also be nice if there was a way to check for blocks that you can walk through(pre existing method) so that I don't need to check for all types of blocks you can walk through. (It helps cut down on time spent checking so that I don't check blocks above that are solid and that a player won't be inside)
     
  2. Offline

    Edward Hand

    I'm not sure about the sneaking thing, but you can check whether a particular block ID can be walked through:

    Code:
    net.minecraft.server.Block.byId[BLOCKID].a()
    It returns true if the block is solid and false if you can walk through it.
     
  3. Offline

    Crash

    Is it possible for maybe a distance check to see if the person is still on the block ?
     
  4. Offline

    Edward Hand

    The only problem you have with sneaking I suspect is when they are sneaking over a ledge. You could check whether they are both sneaking and standing on top of an air block, and if so find the closest non-air block.
     
  5. Offline

    Crash

    That is actually a really good idea. Is the origin of the block in the corner or center because that could not work too well if it's the corner.
     
  6. Offline

    Edward Hand

    Its in the lower corner, such that you add (0.5, 0.5, 0.5) to find the centre.
     
  7. Offline

    Crash

    Yeah I did that, unfortunately it sometimes fails for some odd reason. Like, it works 5 times in a row and then it fails but I didn't move at all... I'll post a vid soon.
     
Thread Status:
Not open for further replies.

Share This Page