Skip to content

Commit ebe0bd4

Browse files
committed
Configuration delegation
1 parent 82396e2 commit ebe0bd4

38 files changed

+247
-276
lines changed

common/src/main/java/com/lambda/mixin/render/DebugHudMixin.java

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

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.task.TaskFlow;
20+
import com.lambda.task.RootTask;
2121
import com.lambda.util.DebugInfoHud;
2222
import net.minecraft.client.gui.hud.DebugHud;
2323
import org.spongepowered.asm.mixin.Mixin;
@@ -36,6 +36,6 @@ private void onGetRightText(CallbackInfoReturnable<List<String>> cir) {
3636

3737
@Inject(method = "getLeftText", at = @At("TAIL"))
3838
private void onGetLeftText(CallbackInfoReturnable<List<String>> cir) {
39-
cir.getReturnValue().addAll(List.of(TaskFlow.INSTANCE.toString().split("\n")));
39+
cir.getReturnValue().addAll(List.of(RootTask.INSTANCE.toString().split("\n")));
4040
}
4141
}

common/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import com.lambda.command.LambdaCommand
2828
import com.lambda.interaction.construction.StructureRegistry
2929
import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure
3030
import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint
31-
import com.lambda.task.TaskFlow.run
31+
import com.lambda.task.RootTask.run
3232
import com.lambda.task.tasks.BuildTask
3333
import com.lambda.task.tasks.BuildTask.Companion.build
3434
import com.lambda.threading.runSafe

common/src/main/kotlin/com/lambda/command/commands/TaskCommand.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.lambda.brigadier.argument.literal
2121
import com.lambda.brigadier.execute
2222
import com.lambda.brigadier.required
2323
import com.lambda.command.LambdaCommand
24-
import com.lambda.task.TaskFlow
24+
import com.lambda.task.RootTask
2525
import com.lambda.util.Communication.info
2626
import com.lambda.util.extension.CommandBuilder
2727

@@ -34,15 +34,15 @@ object TaskCommand : LambdaCommand(
3434
required(literal("cancel")) {
3535
execute {
3636
this@TaskCommand.info("Cancelling all tasks")
37-
TaskFlow.cancel()
37+
RootTask.cancel()
3838
}
3939
}
4040

4141
required(literal("clear")) {
4242
execute {
4343
this@TaskCommand.info("Clearing all tasks")
44-
TaskFlow.cancel()
45-
TaskFlow.clear()
44+
RootTask.cancel()
45+
RootTask.clear()
4646
}
4747
}
4848
}

common/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import com.lambda.interaction.material.container.ContainerManager
2828
import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial
2929
import com.lambda.interaction.material.container.ContainerManager.containerWithSpace
3030
import com.lambda.interaction.material.transfer.TransferResult
31-
import com.lambda.task.TaskFlow.run
31+
import com.lambda.task.RootTask.run
3232
import com.lambda.util.Communication.info
3333
import com.lambda.util.extension.CommandBuilder
3434

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,36 @@
1818
package com.lambda.config.groups
1919

2020
import com.lambda.config.Configurable
21-
import com.lambda.module.modules.client.TaskFlowModule.setting
2221
import com.lambda.util.BlockUtils.allSigns
2322

2423
class BuildSettings(
2524
c: Configurable,
2625
vis: () -> Boolean = { true }
2726
) : BuildConfig {
2827
enum class Page {
29-
GENERAL, BREAK, PLACE
28+
General, Break, Place
3029
}
3130

32-
private val page by c.setting("Build Page", Page.GENERAL, "Current page", vis)
31+
private val page by c.setting("Build Page", Page.General, "Current page", vis)
3332

3433
// General
35-
override val pathing by c.setting("Pathing", true, "Path to blocks") { vis() && page == Page.GENERAL }
36-
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks") { vis() && page == Page.GENERAL && pathing }
37-
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks") { vis() && page == Page.GENERAL }
34+
override val pathing by c.setting("Pathing", true, "Path to blocks") { vis() && page == Page.General }
35+
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks") { vis() && page == Page.General && pathing }
36+
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks") { vis() && page == Page.General }
3837

3938
// Breaking
40-
override val rotateForBreak by c.setting("Rotate For Break", true, "Rotate towards block while breaking") { vis() && page == Page.BREAK }
41-
override val breakConfirmation by c.setting("Break Confirmation", false, "Wait for block break confirmation") { vis() && page == Page.BREAK }
42-
override val maxPendingBreaks by c.setting("Max Pending Breaks", 1, 1..10, 1, "Maximum pending block breaks") { vis() && page == Page.BREAK }
43-
override val breaksPerTick by c.setting("Instant Breaks Per Tick", 5, 1..30, 1, "Maximum instant block breaks per tick") { vis() && page == Page.BREAK }
44-
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)") { vis() && page == Page.BREAK }
45-
override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { vis() && page == Page.BREAK }
46-
override val ignoredBlocks by setting("Ignored Blocks", allSigns, "Blocks that wont be broken") { vis() && page == Page.BREAK }
39+
override val rotateForBreak by c.setting("Rotate For Break", true, "Rotate towards block while breaking") { vis() && page == Page.Break }
40+
override val breakConfirmation by c.setting("Break Confirmation", false, "Wait for block break confirmation") { vis() && page == Page.Break }
41+
override val maxPendingBreaks by c.setting("Max Pending Breaks", 1, 1..10, 1, "Maximum pending block breaks") { vis() && page == Page.Break }
42+
override val breaksPerTick by c.setting("Instant Breaks Per Tick", 5, 1..30, 1, "Maximum instant block breaks per tick") { vis() && page == Page.Break }
43+
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)") { vis() && page == Page.Break }
44+
override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { vis() && page == Page.Break }
45+
override val ignoredBlocks by c.setting("Ignored Blocks", allSigns, "Blocks that wont be broken") { vis() && page == Page.Break }
4746

