Skip to content

Comments

feat(AutoMount): Add AutoMount module#240

Open
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:feature/module/automount
Open

feat(AutoMount): Add AutoMount module#240
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:feature/module/automount

Conversation

@IceTank
Copy link
Contributor

@IceTank IceTank commented Feb 2, 2026

Add AutoMount module to automatically mount or remount entities

@IceTank
Copy link
Contributor Author

IceTank commented Feb 2, 2026

Not tested yet

@IceTank
Copy link
Contributor Author

IceTank commented Feb 3, 2026

Works now

@IceTank IceTank marked this pull request as ready for review February 3, 2026 21:02
@beanbag44 beanbag44 self-requested a review February 22, 2026 10:36
}
}
}
if (autoRemount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in situations like this i would check if (!autoRemount) return@listen

}
if (autoRemount) {
if (player.vehicle != null) {
lastEntity = player.vehicle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here for example, you could add return@listen in the if statement and then you dont have to wrap the rest in the else

} else {
lastEntity?.let {
if (it.isRemoved || it.distanceTo(player) > range) {
lastEntity = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well; return@let

var interval by setting("Interval", 50, 1..200, 1, unit = "ms", description = "Interact interval")
var range by setting("Range", 4.0, 1.0..20.0, 0.1, description = "Mount range")

override var automationConfig = AutomationConfig(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automation configs are set using setDefaultAutomationConfig at the start of the init block

) {
var autoRemount by setting("Auto Remount", false, description = "Automatically remounts if you get off")
var autoMountEntities by setting("Auto Mount Entities", true, description = "Automatically mounts nearby entities in range")
var autoMountEntityList by setting("Auto Mount Entity List",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings should be written on one line with the exception of some builder style functions like onSelect, onDeselect, onValueChange, etc

transitive-accessible field net/minecraft/registry/SimpleRegistry frozen Z

# AutoMount
accessible method net/minecraft/entity/Entity canAddPassenger (Lnet/minecraft/entity/Entity;)Z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be placed under the # Entity group

if (autoMountEntities && player.vehicle == null) {
runSafeAutomated {
val entity = fastEntitySearch<Entity>(10.0) {
autoMountEntityList.contains(it.type) && canRide(it) && it.findRotation(range, player.eyePos) != null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its best to have a rotation setting as currently this checks if its possible for a valid rotation but doesnt perform it.

entity.firstOrNull()?.let {
intervalTimer.reset()
interactEntity(it)
debug("Mounting ${it.name}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nitpick but a log setting or something could be good

}

private fun SafeContext.interactEntity(entity: Entity) {
mc.networkHandler?.sendPacket(PlayerInteractEntityC2SPacket.interactAt(entity, false, Hand.MAIN_HAND, Vec3d(0.5, 0.5, 0.5)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we should fill the parameters with accurate data like player.isSneaking instead of false

mc.networkHandler?.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, false, Hand.MAIN_HAND))
}

private fun SafeContext.canRide(entity: Entity): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be inlined into

private fun SafeContext.canRide(entity: Entity) = entity.canAddPassenger(player)

@beanbag44
Copy link
Member

oh yeah, also use connection inside of SafeContext rather than mc.networkHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants