Apollo
Developers
Utilities
Locations

Locations

Overview

Apollo adds user-friendly location builders that seamlessly integrate with all Apollo modules requiring location information.

ApolloLocation Builder

For obtaining a highly accurate location with decimal point precision, it is recommended to utilize the ApolloLocation builder.

public class ApolloLocation {
 
    /**
     * Returns the world name for this location.
     *
     * @return the world name
     * @since 1.0.0
     */
    String world;
 
    /**
     * Returns the {@code double} X coordinate for this location.
     *
     * @return the x coordinate
     * @since 1.0.0
     */
    double x;
 
    /**
     * Returns the {@code double} Y coordinate for this location.
     *
     * @return the y coordinate
     * @since 1.0.0
     */
    double y;
 
    /**
     * Returns the {@code double} Z coordinate for this location.
     *
     * @return the z coordinate
     * @since 1.0.0
     */
    double z;
 
}

Sample Code

public static ApolloLocation locationExample() {
    return ApolloLocation.builder()
        .world("world")
        .x(50.5D)
        .y(100)
        .z(50.0D)
        .build();
}

ApolloBlockLocation Builder

For obtaining the location of a specific block, despite any discrepancies in decimal points, it is recommended to utilize the ApolloBlockLocation builder.

public class ApolloBlockLocation {
 
    /**
     * Returns the world name for this location.
     *
     * @return the world name
     * @since 1.0.0
     */
    String world;
 
    /**
     * Returns the {@code int} X coordinate for this location.
     *
     * @return the x coordinate
     * @since 1.0.0
     */
    int x;
 
    /**
     * Returns the {@code int} Y coordinate for this location.
     *
     * @return the y coordinate
     * @since 1.0.0
     */
    int y;
 
    /**
     * Returns the {@code int} Z coordinate for this location.
     *
     * @return the z coordinate
     * @since 1.0.0
     */
    int z;
 
}

Sample Code

public static ApolloBlockLocation blockLocationExample() {
    return ApolloBlockLocation.builder()
        .world("world")
        .x(0)
        .y(100)
        .z(0)
        .build();
}

ApolloPlayerLocation Builder

For obtaining a highly accurate player location with decimal point precision, it is recommended to utilize the ApolloPlayerLocation builder.

public final class ApolloPlayerLocation {
 
    /**
     * Returns the {@link ApolloLocation} for this player.
     *
     * @return the apollo location
     * @since 1.0.7
     */
    ApolloLocation location;
 
    /**
     * Returns the {@code float} yaw for this player location.
     *
     * @return the yaw
     * @since 1.0.7
     */
    float yaw;
 
    /**
     * Returns the {@code float} pitch for this player location.
     *
     * @return the pitch
     * @since 1.0.7
     */
    float pitch;
 
}
 

Sample Code

public static ApolloPlayerLocation playerLocationExample() {
    return ApolloPlayerLocation.builder()
        .location(ApolloLocation.builder()
            .world("world")
            .x(50.5D)
            .y(100)
            .z(50.0D)
            .build())
        .yaw(180.0F)
        .pitch(90.0F)
        .build();
}