Skip to content

Commit d009b13

Browse files
committed
Allow radians in interact.look
1 parent e6c539e commit d009b13

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

spockbot/plugins/helpers/interact.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
By default, the client sends swing and look packets like the vanilla client.
1212
This can be disabled by setting the ``auto_swing`` and ``auto_look`` flags.
1313
"""
14+
import math
1415
from spockbot.mcdata import constants
1516
from spockbot.mcp import nbt
1617
from spockbot.mcp.proto import MC_SLOT
@@ -69,16 +70,18 @@ def jump_horse(self, jump_boost=100):
6970
def open_inventory(self):
7071
self._entity_action(constants.ENTITY_ACTION_OPEN_INVENTORY)
7172

72-
def look(self, yaw=0.0, pitch=0.0):
73-
"""
74-
Turn the head. Both angles are in degrees.
75-
"""
76-
self.clientinfo.position.pitch = pitch
77-
self.clientinfo.position.yaw = yaw
73+
def look(self, yaw=0.0, pitch=0.0, radians=False):
74+
if radians:
75+
self.clientinfo.position.yaw = math.degrees(yaw)
76+
self.clientinfo.position.pitch = math.degrees(pitch)
77+
else:
78+
self.clientinfo.position.yaw = yaw
79+
self.clientinfo.position.pitch = pitch
7880

79-
def look_rel(self, d_yaw=0.0, d_pitch=0.0):
81+
def look_rel(self, d_yaw=0.0, d_pitch=0.0, radians=False):
8082
self.look(self.clientinfo.position.yaw + d_yaw,
81-
self.clientinfo.position.pitch + d_pitch)
83+
self.clientinfo.position.pitch + d_pitch,
84+
radians=radians)
8285

8386
def look_at_rel(self, delta):
8487
self.look(*delta.yaw_pitch)

0 commit comments

Comments
 (0)