Skip to content

Commit c39f2c2

Browse files
committed
slightly improved the hotbar swapping in the break manager
1 parent b4ccee8 commit c39f2c2

File tree

1 file changed

+5
-8
lines changed
  • common/src/main/kotlin/com/lambda/interaction/request/breaking

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ object BreakManager : RequestHandler<BreakRequest>() {
8787
return@listen
8888
}
8989

90-
var swapped = false
91-
9290
//ToDo: improve instamine / non instamine integration
9391
if (updateRequest { true }) {
9492
currentRequest?.let request@ { request ->
@@ -109,10 +107,8 @@ object BreakManager : RequestHandler<BreakRequest>() {
109107
if (breakType == BreakType.Null) return@request
110108
if (requestCtx.instantBreak && instaBreaks < request.buildConfig.breakSettings.breaksPerTick) {
111109
breakingInfos.getOrNull(breakType.index)?.let { info ->
112-
if (!swapped) {
113-
request.hotbarConfig.request(HotbarRequest(info.context.hotbarIndex))
114-
swapped = true
115-
}
110+
if (request.hotbarConfig.request(HotbarRequest(info.context.hotbarIndex)).done.not())
111+
return@forEach
116112
if (updateBlockBreakingProgress(info, player.mainHandStack)) {
117113
instaBreaks++
118114
activeThisTick = true
@@ -127,8 +123,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
127123
.filterNotNull()
128124
.firstOrNull()?.let { info ->
129125
activeThisTick = true
130-
if ((!swapped && !info.hotbarConfig.request(HotbarRequest(info.context.hotbarIndex)).done)
131-
|| (info.breakConfig.rotateForBreak && !info.context.rotation.done)) {
126+
if (info.breakConfig.rotateForBreak && !info.context.rotation.done) {
132127
postEvent()
133128
return@listen
134129
}
@@ -138,6 +133,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
138133
.filterNotNull()
139134
.reversed()
140135
.forEach { info ->
136+
if (info.hotbarConfig.request(HotbarRequest(info.context.hotbarIndex)).done.not()) return@forEach
141137
updateBlockBreakingProgress(info, player.mainHandStack)
142138
}
143139

@@ -152,6 +148,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
152148
}
153149
}
154150

151+
//ToDo: Clean this up
155152
listen<WorldEvent.BlockUpdate.Server> { event ->
156153
pendingInteractions
157154
.firstOrNull { it.context.expectedPos == event.pos }

0 commit comments

Comments
 (0)