Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList<Location> getAllPointsBetween(Location point1, Location point2) {
- int xMultiplier = 1;
- int yMultiplier = 1;
- int zMultiplier = 1;
- if(point1.getX() > point2.getBlockX()) {
- xMultiplier *= -1;
- }
- if(point1.getY() > point2.getBlockY()) {
- yMultiplier *= -1;
- }
- if(point1.getZ() > point2.getBlockZ()) {
- zMultiplier *= -1;
- }
- ArrayList<Location> points = new ArrayList<Location>();
- for(int x = 0; x < Math.abs(point1.getBlockX() - point2.getBlockX()); x += xMultiplier) {
- for(int y = 0; y < Math.abs(point1.getBlockY() - point2.getBlockY()); y += yMultiplier) {
- for(int z = 0; x < Math.abs(point1.getBlockX() - point2.getBlockX()); z += zMultiplier) {
- points.add(new Location(point1.getWorld(), x, y, z));
- }
- }
- }
- return points;
- }
Advertisement
Add Comment
Please, Sign In to add comment