BlockPlaceEvent Help

Discussion in 'Plugin Development' started by sethrem, Nov 18, 2014.

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

    sethrem

    Hello,
    I would like to ask the question on how would I check if the block under the placed block is a VOID block meaning that players can place blocks like for making structures can't place blocks ontop of this.
    [​IMG]

    Thanks in advanced.
     
  2. Offline

    WesJD

    Just an idea I got:
    1. Get the placed block
    2. Get coordinates, then minus amounts.
    3. Check if those coords are Material.AIR

    Seems inefficient, just a general rundown. I'll possibly get back to you with another idea on how to do it.
     
  3. Offline

    sethrem

    WesJD Alright mate thanks because the way you said is the way I did it but it wouldn't allow players to regularly build structures like houses and what not
     
  4. Offline

    WesJD

  5. Offline

    adam753

    I did this recently, I just did a check to make sure the placed block was inside the allowed X and Z range. Not sure if that applies to your situation or not.
     
  6. Offline

    sethrem

    WesJD well think of it this way, the method you said would differentiate if someone is making a sky tower, but in my picture it would be easy to just subtract one y coordinate but in other cases not, this is my issue.
     
  7. Offline

    WesJD

    sethrem
    Loop through the world height?
     
  8. Offline

    sethrem

    @WesJDhdmu that wouldn't help either because if there is a mountain for example that height won't eb build able on, I'm trying to do this for a sort of sky block minigame
     
  9. Offline

    Gater12

    sethrem
    So basically there's a set boundary and players can't build out of their boundary?
     
  10. Offline

    sethrem

    Gater12 Well not exactly there are islands and teams and I don't want players extending their islands so I'm trying to make it so you can place blocks above void, which would be below bedrock, to the sides of the island. So yea basically kind of like a boundary but not really.
     
  11. Offline

    Gater12

    sethrem
    So it's a boundary. Simply define it as one (in code) and test if the player is building out of his/her boundary.
     
  12. Offline

    sethrem

    Gater12 No not exactly because there are mulyiple islands and it would take ages to do so. I just want to make it so players can't build on top of void.
     
  13. Offline

    pookeythekid

    sethrem Do you mean build at the void (y = 0), build above the void (y > 0), or build below the void (y < 0)? If you mean the last one, I'm pretty sure you can't place blocks below void level.
     
  14. Offline

    sethrem

    pookeythekid I mean above it. Like if there are blocks under you no matter how far down, you can build on top of it. But if there are no blocks under the block you placed then you can't build.
     
  15. Offline

    msnijder30

    sethrem
    This might work, I haven't tested it though.
    You pass the block location in here:

    Code:java
    1. public boolean isVoid(Location l){
    2. for(int y = 0; y < 256; y++){
    3. if(l.getWorld().getBlockAt(l.getBlockX(), y, l.getBlockZ()) != null || l.getWorld().getBlockAt(l.getBlockX(), y, l.getBlockZ()).getType() == Material.AIR){
    4. return false;
    5. }
    6. }
    7. return true;
    8. }
     
  16. Offline

    sethrem

    msnijder30 Thanks mate but I already got it working, I did it differently than you.
     
Thread Status:
Not open for further replies.

Share This Page