Check if player is inside a water block

Discussion in 'Plugin Development' started by Snowl, Jan 24, 2011.

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

    Snowl

    Say I have blockportal1 = block.getRelative(0, 0, 0);
    blockportal1.setTypeId(9);
    and I try
    public void onPlayerMove(PlayerMoveEvent event) {
    if(event.getPlayer().getLocation() == blockportal1.getLocation())
    {
    System.out.println("LOL");
    }
    }

    it errors on me :( can anyone explain why?
     
  2. Offline

    Guybrush

    You can't compare objects like that. Also, location for a player is (double, double, double) whereas location for a block is (int, int, int). Even if you could compare objects contents that way, and even if we didn't have a double/int problem the likelihood of a person ever being at a blocks location is VERY small. Players x location tends to be something like 25.2341 or something. You're going to need to int cast those, except you'll notice that a block is measured by one of it's vertices, a person is measured relative to that, so standing in the middle of the block your x position will be something.5, same with z, though y is pretty normal.
     
  3. Offline

    Snowl

    Oh yeah, silly me >_>

    How would I get a player inside a (special) water block?
     
Thread Status:
Not open for further replies.

Share This Page