AutoDeposit module

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

1 implementationPLAYER

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)PLAYERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/autodeposit/ModuleAutoDeposit.ktKotlin · 121 lines · 4.8 KB

Automatically deposits configured items from the player inventory into containers.

SettingsFilterItemsAutoClose
ModuleAutoDeposit.ktKotlin · Minecraft 26.2 · 121 lines · 4.8 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.player.autodeposit
20
21
import net.ccbluex.liquidbounce.event.events.ScheduleInventoryActionEvent
22
import net.ccbluex.liquidbounce.event.handler
23
import net.ccbluex.liquidbounce.features.module.ClientModule
24
import net.ccbluex.liquidbounce.features.module.ModuleCategories
25
import net.ccbluex.liquidbounce.utils.collection.Filter
26
import net.ccbluex.liquidbounce.utils.collection.itemSortedSetOf
27
import net.ccbluex.liquidbounce.utils.inventory.CheckScreenHandlerTypeValueGroup
28
import net.ccbluex.liquidbounce.utils.inventory.CheckScreenTitleValueGroup
29
import net.ccbluex.liquidbounce.utils.inventory.getSlotsInContainer
30
import net.ccbluex.liquidbounce.utils.inventory.InventoryAction
31
import net.ccbluex.liquidbounce.utils.inventory.InventoryConstraints
32
import net.ccbluex.liquidbounce.utils.inventory.mergeableCapacityFor
33
import net.ccbluex.liquidbounce.utils.inventory.Slots
34
import net.ccbluex.liquidbounce.utils.inventory.syncId
35
import net.minecraft.client.gui.screens.Screen
36
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
37
import net.minecraft.client.gui.screens.inventory.InventoryScreen
38
39
/**
40
 * AutoDeposit module
41
 *
42
 * Automatically deposits configured items from the player inventory into containers.
43
 */
44
object ModuleAutoDeposit : ClientModule(
45
    "AutoDeposit", ModuleCategories.PLAYER,
46
    aliases = listOf("AutoStore", "ContainerStorer")
47
) {
48
49
    private val filter by enumChoice("Filter", Filter.WHITELIST)
50
    private val itemsList by items("Items", itemSortedSetOf())
51
    private val autoClose by boolean("AutoClose", true)
52
53
    private val inventoryConstraints = tree(InventoryConstraints())
54
    private val checkScreenHandlerType = tree(CheckScreenHandlerTypeValueGroup(this))
55
    private val checkScreenTitle = tree(CheckScreenTitleValueGroup(this))
56
57
    init {
58
        tree(PunchToDeposit)
59
    }
60
61
    /**
62
     * Whether the player inventory currently holds any item matching the configured filter.
63
     *
64
     * Used by features to only act (e.g. click containers) when there is something to deposit.
65
     */
66
    fun matchingSlots(inventory: Boolean) = (if (inventory) Slots.HotbarAndInventory else Slots.Hotbar)
67
        .filter { !it.itemStack.isEmpty && filter(it.itemStack.item, itemsList) }
68
69
    fun canBeStored(screen: Screen): Boolean {
70
        return running && screen is AbstractContainerScreen<*> && screen !is InventoryScreen &&
71
            checkScreenHandlerType.isValid(screen) && checkScreenTitle.isValid(screen)
72
    }
73
74
    // Session state so we only auto-close containers we actually deposited into.
75
    private var currentSyncId = -1
76
    private var depositedAnything = false
77
78
    override fun onDisabled() {
79
        super.onDisabled()
80
        currentSyncId = -1
81
        depositedAnything = false
82
    }
83
84
    @Suppress("unused")
85
    private val scheduleInventoryAction = handler<ScheduleInventoryActionEvent> { event ->
86
        val screen = mc.gui.screen() as? AbstractContainerScreen<*> ?: run {
87
            currentSyncId = -1
88
            depositedAnything = false
89
            return@handler
90
        }
91
        if (!canBeStored(screen)) {
92
            return@handler
93
        }
94
95
        if (screen.syncId != currentSyncId) {
96
            currentSyncId = screen.syncId
97
            depositedAnything = false
98
        }
99
100
        val matching = matchingSlots(inventory = true)
101
        if (matching.isNotEmpty()) {
102
            depositedAnything = true
103
        }
104
105
        // Only click items the container can still absorb; a full container would otherwise be
106
        // re-clicked forever since the server rejects the move without changing the inventory.
107
        val containerSlots = screen.getSlotsInContainer()
108
        val targets = matching.filter { containerSlots.mergeableCapacityFor(it.itemStack) > 0 }
109
110
        if (targets.isNotEmpty()) {
111
            for (slot in targets) {
112
                event.schedule(inventoryConstraints, InventoryAction.Click.performQuickMove(screen, slot))
113
            }
114
        } else if (autoClose && depositedAnything) {
115
            event.schedule(inventoryConstraints, InventoryAction.CloseScreen(screen))
116
            currentSyncId = -1
117
        }
118
    }
119
120
}
121