feat(FastBreak): only tool option (#5899)

This commit is contained in:
lucas
2025-03-27 17:18:52 +02:00
committed by GitHub
parent 8c8cfc574c
commit 0cfea2c220

View File

@@ -26,6 +26,7 @@ import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.tickHandler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.minecraft.item.MiningToolItem
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
/**
@@ -36,10 +37,15 @@ import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
object ModuleFastBreak : ClientModule("FastBreak", Category.WORLD) {
private val breakDamage by float("BreakDamage", 0.8f, 0.1f..1f)
private val onlyTool by boolean("OnlyTool", false)
private val modeChoice = choices("Mode", 0) { arrayOf(NoneChoice(it), AbortAnother) }.apply(::tagBy)
val repeatable = tickHandler {
if (onlyTool && player.mainHandStack.item !is MiningToolItem) {
return@tickHandler
}
interaction.blockBreakingCooldown = 0
if (interaction.currentBreakingProgress > breakDamage) {
@@ -58,15 +64,24 @@ object ModuleFastBreak : ClientModule("FastBreak", Category.WORLD) {
override val parent: ChoiceConfigurable<Choice>
get() = modeChoice
val packetHandler = handler<PacketEvent> {
if (onlyTool && player.mainHandStack.item !is MiningToolItem) {
return@handler
}
val packet = it.packet
if (packet is PlayerActionC2SPacket && packet.action == PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK) {
val blockPos = packet.pos ?: return@handler
// Abort block break on the block above (which we are not breaking)
network.sendPacket(PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK,
blockPos.up(), packet.direction))
network.sendPacket(
PlayerActionC2SPacket(
PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK,
blockPos.up(), packet.direction
)
)
}
}