Skip to content

Commit 800cd68

Browse files
committed
reBreakMode in packetmine rather than break config
1 parent ae3ae44 commit 800cd68

File tree

5 files changed

+11
-43
lines changed

5 files changed

+11
-43
lines changed

common/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BreakSettings(
2929
vis: () -> Boolean = { true }
3030
) : BreakConfig(priority) {
3131
override val breakMode by c.setting("Break Mode", BreakMode.Packet) { vis() }
32-
override val reBreak = ReBreakSettings(c, vis)
32+
override val reBreak by c.setting("ReBreak", true, "Re-breaks blocks after they've been broken once", vis)
3333
override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { vis() }
3434
override val breakThreshold by c.setting("Break Threshold", 0.7f, 0.1f..1.0f, 0.02f, "The break amount at which the block is considered broken") { vis() }
3535
override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") { vis() }

common/src/main/kotlin/com/lambda/config/groups/ReBreakSettings.kt

Lines changed: 0 additions & 36 deletions
This file was deleted.

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.lambda.interaction.request.breaking
1919

2020
import com.lambda.config.groups.BuildConfig
21-
import com.lambda.config.groups.ReBreakSettings
2221
import com.lambda.event.Event
2322
import com.lambda.interaction.request.Priority
2423
import com.lambda.interaction.request.RequestConfig
@@ -28,7 +27,7 @@ abstract class BreakConfig(
2827
priority: Priority = 0
2928
) : RequestConfig<BreakRequest>(priority) {
3029
abstract val breakMode: BreakMode
31-
abstract val reBreak: ReBreakSettings
30+
abstract val reBreak: Boolean
3231
abstract val unsafeCancels: Boolean
3332
abstract val breakThreshold: Float
3433
abstract val doubleBreak: Boolean

common/src/main/kotlin/com/lambda/interaction/request/breaking/ReBreakManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object ReBreakManager {
6363
runSafe {
6464
val info = reBreak ?: return@runSafe ReBreakResult.Ignored
6565

66-
if (info.context.expectedPos != ctx.expectedPos || !info.breakConfig.reBreak.mode.isEnabled()) {
66+
if (info.context.expectedPos != ctx.expectedPos || !info.breakConfig.reBreak) {
6767
return@runSafe ReBreakResult.Ignored
6868
}
6969
if (info.updatedThisTick) return@runSafe ReBreakResult.ReBroke

common/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.lambda.config.groups.BuildSettings
2121
import com.lambda.config.groups.HotbarSettings
2222
import com.lambda.config.groups.InteractionSettings
2323
import com.lambda.config.groups.InventorySettings
24-
import com.lambda.config.groups.ReBreakSettings
2524
import com.lambda.config.groups.RotationSettings
2625
import com.lambda.context.SafeContext
2726
import com.lambda.event.events.PlayerEvent
@@ -53,6 +52,7 @@ object PacketMine : Module(
5352
private val interact = InteractionSettings(this, InteractionMask.Block) { page == Page.Interaction }
5453
private val inventory = InventorySettings(this) { page == Page.Inventory }
5554
private val hotbar = HotbarSettings(this) { page == Page.Hotbar }
55+
private val reBreakMode by setting("ReBreak Mode", ReBreakMode.Manual, "The method used to re-break blocks after they've been broken once") { breakConfig.reBreak }
5656

5757
private val pendingInteractionsList = ConcurrentLinkedQueue<BuildContext>()
5858

@@ -71,8 +71,7 @@ object PacketMine : Module(
7171

7272
//ToDo: run on every tick stage
7373
listen<TickEvent.Pre> {
74-
val reBreakMode = breakConfig.reBreak.mode
75-
if (reBreakMode != ReBreakSettings.Mode.Auto && reBreakMode != ReBreakSettings.Mode.AutoConstant) return@listen
74+
if (breakConfig.reBreak && reBreakMode != ReBreakMode.Auto && reBreakMode != ReBreakMode.AutoConstant) return@listen
7675
val reBreak = reBreakPos ?: return@listen
7776
requestBreakManager(reBreak)
7877
}
@@ -152,4 +151,10 @@ object PacketMine : Module(
152151
enum class Page {
153152
Build, Rotation, Interaction, Inventory, Hotbar
154153
}
154+
155+
enum class ReBreakMode {
156+
Manual,
157+
Auto,
158+
AutoConstant;
159+
}
155160
}

0 commit comments

Comments
 (0)