Check if player is stepping on a plate

Discussion in 'Spigot Plugin Development' started by fbafaro, Jun 14, 2018.

  1. Hi,

    I'm trying to detect if the player is stepping on a plate but using the following code:

    Location loc = player.getLocation();
    Block block = loc.getBlock();

    still detect the block under as grass even do I'm really over a plate.

    Any help will be appreciated.
  2. Never mind, got it. I just don't subtract the Y by 1, just using loc.getBlock() is actually giving me if I'm stepping on a plate.
  3. Code (Text):
    public void onInteract(PlayerInteractEvent event) {
        if (event.getAction() != Action.PHYSICAL) {

        // Player stepped on pressure plate.
        // Simple.