How to get location of block player is looking at

Discussion in 'Spigot Plugin Development' started by Redrield, May 30, 2016.

  1. So I'm trying to make a plugin that gets the location of a block the player is looking at, but then needs to compare the location of blocks against that, I've tried Player#getTargetBlock(Set<Material>, int) but the Location from that differs ever so slightly from the location returned by e.getClickedBlock().getLocation(). So what could I do here?
     
  2. I'm not 100% sure what you're requesting. What do you mean by "needs to compare the location of blocks against that". Also to deal with your location being slightly off, there's a difference between getX() and getBlockX() for example. getX() will return the exact X value the block is at. getBlockX() if i'm not mistaken rounds up. I am kind of tired so I hope that makes some sense haha!