aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/FireVeilWandParticles.kt
blob: ff4c80d69820dd4ad6b291e465d57336d7643492 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package at.hannibal2.skyhanni.features

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ItemClickInHandEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.SpecialColour
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.opengl.GL11
import java.awt.Color

class FireVeilWandParticles {

    var lastClick = 0L

    @SubscribeEvent
    fun onChatPacket(event: PacketEvent.ReceiveEvent) {
        if (!LorenzUtils.inSkyblock) return
        if (SkyHanniMod.feature.abilities.fireVeilWandDisplay == 0) return
        if (System.currentTimeMillis() > lastClick + 5_500) return

        val packet = event.packet
        if (packet !is S2APacketParticles) return


        if (packet.particleType == EnumParticleTypes.FLAME && packet.particleCount == 1 && packet.particleSpeed == 0f &&
            packet.xOffset == 0f &&
            packet.yOffset == 0f &&
            packet.zOffset == 0f
        ) {
            event.isCanceled = true
        }
    }

    @SubscribeEvent
    fun onItemClick(event: ItemClickInHandEvent) {
        if (!LorenzUtils.inSkyblock) return
        if (event.clickType != ItemClickInHandEvent.ClickType.RIGHT_CLICK) return

        val itemInHand = event.itemInHand ?: return

        val internalName = itemInHand.getInternalName()
        if (internalName == "FIRE_VEIL_WAND") {
            lastClick = System.currentTimeMillis()
        }
    }

    @SubscribeEvent
    fun onRenderWorld(event: RenderWorldLastEvent) {
        if (!LorenzUtils.inSkyblock) return
        if (SkyHanniMod.feature.abilities.fireVeilWandDisplay != 1) return
        if (System.currentTimeMillis() > lastClick + 5_500) return

        val color = Color(SpecialColour.specialToChromaRGB(SkyHanniMod.feature.abilities.fireVeilWandDisplayColor), true)

        GlStateManager.pushMatrix()
        GL11.glNormal3f(0.0f, 1.0f, 0.0f)

        GlStateManager.enableDepth()
        GlStateManager.enableBlend()
        GlStateManager.depthFunc(GL11.GL_LEQUAL)
        GlStateManager.disableCull()
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
        GlStateManager.enableAlpha()
        GlStateManager.disableTexture2D()

        GlStateManager.disableDepth()
        RenderUtils.drawCircle(
            Minecraft.getMinecraft().thePlayer,
            event.partialTicks,
            3.5,
            color
        )
        GlStateManager.enableDepth()

        GlStateManager.enableCull()
        GlStateManager.enableTexture2D()
        GlStateManager.enableDepth()
        GlStateManager.disableBlend()
        GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
        GlStateManager.popMatrix()
    }
}