How to get the block the player's standing on?

Discussion in 'Plugin Development' started by BenPlaysMC, Jan 15, 2017.

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

    BenPlaysMC

    What I'm trying to do is basically get the block the player is standing on. The block that I'm looking for is Red Wool. I need something that if a player is standing on Red Wool, do this. Same for Blue Wool but I would think I can do that myself. Here's the code that I've tried.

    Code:
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onMove(PlayerMoveEvent e){
            Location loc = (Location) e.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN);
            Block b = loc.getBlock();
      
            if(b.getType() == Material.WOOL && b.getData() == 14){
      
                e.getPlayer().sendMessage("You stepped on Red Wool!");
      
            }
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    BenPlaysMC

    What arguments should I use in getRelative? BlockFace or int?
     
  4. Offline

    timtower Administrator Administrator Moderator

    Blockface
     
Thread Status:
Not open for further replies.

Share This Page