I hope you will understand what I mean How can I check when I mine specifecd block plane on for exemple stone for expeple this plane:
I have the feeling there is a bukkit or nms way of getting it, but you could do that you take the location of the block and remove the location of the player. If the Z is lower than 0, you're probably mining the north face, if it's higher than 0, it's probably the south face. But that could not be as accurate as you would want, then you could just look in the source of nms and look how they did it, and implement that in your project (but straight up copying doesn't work all the times), or you use something like raytracing.
I need it for my explosive pickaxe plugin. BlockBreakEvent and when I am mining it from exemple y+(this is upper plane) Exemple code Code: if(I mine it from Upper face){ Location b1 = e.getBlock().getLocation().add(1, 0, 0); Location b2 = e.getBlock().getLocation().add(-1, 0, 0); Location b3 = e.getBlock().getLocation().add(0, 0, 1); Location b4 = e.getBlock().getLocation().add(0, 0, -1); b1.getBlock().breakNaturally(); b2.getBlock().breakNaturally(); b3.getBlock().breakNaturally(); b4.getBlock().breakNaturally(); } if(I mine it from North/South face){ Location b1 = e.getBlock().getLocation().add(1, 0, 0); Location b2 = e.getBlock().getLocation().add(-1, 0, 0); Location b3 = e.getBlock().getLocation().add(0, 1, 0); Location b4 = e.getBlock().getLocation().add(0, -1, 0); b1.getBlock().breakNaturally(); b2.getBlock().breakNaturally(); b3.getBlock().breakNaturally(); b4.getBlock().breakNaturally(); } if(I mine it from west/east face){ Location b1 = e.getBlock().getLocation().add(0, 0, 1); Location b2 = e.getBlock().getLocation().add(0, 0, 1); Location b3 = e.getBlock().getLocation().add(0, 1, 0); Location b4 = e.getBlock().getLocation().add(0, -1, 0); b1.getBlock().breakNaturally(); b2.getBlock().breakNaturally(); b3.getBlock().breakNaturally(); b4.getBlock().breakNaturally(); }
I've found this piece of code from an old thread, that should work http://bukkit.org/threads/from-which-direction-is-player-looking-at-the-block.14153/#post-2546827 Code: BlockFace blockFace = block.getFace(player.getLocation().getBlock());
Ty very much. Gonna try it. Code: BlockFace face = block.getFace(p.getLocation().getBlock()); if(face != null ||face == BlockFace.UP || face == BlockFace.DOWN){ } Is this correct beacuse its not working. I fell so stupid:/. Edit: Sorry for double posting I forgot. <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
This only works when the block is right next to another block. I've found this other thread that's much better. https://bukkit.org/threads/find-blockface-player-is-targeting.145903/