@@ -6,30 +6,26 @@ import com.lambda.event.listener.SafeListener.Companion.listener
66import com.lambda.module.Module
77import com.lambda.module.tag.ModuleTag
88import com.lambda.util.world.entitySearch
9+ import com.lambda.util.world.fastEntitySearch
910import net.minecraft.entity.passive.AbstractHorseEntity
11+ import net.minecraft.entity.passive.PigEntity
1012import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
1113
12- // ToDo: Rework this module. All mountables should work, solution should be more elegant.
1314object EntityControl : Module(
1415 name = " EntityControl" ,
1516 description = " Control mountable entities" ,
1617 defaultTags = setOf(ModuleTag .MOVEMENT )
1718) {
18- private val forceMount by setting(" Force Mount" , true , description = " Attempts to force mount chested entities." ).apply {
19- onValueChange { _, _ ->
20- resetMounts()
21- }
22- }
23- private val modified = mutableSetOf<AbstractHorseEntity >()
19+ private val forceMount by setting(" Force Mount" , true , description = " Attempts to force mount chested entities." )
20+
21+ private val saddledHorses = mutableSetOf<AbstractHorseEntity >()
2422
2523 init {
2624 listener<TickEvent .Pre > {
27- if (! forceMount) return @listener
28-
29- entitySearch<AbstractHorseEntity >(8.0 )
25+ fastEntitySearch<AbstractHorseEntity >(8.0 )
3026 .forEach {
27+ if (! it.isSaddled) saddledHorses.add(it)
3128 it.setHorseFlag(4 , true )
32- modified.add(it)
3329 }
3430 }
3531
@@ -45,11 +41,8 @@ object EntityControl : Module(
4541 }
4642
4743 onDisable {
48- resetMounts()
44+ saddledHorses.forEach { it.setHorseFlag(4 , false ) }
45+ saddledHorses.clear()
4946 }
5047 }
51-
52- private fun resetMounts () {
53- modified.forEach { it.updateSaddle() }
54- }
5548}
0 commit comments