@@ -9,32 +9,38 @@ import com.lambda.util.world.WorldUtils.getEntities
99import net.minecraft.entity.passive.AbstractHorseEntity
1010import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
1111
12- object HorseUtils : Module(
13- name = " HorseUtils " ,
14- description = " Various utilities for horses. " ,
12+ object EntityControl : Module(
13+ name = " EntityControl " ,
14+ description = " Control mountable entities " ,
1515 defaultTags = setOf(ModuleTag .MOVEMENT , ModuleTag .BYPASS )
1616) {
1717 private val page by setting(" Page" , Page .General )
1818
1919 /* General */
2020 private val forceMount by setting(" Force Mount" , true , description = " Attempts to force mount chested entities." , visibility = { page == Page .General })
21- private val tameHorses by setting(" Tame Horses" , true , description = " Automatically tames horses (client-side only)." , visibility = { page == Page .General })
2221
23- /* Rendering */
24- private val showInfo by setting(" Show Info" , true , description = " Renders information about entities." , visibility = { page == Page .Rendering })
25-
26- private val theHonses = mutableListOf<AbstractHorseEntity >() // Petah, the honse is here
27- private val tame: (AbstractHorseEntity ) -> Unit = { horse -> if (tameHorses) horse.setHorseFlag(4 , true ) }
22+ /* Movement */
23+ private val speed by setting(" Entity Speed" , 2.0 , 0.1 .. 10.0 , 0.1 , description = " Speed for entities." , visibility = { page == Page .Movement })
2824
2925 private enum class Page {
30- General , Rendering
26+ General , Movement
3127 }
3228
29+ private val theHonses = mutableListOf<AbstractHorseEntity >() // Petah, the honse is here
30+
3331 init {
3432 listener<TickEvent .Pre > {
35- getEntities(theHonses, iterator = tame )
33+ getEntities(player.pos, 8.0 , theHonses, { horse -> horse.setHorseFlag( 4 , true ) } )
3634 }
3735
36+ /* listener<MovementEvent.Pre> {
37+ if (!player.isRiding) return@listener
38+
39+ // We can do this because the player movement depends on the entity movement
40+ player.vehicle?.motionX = speed
41+ player.vehicle?.motionZ = speed
42+ }*/
43+
3844 listener<PacketEvent .Send .Pre > { event ->
3945 if (! forceMount) return @listener
4046 if (event.packet !is PlayerInteractEntityC2SPacket ) return @listener
@@ -45,5 +51,10 @@ object HorseUtils : Module(
4551
4652 event.cancel()
4753 }
54+
55+ onDisable {
56+ theHonses.forEach { horse -> horse.updateSaddle() }
57+ theHonses.clear()
58+ }
4859 }
4960}
0 commit comments