Skip to content

Commit 7f03cd1

Browse files
committed
Fix pr code comments
1 parent 4774b62 commit 7f03cd1

1 file changed

Lines changed: 23 additions & 32 deletions

File tree

  • src/main/kotlin/com/lambda/module/modules/movement

src/main/kotlin/com/lambda/module/modules/movement/AutoMount.kt

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@
1717

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

20-
import com.lambda.config.AutomationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.context.SafeContext
2222
import com.lambda.event.events.TickEvent
2323
import com.lambda.event.listener.SafeListener.Companion.listen
24-
import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker
2524
import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.findRotation
2625
import com.lambda.module.Module
2726
import com.lambda.module.tag.ModuleTag
2827
import com.lambda.threading.runSafeAutomated
29-
import com.lambda.util.Communication.debug
3028
import com.lambda.util.Communication.info
31-
import com.lambda.util.EntityUtils
3229
import com.lambda.util.Timer
33-
import com.lambda.util.math.dist
3430
import com.lambda.util.world.fastEntitySearch
3531
import net.minecraft.entity.Entity
36-
import net.minecraft.entity.EntityType
3732
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
3833
import net.minecraft.registry.Registries
3934
import net.minecraft.util.Hand
@@ -47,22 +42,17 @@ class AutoMount : Module(
4742
) {
4843
var autoRemount by setting("Auto Remount", false, description = "Automatically remounts if you get off")
4944
var autoMountEntities by setting("Auto Mount Entities", true, description = "Automatically mounts nearby entities in range")
50-
var autoMountEntityList by setting("Auto Mount Entity List",
51-
mutableListOf(),
52-
Registries.ENTITY_TYPE.toList()
53-
) { autoMountEntities }
45+
var autoMountEntityList by setting("Auto Mount Entity List", mutableListOf(), Registries.ENTITY_TYPE.toList()) { autoMountEntities }
5446

5547
var interval by setting("Interval", 50, 1..200, 1, unit = "ms", description = "Interact interval")
5648
var range by setting("Range", 4.0, 1.0..20.0, 0.1, description = "Mount range")
57-
58-
override var automationConfig = AutomationConfig(
59-
name = "AutoMount"
60-
)
49+
var debug by setting("Debug", false, description = "Print debug messages")
6150

6251
val intervalTimer = Timer()
6352
var lastEntity: Entity? = null
6453

6554
init {
55+
setDefaultAutomationConfig("AutoMount")
6656
onEnable {
6757
intervalTimer.reset()
6858
lastEntity = null
@@ -80,24 +70,27 @@ class AutoMount : Module(
8070
entity.firstOrNull()?.let {
8171
intervalTimer.reset()
8272
interactEntity(it)
83-
debug("Mounting ${it.name}")
73+
if (debug) info("Mounting ${it.name}")
8474
}
8575
}
8676
}
87-
if (autoRemount) {
88-
if (player.vehicle != null) {
89-
lastEntity = player.vehicle
90-
} else {
91-
lastEntity?.let {
92-
if (it.isRemoved || it.distanceTo(player) > range) {
93-
lastEntity = null
94-
} else {
95-
if (canRide(it)) {
96-
intervalTimer.reset()
97-
interactEntity(it)
98-
}
99-
}
100-
}
77+
if (!autoRemount) {
78+
return@listen
79+
}
80+
if (player.vehicle != null) {
81+
lastEntity = player.vehicle
82+
}
83+
if (lastEntity == null) {
84+
return@listen
85+
}
86+
lastEntity?.let {
87+
if (it.isRemoved || it.distanceTo(player) > range) {
88+
lastEntity = null
89+
return@let
90+
}
91+
if (canRide(it)) {
92+
intervalTimer.reset()
93+
interactEntity(it)
10194
}
10295
}
10396
}
@@ -108,7 +101,5 @@ class AutoMount : Module(
108101
mc.networkHandler?.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, false, Hand.MAIN_HAND))
109102
}
110103

111-
private fun SafeContext.canRide(entity: Entity): Boolean {
112-
return entity.canAddPassenger(player)
113-
}
104+
private fun SafeContext.canRide(entity: Entity) = entity.canAddPassenger(player)
114105
}

0 commit comments

Comments
 (0)