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 Summary
Modifier and TypeMethodDescriptionapply(FixedOffset offset) Apply an offset to this location.default @Nullable DoublegetDistance(OffsetLocation other) Get the distance between two locations.Get the underlying platform-specific location object, for example a Bukkit Location.getWorld()default @Nullable StringDeprecated.doublegetX()doublegetY()doublegetZ()unapply(FixedOffset offset) Reverses the application of the given offset from this location, effectively restoring the "real" coordinates before the offset was applied.
-
Method Details
-
getWorld
OffsetWorld getWorld() -
getX
double getX() -
getY
double getY() -
getZ
double getZ() -
getWorldName
Deprecated.UsegetWorld()instead. -
apply
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
OffsetLocationwith the offset applied and all other data matching the original.
-
unapply
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
OffsetLocationwith the offset unapplied and all other data matching the original.
-
getDistance
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.
-
getWorld()instead.