Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Packet InventoryMove + tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Jul 8, 2024
1 parent 601075b commit 5c63da1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory.MOVEMENT
import net.ccbluex.liquidbounce.ui.client.clickgui.ClickGui
import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.extensions.updateKeys
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager.canClickInventory
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils.serverOpenInventory
import net.ccbluex.liquidbounce.value.BooleanValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.client.gui.GuiChat
import net.minecraft.client.gui.GuiIngameMenu
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.network.play.client.C0DPacketCloseWindow
import net.minecraft.network.play.client.C0EPacketClickWindow
import net.minecraft.network.play.client.C16PacketClientStatus
import net.minecraft.network.play.client.C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT

object InventoryMove : Module("InventoryMove", MOVEMENT, gameDetecting = false) {

private val notInChests by BooleanValue("NotInChests", false)
private val silent by BooleanValue("Silent", false)
private val mode by ListValue("Mode", arrayOf("Normal", "Silent", "Packet"), "Normal")
private val intave by BooleanValue("Intave", false)

private val isIntave = (mc.currentScreen is GuiInventory || mc.currentScreen is GuiChest) && intave
Expand All @@ -38,12 +42,10 @@ object InventoryMove : Module("InventoryMove", MOVEMENT, gameDetecting = false)
private val undetectable by BooleanValue("Undetectable", false)

// If player violates nomove check and inventory is open, close inventory and reopen it when still
private val silentlyCloseAndReopen by BooleanValue("SilentlyCloseAndReopen", false)
{ noMove && (noMoveAir || noMoveGround) }
private val silentlyCloseAndReopen by BooleanValue("SilentlyCloseAndReopen", false) { noMove && (noMoveAir || noMoveGround) && mode == "Normal" }

// Reopen closed inventory just before a click (could flag for clicking too fast after opening inventory)
private val reopenOnClick by BooleanValue("ReopenOnClick", false)
{ silentlyCloseAndReopen && noMove && (noMoveAir || noMoveGround) }
private val reopenOnClick by BooleanValue("ReopenOnClick", false) { silentlyCloseAndReopen && noMove && (noMoveAir || noMoveGround) && mode == "Normal" }

private val affectedBindings = arrayOf(
mc.gameSettings.keyBindForward,
Expand All @@ -54,6 +56,8 @@ object InventoryMove : Module("InventoryMove", MOVEMENT, gameDetecting = false)
mc.gameSettings.keyBindSprint
)

private var clicking = false

@EventTarget(priority = 999)
fun onUpdate(event: UpdateEvent) {
val screen = mc.currentScreen
Expand Down Expand Up @@ -98,14 +102,35 @@ object InventoryMove : Module("InventoryMove", MOVEMENT, gameDetecting = false)

@EventTarget
fun onPacket(event: PacketEvent) {
if (silent) {
if (mode == "Packet") {
if (event.packet is C0EPacketClickWindow && event.packet.windowId == 0 && !clicking) {
clicking = true
event.cancelEvent()

sendPackets(
C16PacketClientStatus(OPEN_INVENTORY_ACHIEVEMENT),
event.packet,
C0DPacketCloseWindow(0)
)

clicking = false
}
}

if (mode == "Silent" || mode == "Packet") {
if (event.packet is C0DPacketCloseWindow && event.packet.windowId == 0
|| event.packet is C16PacketClientStatus && event.packet.status == OPEN_INVENTORY_ACHIEVEMENT
) event.cancelEvent()
|| event.packet is C16PacketClientStatus && event.packet.status == OPEN_INVENTORY_ACHIEVEMENT) {
if (mode != "Packet" || !clicking) {
event.cancelEvent()
}
}
}
}

override fun onDisable() {
mc.gameSettings.updateKeys(*affectedBindings)
}

override val tag
get() = mode
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ object InventoryManager: MinecraftInstance() {
// Shared values between AutoArmor and InventoryCleaner
@JvmStatic val invOpenValue = BooleanValue("InvOpen", false)
@JvmStatic val simulateInventoryValue = BooleanValue("SimulateInventory", true) { !invOpenValue.get() }
@JvmStatic val autoCloseValue = BooleanValue("AutoClose", false) { invOpenValue.get() }
@JvmStatic val autoCloseValue = BooleanValue("AutoClose", false) { invOpenValue.get() }

@JvmStatic val startDelayValue = IntValue("StartDelay", 0, 0..500) { invOpenValue.get() || simulateInventoryValue.get() }
@JvmStatic val closeDelayValue = IntValue("CloseDelay", 0, 0..500) { if (invOpenValue.get()) autoCloseValue.get() else simulateInventoryValue.get() }
@JvmStatic val startDelayValue = IntValue("StartDelay", 0, 0..500) { invOpenValue.get() || simulateInventoryValue.get() }
@JvmStatic val closeDelayValue = IntValue("CloseDelay", 0, 0..500) { if (invOpenValue.get()) autoCloseValue.get() else simulateInventoryValue.get() }

private lateinit var inventoryWorker: Job

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ object InventoryUtils : MinecraftInstance(), Listenable {
return if (parsed in 0..8) parsed else null
}

@EventTarget
@EventTarget(priority = Int.MIN_VALUE)
fun onPacket(event: PacketEvent) {

if (event.isCancelled) return
Expand Down

0 comments on commit 5c63da1

Please sign in to comment.