Skip to content

Commit 9eb8160

Browse files
committed
more small refactors
1 parent fec6d83 commit 9eb8160

File tree

1 file changed

+96
-91
lines changed
  • common/src/main/kotlin/com/lambda/module/modules/player

1 file changed

+96
-91
lines changed

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

Lines changed: 96 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -107,83 +107,6 @@ object PacketMine : Module(
107107
private val queueOutlineWidth by setting("Outline Width", 1f, 0f..3f, 0.1f, "The thickness of the outline used on queue blocks", visibility = { page == Page.QueueRender && renderQueueMode.isEnabled() && renderSetting != RenderSetting.Fill } )
108108

109109

110-
private enum class Page {
111-
General, ReBreak, Queue, BlockRender, QueueRender
112-
}
113-
114-
@Suppress("UNUSED")
115-
private enum class BreakMode {
116-
Total, Additive;
117-
}
118-
119-
private enum class PacketMode {
120-
Vanilla, Grim, NCP
121-
}
122-
123-
@Suppress("UNUSED")
124-
private enum class SwapMethod {
125-
None, StandardSilent, NCPSilent, Vanilla;
126-
127-
fun isEnabled() =
128-
this != None
129-
130-
fun isSilent() =
131-
this == StandardSilent || this == NCPSilent
132-
}
133-
134-
private enum class SwapMode {
135-
StartAndEnd, Start, End, Constant;
136-
}
137-
138-
private enum class ReBreakMode {
139-
None, Standard, Automatic, FastAutomatic;
140-
141-
fun isEnabled() =
142-
this != None
143-
}
144-
145-
private enum class ModeOptions {
146-
None, StartAndEnd, Start, End, Constant;
147-
148-
fun isEnabled() =
149-
this != None
150-
}
151-
152-
private enum class ProgressStage {
153-
StartPre, StartPost, PreTick, During, EndPre, EndPost, PacketReceiveBreak, TimedOut
154-
}
155-
156-
private enum class RenderMode {
157-
None, Out, In, InOut, OutIn, Static;
158-
159-
fun isEnabled() =
160-
this != None
161-
}
162-
163-
@Suppress("UNUSED")
164-
private enum class RenderQueueMode {
165-
None, Cube, Shape;
166-
167-
fun isEnabled() =
168-
this != None
169-
}
170-
171-
private enum class RenderSetting {
172-
Both, Fill, Outline
173-
}
174-
175-
private enum class ColourMode {
176-
Static, Dynamic
177-
}
178-
179-
private enum class BreakState {
180-
Breaking, ReBreaking, AwaitingResponse
181-
}
182-
183-
private enum class BreakType {
184-
Primary, Double;
185-
}
186-
187110
val renderer = DynamicESP
188111
private var currentMiningBlock = Array<BreakingContext?>(2) { null }
189112
private var lastNonEmptyState: BlockState? = null
@@ -225,18 +148,7 @@ object PacketMine : Module(
225148
swingingNextAttack = true
226149
}
227150

228-
if (queueBlocks) {
229-
if (shouldBePlacedInBlockQueue(it.pos)) {
230-
if (reverseQueueOrder) {
231-
blockQueue.addFirst(it.pos)
232-
} else {
233-
blockQueue.add(it.pos)
234-
}
235-
return@listener
236-
}
237-
238-
if (blockQueue.contains(it.pos)) return@listener
239-
}
151+
if (checkAddBlockQueuePos(it.pos)) return@listener
240152

241153
currentMiningBlock.forEach { ctx ->
242154
ctx?.apply {
@@ -259,8 +171,7 @@ object PacketMine : Module(
259171
}
260172

261173
currentMiningBlock[0]?.apply {
262-
263-
currentMiningBlock[1]?.run { return@apply }
174+
if (currentMiningBlock[1] != null) return@apply
264175

265176
if (doubleBreak && breakState != BreakState.ReBreaking) {
266177
switchCurrentMiningBlockToDouble()
@@ -1028,6 +939,23 @@ object PacketMine : Module(
1028939
}
1029940
}
1030941

942+
private fun checkAddBlockQueuePos(pos: BlockPos): Boolean {
943+
if (queueBlocks) {
944+
if (shouldBePlacedInBlockQueue(pos)) {
945+
if (reverseQueueOrder) {
946+
blockQueue.addFirst(pos)
947+
} else {
948+
blockQueue.add(pos)
949+
}
950+
return true
951+
}
952+
953+
if (blockQueue.contains(pos)) return true
954+
}
955+
956+
return false
957+
}
958+
1031959
private fun shouldBePlacedInBlockQueue(pos: BlockPos): Boolean =
1032960
(((currentMiningBlock[0] != null && !doubleBreak) || currentMiningBlock[1] != null) || !blockQueue.isEmpty())
1033961
&& (currentMiningBlock[0]?.breakState != BreakState.ReBreaking || !blockQueue.isEmpty())
@@ -1367,4 +1295,81 @@ object PacketMine : Module(
13671295

13681296
return f
13691297
}
1298+
1299+
private enum class Page {
1300+
General, ReBreak, Queue, BlockRender, QueueRender
1301+
}
1302+
1303+
@Suppress("UNUSED")
1304+
private enum class BreakMode {
1305+
Total, Additive;
1306+
}
1307+
1308+
private enum class PacketMode {
1309+
Vanilla, Grim, NCP
1310+
}
1311+
1312+
@Suppress("UNUSED")
1313+
private enum class SwapMethod {
1314+
None, StandardSilent, NCPSilent, Vanilla;
1315+
1316+
fun isEnabled() =
1317+
this != None
1318+
1319+
fun isSilent() =
1320+
this == StandardSilent || this == NCPSilent
1321+
}
1322+
1323+
private enum class SwapMode {
1324+
StartAndEnd, Start, End, Constant;
1325+
}
1326+
1327+
private enum class ReBreakMode {
1328+
None, Standard, Automatic, FastAutomatic;
1329+
1330+
fun isEnabled() =
1331+
this != None
1332+
}
1333+
1334+
private enum class ModeOptions {
1335+
None, StartAndEnd, Start, End, Constant;
1336+
1337+
fun isEnabled() =
1338+
this != None
1339+
}
1340+
1341+
private enum class ProgressStage {
1342+
StartPre, StartPost, PreTick, During, EndPre, EndPost, PacketReceiveBreak, TimedOut
1343+
}
1344+
1345+
private enum class RenderMode {
1346+
None, Out, In, InOut, OutIn, Static;
1347+
1348+
fun isEnabled() =
1349+
this != None
1350+
}
1351+
1352+
@Suppress("UNUSED")
1353+
private enum class RenderQueueMode {
1354+
None, Cube, Shape;
1355+
1356+
fun isEnabled() =
1357+
this != None
1358+
}
1359+
1360+
private enum class RenderSetting {
1361+
Both, Fill, Outline
1362+
}
1363+
1364+
private enum class ColourMode {
1365+
Static, Dynamic
1366+
}
1367+
1368+
private enum class BreakState {
1369+
Breaking, ReBreaking, AwaitingResponse
1370+
}
1371+
1372+
private enum class BreakType {
1373+
Primary, Double;
1374+
}
13701375
}

0 commit comments

Comments
 (0)