From b62913fa6e0315a33bfe68c16da0554fdb940337 Mon Sep 17 00:00:00 2001 From: Stephen <138625055+stephendotgg@users.noreply.github.com> Date: Fri, 8 Dec 2023 22:36:12 +0000 Subject: [PATCH] Location extension class --- .../gg/flyte/twilight/extension/Location.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/kotlin/gg/flyte/twilight/extension/Location.kt b/src/main/kotlin/gg/flyte/twilight/extension/Location.kt index 6db71ec..8279e0d 100644 --- a/src/main/kotlin/gg/flyte/twilight/extension/Location.kt +++ b/src/main/kotlin/gg/flyte/twilight/extension/Location.kt @@ -1,10 +1,33 @@ package gg.flyte.twilight.extension import org.bukkit.Location +import org.bukkit.World import org.bukkit.entity.Entity import org.bukkit.entity.EntityType import org.bukkit.inventory.ItemStack +/** + * An extension of the Bukkit Location class, providing conversion of the given coordinates + * to double and orientation to float. + * + * @param world The world in which the location exists. + * @param x The x-coordinate of the location. + * @param y The y-coordinate of the location. + * @param z The z-coordinate of the location. + * @param yaw The yaw (rotation on the horizontal plane) at this location, defaulting to 0 if not specified. + * @param pitch The pitch (vertical rotation) at this location, defaulting to 0 if not specified. + * + * @constructor Creates a new Location object with specified world, coordinates, and optionally, orientation. + */ +data class Location( + val world: World, + val x: Number, + val y: Number, + val z: Number, + val yaw: Number = 0, + val pitch: Number = 0 +) : Location(world, x.toDouble(), y.toDouble(), z.toDouble(), yaw.toFloat(), pitch.toFloat()) + /** * Drops the specified [itemStack] at the current location in the world. *