Skip to main content

Overview

PlatformLocation represents a location in the underlying platform. It provides access to coordinates (x, y, z), rotation (pitch, yaw), and the world, as well as methods for manipulating locations and calculating distances. Package: kr.toxicity.model.api.platform Extends: PlatformRegionHolder Since: 2.0.0

Core Properties

world()

Returns the world associated with this location. Returns: The world Since: 2.0.0

x()

Returns the X coordinate. Returns: The X coordinate Since: 2.0.0

y()

Returns the Y coordinate. Returns: The Y coordinate Since: 2.0.0

z()

Returns the Z coordinate. Returns: The Z coordinate Since: 2.0.0

Rotation

pitch()

Returns the pitch (vertical rotation). Returns: The pitch in degrees Since: 2.0.0

yaw()

Returns the yaw (horizontal rotation). Returns: The yaw in degrees Since: 2.0.0

Location Manipulation

add()

Creates a new location by adding the specified coordinates to this location. Parameters:
  • x - The X offset
  • y - The Y offset
  • z - The Z offset
Returns: The new location Since: 2.0.0 Example:

Distance Calculations

distance()

Calculates the distance between this location and another location. Parameters:
  • other - The other location
Returns: The distance Since: 2.1.0 Example:

distanceSquared()

Calculates the squared distance between this location and another location.
Use this method instead of distance() when comparing distances, as it avoids the expensive square root calculation.
Parameters:
  • other - The other location
Returns: The squared distance Since: 2.1.0 Example:

Task Scheduling

Inherited from PlatformRegionHolder:

task()

Schedules a task to run on the next tick, synchronized with this location’s region. Parameters:
  • runnable - The task to run
Returns: The scheduled task, or null if scheduling failed Since: 2.0.0

taskLater()

Schedules a task to run after a delay, synchronized with this location’s region. Parameters:
  • delay - The delay in ticks
  • runnable - The task to run
Returns: The scheduled task, or null if scheduling failed Since: 2.0.0

Platform Adapter Usage

Use BukkitAdapter to convert Bukkit locations to PlatformLocation:

Usage Examples

Basic Usage

Distance Checking

Location Offsetting

Region-Safe Task Scheduling

  • PlatformEntity - Entity with location
  • PlatformWorld - World representation
  • PlatformRegionHolder - Region-aware task scheduling
  • ModelTask - Scheduled task handle