HitFX module

HitFX: Minecraft 26.3 cheat module, full source for every implementation (1 client: LiquidBounce (Kotlin)).

1 implementationRENDER

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

LiquidBounce (Kotlin)RENDERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/hitfx/ModuleHitFX.ktKotlin · 156 lines · 5.4 KB

Hitting a target triggers a special effect.

SettingsParticleParticleAmountOtherSoundSelfSound
ModuleHitFX.ktKotlin · Minecraft 26.2 · 156 lines · 5.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.render.hitfx
20
21
import net.ccbluex.liquidbounce.config.types.list.Tagged
22
import net.ccbluex.liquidbounce.event.events.AttackEntityEvent
23
import net.ccbluex.liquidbounce.event.events.PacketEvent
24
import net.ccbluex.liquidbounce.event.handler
25
import net.ccbluex.liquidbounce.features.module.ClientModule
26
import net.ccbluex.liquidbounce.features.module.ModuleCategories
27
import net.minecraft.core.particles.ParticleTypes
28
import net.minecraft.network.protocol.game.ClientboundSoundPacket
29
import net.minecraft.sounds.SoundEvents
30
import net.minecraft.sounds.SoundSource
31
import net.minecraft.world.entity.LivingEntity
32
import net.minecraft.world.level.block.Blocks
33
34
object ModuleHitFX : ClientModule("HitFX", ModuleCategories.RENDER) {
35
36
    enum class Particle(override val tag: String) : Tagged {
37
        BLOOD("Blood"),
38
        FIRE("Fire"),
39
        HEART("Heart"),
40
        WATER("Water"),
41
        SMOKE("Smoke"),
42
        MAGIC("Magic"),
43
        CRITS("Crits"),
44
    }
45
46
    private val particles by multiEnumChoice("Particle", Particle.FIRE)
47
    private val particleAmount by intRange("ParticleAmount", 1..1, 1..20)
48
49
    private val otherSoundSet by multiEnumChoice("OtherSound", HitFXRegistry.POP)
50
51
    private val otherSound
52
        get() = otherSoundSet.randomOrNull()?.sounds?.randomOrNull()
53
54
    val selfSound
55
        get() = selfSoundSet.randomOrNull()?.sounds?.randomOrNull()
56
57
    private val selfSoundSet by multiEnumChoice("SelfSound", HitFXRegistry.BOYKISSER)
58
59
    private var lastTargetId: Int? = null
60
61
    private val vanillaHitSounds = setOf(
62
        SoundEvents.ARROW_HIT_PLAYER,
63
        SoundEvents.PLAYER_ATTACK_NODAMAGE,
64
        SoundEvents.PLAYER_ATTACK_KNOCKBACK,
65
        SoundEvents.PLAYER_ATTACK_CRIT,
66
        SoundEvents.PLAYER_ATTACK_STRONG,
67
        SoundEvents.PLAYER_ATTACK_SWEEP,
68
        SoundEvents.PLAYER_ATTACK_WEAK,
69
        SoundEvents.SPEAR_HIT,
70
        SoundEvents.PLAYER_HURT,
71
    )
72
73
    @Suppress("unused")
74
    private val effectHandler = handler<PacketEvent> { event ->
75
        val packet = event.packet
76
77
        if (packet !is ClientboundSoundPacket) {
78
            return@handler
79
        }
80
81
        val source = packet.source
82
        val sound = packet.sound.value()
83
84
        // Cannot be from any living entity.
85
        if (source != SoundSource.PLAYERS && source != SoundSource.NEUTRAL && source != SoundSource.HOSTILE) {
86
            return@handler
87
        }
88
89
        if (sound !in vanillaHitSounds) {
90
            return@handler
91
        }
92
93
        val lastTarget = lastTargetId?.let { world.getEntity(it) as? LivingEntity } ?: return@handler
94
        if (!lastTarget.isAlive) {
95
            return@handler
96
        }
97
98
        val distanceToSq = lastTarget.distanceToSqr(packet.x, packet.y, packet.z)
99
        if (distanceToSq > 16.0) {
100
            return@handler
101
        }
102
103
        playEffect(lastTarget)
104
        otherSound?.let { sound ->
105
            mc.execute {
106
                world.playSeededSound(
107
                    player,
108
                    packet.x,
109
                    packet.y,
110
                    packet.z,
111
                    sound,
112
                    packet.source,
113
                    packet.volume,
114
                    packet.pitch,
115
                    packet.seed
116
                )
117
            }
118
            event.cancelEvent()
119
        }
120
        this.lastTargetId = null
121
    }
122
123
    @Suppress("unused")
124
    private val attackHandler = handler<AttackEntityEvent> { event ->
125
        val target = event.entity
126
127
        if (target is LivingEntity) {
128
            if (!target.isAlive) {
129
                return@handler
130
            }
131
132
            this.lastTargetId = target.id
133
        }
134
    }
135
136
    private fun playEffect(target: LivingEntity) = mc.execute {
137
        val particles = particles.ifEmpty { return@execute }
138
        repeat(particleAmount.random()) {
139
            when (particles.random()) {
140
                Particle.BLOOD -> world.addDestroyBlockEffect(
141
                    target.blockPosition().above(1),
142
                    Blocks.REDSTONE_BLOCK.defaultBlockState()
143
                )
144
145
                Particle.FIRE -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.LAVA)
146
                Particle.HEART -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.HEART)
147
                Particle.WATER -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.FALLING_WATER)
148
                Particle.SMOKE -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.SMOKE)
149
                Particle.MAGIC -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.ENCHANTED_HIT)
150
                Particle.CRITS -> mc.particleEngine.createTrackingEmitter(target, ParticleTypes.CRIT)
151
            }
152
        }
153
    }
154
155
}
156