|
11 | 11 | By default, the client sends swing and look packets like the vanilla client. |
12 | 12 | This can be disabled by setting the ``auto_swing`` and ``auto_look`` flags. |
13 | 13 | """ |
| 14 | +import math |
14 | 15 | from spockbot.mcdata import constants |
15 | 16 | from spockbot.mcp import nbt |
16 | 17 | from spockbot.mcp.proto import MC_SLOT |
@@ -69,16 +70,18 @@ def jump_horse(self, jump_boost=100): |
69 | 70 | def open_inventory(self): |
70 | 71 | self._entity_action(constants.ENTITY_ACTION_OPEN_INVENTORY) |
71 | 72 |
|
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 |
78 | 80 |
|
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): |
80 | 82 | 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) |
82 | 85 |
|
83 | 86 | def look_at_rel(self, delta): |
84 | 87 | self.look(*delta.yaw_pitch) |
|
0 commit comments