Skip to content

Commit 178f399

Browse files
committed
Working double break and fast break. Still buggy break delay with no bypass implemented currently. also silent swap scaffold default config
1 parent be5b42f commit 178f399

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/main/kotlin/com/lambda/config/blocks/BreakConfig.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.config.blocks
1919

20+
import com.lambda.config.blocks.BuildConfig.SwingType
2021
import com.lambda.util.Describable
2122
import com.lambda.util.NamedEnum
2223
import net.minecraft.block.Block
@@ -40,7 +41,7 @@ interface BreakConfig : ActionConfig {
4041
val swapMode: SwapMode
4142

4243
val swing: SwingMode
43-
val swingType: BuildConfig.SwingType
44+
val swingType: SwingType
4445

4546
val rotate: Boolean
4647

@@ -85,7 +86,8 @@ interface BreakConfig : ActionConfig {
8586
override val description: String
8687
) : NamedEnum, Describable {
8788
Vanilla("Vanilla", "Uses vanilla breaking"),
88-
Packet("Packet", "Breaks blocks using only using packets")
89+
Grim("Grim", "Uses a grim bypass"),
90+
OldGrim("Old Grim", "Uses an old grim bypass")
8991
}
9092

9193
enum class SwapMode(

src/main/kotlin/com/lambda/config/blocks/BreakSettings.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ import com.lambda.config.Config
2121
import com.lambda.config.ConfigBlock
2222
import com.lambda.config.ConfigEditor.hide
2323
import com.lambda.config.Group
24+
import com.lambda.config.blocks.ActionConfig.SortMode
2425
import com.lambda.config.blocks.BreakConfig.AnimationMode
2526
import com.lambda.config.blocks.BreakConfig.BreakConfirmationMode
2627
import com.lambda.config.blocks.BreakConfig.BreakMode
28+
import com.lambda.config.blocks.BreakConfig.SwapMode
2729
import com.lambda.config.blocks.BreakConfig.SwingMode
2830
import com.lambda.config.blocks.BreakConfig.WhitelistMode
31+
import com.lambda.config.blocks.BuildConfig.SwingType
2932
import com.lambda.config.withEdits
3033
import com.lambda.event.events.TickEvent
3134
import com.lambda.event.events.TickEvent.Companion.ALL_STAGES
@@ -38,8 +41,8 @@ class BreakSettings(override val c: Config) : BreakConfig, ConfigBlock {
3841
}
3942

4043
// General
41-
override val breakMode by c.setting("Break Mode", BreakMode.Packet)
42-
override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed")
44+
override val breakMode by c.setting("Break Mode", BreakMode.OldGrim)
45+
override val sorter by c.setting("Break Sorter", SortMode.Tool, "The order in which breaks are performed")
4346
override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once")
4447
// Double break
4548
override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once")
@@ -52,9 +55,9 @@ class BreakSettings(override val c: Config) : BreakConfig, ConfigBlock {
5255
override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)")
5356
// Timing
5457
override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true)
55-
override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block")
58+
override val swapMode by c.setting("Break Swap Mode", SwapMode.End, "Decides when to swap to the best suited tool when breaking a block")
5659
override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand")
57-
override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None }
60+
override val swingType by c.setting("Break Swing Type", SwingType.Vanilla, "The style of swing") { swing != SwingMode.None }
5861
// Rotate
5962
override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking")
6063
// Pending / Post

src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import net.minecraft.entity.ItemEntity
3434
import net.minecraft.item.ItemStack
3535
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
3636
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action
37+
import net.minecraft.util.math.BlockPos
3738

3839
/**
3940
* A data class that holds all the information required to process and continue a break.
@@ -139,21 +140,21 @@ data class BreakInfo(
139140
}
140141

141142
context(_: SafeContext)
142-
fun startBreakPacket() = breakPacket(Action.START_DESTROY_BLOCK)
143+
fun startBreakPacket(yAddition: Int = 0) = breakPacket(Action.START_DESTROY_BLOCK, yAddition)
143144

144145
context(_: SafeContext)
145-
fun stopBreakPacket() = breakPacket(Action.STOP_DESTROY_BLOCK)
146+
fun stopBreakPacket(yAddition: Int = 0) = breakPacket(Action.STOP_DESTROY_BLOCK, yAddition)
146147

147148
context(_: SafeContext)
148-
fun abortBreakPacket() = breakPacket(Action.ABORT_DESTROY_BLOCK)
149+
fun abortBreakPacket(yAddition: Int = 0) = breakPacket(Action.ABORT_DESTROY_BLOCK, yAddition)
149150

150151
context(safeContext: SafeContext)
151-
private fun breakPacket(action: Action) =
152+
private fun breakPacket(action: Action, yAddition: Int) =
152153
with(safeContext) {
153154
interaction.sendSequencedPacket(world) { sequence: Int ->
154155
PlayerActionC2SPacket(
155156
action,
156-
context.blockPos,
157+
with(context.blockPos) { BlockPos(x, y + yAddition, z) },
157158
context.hitResult.side,
158159
sequence
159160
)

src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ object BreakManager : Manager<BreakRequest>(
166166
field = value
167167
}
168168

169+
const val OLD_GRIM_Y_OFFSET = 2000
170+
169171
override fun load(): String {
170172
super.load()
171173

@@ -818,8 +820,9 @@ object BreakManager : Manager<BreakRequest>(
818820
val instantBreakable = progress >= info.getBreakThreshold()
819821

820822
var packetCount = 1
821-
if (breakConfig.breakMode == BreakMode.Packet) packetCount++
822823
info.vanillaInstantBreakable = progress >= 1
824+
val oldGrim = breakConfig.breakMode == BreakMode.OldGrim && !info.vanillaInstantBreakable
825+
if (breakConfig.breakMode == BreakMode.Grim || oldGrim) packetCount++
823826
val requiresSecondStop = info.type == Secondary || (instantBreakable && !info.vanillaInstantBreakable)
824827
if (requiresSecondStop) packetCount++
825828

@@ -846,8 +849,9 @@ object BreakManager : Manager<BreakRequest>(
846849
}
847850
}
848851

849-
if (breakConfig.breakMode == BreakMode.Packet) info.stopBreakPacket()
852+
if (breakConfig.breakMode == BreakMode.Grim) info.stopBreakPacket()
850853
info.startBreakPacket()
854+
if (oldGrim) info.startBreakPacket(OLD_GRIM_Y_OFFSET)
851855
if (requiresSecondStop) info.stopBreakPacket()
852856

853857
PacketLimitHandler.sentPackets(packetCount, PacketType.PlayerAction)

src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.module.modules.world
1919

20+
import com.lambda.config.ConfigEditor.editSetting
2021
import com.lambda.config.ConfigEditor.editTypedSettings
2122
import com.lambda.config.ConfigEditor.hide
2223
import com.lambda.config.ConfigEditor.hideAllExcept
@@ -68,6 +69,7 @@ object Scaffold : Module(
6869
}
6970
hide(::breakBlocks)
7071
}
72+
hotbarConfig::keepTicks.editSetting { defaultValue(0) }
7173
hideAllExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig)
7274
}
7375

0 commit comments

Comments
 (0)