Teams module

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

1 implementationMISC

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)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleTeams.ktKotlin · 164 lines · 5.7 KB

Prevents KillAura from attacking team mates.

SettingsMatchesArmorColorColorSources
ModuleTeams.ktKotlin · Minecraft 26.2 · 164 lines · 5.7 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.misc
20
21
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet
22
import net.ccbluex.fastutil.enumSetOf
23
import net.ccbluex.liquidbounce.config.types.list.Tagged
24
import net.ccbluex.liquidbounce.event.events.TagEntityEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.render.engine.type.Color4b
29
import net.ccbluex.liquidbounce.utils.text.stripMinecraftColorCodes
30
import net.ccbluex.liquidbounce.utils.inventory.EquipmentSlotChoice
31
import net.ccbluex.liquidbounce.utils.kotlin.Priority
32
import net.ccbluex.liquidbounce.utils.kotlin.matchesAny
33
import net.minecraft.world.entity.Entity
34
import net.minecraft.world.entity.LivingEntity
35
import net.minecraft.world.entity.player.Player
36
import java.util.function.Predicate
37
38
/**
39
 * Teams module
40
 *
41
 * Prevents KillAura from attacking teammates.
42
 */
43
object ModuleTeams : ClientModule("Teams", ModuleCategories.MISC) {
44
45
    private val matches by multiEnumChoice(
46
        "Matches",
47
        enumSetOf(Matches.SCOREBOARD_TEAM, Matches.NAME_COLOR),
48
    )
49
50
    private val armorColorSlots by multiEnumChoice(
51
        "ArmorColor",
52
        enumSetOf(EquipmentSlotChoice.HEAD),
53
        EquipmentSlotChoice.allHumanoidArmor(),
54
    )
55
56
    private val colorSources by multiEnumChoice(
57
        "ColorSources",
58
        ObjectLinkedOpenHashSet(ColorSource.entries),
59
        canBeNone = true,
60
    )
61
62
    private enum class ColorSource(
63
        override val tag: String,
64
        val entityToColor: (Entity) -> Int?,
65
    ) : Tagged {
66
        TEAM("Team", { entity ->
67
            entity.team?.color?.orElse(null)?.rgb()
68
        }),
69
        ARMOR("Armor", { entity ->
70
            val armorColorSlots = armorColorSlots
71
            if (entity is LivingEntity && armorColorSlots.isNotEmpty()) {
72
                armorColorSlots.firstNotNullOfOrNull { it.getArmorColor(entity) }
73
            } else {
74
                null
75
            }
76
        }),
77
    }
78
79
    @Suppress("unused")
80
    private val entityTagEvent = handler<TagEntityEvent> { event ->
81
        val entity = event.entity
82
83
        if (entity is LivingEntity && isInClientPlayersTeam(entity)) {
84
            event.dontTarget()
85
        }
86
87
        // Resolve tag color from sources (first found)
88
        val color = colorSources.firstNotNullOfOrNull { it.entityToColor(entity) }
89
        event.color(Color4b.fullAlpha(color ?: return@handler), Priority.IMPORTANT_FOR_USAGE_1)
90
    }
91
92
    /**
93
     * Check if [entity] is in your own team using scoreboard,
94
     * name color, armor color or team prefix.
95
     */
96
    private fun isInClientPlayersTeam(entity: LivingEntity) =
97
        matches.matchesAny(entity) || checkArmor(entity)
98
99
    /**
100
     * Checks if the color of any armor piece matches.
101
     */
102
    private fun checkArmor(entity: LivingEntity) =
103
        entity is Player && armorColorSlots.any { it.matchesArmorColor(entity) }
104
105
    @Suppress("unused")
106
    private enum class Matches(
107
        override val tag: String,
108
        private val testMatches: Predicate<LivingEntity>,
109
    ) : Tagged, Predicate<LivingEntity> by testMatches {
110
        /**
111
         * Check if [LivingEntity] is in your own team using scoreboard,
112
         */
113
        SCOREBOARD_TEAM("ScoreboardTeam", { suspected ->
114
            player.isAlliedTo(suspected)
115
        }),
116
117
        /**
118
         * Checks if both names have the same color.
119
         */
120
        NAME_COLOR("NameColor", { suspected ->
121
            val targetColor = player.displayName?.style?.color
122
            val clientColor = suspected.displayName?.style?.color
123
124
            targetColor != null
125
                && clientColor != null
126
                && targetColor == clientColor
127
        }),
128
129
        /**
130
         * Prefix check - this works on Hypixel BedWars, GommeHD Skywars and many other servers.
131
         */
132
        PREFIX("Prefix", { suspected ->
133
            val targetSplit = suspected.displayName
134
                ?.string
135
                ?.stripMinecraftColorCodes()
136
                ?.split(' ', limit = 2)
137
138
            val clientSplit = player.displayName
139
                ?.string
140
                ?.stripMinecraftColorCodes()
141
                ?.split(' ', limit = 2)
142
143
            targetSplit != null
144
                && clientSplit != null
145
                && targetSplit.size > 1
146
                && clientSplit.size > 1
147
                && targetSplit[0] == clientSplit[0]
148
        })
149
    }
150
151
    /**
152
     * Checks if the color of the item in the [EquipmentSlotChoice.slot] of
153
     * the [player] matches the user's armor color in the same slot.
154
     */
155
    private fun EquipmentSlotChoice.matchesArmorColor(suspected: Player): Boolean {
156
        // returns false if the armor is not dyeable (e.g., iron armor)
157
        // to avoid a false positive from `null == null`
158
        val ownColor = getArmorColor(player) ?: return false
159
        val otherColor = getArmorColor(suspected) ?: return false
160
161
        return ownColor == otherColor
162
    }
163
}
164