You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In LLSE, 「Packet Object」 is used to get information about packets.
@@ -21,10 +19,8 @@ In LLSE, 「Packet Object」 is used to get information about packets.
21
19
22
20
#### Get from API
23
21
24
-
Call some **return packet object** function to get to the packet object given by BDS
25
-
See [Binary Stream Objects](#-binary-stream-object-api) for details
26
-
27
-
22
+
Call some **return packet object** function to get to the packet object given by BDS
23
+
See [Binary Stream Objects](#-binary-stream-object-api) for details
28
24
29
25
### Packet Objects - Functions
30
26
@@ -35,9 +31,7 @@ Every packet object contains some member functions (member methods) that can be
35
31
`pkt.getName()`
36
32
37
33
- Return value:packet name
38
-
- Return value type: `String`
39
-
40
-
34
+
- Return value type: `String`
41
35
42
36
#### Get packet ID
43
37
@@ -46,15 +40,55 @@ Every packet object contains some member functions (member methods) that can be
46
40
- Return value:packet id
47
41
- Return value type: `Integer`
48
42
43
+
#### Send packet to specified target
44
+
45
+
!!! warning
46
+
This function is only available in 0.19.0 and later.
47
+
48
+
`pkt.sendTo(pos)`
49
+
`pkt.sendTo(x,y,z,dimid)`
50
+
`pkt.sendTo(target)`
51
+
52
+
- Parameters:
53
+
54
+
- pos : `IntPos` / `FloatPos`
55
+
The coordinates of the packet send target (or use x, y, z, dimid to determine the target position)
56
+
- target : `Player` / `Entity`
57
+
Packet send target
58
+
59
+
- Return value:success or not
60
+
- Return value type: `Boolean`
61
+
62
+
If `target` is `Player`, the packet will be sent to the specified player.
63
+
If `target` is `Entity`, the packet will be sent to players around the specified entity.
49
64
65
+
#### Send packet to all clients
66
+
67
+
!!! warning
68
+
This function is only available in 0.19.0 and later.
69
+
70
+
`pkt.sendToClients()`
71
+
72
+
- Return value:success or not
73
+
- Return value type: `Boolean`
74
+
75
+
#### Send packet to server
76
+
77
+
!!! warning
78
+
This function is only available in 0.19.0 and later.
79
+
80
+
`pkt.sendToServer()`
81
+
82
+
- Return value:success or not
83
+
- Return value type: `Boolean`
50
84
51
85
## 🔌 Binary Stream Object API
52
86
53
87
### Create a binary stream object
54
88
55
-
[JavaScript]```new BinaryStream()```
89
+
[JavaScript]`new BinaryStream()`
56
90
57
-
[Lua]```BinaryStream()```
91
+
[Lua]`BinaryStream()`
58
92
59
93
- Return value: Binary stream object
60
94
- Return value type: `BinaryStream`
@@ -70,72 +104,141 @@ Every binary stream object contains some member functions (member methods) that
70
104
- Return value: success or not
71
105
- Return value type: `Boolean`
72
106
107
+
#### Get binary stream read pointer
108
+
109
+
!!! warning
110
+
This function is only available in 0.19.0 and later.
111
+
112
+
`bs.getReadPointer()`
113
+
114
+
- Return value: current read pointer
115
+
- Return value type: `Integer`
116
+
117
+
#### Set binary stream read pointer
73
118
119
+
!!! warning
120
+
This function is only available in 0.19.0 and later.
121
+
122
+
`bs.setReadPointer(pos)`
123
+
124
+
- Parameters:
125
+
126
+
- pos : `Integer`
127
+
New read pointer
128
+
129
+
- Return value: success or not
130
+
- Return value type: `Boolean`
131
+
132
+
#### Get binary stream data
133
+
134
+
!!! warning
135
+
The optional parameter and `ByteBuffer` return value of this function are only available in 0.19.0 and later.
136
+
137
+
`bs.getData([clear])`
138
+
139
+
- Parameters:
140
+
141
+
- clear : `Boolean` (Optional parameter)
142
+
Whether to clear stream data after reading. The default value is `true`
143
+
144
+
- Return value: binary stream data
145
+
- Return value type: `ByteBuffer`
146
+
147
+
Before 0.19.0, this function can only be used as `bs.getData()`.
148
+
At that time, it always cleared the stream data after reading, and the return value type was `String`.
149
+
150
+
Because the old return value was `String`, in JavaScript it may be forcibly encoded as UTF-8, causing binary data corruption and incorrect data content.
151
+
152
+
#### Set binary stream data
153
+
154
+
!!! warning
155
+
This function is only available in 0.19.0 and later.
156
+
157
+
`bs.setData(data)`
158
+
159
+
- Parameters:
160
+
161
+
- data : `ByteBuffer`
162
+
Binary stream data
163
+
164
+
- Return value: success or not
165
+
- Return value type: `Boolean`
74
166
75
167
#### Write to binary stream
76
168
77
-
`bs.writexxxx(value)`
169
+
`bs.writexxxx(value)`
78
170
79
171
- Parameters:
172
+
80
173
- value : `NULL`
81
174
Refer to the table below
175
+
For some numeric write functions, `String` is also accepted
0 commit comments