Skip to content

feat(Freecam): Add Exclude Rotation mode to freecam#269

Open
IceTank wants to merge 1 commit intolambda-client:1.21.11from
IceTank:feature/add-free-cam-rotation-exclusion-mode
Open

feat(Freecam): Add Exclude Rotation mode to freecam#269
IceTank wants to merge 1 commit intolambda-client:1.21.11from
IceTank:feature/add-free-cam-rotation-exclusion-mode

Conversation

@IceTank
Copy link
Contributor

@IceTank IceTank commented Mar 14, 2026

This mode lets you configure what rotations are applied to the player when rotation mode in freecam is enabled.
This is useful for when you are in freecam and want to be able to change the view direction of the player without exiting freecam. Possible use cases are elytra flying while in freecam and changing the player's yaw to the freecam yaw while flying.

@github-project-automation github-project-automation bot moved this to Backlog in Kanban Mar 14, 2026
@IceTank IceTank changed the title Add Exclude Rotation mode to freecam feat(Freecam): Add Exclude Rotation mode to freecam Mar 14, 2026
@beanbag44 beanbag44 self-requested a review March 17, 2026 01:20
context(rotationContext: IRotationRequest.RotationRequestBuilder)
private fun buildRotationTo(rotation: Rotation) {
when (excludeRotation) {
FreecamRotationExclusion.Pitch -> {
Copy link
Member

Choose a reason for hiding this comment

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

can inline these to avoid the brackets


listen<TickEvent.Pre> {
when (rotateMode) {
FreecamRotationMode.None -> return@listen
Copy link
Member

Choose a reason for hiding this comment

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

can change the None case to null and remove the submit calls for the other outcomes. Then you can move the .submit to the end of the when block with ?.submit(). Or the submit calls could be moved into the buildRotationTo function

}

context(rotationContext: IRotationRequest.RotationRequestBuilder)
private fun buildRotationTo(rotation: Rotation) {
Copy link
Member

Choose a reason for hiding this comment

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

rather than passing a rotation request context, you could just have this function create the request and return it. rotationRequest { when block with builder calls }

}
}

private enum class FreecamRotationMode(override val displayName: String, override val description: String) : NamedEnum, Describable {
Copy link
Member

Choose a reason for hiding this comment

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

can remove the Freecam prefix for these enums. Theyre private so theres no need to preface what theyre for. Also while you're cleaning things up, might as well move these enums below the function at the bottom and remove the extra white space under the followTrackPlayer setting

@@ -77,6 +78,7 @@ object Freecam : Module(
private val sprint by setting("Sprint Multiplier", 3.0, 0.1..10.0, 0.1, description = "Set below 1.0 to fly slower on sprint.") { mode == Mode.Free }
private val reach by setting("Reach", 10.0, 1.0..100.0, 1.0, "Freecam reach distance")
private val rotateMode by setting("Rotate Mode", FreecamRotationMode.None, "Rotation mode").onValueChange { _, it -> if (it == FreecamRotationMode.LookAtTarget) mc.crosshairTarget = BlockHitResult.createMissed(Vec3d.ZERO, Direction.UP, BlockPos.ORIGIN) }
Copy link
Member

Choose a reason for hiding this comment

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

onValueChange can be placed on the next line. Also you sure we need this onValueChange?

private val reach by setting("Reach", 10.0, 1.0..100.0, 1.0, "Freecam reach distance")
private val rotateMode by setting("Rotate Mode", FreecamRotationMode.None, "Rotation mode").onValueChange { _, it -> if (it == FreecamRotationMode.LookAtTarget) mc.crosshairTarget = BlockHitResult.createMissed(Vec3d.ZERO, Direction.UP, BlockPos.ORIGIN) }
private val excludeRotation by setting("Exclude Rotation", FreecamRotationExclusion.None, description = "Exclude certain rotation changes from rotate mode") { rotateMode != FreecamRotationMode.None }
private val relative by setting("Relative", false, "Moves freecam relative to player position") { mode == Mode.Free }.onValueChange { _, it -> if (it) lastPlayerPosition = player.pos }
Copy link
Member

Choose a reason for hiding this comment

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

onValueChanged on the next line again

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants