Skip to content

Commit 48e71b9

Browse files
committed
Cleanup
1 parent 076a785 commit 48e71b9

File tree

15 files changed

+64
-92
lines changed

15 files changed

+64
-92
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class InteractionSettings(
4949
}
5050

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

5757
// Point scan

common/src/main/kotlin/com/lambda/interaction/material/transfer/SlotTransfer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class SlotTransfer @Ta5kBuilder constructor(
7272
val nextTo = selectedTo.firstOrNull() ?: return@listen
7373

7474
transfer {
75-
moveSlot(nextFrom.id, nextTo.id)
76-
// swap(nextFrom.id, 0)
77-
// swap(nextTo.id, 0)
75+
// moveSlot(nextFrom.id, nextTo.id)
76+
swap(nextTo.id, 0)
77+
swap(nextFrom.id, 0)
7878
}.finally { change ->
7979
changes merge change
8080
}.execute(this@SlotTransfer)

common/src/main/kotlin/com/lambda/interaction/request/rotation/Rotation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ data class Rotation(val yaw: Double, val pitch: Double) {
6262
reach: Double,
6363
eye: Vec3d? = null,
6464
fluids: Boolean = false,
65-
mask: InteractionMask = InteractionMask.BOTH,
65+
mask: InteractionMask = InteractionMask.Both,
6666
) = runSafe {
6767
rayCast(eye ?: player.eyePos, vector, reach, mask, fluids)
6868
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/visibilty/RotationTargets.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fun lookAtEntity(
103103
player.eyePos,
104104
ALL_SIDES,
105105
SurfaceScan.DEFAULT,
106-
InteractionMask.ENTITY,
106+
InteractionMask.Entity,
107107
config
108108
) { requestedHit.verifyHit(hit) }?.targetRotation
109109
}
@@ -133,7 +133,7 @@ fun lookAtBlock(
133133
player.eyePos,
134134
sides,
135135
surfaceScan,
136-
InteractionMask.BLOCK,
136+
InteractionMask.Block,
137137
config
138138
) { requestedHit.verifyHit(hit) }?.targetRotation
139139
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/visibilty/VisibilityChecker.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
package com.lambda.interaction.request.rotation.visibilty
1919

2020
import com.lambda.config.groups.InteractionConfig
21-
import com.lambda.config.groups.InteractionSettings
2221
import com.lambda.context.SafeContext
23-
import com.lambda.interaction.construction.processing.PreprocessingStep
2422
import com.lambda.interaction.construction.verify.ScanMode
2523
import com.lambda.interaction.construction.verify.SurfaceScan
2624
import com.lambda.interaction.request.rotation.*
@@ -29,7 +27,6 @@ import com.lambda.util.extension.component6
2927
import com.lambda.util.math.distSq
3028
import com.lambda.util.world.raycast.InteractionMask
3129
import net.minecraft.entity.LivingEntity
32-
import net.minecraft.util.hit.EntityHitResult
3330
import net.minecraft.util.hit.HitResult
3431
import net.minecraft.util.math.Box
3532
import net.minecraft.util.math.Direction
@@ -111,7 +108,7 @@ object VisibilityChecker {
111108

112109
val newRotation = eye.rotationTo(vec)
113110

114-
val mask = if (interaction.strictRayCast) InteractionMask.BOTH else targetType
111+
val mask = if (interaction.strictRayCast) InteractionMask.Both else targetType
115112
val hit = newRotation.rayCast(reach, eye, mask = mask) ?: return@scanSurfaces
116113

117114
val checked = CheckedHit(hit, newRotation, reach)
@@ -143,7 +140,7 @@ object VisibilityChecker {
143140

144141
val newRotation = eye.rotationTo(vec)
145142

146-
val mask = if (interaction.strictRayCast || entity == null) InteractionMask.BOTH else targetType
143+
val mask = if (interaction.strictRayCast || entity == null) InteractionMask.Both else targetType
147144
val hit = newRotation.rayCast(reach, eye, mask = mask) ?: return@scanSurfaces
148145

149146
val checked = CheckedHit(hit, newRotation, reach)

common/src/main/kotlin/com/lambda/module/modules/client/TaskFlowModule.kt

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

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

20-
import com.lambda.config.groups.BuildSettings
21-
import com.lambda.config.groups.InteractionSettings
22-
import com.lambda.config.groups.InventorySettings
23-
import com.lambda.config.groups.RotationSettings
24-
import com.lambda.core.PingManager
20+
import com.lambda.config.groups.*
2521
import com.lambda.event.events.RenderEvent
2622
import com.lambda.event.listener.SafeListener.Companion.listen
2723
import com.lambda.interaction.construction.result.Drawable
@@ -35,16 +31,16 @@ object TaskFlowModule : Module(
3531
defaultTags = setOf(ModuleTag.CLIENT, ModuleTag.AUTOMATION)
3632
) {
3733
enum class Page {
38-
BUILD, ROTATION, INTERACTION, INVENTORY, DEBUG
34+
Build, Rotation, Interaction, Inventory, Debug
3935
}
4036

41-
private val page by setting("Page", Page.BUILD)
42-
val build = BuildSettings(this) { page == Page.BUILD }
43-
val rotation = RotationSettings(this) { page == Page.ROTATION }
44-
val interact = InteractionSettings(this, InteractionMask.BOTH) { page == Page.INTERACTION }
45-
val inventory = InventorySettings(this) { page == Page.INVENTORY }
37+
private val page by setting("Page", Page.Build)
38+
val build = BuildSettings(this) { page == Page.Build }
39+
val rotation = RotationSettings(this) { page == Page.Rotation }
40+
val interact = InteractionSettings(this, InteractionMask.Both) { page == Page.Interaction }
41+
val inventory = InventorySettings(this) { page == Page.Inventory }
4642

47-
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") { page == Page.DEBUG }
43+
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") { page == Page.Debug }
4844

4945
@Volatile
5046
var drawables = listOf<Drawable>()
@@ -56,6 +52,4 @@ object TaskFlowModule : Module(
5652
}
5753
}
5854
}
59-
60-
6155
}

common/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object KillAura : Module(
5151
private val page by setting("Page", Page.Interact)
5252

5353
// Interact
54-
private val interactionSettings = InteractionSettings(this, InteractionMask.ENTITY) { page == Page.Interact }
54+
private val interactionSettings = InteractionSettings(this, InteractionMask.Entity) { page == Page.Interact }
5555
private val attackMode by setting("Attack Mode", AttackMode.Cooldown) { page == Page.Interact }
5656
private val delaySync by setting("Client-side Delay", true) { page == Page.Interact && attackMode == AttackMode.Cooldown }
5757
private val cooldownSync by setting("Client-side Cooldown", true) { page == Page.Interact && attackMode == AttackMode.Cooldown }

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

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

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

20-
import com.lambda.config.groups.BuildSettings
21-
import com.lambda.config.groups.InteractionSettings
22-
import com.lambda.config.groups.InventorySettings
23-
import com.lambda.config.groups.RotationSettings
20+
import com.lambda.config.groups.*
2421
import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure
2522
import com.lambda.interaction.construction.blueprint.PropagatingBlueprint.Companion.propagatingBlueprint
2623
import com.lambda.interaction.construction.verify.TargetState
@@ -53,22 +50,22 @@ object HighwayTools : Module(
5350

5451
private val height by setting("Height", 4, 2..10, 1) { page == Page.Structure }
5552
private val width by setting("Width", 6, 1..30, 1) { page == Page.Structure }
56-
private val pavement by setting("Pavement", Material.Block, description = "Material for the pavement") { page == Page.Structure }
53+
private val pavement by setting("Pavement", Material.Block, "Material for the pavement") { page == Page.Structure }
5754
private val rimHeight by setting("Pavement Rim Height", 1, 0..6, 1) { page == Page.Structure && pavement != Material.None }
58-
private val cornerBlock by setting("Corner", Corner.None, description = "Include corner blocks in the highway") { page == Page.Structure && pavement != Material.None }
59-
private val pavementMaterial by setting("Pavement Material", Blocks.OBSIDIAN, description = "Material to build the highway with") { page == Page.Structure && pavement == Material.Block }
60-
private val floor by setting("Floor", Material.None, description = "Material for the floor") { page == Page.Structure }
61-
private val floorMaterial by setting("Floor Material", Blocks.NETHERRACK, description = "Material to build the floor with") { page == Page.Structure && floor == Material.Block }
62-
private val walls by setting("Walls", Material.None, description = "Material for the walls") { page == Page.Structure }
63-
private val wallMaterial by setting("Wall Material", Blocks.NETHERRACK, description = "Material to build the walls with") { page == Page.Structure && walls == Material.Block }
64-
private val ceiling by setting("Ceiling", Material.None, description = "Material for the ceiling") { page == Page.Structure }
65-
private val ceilingMaterial by setting("Ceiling Material", Blocks.OBSIDIAN, description = "Material to build the ceiling with") { page == Page.Structure && ceiling == Material.Block }
66-
private val distance by setting("Distance", -1, -1..1000000, 1, description = "Distance to build the highway/tunnel (negative for infinite)") { page == Page.Structure }
67-
private val sliceSize by setting("Slice Size", 3, 1..5, 1, description = "Number of slices to build at once") { page == Page.Structure }
55+
private val cornerBlock by setting("Corner", Corner.None, "Include corner blocks in the highway") { page == Page.Structure && pavement != Material.None }
56+
private val pavementMaterial by setting("Pavement Material", Blocks.OBSIDIAN, "Material to build the highway with") { page == Page.Structure && pavement == Material.Block }
57+
private val floor by setting("Floor", Material.None, "Material for the floor") { page == Page.Structure }
58+
private val floorMaterial by setting("Floor Material", Blocks.NETHERRACK, "Material to build the floor with") { page == Page.Structure && floor == Material.Block }
59+
private val walls by setting("Walls", Material.None, "Material for the walls") { page == Page.Structure }
60+
private val wallMaterial by setting("Wall Material", Blocks.NETHERRACK, "Material to build the walls with") { page == Page.Structure && walls == Material.Block }
61+
private val ceiling by setting("Ceiling", Material.None, "Material for the ceiling") { page == Page.Structure }
62+
private val ceilingMaterial by setting("Ceiling Material", Blocks.OBSIDIAN, "Material to build the ceiling with") { page == Page.Structure && ceiling == Material.Block }
63+
private val distance by setting("Distance", -1, -1..1000000, 1, "Distance to build the highway/tunnel (negative for infinite)") { page == Page.Structure }
64+
private val sliceSize by setting("Slice Size", 3, 1..5, 1, "Number of slices to build at once") { page == Page.Structure }
6865

6966
private val build = BuildSettings(this) { page == Page.Build }
7067
private val rotation = RotationSettings(this) { page == Page.Rotation }
71-
private val interact = InteractionSettings(this, InteractionMask.BLOCK) { page == Page.Interaction }
68+
private val interact = InteractionSettings(this, InteractionMask.Block) { page == Page.Interaction }
7269
private val inventory = InventorySettings(this) { page == Page.Inventory }
7370

7471
private var octant = EightWayDirection.NORTH
@@ -78,11 +75,11 @@ object HighwayTools : Module(
7875
private var runningTask: Task<*>? = null
7976

8077
enum class Material {
81-
None, Solid, Block,
78+
None, Solid, Block
8279
}
8380

8481
enum class Corner {
85-
None, Solid,
82+
None, Solid
8683
}
8784

8885
enum class Page {

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

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

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

20-
import com.lambda.context.SafeContext
20+
import com.lambda.config.groups.InventorySettings
2121
import com.lambda.event.events.InventoryEvent
2222
import com.lambda.event.events.PlayerEvent
2323
import com.lambda.event.listener.SafeListener.Companion.listen
@@ -29,24 +29,20 @@ import com.lambda.task.tasks.BuildTask.Companion.breakAndCollectBlock
2929
import com.lambda.task.tasks.OpenContainer
3030
import com.lambda.task.tasks.PlaceContainer
3131
import com.lambda.util.item.ItemUtils.shulkerBoxes
32-
import com.lambda.util.player.SlotUtils.clickSlot
33-
import com.lambda.util.player.SlotUtils.hotbar
34-
import net.minecraft.item.ItemStack
3532
import net.minecraft.item.Items
36-
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
3733
import net.minecraft.screen.ScreenHandler
3834
import net.minecraft.screen.slot.SlotActionType
3935
import net.minecraft.util.math.BlockPos
40-
import net.minecraft.util.math.Direction
4136

4237
object InventoryTweaks : Module(
4338
name = "InventoryTweaks",
4439
defaultTags = setOf(ModuleTag.PLAYER)
4540
) {
4641
private val instantShulker by setting("Instant Shulker", true, description = "Right-click shulker boxes in your inventory to instantly place them and open them.")
4742
private val instantEChest by setting("Instant Ender-Chest", true, description = "Right-click ender chests in your inventory to instantly place them and open them.")
43+
private val inventory = InventorySettings(this)
4844
private var placedPos: BlockPos? = null
49-
private var lastPlace: Task<*>? = null
45+
private var placeAndOpen: Task<*>? = null
5046
private var lastBreak: Task<*>? = null
5147
private var lastOpenScreen: ScreenHandler? = null
5248

@@ -56,11 +52,8 @@ object InventoryTweaks : Module(
5652
val stack = it.screenHandler.getSlot(it.slot).stack
5753
if (!(instantShulker && stack.item in shulkerBoxes) && !(instantEChest && stack.item == Items.ENDER_CHEST)) return@listen
5854
it.cancel()
59-
move(it.slot, stack)
60-
61-
player.closeScreen()
62-
63-
lastPlace = PlaceContainer(stack).then { placePos ->
55+
lastOpenScreen = null
56+
placeAndOpen = PlaceContainer(stack, inventory = inventory).then { placePos ->
6457
placedPos = placePos
6558
OpenContainer(placePos).finally { screenHandler ->
6659
lastOpenScreen = screenHandler
@@ -78,32 +71,8 @@ object InventoryTweaks : Module(
7871
}
7972

8073
onDisable {
81-
lastPlace?.cancel()
74+
placeAndOpen?.cancel()
8275
lastBreak?.cancel()
8376
}
8477
}
85-
86-
private fun SafeContext.move(index: Int, stack: ItemStack) {
87-
if (stack == player.mainHandStack) {
88-
return
89-
}
90-
91-
if (stack == player.offHandStack) {
92-
connection.sendPacket(
93-
PlayerActionC2SPacket(
94-
PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND,
95-
BlockPos.ORIGIN,
96-
Direction.DOWN,
97-
),
98-
)
99-
return
100-
}
101-
102-
if (stack in player.hotbar) {
103-
player.inventory.selectedSlot = player.hotbar.indexOf(stack)
104-
return
105-
}
106-
107-
clickSlot(index, player.inventory.selectedSlot, SlotActionType.SWAP)
108-
}
10978
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ object Scaffold : Module(
8686
private val direction by setting("Direction", LookingDirection.FREE) { page == Page.ROTATION }
8787
private val optimalPitch by setting("Optimal Pitch", 81.0, 70.0..85.0, 0.05) { page == Page.ROTATION }
8888

89-
private val interactionConfig = InteractionSettings(this, InteractionMask.BLOCK) { page == Page.INTERACTION }
89+
private val interactionConfig = InteractionSettings(this, InteractionMask.Block) { page == Page.INTERACTION }
9090

9191
// Placement
9292
private var placeInfo: PlaceInfo? = null

0 commit comments

Comments
 (0)