aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/HurtCamSlider.kt
blob: 7237d9554a6d31aa02ef6e5103f16487848608d5 (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
package dulkirmod.features

import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.EntityLivingBase
import net.minecraft.util.MathHelper

object HurtCamSlider {
    fun renderHurt(partialTicks: Float): Boolean {
        if (!Config.hurtCamSlider) return false
        if (mc.renderViewEntity is EntityLivingBase) {
            val entitylivingbase = mc.renderViewEntity as EntityLivingBase
            var f: Float = (entitylivingbase.hurtTime.toFloat() - partialTicks)
            if (entitylivingbase.health <= 0.0f) {
                val f1: Float = entitylivingbase.deathTime.toFloat() + partialTicks
                GlStateManager.rotate(40.0f - 8000.0f / (f1 + 200.0f), 0.0f, 0.0f, 1.0f)
            }
            if (f < 0.0f) {
                return true
            }
            f /= entitylivingbase.maxHurtTime.toFloat()
            f = MathHelper.sin(f * f * f * f * Math.PI.toFloat())
            val f2 = entitylivingbase.attackedAtYaw
            GlStateManager.rotate(-f2, 0.0f, 1.0f, 0.0f)
            GlStateManager.rotate(-f * 14.0f * Config.hurtCamIntensity, 0.0f, 0.0f, 1.0f)
            GlStateManager.rotate(f2, 0.0f, 1.0f, 0.0f)
        }
        return true
    }
}