-
Notifications
You must be signed in to change notification settings - Fork 1
/
CuboidLocation.java
34 lines (27 loc) · 1.11 KB
/
CuboidLocation.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.github.sanctum.labyrinth.data;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
public class CuboidLocation {
private final World world;
private final CuboidAxis axis;
private final Location center;
public CuboidLocation(CuboidAxis axis, World world) {
this.world = world;
this.axis = axis;
this.center = new Location(getWorld(), (double) (this.axis.getxMax() - this.axis.getxMin()) / 2 + this.axis.getxMin(), (double) (this.axis.getyMax() - this.axis.getyMin()) / 2 + this.axis.getyMin(), (double) (this.axis.getzMax() - this.axis.getzMin()) / 2 + this.axis.getzMin());
}
public Location getCenter() {
return center;
}
public Location getRandom() {
Random r = new Random();
int x = r.nextInt(Math.abs(this.axis.getxMax() - this.axis.getxMin()) + 1) + this.axis.getxMin();
int y = r.nextInt(Math.abs(this.axis.getyMax() - this.axis.getyMin()) + 1) + this.axis.getyMin();
int z = r.nextInt(Math.abs(this.axis.getzMax() - this.axis.getzMin()) + 1) + this.axis.getzMin();
return new Location(getWorld(), x, y, z);
}
public World getWorld() {
return world;
}
}