14
14
15
15
namespace pocketmine \network \mcpe \protocol ;
16
16
17
+ use pocketmine \math \Vector2 ;
17
18
use pocketmine \math \Vector3 ;
18
19
use pocketmine \network \mcpe \protocol \serializer \PacketSerializer ;
19
20
use pocketmine \network \mcpe \protocol \types \InputMode ;
26
27
use pocketmine \network \mcpe \protocol \types \PlayerBlockActionStopBreak ;
27
28
use pocketmine \network \mcpe \protocol \types \PlayerBlockActionWithBlockInfo ;
28
29
use pocketmine \network \mcpe \protocol \types \PlayMode ;
29
- use function assert ;
30
30
use function count ;
31
31
32
32
class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
@@ -42,7 +42,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
42
42
private int $ inputMode ;
43
43
private int $ playMode ;
44
44
private int $ interactionMode ;
45
- private ? Vector3 $ vrGazeDirection = null ;
45
+ private Vector2 $ interactRotation ;
46
46
private int $ tick ;
47
47
private Vector3 $ delta ;
48
48
private ?ItemInteractionData $ itemInteractionData = null ;
@@ -52,6 +52,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
52
52
private ?PlayerAuthInputVehicleInfo $ vehicleInfo = null ;
53
53
private float $ analogMoveVecX ;
54
54
private float $ analogMoveVecZ ;
55
+ private Vector3 $ cameraOrientation ;
55
56
56
57
/**
57
58
* @generate-create-func
@@ -68,7 +69,7 @@ private static function internalCreate(
68
69
int $ inputMode ,
69
70
int $ playMode ,
70
71
int $ interactionMode ,
71
- ? Vector3 $ vrGazeDirection ,
72
+ Vector2 $ interactRotation ,
72
73
int $ tick ,
73
74
Vector3 $ delta ,
74
75
?ItemInteractionData $ itemInteractionData ,
@@ -77,6 +78,7 @@ private static function internalCreate(
77
78
?PlayerAuthInputVehicleInfo $ vehicleInfo ,
78
79
float $ analogMoveVecX ,
79
80
float $ analogMoveVecZ ,
81
+ Vector3 $ cameraOrientation ,
80
82
) : self {
81
83
$ result = new self ;
82
84
$ result ->position = $ position ;
@@ -89,7 +91,7 @@ private static function internalCreate(
89
91
$ result ->inputMode = $ inputMode ;
90
92
$ result ->playMode = $ playMode ;
91
93
$ result ->interactionMode = $ interactionMode ;
92
- $ result ->vrGazeDirection = $ vrGazeDirection ;
94
+ $ result ->interactRotation = $ interactRotation ;
93
95
$ result ->tick = $ tick ;
94
96
$ result ->delta = $ delta ;
95
97
$ result ->itemInteractionData = $ itemInteractionData ;
@@ -98,6 +100,7 @@ private static function internalCreate(
98
100
$ result ->vehicleInfo = $ vehicleInfo ;
99
101
$ result ->analogMoveVecX = $ analogMoveVecX ;
100
102
$ result ->analogMoveVecZ = $ analogMoveVecZ ;
103
+ $ result ->cameraOrientation = $ cameraOrientation ;
101
104
return $ result ;
102
105
}
103
106
@@ -106,7 +109,6 @@ private static function internalCreate(
106
109
* @param int $inputMode @see InputMode
107
110
* @param int $playMode @see PlayMode
108
111
* @param int $interactionMode @see InteractionMode
109
- * @param Vector3|null $vrGazeDirection only used when PlayMode::VR
110
112
* @param PlayerBlockAction[]|null $blockActions Blocks that the client has interacted with
111
113
*/
112
114
public static function create (
@@ -120,21 +122,17 @@ public static function create(
120
122
int $ inputMode ,
121
123
int $ playMode ,
122
124
int $ interactionMode ,
123
- ? Vector3 $ vrGazeDirection ,
125
+ Vector2 $ interactRotation ,
124
126
int $ tick ,
125
127
Vector3 $ delta ,
126
128
?ItemInteractionData $ itemInteractionData ,
127
129
?ItemStackRequest $ itemStackRequest ,
128
130
?array $ blockActions ,
129
131
?PlayerAuthInputVehicleInfo $ vehicleInfo ,
130
132
float $ analogMoveVecX ,
131
- float $ analogMoveVecZ
133
+ float $ analogMoveVecZ ,
134
+ Vector3 $ cameraOrientation
132
135
) : self {
133
- if ($ playMode === PlayMode::VR and $ vrGazeDirection === null ){
134
- //yuck, can we get a properly written packet just once? ...
135
- throw new \InvalidArgumentException ("Gaze direction must be provided for VR play mode " );
136
- }
137
-
138
136
$ realInputFlags = $ inputFlags & ~((1 << PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST ) | (1 << PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION ) | (1 << PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS ));
139
137
if ($ itemStackRequest !== null ){
140
138
$ realInputFlags |= 1 << PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST ;
@@ -160,15 +158,16 @@ public static function create(
160
158
$ inputMode ,
161
159
$ playMode ,
162
160
$ interactionMode ,
163
- $ vrGazeDirection ?->asVector3() ,
161
+ $ interactRotation ,
164
162
$ tick ,
165
163
$ delta ,
166
164
$ itemInteractionData ,
167
165
$ itemStackRequest ,
168
166
$ blockActions ,
169
167
$ vehicleInfo ,
170
168
$ analogMoveVecX ,
171
- $ analogMoveVecZ
169
+ $ analogMoveVecZ ,
170
+ $ cameraOrientation
172
171
);
173
172
}
174
173
@@ -224,9 +223,7 @@ public function getInteractionMode() : int{
224
223
return $ this ->interactionMode ;
225
224
}
226
225
227
- public function getVrGazeDirection () : ?Vector3 {
228
- return $ this ->vrGazeDirection ;
229
- }
226
+ public function getInteractRotation () : Vector2 { return $ this ->interactRotation ; }
230
227
231
228
public function getTick () : int {
232
229
return $ this ->tick ;
@@ -257,6 +254,8 @@ public function getAnalogMoveVecX() : float{ return $this->analogMoveVecX; }
257
254
258
255
public function getAnalogMoveVecZ () : float { return $ this ->analogMoveVecZ ; }
259
256
257
+ public function getCameraOrientation () : Vector3 { return $ this ->cameraOrientation ; }
258
+
260
259
public function hasFlag (int $ flag ) : bool {
261
260
return ($ this ->inputFlags & (1 << $ flag )) !== 0 ;
262
261
}
@@ -272,9 +271,7 @@ protected function decodePayload(PacketSerializer $in) : void{
272
271
$ this ->inputMode = $ in ->getUnsignedVarInt ();
273
272
$ this ->playMode = $ in ->getUnsignedVarInt ();
274
273
$ this ->interactionMode = $ in ->getUnsignedVarInt ();
275
- if ($ this ->playMode === PlayMode::VR ){
276
- $ this ->vrGazeDirection = $ in ->getVector3 ();
277
- }
274
+ $ this ->interactRotation = $ in ->getVector2 ();
278
275
$ this ->tick = $ in ->getUnsignedVarLong ();
279
276
$ this ->delta = $ in ->getVector3 ();
280
277
if ($ this ->hasFlag (PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION )){
@@ -300,6 +297,7 @@ protected function decodePayload(PacketSerializer $in) : void{
300
297
}
301
298
$ this ->analogMoveVecX = $ in ->getLFloat ();
302
299
$ this ->analogMoveVecZ = $ in ->getLFloat ();
300
+ $ this ->cameraOrientation = $ in ->getVector3 ();
303
301
}
304
302
305
303
protected function encodePayload (PacketSerializer $ out ) : void {
@@ -313,10 +311,7 @@ protected function encodePayload(PacketSerializer $out) : void{
313
311
$ out ->putUnsignedVarInt ($ this ->inputMode );
314
312
$ out ->putUnsignedVarInt ($ this ->playMode );
315
313
$ out ->putUnsignedVarInt ($ this ->interactionMode );
316
- if ($ this ->playMode === PlayMode::VR ){
317
- assert ($ this ->vrGazeDirection !== null );
318
- $ out ->putVector3 ($ this ->vrGazeDirection );
319
- }
314
+ $ out ->putVector2 ($ this ->interactRotation );
320
315
$ out ->putUnsignedVarLong ($ this ->tick );
321
316
$ out ->putVector3 ($ this ->delta );
322
317
if ($ this ->itemInteractionData !== null ){
@@ -337,6 +332,7 @@ protected function encodePayload(PacketSerializer $out) : void{
337
332
}
338
333
$ out ->putLFloat ($ this ->analogMoveVecX );
339
334
$ out ->putLFloat ($ this ->analogMoveVecZ );
335
+ $ out ->putVector3 ($ this ->cameraOrientation );
340
336
}
341
337
342
338
public function handle (PacketHandlerInterface $ handler ) : bool {
0 commit comments