Subtracts the location by another. @see Vector @param vec The other location @return the same location @throws IllegalArgumentException for differing worlds
(@NotNull Location vec)
| 397 | * @throws IllegalArgumentException for differing worlds |
| 398 | */ |
| 399 | @NotNull |
| 400 | public Location subtract(@NotNull Location vec) { |
| 401 | if (vec == null || vec.getWorld() != getWorld()) { |
| 402 | throw new IllegalArgumentException("Cannot add Locations of differing worlds"); |
| 403 | } |
| 404 | |
| 405 | x -= vec.x; |
| 406 | y -= vec.y; |
| 407 | z -= vec.z; |
| 408 | return this; |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Subtracts the location by a vector. |