@@ -88,13 +88,13 @@ def look_at_rel(self, delta):
8888 self .look (* delta .yaw_pitch )
8989
9090 def look_at (self , pos ):
91- delta = pos - self .clientinfo .eye_pos
91+ delta = Vector3 ( pos ) - self .clientinfo .eye_pos
9292 if delta .x or delta .z :
9393 self .look_at_rel (delta )
9494 else : # looking up or down, do not turn head
9595 self .look (self .clientinfo .position .yaw , delta .yaw_pitch .pitch )
9696
97- def _send_dig_block (self , status , pos = None , face = constants .FACE_Y_POS ):
97+ def _send_dig_block (self , status , pos = None , face = constants .FACE_TOP ):
9898 if status == constants .DIG_START :
9999 self .dig_pos_dict = pos .floor ().get_dict ().copy ()
100100 self .net .push_packet ('PLAY>Player Digging' , {
@@ -103,19 +103,20 @@ def _send_dig_block(self, status, pos=None, face=constants.FACE_Y_POS):
103103 'face' : face ,
104104 })
105105
106- def start_digging (self , pos ):
106+ def start_digging (self , pos , face = constants .FACE_TOP ):
107+ pos = Vector3 (pos )
107108 if self .auto_look :
108109 self .look_at (pos .floor () + Vector3 (0.5 , 0.5 , 0.5 ))
109- self ._send_dig_block (constants .DIG_START , pos )
110+ self ._send_dig_block (status = constants .DIG_START , pos = pos , face = face )
110111 if self .auto_swing :
111112 self .swing_arm ()
112113 # TODO send swing animation until done or stopped
113114
114115 def cancel_digging (self ):
115- self ._send_dig_block (constants .DIG_CANCEL )
116+ self ._send_dig_block (status = constants .DIG_CANCEL )
116117
117118 def finish_digging (self ):
118- self ._send_dig_block (constants .DIG_FINISH )
119+ self ._send_dig_block (status = constants .DIG_FINISH )
119120
120121 def dig_block (self , pos ):
121122 """
@@ -124,7 +125,8 @@ def dig_block(self, pos):
124125 self .start_digging (pos )
125126 self .finish_digging ()
126127
127- def _send_click_block (self , pos , face = 1 , cursor_pos = Vector3 (8 , 8 , 8 )):
128+ def _send_click_block (self , pos , face = constants .FACE_TOP ,
129+ cursor_pos = Vector3 (8 , 8 , 8 )):
128130 self .net .push_packet ('PLAY>Player Block Placement' , {
129131 'location' : pos .floor ().get_dict (),
130132 'direction' : face ,
@@ -134,8 +136,7 @@ def _send_click_block(self, pos, face=1, cursor_pos=Vector3(8, 8, 8)):
134136 'cur_pos_z' : int (cursor_pos .z ),
135137 })
136138
137- def click_block (self , pos , face = 1 , cursor_pos = Vector3 (8 , 8 , 8 ),
138- look_at_block = True , swing = True ):
139+ def click_block (self , pos , look_at_block = True , swing = True , ** kwargs ):
139140 """
140141 Click on a block.
141142 Examples: push button, open window, make redstone ore glow
@@ -145,24 +146,24 @@ def click_block(self, pos, face=1, cursor_pos=Vector3(8, 8, 8),
145146 cursor_pos (Vector3): where to click inside the block,
146147 each dimension 0-15
147148 """
149+ pos = Vector3 (pos )
148150 if look_at_block and self .auto_look :
149151 # TODO look at cursor_pos
150152 self .look_at (pos .floor () + Vector3 (0.5 , 0.5 , 0.5 ))
151- self ._send_click_block (pos , face , cursor_pos )
153+ self ._send_click_block (pos , ** kwargs )
152154 if swing and self .auto_swing :
153155 self .swing_arm ()
154156
155- def place_block (self , pos , face = 1 , cursor_pos = Vector3 (8 , 8 , 8 ),
156- sneak = True , look_at_block = True , swing = True ):
157+ def place_block (self , pos , sneak = True , ** kwargs ):
157158 """
158159 Place a block next to ``pos``.
159160 If the block at ``pos`` is air, place at ``pos``.
160161 """
161162 sneaking_before = self .sneaking
162163 if sneak :
163164 self .sneak ()
164- self .click_block (pos , face , cursor_pos , look_at_block , swing )
165- if sneak :
165+ self .click_block (pos , ** kwargs )
166+ if not sneaking_before :
166167 self .sneak (sneaking_before )
167168
168169 def use_bucket (self , pos ): # TODO
0 commit comments