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

com.skillw.pouvoir.internal.feature.raytrace.RayTrace.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.internal.feature.raytrace

import org.bukkit.entity.LivingEntity
import org.bukkit.util.Vector

class RayTrace(private val origin: Vector, private val direction: Vector) {

    constructor(entity: LivingEntity) : this(
        entity.eyeLocation.toVector(),
        entity.eyeLocation.direction
    )

    fun traces(distance: Double, accuracy: Double): Set {
        return mutableSetOf().let {
            var process = 0.0
            while (process <= distance) {
                it.add(distance(process))
                process += accuracy
            }
            it
        }
    }

    private fun distance(distance: Double): Vector {
        return origin.clone().add(direction.clone().multiply(distance))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy