Handle door navigation and turnarounds
This commit is contained in:
+22
-7
@@ -79,6 +79,18 @@ def update_pitch(g, look_at_d):
|
||||
g.pitch += utils.cap(target_pitch - g.pitch, 10)
|
||||
|
||||
|
||||
def update_yaw(g, look_at_d, max_turn=30, fixed_target=None):
|
||||
if fixed_target is not None:
|
||||
g.yaw += utils.cap(fixed_target - g.yaw, max_turn)
|
||||
return
|
||||
if look_at_d.length() <= 0.6:
|
||||
return
|
||||
target_yaw = look_at_d.normalized().signedAngleDeg(
|
||||
other=YAW_ANGLE_DIR, ref=YAW_ANGLE_REF)
|
||||
delta = (target_yaw - g.yaw + 180) % 360 - 180
|
||||
g.yaw = (g.yaw + utils.cap(delta, max_turn) + 180) % 360 - 180
|
||||
|
||||
|
||||
def missing_movement_chunks(g):
|
||||
"""Return chunks needed for local physics and the next path steps only."""
|
||||
position = g.get('pos')
|
||||
@@ -142,6 +154,10 @@ def tick(global_state):
|
||||
print('[movement] status={}'.format(status), flush=True)
|
||||
g.movement_status = status
|
||||
|
||||
door_pause = (g.game.handle_path_doors()
|
||||
if g.get('game') and
|
||||
hasattr(g.game, 'handle_path_doors') else False)
|
||||
|
||||
########## object physics ##########
|
||||
# note: it's possible the chunk data is out of date when this runs
|
||||
|
||||
@@ -176,7 +192,7 @@ def tick(global_state):
|
||||
|
||||
########## player physics ##########
|
||||
|
||||
if g.path and len(g.path):
|
||||
if g.path and len(g.path) and not door_pause:
|
||||
target = vector.Point3D(g.path[0])
|
||||
target.x += 0.5
|
||||
target.z += 0.5
|
||||
@@ -247,14 +263,13 @@ def tick(global_state):
|
||||
|
||||
# remove vertical component for yaw calculation
|
||||
look_at_d.y = 0
|
||||
|
||||
if look_at_d.length() > 0.6:
|
||||
target_yaw = look_at_d.normalized().signedAngleDeg(other=YAW_ANGLE_DIR, ref=YAW_ANGLE_REF)
|
||||
target_yaw_d = target_yaw - g.yaw
|
||||
target_yaw_d = (target_yaw_d + 180) % 360 - 180
|
||||
g.yaw += utils.cap(target_yaw_d, 30)
|
||||
update_yaw(g, look_at_d,
|
||||
fixed_target=g.get('yaw_target_override'))
|
||||
else:
|
||||
update_pitch(g, None)
|
||||
if g.get('yaw_target_override') is not None:
|
||||
update_yaw(g, None,
|
||||
fixed_target=g.yaw_target_override)
|
||||
|
||||
from minecraft.networking.modern import (
|
||||
ClientTickEnd, PlayerPositionRotation,
|
||||
|
||||
Reference in New Issue
Block a user