11from unittest import TestCase
22
3- from spockbot .mcdata .constants import \
4- ATTACK_ENTITY , INTERACT_ENTITY , PLAYER_HEIGHT
3+ from spockbot .mcdata import constants
54from spockbot .plugins .helpers .clientinfo import PlayerPosition
65from spockbot .plugins .helpers .interact import InteractPlugin
76from spockbot .vector import Vector3
@@ -53,6 +52,7 @@ class InventoryMock(object):
5352class ClientInfoMock (object ):
5453 eid = 123
5554 position = PlayerPosition (1. , 2. , 3. )
55+ eye_pos = position + (0 , constants .PLAYER_EYE_HEIGHT , 0 )
5656
5757
5858class InteractPluginTest (TestCase ):
@@ -97,7 +97,7 @@ def test_look(self):
9797 self .assertAlmostEqual (ClientInfoMock .position .yaw , - 90 )
9898 self .assertAlmostEqual (ClientInfoMock .position .pitch , 0 )
9999
100- self .plug .look_at (Vector3 (0 , 2 + PLAYER_HEIGHT , 3 ))
100+ self .plug .look_at (Vector3 (0 , 2 + constants . PLAYER_EYE_HEIGHT , 3 ))
101101 self .assertAlmostEqual (ClientInfoMock .position .yaw , 90 )
102102 self .assertAlmostEqual (ClientInfoMock .position .pitch , 0 )
103103
@@ -115,32 +115,32 @@ def test_activate_item(self):
115115 # TODO deactivate_item
116116
117117 def test_entity (self ):
118- entity = DataDict (eid = 234 , x = 2 , y = 2 + PLAYER_HEIGHT , z = 4 )
118+ entity = DataDict (eid = 234 , x = 2 , y = 2 + constants . PLAYER_EYE_HEIGHT , z = 4 )
119119
120120 self .plug .use_entity (entity )
121121 self .assertAlmostEqual (ClientInfoMock .position .yaw , - 45 )
122122 self .assertAlmostEqual (ClientInfoMock .position .pitch , 0 )
123- self .assertEqual (NetMock .datas [- 2 ].action , INTERACT_ENTITY )
123+ self .assertEqual (NetMock .datas [- 2 ].action , constants . INTERACT_ENTITY )
124124 self .assertEqual (NetMock .datas [- 2 ].target , 234 )
125125 self .assertEqual (NetMock .idents [- 1 ], 'PLAY>Animation' )
126126
127127 self .plug .auto_look = False
128- entity = DataDict (eid = 345 , x = 0 , y = 3 + PLAYER_HEIGHT , z = 3 )
128+ entity = DataDict (eid = 345 , x = 0 , y = 3 + constants . PLAYER_EYE_HEIGHT , z = 3 )
129129 self .plug .attack_entity (entity )
130130 # different pos, but look shouldn't have changed
131131 self .assertAlmostEqual (ClientInfoMock .position .yaw , - 45 )
132132 self .assertAlmostEqual (ClientInfoMock .position .pitch , 0 )
133- self .assertEqual (NetMock .datas [- 2 ].action , ATTACK_ENTITY )
133+ self .assertEqual (NetMock .datas [- 2 ].action , constants . ATTACK_ENTITY )
134134 self .assertEqual (NetMock .datas [- 2 ].target , 345 )
135135 self .assertEqual (NetMock .idents [- 1 ], 'PLAY>Animation' )
136136 self .plug .auto_look = True
137137
138138 self .plug .auto_swing = False
139- entity = DataDict (eid = 456 , x = 2 , y = 3 + PLAYER_HEIGHT , z = 3 )
139+ entity = DataDict (eid = 456 , x = 2 , y = 3 + constants . PLAYER_EYE_HEIGHT , z = 3 )
140140 self .plug .mount_vehicle (entity )
141141 self .assertAlmostEqual (ClientInfoMock .position .yaw , - 90 )
142142 self .assertAlmostEqual (ClientInfoMock .position .pitch , - 45 )
143- self .assertEqual (NetMock .datas [- 1 ].action , INTERACT_ENTITY )
143+ self .assertEqual (NetMock .datas [- 1 ].action , constants . INTERACT_ENTITY )
144144 self .assertEqual (NetMock .datas [- 1 ].target , 456 )
145145 self .plug .auto_swing = True
146146
0 commit comments