/** * Gets the location next to this one in the given direction. * Always moves by a block amount, even diagonally. * * <p>{@link org.spongepowered.api.util.Direction.Division#SECONDARY_ORDINAL} * directions are not a valid argument. These will throw an exception. * </p> * * @param direction The direction to move in * @return The location in that direction * @throws IllegalArgumentException If the direction is a * {@link org.spongepowered.api.util.Direction.Division#SECONDARY_ORDINAL} */ public Location<E> getBlockRelative(Direction direction) { checkArgument(!direction.isSecondaryOrdinal(), "Secondary cardinal directions can't be used here"); return add(direction.asBlockOffset()); }
/** * Moves chunk coordinates a number of steps in the given direction. Returns * nothing if the new coordinates are not valid. * {@link Division#SECONDARY_ORDINAL} directions are not a valid * argument. These will throw an exception. * * @param chunkCoords The chunk coordinates to move from * @param direction The direction in which to move * @param steps The number of steps to take * @return The new chunk coordinates if they are valid * @throws IllegalArgumentException If the direction is a * {@link Division#SECONDARY_ORDINAL} */ default Optional<Vector3i> moveToChunk(Vector3i chunkCoords, Direction direction, int steps) { checkNotNull(direction, "direction"); checkArgument(!direction.isSecondaryOrdinal(), "Secondary cardinal directions can't be used here"); return addToChunk(chunkCoords, direction.asBlockOffset().mul(steps)); }
/** * Gets the location next to this one in the given direction. * Always moves by a block amount, even diagonally. * * <p>{@link org.spongepowered.api.util.Direction.Division#SECONDARY_ORDINAL} * directions are not a valid argument. These will throw an exception. * </p> * * @param direction The direction to move in * @return The location in that direction * @throws IllegalArgumentException If the direction is a * {@link org.spongepowered.api.util.Direction.Division#SECONDARY_ORDINAL} */ public Location<E> getBlockRelative(Direction direction) { checkArgument(!direction.isSecondaryOrdinal(), "Secondary cardinal directions can't be used here"); return add(direction.asBlockOffset()); }
/** * Moves chunk coordinates a number of steps in the given direction. Returns * nothing if the new coordinates are not valid. * {@link Division#SECONDARY_ORDINAL} directions are not a valid * argument. These will throw an exception. * * @param chunkCoords The chunk coordinates to move from * @param direction The direction in which to move * @param steps The number of steps to take * @return The new chunk coordinates if they are valid * @throws IllegalArgumentException If the direction is a * {@link Division#SECONDARY_ORDINAL} */ default Optional<Vector3i> moveToChunk(Vector3i chunkCoords, Direction direction, int steps) { checkNotNull(direction, "direction"); checkArgument(!direction.isSecondaryOrdinal(), "Secondary cardinal directions can't be used here"); return addToChunk(chunkCoords, direction.asBlockOffset().mul(steps)); }