feat(Freecam): Add Exclude Rotation mode to freecam#269
feat(Freecam): Add Exclude Rotation mode to freecam#269IceTank wants to merge 1 commit intolambda-client:1.21.11from
Conversation
… player rotation on specific axis
| context(rotationContext: IRotationRequest.RotationRequestBuilder) | ||
| private fun buildRotationTo(rotation: Rotation) { | ||
| when (excludeRotation) { | ||
| FreecamRotationExclusion.Pitch -> { |
There was a problem hiding this comment.
can inline these to avoid the brackets
|
|
||
| listen<TickEvent.Pre> { | ||
| when (rotateMode) { | ||
| FreecamRotationMode.None -> return@listen |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) } | |||
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
onValueChanged on the next line again
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.