4847
// Placing
49-
override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing") { vis() && page == Page.PLACE }
50-
override val placeConfirmation by c.setting("Place Confirmation", true, "Wait for block placement confirmation") { vis() && page == Page.PLACE }
51-
override val placeTimeout by c.setting("Place Timeout", 10, 1..30, 1, "Timeout for block placement in ticks", unit = " ticks") { vis() && page == Page.PLACE && placeConfirmation }
52-
override val maxPendingPlacements by c.setting("Max Pending Places", 1, 1..10, 1, "Maximum pending block places") { vis() && page == Page.PLACE }
53-
override val placementsPerTick by c.setting("Instant Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick") { vis() && page == Page.PLACE }
48+
override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing") { vis() && page == Page.Place }
49+
override val placeConfirmation by c.setting("Place Confirmation", true, "Wait for block placement confirmation") { vis() && page == Page.Place }
50+
override val placeTimeout by c.setting("Place Timeout", 10, 1..30, 1, "Timeout for block placement in ticks", unit = " ticks") { vis() && page == Page.Place && placeConfirmation }
51+
override val maxPendingPlacements by c.setting("Max Pending Places", 1, 1..10, 1, "Maximum pending block places") { vis() && page == Page.Place }
52+
override val placementsPerTick by c.setting("Instant Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick") { vis() && page == Page.Place }
5453
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface InteractionConfig {
2828
/**
2929
* Maximum block interaction distance
3030
*/
31-
val placeReach: Double
31+
val interactReach: Double
3232

3333
/**
3434
* Maximum possible interaction distance

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class InteractionSettings(
3030
// Reach
3131
private val useDefaultReach by c.setting("Default Reach", true, "Whether to use vanilla interaction ranges", vis)
3232
private val attackReachSetting = if (usage.entity) c.setting("Attack Reach", DEFAULT_ATTACK_REACH, 1.0..10.0, 0.01, "Maximum entity interaction distance") { vis() && !useDefaultReach } else null
33-
private val placeReachSetting = if (usage.block) c.setting("Place Reach", DEFAULT_PLACE_REACH, 1.0..10.0, 0.01, "Maximum block interaction distance") { vis() && !useDefaultReach } else null
33+
private val interactReachSetting = if (usage.block) c.setting("Interact Reach", DEFAULT_INTERACT_REACH, 1.0..10.0, 0.01, "Maximum block interaction distance") { vis() && !useDefaultReach } else null
3434

3535
override val attackReach: Double get() {
3636
check(usage.entity) {
@@ -40,18 +40,18 @@ class InteractionSettings(
4040
return if (useDefaultReach) DEFAULT_ATTACK_REACH else attackReachSetting!!.value
4141
}
4242

43-
override val placeReach: Double get() {
43+
override val interactReach: Double get() {
4444
check(usage.block) {
4545
"Given interaction config has no place reach implementation"
4646
}
4747

48-
return if (useDefaultReach) DEFAULT_ATTACK_REACH else placeReachSetting!!.value
48+
return if (useDefaultReach) DEFAULT_INTERACT_REACH else interactReachSetting!!.value
4949
}
5050

5151
override val scanReach: Double get() = when (usage) {
5252
InteractionMask.ENTITY -> attackReach
53-
InteractionMask.BLOCK -> placeReach
54-
InteractionMask.BOTH -> max(attackReach, placeReach)
53+
InteractionMask.BLOCK -> interactReach
54+
InteractionMask.BOTH -> max(attackReach, interactReach)
5555
}
5656

5757
// Point scan
@@ -65,6 +65,6 @@ class InteractionSettings(
6565

6666
companion object {
6767
const val DEFAULT_ATTACK_REACH = 3.0
68-
const val DEFAULT_PLACE_REACH = 4.5
68+
const val DEFAULT_INTERACT_REACH = 4.5
6969
}
7070
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ interface InventoryConfig {
3232
val storePriority: Priority
3333

3434
enum class Priority {
35-
WITH_MIN_ITEMS,
36-
WITH_MAX_ITEMS;
35+
WithMinItems,
36+
WithMaxItems;
3737

3838
fun materialComparator(selection: StackSelection) =
3939
when (this) {
40-
WITH_MAX_ITEMS -> compareBy<MaterialContainer> { it.rank }
40+
WithMaxItems -> compareBy<MaterialContainer> { it.rank }
4141
.thenByDescending { it.materialAvailable(selection) }
4242
.thenBy { it.name }
4343

44-
WITH_MIN_ITEMS -> compareBy<MaterialContainer> { it.rank }
44+
WithMinItems -> compareBy<MaterialContainer> { it.rank }
4545
.thenBy { it.materialAvailable(selection) }
4646
.thenBy { it.name }
4747
}
4848

4949
fun spaceComparator(selection: StackSelection) =
5050
when (this) {
51-
WITH_MAX_ITEMS -> compareBy<MaterialContainer> { it.rank }
51+
WithMaxItems -> compareBy<MaterialContainer> { it.rank }
5252
.thenByDescending { it.spaceAvailable(selection) }
5353
.thenBy { it.name }
5454

55-
WITH_MIN_ITEMS -> compareBy<MaterialContainer> { it.rank }
55+
WithMinItems -> compareBy<MaterialContainer> { it.rank }
5656
.thenBy { it.spaceAvailable(selection) }
5757
.thenBy { it.name }
5858
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ class InventorySettings(
2828
override val accessEnderChest by c.setting("Access Ender Chest", false, "Allow access to the player's ender chest", vis)
2929
override val actionTimout by c.setting("Action Timeout", 10, 0..100, 1, "How long to wait for after each inventory action", " ticks", vis)
3030
override val swapWithDisposables by c.setting("Swap With Disposables", true, "Swap items with disposable ones", vis)
31-
override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WITH_MIN_ITEMS, "What container to prefer when retrieving the item from", vis)
32-
override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WITH_MIN_ITEMS, "What container to prefer when storing the item to", vis)
31+
override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from", vis)
32+
override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to", vis)
3333
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ package com.lambda.config.groups
1919

2020
import com.lambda.config.Configurable
2121
import com.lambda.interaction.request.Priority
22-
import com.lambda.interaction.request.rotation.Rotation
2322
import com.lambda.interaction.request.rotation.RotationConfig
2423
import com.lambda.interaction.request.rotation.RotationMode
25-
import com.lambda.interaction.request.rotation.RotationRequest
2624
import kotlin.math.*
2725
import kotlin.random.Random
2826

@@ -31,7 +29,7 @@ class RotationSettings(
3129
priority: Priority = 0,
3230
vis: () -> Boolean = { true }
3331
) : RotationConfig(priority) {
34-
override var rotationMode by c.setting("Mode", RotationMode.SYNC, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera, NONE - No rotation", vis)
32+
override var rotationMode by c.setting("Mode", RotationMode.Sync, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera, NONE - No rotation", vis)
3533

3634
/** How many ticks to keep the rotation before resetting */
3735
override val keepTicks by c.setting("Keep Rotation", 3, 0..10, 1, "Ticks to keep rotation", " ticks") { rotate && vis() }

0 commit comments

Comments
 (0)