Block Plane

Discussion in 'Plugin Development' started by bronzzze, Apr 7, 2015.

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

    bronzzze

    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:
    [​IMG]
     
  2. 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.
     
    bronzzze likes this.
  3. Offline

    bronzzze

    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();
    
    }
     
  4. bronzzze likes this.
  5. Offline

    bronzzze

    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.>
     
    Last edited by a moderator: Apr 7, 2015
  6. 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/
     
    bronzzze likes this.
  7. Offline

    bronzzze

    Will check It thanks for helping.
     
Thread Status:
Not open for further replies.

Share This Page