Solved Getting cuboid's center coordinates?

Discussion in 'Plugin Development' started by IconByte, Jun 13, 2015.

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

    IconByte

    Hello Bukkiters.
    I have simple question about that is there any way to calculate Cuboid's center location?

    //EDIT: Solved, I needed to google a little bit more.

    This code did the job:
    Code:
        public Location getCenter(Location loc1, Location loc2) {
            int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
            int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
            int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
            int x1 = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1;
            int y1 = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1;
            int z1 = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1;
    
            return new Location(Bukkit.getWorld("world"), minX + (x1 - minX) / 2.0D, minY + (y1 - minY) / 2.0D, minZ + (z1 - minZ) / 2.0D);
        }
     
    Last edited: Jun 13, 2015
  2. Offline

    LeePMC

    Mark your thread as solved so people looking at the forum section know not to click on it
     
  3. Offline

    mine-care

    @LeePMC True :/ i just fell in the trap.
    So @IconByte mark as solved, also please post the solution you found for future reference.
     
  4. Offline

    IconByte

    Done, sorry about that. :/
     
  5. Offline

    mine-care

Thread Status:
Not open for further replies.

Share This Page