mirror of
https://github.com/retrooper/packetevents.git
synced 2026-11-04 16:50:04 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b766e86de | ||
|
|
f611cc97f7 | ||
|
|
a571b061dd | ||
|
|
ff5e19c172 | ||
|
|
05b8b2d3ae | ||
|
|
9adfcfdd30 | ||
|
|
e43d3f7cd4 | ||
|
|
9e556292e6 | ||
|
|
e022e53ac9 | ||
|
|
5d52a060f0 | ||
|
|
c1dd732ffb | ||
|
|
7ceabaef73 | ||
|
|
be51239dde | ||
|
|
39d84dc088 | ||
|
|
01438f3b25 | ||
|
|
ea88ee2c4e | ||
|
|
d9a301cb80 | ||
|
|
a2e4e738eb | ||
|
|
a19774ea2d | ||
|
|
8827011e04 | ||
|
|
aa9e65ba60 | ||
|
|
5a623fe06e | ||
|
|
c9d3563a4e | ||
|
|
cd1ee087ec | ||
|
|
d056a5b61e | ||
|
|
1a683f68e8 | ||
|
|
5489432c65 | ||
|
|
97fe8c56e6 | ||
|
|
d786eebb6f | ||
|
|
36cee94757 | ||
|
|
3a2d75c7dc | ||
|
|
5da85d7ad8 | ||
|
|
dc5ffc6398 | ||
|
|
5e24682ac9 | ||
|
|
e7c13af66a | ||
|
|
0ae99c18f1 | ||
|
|
59470bd980 | ||
|
|
45e4517d86 | ||
|
|
9c6920114f | ||
|
|
bf70448c55 | ||
|
|
101798c4fa | ||
|
|
4a3cf0e006 | ||
|
|
25c313be0f | ||
|
|
55a0291af9 | ||
|
|
d1e3358bc7 | ||
|
|
5a8a122476 | ||
|
|
8ca0c18b78 | ||
|
|
748704629a | ||
|
|
c21712295a | ||
|
|
b5d88fc90f | ||
|
|
45c4c8302b | ||
|
|
3ba02ddd51 | ||
|
|
d0d10fbf65 | ||
|
|
5e0ba010f4 | ||
|
|
77d72417d3 | ||
|
|
8021ba07ed | ||
|
|
c2a50600eb | ||
|
|
74cd03b0ff | ||
|
|
11873d14d1 | ||
|
|
82261fe3f3 | ||
|
|
d961a6d683 | ||
|
|
f762a1fcd5 | ||
|
|
729229c565 | ||
|
|
328edf0dbc | ||
|
|
8142e50df0 | ||
|
|
9ac53fc1b7 | ||
|
|
8037be691e | ||
|
|
37f9e2f10b | ||
|
|
c3e5a08faf | ||
|
|
8065dbc265 | ||
|
|
cbc8327c80 | ||
|
|
6eefd684fa | ||
|
|
bf5baa4a65 | ||
|
|
3bba03b331 | ||
|
|
01920931ee | ||
|
|
11139134f9 | ||
|
|
895f6789df | ||
|
|
778a86952a | ||
|
|
f9d547a6b6 | ||
|
|
8f6134187b | ||
|
|
248541f353 | ||
|
|
03d1763ed0 | ||
|
|
546c2bbdd1 | ||
|
|
d3bf02d740 | ||
|
|
5210d8fd77 | ||
|
|
6d34e7de66 | ||
|
|
c28a94334e | ||
|
|
e68699576f | ||
|
|
28111ef588 | ||
|
|
9b24e16d8f | ||
|
|
77fd9afe0b | ||
|
|
4e4e89ec94 | ||
|
|
5305636723 | ||
|
|
5105223e36 | ||
|
|
93a055f92d | ||
|
|
5125e6695f | ||
|
|
15036ed594 | ||
|
|
16124da5bd | ||
|
|
20906355e5 | ||
|
|
46f5b80120 | ||
|
|
5ee1e5deda | ||
|
|
bbfdbdd2bc | ||
|
|
f9a83f32ed | ||
|
|
13ef358fa3 | ||
|
|
c7db2a0d18 | ||
|
|
f5753a0949 | ||
|
|
eb72f566fe | ||
|
|
afe4955258 | ||
|
|
a4a3c3780e | ||
|
|
411732d328 | ||
|
|
1ec1adfd2b | ||
|
|
fe8682e05c | ||
|
|
5c56fa53d5 | ||
|
|
2e49ec0965 | ||
|
|
0f5d0416da | ||
|
|
7769fdecc9 | ||
|
|
12048edba7 | ||
|
|
c18d2d2d9b | ||
|
|
268a6ce6e5 | ||
|
|
94153f9d9a | ||
|
|
4994e81add | ||
|
|
118fec22f5 | ||
|
|
23832438a8 | ||
|
|
d8e5a43a55 | ||
|
|
6de980672c | ||
|
|
f52b3b9232 | ||
|
|
512f8101dd | ||
|
|
d4b543793e | ||
|
|
b2d5f25948 | ||
|
|
d6a8c865c9 | ||
|
|
c163700841 | ||
|
|
9236ee4e55 | ||
|
|
20816696bc | ||
|
|
9f78508a18 | ||
|
|
b7ed73f454 | ||
|
|
3da1c107ce | ||
|
|
3e0e4a2573 | ||
|
|
f41d59b74b | ||
|
|
7195684a73 | ||
|
|
970917e645 | ||
|
|
c254f62a82 | ||
|
|
0a7ae1813d | ||
|
|
0cd8488422 | ||
|
|
85efd42663 | ||
|
|
aa17667791 | ||
|
|
8c46b02bde | ||
|
|
877315d7a1 | ||
|
|
3df6015486 | ||
|
|
0b7bb950a1 | ||
|
|
5b3008e9d7 | ||
|
|
ac4bee1000 | ||
|
|
1063d4e71c | ||
|
|
cf4d94f63e | ||
|
|
254d004deb | ||
|
|
b1bbbaed2f | ||
|
|
471a9e2114 | ||
|
|
b1278a9b38 | ||
|
|
4dd0934c1f | ||
|
|
9ba8a4cd7a | ||
|
|
775a2bdfa9 | ||
|
|
d2a171632b | ||
|
|
046f653636 | ||
|
|
424f9f36de | ||
|
|
6864b9e6bb | ||
|
|
3c43c98c97 | ||
|
|
afe526ddd4 | ||
|
|
02a203e97d | ||
|
|
0490a88ecc | ||
|
|
7c4dd0b039 | ||
|
|
adc6e764c1 | ||
|
|
7a03353212 | ||
|
|
7452bd683c | ||
|
|
1815cba610 | ||
|
|
3dae46a3bb | ||
|
|
0330ace434 | ||
|
|
78b2a0d462 | ||
|
|
4cde5f1dea | ||
|
|
6b1c874f5e | ||
|
|
94456501c0 | ||
|
|
0affc61d05 | ||
|
|
c03519e3bd | ||
|
|
3c9cf26c08 | ||
|
|
a6175769eb | ||
|
|
a376e3dfe1 | ||
|
|
acd2391eb4 | ||
|
|
af07f27c87 | ||
|
|
9e9814dc6b | ||
|
|
cb8fb8b926 | ||
|
|
854f12c2e4 | ||
|
|
a1067f5e4f | ||
|
|
a84ea657b7 | ||
|
|
20d2bd3432 | ||
|
|
17b99aead1 | ||
|
|
65464472e7 | ||
|
|
932bf6c157 | ||
|
|
2c54461432 | ||
|
|
de0c2fb65b | ||
|
|
ccae7bf84c | ||
|
|
070b6eb1e1 | ||
|
|
07135e3e7c | ||
|
|
651d8bcfd9 | ||
|
|
ff5df98644 | ||
|
|
d0a9799718 | ||
|
|
64f06b2ae5 | ||
|
|
756495376d | ||
|
|
9be511e283 | ||
|
|
4ce52714ee | ||
|
|
08c69d3f13 | ||
|
|
e1d312c881 | ||
|
|
9a83cf6142 | ||
|
|
f15b8de630 | ||
|
|
79a65746fb | ||
|
|
bf54466875 | ||
|
|
66d768d00f | ||
|
|
85bb33205e | ||
|
|
89550990af | ||
|
|
73603f89b7 | ||
|
|
063482716d | ||
|
|
2fccee72cf | ||
|
|
6ae02d37da | ||
|
|
809e18e951 | ||
|
|
8ac26761cf | ||
|
|
778218f3d1 | ||
|
|
47e0a76478 | ||
|
|
f7479fdf6d | ||
|
|
ee58a29394 | ||
|
|
481b04033b | ||
|
|
95afd3fce8 | ||
|
|
2673441c36 | ||
|
|
de0fad35c5 | ||
|
|
28d3f43ed6 | ||
|
|
f25c79f631 | ||
|
|
bf3e80bdfb | ||
|
|
5fc0b3079a | ||
|
|
e227e46906 | ||
|
|
d0c35254ca | ||
|
|
f2974eca7c | ||
|
|
c1163ee723 | ||
|
|
500adf3b78 | ||
|
|
96c79befb1 | ||
|
|
af0d6ea44f | ||
|
|
ae15bf6a52 | ||
|
|
412ba17e50 | ||
|
|
a7d7f2b87c | ||
|
|
bbeec89638 | ||
|
|
03f4346e0e | ||
|
|
6776865430 | ||
|
|
7a372654ab | ||
|
|
e840307e70 | ||
|
|
4b584bd6e7 | ||
|
|
39f7932ebe | ||
|
|
213f27fab0 | ||
|
|
09b4081581 | ||
|
|
afe96b3187 | ||
|
|
a3c6f99c43 | ||
|
|
c16b3a1bcd | ||
|
|
705526e13a | ||
|
|
b6c86cb522 | ||
|
|
95ccc6f950 | ||
|
|
4d1938b975 | ||
|
|
aae31cbb4e | ||
|
|
fbe8306d62 | ||
|
|
d7d9437ba5 | ||
|
|
97b09b011d | ||
|
|
17fe0bdc88 | ||
|
|
b36eb0afe4 | ||
|
|
275da3343a | ||
|
|
d18e28e8a9 | ||
|
|
9b2f0895d8 | ||
|
|
12441d0a45 | ||
|
|
e531200e2e | ||
|
|
745604631b | ||
|
|
f403e4ffa5 | ||
|
|
226fde0980 | ||
|
|
4c1dca3153 | ||
|
|
63acbbc86f | ||
|
|
b70789bc30 | ||
|
|
a28a04e8bf | ||
|
|
5c24615b8e | ||
|
|
5ac8d1262d | ||
|
|
dbe39c61a4 | ||
|
|
e0455447d3 | ||
|
|
3ccbbcd8a1 | ||
|
|
3a9cee8911 | ||
|
|
25e298e466 | ||
|
|
2ddba25909 | ||
|
|
c9c1953630 | ||
|
|
3598150462 | ||
|
|
3855390263 | ||
|
|
b8d219f229 | ||
|
|
80a3652814 | ||
|
|
7859850cf1 | ||
|
|
3cc6596463 | ||
|
|
a442e31d1d | ||
|
|
73e31db63f | ||
|
|
3b6fc07fc4 | ||
|
|
e80d0c166c | ||
|
|
b1629e1816 | ||
|
|
a9465b2e16 | ||
|
|
b2d05b6402 | ||
|
|
a34636e4d5 | ||
|
|
36685cad15 | ||
|
|
d16b9b4148 | ||
|
|
e0a9b964d6 | ||
|
|
ea2d00cd58 | ||
|
|
7ba6963a24 | ||
|
|
8525714531 | ||
|
|
b0e3fff6b7 | ||
|
|
b755994c44 | ||
|
|
796cf24672 | ||
|
|
6efc4324f8 | ||
|
|
61818d1b75 | ||
|
|
50f9cab76d | ||
|
|
f5b4b9a9d2 | ||
|
|
5d7b2bdf33 | ||
|
|
be7a7a2f73 | ||
|
|
f318ce28cc | ||
|
|
0b03d8f002 | ||
|
|
a12a1da03f | ||
|
|
3731593ada | ||
|
|
788806e026 | ||
|
|
bbf586f7c3 | ||
|
|
a1f8e94c41 | ||
|
|
cb0d5300e7 | ||
|
|
bbcda0ed92 | ||
|
|
4cc219bb03 | ||
|
|
2002e778c4 | ||
|
|
dcc3cec023 | ||
|
|
989c38f377 | ||
|
|
10a6b6dbba | ||
|
|
77018b00a3 | ||
|
|
457a1a8af1 | ||
|
|
fea65c7891 | ||
|
|
ce2b0a27ae | ||
|
|
646b03e5a9 | ||
|
|
2a0ac8fa72 | ||
|
|
df12da1419 | ||
|
|
0cc3f47f74 | ||
|
|
a5971bb38e | ||
|
|
588a452f79 | ||
|
|
51246f60cc | ||
|
|
fc6c134b5c | ||
|
|
0eead9baa7 | ||
|
|
fdd1802425 | ||
|
|
c8dcb28439 | ||
|
|
1f3b2dbc59 | ||
|
|
0bb1f9d65a | ||
|
|
33b904ce83 | ||
|
|
0a7785f71d | ||
|
|
537765af6e | ||
|
|
d2232163c1 | ||
|
|
365f56902b | ||
|
|
d49555c5e1 | ||
|
|
07ce50972f | ||
|
|
40ef51a882 | ||
|
|
3e862e6e58 | ||
|
|
8beda564e7 | ||
|
|
fa2333ae79 | ||
|
|
9b0a521651 | ||
|
|
0b03494fb4 | ||
|
|
c6829237c7 | ||
|
|
d0b0edd967 | ||
|
|
bc9985bca7 | ||
|
|
705f25a257 | ||
|
|
6b634e4ec4 | ||
|
|
d657cbd0dd | ||
|
|
23d241ed66 | ||
|
|
43b73120ce | ||
|
|
443c874751 | ||
|
|
1d5983d774 | ||
|
|
b4f642a056 | ||
|
|
637b6ba14e | ||
|
|
2c9306431e | ||
|
|
0bd43e7644 | ||
|
|
d4b59971f0 | ||
|
|
149a45afac | ||
|
|
2465a110d2 | ||
|
|
c8cbeb3b49 | ||
|
|
dedb96e5cb | ||
|
|
9323453184 | ||
|
|
d661c8b4ce | ||
|
|
6a95636733 | ||
|
|
1b0a8bf8de | ||
|
|
8bf18ac3c6 | ||
|
|
61a91ca4a9 | ||
|
|
5e281eb967 | ||
|
|
91be6cad03 | ||
|
|
f0b29d0266 | ||
|
|
4ec6b01e6a | ||
|
|
58a1ada322 | ||
|
|
195ee0446a | ||
|
|
629080cfb3 | ||
|
|
2390e06ad3 | ||
|
|
b6a3e39cae | ||
|
|
a09cb81ede | ||
|
|
cceeb0c999 | ||
|
|
05f0b3ebae | ||
|
|
25f240a5f1 | ||
|
|
6c569b72f2 | ||
|
|
548312ea34 | ||
|
|
1c1702b11d | ||
|
|
eb09f196e5 | ||
|
|
d122518bcf | ||
|
|
fd53b95457 | ||
|
|
76af835e2e | ||
|
|
90a196d3bc | ||
|
|
ae928dbee1 | ||
|
|
fa701e81cf | ||
|
|
c44e502dab | ||
|
|
8669b0f183 | ||
|
|
2b9e7b1166 | ||
|
|
5a00e5c79f | ||
|
|
887fa9ff4c | ||
|
|
ac962ce70d | ||
|
|
21866cc94f | ||
|
|
497c8dbd94 | ||
|
|
40cd6b43cb | ||
|
|
84b3392e9a | ||
|
|
b654ab1b54 | ||
|
|
1639b73a0d | ||
|
|
74163d2edf | ||
|
|
a35742fc64 | ||
|
|
2768b3445f | ||
|
|
7c0eaa2805 | ||
|
|
7763337e37 | ||
|
|
c93fcd2c0f | ||
|
|
ae20589b1a | ||
|
|
6e2005c6c9 | ||
|
|
d7f3ff6e06 | ||
|
|
75b6d14aac | ||
|
|
f250854243 | ||
|
|
bfd1b40482 | ||
|
|
941bf7c30e | ||
|
|
28f14a7b42 | ||
|
|
a3dc1118f8 | ||
|
|
8b9ca0541a | ||
|
|
6680d33abb | ||
|
|
4e6ae10528 | ||
|
|
c728f2fd05 | ||
|
|
aa54f50116 | ||
|
|
233c89b7ad | ||
|
|
f9775eb3ce | ||
|
|
d8adfb132a | ||
|
|
ebd8a66d05 | ||
|
|
024d4b93a3 | ||
|
|
a04e0eddc7 | ||
|
|
0c1e3ee82d | ||
|
|
e65004c12e | ||
|
|
e61a83e5ad | ||
|
|
10d126cbe7 | ||
|
|
39df65b111 | ||
|
|
d8c39f6463 | ||
|
|
b97c13b487 | ||
|
|
71c8f41bd4 | ||
|
|
eeea9d7fdc | ||
|
|
e46deea6c5 | ||
|
|
0e30d2f5ee | ||
|
|
5310fec246 | ||
|
|
c2634d2dc3 | ||
|
|
d1254391aa | ||
|
|
3dae51062d | ||
|
|
86e454077a | ||
|
|
7d032a3e4a | ||
|
|
b4b6ff015e | ||
|
|
db647ba73a | ||
|
|
5dd5de04a8 | ||
|
|
bfbeb8dafc | ||
|
|
577590b1eb | ||
|
|
c828e8b111 | ||
|
|
9109e247db | ||
|
|
fe29db24cf | ||
|
|
3c8079aee2 | ||
|
|
ee82a47abb | ||
|
|
7251ee1b18 | ||
|
|
1582bca318 | ||
|
|
0615c78075 | ||
|
|
fbb80124db | ||
|
|
3430b25b5e | ||
|
|
def0ce4840 | ||
|
|
ed89d0a5a8 | ||
|
|
7af96fec84 | ||
|
|
d8fd027415 | ||
|
|
4441e04472 | ||
|
|
c5bec028c0 | ||
|
|
bd6008d5a7 | ||
|
|
fc4157127a | ||
|
|
ea3c9d085e | ||
|
|
1b1a104cc4 | ||
|
|
6d43d90367 | ||
|
|
3323449eea | ||
|
|
c72ca2baa0 | ||
|
|
d4e6fff86e | ||
|
|
06c96900ec | ||
|
|
a0dd21bed5 | ||
|
|
b25c0f9850 | ||
|
|
f9ab88c9e4 | ||
|
|
3238a3eca4 | ||
|
|
8685846be3 | ||
|
|
2ebfa4185b | ||
|
|
c4b4c8d9e0 | ||
|
|
60dd509fcb | ||
|
|
b6c67c320e | ||
|
|
e4676a18fe | ||
|
|
a5b0758b67 | ||
|
|
27ba69fa43 | ||
|
|
14b162b098 | ||
|
|
f1e9a6f1e8 | ||
|
|
00c8164201 | ||
|
|
206d1e03bb | ||
|
|
c180263e3f | ||
|
|
8872c65ba2 | ||
|
|
abe79fb351 | ||
|
|
b76a014432 | ||
|
|
c7b9e15cef | ||
|
|
fade6da4e2 | ||
|
|
86c67bfe52 | ||
|
|
6cda366bc2 | ||
|
|
2771c6c5d1 | ||
|
|
7ba541843b | ||
|
|
47ac4d5894 | ||
|
|
6c424946fe | ||
|
|
b4e5b10299 | ||
|
|
efeb9019a6 | ||
|
|
5b994a58da | ||
|
|
1f7cd879a8 | ||
|
|
73a67d3b0c | ||
|
|
4d95c55361 | ||
|
|
8576933f7d | ||
|
|
ffbbe29ef6 | ||
|
|
0d030d0ca7 | ||
|
|
8b45ddd4ef | ||
|
|
cff73e9e67 | ||
|
|
a7fa150836 | ||
|
|
7225117fea | ||
|
|
3f44016db1 | ||
|
|
c0dc2c5908 | ||
|
|
8a0ebb77eb | ||
|
|
4ebb0acbfe | ||
|
|
b4831c4f09 | ||
|
|
17563f1856 | ||
|
|
486cf4c74d | ||
|
|
0528f0ebc6 | ||
|
|
ce43c2ba84 | ||
|
|
f37bb34cdf | ||
|
|
3fb60fa2c5 | ||
|
|
e59c1a5d3a | ||
|
|
3831a7d1f0 | ||
|
|
f7aee7c797 | ||
|
|
68b0a65288 | ||
|
|
7633319f2a | ||
|
|
ca8ca25a3f | ||
|
|
a96657d600 | ||
|
|
bf664a4314 | ||
|
|
8dd5bec27f | ||
|
|
e11ae8b2cf | ||
|
|
c8f070cf7d | ||
|
|
cc76a19fe3 | ||
|
|
d0b4ca57d1 | ||
|
|
18d103d202 | ||
|
|
56241cee40 | ||
|
|
061874fa46 | ||
|
|
c1d22c98ef | ||
|
|
06c7afd21a | ||
|
|
ecb360eabd | ||
|
|
56941722aa | ||
|
|
2452d753af | ||
|
|
2085a725b0 | ||
|
|
b67f99e8ea | ||
|
|
eee5dd7fa2 | ||
|
|
9c5e2bd4c9 | ||
|
|
87efd2dcf3 | ||
|
|
170e1a9cb5 | ||
|
|
7d4ef278cd | ||
|
|
05c6d3447a | ||
|
|
ef9f8d2000 | ||
|
|
9d192b61ea | ||
|
|
d4d7e96c15 | ||
|
|
918fa83388 | ||
|
|
34f26bb3bd | ||
|
|
ccbfa6cf00 | ||
|
|
bcb429ec7f | ||
|
|
5f38d74cfc | ||
|
|
5111c354c1 | ||
|
|
643b2e9975 | ||
|
|
d9bc12b05e | ||
|
|
f7e6de8594 | ||
|
|
8275088bda | ||
|
|
06dd7a5555 | ||
|
|
4fa6bccaa7 | ||
|
|
7df7e3700b | ||
|
|
adf1b2692a | ||
|
|
b57d3364a3 | ||
|
|
48e67537c1 | ||
|
|
fe7455e379 | ||
|
|
01e4f20c68 | ||
|
|
bf066d6156 | ||
|
|
20bf1fd89d | ||
|
|
f2a470f943 | ||
|
|
845077ff35 | ||
|
|
ff03e29b3f | ||
|
|
fad9a4873f | ||
|
|
ad21d93863 | ||
|
|
4d366d06cd | ||
|
|
197a3c956e | ||
|
|
f8371c461d | ||
|
|
02f0855d3d | ||
|
|
22a4085978 | ||
|
|
acae93e9cf | ||
|
|
803cf8f109 | ||
|
|
4af2de9fee | ||
|
|
d916789acb | ||
|
|
54d120c296 | ||
|
|
a84cbbd209 | ||
|
|
295b6f268e | ||
|
|
a1e674f61d | ||
|
|
bf1f896b39 | ||
|
|
eeb2b40138 | ||
|
|
60ff394785 | ||
|
|
149c017099 | ||
|
|
233d6c150c | ||
|
|
96aa95f9d7 | ||
|
|
7e1a8a704a | ||
|
|
cd769921b9 | ||
|
|
7d33952145 | ||
|
|
58f1134254 | ||
|
|
6d1f2830d1 | ||
|
|
d103dd74f9 | ||
|
|
cd0f238b97 | ||
|
|
d7a475adfd | ||
|
|
ccfb6b422c | ||
|
|
2c8143ddb0 | ||
|
|
f9892c598c | ||
|
|
3eb79fd6d2 | ||
|
|
8ddceada42 | ||
|
|
a1c355d4c9 | ||
|
|
5c23459e1e | ||
|
|
af3dbc928b | ||
|
|
bd1bc7f06a | ||
|
|
7f16b992eb | ||
|
|
460884cbd8 | ||
|
|
0cc99eadde | ||
|
|
24bf010d98 | ||
|
|
e74adedf88 | ||
|
|
a34d03f422 | ||
|
|
c0a9be3c7d | ||
|
|
8f352d9115 | ||
|
|
6ca306405c | ||
|
|
d4190b2fde | ||
|
|
30ed0bdcf3 | ||
|
|
c3e2c3ee9e | ||
|
|
155f8520d4 | ||
|
|
55b548d3ca | ||
|
|
8eff09ff6e | ||
|
|
59596653a2 | ||
|
|
4df76391cb | ||
|
|
822f1d26b8 | ||
|
|
55a42ab0e2 | ||
|
|
cdf3521154 | ||
|
|
820b530240 | ||
|
|
1823f61748 | ||
|
|
cffc7750b9 | ||
|
|
838109ccd5 | ||
|
|
67f413cc59 | ||
|
|
c498332c36 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
[*.java]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
ij_continuation_indent_size = 8
|
||||
ij_java_names_count_to_use_import_on_demand = 9999
|
||||
ij_java_class_count_to_use_import_on_demand = 9999
|
||||
@@ -35,11 +35,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v6
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -64,4 +64,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
@@ -10,13 +10,13 @@ jobs:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v6
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
@@ -28,43 +28,43 @@ jobs:
|
||||
run: chmod +x gradlew && ./gradlew build
|
||||
|
||||
- name: Upload build artifacts api
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: api-build
|
||||
path: api/build/libs
|
||||
path: build/libs/packetevents-api-*.jar
|
||||
|
||||
- name: Upload build artifacts spigot
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: spigot-build
|
||||
path: spigot/build/libs
|
||||
path: build/libs/packetevents-spigot-*.jar
|
||||
|
||||
- name: Upload build artifacts netty-common
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: netty-common-build
|
||||
path: netty-common/build/libs
|
||||
path: build/libs/packetevents-netty-common-*.jar
|
||||
|
||||
- name: Upload build artifacts bungeecord
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: bungeecord-build
|
||||
path: bungeecord/build/libs
|
||||
path: build/libs/packetevents-bungeecord-*.jar
|
||||
|
||||
- name: Upload build artifacts velocity
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: velocity-build
|
||||
path: velocity/build/libs
|
||||
path: build/libs/packetevents-velocity-*.jar
|
||||
|
||||
- name: Upload build artifacts fabric
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: fabric-build
|
||||
path: fabric/build/libs
|
||||
path: build/libs/packetevents-fabric-*.jar
|
||||
|
||||
- name: Upload build artifacts sponge
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: sponge-build
|
||||
path: sponge/build/libs
|
||||
path: build/libs/packetevents-sponge-*.jar
|
||||
@@ -12,13 +12,13 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v6
|
||||
|
||||
- name: Setup java 21
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: temurin
|
||||
|
||||
@@ -126,3 +126,5 @@ run/
|
||||
|
||||
# Build Source Kotlin
|
||||
/buildSrc/.kotlin/
|
||||
|
||||
.env
|
||||
+418
@@ -1,3 +1,421 @@
|
||||
!!!!! v2.14.0
|
||||
|
||||
# PacketEvents 2.14.0 is finally out! 🎉
|
||||
|
||||
This minor release includes mainly support for Minecraft 26.3, but also includes a few smaller fixes and improvements.
|
||||
|
||||
Recent donors: **@PebbleHost, Aurel (Advanced GUI), @zer0origin**\
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢
|
||||
|
||||
Visit our website: https://packetevents.com/ \
|
||||
Documentation: https://docs.packetevents.com/ \
|
||||
Javadoc: https://javadocs.packetevents.com/
|
||||
|
||||
Thanks to all contributors who helped make this release possible:
|
||||
- @booky10
|
||||
- @Bram1903
|
||||
- @carragrive
|
||||
- @ChengZhiMeow
|
||||
- @Jan1k1
|
||||
- @ManInMyVan
|
||||
- @R00tB33rMan
|
||||
- @ThatApplePieGuy
|
||||
- @TheFaser
|
||||
|
||||
## What's Changed
|
||||
|
||||
* Add support for 26.3 ([#1582](https://github.com/retrooper/packetevents/pull/1582))
|
||||
* Fix state type in wrapper for `block_event` packet ([#1571](https://github.com/retrooper/packetevents/pull/1571))
|
||||
* Fix dialog body encoding for versions prior to 26.1 ([`2e49ec0`](https://github.com/retrooper/packetevents/commit/2e49ec0965d949de69f54f6f2eea5be75ca25ac0))
|
||||
* Fix equippable item component ([#1573](https://github.com/retrooper/packetevents/pull/1573))
|
||||
* Prevent null types in ItemStack ([#1574](https://github.com/retrooper/packetevents/pull/1574))
|
||||
* Fix errors in WrapperPlayServerUseBed copying ([#1580](https://github.com/retrooper/packetevents/pull/1580))
|
||||
* Add short Javadoc to bundle packet wrapper ([#1570](https://github.com/retrooper/packetevents/pull/1570))
|
||||
* Minor NBT component serializer performance improvements ([#1549](https://github.com/retrooper/packetevents/pull/1549))
|
||||
* Fix limits for clientbound `custom_payload` packets ([#1566](https://github.com/retrooper/packetevents/pull/1566))
|
||||
* Implement `Location#equals` ([#1561](https://github.com/retrooper/packetevents/pull/1561))
|
||||
* Fix Vector3i decode for versions prior to 1.14 ([`f52b3b9`](https://github.com/retrooper/packetevents/commit/f52b3b92323b380f2ffb061ebd8e22ef1836d75c)
|
||||
* Fix interact action in 1.7 ([#1562](https://github.com/retrooper/packetevents/pull/1562))
|
||||
* Fix NBT Component serialization bug with numbers ([#1543](https://github.com/retrooper/packetevents/pull/1543))
|
||||
|
||||
**View Full Changelog**: [`v2.13.0...v2.14.0`](https://github.com/retrooper/packetevents/compare/v2.13.0...v2.14.0)
|
||||
|
||||
!!!!! v2.13.0
|
||||
|
||||
# PacketEvents 2.13.0 is finally out! 🎉
|
||||
|
||||
This minor release includes mainly support for Minecraft 26.2, but also includes a few smaller fixes and improvements.
|
||||
|
||||
Recent donors: **@PebbleHost**\
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢
|
||||
|
||||
Visit our website: https://packetevents.com/ \
|
||||
Documentation: https://docs.packetevents.com/ \
|
||||
Javadoc: https://javadocs.packetevents.com/
|
||||
|
||||
Thanks to all contributors who helped make this release possible:
|
||||
- @booky10
|
||||
- @Jan1k1
|
||||
- @linsaftw
|
||||
- @rafi67000
|
||||
- @retrooper
|
||||
- @Rothes
|
||||
- @TheFaser
|
||||
|
||||
## What's Changed
|
||||
|
||||
* Improve chunk reading performance ([#1526](https://github.com/retrooper/packetevents/pull/1526))
|
||||
* Add PluginMessage Common Wrapper ([#1523](https://github.com/retrooper/packetevents/pull/1523))
|
||||
* Fix custom world clock use in dimension types ([`7c4dd0b`](https://github.com/retrooper/packetevents/commit/7c4dd0b039e695e5ae7d9c0562082f913cbb2677))
|
||||
* Add support for 26.2 ([#1529](https://github.com/retrooper/packetevents/pull/1529), [`471a9e2`](https://github.com/retrooper/packetevents/commit/471a9e21144f0ea56e4053bda0477cca8402dc69), [`b1bbbae`](https://github.com/retrooper/packetevents/commit/b1bbbaed2f7bd8e09ff758bfa02f9b63df21c3b1))
|
||||
* Update Gradle, Gradle plugins and actions ([#1533](https://github.com/retrooper/packetevents/pull/1533), [#1534](https://github.com/retrooper/packetevents/pull/1534))
|
||||
* Fix nullability annotations for ProtcolManager/PlayerManager ([#1535](https://github.com/retrooper/packetevents/pull/1535))
|
||||
* Ignore udp listeners during injection ([#1537](https://github.com/retrooper/packetevents/pull/1537))
|
||||
|
||||
**View Full Changelog**: [`v2.12.2...v2.13.0`](https://github.com/retrooper/packetevents/compare/v2.12.2...v2.13.0)
|
||||
|
||||
!!!!! v2.12.2
|
||||
# PacketEvents 2.12.2 is finally out! 🎉
|
||||
|
||||
This patch release contains a few critical bug fixes as well as some optimizations and reworks.
|
||||
|
||||
Recent donors: **@PebbleHost, @perlsol, @TRGReal**\
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
Unfortunately, the PacketEvents PayPal account is no longer active. I hope to resolve any concerns with PayPal, who has frozen funds and activity on the account. If you want to donate, please use [GitHub Sponsors](https://github.com/sponsors/retrooper) or the newly setup [BuyMeACoffee](https://buymeacoffee.com/retrooper).
|
||||
|
||||
Thanks to all contributors who helped make this release possible:
|
||||
- @booky10
|
||||
- @Beaness
|
||||
- @SamB440
|
||||
- @retrooper
|
||||
- @LeonTG
|
||||
|
||||
## What's Changed
|
||||
* Rework logging system in PacketEvents (now more consistently used across API) [`a1067f5`](https://github.com/retrooper/packetevents/commit/a1067f5e4f53bcd7fbeaa19fb4d8046a3f6248ca)
|
||||
* Optimize SpigotReflectionUtil.generateEntityId() method [`95afd3f`](https://github.com/retrooper/packetevents/commit/95afd3fce8bfbf7087233a3bd31e0705cd1e4df5)
|
||||
* Fix transmission/copying of packet wrappers when dealing with multiple packet listeners for the following wrappers: WrapperLoginServerLoginSuccess, WrapperPlayServerDeclareCommands, WrapperPlayServerMapData, WrapperPlayServerPlayerRotation, WrapperPlayServerSpawnWeatherEntity [`20d2bd3`](https://github.com/retrooper/packetevents/commit/20d2bd34326ea9fab602ff07333fcfc713ae6ced)
|
||||
* Allow for the customization of chat message length limit for legacy Minecraft versions [`a1067f5`](https://github.com/retrooper/packetevents/commit/a1067f5e4f53bcd7fbeaa19fb4d8046a3f6248ca)
|
||||
* Multiple fixes for WrapperPlayServerSoundEffect [`66d768d`](https://github.com/retrooper/packetevents/commit/66d768d00f6f69c71a9ba27998976a6d2b5020f7), [`73603f8`](https://github.com/retrooper/packetevents/commit/73603f89b7aafab6ff7eed7be488b03fa5e064dc)
|
||||
* Fix incorrect swapping of pitch and yaw for WrapperPlayServerSpawnEntity on Minecraft versions lower than 1.15 [`0634827`](https://github.com/retrooper/packetevents/commit/063482716d0fd858bef8e65b9c4714c8e1fd4aa9)
|
||||
* Fix injection cleanup issues on Velocity ([#1489](https://github.com/retrooper/packetevents/issues/1489), [`cb8fb8b`](https://github.com/retrooper/packetevents/commit/cb8fb8b9268f7fb83f2a931432757d7d36ae220b))
|
||||
|
||||
**View Full Changelog**: [`v2.12.1...v2.12.2`](https://github.com/retrooper/packetevents/compare/v2.12.1...v2.12.2)
|
||||
|
||||
!!!!! v2.12.1
|
||||
|
||||
# PacketEvents 2.12.1 is finally out! 🎉
|
||||
|
||||
This patch release includes mainly bugfixes related to Minecraft 26.1, but also includes a few smaller features.
|
||||
|
||||
Recent donors: **PebbleHost, JustUsBuilds, matsu1213**\
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢
|
||||
|
||||
Visit our website: https://packetevents.com/ \
|
||||
Documentation: https://docs.packetevents.com/ \
|
||||
Javadoc: https://javadocs.packetevents.com/
|
||||
|
||||
Thanks to all contributors which helped make this release possible:
|
||||
- @Beaness
|
||||
- @booky10
|
||||
- @ieatglu3
|
||||
- @ManInMyVan
|
||||
- @rafi67000
|
||||
- @retrooper
|
||||
- @roggy666
|
||||
- @vadim-soude
|
||||
- @Vrganj
|
||||
- @ytnoos
|
||||
|
||||
## What's Changed
|
||||
|
||||
* Fix minor issues related to 26.1 ([#1483](https://github.com/retrooper/packetevents/pull/1483), [`f2974ec`](https://github.com/retrooper/packetevents/commit/f2974eca7c919ca60266016339991ea0e28a17bb))
|
||||
* Add WrapperPlayServerChunkBiomes ([#1383](https://github.com/retrooper/packetevents/pull/1383))
|
||||
* Mark 26.1.2 as fully supported ([`4d1938b`](https://github.com/retrooper/packetevents/commit/4d1938b97564633900d3a73061ad137b680e8fa1))
|
||||
* Track chunk section fluid count ([#1477](https://github.com/retrooper/packetevents/pull/1477))
|
||||
* Add support for adventure v5 ([`bbeec89...c1163ee`](https://github.com/retrooper/packetevents/compare/bbeec896384e22844a51ab28b9bc4c91f8f1daf0...c1163ee7232c9084ae25b3e2e2a6f44d602ec737))
|
||||
|
||||
**View Full Changelog**: [`v2.12.0...v2.12.1`](https://github.com/retrooper/packetevents/compare/v2.12.0...v2.12.1)
|
||||
|
||||
!!!!! v2.12.0
|
||||
|
||||
# PacketEvents 2.12.0 is finally out! 🎉
|
||||
|
||||
This update primarily adds support for Minecraft 26.1.
|
||||
Again, huge thanks to all users who have donated their hard-earned money to PacketEvents since the previous release. It's been received & it's very much appreciated.
|
||||
|
||||
Recent donors: PebbleHost, Dylan\
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
Also, thanks to the contributors that made this update possible, especially @booky10. Open-source software thrives when it receives contributions from the community.
|
||||
|
||||
# Announcement 📢
|
||||
|
||||
Visit our website: https://packetevents.com\
|
||||
Documentation: https://docs.packetevents.com\
|
||||
JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Added support for Minecraft 26.1 (and 26.1.1)
|
||||
* Added support for changes to Fabric, leading to the addition of new internal modules.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.2...v2.12.0
|
||||
|
||||
### If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/packetevents), [Streamlabs](https://streamlabs.com/retrooper), or [GitHub Sponsors](https://github.com/sponsors/retrooper).
|
||||
|
||||
## Maven/Gradle Dependency Setup Guide
|
||||
|
||||
**Check it out**: https://docs.packetevents.com/introduction/development-setup/
|
||||
|
||||
|
||||
!!!!! v2.11.2
|
||||
|
||||
# PacketEvents 2.11.2 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Again, huge thanks to all users who have donated their hard-earned money to PacketEvents since the previous release. It's been received & it's very much appreciated.
|
||||
|
||||
Recent donors: PebbleHost, SSomar1607, ipavdev, Meed, frap
|
||||
|
||||
Also, thanks to the contributors that made this update possible.
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢⚠️
|
||||
|
||||
Visit our website: https://packetevents.com\
|
||||
Documentation: https://docs.packetevents.com\
|
||||
JavaDocs: https://javadocs.packetevents.com\
|
||||
I've released a new YouTube [video](https://youtu.be/G7qYRHpZVIo).
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed SynchronizedRegistriesHandler issues
|
||||
* Fixed various equality/nullability issues with Registry values
|
||||
* Explicitly specify 'Locale#ROOT' for all String#toLowerCaser() calls
|
||||
* Removed 'end skylight' for 1.21.8 and below
|
||||
* Log warning message when failing to uninject from velocity initializer
|
||||
* Recommend release builds (and fallback to development builds) to users who run outdated software.
|
||||
* Add 'CHAIN' to the 'CHAINS' tag
|
||||
* Add new offset(Blockface face, int i) method to Vector3f/d/i classes
|
||||
* Fixed 'infiniburn' tag parsing for 1.18.1 and older
|
||||
* Fixed unexpected NPE if bukkit entity is null during unsafe lookup
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.1...v2.11.2
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/packetevents) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper).
|
||||
|
||||
## Maven/Gradle Dependency Setup Guide
|
||||
|
||||
**Check it out**: https://docs.packetevents.com/introduction/development-setup/
|
||||
|
||||
|
||||
!!!!! v2.11.1
|
||||
|
||||
# PacketEvents 2.11.1 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Thanks to all users who donated after the previous release announcement. It's been received & it's appreciated.
|
||||
|
||||
Recent donors: TrekCraft, 3add, Vadim Soudé
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed 'Can't resolve 'minecraft:day' in 'minecraft:timeline' for V_1_21_11'
|
||||
* Fixed decoding & encoding for WrapperLoginServerPluginRequest & WrapperLoginClientPluginResponse
|
||||
* Improve StateTypes testing
|
||||
* Added system property packetevents.debug.nbt-codec-trace
|
||||
* Fixed Sound Codec
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.0...v2.11.1
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/packetevents) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.11.0
|
||||
|
||||
# PacketEvents 2.11.0 is finally out! 🎉
|
||||
|
||||
This update adds support for Minecraft 1.21.11.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for Minecraft 1.21.11
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.1...v2.11.0
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/packetevents) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.1
|
||||
|
||||
# PacketEvents 2.10.1 is finally out! 🎉
|
||||
|
||||
This update includes some bug fixes.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Fixed for certain particle types on 1.21.9 & 1.21.10 Minecraft
|
||||
* Fixed the bee's component on 1.21.9 & 1.21.10 Minecraft
|
||||
* Correction of 'mul' calculation in LpVector3d
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.0...v2.10.1
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.0
|
||||
|
||||
# PacketEvents 2.10.0 is finally out! 🎉
|
||||
|
||||
This update includes critical bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added 1.21.9 & 1.21.10 support
|
||||
* Various bug fixes (such as TPS reading, PlayerModelType reading/writing, and more)
|
||||
* Update adventure API
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.5...v2.10.0
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.5
|
||||
|
||||
# PacketEvents 2.9.5 is out now! 🎉
|
||||
|
||||
This update includes critical bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Injector bug fix (for Spigot)
|
||||
* WolfVariant issue fixed
|
||||
* Chunk Data error fixed
|
||||
* NBT tag issues fixed
|
||||
* Direction Y/Z axis being swapped fixed
|
||||
* Added WrappedBlockState to constructor of WrapperPlayServerBlockChange
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.4...v2.9.5
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.4
|
||||
|
||||
# PacketEvents 2.9.4 is out now! 🎉
|
||||
|
||||
This update includes minor bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added SpigotConversionUtil#getEntityMetadata to retrieve metadata from a Bukkit entity.
|
||||
* Fixed outdated 1.8 Spigot forks from being unable to load on PacketEvents.
|
||||
* Fixed WrapperPlayServerWorldBorder for versions lower than 1.12.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.3...v2.9.4
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.3
|
||||
|
||||
# PacketEvents 2.9.3 is out now! 🎉
|
||||
|
||||
This is an update that adds support for Minecraft 1.21.8 server builds.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for 1.21.8 Minecraft server builds.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.2...v2.9.3
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.2
|
||||
|
||||
# PacketEvents 2.9.2 is out now! 🎉
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<h2><i>PacketEvents</i></h2>
|
||||
<h3><i>A powerful networking library for Minecraft packet processing and manipulation.</i></h3>
|
||||
<h3>PacketEvents is a protocol library tailored to Minecraft Java Edition, designed to facilitate the processing and transmission of packets.</h3>
|
||||
<a href="https://github.com/retrooper/packetevents/actions"><img src="https://img.shields.io/github/actions/workflow/status/retrooper/packetevents/gradle-publish.yml?style=for-the-badge&logo=github"></a>
|
||||
<a href="https://discord.gg/DVHxPPxHZc"><img src="https://img.shields.io/discord/721686193061888071?color=5562e9&logo=discord&logoColor=white&style=for-the-badge"></a>
|
||||
<img src="https://img.shields.io/github/license/retrooper/packetevents?style=for-the-badge&logo=github">
|
||||
@@ -11,7 +11,7 @@
|
||||
<h3>Resources</h3>
|
||||
|
||||
- [Read documentation](https://docs.packetevents.com/)
|
||||
- [Getting Started](https://docs.packetevents.com/getting-started)
|
||||
- [Getting Started](https://docs.packetevents.com/development-setup)
|
||||
- [JavaDocs](https://javadocs.packetevents.com)
|
||||
- [Releases](https://github.com/retrooper/packetevents/releases/)
|
||||
- [Modrinth](https://modrinth.com/plugin/packetevents)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# Table of contents
|
||||
|
||||
* [Initial page](README.md)
|
||||
|
||||
+18
-1
@@ -2,6 +2,7 @@ import com.github.retrooper.compression.strategy.dir.JsonBase64DataDirStrategy
|
||||
import com.github.retrooper.compression.strategy.dir.JsonRegistryCompressionDirStrategy
|
||||
import com.github.retrooper.compression.strategy.dir.JsonToNbtDirStrategy
|
||||
import com.github.retrooper.excludeAdventure
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
|
||||
plugins {
|
||||
packetevents.`shadow-conventions`
|
||||
@@ -26,20 +27,30 @@ dependencies {
|
||||
api(project(":patch:adventure-text-serializer-gson", "shadow")) {
|
||||
excludeAdventure()
|
||||
}
|
||||
api(libs.adventure.text.serializer.legacy) {
|
||||
api(project(":patch:adventure-text-serializer-legacy", "shadow")) {
|
||||
excludeAdventure()
|
||||
}
|
||||
compileOnly(libs.gson)
|
||||
compileOnly(libs.adventure.text.logger.slf4j)
|
||||
compileOnly(libs.checkerqual)
|
||||
|
||||
testRuntimeOnly(testlibs.bundles.adventure)
|
||||
testRuntimeOnly(testlibs.bundles.adventure.serializers)
|
||||
testImplementation(libs.bundles.adventure)
|
||||
testImplementation(project(":patch:adventure-text-serializer-gson"))
|
||||
testImplementation(project(":patch:adventure-text-serializer-legacy"))
|
||||
testImplementation(libs.adventure.text.serializer.legacy)
|
||||
testImplementation(libs.adventure.text.logger.slf4j)
|
||||
testImplementation(project(":netty-common"))
|
||||
testImplementation(testlibs.mockbukkit)
|
||||
testImplementation(testlibs.paper.api)
|
||||
testImplementation(testlibs.slf4j)
|
||||
testImplementation(testlibs.bundles.junit)
|
||||
testImplementation(libs.netty)
|
||||
testImplementation(libs.classgraph)
|
||||
testImplementation(project(":spigot"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.2")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.2")
|
||||
}
|
||||
|
||||
mappingCompression {
|
||||
@@ -63,6 +74,9 @@ tasks {
|
||||
}
|
||||
|
||||
javadoc {
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.use(true)
|
||||
options.tags("versions:A:Minecraft Versions:")
|
||||
mustRunAfter(generateVersionsFile)
|
||||
}
|
||||
|
||||
@@ -85,6 +99,9 @@ tasks {
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
||||
@@ -20,25 +20,30 @@ package com.github.retrooper.packetevents;
|
||||
|
||||
import com.github.retrooper.packetevents.event.EventManager;
|
||||
import com.github.retrooper.packetevents.injector.ChannelInjector;
|
||||
import com.github.retrooper.packetevents.manager.InternalPacketListener;
|
||||
import com.github.retrooper.packetevents.manager.player.PlayerManager;
|
||||
import com.github.retrooper.packetevents.manager.protocol.ProtocolManager;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerManager;
|
||||
import com.github.retrooper.packetevents.netty.NettyManager;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import com.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||
import com.github.retrooper.packetevents.util.logger.JulLegacyLogManager;
|
||||
import com.github.retrooper.packetevents.util.LogManager;
|
||||
import com.github.retrooper.packetevents.util.PEVersion;
|
||||
//Note: The PEVersions class is generated. Refer to PEVersionTask.kt
|
||||
import com.github.retrooper.packetevents.util.PEVersions;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureConversionInjector;
|
||||
import com.github.retrooper.packetevents.util.mappings.SynchronizedRegistriesHandler;
|
||||
import com.github.retrooper.packetevents.util.updatechecker.UpdateChecker;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class PacketEventsAPI<T> {
|
||||
|
||||
private final EventManager eventManager = new EventManager();
|
||||
private final PacketEventsSettings settings = new PacketEventsSettings();
|
||||
private final UpdateChecker updateChecker = new UpdateChecker();
|
||||
private final LogManager logManager = new LogManager();
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketEventsAPI.class.getName());
|
||||
private final LogManager logManager = LogManager.construct(this);
|
||||
|
||||
public EventManager getEventManager() {
|
||||
return eventManager;
|
||||
@@ -57,15 +62,31 @@ public abstract class PacketEventsAPI<T> {
|
||||
return PEVersions.CURRENT;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
return JulLegacyLogManager.getLogger();
|
||||
}
|
||||
|
||||
public LogManager getLogManager() {
|
||||
return logManager;
|
||||
return this.logManager;
|
||||
}
|
||||
|
||||
public abstract void load();
|
||||
public void load() {
|
||||
this.getLogManager().info("Loading packetevents...");
|
||||
|
||||
WrappedBlockState.ensureLoad();
|
||||
SynchronizedRegistriesHandler.init();
|
||||
PacketType.prepare();
|
||||
AdventureConversionInjector.inject();
|
||||
|
||||
// Register internal packet listener (should be the first listener)
|
||||
// This listener doesn't do any modifications to the packets, just reads data
|
||||
this.registerInternalListener();
|
||||
}
|
||||
|
||||
protected void registerInternalListener() {
|
||||
this.getEventManager().registerListener(new InternalPacketListener());
|
||||
}
|
||||
|
||||
public abstract boolean isLoaded();
|
||||
|
||||
@@ -73,7 +94,15 @@ public abstract class PacketEventsAPI<T> {
|
||||
|
||||
public abstract boolean isInitialized();
|
||||
|
||||
public abstract void terminate();
|
||||
public void terminate() {
|
||||
try {
|
||||
this.getInjector().uninject();
|
||||
} catch (Throwable throwable) {
|
||||
this.getLogManager().warn("Failed to uninject during termination, this error can be ignored on shutdown", throwable);
|
||||
}
|
||||
this.getEventManager().unregisterAllListeners();
|
||||
AdventureConversionInjector.uninject();
|
||||
}
|
||||
|
||||
public abstract boolean isTerminated();
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* The {@link PacketEvent} implements this interface.
|
||||
@@ -31,7 +30,9 @@ import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
* @author retrooper
|
||||
* @since 1.8
|
||||
*/
|
||||
@NullMarked
|
||||
public interface CallableEvent {
|
||||
|
||||
default void call(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal((PacketEvent) this);
|
||||
}
|
||||
|
||||
@@ -22,23 +22,24 @@ import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.exception.InvalidHandshakeException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Class for event managing. Implements both, internal and API methods.
|
||||
*
|
||||
* @author retrooper
|
||||
* @author ShadowOfHeaven (optimization)
|
||||
* @apiNote It is highly recommended to register the event listeners at server start-up,
|
||||
* without frequent modifications during runtime, since this class needs to recalculate all of
|
||||
* its event listeners during any modifications. In other words, it assumes that reads (events fired)
|
||||
* greatly outnumber writes (listeners modifications). If your case requires frequent listener modifications,
|
||||
* open a pull request on GitHub and describe your case.
|
||||
*
|
||||
* @author retrooper
|
||||
* @author ShadowOfHeaven (optimization)
|
||||
*
|
||||
*/
|
||||
|
||||
public class EventManager {
|
||||
@@ -76,7 +77,7 @@ public class EventManager {
|
||||
* be the final decider whether the event has been cancelled or not.
|
||||
*
|
||||
* @param event {@link PacketEvent}
|
||||
* @param postCallListenerAction The action to be ran after all the listeners have finished processing
|
||||
* @param postCallListenerAction The action to be run after all the listeners have finished processing
|
||||
*/
|
||||
public void callEvent(PacketEvent event, @Nullable Runnable postCallListenerAction) {
|
||||
for (PacketListenerCommon listener : listeners) {
|
||||
@@ -84,8 +85,8 @@ public class EventManager {
|
||||
event.call(listener);
|
||||
} catch (Exception t) {
|
||||
// ignore handshake exceptions
|
||||
if (t.getClass() != InvalidHandshakeException.class) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
if (t.getClass() != InvalidHandshakeException.class && (t.getCause() == null || t.getCause().getClass() != InvalidHandshakeException.class)) {
|
||||
PacketEvents.getAPI().getLogManager().warn("PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
}
|
||||
}
|
||||
if (postCallListenerAction != null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* An event in both of PacketEvents' event systems.
|
||||
@@ -28,7 +29,9 @@ import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
* @author retrooper
|
||||
* @since 1.2.6
|
||||
*/
|
||||
@NullMarked
|
||||
public abstract class PacketEvent implements CallableEvent {
|
||||
|
||||
private final long timestamp;
|
||||
|
||||
public PacketEvent() {
|
||||
@@ -60,4 +63,4 @@ public abstract class PacketEvent implements CallableEvent {
|
||||
public void callPacketEventExternal(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,25 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
protected PacketReceiveEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
protected PacketReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.CLIENT, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketReceiveEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user, Object player,
|
||||
Object byteBuf) throws PacketProcessException {
|
||||
protected PacketReceiveEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
}
|
||||
@@ -46,13 +54,8 @@ public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,32 +18,38 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.simple.PacketHandshakeSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
private List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
private @Nullable List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.SERVER, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketSendEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetID, packetType,
|
||||
serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
protected PacketSendEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,13 +71,8 @@ public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,25 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.NullUnmarked;
|
||||
|
||||
/**
|
||||
* Every event that has an associated player is recommended to implement this interface.
|
||||
*
|
||||
* @author retrooper
|
||||
* @since 1.6.9
|
||||
*/
|
||||
@NullMarked
|
||||
public interface PlayerEvent {
|
||||
|
||||
/**
|
||||
* Associated player.
|
||||
* May be null (e.g. early connection states).
|
||||
*
|
||||
* @return Player.
|
||||
*/
|
||||
<T> T getPlayer();
|
||||
@NullUnmarked
|
||||
<T> @UnknownNullability T getPlayer();
|
||||
}
|
||||
+40
-27
@@ -33,40 +33,50 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.NullUnmarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerEvent, CancellableEvent, UserEvent {
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
private Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private final int packetID;
|
||||
private final PacketTypeCommon packetType;
|
||||
private ServerVersion serverVersion;
|
||||
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
|
||||
private @UnknownNullability Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private boolean cancel;
|
||||
private PacketWrapper<?> lastUsedWrapper;
|
||||
private List<Runnable> postTasks = null;
|
||||
private @Nullable PacketWrapper<?> lastUsedWrapper;
|
||||
private @Nullable List<Runnable> postTasks = null;
|
||||
|
||||
private boolean cloned;
|
||||
private boolean needsReEncode = PacketEvents.getAPI().getSettings().reEncodeByDefault();
|
||||
|
||||
public ProtocolPacketEvent(PacketSide packetSide, Object channel,
|
||||
User user, Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public ProtocolPacketEvent(
|
||||
PacketSide packetSide, Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
|
||||
if (autoProtocolTranslation || user.getClientVersion() == null) {
|
||||
this.serverVersion = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
} else {
|
||||
//TODO Optimize
|
||||
this.serverVersion = user.getClientVersion().toServerVersion();
|
||||
this.serverVersion = user.getPacketVersion().toServerVersion();
|
||||
}
|
||||
|
||||
this.byteBuf = byteBuf;
|
||||
@@ -79,22 +89,25 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
} catch (Exception e) {
|
||||
throw new PacketProcessException("Failed to read the Packet ID of a packet. (Size: " + size + ")");
|
||||
}
|
||||
|
||||
ClientVersion version = serverVersion.toClientVersion();
|
||||
ConnectionState state = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
this.packetType = PacketType.getById(packetSide, state,
|
||||
version, packetID);
|
||||
if (this.packetType == null) {
|
||||
this.connectionState = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
PacketTypeCommon packetType = PacketType.getById(packetSide, this.connectionState, version, this.packetID);
|
||||
if (packetType == null) {
|
||||
// mojang messed up and keeps sending disconnect packets in the wrong protocol state
|
||||
if (PacketType.getById(packetSide, ConnectionState.PLAY, version, packetID) == PacketType.Play.Server.DISCONNECT) {
|
||||
throw new InvalidDisconnectPacketSend();
|
||||
}
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getDecoderState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
}
|
||||
this.connectionState = state;
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public ProtocolPacketEvent(int packetID, PacketTypeCommon packetType, ServerVersion serverVersion, Object channel,
|
||||
User user, Object player, Object byteBuf) {
|
||||
public ProtocolPacketEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
@@ -105,7 +118,7 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
|
||||
this.connectionState = (packetType != null && packetType.getSide() == PacketSide.SERVER)
|
||||
? user.getEncoderState() : user.getDecoderState();
|
||||
cloned = true;
|
||||
this.cloned = true;
|
||||
}
|
||||
|
||||
public void markForReEncode(boolean needsReEncode) {
|
||||
@@ -116,7 +129,6 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return needsReEncode;
|
||||
}
|
||||
|
||||
|
||||
public boolean isClone() {
|
||||
return cloned;
|
||||
}
|
||||
@@ -142,7 +154,8 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getPlayer() {
|
||||
@NullUnmarked
|
||||
public <T> @UnknownNullability T getPlayer() {
|
||||
return (T) player;
|
||||
}
|
||||
|
||||
@@ -159,14 +172,13 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return connectionState;
|
||||
}
|
||||
|
||||
//TODO Possibly put clientversion inside User class and remove here
|
||||
@Deprecated
|
||||
public ClientVersion getClientVersion() {
|
||||
return user.getClientVersion();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClientVersion(@NotNull ClientVersion clientVersion) {
|
||||
public void setClientVersion(ClientVersion clientVersion) {
|
||||
PacketEvents.getAPI().getLogManager().debug("Setting client version with deprecated method " + clientVersion.getReleaseName());
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
@@ -175,7 +187,8 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public void setServerVersion(@NotNull ServerVersion serverVersion) {
|
||||
@Deprecated
|
||||
public void setServerVersion(ServerVersion serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent {
|
||||
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent{
|
||||
private final User user;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserDisconnectEvent extends PacketEvent implements UserEvent {
|
||||
|
||||
private final User user;
|
||||
|
||||
public UserDisconnectEvent(User user) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Event that involves users.
|
||||
@@ -26,6 +27,8 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
* @author retrooper
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@NullMarked
|
||||
public interface UserEvent {
|
||||
|
||||
User getUser();
|
||||
}
|
||||
@@ -19,10 +19,15 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.NullUnmarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserLoginEvent extends PacketEvent implements CallableEvent, UserEvent, PlayerEvent {
|
||||
|
||||
private final User user;
|
||||
private final Object player;
|
||||
private final @UnknownNullability Object player;
|
||||
|
||||
public UserLoginEvent(User user, Object player) {
|
||||
this.user = user;
|
||||
@@ -35,7 +40,8 @@ public class UserLoginEvent extends PacketEvent implements CallableEvent, UserEv
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getPlayer() {
|
||||
@NullUnmarked
|
||||
public <T> @UnknownNullability T getPlayer() {
|
||||
return (T) player;
|
||||
}
|
||||
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigReceiveEvent extends PacketReceiveEvent {
|
||||
|
||||
public PacketConfigReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Client getPacketType() {
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigSendEvent extends PacketSendEvent {
|
||||
|
||||
public PacketConfigSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketHandshakeReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketHandshakeReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -7,31 +7,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeSendEvent extends PacketSendEvent {
|
||||
public PacketHandshakeSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketHandshakeSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketLoginReceiveEvent(Object channel, User user, Object player,
|
||||
Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginSendEvent extends PacketSendEvent {
|
||||
public PacketLoginSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Login.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlayReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketPlayReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlayReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlayReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlayReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlayReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlaySendEvent extends PacketSendEvent {
|
||||
public PacketPlaySendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlaySendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlaySendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlaySendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlaySendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketStatusReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Status.Client getPacketType() {
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusSendEvent extends PacketSendEvent {
|
||||
public PacketStatusSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-1
@@ -23,7 +23,7 @@ import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerPriority;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.manager.protocol.ProtocolManager;
|
||||
import com.github.retrooper.packetevents.event.ProtocolPacketEvent;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
@@ -32,6 +32,7 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import com.github.retrooper.packetevents.util.LogManager;
|
||||
import com.github.retrooper.packetevents.util.mappings.SynchronizedRegistriesHandler;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerConfigurationEnd;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerRegistryData;
|
||||
import com.github.retrooper.packetevents.wrapper.handshaking.client.WrapperHandshakingClientHandshake;
|
||||
import com.github.retrooper.packetevents.wrapper.login.server.WrapperLoginServerLoginSuccess;
|
||||
@@ -50,6 +51,9 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
super(priority);
|
||||
}
|
||||
|
||||
protected void handlePlayEnter(ProtocolPacketEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
User user = event.getUser();
|
||||
@@ -82,6 +86,7 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else {
|
||||
user.setConnectionState(ConnectionState.PLAY);
|
||||
this.handlePlayEnter(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +111,7 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
if (joinGame.getDimensionCodec() != null) { // 1.16 to 1.20.1
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, joinGame,
|
||||
joinGame.getDimensionCodec());
|
||||
user.finalizeRegistries(joinGame);
|
||||
}
|
||||
|
||||
user.setDimensionType(joinGame.getDimensionType());
|
||||
@@ -119,6 +125,8 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Configuration.Server.CONFIGURATION_END) {
|
||||
user.setEncoderState(ConnectionState.PLAY);
|
||||
user.finalizeRegistries(new WrapperConfigServerConfigurationEnd(event));
|
||||
this.handlePlayEnter(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -26,15 +26,16 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PlayerManager {
|
||||
int getPing(@NotNull Object player);
|
||||
|
||||
@NotNull ClientVersion getClientVersion(@NotNull Object player);
|
||||
|
||||
Object getChannel(@NotNull Object player);
|
||||
@Nullable Object getChannel(@NotNull Object player);
|
||||
|
||||
User getUser(@NotNull Object player);
|
||||
@Nullable User getUser(@NotNull Object player);
|
||||
|
||||
/**
|
||||
* <strong>WARNING</strong>: Usage of this method should be avoided. Please use either
|
||||
|
||||
+5
-4
@@ -26,6 +26,7 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.util.PacketTransformationUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -55,7 +56,7 @@ public interface ProtocolManager {
|
||||
void writePacketSilently(Object channel, Object byteBuf);
|
||||
void receivePacket(Object channel, Object byteBuf);
|
||||
void receivePacketSilently(Object channel, Object byteBuf);
|
||||
ClientVersion getClientVersion(Object channel);
|
||||
@Nullable ClientVersion getClientVersion(Object channel);
|
||||
//TODO Define method that accepts an array of channels/set/list of channels.
|
||||
|
||||
default void sendPackets(Object channel, Object... byteBuf) {
|
||||
@@ -147,13 +148,13 @@ public interface ProtocolManager {
|
||||
receivePacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default User getUser(Object channel) {
|
||||
default @Nullable User getUser(Object channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.get(pipeline);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default User removeUser(Object channel) {
|
||||
default @Nullable User removeUser(Object channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.remove(pipeline);
|
||||
}
|
||||
@@ -167,7 +168,7 @@ public interface ProtocolManager {
|
||||
PacketEvents.getAPI().getInjector().updateUser(channel, user);
|
||||
}
|
||||
|
||||
default Object getChannel(UUID uuid) {
|
||||
default @Nullable Object getChannel(UUID uuid) {
|
||||
return CHANNELS.get(uuid);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -50,8 +50,11 @@ public enum ServerVersion {
|
||||
V_1_19(759), V_1_19_1(760), V_1_19_2(760), V_1_19_3(761), V_1_19_4(762),
|
||||
//1.20 and 1.20.1 have the same protocol version. 1.20.3 and 1.20.4 have the same protocol version. 1.20.5 and 1.20.6 have the same protocol version
|
||||
V_1_20(763), V_1_20_1(763), V_1_20_2(764), V_1_20_3(765), V_1_20_4(765), V_1_20_5(766), V_1_20_6(766),
|
||||
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770), V_1_21_6(771), V_1_21_7(772),
|
||||
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version. 1.21.7 and 1.21.8 have the same protocol version. 1.21.9 and 1.21.10 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770), V_1_21_6(771), V_1_21_7(772), V_1_21_8(772), V_1_21_9(773), V_1_21_10(773), V_1_21_11(774),
|
||||
V_26_1(775), V_26_1_1(775), V_26_1_2(775),
|
||||
V_26_2(776),
|
||||
V_26_3(777),
|
||||
//TODO UPDATE Add server version constant
|
||||
ERROR(-1, true);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.manager.server;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* System Operating system.
|
||||
*
|
||||
@@ -36,9 +38,9 @@ public enum SystemOS {
|
||||
* @return Operating System.
|
||||
*/
|
||||
public static SystemOS getOSNoCache() {
|
||||
final String os = System.getProperty("os.name").toLowerCase();
|
||||
final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
for (SystemOS sysos : values()) {
|
||||
if (os.contains(sysos.name().toLowerCase())) {
|
||||
if (os.contains(sysos.name().toLowerCase(Locale.ROOT))) {
|
||||
return sysos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ public class ByteBufHelper {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShort(buffer, value);
|
||||
}
|
||||
|
||||
public static void writeShortLE(Object buffer, int value) {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShortLE(buffer, value);
|
||||
}
|
||||
|
||||
public static int readMedium(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().readMedium(buffer);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface ByteBufOperator {
|
||||
|
||||
void writeByte(Object buffer, int value);
|
||||
void writeShort(Object buffer, int value);
|
||||
void writeShortLE(Object buffer, int value);
|
||||
void writeMedium(Object buffer, int value);
|
||||
void writeInt(Object buffer, int value);
|
||||
void writeLong(Object buffer, long value);
|
||||
|
||||
+46
-8
@@ -18,10 +18,13 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStackSerialization;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class AdvancementDisplay {
|
||||
@@ -40,8 +43,25 @@ public final class AdvancementDisplay {
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
public AdvancementDisplay(Component title, Component description, ItemStack icon, AdvancementType type, @Nullable ResourceLocation background, boolean showToast,
|
||||
boolean hidden, float x, float y) {
|
||||
public AdvancementDisplay(
|
||||
Component title, Component description, ItemStack icon, AdvancementType type,
|
||||
@Nullable ResourceLocation background, boolean showToast, boolean hidden
|
||||
) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.type = type;
|
||||
this.showToast = showToast;
|
||||
this.hidden = hidden;
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public AdvancementDisplay(
|
||||
Component title, Component description, ItemStack icon, AdvancementType type,
|
||||
@Nullable ResourceLocation background, boolean showToast, boolean hidden,
|
||||
float x, float y
|
||||
) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
@@ -56,28 +76,34 @@ public final class AdvancementDisplay {
|
||||
public static AdvancementDisplay read(PacketWrapper<?> wrapper) {
|
||||
Component title = wrapper.readComponent();
|
||||
Component description = wrapper.readComponent();
|
||||
ItemStack icon = wrapper.readItemStack();
|
||||
ItemStack icon = ItemStackSerialization.readTemplate(wrapper);
|
||||
AdvancementType type = wrapper.readEnum(AdvancementType.class);
|
||||
int flags = wrapper.readInt();
|
||||
ResourceLocation background = (flags & FLAG_HAS_BACKGROUND) != 0 ? ResourceLocation.read(wrapper) : null;
|
||||
boolean showToast = (flags & FLAG_SHOW_TOAST) != 0;
|
||||
boolean hidden = (flags & FLAG_HIDDEN) != 0;
|
||||
float x = wrapper.readFloat();
|
||||
float y = wrapper.readFloat();
|
||||
float x = 0f;
|
||||
float y = 0f;
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_26_3)) {
|
||||
x = wrapper.readFloat();
|
||||
y = wrapper.readFloat();
|
||||
}
|
||||
return new AdvancementDisplay(title, description, icon, type, background, showToast, hidden, x, y);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AdvancementDisplay display) {
|
||||
wrapper.writeComponent(display.title);
|
||||
wrapper.writeComponent(display.description);
|
||||
wrapper.writeItemStack(display.icon);
|
||||
ItemStackSerialization.writeTemplate(wrapper, display.icon);
|
||||
wrapper.writeEnum(display.type);
|
||||
wrapper.writeInt(display.packFlags());
|
||||
if (display.background != null) {
|
||||
ResourceLocation.write(wrapper, display.background);
|
||||
}
|
||||
wrapper.writeFloat(display.x);
|
||||
wrapper.writeFloat(display.y);
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_26_3)) {
|
||||
wrapper.writeFloat(display.x);
|
||||
wrapper.writeFloat(display.y);
|
||||
}
|
||||
}
|
||||
|
||||
public int packFlags() {
|
||||
@@ -150,18 +176,30 @@ public final class AdvancementDisplay {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions -26.2
|
||||
*/
|
||||
public float getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions -26.2
|
||||
*/
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions -26.2
|
||||
*/
|
||||
public float getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions -26.2
|
||||
*/
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
+71
-1
@@ -18,28 +18,70 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class AdvancementHolder {
|
||||
|
||||
private ResourceLocation identifier;
|
||||
private Advancement advancement;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
private float x;
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
private float y;
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public AdvancementHolder(ResourceLocation identifier, Advancement advancement) {
|
||||
this.identifier = identifier;
|
||||
this.advancement = advancement;
|
||||
// legacy compat
|
||||
AdvancementDisplay display = advancement.getDisplay();
|
||||
if (display != null) {
|
||||
this.x = display.getX();
|
||||
this.y = display.getY();
|
||||
}
|
||||
}
|
||||
|
||||
public AdvancementHolder(ResourceLocation identifier, Advancement advancement, float x, float y) {
|
||||
this.identifier = identifier;
|
||||
this.advancement = advancement;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public static AdvancementHolder read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation identifier = wrapper.readIdentifier();
|
||||
Advancement advancement = Advancement.read(wrapper);
|
||||
return new AdvancementHolder(identifier, advancement);
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_26_3)) {
|
||||
return new AdvancementHolder(identifier, advancement);
|
||||
}
|
||||
float x = wrapper.readFloat();
|
||||
float y = wrapper.readFloat();
|
||||
// minimal legacy compat
|
||||
AdvancementDisplay display = advancement.getDisplay();
|
||||
if (display != null) {
|
||||
display.setX(x);
|
||||
display.setY(y);
|
||||
}
|
||||
return new AdvancementHolder(identifier, advancement, x, y);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AdvancementHolder holder) {
|
||||
wrapper.writeIdentifier(holder.identifier);
|
||||
Advancement.write(wrapper, holder.advancement);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_3)) {
|
||||
wrapper.writeFloat(holder.x);
|
||||
wrapper.writeFloat(holder.y);
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getIdentifier() {
|
||||
@@ -57,4 +99,32 @@ public final class AdvancementHolder {
|
||||
public void setAdvancement(Advancement advancement) {
|
||||
this.advancement = advancement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public float getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public float getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,15 @@ package com.github.retrooper.packetevents.protocol.attribute;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
|
||||
public interface Attribute extends MappedEntity {
|
||||
|
||||
NbtCodec<Attribute> CODEC = NbtCodecs.forRegistry(Attributes.getRegistry());
|
||||
|
||||
@Override
|
||||
default ResourceLocation getName() {
|
||||
return this.getName(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion());
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecException;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapCodec;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public final class AttributeEntry {
|
||||
|
||||
public static final NbtCodec<AttributeEntry> CODEC = new NbtMapCodec<AttributeEntry>() {
|
||||
@Override
|
||||
public AttributeEntry decode(NBTCompound tag, PacketWrapper<?> wrapper) throws NbtCodecException {
|
||||
Attribute attribute = tag.getOrThrow("attribute", Attribute.CODEC, wrapper);
|
||||
AttributeModifier modifier = AttributeModifier.MAP_CODEC.decode(tag, wrapper);
|
||||
return new AttributeEntry(attribute, modifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(NBTCompound tag, PacketWrapper<?> wrapper, AttributeEntry value) throws NbtCodecException {
|
||||
tag.set("attribute", value.attribute, Attribute.CODEC, wrapper);
|
||||
AttributeModifier.MAP_CODEC.encode(tag, wrapper, value.modifier);
|
||||
}
|
||||
}.codec();
|
||||
|
||||
private final Attribute attribute;
|
||||
private final AttributeModifier modifier;
|
||||
|
||||
public AttributeEntry(Attribute attribute, AttributeModifier modifier) {
|
||||
this.attribute = attribute;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public static AttributeEntry read(PacketWrapper<?> wrapper) {
|
||||
Attribute attribute = wrapper.readMappedEntity(Attributes.getRegistry());
|
||||
AttributeModifier modifier = AttributeModifier.read(wrapper);
|
||||
return new AttributeEntry(attribute, modifier);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AttributeEntry entry) {
|
||||
wrapper.writeMappedEntity(entry.attribute);
|
||||
AttributeModifier.write(wrapper, entry.modifier);
|
||||
}
|
||||
|
||||
public Attribute getAttribute() {
|
||||
return this.attribute;
|
||||
}
|
||||
|
||||
public AttributeModifier getModifier() {
|
||||
return this.modifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
AttributeEntry that = (AttributeEntry) obj;
|
||||
if (!this.attribute.equals(that.attribute)) return false;
|
||||
return this.modifier.equals(that.modifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.attribute, this.modifier);
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTDouble;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecException;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapCodec;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@NullMarked
|
||||
public final class AttributeModifier {
|
||||
|
||||
public static final NbtMapCodec<AttributeModifier> MAP_CODEC = new NbtMapCodec<AttributeModifier>() {
|
||||
@Override
|
||||
public AttributeModifier decode(NBTCompound tag, PacketWrapper<?> wrapper) throws NbtCodecException {
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21)) {
|
||||
throw new NbtCodecException(wrapper.getServerVersion() + " is not supported");
|
||||
}
|
||||
ResourceLocation id = tag.getOrThrow("id", ResourceLocation.CODEC, wrapper);
|
||||
double amount = tag.getNumberTagValueOrThrow("amount").doubleValue();
|
||||
AttributeOperation operation = tag.getOrThrow("operation", AttributeOperation.CODEC, wrapper);
|
||||
return new AttributeModifier(id, amount, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(NBTCompound tag, PacketWrapper<?> wrapper, AttributeModifier value) throws NbtCodecException {
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21)) {
|
||||
throw new NbtCodecException(wrapper.getServerVersion() + " is not supported");
|
||||
}
|
||||
tag.set("id", value.id, ResourceLocation.CODEC, wrapper);
|
||||
tag.setTag("amount", new NBTDouble(value.amount));
|
||||
tag.set("operation", value.operation, AttributeOperation.CODEC, wrapper);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @versions -1.20.6
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
private final UUID uniqueId;
|
||||
/**
|
||||
* @versions 1.21+
|
||||
*/
|
||||
private final ResourceLocation id;
|
||||
private final double amount;
|
||||
private final AttributeOperation operation;
|
||||
|
||||
/**
|
||||
* @versions -1.20.6
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public AttributeModifier(UUID uniqueId, double amount, AttributeOperation operation) {
|
||||
this.uniqueId = uniqueId;
|
||||
this.id = new ResourceLocation(uniqueId.toString());
|
||||
this.amount = amount;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21+
|
||||
*/
|
||||
public AttributeModifier(ResourceLocation id, double amount, AttributeOperation operation) {
|
||||
this.uniqueId = WrapperPlayServerUpdateAttributes.PropertyModifier.generateSemiUniqueId(id);
|
||||
this.id = id;
|
||||
this.amount = amount;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public static AttributeModifier read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21)) {
|
||||
UUID uniqueId = wrapper.readUUID();
|
||||
double amount = wrapper.readDouble();
|
||||
AttributeOperation operation = wrapper.readEnum(AttributeOperation.values());
|
||||
return new AttributeModifier(uniqueId, amount, operation);
|
||||
}
|
||||
ResourceLocation id = ResourceLocation.read(wrapper);
|
||||
double amount = wrapper.readDouble();
|
||||
AttributeOperation operation = wrapper.readEnum(AttributeOperation.values());
|
||||
return new AttributeModifier(id, amount, operation);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AttributeModifier modifier) {
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21)) {
|
||||
wrapper.writeUUID(modifier.uniqueId);
|
||||
} else {
|
||||
ResourceLocation.write(wrapper, modifier.id);
|
||||
}
|
||||
wrapper.writeDouble(modifier.amount);
|
||||
wrapper.writeEnum(modifier.operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions -1.20.6
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public UUID getUniqueId() {
|
||||
return this.uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.12+
|
||||
*/
|
||||
public ResourceLocation getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public AttributeOperation getOperation() {
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
AttributeModifier that = (AttributeModifier) obj;
|
||||
if (Double.compare(that.amount, this.amount) != 0) return false;
|
||||
if (!this.id.equals(that.id)) return false;
|
||||
return this.operation == that.operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id, this.amount, this.operation);
|
||||
}
|
||||
}
|
||||
+25
-4
@@ -18,8 +18,29 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
public enum AttributeOperation {
|
||||
ADDITION,
|
||||
MULTIPLY_BASE,
|
||||
MULTIPLY_TOTAL,
|
||||
import com.github.retrooper.packetevents.protocol.util.CodecNameable;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public enum AttributeOperation implements CodecNameable {
|
||||
|
||||
ADDITION("add_value"),
|
||||
MULTIPLY_BASE("add_multiplied_base"),
|
||||
MULTIPLY_TOTAL("add_multiplied_total"),
|
||||
;
|
||||
|
||||
public static final NbtCodec<AttributeOperation> CODEC = NbtCodecs.forEnum(values());
|
||||
|
||||
private final String name;
|
||||
|
||||
AttributeOperation(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCodecName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
+21
@@ -203,6 +203,27 @@ public final class Attributes {
|
||||
public static final Attribute WAYPOINT_RECEIVE_RANGE = define("waypoint_receive_range",
|
||||
null, 0d, 0d, 60_000_000d);
|
||||
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Attribute AIR_DRAG_MODIFIER = define("air_drag_modifier", null, 1d, 0d, 2048d);
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Attribute BELOW_NAME_DISTANCE = define("below_name_distance", null, 10d, 0d, 512d);
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Attribute BOUNCINESS = define("bounciness", null, 0d, 0d, 1d);
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Attribute FRICTION_MODIFIER = define("friction_modifier", null, 1d, 0d, 2048d);
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Attribute NAME_TAG_DISTANCE = define("name_tag_distance", null, 64d, 0d, 512d);
|
||||
|
||||
/**
|
||||
* This attribute has been renamed in 1.20.5 to {@link #JUMP_STRENGTH}
|
||||
*/
|
||||
|
||||
@@ -31,13 +31,15 @@ import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.util.Index;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil.indexValueOrThrow;
|
||||
|
||||
@NullMarked
|
||||
public interface ChatType extends MappedEntity, CopyableEntity<ChatType>, DeepComparableEntity {
|
||||
|
||||
@UnknownNullability("only nullable for 1.19")
|
||||
|
||||
@@ -55,11 +55,11 @@ public final class Parsers {
|
||||
return REGISTRY.define(key, data -> new Parser(data, reader, writer));
|
||||
}
|
||||
|
||||
public static Parser getByName(String name) {
|
||||
public static @Nullable Parser getByName(String name) {
|
||||
return REGISTRY.getByName(name);
|
||||
}
|
||||
|
||||
public static Parser getById(ClientVersion version, int id) {
|
||||
public static @Nullable Parser getById(ClientVersion version, int id) {
|
||||
return REGISTRY.getById(version, id);
|
||||
}
|
||||
|
||||
@@ -145,6 +145,10 @@ public final class Parsers {
|
||||
public static final Parser BLOCK_PREDICATE = define("block_predicate", null, null);
|
||||
public static final Parser ITEM_STACK = define("item_stack", null, null);
|
||||
public static final Parser ITEM_PREDICATE = define("item_predicate", null, null);
|
||||
/**
|
||||
* @versions -26.1.2
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final Parser COLOR = define("color", null, null);
|
||||
public static final Parser COMPONENT = define("component", null, null);
|
||||
public static final Parser STYLE = define("style", null, null);
|
||||
@@ -213,7 +217,7 @@ public final class Parsers {
|
||||
public static final Parser UUID = define("uuid", null, null);
|
||||
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public static final Parser RESOURCE_SELECTOR = define("resource_selector",
|
||||
wrapper -> Collections.singletonList(wrapper.readIdentifier()),
|
||||
@@ -221,28 +225,56 @@ public final class Parsers {
|
||||
);
|
||||
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
* @versions 1.21.6+
|
||||
*/
|
||||
public static final Parser HEX_COLOR = define("hex_color", null, null);
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
* @versions 1.21.6+
|
||||
*/
|
||||
public static final Parser DIALOG = define("dialog", null, null);
|
||||
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final Parser TEAM_COLOR = define("team_color", null, null);
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public static final Parser CONTEXT_FLOAT_PROVIDER = define("context_float_provider", null, null);
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public static final Parser CONTEXT_INT_PROVIDER = define("context_int_provider", null, null);
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public static final Parser SLOT_SOURCE = define("slot_source", null, null);
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public static final Parser FEATURE = define("feature", null, null);
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
public static final Parser SWING_ANIMATION = define("swing_animation", null, null);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Reader extends Function<PacketWrapper<?>, List<Object>> {}
|
||||
public interface Reader extends Function<PacketWrapper<?>, List<Object>> {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Writer extends BiConsumer<PacketWrapper<?>, List<Object>> {}
|
||||
public interface Writer extends BiConsumer<PacketWrapper<?>, List<Object>> {
|
||||
}
|
||||
|
||||
public static final class Parser extends AbstractMappedEntity {
|
||||
|
||||
private final Reader reader;
|
||||
private final Writer writer;
|
||||
private final @Nullable Reader reader;
|
||||
private final @Nullable Writer writer;
|
||||
|
||||
@Deprecated
|
||||
public Parser(String name, @Nullable Function<PacketWrapper<?>, List<Object>> read, @Nullable BiConsumer<PacketWrapper<?>, List<Object>> write) {
|
||||
|
||||
+7
-6
@@ -21,11 +21,13 @@ package com.github.retrooper.packetevents.protocol.chat;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
|
||||
private final @UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration;
|
||||
@@ -61,9 +63,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
@ApiStatus.Internal
|
||||
public StaticChatType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration overlayDecoration,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration narrationDecoration,
|
||||
@Nullable ChatTypeDecoration narrationDecoration,
|
||||
@Nullable NarrationPriority narrationPriority
|
||||
) {
|
||||
super(data);
|
||||
@@ -100,10 +102,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deepEquals(Object obj) {
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof StaticChatType)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticChatType that = (StaticChatType) obj;
|
||||
if (!Objects.equals(this.chatDecoration, that.chatDecoration)) return false;
|
||||
if (!Objects.equals(this.overlayDecoration, that.overlayDecoration)) return false;
|
||||
@@ -113,7 +114,7 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
return Objects.hash(this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+19
-16
@@ -22,11 +22,14 @@ import com.github.retrooper.packetevents.protocol.dialog.Dialog;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTEnd;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSupportUtil;
|
||||
import com.github.retrooper.packetevents.util.adventure.NbtTagHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.event.ClickEvent.Payload;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@NullMarked
|
||||
public interface ClickEvent {
|
||||
|
||||
@@ -45,27 +48,27 @@ public interface ClickEvent {
|
||||
ClickEventAction<?> getAction();
|
||||
|
||||
static ClickEvent fromAdventure(net.kyori.adventure.text.event.ClickEvent clickEvent) {
|
||||
switch (clickEvent.action()) {
|
||||
case OPEN_URL:
|
||||
return new OpenUrlClickEvent(clickEvent.value());
|
||||
case OPEN_FILE:
|
||||
return new OpenFileClickEvent(clickEvent.value());
|
||||
case RUN_COMMAND:
|
||||
return new RunCommandClickEvent(clickEvent.value());
|
||||
case SUGGEST_COMMAND:
|
||||
return new SuggestCommandClickEvent(clickEvent.value());
|
||||
case CHANGE_PAGE:
|
||||
return new ChangePageClickEvent(clickEvent.value());
|
||||
case COPY_TO_CLIPBOARD:
|
||||
return new CopyToClipboardClickEvent(clickEvent.value());
|
||||
case SHOW_DIALOG:
|
||||
switch (clickEvent.action().name().toLowerCase(Locale.ROOT)) {
|
||||
case "open_url":
|
||||
return new OpenUrlClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "open_file":
|
||||
return new OpenFileClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "run_command":
|
||||
return new RunCommandClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "suggest_command":
|
||||
return new SuggestCommandClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "change_page":
|
||||
return new ChangePageClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "copy_to_clipboard":
|
||||
return new CopyToClipboardClickEvent(AdventureSupportUtil.getStringValue(clickEvent));
|
||||
case "show_dialog":
|
||||
return new ShowDialogClickEvent((Dialog) ((Payload.Dialog) clickEvent.payload()).dialog());
|
||||
case CUSTOM:
|
||||
case "custom":
|
||||
Payload.Custom payload = (Payload.Custom) clickEvent.payload();
|
||||
NbtTagHolder nbtTag = (NbtTagHolder) payload.nbt();
|
||||
return new CustomClickEvent(
|
||||
new ResourceLocation(payload.key()),
|
||||
nbtTag.getTag() instanceof NBTEnd ? null : nbtTag.getTag()
|
||||
nbtTag == null || nbtTag.getTag() instanceof NBTEnd ? null : nbtTag.getTag()
|
||||
);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsupported clickevent: " + clickEvent);
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessageLegacy;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatMessageProcessor_v1_7 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
return new ChatMessageLegacy(chatContent, ChatTypes.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
wrapper.writeComponent(data.getChatContent());
|
||||
}
|
||||
}
|
||||
+93
-18
@@ -27,10 +27,14 @@ import com.github.retrooper.packetevents.protocol.nbt.NBTType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class AlphaColor extends Color {
|
||||
|
||||
public static final AlphaColor WHITE = new AlphaColor(0xFFFFFFFF);
|
||||
public static final AlphaColor BLACK = new AlphaColor(0xFF000000);
|
||||
public static final AlphaColor TRANSPARENT = new AlphaColor(0x00000000);
|
||||
|
||||
private final int alpha;
|
||||
|
||||
@@ -49,7 +53,7 @@ public final class AlphaColor extends Color {
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
super(red, green, blue);
|
||||
this.alpha = alpha;
|
||||
this.alpha = MathUtil.clamp(alpha, 0, 255);
|
||||
}
|
||||
|
||||
public AlphaColor(
|
||||
@@ -101,8 +105,9 @@ public final class AlphaColor extends Color {
|
||||
return list;
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha(@Range(from = 0L, to = 255L) int alpha) {
|
||||
return new AlphaColor(alpha, this.red, this.green, this.blue);
|
||||
@Override
|
||||
public AlphaColor withAlpha() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,22 +130,92 @@ public final class AlphaColor extends Color {
|
||||
return (this.alpha << 24) | (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor plus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor minus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor times(Color other) {
|
||||
if (other.alpha() == 255 && other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new AlphaColor(
|
||||
(this.alpha * other.alpha()) / 255,
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha;
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this;
|
||||
}
|
||||
int alpha = srcAlpha + (this.alpha * (255 - srcAlpha)) / 255;
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new AlphaColor(this.alpha, grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float redScale, float greenScale, float blueScale) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor lerpSrgb(Color dest, float t) {
|
||||
return new AlphaColor(
|
||||
MathUtil.lerp(t, this.alpha, dest.alpha()),
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return this.red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int green() {
|
||||
return this.green;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return this.blue;
|
||||
}
|
||||
}
|
||||
@@ -18,29 +18,61 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.color;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTFloat;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTList;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTNumber;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecException;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class Color implements RGBLike {
|
||||
|
||||
private static final NbtCodec<Color> INT_CODEC = NbtCodecs.INT.apply(Color::new, Color::asRGB);
|
||||
private static final NbtCodec<Color> FLOATS_CODEC = NbtCodecs.FLOAT.applyFixedList(3)
|
||||
.apply(floats -> new Color(floats.get(0), floats.get(1), floats.get(2)),
|
||||
color -> Arrays.asList(color.red / 255f, color.green / 255f, color.blue / 255f));
|
||||
|
||||
public static final NbtCodec<Color> CODEC = new NbtCodec<Color>() {
|
||||
private final NbtCodec<Color> decodeCodec = INT_CODEC.withAlternative(FLOATS_CODEC);
|
||||
|
||||
@Override
|
||||
public Color decode(NBT tag, PacketWrapper<?> wrapper) throws NbtCodecException {
|
||||
return this.decodeCodec.decode(tag, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBT encode(PacketWrapper<?> wrapper, Color value) throws NbtCodecException {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
|
||||
return INT_CODEC.encode(wrapper, value);
|
||||
}
|
||||
return FLOATS_CODEC.encode(wrapper, value);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Color WHITE = new Color(0xFFFFFFFF);
|
||||
public static final Color BLACK = new Color(0xFF000000);
|
||||
|
||||
protected static final int BIT_MASK = 0xFF;
|
||||
|
||||
protected final int red, green, blue;
|
||||
|
||||
public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
public Color(
|
||||
@Range(from = 0L, to = 255L) int red,
|
||||
@Range(from = 0L, to = 255L) int green,
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
this.red = MathUtil.clamp(red, 0, 255);
|
||||
this.green = MathUtil.clamp(green, 0, 255);
|
||||
this.blue = MathUtil.clamp(blue, 0, 255);
|
||||
}
|
||||
|
||||
public Color(
|
||||
@@ -75,37 +107,43 @@ public class Color implements RGBLike {
|
||||
wrapper.writeByte(color.blue);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Color decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
return CODEC.decode(nbt, wrapper);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Color decode(NBT nbt, ClientVersion version) {
|
||||
if (nbt instanceof NBTNumber) {
|
||||
return new Color(((NBTNumber) nbt).getAsInt());
|
||||
}
|
||||
NBTList<?> list = (NBTList<?>) nbt;
|
||||
float red = ((NBTNumber) list.getTag(0)).getAsFloat();
|
||||
float green = ((NBTNumber) list.getTag(1)).getAsFloat();
|
||||
float blue = ((NBTNumber) list.getTag(2)).getAsFloat();
|
||||
return new Color(red, green, blue);
|
||||
return decode(nbt, PacketWrapper.createDummyWrapper(version));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static NBT encode(PacketWrapper<?> wrapper, Color color) {
|
||||
return CODEC.encode(wrapper, color);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static NBT encode(Color color, ClientVersion version) {
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_21_2)) {
|
||||
return new NBTInt(color.asRGB());
|
||||
}
|
||||
NBTList<NBTFloat> list = new NBTList<>(NBTType.FLOAT, 3);
|
||||
list.addTag(new NBTFloat(color.red));
|
||||
list.addTag(new NBTFloat(color.green));
|
||||
list.addTag(new NBTFloat(color.blue));
|
||||
return list;
|
||||
return encode(PacketWrapper.createDummyWrapper(version), color);
|
||||
}
|
||||
|
||||
public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
public AlphaColor withAlpha() {
|
||||
return this.withAlpha(255);
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha(@Range(from = 0L, to = 255L) int alpha) {
|
||||
return new AlphaColor(alpha, this.red, this.green, this.blue);
|
||||
}
|
||||
|
||||
public Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
public Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
public Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
@@ -113,6 +151,86 @@ public class Color implements RGBLike {
|
||||
return (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
public Color plus(Color other) {
|
||||
return new Color(
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color minus(Color other) {
|
||||
return new Color(
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color times(Color other) {
|
||||
if (other instanceof AlphaColor) {
|
||||
return other.times(this);
|
||||
} else if (this.red == 255 && this.green == 255 && this.blue == 255) {
|
||||
return other;
|
||||
} else if (other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new Color(
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha();
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this.withAlpha();
|
||||
}
|
||||
int alpha = srcAlpha + (255 - srcAlpha);
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
public Color asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new Color(grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
public Color scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
public Color scale(float redScale, float greenScale, float blueScale) {
|
||||
return new Color(
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
public Color lerpSrgb(Color dest, float t) {
|
||||
return new Color(
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return red;
|
||||
@@ -127,4 +245,17 @@ public class Color implements RGBLike {
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Color) {
|
||||
return this.asRGB() == ((Color) obj).asRGB();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.asRGB());
|
||||
}
|
||||
}
|
||||
+146
-7
@@ -21,9 +21,13 @@ package com.github.retrooper.packetevents.protocol.component;
|
||||
import com.github.retrooper.packetevents.protocol.color.DyeColor;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.AxolotlVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CatCollarComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CatSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CatVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ChickenSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ChickenVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CowSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CowVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CushionColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.FoxVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.FrogVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.HorseVariantComponent;
|
||||
@@ -31,37 +35,51 @@ import com.github.retrooper.packetevents.protocol.component.builtin.LlamaVariant
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.MooshroomVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PaintingVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ParrotVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PigSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PigVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PotteryPatternComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.RabbitVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SalmonSizeComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SheepColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ShulkerColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SignTextComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SulfurCubeContentComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishBaseColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedBlockEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.VillagerVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfCollarComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ZombieNautilusVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ArmorTrim;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BannerLayers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BlockTransformerComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BundleContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ChargedProjectiles;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.CustomData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.DebugStickState;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FireworkExplosion;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FoodProperties;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAdditionalTradeCost;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAdventurePredicate;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttackRange;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttributeModifiers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBees;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlockStateProperties;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlocksAttacks;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBreakSound;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBrewingFuel;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCompostable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemConsumable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerLoot;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCookingFuel;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCustomModelData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageResistant;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageType;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDeathProtection;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDyeColor;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantable;
|
||||
@@ -70,11 +88,15 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEqu
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemFireworks;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemInstrument;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemJukeboxPlayable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemKineticWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLock;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapDecorations;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapPostProcessingState;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMinimumAttackCharge;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMobVisibility;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemModel;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPiercingWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionDurationScale;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile;
|
||||
@@ -83,12 +105,16 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPro
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRecipes;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRepairable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemSwingAnimation;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTool;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipDisplay;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipStyle;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUnbreakable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseCooldown;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseEffects;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseRemainder;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemVillagerFood;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemWaxed;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.LodestoneTracker;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.PotDecorations;
|
||||
@@ -96,7 +122,6 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.Suspici
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.WritableBookContent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.WrittenBookContent;
|
||||
import com.github.retrooper.packetevents.protocol.item.instrument.Instrument;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
@@ -114,6 +139,7 @@ import java.util.Collection;
|
||||
/**
|
||||
* Contains all item data component types.
|
||||
*
|
||||
* @versions 1.20.5+
|
||||
* @see EnchantEffectComponentTypes
|
||||
*/
|
||||
public final class ComponentTypes {
|
||||
@@ -221,6 +247,10 @@ public final class ComponentTypes {
|
||||
ItemEnchantments::read, ItemEnchantments::write);
|
||||
public static final ComponentType<ItemDyeColor> DYED_COLOR = define("dyed_color",
|
||||
ItemDyeColor::read, ItemDyeColor::write);
|
||||
/**
|
||||
* @versions 1.20.5-26.2
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ComponentType<Integer> MAP_COLOR = define("map_color",
|
||||
PacketWrapper::readInt, PacketWrapper::writeInt);
|
||||
public static final ComponentType<Integer> MAP_ID = define("map_id",
|
||||
@@ -245,18 +275,23 @@ public final class ComponentTypes {
|
||||
ArmorTrim::read, ArmorTrim::write);
|
||||
public static final ComponentType<DebugStickState> DEBUG_STICK_STATE = define("debug_stick_state",
|
||||
DebugStickState::read, DebugStickState::write);
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = define("entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<TypedEntityData> TYPED_ENTITY_DATA = define("entity_data",
|
||||
TypedEntityData::read, TypedEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = TYPED_ENTITY_DATA
|
||||
.legacyMap(TypedEntityData::getCompound, TypedEntityData::new);
|
||||
public static final ComponentType<NBTCompound> BUCKET_ENTITY_DATA = define("bucket_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<TypedBlockEntityData> TYPED_BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
TypedBlockEntityData::read, TypedBlockEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = TYPED_BLOCK_ENTITY_DATA
|
||||
.legacyMap(TypedBlockEntityData::getCompound, TypedBlockEntityData::new);
|
||||
public static final ComponentType<ItemInstrument> ITEM_INSTRUMENT = define("instrument",
|
||||
ItemInstrument::read, ItemInstrument::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<Instrument> INSTRUMENT = ITEM_INSTRUMENT.legacyMap(
|
||||
inst -> inst.getInstrument().getValue(),
|
||||
inst -> new ItemInstrument(new MaybeMappedEntity<>(inst)));
|
||||
inst -> inst.getInstrument().getValue(), ItemInstrument::new);
|
||||
public static final ComponentType<Integer> OMINOUS_BOTTLE_AMPLIFIER = define("ominous_bottle_amplifier",
|
||||
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
public static final ComponentType<ItemRecipes> RECIPES = define("recipes",
|
||||
@@ -472,6 +507,110 @@ public final class ComponentTypes {
|
||||
public static final ComponentType<ShulkerColorComponent> SHULKER_COLOR = define("shulker/color",
|
||||
ShulkerColorComponent::read, ShulkerColorComponent::write);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemUseEffects> USE_EFFECTS = define("use_effects",
|
||||
ItemUseEffects::read, ItemUseEffects::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemMinimumAttackCharge> MINIMUM_ATTACK_CHARGE = define("minimum_attack_charge",
|
||||
ItemMinimumAttackCharge::read, ItemMinimumAttackCharge::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemDamageType> DAMAGE_TYPE = define("damage_type",
|
||||
ItemDamageType::read, ItemDamageType::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemAttackRange> ATTACK_RANGE = define("attack_range",
|
||||
ItemAttackRange::read, ItemAttackRange::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemPiercingWeapon> PIERCING_WEAPON = define("piercing_weapon",
|
||||
ItemPiercingWeapon::read, ItemPiercingWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemKineticWeapon> KINETIC_WEAPON = define("kinetic_weapon",
|
||||
ItemKineticWeapon::read, ItemKineticWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11-26.2
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ComponentType<ItemSwingAnimation> SWING_ANIMATION = define("swing_animation",
|
||||
ItemSwingAnimation::read, ItemSwingAnimation::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ZombieNautilusVariantComponent> ZOMBIE_NAUTILUS_VARIANT = define("zombie_nautilus/variant",
|
||||
ZombieNautilusVariantComponent::read, ZombieNautilusVariantComponent::write);
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<DyeColor> DYE = define("dye", DyeColor::read, DyeColor::write);
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<ItemAdditionalTradeCost> ADDITIONAL_TRADE_COST = define("additional_trade_cost",
|
||||
ItemAdditionalTradeCost::read, ItemAdditionalTradeCost::write);
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<CatSoundVariantComponent> CAT_SOUND_VARIANT = define("cat/sound_variant",
|
||||
CatSoundVariantComponent::read, CatSoundVariantComponent::write);
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<ChickenSoundVariantComponent> CHICKEN_SOUND_VARIANT = define("chicken/sound_variant",
|
||||
ChickenSoundVariantComponent::read, ChickenSoundVariantComponent::write);
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<CowSoundVariantComponent> COW_SOUND_VARIANT = define("cow/sound_variant",
|
||||
CowSoundVariantComponent::read, CowSoundVariantComponent::write);
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public static final ComponentType<PigSoundVariantComponent> PIG_SOUND_VARIANT = define("pig/sound_variant",
|
||||
PigSoundVariantComponent::read, PigSoundVariantComponent::write);
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
public static final ComponentType<SulfurCubeContentComponent> SULFUR_CUBE_CONTENT = define("sulfur_cube_content",
|
||||
SulfurCubeContentComponent::read, SulfurCubeContentComponent::write);
|
||||
|
||||
public static final ComponentType<ItemSwingAnimation> ATTACK_ANIMATION = define("attack_animation",
|
||||
ItemSwingAnimation::read, ItemSwingAnimation::write);
|
||||
public static final ComponentType<ItemSwingAnimation> INTERACT_ANIMATION = define("interact_animation",
|
||||
ItemSwingAnimation::read, ItemSwingAnimation::write);
|
||||
public static final ComponentType<BlockTransformerComponent> BLOCK_TRANSFORMER = define("block_transformer",
|
||||
BlockTransformerComponent::read, BlockTransformerComponent::write);
|
||||
public static final ComponentType<ItemVillagerFood> VILLAGER_FOOD = define("villager_food",
|
||||
ItemVillagerFood::read, ItemVillagerFood::write);
|
||||
public static final ComponentType<ItemCompostable> COMPOSTABLE = define("compostable",
|
||||
ItemCompostable::read, ItemCompostable::write);
|
||||
public static final ComponentType<ItemCookingFuel> COOKING_FUEL = define("cooking_fuel",
|
||||
ItemCookingFuel::read, ItemCookingFuel::write);
|
||||
public static final ComponentType<ItemBrewingFuel> BREWING_FUEL = define("brewing_fuel",
|
||||
ItemBrewingFuel::read, ItemBrewingFuel::write);
|
||||
public static final ComponentType<ItemMobVisibility> MOB_VISIBILITY = define("mob_visibility",
|
||||
ItemMobVisibility::read, ItemMobVisibility::write);
|
||||
public static final ComponentType<PotteryPatternComponent> PROVIDES_POTTERY_PATTERN = define("provides_pottery_pattern",
|
||||
PotteryPatternComponent::read, PotteryPatternComponent::write);
|
||||
public static final ComponentType<SignTextComponent> SIGN_TEXT_FRONT = define("sign_text_front",
|
||||
SignTextComponent::read, SignTextComponent::write);
|
||||
public static final ComponentType<SignTextComponent> SIGN_TEXT_BACK = define("sign_text_back",
|
||||
SignTextComponent::read, SignTextComponent::write);
|
||||
public static final ComponentType<ItemWaxed> WAXED = define("waxed",
|
||||
ItemWaxed::read, ItemWaxed::write);
|
||||
public static final ComponentType<CushionColorComponent> CUSHION_COLOR = define("cushion/color",
|
||||
CushionColorComponent::read, CushionColorComponent::write);
|
||||
|
||||
/**
|
||||
* Returns an immutable view of the component types.
|
||||
*
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2026 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.netty.buffer.UnpooledByteBufAllocationHelper;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.mappings.GlobalRegistryHolder;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistryHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
@NullMarked
|
||||
public interface ComponentValueRef<T> {
|
||||
|
||||
@ApiStatus.Internal
|
||||
static <T> ComponentValueRef<T> ofBytes(ComponentType<T> type, byte[] bytes, ClientVersion version) {
|
||||
ServerVersion serverVersion = version.toServerVersion();
|
||||
return asCached(registries -> {
|
||||
Object byteBuf = UnpooledByteBufAllocationHelper.wrappedBuffer(bytes);
|
||||
try {
|
||||
PacketWrapper<?> wrapper = PacketWrapper.createUniversalPacketWrapper(byteBuf, serverVersion);
|
||||
wrapper.setRegistryHolder(registries);
|
||||
return type.read(wrapper);
|
||||
} finally {
|
||||
ByteBufHelper.release(byteBuf);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static <T> ComponentValueRef<T> ofStatic(T value) {
|
||||
return registries -> value;
|
||||
}
|
||||
|
||||
static <T> ComponentValueRef<T> asCached(ComponentValueRef<T> delegate) {
|
||||
return new ComponentValueRef<T>() {
|
||||
// I would rather want to use a weak, concurrent, identity-based hashmap, but java doesn't
|
||||
// have this datatype built-in and I don't want to write it myself
|
||||
private final Map<IRegistryHolder, T> values = new WeakHashMap<>();
|
||||
|
||||
@Override
|
||||
public synchronized T resolve(IRegistryHolder registries) {
|
||||
return this.values.computeIfAbsent(registries, delegate::resolve);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default T resolveUsingGlobals() {
|
||||
return this.resolve(GlobalRegistryHolder.INSTANCE);
|
||||
}
|
||||
|
||||
T resolve(IRegistryHolder registries);
|
||||
}
|
||||
+6
@@ -113,6 +113,12 @@ public final class EnchantEffectComponentTypes {
|
||||
public static ComponentType<NBT> TRIDENT_SPIN_ATTACK_STRENGTH = define("trident_spin_attack_strength",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static ComponentType<NBT> POST_PIERCING_ATTACK = define("post_piercing_attack",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
+17
-16
@@ -22,7 +22,9 @@ import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistry;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistryHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
@@ -33,13 +35,10 @@ import java.util.Optional;
|
||||
@NullMarked
|
||||
public interface IComponentMap {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiStatus.Internal
|
||||
static StaticComponentMap decode(NBT nbt, PacketWrapper<?> wrapper, IRegistry<? extends ComponentType<?>> registry) {
|
||||
return decode(nbt, wrapper.getServerVersion().toClientVersion(), registry);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked") // safe in this case
|
||||
static StaticComponentMap decode(NBT nbt, ClientVersion version, IRegistry<? extends ComponentType<?>> registry) {
|
||||
ClientVersion version = wrapper.getServerVersion().toClientVersion();
|
||||
NBTCompound compound = (NBTCompound) nbt;
|
||||
StaticComponentMap.Builder components = StaticComponentMap.builder();
|
||||
for (Map.Entry<String, NBT> entry : compound.getTags().entrySet()) {
|
||||
@@ -50,21 +49,21 @@ public interface IComponentMap {
|
||||
Object value = type.decode(entry.getValue(), version);
|
||||
components.set((ComponentType<? super Object>) type, value);
|
||||
}
|
||||
return components.build();
|
||||
return components.setRegistries(wrapper.getRegistryHolder()).build();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiStatus.Internal
|
||||
static NBT encode(PacketWrapper<?> wrapper, StaticComponentMap components) {
|
||||
return encode(components, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
components = components.withRegistries(wrapper.getRegistryHolder());
|
||||
ClientVersion version = wrapper.getServerVersion().toClientVersion();
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked") // safe in this case
|
||||
static NBT encode(StaticComponentMap components, ClientVersion version) {
|
||||
NBTCompound compound = new NBTCompound();
|
||||
for (Map.Entry<ComponentType<?>, ?> entry : components.getDelegate().entrySet()) {
|
||||
String key = entry.getKey().getName().toString();
|
||||
NBT value = ((ComponentType<? super Object>) entry.getKey()).encode(entry.getValue(), version);
|
||||
compound.setTag(key, value);
|
||||
for (ComponentType<?> type : components.getKeys()) {
|
||||
String key = type.getName().toString();
|
||||
Object value = components.get(type);
|
||||
NBT tag = ((ComponentType<? super Object>) type).encode(value, version);
|
||||
compound.setTag(key, tag);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
@@ -99,4 +98,6 @@ public interface IComponentMap {
|
||||
}
|
||||
|
||||
<T> void set(ComponentType<T> type, Optional<T> value);
|
||||
|
||||
IComponentMap withRegistries(IRegistryHolder registries);
|
||||
}
|
||||
+167
-11
@@ -18,7 +18,14 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component;
|
||||
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
|
||||
import com.github.retrooper.packetevents.util.mappings.GlobalRegistryHolder;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistryHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -26,6 +33,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@NullMarked
|
||||
public class PatchableComponentMap implements IComponentMap {
|
||||
|
||||
public static final PatchableComponentMap EMPTY = new PatchableComponentMap(
|
||||
@@ -33,43 +41,181 @@ public class PatchableComponentMap implements IComponentMap {
|
||||
|
||||
private final Map<ComponentType<?>, ?> base;
|
||||
private final Map<ComponentType<?>, Optional<?>> patches;
|
||||
private final IRegistryHolder registries;
|
||||
|
||||
public PatchableComponentMap(StaticComponentMap base) {
|
||||
this(base.getDelegate(), new HashMap<>());
|
||||
this(base.delegate, new HashMap<>(), base.registries);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PatchableComponentMap(Map<ComponentType<?>, ?> base) {
|
||||
this(base, new HashMap<>());
|
||||
this(base, new HashMap<>(), GlobalRegistryHolder.INSTANCE);
|
||||
}
|
||||
|
||||
public PatchableComponentMap(
|
||||
StaticComponentMap base,
|
||||
Map<ComponentType<?>, Optional<?>> patches
|
||||
) {
|
||||
this(base.getDelegate(), patches);
|
||||
this(base.delegate, patches, base.registries);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PatchableComponentMap(
|
||||
Map<ComponentType<?>, ?> base,
|
||||
Map<ComponentType<?>, Optional<?>> patches
|
||||
) {
|
||||
this.base = Collections.unmodifiableMap(new HashMap<>(base));
|
||||
this.patches = patches;
|
||||
this(base, patches, GlobalRegistryHolder.INSTANCE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // no
|
||||
public PatchableComponentMap(StaticComponentMap base, IRegistryHolder registries) {
|
||||
this(base.delegate, new HashMap<>(), registries);
|
||||
}
|
||||
|
||||
public PatchableComponentMap(Map<ComponentType<?>, ?> base, IRegistryHolder registries) {
|
||||
this(base, new HashMap<>(), registries);
|
||||
}
|
||||
|
||||
public PatchableComponentMap(
|
||||
StaticComponentMap base,
|
||||
Map<ComponentType<?>, Optional<?>> patches,
|
||||
IRegistryHolder registries
|
||||
) {
|
||||
this(base.delegate, patches, registries);
|
||||
}
|
||||
|
||||
public PatchableComponentMap(
|
||||
Map<ComponentType<?>, ?> base,
|
||||
Map<ComponentType<?>, Optional<?>> patches,
|
||||
IRegistryHolder registries
|
||||
) {
|
||||
this.base = Collections.unmodifiableMap(new HashMap<>(base));
|
||||
this.patches = patches;
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
public static PatchableComponentMap read(PacketWrapper<?> wrapper, ItemType item, boolean lengthPrefixed) {
|
||||
return read(wrapper, item.getComponents(wrapper.getServerVersion().toClientVersion()), lengthPrefixed);
|
||||
}
|
||||
|
||||
public static PatchableComponentMap read(PacketWrapper<?> wrapper, StaticComponentMap base, boolean lengthPrefixed) {
|
||||
// read component patch counts
|
||||
int presentCount = wrapper.readVarInt();
|
||||
int absentCount = wrapper.readVarInt();
|
||||
if (presentCount == 0 && absentCount == 0) {
|
||||
return new PatchableComponentMap(base);
|
||||
}
|
||||
|
||||
PatchableComponentMap components = new PatchableComponentMap(base,
|
||||
new HashMap<>(presentCount + absentCount),
|
||||
wrapper.getRegistryHolder());
|
||||
for (int i = 0; i < presentCount; i++) {
|
||||
ComponentType<?> type = wrapper.readMappedEntity(ComponentTypes.getRegistry());
|
||||
// this is not 1:1 how vanilla decodes the length prefix, vanilla slices the buffer and
|
||||
// restricts reading to only the slice; packetevents just verifies the length isn't too large
|
||||
// and throws an error if we actually read more/less than expected
|
||||
int expectedReaderIndex;
|
||||
if (lengthPrefixed) {
|
||||
int size = wrapper.readVarInt();
|
||||
if (size > ByteBufHelper.readableBytes(wrapper.buffer)) {
|
||||
throw new RuntimeException("Component size " + size + " for " + type.getName() + " out of bounds");
|
||||
}
|
||||
expectedReaderIndex = ByteBufHelper.readerIndex(wrapper.buffer) + size;
|
||||
} else {
|
||||
expectedReaderIndex = -1;
|
||||
}
|
||||
// read component value
|
||||
Object value = type.read(wrapper);
|
||||
// if this component is length-prefixed, verify the reader index changed to the expected value
|
||||
if (expectedReaderIndex != -1) {
|
||||
int readerIndex = ByteBufHelper.readerIndex(wrapper.buffer);
|
||||
if (readerIndex != expectedReaderIndex) {
|
||||
throw new RuntimeException("Invalid component read for " + type.getName() + "; expected reader index "
|
||||
+ expectedReaderIndex + ", got reader index " + readerIndex);
|
||||
}
|
||||
}
|
||||
// set component value in component patch-map
|
||||
components.set((ComponentType<Object>) type, value);
|
||||
}
|
||||
for (int i = 0; i < absentCount; i++) {
|
||||
components.unset(wrapper.readMappedEntity(ComponentTypes.getRegistry()));
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemStack stack, boolean lengthPrefixed) {
|
||||
if (!stack.hasComponentPatches()) {
|
||||
wrapper.writeShort(0);
|
||||
} else {
|
||||
write(wrapper, stack.getComponents(), lengthPrefixed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, PatchableComponentMap components, boolean lengthPrefixed) {
|
||||
// write component patch counts
|
||||
Map<ComponentType<?>, Optional<?>> allPatches = components.getPatches();
|
||||
int presentCount = 0, absentCount = 0;
|
||||
for (Map.Entry<ComponentType<?>, Optional<?>> patch : allPatches.entrySet()) {
|
||||
if (patch.getValue().isPresent()) {
|
||||
presentCount++;
|
||||
} else {
|
||||
absentCount++;
|
||||
}
|
||||
}
|
||||
wrapper.writeVarInt(presentCount);
|
||||
wrapper.writeVarInt(absentCount);
|
||||
|
||||
// write present patches
|
||||
for (Map.Entry<ComponentType<?>, Optional<?>> patch : allPatches.entrySet()) {
|
||||
if (patch.getValue().isPresent()) {
|
||||
wrapper.writeVarInt(patch.getKey().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
if (lengthPrefixed) {
|
||||
// easiest solution is to just temporarily replace the buffer
|
||||
Object originalBuffer = wrapper.buffer;
|
||||
wrapper.buffer = ByteBufHelper.allocateNewBuffer(originalBuffer);
|
||||
((ComponentType<Object>) patch.getKey()).write(wrapper, patch.getValue().get());
|
||||
Object componentBuffer = wrapper.buffer;
|
||||
wrapper.buffer = originalBuffer;
|
||||
// after writing to new buffer, write length of newly written buffer to original buffer
|
||||
wrapper.writeVarInt(ByteBufHelper.readableBytes(componentBuffer));
|
||||
// copy component buffer bytes to original buffer
|
||||
ByteBufHelper.writeBytes(wrapper.buffer, componentBuffer);
|
||||
// release component buffer
|
||||
ByteBufHelper.release(componentBuffer);
|
||||
} else {
|
||||
((ComponentType<Object>) patch.getKey()).write(wrapper, patch.getValue().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write absent patches
|
||||
for (Map.Entry<ComponentType<?>, Optional<?>> patch : allPatches.entrySet()) {
|
||||
if (!patch.getValue().isPresent()) {
|
||||
wrapper.writeVarInt(patch.getKey().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> @Nullable T get(ComponentType<T> type) {
|
||||
Optional<?> patched = this.patches.get(type);
|
||||
if (patched != null) {
|
||||
return (T) patched.orElse(null);
|
||||
Object v = patched != null
|
||||
? (T) patched.orElse(null)
|
||||
: (T) this.base.get(type);
|
||||
if (v instanceof ComponentValueRef) {
|
||||
v = ((ComponentValueRef<?>) v).resolve(this.registries);
|
||||
}
|
||||
return (T) this.base.get(type);
|
||||
return (T) v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void set(ComponentType<T> type, Optional<T> value) {
|
||||
Object baseVal = this.base.get(type);
|
||||
if (baseVal instanceof ComponentValueRef) {
|
||||
baseVal = ((ComponentValueRef<?>) baseVal).resolve(this.registries);
|
||||
}
|
||||
|
||||
T newVal = value.orElse(null);
|
||||
if (Objects.equals(baseVal, newVal)) {
|
||||
this.patches.remove(type); // fallback to base
|
||||
@@ -84,14 +230,24 @@ public class PatchableComponentMap implements IComponentMap {
|
||||
return patched != null ? patched.isPresent() : this.base.containsKey(type);
|
||||
}
|
||||
|
||||
public PatchableComponentMap copy() {
|
||||
return new PatchableComponentMap(this.base, new HashMap<>(this.patches));
|
||||
@Override
|
||||
public PatchableComponentMap withRegistries(IRegistryHolder registries) {
|
||||
if (this.registries != registries) {
|
||||
return new PatchableComponentMap(this.base, this.patches, this.registries);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public PatchableComponentMap copy() {
|
||||
return new PatchableComponentMap(this.base, new HashMap<>(this.patches), this.registries);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<ComponentType<?>, ?> getBase() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<ComponentType<?>, Optional<?>> getPatches() {
|
||||
return this.patches;
|
||||
}
|
||||
|
||||
+53
-8
@@ -22,16 +22,21 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAtt
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
|
||||
import com.github.retrooper.packetevents.util.mappings.GlobalRegistryHolder;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistryHolder;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class StaticComponentMap implements IComponentMap {
|
||||
@NullMarked
|
||||
public final class StaticComponentMap implements IComponentMap {
|
||||
|
||||
public static final StaticComponentMap EMPTY = new StaticComponentMap(Collections.emptyMap());
|
||||
|
||||
@@ -46,12 +51,19 @@ public class StaticComponentMap implements IComponentMap {
|
||||
.build();
|
||||
|
||||
private final boolean empty;
|
||||
private final Map<ComponentType<?>, ?> delegate;
|
||||
final Map<ComponentType<?>, ?> delegate;
|
||||
final IRegistryHolder registries;
|
||||
|
||||
@Deprecated
|
||||
public StaticComponentMap(Map<ComponentType<?>, ?> delegate) {
|
||||
this(delegate, GlobalRegistryHolder.INSTANCE);
|
||||
}
|
||||
|
||||
public StaticComponentMap(Map<ComponentType<?>, ?> delegate, IRegistryHolder registries) {
|
||||
this.empty = delegate.isEmpty();
|
||||
this.delegate = this.empty ? Collections.emptyMap()
|
||||
: Collections.unmodifiableMap(new HashMap<>(delegate));
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@@ -63,10 +75,14 @@ public class StaticComponentMap implements IComponentMap {
|
||||
return !this.empty && this.delegate.containsKey(type);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // no
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> @Nullable T get(ComponentType<T> type) {
|
||||
return this.empty ? null : (T) this.delegate.get(type);
|
||||
Object v = this.delegate.get(type);
|
||||
if (v instanceof ComponentValueRef) {
|
||||
v = ((ComponentValueRef<?>) v).resolve(this.registries);
|
||||
}
|
||||
return (T) v;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,10 +90,23 @@ public class StaticComponentMap implements IComponentMap {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public StaticComponentMap merge(StaticComponentMap prioritizedMap) {
|
||||
return builder().setAll(this).setAll(prioritizedMap).build();
|
||||
@Override
|
||||
public StaticComponentMap withRegistries(IRegistryHolder registries) {
|
||||
if (this.registries != registries) {
|
||||
return new StaticComponentMap(this.delegate, registries);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public StaticComponentMap merge(StaticComponentMap prioritizedMap) {
|
||||
return builder().setAll(this).setAll(prioritizedMap).setRegistries(this.registries).build();
|
||||
}
|
||||
|
||||
public Set<ComponentType<?>> getKeys() {
|
||||
return this.delegate.keySet();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<ComponentType<?>, ?> getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
@@ -107,12 +136,18 @@ public class StaticComponentMap implements IComponentMap {
|
||||
public static class Builder {
|
||||
|
||||
private final Map<ComponentType<?>, Object> map = new HashMap<>();
|
||||
private IRegistryHolder registries = GlobalRegistryHolder.INSTANCE;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
public StaticComponentMap build() {
|
||||
return new StaticComponentMap(this.map);
|
||||
return new StaticComponentMap(this.map, this.registries);
|
||||
}
|
||||
|
||||
public Builder setRegistries(IRegistryHolder registries) {
|
||||
this.registries = registries;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAll(StaticComponentMap.Builder map) {
|
||||
@@ -120,7 +155,7 @@ public class StaticComponentMap implements IComponentMap {
|
||||
}
|
||||
|
||||
public Builder setAll(StaticComponentMap map) {
|
||||
return this.setAll(map.getDelegate());
|
||||
return this.setAll(map.delegate);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -143,5 +178,15 @@ public class StaticComponentMap implements IComponentMap {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Builder set(ComponentType<T> type, @Nullable ComponentValueRef<T> ref) {
|
||||
if (ref == null) {
|
||||
this.map.remove(type);
|
||||
} else {
|
||||
// needs special handling on get
|
||||
this.map.put(type, ref);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.cat.CatSoundVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cat.CatSoundVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CatSoundVariantComponent {
|
||||
|
||||
private final CatSoundVariant soundVariant;
|
||||
|
||||
public CatSoundVariantComponent(CatSoundVariant soundVariant) {
|
||||
this.soundVariant = soundVariant;
|
||||
}
|
||||
|
||||
public static CatSoundVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
CatSoundVariant type = wrapper.readMappedEntity(CatSoundVariants.getRegistry());
|
||||
return new CatSoundVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CatSoundVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.soundVariant);
|
||||
}
|
||||
|
||||
public CatSoundVariant getSoundVariant() {
|
||||
return this.soundVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof CatSoundVariantComponent)) return false;
|
||||
CatSoundVariantComponent that = (CatSoundVariantComponent) obj;
|
||||
return this.soundVariant.equals(that.soundVariant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.soundVariant);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenSoundVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenSoundVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChickenSoundVariantComponent {
|
||||
|
||||
private final ChickenSoundVariant soundVariant;
|
||||
|
||||
public ChickenSoundVariantComponent(ChickenSoundVariant soundVariant) {
|
||||
this.soundVariant = soundVariant;
|
||||
}
|
||||
|
||||
public static ChickenSoundVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
ChickenSoundVariant type = wrapper.readMappedEntity(ChickenSoundVariants.getRegistry());
|
||||
return new ChickenSoundVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ChickenSoundVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.soundVariant);
|
||||
}
|
||||
|
||||
public ChickenSoundVariant getSoundVariant() {
|
||||
return this.soundVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ChickenSoundVariantComponent)) return false;
|
||||
ChickenSoundVariantComponent that = (ChickenSoundVariantComponent) obj;
|
||||
return this.soundVariant.equals(that.soundVariant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.soundVariant);
|
||||
}
|
||||
}
|
||||
+21
-1
@@ -18,29 +18,49 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariants;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public class ChickenVariantComponent {
|
||||
|
||||
private MaybeMappedEntity<ChickenVariant> variant;
|
||||
|
||||
public ChickenVariantComponent(ChickenVariant variant) {
|
||||
this(new MaybeMappedEntity<>(variant));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.5-1.21.11
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ChickenVariantComponent(MaybeMappedEntity<ChickenVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static ChickenVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ChickenVariantComponent(ChickenVariant.read(wrapper));
|
||||
}
|
||||
MaybeMappedEntity<ChickenVariant> variant = MaybeMappedEntity.read(wrapper,
|
||||
ChickenVariants.getRegistry(), ChickenVariant::read);
|
||||
return new ChickenVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ChickenVariantComponent component) {
|
||||
MaybeMappedEntity.write(wrapper, component.variant, ChickenVariant::write);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
ChickenVariant.write(wrapper, component.variant.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, component.variant, ChickenVariant::write);
|
||||
}
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<ChickenVariant> getVariant() {
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.cow.CowSoundVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cow.CowSoundVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CowSoundVariantComponent {
|
||||
|
||||
private final CowSoundVariant soundVariant;
|
||||
|
||||
public CowSoundVariantComponent(CowSoundVariant soundVariant) {
|
||||
this.soundVariant = soundVariant;
|
||||
}
|
||||
|
||||
public static CowSoundVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
CowSoundVariant type = wrapper.readMappedEntity(CowSoundVariants.getRegistry());
|
||||
return new CowSoundVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CowSoundVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.soundVariant);
|
||||
}
|
||||
|
||||
public CowSoundVariant getSoundVariant() {
|
||||
return this.soundVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof CowSoundVariantComponent)) return false;
|
||||
CowSoundVariantComponent that = (CowSoundVariantComponent) obj;
|
||||
return this.soundVariant.equals(that.soundVariant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.soundVariant);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.DyeColor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class CushionColorComponent {
|
||||
|
||||
private DyeColor color;
|
||||
|
||||
public CushionColorComponent(DyeColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static CushionColorComponent read(PacketWrapper<?> wrapper) {
|
||||
DyeColor type = DyeColor.read(wrapper);
|
||||
return new CushionColorComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CushionColorComponent component) {
|
||||
DyeColor.write(wrapper, component.color);
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setDyeColor(DyeColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof CushionColorComponent)) return false;
|
||||
CushionColorComponent that = (CushionColorComponent) obj;
|
||||
return this.color.equals(that.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.color);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -33,12 +33,12 @@ public class PaintingVariantComponent {
|
||||
}
|
||||
|
||||
public static PaintingVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
PaintingVariant variant = wrapper.readMappedEntity(PaintingVariants.getRegistry());
|
||||
PaintingVariant variant = PaintingVariant.read(wrapper);
|
||||
return new PaintingVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, PaintingVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
PaintingVariant.write(wrapper, component.variant);
|
||||
}
|
||||
|
||||
public PaintingVariant getVariant() {
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.pig.PigSoundVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pig.PigSoundVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PigSoundVariantComponent {
|
||||
|
||||
private final PigSoundVariant soundVariant;
|
||||
|
||||
public PigSoundVariantComponent(PigSoundVariant soundVariant) {
|
||||
this.soundVariant = soundVariant;
|
||||
}
|
||||
|
||||
public static PigSoundVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
PigSoundVariant type = wrapper.readMappedEntity(PigSoundVariants.getRegistry());
|
||||
return new PigSoundVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, PigSoundVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.soundVariant);
|
||||
}
|
||||
|
||||
public PigSoundVariant getSoundVariant() {
|
||||
return this.soundVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PigSoundVariantComponent)) return false;
|
||||
PigSoundVariantComponent that = (PigSoundVariantComponent) obj;
|
||||
return this.soundVariant.equals(that.soundVariant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.soundVariant);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.blockentity.decopot.DecoratedPotPattern;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class PotteryPatternComponent {
|
||||
|
||||
private DecoratedPotPattern pattern;
|
||||
|
||||
public PotteryPatternComponent(DecoratedPotPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public static PotteryPatternComponent read(PacketWrapper<?> wrapper) {
|
||||
DecoratedPotPattern variant = DecoratedPotPattern.read(wrapper);
|
||||
return new PotteryPatternComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, PotteryPatternComponent component) {
|
||||
DecoratedPotPattern.write(wrapper, component.pattern);
|
||||
}
|
||||
|
||||
public DecoratedPotPattern getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
public void setPattern(DecoratedPotPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PotteryPatternComponent)) return false;
|
||||
PotteryPatternComponent that = (PotteryPatternComponent) obj;
|
||||
return this.pattern.equals(that.pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.pattern);
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.DyeColor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class SignTextComponent {
|
||||
|
||||
private final List<Component> messages;
|
||||
private final @Nullable List<Component> filteredMessages;
|
||||
private final DyeColor color;
|
||||
private final boolean glowing;
|
||||
|
||||
public SignTextComponent(
|
||||
List<Component> messages, @Nullable List<Component> filteredMessages,
|
||||
DyeColor color, boolean glowing
|
||||
) {
|
||||
this.messages = Collections.unmodifiableList(messages);
|
||||
this.filteredMessages = filteredMessages != null ? Collections.unmodifiableList(filteredMessages) : null;
|
||||
this.color = color;
|
||||
this.glowing = glowing;
|
||||
}
|
||||
|
||||
public static SignTextComponent read(PacketWrapper<?> wrapper) {
|
||||
List<Component> messages = wrapper.readFixedList(PacketWrapper::readComponent, 4);
|
||||
List<Component> filteredMessages = wrapper.readOptional(ew ->
|
||||
ew.readFixedList(PacketWrapper::readComponent, 4));
|
||||
DyeColor color = DyeColor.read(wrapper);
|
||||
boolean glowing = wrapper.readBoolean();
|
||||
return new SignTextComponent(messages, filteredMessages, color, glowing);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, SignTextComponent component) {
|
||||
wrapper.writeFixedList(component.messages, PacketWrapper::writeComponent);
|
||||
wrapper.writeOptional(component.filteredMessages, (ew, v) ->
|
||||
ew.writeFixedList(v, PacketWrapper::writeComponent));
|
||||
DyeColor.write(wrapper, component.color);
|
||||
wrapper.writeBoolean(component.glowing);
|
||||
}
|
||||
|
||||
public List<Component> getMessages() {
|
||||
return this.messages;
|
||||
}
|
||||
|
||||
public @Nullable List<Component> getFilteredMessages() {
|
||||
return this.filteredMessages;
|
||||
}
|
||||
|
||||
public DyeColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public boolean isGlowing() {
|
||||
return this.glowing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof SignTextComponent)) return false;
|
||||
SignTextComponent that = (SignTextComponent) obj;
|
||||
if (this.glowing != that.glowing) return false;
|
||||
if (!this.color.equals(that.color)) return false;
|
||||
if (!this.messages.equals(that.messages)) return false;
|
||||
return Objects.equals(this.filteredMessages, that.filteredMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.messages, this.filteredMessages, this.color, this.glowing);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStackSerialization;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.2+
|
||||
*/
|
||||
@NullMarked
|
||||
public class SulfurCubeContentComponent {
|
||||
|
||||
private ItemStack stack;
|
||||
|
||||
public SulfurCubeContentComponent(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static SulfurCubeContentComponent read(PacketWrapper<?> wrapper) {
|
||||
ItemStack stack = ItemStackSerialization.readTemplate(wrapper);
|
||||
return new SulfurCubeContentComponent(stack);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, SulfurCubeContentComponent component) {
|
||||
ItemStackSerialization.writeTemplate(wrapper, component.stack);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
SulfurCubeContentComponent that = (SulfurCubeContentComponent) obj;
|
||||
return this.stack.equals(that.stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.stack);
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.world.blockentity.BlockEntityType;
|
||||
import com.github.retrooper.packetevents.protocol.world.blockentity.BlockEntityTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public final class TypedBlockEntityData {
|
||||
|
||||
private static final BlockEntityType FALLBACK_TYPE = BlockEntityTypes.FURNACE;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private final BlockEntityType type;
|
||||
private final NBTCompound compound;
|
||||
|
||||
public TypedBlockEntityData(NBTCompound compound) {
|
||||
this(FALLBACK_TYPE, compound);
|
||||
}
|
||||
|
||||
public TypedBlockEntityData(BlockEntityType type, NBTCompound compound) {
|
||||
this.type = type;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public static TypedBlockEntityData read(PacketWrapper<?> wrapper) {
|
||||
BlockEntityType type = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? wrapper.readMappedEntity(BlockEntityTypes.getRegistry()) : FALLBACK_TYPE;
|
||||
NBTCompound compound = wrapper.readNBT();
|
||||
return new TypedBlockEntityData(type, compound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, TypedBlockEntityData data) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
wrapper.writeMappedEntity(data.type);
|
||||
}
|
||||
wrapper.writeNBT(data.compound);
|
||||
}
|
||||
|
||||
public BlockEntityType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public NBTCompound getCompound() {
|
||||
return this.compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
TypedBlockEntityData that = (TypedBlockEntityData) obj;
|
||||
if (!this.type.equals(that.type)) return false;
|
||||
return this.compound.equals(that.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.compound);
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public final class TypedEntityData {
|
||||
|
||||
private static final EntityType FALLBACK_TYPE = EntityTypes.PIG;
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private final EntityType type;
|
||||
private final NBTCompound compound;
|
||||
|
||||
public TypedEntityData(NBTCompound compound) {
|
||||
this(FALLBACK_TYPE, compound);
|
||||
}
|
||||
|
||||
public TypedEntityData(EntityType type, NBTCompound compound) {
|
||||
this.type = type;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public static TypedEntityData read(PacketWrapper<?> wrapper) {
|
||||
EntityType type = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? wrapper.readMappedEntity(EntityTypes.getRegistry()) : FALLBACK_TYPE;
|
||||
NBTCompound compound = wrapper.readNBT();
|
||||
return new TypedEntityData(type, compound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, TypedEntityData data) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
wrapper.writeMappedEntity(data.type);
|
||||
}
|
||||
wrapper.writeNBT(data.compound);
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public NBTCompound getCompound() {
|
||||
return this.compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
TypedEntityData that = (TypedEntityData) obj;
|
||||
if (!this.type.equals(that.type)) return false;
|
||||
return this.compound.equals(that.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.compound);
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.nautilus.ZombieNautilusVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.nautilus.ZombieNautilusVariants;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public class ZombieNautilusVariantComponent {
|
||||
|
||||
private MaybeMappedEntity<ZombieNautilusVariant> variant;
|
||||
|
||||
public ZombieNautilusVariantComponent(ZombieNautilusVariant variant) {
|
||||
this(new MaybeMappedEntity<>(variant));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.11
|
||||
*/
|
||||
public ZombieNautilusVariantComponent(MaybeMappedEntity<ZombieNautilusVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static ZombieNautilusVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ZombieNautilusVariantComponent(ZombieNautilusVariant.read(wrapper));
|
||||
}
|
||||
MaybeMappedEntity<ZombieNautilusVariant> variant = MaybeMappedEntity.read(wrapper,
|
||||
ZombieNautilusVariants.getRegistry(), ZombieNautilusVariant::read);
|
||||
return new ZombieNautilusVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ZombieNautilusVariantComponent component) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
ZombieNautilusVariant.write(wrapper, component.variant.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, component.variant, ZombieNautilusVariant::write);
|
||||
}
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<ZombieNautilusVariant> getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(MaybeMappedEntity<ZombieNautilusVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ZombieNautilusVariantComponent)) return false;
|
||||
ZombieNautilusVariantComponent that = (ZombieNautilusVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.blocktransformer.BlockTransformer;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockTransformerComponent {
|
||||
|
||||
private final BlockTransformer transformer;
|
||||
|
||||
public BlockTransformerComponent(BlockTransformer transformer) {
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
public static BlockTransformerComponent read(PacketWrapper<?> wrapper) {
|
||||
return new BlockTransformerComponent(BlockTransformer.read(wrapper));
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, BlockTransformerComponent transformer) {
|
||||
BlockTransformer.write(wrapper, transformer.transformer);
|
||||
}
|
||||
|
||||
public BlockTransformer getTransformer() {
|
||||
return this.transformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof BlockTransformerComponent)) return false;
|
||||
BlockTransformerComponent that = (BlockTransformerComponent) obj;
|
||||
return this.transformer.equals(that.transformer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.transformer);
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStackSerialization;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,12 +34,12 @@ public class BundleContents {
|
||||
}
|
||||
|
||||
public static BundleContents read(PacketWrapper<?> wrapper) {
|
||||
List<ItemStack> items = wrapper.readList(PacketWrapper::readPresentItemStack);
|
||||
List<ItemStack> items = wrapper.readList(ItemStackSerialization::readTemplate);
|
||||
return new BundleContents(items);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, BundleContents projectiles) {
|
||||
wrapper.writeList(projectiles.items, PacketWrapper::writePresentItemStack);
|
||||
wrapper.writeList(projectiles.items, ItemStackSerialization::writeTemplate);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack itemStack) {
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStackSerialization;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,12 +34,12 @@ public class ChargedProjectiles {
|
||||
}
|
||||
|
||||
public static ChargedProjectiles read(PacketWrapper<?> wrapper) {
|
||||
List<ItemStack> items = wrapper.readList(PacketWrapper::readPresentItemStack);
|
||||
List<ItemStack> items = wrapper.readList(ItemStackSerialization::readTemplate);
|
||||
return new ChargedProjectiles(items);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ChargedProjectiles projectiles) {
|
||||
wrapper.writeList(projectiles.items, PacketWrapper::writePresentItemStack);
|
||||
wrapper.writeList(projectiles.items, ItemStackSerialization::writeTemplate);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack itemStack) {
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureNbtUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
public class CustomData {
|
||||
@@ -34,9 +35,10 @@ public class CustomData {
|
||||
return (NBTCompound) nbt;
|
||||
}
|
||||
if (nbt instanceof NBTString) {
|
||||
// TODO: parse nbt string
|
||||
String nbtString = ((NBTString) nbt).getValue();
|
||||
return (NBTCompound) AdventureNbtUtil.fromString(nbtString);
|
||||
}
|
||||
throw new UnsupportedOperationException("Unsupported custom data nbt type: " + nbt.getType());
|
||||
throw new UnsupportedOperationException("Unsupported custom data tag: " + nbt);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, NBTCompound compound) {
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2026 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemAdditionalTradeCost {
|
||||
|
||||
private final int cost;
|
||||
|
||||
public ItemAdditionalTradeCost(int cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public static ItemAdditionalTradeCost read(PacketWrapper<?> wrapper) {
|
||||
return new ItemAdditionalTradeCost(wrapper.readVarInt());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemAdditionalTradeCost cost) {
|
||||
wrapper.writeVarInt(cost.cost);
|
||||
}
|
||||
|
||||
public ItemAdditionalTradeCost withCost(int cost) {
|
||||
return new ItemAdditionalTradeCost(cost);
|
||||
}
|
||||
|
||||
public int getCost() {
|
||||
return this.cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ItemAdditionalTradeCost)) return false;
|
||||
ItemAdditionalTradeCost that = (ItemAdditionalTradeCost) obj;
|
||||
return this.cost == that.cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.cost);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class ItemAdventurePredicate {
|
||||
|
||||
public static BlockPredicate read(PacketWrapper<?> wrapper) {
|
||||
MappedEntitySet<StateType.Mapped> blocks = wrapper.readOptional(
|
||||
ew -> MappedEntitySet.read(ew, StateTypes::getMappedById));
|
||||
ew -> MappedEntitySet.read(ew, StateTypes.getRegistry()));
|
||||
List<PropertyMatcher> properties = wrapper.readOptional(
|
||||
ew -> wrapper.readList(PropertyMatcher::read));
|
||||
NBTCompound nbt = wrapper.readOptional(PacketWrapper::readNBT);
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemAttackRange {
|
||||
|
||||
private float minRange;
|
||||
private float maxRange;
|
||||
private float minCreativeRange;
|
||||
private float maxCreativeRange;
|
||||
private float hitboxMargin;
|
||||
private float mobFactor;
|
||||
|
||||
public ItemAttackRange(
|
||||
float minRange, float maxRange,
|
||||
float minCreativeRange, float maxCreativeRange,
|
||||
float hitboxMargin, float mobFactor
|
||||
) {
|
||||
this.minRange = minRange;
|
||||
this.maxRange = maxRange;
|
||||
this.minCreativeRange = minCreativeRange;
|
||||
this.maxCreativeRange = maxCreativeRange;
|
||||
this.hitboxMargin = hitboxMargin;
|
||||
this.mobFactor = mobFactor;
|
||||
}
|
||||
|
||||
public static ItemAttackRange read(PacketWrapper<?> wrapper) {
|
||||
float minRange = wrapper.readFloat();
|
||||
float maxRange = wrapper.readFloat();
|
||||
float minCreativeRange = wrapper.readFloat();
|
||||
float maxCreativeRange = wrapper.readFloat();
|
||||
float hitboxMargin = wrapper.readFloat();
|
||||
float mobFactor = wrapper.readFloat();
|
||||
return new ItemAttackRange(minRange, maxRange, minCreativeRange, maxCreativeRange, hitboxMargin, mobFactor);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemAttackRange component) {
|
||||
wrapper.writeFloat(component.minRange);
|
||||
wrapper.writeFloat(component.maxRange);
|
||||
wrapper.writeFloat(component.minCreativeRange);
|
||||
wrapper.writeFloat(component.maxCreativeRange);
|
||||
wrapper.writeFloat(component.hitboxMargin);
|
||||
wrapper.writeFloat(component.mobFactor);
|
||||
}
|
||||
|
||||
public float getMinRange() {
|
||||
return this.minRange;
|
||||
}
|
||||
|
||||
public void setMinRange(float minRange) {
|
||||
this.minRange = minRange;
|
||||
}
|
||||
|
||||
public float getMaxRange() {
|
||||
return this.maxRange;
|
||||
}
|
||||
|
||||
public void setMaxRange(float maxRange) {
|
||||
this.maxRange = maxRange;
|
||||
}
|
||||
|
||||
public float getMinCreativeRange() {
|
||||
return this.minCreativeRange;
|
||||
}
|
||||
|
||||
public void setMinCreativeRange(float minCreativeRange) {
|
||||
this.minCreativeRange = minCreativeRange;
|
||||
}
|
||||
|
||||
public float getMaxCreativeRange() {
|
||||
return this.maxCreativeRange;
|
||||
}
|
||||
|
||||
public void setMaxCreativeRange(float maxCreativeRange) {
|
||||
this.maxCreativeRange = maxCreativeRange;
|
||||
}
|
||||
|
||||
public float getHitboxMargin() {
|
||||
return this.hitboxMargin;
|
||||
}
|
||||
|
||||
public void setHitboxMargin(float hitboxMargin) {
|
||||
this.hitboxMargin = hitboxMargin;
|
||||
}
|
||||
|
||||
public float getMobFactor() {
|
||||
return this.mobFactor;
|
||||
}
|
||||
|
||||
public void setMobFactor(float mobFactor) {
|
||||
this.mobFactor = mobFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemAttackRange that = (ItemAttackRange) obj;
|
||||
if (Float.compare(that.minRange, this.minRange) != 0) return false;
|
||||
if (Float.compare(that.maxRange, this.maxRange) != 0) return false;
|
||||
if (Float.compare(that.minCreativeRange, this.minCreativeRange) != 0) return false;
|
||||
if (Float.compare(that.maxCreativeRange, this.maxCreativeRange) != 0) return false;
|
||||
if (Float.compare(that.hitboxMargin, this.hitboxMargin) != 0) return false;
|
||||
return Float.compare(that.mobFactor, this.mobFactor) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.minRange, this.maxRange, this.minCreativeRange, this.maxCreativeRange, this.hitboxMargin, this.mobFactor);
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
@@ -68,37 +69,50 @@ public class ItemBees {
|
||||
|
||||
public static class BeeEntry {
|
||||
|
||||
private NBTCompound entityData;
|
||||
private TypedEntityData entityData;
|
||||
private int ticksInHive;
|
||||
private int minTicksInHive;
|
||||
|
||||
@Deprecated
|
||||
public BeeEntry(NBTCompound entityData, int ticksInHive, int minTicksInHive) {
|
||||
this(new TypedEntityData(entityData), ticksInHive, minTicksInHive);
|
||||
}
|
||||
|
||||
public BeeEntry(TypedEntityData entityData, int ticksInHive, int minTicksInHive) {
|
||||
this.entityData = entityData;
|
||||
this.ticksInHive = ticksInHive;
|
||||
this.minTicksInHive = minTicksInHive;
|
||||
}
|
||||
|
||||
public static BeeEntry read(PacketWrapper<?> wrapper) {
|
||||
NBTCompound entityData = wrapper.readNBT();
|
||||
TypedEntityData entityData = TypedEntityData.read(wrapper);
|
||||
int ticksInHive = wrapper.readVarInt();
|
||||
int minTicksInHive = wrapper.readVarInt();
|
||||
return new BeeEntry(entityData, ticksInHive, minTicksInHive);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, BeeEntry bee) {
|
||||
wrapper.writeNBT(bee.entityData);
|
||||
TypedEntityData.write(wrapper, bee.entityData);
|
||||
wrapper.writeVarInt(bee.ticksInHive);
|
||||
wrapper.writeVarInt(bee.minTicksInHive);
|
||||
}
|
||||
|
||||
public NBTCompound getEntityData() {
|
||||
public TypedEntityData getTypedEntityData() {
|
||||
return this.entityData;
|
||||
}
|
||||
|
||||
public void setEntityData(NBTCompound entityData) {
|
||||
public void setTypedEntityData(TypedEntityData entityData) {
|
||||
this.entityData = entityData;
|
||||
}
|
||||
|
||||
public NBTCompound getEntityData() {
|
||||
return this.entityData.getCompound();
|
||||
}
|
||||
|
||||
public void setEntityData(NBTCompound entityData) {
|
||||
this.entityData = new TypedEntityData(entityData);
|
||||
}
|
||||
|
||||
public int getTicksInHive() {
|
||||
return this.ticksInHive;
|
||||
}
|
||||
|
||||
+45
-5
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
|
||||
import com.github.retrooper.packetevents.protocol.sound.Sound;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageType;
|
||||
@@ -29,13 +30,19 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public class ItemBlocksAttacks {
|
||||
|
||||
private float blockDelaySeconds;
|
||||
private float disableCooldownScale;
|
||||
private List<DamageReduction> damageReductions;
|
||||
private ItemDamageFunction itemDamage;
|
||||
private @Nullable ResourceLocation bypassedBy;
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
private @Nullable MappedEntitySet<DamageType> bypassedBy;
|
||||
private @Nullable Sound blockSound;
|
||||
private @Nullable Sound disableSound;
|
||||
|
||||
@@ -43,6 +50,19 @@ public class ItemBlocksAttacks {
|
||||
float blockDelaySeconds, float disableCooldownScale, List<DamageReduction> damageReductions,
|
||||
ItemDamageFunction itemDamage, @Nullable ResourceLocation bypassedBy,
|
||||
@Nullable Sound blockSound, @Nullable Sound disableSound
|
||||
) {
|
||||
this(blockDelaySeconds, disableCooldownScale, damageReductions, itemDamage,
|
||||
bypassedBy != null ? new MappedEntitySet<>(bypassedBy) : null,
|
||||
blockSound, disableSound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public ItemBlocksAttacks(
|
||||
float blockDelaySeconds, float disableCooldownScale, List<DamageReduction> damageReductions,
|
||||
ItemDamageFunction itemDamage, @Nullable MappedEntitySet<DamageType> bypassedBy,
|
||||
@Nullable Sound blockSound, @Nullable Sound disableSound
|
||||
) {
|
||||
this.blockDelaySeconds = blockDelaySeconds;
|
||||
this.disableCooldownScale = disableCooldownScale;
|
||||
@@ -58,7 +78,9 @@ public class ItemBlocksAttacks {
|
||||
float disableCooldownScale = wrapper.readFloat();
|
||||
List<DamageReduction> damageReductions = wrapper.readList(DamageReduction::read);
|
||||
ItemDamageFunction itemDamage = ItemDamageFunction.read(wrapper);
|
||||
ResourceLocation bypassedBy = wrapper.readOptional(PacketWrapper::readIdentifier);
|
||||
MappedEntitySet<DamageType> bypassedBy = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)
|
||||
? wrapper.readOptional(ew -> MappedEntitySet.read(wrapper, DamageTypes.getRegistry()))
|
||||
: wrapper.readOptional(ew -> new MappedEntitySet<>(ew.readIdentifier()));
|
||||
Sound blockSound = wrapper.readOptional(Sound::read);
|
||||
Sound disableSound = wrapper.readOptional(Sound::read);
|
||||
return new ItemBlocksAttacks(
|
||||
@@ -71,7 +93,11 @@ public class ItemBlocksAttacks {
|
||||
wrapper.writeFloat(attack.disableCooldownScale);
|
||||
wrapper.writeList(attack.damageReductions, DamageReduction::write);
|
||||
ItemDamageFunction.write(wrapper, attack.itemDamage);
|
||||
wrapper.writeOptional(attack.bypassedBy, PacketWrapper::writeIdentifier);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
wrapper.writeOptional(attack.bypassedBy, MappedEntitySet::write);
|
||||
} else {
|
||||
wrapper.writeOptional(attack.getBypassedBy(), PacketWrapper::writeIdentifier);
|
||||
}
|
||||
wrapper.writeOptional(attack.blockSound, Sound::write);
|
||||
wrapper.writeOptional(attack.disableSound, Sound::write);
|
||||
}
|
||||
@@ -108,14 +134,28 @@ public class ItemBlocksAttacks {
|
||||
this.itemDamage = itemDamage;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getBypassedBy() {
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public @Nullable MappedEntitySet<DamageType> getBypassedBySet() {
|
||||
return this.bypassedBy;
|
||||
}
|
||||
|
||||
public void setBypassedBy(@Nullable ResourceLocation bypassedBy) {
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public void setBypassedBySet(@Nullable MappedEntitySet<DamageType> bypassedBy) {
|
||||
this.bypassedBy = bypassedBy;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getBypassedBy() {
|
||||
return this.bypassedBy != null ? this.bypassedBy.getTagKey() : null;
|
||||
}
|
||||
|
||||
public void setBypassedBy(@Nullable ResourceLocation bypassedBy) {
|
||||
this.bypassedBy = bypassedBy != null ? new MappedEntitySet<>(bypassedBy) : null;
|
||||
}
|
||||
|
||||
public @Nullable Sound getBlockSound() {
|
||||
return this.blockSound;
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.numbers.ResolvableFloat;
|
||||
import com.github.retrooper.packetevents.protocol.world.numbers.ResolvableInt;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemBrewingFuel {
|
||||
|
||||
private final ResolvableInt uses;
|
||||
private final ResolvableFloat speedMultiplier;
|
||||
|
||||
public ItemBrewingFuel(ResolvableInt uses, ResolvableFloat speedMultiplier) {
|
||||
this.uses = uses;
|
||||
this.speedMultiplier = speedMultiplier;
|
||||
}
|
||||
|
||||
public static ItemBrewingFuel read(PacketWrapper<?> wrapper) {
|
||||
ResolvableInt uses = ResolvableInt.read(wrapper);
|
||||
ResolvableFloat speedMultiplier = ResolvableFloat.read(wrapper);
|
||||
return new ItemBrewingFuel(uses, speedMultiplier);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemBrewingFuel fuel) {
|
||||
ResolvableInt.write(wrapper, fuel.uses);
|
||||
ResolvableFloat.write(wrapper, fuel.speedMultiplier);
|
||||
}
|
||||
|
||||
public ResolvableInt getUses() {
|
||||
return this.uses;
|
||||
}
|
||||
|
||||
public ResolvableFloat getSpeedMultiplier() {
|
||||
return this.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
ItemBrewingFuel that = (ItemBrewingFuel) obj;
|
||||
if (!this.uses.equals(that.uses)) return false;
|
||||
return this.speedMultiplier.equals(that.speedMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.uses, this.speedMultiplier);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.numbers.ResolvableInt;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemCompostable {
|
||||
|
||||
private final ResolvableInt layers;
|
||||
|
||||
public ItemCompostable(ResolvableInt layers) {
|
||||
this.layers = layers;
|
||||
}
|
||||
|
||||
public static ItemCompostable read(PacketWrapper<?> wrapper) {
|
||||
ResolvableInt layers = ResolvableInt.read(wrapper);
|
||||
return new ItemCompostable(layers);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemCompostable compostable) {
|
||||
ResolvableInt.write(wrapper, compostable.layers);
|
||||
}
|
||||
|
||||
public ResolvableInt getLayers() {
|
||||
return this.layers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
ItemCompostable that = (ItemCompostable) obj;
|
||||
return this.layers.equals(that.layers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.layers);
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -130,15 +130,19 @@ public class ItemConsumable {
|
||||
DRINK,
|
||||
BLOCK,
|
||||
BOW,
|
||||
SPEAR,
|
||||
TRIDENT,
|
||||
CROSSBOW,
|
||||
SPYGLASS,
|
||||
TOOT_HORN,
|
||||
BRUSH,
|
||||
/**
|
||||
* Added with 1.21.4
|
||||
* @versions 1.21.4+
|
||||
*/
|
||||
BUNDLE,
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
SPEAR,
|
||||
;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStackSerialization;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,12 +34,12 @@ public class ItemContainerContents {
|
||||
}
|
||||
|
||||
public static ItemContainerContents read(PacketWrapper<?> wrapper) {
|
||||
List<ItemStack> items = wrapper.readList(PacketWrapper::readItemStack);
|
||||
List<ItemStack> items = wrapper.readList(ItemStackSerialization::readOptionalTemplate);
|
||||
return new ItemContainerContents(items);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemContainerContents contents) {
|
||||
wrapper.writeList(contents.items, PacketWrapper::writeItemStack);
|
||||
wrapper.writeList(contents.items, ItemStackSerialization::writeOptionalTemplate);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack itemStack) {
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.numbers.ResolvableFloat;
|
||||
import com.github.retrooper.packetevents.protocol.world.numbers.ResolvableInt;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemCookingFuel {
|
||||
|
||||
private final ResolvableInt burnTime;
|
||||
private final ResolvableFloat speedMultiplier;
|
||||
|
||||
public ItemCookingFuel(ResolvableInt burnTime, ResolvableFloat speedMultiplier) {
|
||||
this.burnTime = burnTime;
|
||||
this.speedMultiplier = speedMultiplier;
|
||||
}
|
||||
|
||||
public static ItemCookingFuel read(PacketWrapper<?> wrapper) {
|
||||
ResolvableInt uses = ResolvableInt.read(wrapper);
|
||||
ResolvableFloat speedMultiplier = ResolvableFloat.read(wrapper);
|
||||
return new ItemCookingFuel(uses, speedMultiplier);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemCookingFuel fuel) {
|
||||
ResolvableInt.write(wrapper, fuel.burnTime);
|
||||
ResolvableFloat.write(wrapper, fuel.speedMultiplier);
|
||||
}
|
||||
|
||||
public ResolvableInt getBurnTime() {
|
||||
return this.burnTime;
|
||||
}
|
||||
|
||||
public ResolvableFloat getSpeedMultiplier() {
|
||||
return this.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
ItemCookingFuel that = (ItemCookingFuel) obj;
|
||||
if (!this.burnTime.equals(that.burnTime)) return false;
|
||||
return this.speedMultiplier.equals(that.speedMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.burnTime, this.speedMultiplier);
|
||||
}
|
||||
}
|
||||
+22
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Custom model data was completely rewritten with 1.21.4.
|
||||
@@ -131,4 +132,25 @@ public class ItemCustomModelData {
|
||||
this.floats.set(0, (float) legacyId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ItemCustomModelData)) return false;
|
||||
ItemCustomModelData that = (ItemCustomModelData) obj;
|
||||
if (!floats.equals(that.floats)) return false;
|
||||
if (!flags.equals(that.flags)) return false;
|
||||
if (!strings.equals(that.strings)) return false;
|
||||
return colors.equals(that.colors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.floats, this.flags, this.strings, this.colors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemCustomModelData{floats=" + floats + ", flags=" + ", strings=" + flags + strings + ", colors=" + colors + '}';
|
||||
}
|
||||
}
|
||||
+51
-10
@@ -18,33 +18,74 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageType;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageTypes;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemDamageResistant {
|
||||
|
||||
private ResourceLocation typesTagKey;
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
private MappedEntitySet<DamageType> types;
|
||||
|
||||
public ItemDamageResistant(ResourceLocation typesTagKey) {
|
||||
this.typesTagKey = typesTagKey;
|
||||
public ItemDamageResistant(ResourceLocation types) {
|
||||
this(new MappedEntitySet<>(types));
|
||||
}
|
||||
|
||||
public ItemDamageResistant(MappedEntitySet<DamageType> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public static ItemDamageResistant read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ItemDamageResistant(MappedEntitySet.read(wrapper, DamageTypes.getRegistry()));
|
||||
}
|
||||
return new ItemDamageResistant(wrapper.readIdentifier());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemDamageResistant resistant) {
|
||||
wrapper.writeIdentifier(resistant.typesTagKey);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
MappedEntitySet.write(wrapper, resistant.types);
|
||||
} else {
|
||||
wrapper.writeIdentifier(resistant.getTypesTagKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public MappedEntitySet<DamageType> getTypes() {
|
||||
return this.types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public void setTypes(MappedEntitySet<DamageType> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public ResourceLocation getTypesTagKey() {
|
||||
return this.typesTagKey;
|
||||
ResourceLocation tagKey = this.types.getTagKey();
|
||||
if (tagKey == null) {
|
||||
throw new IllegalStateException("No tag key present");
|
||||
}
|
||||
return tagKey;
|
||||
}
|
||||
|
||||
public void setTypesTagKey(ResourceLocation typesTagKey) {
|
||||
this.typesTagKey = typesTagKey;
|
||||
public void setTypesTagKey(ResourceLocation types) {
|
||||
this.types = new MappedEntitySet<>(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,16 +93,16 @@ public class ItemDamageResistant {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ItemDamageResistant)) return false;
|
||||
ItemDamageResistant that = (ItemDamageResistant) obj;
|
||||
return this.typesTagKey.equals(that.typesTagKey);
|
||||
return this.types.equals(that.types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.typesTagKey);
|
||||
return Objects.hashCode(this.types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDamageResistant{typesTagKey=" + this.typesTagKey + '}';
|
||||
return "ItemDamageResistant{types=" + this.types + '}';
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageType;
|
||||
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemDamageType {
|
||||
|
||||
private MaybeMappedEntity<DamageType> damageType;
|
||||
|
||||
public ItemDamageType(DamageType damageType) {
|
||||
this(new MaybeMappedEntity<>(damageType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.11
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemDamageType(MaybeMappedEntity<DamageType> damageType) {
|
||||
this.damageType = damageType;
|
||||
}
|
||||
|
||||
public static ItemDamageType read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ItemDamageType(DamageType.read(wrapper));
|
||||
}
|
||||
MaybeMappedEntity<DamageType> damageType = MaybeMappedEntity.read(wrapper,
|
||||
DamageTypes.getRegistry(), DamageType::read);
|
||||
return new ItemDamageType(damageType);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemDamageType component) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
DamageType.write(wrapper, component.damageType.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, component.damageType, DamageType::write);
|
||||
}
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<DamageType> getDamageType() {
|
||||
return this.damageType;
|
||||
}
|
||||
|
||||
public void setDamageType(DamageType damageType) {
|
||||
this.setDamageType(new MaybeMappedEntity<>(damageType));
|
||||
}
|
||||
|
||||
public void setDamageType(MaybeMappedEntity<DamageType> damageType) {
|
||||
this.damageType = damageType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemDamageType that = (ItemDamageType) obj;
|
||||
return this.damageType.equals(that.damageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.damageType);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -114,12 +114,12 @@ public class ItemEquippable {
|
||||
}
|
||||
|
||||
public static ItemEquippable read(PacketWrapper<?> wrapper) {
|
||||
EquipmentSlot slot = wrapper.readEnum(EquipmentSlot.values());
|
||||
EquipmentSlot slot = EquipmentSlot.getByComponentId(wrapper.getServerVersion(), wrapper.readVarInt());
|
||||
Sound equipSound = Sound.read(wrapper);
|
||||
ResourceLocation assetId = wrapper.readOptional(PacketWrapper::readIdentifier);
|
||||
ResourceLocation cameraOverlay = wrapper.readOptional(PacketWrapper::readIdentifier);
|
||||
MappedEntitySet<EntityType> allowedEntities = wrapper.readOptional(
|
||||
ew -> MappedEntitySet.read(ew, EntityTypes::getById));
|
||||
ew -> MappedEntitySet.read(ew, EntityTypes.getRegistry()));
|
||||
boolean dispensable = wrapper.readBoolean();
|
||||
boolean swappable = wrapper.readBoolean();
|
||||
boolean damageOnHurt = wrapper.readBoolean();
|
||||
@@ -139,7 +139,7 @@ public class ItemEquippable {
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemEquippable equippable) {
|
||||
wrapper.writeEnum(equippable.slot);
|
||||
wrapper.writeVarInt(equippable.slot.getComponentId(wrapper.getServerVersion()));
|
||||
Sound.write(wrapper, equippable.equipSound);
|
||||
wrapper.writeOptional(equippable.assetId, PacketWrapper::writeIdentifier);
|
||||
wrapper.writeOptional(equippable.cameraOverlay, PacketWrapper::writeIdentifier);
|
||||
|
||||
+20
-9
@@ -23,32 +23,43 @@ import com.github.retrooper.packetevents.protocol.item.instrument.Instrument;
|
||||
import com.github.retrooper.packetevents.protocol.item.instrument.Instruments;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.20.5+
|
||||
*/
|
||||
public class ItemInstrument {
|
||||
|
||||
private MaybeMappedEntity<Instrument> instrument;
|
||||
|
||||
public ItemInstrument(Instrument instrument) {
|
||||
this(new MaybeMappedEntity<>(instrument));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.5-1.21.11
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemInstrument(MaybeMappedEntity<Instrument> instrument) {
|
||||
this.instrument = instrument;
|
||||
}
|
||||
|
||||
public static ItemInstrument read(PacketWrapper<?> wrapper) {
|
||||
MaybeMappedEntity<Instrument> instrument;
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
|
||||
instrument = MaybeMappedEntity.read(wrapper, Instruments.getRegistry(), Instrument::read);
|
||||
} else {
|
||||
instrument = new MaybeMappedEntity<>(Instrument.read(wrapper));
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)
|
||||
|| wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
|
||||
return new ItemInstrument(Instrument.read(wrapper));
|
||||
}
|
||||
return new ItemInstrument(instrument);
|
||||
return new ItemInstrument(MaybeMappedEntity.read(wrapper, Instruments.getRegistry(), Instrument::read));
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemInstrument instrument) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
|
||||
MaybeMappedEntity.write(wrapper, instrument.instrument, Instrument::write);
|
||||
} else {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)
|
||||
|| wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
|
||||
Instrument.write(wrapper, instrument.instrument.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, instrument.instrument, Instrument::write);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-7
@@ -34,19 +34,29 @@ public class ItemJukeboxPlayable {
|
||||
|
||||
private MaybeMappedEntity<IJukeboxSong> song;
|
||||
/**
|
||||
* Removed in 1.21.5
|
||||
* @versions 1.21-1.21.4
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
private boolean showInTooltip;
|
||||
|
||||
public ItemJukeboxPlayable(IJukeboxSong song) {
|
||||
this(new MaybeMappedEntity<>(song));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.5-1.21.11
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemJukeboxPlayable(MaybeMappedEntity<IJukeboxSong> song) {
|
||||
this(song, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #showInTooltip} has been removed in 1.21.5
|
||||
* @versions 1.21-1.21.4
|
||||
* @deprecated use {@link #ItemJukeboxPlayable(MaybeMappedEntity, boolean)}
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
@Deprecated
|
||||
public ItemJukeboxPlayable(
|
||||
@Nullable JukeboxSong song,
|
||||
@Nullable ResourceLocation songKey,
|
||||
@@ -56,8 +66,10 @@ public class ItemJukeboxPlayable {
|
||||
}
|
||||
|
||||
/**
|
||||
* use {@link #ItemJukeboxPlayable(MaybeMappedEntity, boolean)}
|
||||
* @versions 1.21-1.21.4
|
||||
* @deprecated use {@link #ItemJukeboxPlayable(MaybeMappedEntity, boolean)}
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
@Deprecated
|
||||
public ItemJukeboxPlayable(
|
||||
@Nullable IJukeboxSong song,
|
||||
@@ -68,7 +80,7 @@ public class ItemJukeboxPlayable {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #showInTooltip} has been removed in 1.21.5
|
||||
* @versions 1.21-1.21.4
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemJukeboxPlayable(
|
||||
@@ -80,13 +92,20 @@ public class ItemJukeboxPlayable {
|
||||
}
|
||||
|
||||
public static ItemJukeboxPlayable read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ItemJukeboxPlayable(IJukeboxSong.read(wrapper));
|
||||
}
|
||||
MaybeMappedEntity<IJukeboxSong> song = MaybeMappedEntity.read(wrapper, JukeboxSongs.getRegistry(), IJukeboxSong::read);
|
||||
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
|
||||
return new ItemJukeboxPlayable(song, showInTooltip);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemJukeboxPlayable jukeboxPlayable) {
|
||||
MaybeMappedEntity.write(wrapper, jukeboxPlayable.song, IJukeboxSong::write);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
IJukeboxSong.write(wrapper, jukeboxPlayable.song.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, jukeboxPlayable.song, IJukeboxSong::write);
|
||||
}
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
|
||||
wrapper.writeBoolean(jukeboxPlayable.showInTooltip);
|
||||
}
|
||||
@@ -137,7 +156,7 @@ public class ItemJukeboxPlayable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed in 1.21.5
|
||||
* @versions 1.21-1.21.4
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public boolean isShowInTooltip() {
|
||||
@@ -145,7 +164,7 @@ public class ItemJukeboxPlayable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed in 1.21.5
|
||||
* @versions 1.21-1.21.4
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public void setShowInTooltip(boolean showInTooltip) {
|
||||
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.sound.Sound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemKineticWeapon {
|
||||
|
||||
private int contactCooldownTicks;
|
||||
private int delayTicks;
|
||||
private @Nullable Condition dismountConditions;
|
||||
private @Nullable Condition knockbackConditions;
|
||||
private @Nullable Condition damageConditions;
|
||||
private float forwardMovement;
|
||||
private float damageMultiplier;
|
||||
private @Nullable Sound sound;
|
||||
private @Nullable Sound hitSound;
|
||||
|
||||
public ItemKineticWeapon(
|
||||
int contactCooldownTicks, int delayTicks, @Nullable Condition dismountConditions,
|
||||
@Nullable Condition knockbackConditions, @Nullable Condition damageConditions,
|
||||
float forwardMovement, float damageMultiplier, @Nullable Sound sound, @Nullable Sound hitSound
|
||||
) {
|
||||
this.contactCooldownTicks = contactCooldownTicks;
|
||||
this.delayTicks = delayTicks;
|
||||
this.dismountConditions = dismountConditions;
|
||||
this.knockbackConditions = knockbackConditions;
|
||||
this.damageConditions = damageConditions;
|
||||
this.forwardMovement = forwardMovement;
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
this.sound = sound;
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
public static ItemKineticWeapon read(PacketWrapper<?> wrapper) {
|
||||
int contactCooldownTicks = wrapper.readVarInt();
|
||||
int delayTicks = wrapper.readVarInt();
|
||||
Condition dismountConditions = wrapper.readOptional(Condition::read);
|
||||
Condition knockbackConditions = wrapper.readOptional(Condition::read);
|
||||
Condition damageConditions = wrapper.readOptional(Condition::read);
|
||||
float forwardMovement = wrapper.readFloat();
|
||||
float damageMultiplier = wrapper.readFloat();
|
||||
Sound sound = wrapper.readOptional(Sound::read);
|
||||
Sound hitSound = wrapper.readOptional(Sound::read);
|
||||
return new ItemKineticWeapon(contactCooldownTicks, delayTicks, dismountConditions,
|
||||
knockbackConditions, damageConditions, forwardMovement, damageMultiplier, sound, hitSound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemKineticWeapon component) {
|
||||
wrapper.writeVarInt(component.contactCooldownTicks);
|
||||
wrapper.writeVarInt(component.delayTicks);
|
||||
wrapper.writeOptional(component.dismountConditions, Condition::write);
|
||||
wrapper.writeOptional(component.knockbackConditions, Condition::write);
|
||||
wrapper.writeOptional(component.damageConditions, Condition::write);
|
||||
wrapper.writeFloat(component.forwardMovement);
|
||||
wrapper.writeFloat(component.damageMultiplier);
|
||||
wrapper.writeOptional(component.sound, Sound::write);
|
||||
wrapper.writeOptional(component.hitSound, Sound::write);
|
||||
}
|
||||
|
||||
public int getContactCooldownTicks() {
|
||||
return this.contactCooldownTicks;
|
||||
}
|
||||
|
||||
public void setContactCooldownTicks(int contactCooldownTicks) {
|
||||
this.contactCooldownTicks = contactCooldownTicks;
|
||||
}
|
||||
|
||||
public int getDelayTicks() {
|
||||
return this.delayTicks;
|
||||
}
|
||||
|
||||
public void setDelayTicks(int delayTicks) {
|
||||
this.delayTicks = delayTicks;
|
||||
}
|
||||
|
||||
public @Nullable Condition getDismountConditions() {
|
||||
return this.dismountConditions;
|
||||
}
|
||||
|
||||
public void setDismountConditions(@Nullable Condition dismountConditions) {
|
||||
this.dismountConditions = dismountConditions;
|
||||
}
|
||||
|
||||
public @Nullable Condition getKnockbackConditions() {
|
||||
return this.knockbackConditions;
|
||||
}
|
||||
|
||||
public void setKnockbackConditions(@Nullable Condition knockbackConditions) {
|
||||
this.knockbackConditions = knockbackConditions;
|
||||
}
|
||||
|
||||
public @Nullable Condition getDamageConditions() {
|
||||
return this.damageConditions;
|
||||
}
|
||||
|
||||
public void setDamageConditions(@Nullable Condition damageConditions) {
|
||||
this.damageConditions = damageConditions;
|
||||
}
|
||||
|
||||
public float getForwardMovement() {
|
||||
return this.forwardMovement;
|
||||
}
|
||||
|
||||
public void setForwardMovement(float forwardMovement) {
|
||||
this.forwardMovement = forwardMovement;
|
||||
}
|
||||
|
||||
public float getDamageMultiplier() {
|
||||
return this.damageMultiplier;
|
||||
}
|
||||
|
||||
public void setDamageMultiplier(float damageMultiplier) {
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
}
|
||||
|
||||
public @Nullable Sound getSound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public void setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
public @Nullable Sound getHitSound() {
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
public void setHitSound(@Nullable Sound hitSound) {
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemKineticWeapon that = (ItemKineticWeapon) obj;
|
||||
if (this.contactCooldownTicks != that.contactCooldownTicks) return false;
|
||||
if (this.delayTicks != that.delayTicks) return false;
|
||||
if (Float.compare(that.forwardMovement, this.forwardMovement) != 0) return false;
|
||||
if (Float.compare(that.damageMultiplier, this.damageMultiplier) != 0) return false;
|
||||
if (!Objects.equals(this.dismountConditions, that.dismountConditions)) return false;
|
||||
if (!Objects.equals(this.knockbackConditions, that.knockbackConditions)) return false;
|
||||
if (!Objects.equals(this.damageConditions, that.damageConditions)) return false;
|
||||
if (!Objects.equals(this.sound, that.sound)) return false;
|
||||
return Objects.equals(this.hitSound, that.hitSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.contactCooldownTicks, this.delayTicks, this.dismountConditions,
|
||||
this.knockbackConditions, this.damageConditions, this.forwardMovement,
|
||||
this.damageMultiplier, this.sound, this.hitSound);
|
||||
}
|
||||
|
||||
public static class Condition {
|
||||
|
||||
private int maxDurationTicks;
|
||||
private float minSpeed;
|
||||
private float minRelativeSpeed;
|
||||
|
||||
public Condition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) {
|
||||
this.maxDurationTicks = maxDurationTicks;
|
||||
this.minSpeed = minSpeed;
|
||||
this.minRelativeSpeed = minRelativeSpeed;
|
||||
}
|
||||
|
||||
public static Condition read(PacketWrapper<?> wrapper) {
|
||||
int maxDurationTicks = wrapper.readVarInt();
|
||||
float minSpeed = wrapper.readFloat();
|
||||
float minRelativeSpeed = wrapper.readFloat();
|
||||
return new Condition(maxDurationTicks, minSpeed, minRelativeSpeed);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, Condition condition) {
|
||||
wrapper.writeVarInt(condition.maxDurationTicks);
|
||||
wrapper.writeFloat(condition.minSpeed);
|
||||
wrapper.writeFloat(condition.minRelativeSpeed);
|
||||
}
|
||||
|
||||
public int getMaxDurationTicks() {
|
||||
return this.maxDurationTicks;
|
||||
}
|
||||
|
||||
public void setMaxDurationTicks(int maxDurationTicks) {
|
||||
this.maxDurationTicks = maxDurationTicks;
|
||||
}
|
||||
|
||||
public float getMinSpeed() {
|
||||
return this.minSpeed;
|
||||
}
|
||||
|
||||
public void setMinSpeed(float minSpeed) {
|
||||
this.minSpeed = minSpeed;
|
||||
}
|
||||
|
||||
public float getMinRelativeSpeed() {
|
||||
return this.minRelativeSpeed;
|
||||
}
|
||||
|
||||
public void setMinRelativeSpeed(float minRelativeSpeed) {
|
||||
this.minRelativeSpeed = minRelativeSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Condition condition = (Condition) obj;
|
||||
if (this.maxDurationTicks != condition.maxDurationTicks) return false;
|
||||
if (Float.compare(condition.minSpeed, this.minSpeed) != 0) return false;
|
||||
return Float.compare(condition.minRelativeSpeed, this.minRelativeSpeed) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.maxDurationTicks, this.minSpeed, this.minRelativeSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
-6
@@ -18,46 +18,100 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class ItemLock {
|
||||
|
||||
private String code;
|
||||
private static final String FALLBACK_LOCK_STRING = "packetevents$invalid_lock";
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
private String code;
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
private NBTCompound predicate;
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemLock(String code) {
|
||||
this.code = code;
|
||||
this.predicate = new NBTCompound();
|
||||
}
|
||||
|
||||
public ItemLock(NBTCompound predicate) {
|
||||
this.code = FALLBACK_LOCK_STRING;
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
public static ItemLock read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
|
||||
return new ItemLock(wrapper.readNBT());
|
||||
}
|
||||
NBTString codeTag = (NBTString) wrapper.readNBTRaw();
|
||||
return new ItemLock(codeTag.getValue());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemLock lock) {
|
||||
wrapper.writeNBTRaw(new NBTString(lock.code));
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
|
||||
wrapper.writeNBT(lock.predicate);
|
||||
} else {
|
||||
wrapper.writeNBTRaw(new NBTString(lock.code));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.20.5-1.21.1
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
public NBTCompound getPredicate() {
|
||||
return this.predicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.2+
|
||||
*/
|
||||
public void setPredicate(NBTCompound predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ItemLock)) return false;
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
ItemLock itemLock = (ItemLock) obj;
|
||||
return this.code.equals(itemLock.code);
|
||||
if (!this.code.equals(itemLock.code)) return false;
|
||||
return this.predicate.equals(itemLock.predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.code);
|
||||
return Objects.hash(this.code, this.predicate);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemMinimumAttackCharge {
|
||||
|
||||
private float value;
|
||||
|
||||
public ItemMinimumAttackCharge(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ItemMinimumAttackCharge read(PacketWrapper<?> wrapper) {
|
||||
return new ItemMinimumAttackCharge(wrapper.readFloat());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemMinimumAttackCharge component) {
|
||||
wrapper.writeFloat(component.value);
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemMinimumAttackCharge that = (ItemMinimumAttackCharge) obj;
|
||||
return Float.compare(that.value, this.value) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.value);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 26.3+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemMobVisibility {
|
||||
|
||||
private final MappedEntitySet<EntityType> targetingEntityTypes;
|
||||
private final float visibility;
|
||||
|
||||
public ItemMobVisibility(MappedEntitySet<EntityType> targetingEntityTypes, float visibility) {
|
||||
this.targetingEntityTypes = targetingEntityTypes;
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public static ItemMobVisibility read(PacketWrapper<?> wrapper) {
|
||||
MappedEntitySet<EntityType> targetingEntityTypes = MappedEntitySet.read(wrapper, EntityTypes.getRegistry());
|
||||
float visibility = wrapper.readFloat();
|
||||
return new ItemMobVisibility(targetingEntityTypes, visibility);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemMobVisibility visibility) {
|
||||
MappedEntitySet.write(wrapper, visibility.targetingEntityTypes);
|
||||
wrapper.writeFloat(visibility.visibility);
|
||||
}
|
||||
|
||||
public MappedEntitySet<EntityType> getTargetingEntityTypes() {
|
||||
return this.targetingEntityTypes;
|
||||
}
|
||||
|
||||
public float getVisibility() {
|
||||
return this.visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemMobVisibility that = (ItemMobVisibility) obj;
|
||||
if (Float.compare(that.visibility, this.visibility) != 0) return false;
|
||||
return this.targetingEntityTypes.equals(that.targetingEntityTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.targetingEntityTypes, this.visibility);
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.sound.Sound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemPiercingWeapon {
|
||||
|
||||
private boolean dealsKnockback;
|
||||
private boolean dismounts;
|
||||
private @Nullable Sound sound;
|
||||
private @Nullable Sound hitSound;
|
||||
|
||||
public ItemPiercingWeapon(
|
||||
boolean dealsKnockback, boolean dismounts,
|
||||
@Nullable Sound sound, @Nullable Sound hitSound
|
||||
) {
|
||||
this.dealsKnockback = dealsKnockback;
|
||||
this.dismounts = dismounts;
|
||||
this.sound = sound;
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
public static ItemPiercingWeapon read(PacketWrapper<?> wrapper) {
|
||||
boolean dealsKnockback = wrapper.readBoolean();
|
||||
boolean dismounts = wrapper.readBoolean();
|
||||
Sound sound = wrapper.readOptional(Sound::read);
|
||||
Sound hitSound = wrapper.readOptional(Sound::read);
|
||||
return new ItemPiercingWeapon(dealsKnockback, dismounts, sound, hitSound);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemPiercingWeapon component) {
|
||||
wrapper.writeBoolean(component.dealsKnockback);
|
||||
wrapper.writeBoolean(component.dismounts);
|
||||
wrapper.writeOptional(component.sound, Sound::write);
|
||||
wrapper.writeOptional(component.hitSound, Sound::write);
|
||||
}
|
||||
|
||||
public boolean isDealsKnockback() {
|
||||
return this.dealsKnockback;
|
||||
}
|
||||
|
||||
public void setDealsKnockback(boolean dealsKnockback) {
|
||||
this.dealsKnockback = dealsKnockback;
|
||||
}
|
||||
|
||||
public boolean isDismounts() {
|
||||
return this.dismounts;
|
||||
}
|
||||
|
||||
public void setDismounts(boolean dismounts) {
|
||||
this.dismounts = dismounts;
|
||||
}
|
||||
|
||||
public @Nullable Sound getSound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public void setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
public @Nullable Sound getHitSound() {
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
public void setHitSound(@Nullable Sound hitSound) {
|
||||
this.hitSound = hitSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ItemPiercingWeapon that = (ItemPiercingWeapon) obj;
|
||||
if (this.dealsKnockback != that.dealsKnockback) return false;
|
||||
if (this.dismounts != that.dismounts) return false;
|
||||
if (!Objects.equals(this.sound, that.sound)) return false;
|
||||
return Objects.equals(this.hitSound, that.hitSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.dealsKnockback, this.dismounts, this.sound, this.hitSound);
|
||||
}
|
||||
}
|
||||
+274
-9
@@ -18,40 +18,148 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.protocol.player.PlayerModelType;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodec;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecException;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtCodecs;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapCodec;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.kyori.adventure.text.object.PlayerHeadObjectContents;
|
||||
import net.kyori.adventure.text.object.PlayerHeadObjectContents.ProfileProperty;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemProfile {
|
||||
import static net.kyori.adventure.text.object.PlayerHeadObjectContents.property;
|
||||
|
||||
@NullMarked
|
||||
public final class ItemProfile {
|
||||
|
||||
private @Nullable String name;
|
||||
private @Nullable UUID id;
|
||||
private List<Property> properties;
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
private SkinPatch skinPatch;
|
||||
|
||||
public ItemProfile(
|
||||
@Nullable String name,
|
||||
@Nullable UUID id,
|
||||
List<Property> properties
|
||||
) {
|
||||
this(name, id, properties, SkinPatch.EMPTY);
|
||||
}
|
||||
|
||||
public ItemProfile(
|
||||
@Nullable String name,
|
||||
@Nullable UUID id,
|
||||
List<Property> properties,
|
||||
SkinPatch skinPatch
|
||||
) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.properties = properties;
|
||||
this.skinPatch = skinPatch;
|
||||
}
|
||||
|
||||
public static ItemProfile read(PacketWrapper<?> wrapper) {
|
||||
String name = wrapper.readOptional(ew -> ew.readString(16));
|
||||
UUID id = wrapper.readOptional(PacketWrapper::readUUID);
|
||||
String name;
|
||||
UUID id;
|
||||
boolean partial = wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_9) || !wrapper.readBoolean();
|
||||
if (!partial) {
|
||||
id = wrapper.readUUID();
|
||||
name = wrapper.readString(16);
|
||||
} else {
|
||||
name = wrapper.readOptional(ew -> ew.readString(16));
|
||||
id = wrapper.readOptional(PacketWrapper::readUUID);
|
||||
}
|
||||
List<Property> properties = wrapper.readList(Property::read);
|
||||
return new ItemProfile(name, id, properties);
|
||||
SkinPatch skinPatch = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)
|
||||
? SkinPatch.read(wrapper) : SkinPatch.EMPTY;
|
||||
return new ItemProfile(name, id, properties, skinPatch);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemProfile profile) {
|
||||
wrapper.writeOptional(profile.name, (ew, name) -> ew.writeString(name, 16));
|
||||
wrapper.writeOptional(profile.id, PacketWrapper::writeUUID);
|
||||
boolean partial;
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
partial = profile.name == null || profile.id == null;
|
||||
wrapper.writeBoolean(!partial);
|
||||
} else {
|
||||
// always partial profile (which is way simpler, why did they change this?)
|
||||
partial = true;
|
||||
}
|
||||
if (!partial) {
|
||||
wrapper.writeUUID(profile.id);
|
||||
wrapper.writeString(profile.name, 16);
|
||||
} else {
|
||||
wrapper.writeOptional(profile.name, (ew, name) -> ew.writeString(name, 16));
|
||||
wrapper.writeOptional(profile.id, PacketWrapper::writeUUID);
|
||||
}
|
||||
wrapper.writeList(profile.properties, Property::write);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_9)) {
|
||||
SkinPatch.write(wrapper, profile.skinPatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemProfile decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
if (nbt instanceof NBTString) {
|
||||
String name = ((NBTString) nbt).getValue();
|
||||
return new ItemProfile(name, null, new ArrayList<>());
|
||||
}
|
||||
NBTCompound compound = (NBTCompound) nbt;
|
||||
UUID id = compound.getOrNull("id", NbtCodecs.UUID, wrapper);
|
||||
String name = compound.getStringTagValueOrNull("name");
|
||||
List<Property> properties = compound.getOrSupply("properties",
|
||||
Property.PROPERTY_MAP, ArrayList::new, wrapper);
|
||||
SkinPatch patch = SkinPatch.decode(compound, wrapper);
|
||||
return new ItemProfile(name, id, properties, patch);
|
||||
}
|
||||
|
||||
public static NBT encode(PacketWrapper<?> wrapper, ItemProfile profile) {
|
||||
NBTCompound compound = new NBTCompound();
|
||||
if (profile.id != null) {
|
||||
compound.set("id", profile.id, NbtCodecs.UUID, wrapper);
|
||||
}
|
||||
if (profile.name != null) {
|
||||
compound.setTag("name", new NBTString(profile.name));
|
||||
}
|
||||
if (!profile.properties.isEmpty()) {
|
||||
compound.set("properties", profile.properties, Property.PROPERTY_MAP, wrapper);
|
||||
}
|
||||
SkinPatch.encode(compound, wrapper, profile.skinPatch);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static ItemProfile fromAdventure(PlayerHeadObjectContents headContents) {
|
||||
List<ProfileProperty> advProps = headContents.profileProperties();
|
||||
List<Property> properties = new ArrayList<>(advProps.size());
|
||||
for (ProfileProperty property : advProps) {
|
||||
properties.add(Property.fromAdventure(property));
|
||||
}
|
||||
return new ItemProfile(headContents.name(), headContents.id(), properties);
|
||||
}
|
||||
|
||||
public List<ProfileProperty> getAdventureProperties() {
|
||||
if (this.properties.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ProfileProperty> properties = new ArrayList<>(this.properties.size());
|
||||
for (Property property : this.properties) {
|
||||
properties.add(property.asAdventure());
|
||||
}
|
||||
return Collections.unmodifiableList(properties);
|
||||
}
|
||||
|
||||
public @Nullable String getName() {
|
||||
@@ -82,6 +190,20 @@ public class ItemProfile {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public SkinPatch getSkinPatch() {
|
||||
return this.skinPatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.9+
|
||||
*/
|
||||
public void setSkinPatch(SkinPatch skinPatch) {
|
||||
this.skinPatch = skinPatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
@@ -89,16 +211,60 @@ public class ItemProfile {
|
||||
ItemProfile that = (ItemProfile) obj;
|
||||
if (!Objects.equals(this.name, that.name)) return false;
|
||||
if (!Objects.equals(this.id, that.id)) return false;
|
||||
return this.properties.equals(that.properties);
|
||||
if (!this.properties.equals(that.properties)) return false;
|
||||
return this.skinPatch.equals(that.skinPatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.name, this.id, this.properties);
|
||||
return Objects.hash(this.name, this.id, this.properties, this.skinPatch);
|
||||
}
|
||||
|
||||
public static class Property {
|
||||
|
||||
public static final NbtCodec<Property> CODEC = new NbtMapCodec<Property>() {
|
||||
@Override
|
||||
public Property decode(NBTCompound compound, PacketWrapper<?> wrapper) throws NbtCodecException {
|
||||
String name = compound.getStringTagValueOrThrow("name");
|
||||
String value = compound.getStringTagValueOrThrow("value");
|
||||
String signature = compound.getStringTagValueOrNull("signature");
|
||||
return new ItemProfile.Property(name, value, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(NBTCompound compound, PacketWrapper<?> wrapper, Property value) throws NbtCodecException {
|
||||
compound.setTag("name", new NBTString(value.getName()));
|
||||
compound.setTag("value", new NBTString(value.getValue()));
|
||||
if (value.getSignature() != null) {
|
||||
compound.setTag("signature", new NBTString(value.getSignature()));
|
||||
}
|
||||
}
|
||||
}.codec();
|
||||
|
||||
public static final NbtCodec<List<ItemProfile.Property>> PROPERTY_MAP = new NbtCodec<List<ItemProfile.Property>>() {
|
||||
private final NbtCodec<List<ItemProfile.Property>> propertyList = CODEC.applyList();
|
||||
|
||||
@Override
|
||||
public List<ItemProfile.Property> decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
if (nbt instanceof NBTCompound) {
|
||||
Map<String, NBT> tags = ((NBTCompound) nbt).getTags();
|
||||
List<ItemProfile.Property> properties = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, NBT> entry : tags.entrySet()) {
|
||||
for (String value : NbtCodecs.STRING_LIST.decode(entry.getValue(), wrapper)) {
|
||||
properties.add(new ItemProfile.Property(entry.getKey(), value, null));
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
return this.propertyList.decode(nbt, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBT encode(PacketWrapper<?> wrapper, List<ItemProfile.Property> value) {
|
||||
return this.propertyList.encode(wrapper, value);
|
||||
}
|
||||
};
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
private @Nullable String signature;
|
||||
@@ -123,6 +289,14 @@ public class ItemProfile {
|
||||
(ew, signature) -> ew.writeString(signature, 1024));
|
||||
}
|
||||
|
||||
public static Property fromAdventure(ProfileProperty property) {
|
||||
return new Property(property.name(), property.value(), property.signature());
|
||||
}
|
||||
|
||||
public ProfileProperty asAdventure() {
|
||||
return property(this.name, this.value, this.signature);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -162,4 +336,95 @@ public class ItemProfile {
|
||||
return Objects.hash(this.name, this.value, this.signature);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SkinPatch {
|
||||
|
||||
public static final SkinPatch EMPTY = new SkinPatch(null, null, null, null);
|
||||
|
||||
private final @Nullable ResourceLocation body;
|
||||
private final @Nullable ResourceLocation cape;
|
||||
private final @Nullable ResourceLocation elytra;
|
||||
private final @Nullable PlayerModelType model;
|
||||
|
||||
public SkinPatch(
|
||||
@Nullable ResourceLocation body,
|
||||
@Nullable ResourceLocation cape,
|
||||
@Nullable ResourceLocation elytra,
|
||||
@Nullable PlayerModelType model
|
||||
) {
|
||||
this.body = body;
|
||||
this.cape = cape;
|
||||
this.elytra = elytra;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public static SkinPatch read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation body = wrapper.readOptional(ResourceLocation::read);
|
||||
ResourceLocation cape = wrapper.readOptional(ResourceLocation::read);
|
||||
ResourceLocation elytra = wrapper.readOptional(ResourceLocation::read);
|
||||
PlayerModelType model = wrapper.readOptional(PlayerModelType::read);
|
||||
return new SkinPatch(body, cape, elytra, model);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, SkinPatch patch) {
|
||||
wrapper.writeOptional(patch.body, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.cape, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.elytra, ResourceLocation::write);
|
||||
wrapper.writeOptional(patch.model, PlayerModelType::write);
|
||||
}
|
||||
|
||||
public static SkinPatch decode(NBTCompound nbt, PacketWrapper<?> wrapper) {
|
||||
ResourceLocation body = nbt.getOrNull("texture", ResourceLocation.CODEC, wrapper);
|
||||
ResourceLocation cape = nbt.getOrNull("cape", ResourceLocation.CODEC, wrapper);
|
||||
ResourceLocation elytra = nbt.getOrNull("elytra", ResourceLocation.CODEC, wrapper);
|
||||
PlayerModelType model = nbt.getOrNull("model", PlayerModelType.CODEC, wrapper);
|
||||
return new SkinPatch(body, cape, elytra, model);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, SkinPatch patch) {
|
||||
if (patch.body != null) {
|
||||
compound.set("texture", patch.body, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.cape != null) {
|
||||
compound.set("cape", patch.cape, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.elytra != null) {
|
||||
compound.set("elytra", patch.elytra, ResourceLocation.CODEC, wrapper);
|
||||
}
|
||||
if (patch.model != null) {
|
||||
compound.set("model", patch.model, PlayerModelType.CODEC, wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getCape() {
|
||||
return this.cape;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getElytra() {
|
||||
return this.elytra;
|
||||
}
|
||||
|
||||
public @Nullable PlayerModelType getModel() {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
SkinPatch skinPatch = (SkinPatch) obj;
|
||||
if (!Objects.equals(this.body, skinPatch.body)) return false;
|
||||
if (!Objects.equals(this.cape, skinPatch.cape)) return false;
|
||||
if (!Objects.equals(this.elytra, skinPatch.elytra)) return false;
|
||||
return this.model == skinPatch.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.body, this.cape, this.elytra, this.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
-7
@@ -18,45 +18,90 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.item.banner.BannerPattern;
|
||||
import com.github.retrooper.packetevents.protocol.item.banner.BannerPatterns;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
@NullMarked
|
||||
public class ItemProvidesBannerPatterns {
|
||||
|
||||
private ResourceLocation tagKey;
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
private MappedEntitySet<BannerPattern> set;
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public ItemProvidesBannerPatterns(MappedEntitySet<BannerPattern> set) {
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
public ItemProvidesBannerPatterns(ResourceLocation tagKey) {
|
||||
this.tagKey = tagKey;
|
||||
this(new MappedEntitySet<>(tagKey));
|
||||
}
|
||||
|
||||
public static ItemProvidesBannerPatterns read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
MappedEntitySet<BannerPattern> set = MappedEntitySet.read(wrapper, BannerPatterns.getRegistry());
|
||||
return new ItemProvidesBannerPatterns(set);
|
||||
}
|
||||
ResourceLocation tagKey = wrapper.readIdentifier();
|
||||
return new ItemProvidesBannerPatterns(tagKey);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemProvidesBannerPatterns patterns) {
|
||||
wrapper.writeIdentifier(patterns.tagKey);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
MappedEntitySet.write(wrapper, patterns.set);
|
||||
} else {
|
||||
wrapper.writeIdentifier(patterns.getTagKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public MappedEntitySet<BannerPattern> getSet() {
|
||||
return this.set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 26.1+
|
||||
*/
|
||||
public void setSet(MappedEntitySet<BannerPattern> set) {
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
public ResourceLocation getTagKey() {
|
||||
return this.tagKey;
|
||||
ResourceLocation tagKey = this.set.getTagKey();
|
||||
if (tagKey == null) {
|
||||
throw new IllegalStateException("No tag key present");
|
||||
}
|
||||
return tagKey;
|
||||
}
|
||||
|
||||
public void setTagKey(ResourceLocation tagKey) {
|
||||
this.tagKey = tagKey;
|
||||
this.set = new MappedEntitySet<>(tagKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ItemProvidesBannerPatterns)) return false;
|
||||
ItemProvidesBannerPatterns that = (ItemProvidesBannerPatterns) obj;
|
||||
return this.tagKey.equals(that.tagKey);
|
||||
return this.set.equals(that.set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.tagKey);
|
||||
return Objects.hashCode(this.set);
|
||||
}
|
||||
}
|
||||
+21
-1
@@ -18,28 +18,48 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.component.builtin.item;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.item.trimmaterial.TrimMaterial;
|
||||
import com.github.retrooper.packetevents.protocol.item.trimmaterial.TrimMaterials;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @versions 1.21.5+
|
||||
*/
|
||||
public class ItemProvidesTrimMaterial {
|
||||
|
||||
private MaybeMappedEntity<TrimMaterial> material;
|
||||
|
||||
public ItemProvidesTrimMaterial(TrimMaterial material) {
|
||||
this(new MaybeMappedEntity<>(material));
|
||||
}
|
||||
|
||||
/**
|
||||
* @versions 1.21.5-1.21.11
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public ItemProvidesTrimMaterial(MaybeMappedEntity<TrimMaterial> material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public static ItemProvidesTrimMaterial read(PacketWrapper<?> wrapper) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
return new ItemProvidesTrimMaterial(TrimMaterial.read(wrapper));
|
||||
}
|
||||
MaybeMappedEntity<TrimMaterial> material = MaybeMappedEntity.read(wrapper, TrimMaterials.getRegistry(), TrimMaterial::read);
|
||||
return new ItemProvidesTrimMaterial(material);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ItemProvidesTrimMaterial material) {
|
||||
MaybeMappedEntity.write(wrapper, material.material, TrimMaterial::write);
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_26_1)) {
|
||||
TrimMaterial.write(wrapper, material.material.getValueOrThrow());
|
||||
} else {
|
||||
MaybeMappedEntity.write(wrapper, material.material, TrimMaterial::write);
|
||||
}
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<TrimMaterial> getMaterial() {
|
||||
|
||||
+3
-2
@@ -37,8 +37,9 @@ public class ItemRecipes {
|
||||
|
||||
public static ItemRecipes read(PacketWrapper<?> wrapper) {
|
||||
NBTList<?> recipes = (NBTList<?>) wrapper.readNBTRaw();
|
||||
List<ResourceLocation> recipeKeys = new ArrayList<>(recipes.size());
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
int size = recipes.size();
|
||||
List<ResourceLocation> recipeKeys = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
NBTString tag = (NBTString) recipes.getTag(i);
|
||||
recipeKeys.add(new ResourceLocation(tag.getValue()));
|
||||
}
|
||||
|
||||
Loaded 100 of 779 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user