Skip to content

Commit 26c510a

Browse files
committed
Set correct freecam perspective
1 parent ae2c06f commit 26c510a

File tree

1 file changed

+10
-3
lines changed
  • common/src/main/kotlin/com/lambda/module/modules/player

1 file changed

+10
-3
lines changed

common/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.lambda.util.primitives.extension.rotation
2222
import com.lambda.util.world.raycast.RayCastUtils.orMiss
2323
import com.lambda.util.world.raycast.RayCastUtils.orNull
2424
import net.minecraft.client.input.KeyboardInput
25+
import net.minecraft.client.option.Perspective
2526
import net.minecraft.entity.Entity
2627
import net.minecraft.util.math.Vec3d
2728

@@ -32,7 +33,7 @@ object Freecam : Module(
3233
) {
3334
private val speed by setting("Speed", 0.5f, 0.1f..1.0f, 0.1f)
3435
private val sprint by setting("Sprint Multiplier", 3.0f, 0.1f..10.0f, 0.1f, description = "Set below 1.0 to fly slower on sprint.")
35-
private val reach by setting("Reach", 5.0, 1.0..100.0, 1.0, "Freecam reach distance")
36+
private val reach by setting("Reach", 10.0, 1.0..100.0, 1.0, "Freecam reach distance")
3637
private val rotateToTarget by setting("Rotate to target", true)
3738

3839
private val rotationConfig = RotationSettings(this) {
@@ -41,11 +42,11 @@ object Freecam : Module(
4142
rotationMode = RotationMode.LOCK
4243
}
4344

45+
private var lastPerspective = Perspective.FIRST_PERSON
4446
private var prevPosition: Vec3d = Vec3d.ZERO
4547
private var position: Vec3d = Vec3d.ZERO
4648
private val interpolatedPosition: Vec3d
47-
get() =
48-
prevPosition.interpolate(position, mc.partialTicks)
49+
get() = prevPosition.interpolate(position, mc.partialTicks)
4950

5051
private var rotation: Rotation = Rotation.ZERO
5152
private var velocity: Vec3d = Vec3d.ZERO
@@ -70,11 +71,17 @@ object Freecam : Module(
7071

7172
init {
7273
onEnable {
74+
lastPerspective = mc.options.perspective
75+
mc.options.perspective = Perspective.FIRST_PERSON
7376
position = player.eyePos
7477
rotation = player.rotation
7578
velocity = Vec3d.ZERO
7679
}
7780

81+
onDisable {
82+
mc.options.perspective = lastPerspective
83+
}
84+
7885
listener<RotationEvent.Pre>(Int.MAX_VALUE) {
7986
if (!rotateToTarget) return@listener
8087
val target = mc.crosshairTarget?.orNull ?: return@listener

0 commit comments

Comments
 (0)