Mine blocks around a block

Discussion in 'Plugin Development' started by Rabrg, Feb 3, 2015.

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

    Rabrg

    I'm making a plugin where if you mine a block, it also mines the blocks left, right, up, and down from the mined block. I'm having problems finding which blocks to mine, as the directions north, east, south, and west change depending on where the player is in relation to block.

    Could someone help me?
     
  2. Offline

    SuperOriginal

  3. Offline

    Rabrg

    @SuperOriginal Like I said in the post, I can't just use that as I don't know where the player is mining the block from.
     
  4. Offline

    Ambamore2000

    BlockBreakEvent
     
  5. Offline

    SuperOriginal

    @Rabrg Block positions relative to another block don't change based on where a player mines it.
     
    ReadySetPawn likes this.
  6. Offline

    Rabrg

  7. Offline

    Ambamore2000

    You're kidding me.
    event.getBlock
     
  8. Offline

    Rabrg

    @SuperOriginal I can't do north, east, etc as north could be forward or backward instead of left or right.

    @Ambamore2000 Did you even read the post? I need help finding which blocks to mine, not finding the block mine event.
     
    Last edited by a moderator: Feb 4, 2015
  9. Offline

    SuperOriginal

    @Ambamore2000 basic assistance isn't needed.

    @Rabrg I found this post in another thread, you may be able to get this working with a block's location
     
  10. Offline

    Ambamore2000


    Ofc I read the post, I was just trying to help with this here:
    unless I understood this post wrong

    EDIT: I understood that post wrong
     
  11. Offline

    Rabrg

    @Ambamore2000 you understood wrong @SuperOriginal I'll try that, thanks

    @Ambamore2000 I tried both that and the one underneath it. The first was getting x coordinates ~10 off and z coordinates ~5 off, and the second wasn't taking directions into consideration correctly and was getting relatively random results.

    Still looking for help
     
    Last edited by a moderator: Feb 4, 2015
  12. Offline

    Rabrg

    Bump, still need help.
     
  13. Offline

    Rabrg

    Bump, still need help.
     
  14. @Rabrg
    Pseudo code for getting up and down blocks.

    Code:
    World world = event.getWorld();
    Location location = event.getBlock().getLocation();
    
    Block blockUp = world.getBlockAt(location.x, location.y + 1, location.z);
    Block blockDown= world.getBlockAt(location.x, location.y - 1, location.z);
    But, I doubt that's what you're having trouble on.
    Alright so let me get this straight, you want to get the location of the right and left blocks of what block the player mined. But, this is based off of the players location relative to the block correct? If not, wouldn't you just get the blocks besides the block being broken that you define as right or left. I.E.
    Code:
    Block blockRight = world.getBlockAt(location.x + 1, location.y location.z);
    Block blockLeft = world.getBlockAt(location.x - 1, location.y location.z);
     
  15. Offline

    Rabrg

    @BorisTheTerrible No, because that will get the block in front and behind of the block being mined instead of left and right half the time, depending on the player's direction.
     
  16. @Rabrg
    Then you are going to have to break out the mathmatics and figure out a way to calculated which ones are left and right based on the players location.
     
  17. Offline

    Techy4198

Thread Status:
Not open for further replies.

Share This Page