aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/util/Utils.kt
blob: 93597d26be9438852faa55d6c31f7d699a2fc983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.dulkirfabric.util

import com.dulkirfabric.events.PlaySoundEvent
import net.minecraft.entity.Entity
import net.minecraft.util.math.Vec3d

object Utils {
    fun isInSkyblock(): Boolean {
        return ScoreBoardUtils.getLines() != null
    }

    /**
     * Prints relevant information about a sound that is being displayed
     */
    fun debugSound(event: PlaySoundEvent) {
        if (event.sound.id.path == "entity.player.hurt"
            && event.sound.pitch == 0f
            && event.sound.volume == 0f) return
        println("Path: ${event.sound.id.path}")
        println("Pitch: ${event.sound.pitch}")
        println("Volume: ${event.sound.volume}")
    }

    private fun lerp(prev: Vec3d, cur: Vec3d, tickDelta: Float): Vec3d {
        return Vec3d(
            prev.x + (cur.x - prev.x) * tickDelta,
            prev.y + (cur.y - prev.y) * tickDelta,
            prev.z + (cur.z - prev.z) * tickDelta,
        )
    }
    fun Entity.getInterpolatedPos(tickDelta: Float): Vec3d {
        val prevPos = Vec3d(this.prevX, this.prevY, this.prevZ)
        return lerp(prevPos, this.pos, tickDelta)
    }
}