Block Break Event Zone

Discussion in 'Plugin Development' started by 6zero, Aug 30, 2019.

  1. Offline

    6zero

    Someone can help me. I need help to create a zone from(x: 2033 y: 15 z: 1979) to (x: 948 y: 0 z: 2043) in which a player cant break any blocks.
     
  2. Offline

    timtower Moderator Moderator

  3. Offline

    6zero

    But i want make plugin like WorldGuard
     
  4. Offline

    timtower Moderator Moderator

    @6zero Then you check if the block is within those bounds and cancel the event.
     
  5. Offline

    6zero

    How XD ?
     
  6. Offline

    timtower Moderator Moderator

    What do you have already?
    And why do you want to make it yourself?
     
  7. Offline

    6zero

    Code:
    private Block getFloor() {
            Block b = null;
            for (int x = -2000; x < -1975; x++) {
                for (int z = 2600; z < 2650; z++) {
                   
                    getFloor().setType(Material.AIR);
                   
                }
            }
        }
     
  8. Offline

    timtower Moderator Moderator

    @6zero That is not a compare though, nor has it anything to do with the block breaking.
     
  9. Offline

    Tommy_T0mmY

    To check if a number a is within two numbers b and c you need to check if the minimum number between b and c is less or equal than a, and that the maximum number between b and c is greater or equal than a, you can pick minimum and maximum with the Math class like this
    Code:
    Math.min(b, c);
    Math.max(b, c);
    So the if statement will be
    Code:
    if (Math.min(b, c) < a && Math.max(b, c) > a) { ... }
    For a coordinate you need to check this three times per axis: x, y and z. if all three checks are successful, the coordinate is between the other two
     

Share This Page