Adds the location by another. @see Vector @param vec The other location @return the same location @throws IllegalArgumentException for differing worlds
(@NotNull Location vec)
| 345 | * @throws IllegalArgumentException for differing worlds |
| 346 | */ |
| 347 | @NotNull |
| 348 | public Location add(@NotNull Location vec) { |
| 349 | if (vec == null || vec.getWorld() != getWorld()) { |
| 350 | throw new IllegalArgumentException("Cannot add Locations of differing worlds"); |
| 351 | } |
| 352 | |
| 353 | x += vec.x; |
| 354 | y += vec.y; |
| 355 | z += vec.z; |
| 356 | return this; |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Adds the location by a vector. |