LogoffSpot module

LogoffSpot: 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/ModuleLogoffSpot.ktKotlin · 140 lines · 5.4 KB

Allows you to see where other players logged off.

SettingsSendInChat
ModuleLogoffSpot.ktKotlin · Minecraft 26.2 · 140 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
20
21
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
22
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleBlink
23
import net.ccbluex.liquidbounce.event.events.GameTickEvent
24
import net.ccbluex.liquidbounce.event.events.PacketEvent
25
import net.ccbluex.liquidbounce.event.events.WorldChangeEvent
26
import net.ccbluex.liquidbounce.event.events.WorldEntityRemoveEvent
27
import net.ccbluex.liquidbounce.event.handler
28
import net.ccbluex.liquidbounce.features.module.ClientModule
29
import net.ccbluex.liquidbounce.features.module.ModuleCategories
30
import net.ccbluex.liquidbounce.utils.client.chat
31
import net.ccbluex.liquidbounce.utils.client.regular
32
import net.ccbluex.liquidbounce.utils.entity.getActualHealth
33
import net.ccbluex.liquidbounce.utils.network.entityIdC2SInteractOrAttack
34
import net.ccbluex.liquidbounce.utils.render.entity
35
import net.ccbluex.liquidbounce.utils.world.nextLocalEntityId
36
import net.minecraft.client.player.RemotePlayer
37
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState
38
import net.minecraft.world.entity.Entity
39
import net.minecraft.world.entity.player.Player
40
import java.time.Instant
41
import java.util.UUID
42
43
/**
44
 * Log off spot
45
 *
46
 * Creates a fake player entity when a player logs off.
47
 */
48
object ModuleLogoffSpot : ClientModule("LogoffSpot", ModuleCategories.RENDER) {
49
50
    private val enableSendInChat by boolean("SendInChat", default = true)
51
52
    @JvmRecord
53
    private data class LoggedOffPlayer(
54
        val time: Instant,
55
        val entity: Entity,
56
    )
57
58
    private val lastSeenPlayers = Object2ObjectOpenHashMap<UUID, LoggedOffPlayer>()
59
60
    @Suppress("unused")
61
    private val entityRemoveHandler = handler<WorldEntityRemoveEvent> { event ->
62
        val entity = event.entity
63
        if (entity !is Player
64
            || isLogoffEntity(entity.id)
65
            || ModuleBlink.isDummyPlayer(entity.id)) {
66
            return@handler
67
        }
68
69
        // Note: I thought we could keep [entity], but I was not able to keep it from being removed
70
        // from the world. So, we have to create a new entity and copy the position and rotation.
71
        val clone = RemotePlayer(world, entity.gameProfile)
72
        clone.yHeadRot = entity.yHeadRot
73
        clone.copyPosition(entity)
74
        clone.setUUID(UUID.randomUUID())
75
        clone.id = world.nextLocalEntityId()
76
        clone.inventory.replaceWith(entity.inventory)
77
        clone.health = entity.getActualHealth()
78
        world.addEntity(clone)
79
        lastSeenPlayers[entity.uuid] = LoggedOffPlayer(Instant.now(), clone)
80
81
        val blockPos = entity.blockPosition()
82
        if (enableSendInChat) {
83
            chat(regular(message("disappeared", entity.scoreboardName, blockPos.x, blockPos.y, blockPos.z)))
84
        }
85
    }
86
87
    @Suppress("unused")
88
    private val tickHandler = handler<GameTickEvent> {
89
        lastSeenPlayers.entries.removeIf { (id, loggedOffPlayer) ->
90
            val playerEntity = loggedOffPlayer.entity
91
            val blockPos = playerEntity.blockPosition()
92
93
            if (!world.isLoaded(blockPos)) {
94
                if (enableSendInChat) chat(regular(message("unloaded", playerEntity.scoreboardName)))
95
                world.removeEntity(playerEntity.id, Entity.RemovalReason.UNLOADED_TO_CHUNK)
96
                true
97
            } else if (world.getPlayerByUUID(id) != null) {
98
                if (enableSendInChat) chat(regular(message("reappeared", playerEntity.scoreboardName)))
99
                world.removeEntity(playerEntity.id, Entity.RemovalReason.UNLOADED_WITH_PLAYER)
100
                true
101
            } else {
102
                false
103
            }
104
        }
105
    }
106
107
    @Suppress("unused")
108
    private val worldChangeHandler = handler<WorldChangeEvent> {
109
        lastSeenPlayers.clear()
110
    }
111
112
    @Suppress("unused")
113
    private val packetHandler = handler<PacketEvent> { event ->
114
        val packet = event.packet
115
116
        if (isLogoffEntity(packet.entityIdC2SInteractOrAttack ?: return@handler)) {
117
            event.cancelEvent()
118
        }
119
    }
120
121
    override fun onDisabled() {
122
        for ((_, playerEntity) in lastSeenPlayers.values) {
123
            // Use [mc.world] instead of [world] to prevent NPE when the module is disabled
124
            // outside the game
125
            mc.level?.removeEntity(playerEntity.id, Entity.RemovalReason.UNLOADED_TO_CHUNK)
126
        }
127
128
        lastSeenPlayers.clear()
129
        super.onDisabled()
130
    }
131
132
    fun isLogoffEntity(state: LivingEntityRenderState): Boolean {
133
        return isLogoffEntity(state.entity?.id ?: return false)
134
    }
135
136
    fun isLogoffEntity(entityId: Int) = this.running
137
        && lastSeenPlayers.values.any { (_, playerEntity) -> playerEntity.id == entityId }
138
139
}
140