1717
1818package com.lambda.module.modules.movement
1919
20- import com.lambda.config.AutomationConfig
20+ import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121import com.lambda.context.SafeContext
2222import com.lambda.event.events.TickEvent
2323import com.lambda.event.listener.SafeListener.Companion.listen
24- import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker
2524import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.findRotation
2625import com.lambda.module.Module
2726import com.lambda.module.tag.ModuleTag
2827import com.lambda.threading.runSafeAutomated
29- import com.lambda.util.Communication.debug
3028import com.lambda.util.Communication.info
31- import com.lambda.util.EntityUtils
3229import com.lambda.util.Timer
33- import com.lambda.util.math.dist
3430import com.lambda.util.world.fastEntitySearch
3531import net.minecraft.entity.Entity
36- import net.minecraft.entity.EntityType
3732import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
3833import net.minecraft.registry.Registries
3934import 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