I'm always frustrated when I have to do:
Location start = new Location(Bukkit.getWorld("oof"), 10, 10, 10);
Location editableClone = start.clone();
for (int i = 0; i < 100; i++) {
editableClone.setX(start.getX() + i);
editableClone.setY(start.getY() + i);
editableClone.setZ(start.getZ() + i);
}
I want to have a location builder:
for (int i = 0; i < 100; i++) {
start.clone().setX(start.getX() + i).setY(start.getY() + i).setZ(start.getZ() + i);
}
I'm not very important in this project, but I don't see why there should be a location object with a builder pattern.
This could be easily accomplished with a location "wrapper" with the needed Location builder.
Your original snippet:
Location start = new Location(Bukkit.getWorld("oof"), 10, 10, 10);
Location editableClone = start.clone();
for (int i = 0; i < 100; i++) {
editableClone.setX(start.getX() + i);
editableClone.setY(start.getY() + i);
editableClone.setZ(start.getZ() + i);
}
Can be made simpler, like so:
Location start = new Location(Bukkit.getWorld("oof"), 10, 10, 10);
for (int i = 0; i < 100; i++) {
start.add(i, i, i);
//Logic
start.subtract(i, i, i);
}
What would be a cool API addition would be a imutable location/vector which supports add and subtract operations by returning a clone.
as said, there is solutions to what you are trying to do here.
What we could do though is a .set(x,y,z) that returns self, and .set(start, x, y, z) that is a shortcut to start.x + x, y, z etc.
So I will consider this accepted and we can add a few more util methods.
Most helpful comment
Your original snippet:
Can be made simpler, like so: