Lock farming pitch downward

This commit is contained in:
Tanner
2026-11-04 20:12:12 +00:00
parent 7d4f045100
commit b9d43c7c37
2 changed files with 56 additions and 8 deletions
+23 -8
View File
@@ -57,6 +57,26 @@ PITCH_ANGLE_DIR = vector.Vector3D((0, 1, 0))
YAW_ANGLE_DIR = vector.Vector3D((0, 0, -1))
YAW_ANGLE_REF = vector.Vector3D((0, 1, 0))
YAW_LOOK_AHEAD = 4
FARMING_PITCH = 45.0
def pitch_lock_for_job(job_state):
state = getattr(job_state, 'state', None) if job_state else None
return (FARMING_PITCH if getattr(state, '__name__', None) == 'farm_crop'
else None)
def update_pitch(g, look_at_d, fixed_pitch=None):
if fixed_pitch is not None:
target_pitch = fixed_pitch
elif look_at_d is None:
target_pitch = 0.0
elif look_at_d.length() > 0.6:
target_pitch = look_at_d.normalized().angleDeg(PITCH_ANGLE_DIR)
target_pitch = (target_pitch - 90) * -1
else:
return
g.pitch += utils.cap(target_pitch - g.pitch, 10)
def missing_movement_chunks(g):
@@ -218,16 +238,12 @@ def tick(global_state):
else:
look_at = None
pitch_lock = pitch_lock_for_job(g.get('job'))
if look_at:
look_at.x += 0.5
look_at.z += 0.5
look_at_d = p - look_at
if look_at_d.length() > 0.6:
target_pitch = look_at_d.normalized().angleDeg(PITCH_ANGLE_DIR)
target_pitch = (target_pitch - 90) * -1
target_pitch_d = target_pitch - g.pitch
g.pitch += utils.cap(target_pitch_d, 10)
update_pitch(g, look_at_d, pitch_lock)
# remove vertical component for yaw calculation
look_at_d.y = 0
@@ -238,8 +254,7 @@ def tick(global_state):
target_yaw_d = (target_yaw_d + 180) % 360 - 180
g.yaw += utils.cap(target_yaw_d, 30)
else:
target_pitch_d = 0 - g.pitch
g.pitch += utils.cap(target_pitch_d, 10)
update_pitch(g, None, pitch_lock)
from minecraft.networking.modern import (
ClientTickEnd, PlayerPositionRotation,