Assign/claim schematic

Discussion in 'Spigot Plugin Development' started by yhl, Jul 28, 2018.

  1. yhl

    yhl

    I'm making a skyblock plugin and I was wondering whats the most efficient way to assign a schematic build to a player? I know I have to use Hashmap but how do I get the schematic in code.
     
  2. You could get the top corner of 1 block, and the opposite bottom corner of that and check if a location is in between that location.

    Off Topic: Just realized your profile picture is Heisenberg.
     
  3. yhl

    yhl

    How would I check in between tho?
     
  4. Code (Java):
    public boolean inRegion(double x, double y, double z) {
        return x >= this.min.getX() && x <= this.max.getX()
                && y >= this.min.getY() && y <= this.max.getY()
                && z >= this.min.getZ() && z <= this.max.getZ();
    }
    min & max being locations. I expanded it out as x, y, z so you could see what's happening. You'd rather input a location instead.
     
  5. Code (Text):
    Location topCorner = ...;
    Location bottomCorner = ...;

    int x1 = topCorner.getX();
    int y1 = topCorner.getY();
    int z1 = topCorner.getZ();
         
    double x2 = bottomCorner.getX();
    double y2 = bottomCorner.getY();
    double z2 = bottomCorner.getZ();

    Location brokenBlock = ...;

    int brokenX = brokenBlock.getX();
    int brokenY = brokenBlock.getY();
    int brokenZ = brokenBlock.getZ();

    if((brokenX > x1) && (brokenY > y1) && (brokenZ > z1) && (brokenX < x2) && (brokenY < y2) && (brokenZ < z2)) {
    //in area
    } else {
    //not in area
    }
    Something like this

    Slees beat me >.<
    (He wouldn't be using a double, assuming he's testing for block locations)
     
  6. The doubles might not be a bad idea depending on the events being checked (some events won't adhere to whole number values at least). Casting to int will tend to truncate decimals which would generally lead to omitting a block that should be included. So possibly simpler to just stick with doubles.