Interface OffsetLocation


@NullMarked public interface OffsetLocation
Adapter interface representing a location in a Minecraft world with X, Y, Z coordinates.

The name does NOT imply that an offset was already applied. It refers to any Location object in the different platforms.

  • Method Details

    • getWorld

      OffsetWorld getWorld()
    • getX

      double getX()
    • getY

      double getY()
    • getZ

      double getZ()
    • getWorldName

      @Deprecated default @Nullable String getWorldName()
      Deprecated.
      Use getWorld() instead.
    • apply

      @Pure OffsetLocation apply(FixedOffset offset)
      Apply an offset to this location. This location should refer to coordinates in "real" space, i.e. not yet transformed by an offset.

      Be careful not to use the returned Location for anything internal to the server, such as getting the Block at that Location. The returned Location is primarily intended to be sent to a Player who this Offset is applied to, such as in a message.

      Parameters:
      offset - The offset to apply.
      Returns:
      A new OffsetLocation with the offset applied and all other data matching the original.
    • unapply

      @Pure OffsetLocation unapply(FixedOffset offset)
      Reverses the application of the given offset from this location, effectively restoring the "real" coordinates before the offset was applied. This location should refer to coordinates in a player's offsetted space.
      Parameters:
      offset - The offset to reverse.
      Returns:
      A new OffsetLocation with the offset unapplied and all other data matching the original.
    • getDistance

      default @Nullable Double getDistance(OffsetLocation other)
      Get the distance between two locations.
      Parameters:
      other - Second location to compare against.
      Returns:
      A distance in blocks, or null if the locations are in different worlds.
    • getPlatformLocationObject

      Object getPlatformLocationObject()
      Get the underlying platform-specific location object, for example a Bukkit Location.