All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.skillw.particlelib.utils.coordinate.PlayerFixedCoordinate.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.particlelib.utils.coordinate

import taboolib.common.util.Location
import com.skillw.particlelib.utils.LocationUtils

/**
 * 表示一个将X轴显示在玩家面前的坐标器
 *
 * 自动修正在XZ平面上的粒子朝向
 *
 * @author Zoyn
 */
class PlayerFixedCoordinate(playerLocation: Location) : Coordinate {
    /** 原点 */
    private val originDot: Location

    /** 旋转角度 */
    private val rotateAngle: Double

    init {
        // 旋转的角度
        rotateAngle = playerLocation.yaw.toDouble()
        originDot = playerLocation.clone()
        // 重设仰俯角, 防止出现仰头后旋转角度不正确的问题
        originDot.pitch = 0f
    }

    fun getOriginDot(): Location {
        return originDot
    }

    override fun newLocation(x: Double, y: Double, z: Double): Location? {
        return LocationUtils.rotateLocationAboutPoint(originDot.clone().add(-x, y, z), rotateAngle, originDot)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy