LeDennis32

Block in front of Player

Oct 15th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. private static final BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
  2.  
  3. public BlockFace yawToFace(float yaw) {
  4.     return axis[Math.round(yaw / 90f) & 0x3].getOppositeFace();
  5. }
  6.  
  7. public Block frontBlock(Player p) {
  8.   BlockFace face = yawToFace(p.getLocation().getYaw());
  9.   Block b = p.getLocation().getBlock();
  10.   return b.getRelative(face);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment