MurderMystery module

MurderMystery: 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/murdermystery/ModuleMurderMystery.ktKotlin · 197 lines · 6.4 KB

Tells you who the murderer is.

SettingsSetTeamPrefix
ModuleMurderMystery.ktKotlin · Minecraft 26.2 · 197 lines · 6.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.murdermystery
20
21
import net.ccbluex.fastutil.forEachIsInstance
22
import net.ccbluex.liquidbounce.event.events.PacketEvent
23
import net.ccbluex.liquidbounce.event.events.TagEntityEvent
24
import net.ccbluex.liquidbounce.event.events.WorldChangeEvent
25
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
26
import net.ccbluex.liquidbounce.event.handler
27
import net.ccbluex.liquidbounce.features.module.ClientModule
28
import net.ccbluex.liquidbounce.features.module.ModuleCategories
29
import net.ccbluex.liquidbounce.render.WorldRenderEnvironment
30
import net.ccbluex.liquidbounce.render.drawBox
31
import net.ccbluex.liquidbounce.render.engine.type.Color4b
32
import net.ccbluex.liquidbounce.render.renderEnvironment
33
import net.ccbluex.liquidbounce.render.withPositionRelativeToCamera
34
import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition
35
import net.ccbluex.liquidbounce.utils.kotlin.Priority
36
import net.minecraft.client.player.AbstractClientPlayer
37
import net.minecraft.client.resources.sounds.SimpleSoundInstance
38
import net.minecraft.network.protocol.game.ClientboundLoginPacket
39
import net.minecraft.network.protocol.game.ClientboundRespawnPacket
40
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
41
import net.minecraft.sounds.SoundEvents
42
import net.minecraft.world.entity.Entity
43
import net.minecraft.world.entity.EquipmentSlot
44
import net.minecraft.world.entity.decoration.ArmorStand
45
import net.minecraft.world.item.BowItem
46
import net.minecraft.world.item.ItemStack
47
import net.minecraft.world.phys.AABB
48
49
object ModuleMurderMystery : ClientModule("MurderMystery", ModuleCategories.RENDER) {
50
    var playHurt = false
51
    var playBow = false
52
53
    private val setTeamPrefix by boolean("SetTeamPrefix", true)
54
55
    val modes =
56
        choices(
57
            "Mode",
58
            MurderMysteryClassicMode,
59
            arrayOf(MurderMysteryClassicMode, MurderMysteryInfectionMode, MurderMysteryAssassinationMode),
60
        )
61
62
    init {
63
        modes.onChanged {
64
            resetModeState()
65
        }
66
    }
67
68
    private val currentMode: MurderMysteryMode
69
        get() = this.modes.activeMode
70
71
    override fun onDisabled() {
72
        this.reset()
73
    }
74
75
    private fun reset() {
76
        playHurt = false
77
        playBow = false
78
        resetModeState()
79
    }
80
81
    private fun resetModeState() {
82
        this.modes.modes.forEach(MurderMysteryMode::reset)
83
    }
84
85
    @Suppress("unused")
86
    val renderHandler = handler<WorldRenderEvent> { event ->
87
        if (playHurt) {
88
            mc.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.VILLAGER_HURT, 1F))
89
90
            playHurt = false
91
        }
92
93
        if (playBow) {
94
            mc.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.CROSSBOW_SHOOT, 1F))
95
96
            playBow = false
97
        }
98
99
        event.renderEnvironment {
100
            world.entitiesForRendering().forEachIsInstance<ArmorStand> {
101
                if (it.getItemBySlot(EquipmentSlot.MAINHAND).item is BowItem && it.isInvisible) {
102
                    renderDroppedBowBox(event.partialTicks, it)
103
                }
104
            }
105
        }
106
    }
107
108
    val packetHandler = handler<PacketEvent> { packetEvent ->
109
        val world = mc.level ?: return@handler
110
111
        when (val packet = packetEvent.packet) {
112
            is ClientboundSetEquipmentPacket -> {
113
                val entity = world.getEntity(packet.entity)
114
115
                packet.slots
116
                    .filter {
117
                        !it.second.isEmpty && it.first.type == EquipmentSlot.Type.HAND
118
                    }
119
                    .forEach {
120
                        handleItem(it.second, entity)
121
                    }
122
            }
123
124
            is ClientboundLoginPacket, is ClientboundRespawnPacket -> {
125
                this.reset()
126
            }
127
        }
128
    }
129
130
    val tagHandler = handler<TagEntityEvent> {
131
        if (it.entity !is AbstractClientPlayer) {
132
            return@handler
133
        }
134
135
        if (!shouldAttack(it.entity)) {
136
            it.dontTarget()
137
        }
138
139
        val playerType = this.currentMode.getPlayerType(it.entity)
140
        val entity = it.entity
141
142
        val col = when (playerType) {
143
            MurderMysteryMode.PlayerType.DETECTIVE_LIKE -> Color4b(0, 144, 255)
144
            MurderMysteryMode.PlayerType.MURDERER -> Color4b(203, 9, 9)
145
            MurderMysteryMode.PlayerType.NEUTRAL -> return@handler
146
        }
147
        if (setTeamPrefix) entity.team?.setPlayerPrefix(playerType.prefix)
148
149
        it.color(col, Priority.IMPORTANT_FOR_USAGE_3)
150
    }
151
152
    val worldChangeHandler = handler<WorldChangeEvent> {
153
        reset()
154
    }
155
156
    private fun handleItem(
157
        itemStack: ItemStack,
158
        entity: Entity?,
159
    ) {
160
        if (entity !is AbstractClientPlayer) {
161
            return
162
        }
163
164
        val isSword = MurderMysterySwordDetection.isSword(itemStack)
165
        val isBow = itemStack.item is BowItem
166
167
        when {
168
            isSword -> currentMode.handleHasSword(entity)
169
            isBow -> currentMode.handleHasBow(entity)
170
        }
171
    }
172
173
    private fun WorldRenderEnvironment.renderDroppedBowBox(partialTicks: Float, armorStandEntity: ArmorStand) {
174
        val box = AABB(-0.6, 0.0, -0.6, 0.6, 2.5, 0.6)
175
        val pos = armorStandEntity.interpolateCurrentPosition(partialTicks)
176
177
        withPositionRelativeToCamera(pos) {
178
            drawBox(
179
                box,
180
                Color4b(127, 255, 212, 100), Color4b(0, 255, 255)
181
            )
182
        }
183
    }
184
185
    private fun shouldAttack(entityPlayer: AbstractClientPlayer): Boolean {
186
        return this.currentMode.shouldAttack(entityPlayer)
187
    }
188
189
    fun disallowsArrowDodge(): Boolean {
190
        if (!running) {
191
            return false
192
        }
193
194
        return this.currentMode.disallowsArrowDodge()
195
    }
196
}
197