mirror of
https://github.com/CCBlueX/LiquidBounce.git
synced 2025-09-06 09:46:38 +00:00
feat(FastBreak): only tool option (#5899)
This commit is contained in:
@@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user