Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f01f0100c | ||
|
|
29d3787de8 | ||
|
|
59df758ceb | ||
|
|
80360bf27c | ||
|
|
3da7d7513e | ||
|
|
a654becac8 | ||
|
|
77a5b2212b | ||
|
|
7013ed8acf | ||
|
|
9d41854e22 | ||
|
|
edf9ccca8b | ||
|
|
d62165bf51 | ||
|
|
00bc4a9d6a | ||
|
|
7885babe1e | ||
|
|
9a53678838 | ||
|
|
91874ffc3b | ||
|
|
e71c34255b | ||
|
|
8e78a14c14 | ||
|
|
3b85200641 | ||
|
|
1dc0f72e54 | ||
|
|
13d27a6f4d | ||
|
|
3cec1751c9 | ||
|
|
80f9dce513 | ||
|
|
cf7c718493 | ||
|
|
0ba20299a3 | ||
|
|
54a979c641 | ||
|
|
e41d643488 | ||
|
|
5281f6e7dd | ||
|
|
7e2775114b | ||
|
|
cbbc127360 | ||
|
|
83a566d145 | ||
|
|
3d3c1a0430 | ||
|
|
08f6c0b1f1 | ||
|
|
4cc3ea0883 | ||
|
|
2876495b62 | ||
|
|
7d03831ba8 | ||
|
|
0514dd2ea5 | ||
|
|
f341fc132c | ||
|
|
27b4933262 | ||
|
|
fb368a9ebe | ||
|
|
8adb80b5eb | ||
|
|
4a60f0f903 | ||
|
|
a789e2ff7b | ||
|
|
1201c2979b | ||
|
|
0e15a98472 | ||
|
|
51d07c1c50 | ||
|
|
5f59a57a78 | ||
|
|
084fc5d327 | ||
|
|
2194c96883 | ||
|
|
bd421fcfab | ||
|
|
93e99bc1ef | ||
|
|
687e1f4f43 | ||
|
|
4ea5a76337 | ||
|
|
face56dce1 | ||
|
|
24aebfe92a | ||
|
|
9337ff8958 | ||
|
|
18e2ef01e7 | ||
|
|
516be47827 | ||
|
|
9e62c161b4 | ||
|
|
d4785f093e | ||
|
|
fad65e5b81 | ||
|
|
49d507dfad | ||
|
|
75031f66b5 | ||
|
|
ad48770606 | ||
|
|
f7bd440a96 | ||
|
|
b2586cf13b | ||
|
|
7a5e57e1a8 | ||
|
|
0812204f11 | ||
|
|
066fef0513 | ||
|
|
8d7ed4c16c | ||
|
|
51b74fd618 | ||
|
|
6403c6480d | ||
|
|
9dcd95b2c3 | ||
|
|
4c7919fe82 | ||
|
|
df09b9a5ee | ||
|
|
a5f5185f1d | ||
|
|
bd6c2e1dcc | ||
|
|
9352ea54f8 | ||
|
|
e1325311c7 | ||
|
|
a0bb191e9f | ||
|
|
44ae5c8c1b | ||
|
|
35ced30047 | ||
|
|
f498d59303 | ||
|
|
62b321b7e9 | ||
|
|
279e0f01ea | ||
|
|
ea59ab372e | ||
|
|
70b4e74b52 | ||
|
|
a8de222bc2 | ||
|
|
70a10132d0 | ||
|
|
25a2cb2eb9 | ||
|
|
43a36be834 | ||
|
|
a33f2d7fae | ||
|
|
a349c001fe | ||
|
|
0fbe2dc432 | ||
|
|
0323300acd | ||
|
|
189936ecd2 | ||
|
|
9a581c534f | ||
|
|
99e2297d67 | ||
|
|
3fc2a3e395 | ||
|
|
5c1c7940a3 | ||
|
|
15348f659a | ||
|
|
8dfacde007 | ||
|
|
859a79d7da | ||
|
|
e27d107ebc | ||
|
|
0ddf718be1 | ||
|
|
6738b2a16b | ||
|
|
c75f497c79 | ||
|
|
84bb022a31 | ||
|
|
b48edbde04 | ||
|
|
ab0406ba77 | ||
|
|
600c843747 | ||
|
|
d2bd9679da | ||
|
|
518aafe617 | ||
|
|
0166d1a3b1 | ||
|
|
0da5b65858 | ||
|
|
e8da5554dc | ||
|
|
8a67061d32 | ||
|
|
29ec3efa9c | ||
|
|
4a360bac44 | ||
|
|
1c4b27e56c | ||
|
|
673239108c | ||
|
|
56b926be40 | ||
|
|
963630db7e | ||
|
|
54dcb32232 | ||
|
|
9e4718abc3 | ||
|
|
5e5e32769f | ||
|
|
c0f88bbf62 | ||
|
|
ec2f118d80 | ||
|
|
2a8c7334a9 | ||
|
|
ad4092b8f6 | ||
|
|
92cec1f798 | ||
|
|
56c80fb5c3 | ||
|
|
6e011f9297 | ||
|
|
d11e9d3b77 | ||
|
|
0f631eb1d9 | ||
|
|
9fbfcb3851 | ||
|
|
a982d8c0f0 | ||
|
|
27f7c3e72b | ||
|
|
819d7f3d39 | ||
|
|
25404d6c92 | ||
|
|
b340c7246b | ||
|
|
2669967b49 | ||
|
|
e945db8cb6 | ||
|
|
9a09e53572 | ||
|
|
0c040db6f0 | ||
|
|
46c7cab3a4 | ||
|
|
922afc12a5 | ||
|
|
4817bf7e2b | ||
|
|
2a118acf77 | ||
|
|
0b93cd0e09 | ||
|
|
b1af6ad721 | ||
|
|
c6d8a83ac9 | ||
|
|
72a070da3e | ||
|
|
dbe0f7049e | ||
|
|
91b81ebb24 | ||
|
|
897e9545c2 | ||
|
|
947e5c3e07 | ||
|
|
ececd96718 | ||
|
|
e9ace2dd6b | ||
|
|
c72f8f766d | ||
|
|
1b89327d84 | ||
|
|
8a8c1a33a6 | ||
|
|
761249d39f | ||
|
|
e03da34f55 | ||
|
|
03ec04cc8d | ||
|
|
f387899dab | ||
|
|
ce49daa300 | ||
|
|
249a720cee | ||
|
|
fa59cbcc01 | ||
|
|
803c24f4d3 | ||
|
|
5e19a5af33 | ||
|
|
8911f1eb94 | ||
|
|
6f0bd98be2 | ||
|
|
e325a03c0a | ||
|
|
b9317df859 | ||
|
|
11bb1349e9 | ||
|
|
6289e9317d | ||
|
|
2d9d67bcb2 | ||
|
|
62fd868130 | ||
|
|
b2b8c48fd0 | ||
|
|
9f9d05d3c6 | ||
|
|
6e01a0affd | ||
|
|
d6d6307550 | ||
|
|
1afdf0fb81 | ||
|
|
fd529ce967 | ||
|
|
c5ba1864d1 | ||
|
|
831b8ad5ad | ||
|
|
58256b5b64 | ||
|
|
d209e9b768 | ||
|
|
61b1f0d8a4 | ||
|
|
2748624dde | ||
|
|
d5b19b8869 | ||
|
|
650f89e1ce | ||
|
|
00172ee675 | ||
|
|
45aab8f9f2 | ||
|
|
1e455b0391 | ||
|
|
59cb67da6e | ||
|
|
6b96e1a8e2 | ||
|
|
5ef94d94e6 | ||
|
|
a59c384884 | ||
|
|
7638d678bb | ||
|
|
f3c30130d2 | ||
|
|
bb583065f3 | ||
|
|
f5bb30559d | ||
|
|
87afb84a4d | ||
|
|
07078b21f1 | ||
|
|
63d3dcb31b | ||
|
|
478e663506 | ||
|
|
6bb8ae1dfc | ||
|
|
2cea70e643 | ||
|
|
54de77a110 | ||
|
|
e38cb88640 | ||
|
|
8deeda641a | ||
|
|
f75420a642 | ||
|
|
efd435e908 | ||
|
|
875ffb7f2d | ||
|
|
385ca98125 | ||
|
|
c4630039c4 | ||
|
|
cf6df691d2 | ||
|
|
76dfbe030e | ||
|
|
c7a168d3b3 | ||
|
|
b79bf429f7 | ||
|
|
6e1c482e2d | ||
|
|
b506060e48 | ||
|
|
8294f6af4f | ||
|
|
b98f208a98 | ||
|
|
bdc79c43eb | ||
|
|
f83ac57d8f | ||
|
|
124f5a5b87 | ||
|
|
4a8a475d55 | ||
|
|
86cf835d53 | ||
|
|
166b4314fd | ||
|
|
615cd40cae | ||
|
|
25220621e7 | ||
|
|
e3faa0d77d | ||
|
|
6de1ba9f30 | ||
|
|
79708fe952 | ||
|
|
16b68f7e3d | ||
|
|
71d5aab1b0 | ||
|
|
3bda6dd503 | ||
|
|
5ff7767353 | ||
|
|
d334a202e7 | ||
|
|
eec16eb5bb | ||
|
|
ee86b109b2 | ||
|
|
004d0d2b23 | ||
|
|
cf5e5590ad | ||
|
|
5988ab4c19 | ||
|
|
e25abe57e0 | ||
|
|
3d50c36ce3 | ||
|
|
38ed381094 | ||
|
|
2698725401 | ||
|
|
aec46ecd38 | ||
|
|
c2fb40b4e1 | ||
|
|
8b4733258b | ||
|
|
4b0e352849 | ||
|
|
611dd93bb9 | ||
|
|
cb8cdf27a4 | ||
|
|
f487f13e82 | ||
|
|
13bcce6d30 | ||
|
|
a30b48d8e9 | ||
|
|
e7ab178449 | ||
|
|
040558e01f | ||
|
|
d4a76b0ff5 | ||
|
|
446f46db83 | ||
|
|
e49c355580 | ||
|
|
8fbcd71e09 | ||
|
|
6e9155ba80 | ||
|
|
c2d81e6e9d | ||
|
|
8409f6fb2a | ||
|
|
29908523b0 | ||
|
|
48a69f1411 | ||
|
|
49daeb33c0 | ||
|
|
b1ca8cc2a0 | ||
|
|
2b0745dc2c | ||
|
|
4d701b1c4e | ||
|
|
0cb41c970b | ||
|
|
345d78976a | ||
|
|
11417fa04e | ||
|
|
c0668f1ee7 | ||
|
|
b11c5e27c5 | ||
|
|
99482b611f | ||
|
|
46577b4396 | ||
|
|
6ab2e2f0b2 | ||
|
|
b8dde25f3a | ||
|
|
32c26a5539 | ||
|
|
f263f757de | ||
|
|
ecceac660d | ||
|
|
910f5d98dc | ||
|
|
1d48bf5086 | ||
|
|
432977614f | ||
|
|
60164a7383 | ||
|
|
1b70321018 | ||
|
|
3b24b0dfe1 | ||
|
|
6b73de2510 | ||
|
|
5909103c56 | ||
|
|
99884107fc | ||
|
|
8087b42c40 | ||
|
|
2b269a6563 | ||
|
|
af88a57983 | ||
|
|
9a5d4197fc | ||
|
|
126300b388 | ||
|
|
334ae94577 | ||
|
|
1d1c3fdc06 | ||
|
|
ace1e6c553 | ||
|
|
9550151de6 | ||
|
|
947ff8e5ac | ||
|
|
2b76a5bc17 | ||
|
|
ba7333184b | ||
|
|
d6fe7914e8 | ||
|
|
a4ed18f59b | ||
|
|
57602f2cee | ||
|
|
78d85b7080 | ||
|
|
91f784f3f3 | ||
|
|
0f1f9328ae | ||
|
|
c560373be3 | ||
|
|
d9e5f650f1 | ||
|
|
3144c6fb19 | ||
|
|
7296fd58ec | ||
|
|
2334f6c5c9 | ||
|
|
152b9db80f | ||
|
|
01121dedf3 | ||
|
|
8df3815e82 | ||
|
|
83ef8572c1 | ||
|
|
aca265956f | ||
|
|
08743513ca | ||
|
|
7578671fc6 | ||
|
|
b2df8fc0d9 | ||
|
|
b62c8c46e3 | ||
|
|
96b9a023c1 | ||
|
|
4b3f1be599 | ||
|
|
d3bcc9f6c8 | ||
|
|
4680c0f3d2 | ||
|
|
e809c117c4 | ||
|
|
80ef8a401d | ||
|
|
b00ae1b701 | ||
|
|
8878a18108 | ||
|
|
9d3bec1aa1 | ||
|
|
1857244eae | ||
|
|
d7f67065be | ||
|
|
8c1923b077 | ||
|
|
ed67bd888e | ||
|
|
95dd94f645 | ||
|
|
71e24d9797 | ||
|
|
d50c26dd55 | ||
|
|
d3ecce71fa | ||
|
|
e40300d0b1 | ||
|
|
884dcbe5b9 | ||
|
|
26fab9f1ea | ||
|
|
07cc5fd7ed | ||
|
|
b1c4d563b4 | ||
|
|
617f1d3876 | ||
|
|
3e01afbe17 | ||
|
|
b339216533 | ||
|
|
edc4f71403 | ||
|
|
5d8f86e9eb | ||
|
|
de2c3b3719 | ||
|
|
35f531d051 | ||
|
|
f95b05866c | ||
|
|
12819a63a3 | ||
|
|
6b8f9d87f2 | ||
|
|
cc93551339 | ||
|
|
98eb47c360 | ||
|
|
31b3acdba7 | ||
|
|
03b7f995f6 | ||
|
|
a642e46eb3 | ||
|
|
a25b002fa8 | ||
|
|
653a38fbba | ||
|
|
9177dff34f | ||
|
|
449d45da9b | ||
|
|
f22b6138b9 | ||
|
|
f959a388c0 | ||
|
|
e55ff0130c | ||
|
|
3b48aa8076 | ||
|
|
10217f5c5f | ||
|
|
2531e9f353 | ||
|
|
5bb87bc059 | ||
|
|
91ca18de3e | ||
|
|
e7e315983e | ||
|
|
0da10a2864 | ||
|
|
b21fce2506 | ||
|
|
8e032f6499 | ||
|
|
1d12eb0b95 | ||
|
|
6a0e553c96 | ||
|
|
f0da0624f7 | ||
|
|
8e2d640f8c | ||
|
|
b879076026 | ||
|
|
fdcab0d5a8 | ||
|
|
e6059845aa | ||
|
|
781ef86af6 | ||
|
|
3ecf898d0a | ||
|
|
1c82d51734 | ||
|
|
b7bd93cfb6 | ||
|
|
5a7a8eb334 | ||
|
|
0e10b6b54b | ||
|
|
2376dad26a | ||
|
|
2fc0eac1e2 | ||
|
|
04793f41c5 | ||
|
|
e481c45b62 | ||
|
|
66b7b461b7 | ||
|
|
751c585469 | ||
|
|
485c8270fa | ||
|
|
24d77278f6 | ||
|
|
d66eb0c56b | ||
|
|
960197c02e | ||
|
|
21a6852593 | ||
|
|
c186d13ae5 | ||
|
|
01018fe600 | ||
|
|
cba2566c21 | ||
|
|
b9cb23e353 | ||
|
|
e9ffe66131 | ||
|
|
d6a1f06b35 | ||
|
|
d124b2ddfe | ||
|
|
92e9eab85e | ||
|
|
1d9a0773c7 | ||
|
|
105e6f23a2 | ||
|
|
ff1bf45fd2 | ||
|
|
21bd518f45 | ||
|
|
167b715048 | ||
|
|
1c94e0ead2 | ||
|
|
b4c30dbff3 | ||
|
|
5e1143af4b | ||
|
|
ac571df2cd | ||
|
|
fd8c89ae17 | ||
|
|
3acba1b8e2 | ||
|
|
0c7c7ba05c | ||
|
|
4070efd803 | ||
|
|
6c27c1e863 | ||
|
|
dc12f26f05 | ||
|
|
3f9e66bd7b | ||
|
|
9849eebda3 | ||
|
|
8f84efb833 | ||
|
|
0084f764ba | ||
|
|
c2d72214de | ||
|
|
d64e75d374 | ||
|
|
a12b39b67f | ||
|
|
25b5b1ca8c | ||
|
|
afe7c69ec1 | ||
|
|
955056ae61 | ||
|
|
041796c85d | ||
|
|
f684ed2801 | ||
|
|
92b8a7fd58 | ||
|
|
dc18190452 | ||
|
|
4239d75275 | ||
|
|
111ead2719 | ||
|
|
f3710c4fcf | ||
|
|
fda618d7e8 | ||
|
|
89099a6f0d | ||
|
|
41d286feb5 | ||
|
|
e043ef5f66 | ||
|
|
070661c623 | ||
|
|
1d2f9c6d4c | ||
|
|
884113ae3c | ||
|
|
649d2d1381 | ||
|
|
a44d18fb87 | ||
|
|
f85ef70366 | ||
|
|
8d02b00cc3 | ||
|
|
747943258e | ||
|
|
b20c2cbc3b | ||
|
|
b466ed9eb8 | ||
|
|
a29e88f535 | ||
|
|
85a5ae44e1 | ||
|
|
3107094faa | ||
|
|
885ae3f63b | ||
|
|
88cfa40776 | ||
|
|
1dc4a771a3 | ||
|
|
24bfa82c0c | ||
|
|
4b0881263b | ||
|
|
3d1aa03abb | ||
|
|
114dbedfb7 | ||
|
|
a9ee4ae88b | ||
|
|
e4638688f5 | ||
|
|
347da9c309 | ||
|
|
19d86058f9 | ||
|
|
a7126b39dc | ||
|
|
dd454d56f3 | ||
|
|
96b05bcd4f | ||
|
|
9aa98846d2 | ||
|
|
8102506468 | ||
|
|
05e1fef42c | ||
|
|
1911bc55cd | ||
|
|
0bb4539d57 | ||
|
|
028350de3e | ||
|
|
4493f1c3a6 | ||
|
|
2c66e21268 | ||
|
|
3706b72855 | ||
|
|
cb396c8534 | ||
|
|
53d753932f | ||
|
|
e4a54fbade | ||
|
|
13c157d2fc | ||
|
|
c9eee58a80 | ||
|
|
2584d2934d | ||
|
|
271079370d | ||
|
|
15324dd149 | ||
|
|
6072b9a74e | ||
|
|
9441a1e49e | ||
|
|
aaaa396f2c | ||
|
|
da67500eaa | ||
|
|
adc8c56862 | ||
|
|
cec91ee159 | ||
|
|
4e36ac59b0 | ||
|
|
608df43225 | ||
|
|
cc68a6fa4c | ||
|
|
6877304de1 | ||
|
|
bb2e089f27 | ||
|
|
2d0db67a29 | ||
|
|
44d71ec538 | ||
|
|
86c1a035f6 | ||
|
|
77efe57015 | ||
|
|
6f20b874c5 | ||
|
|
1f3ed39eb6 | ||
|
|
b6e1e7e35b | ||
|
|
b8c87cfa2e | ||
|
|
ebb964dbd5 | ||
|
|
6c49c0b2d3 | ||
|
|
0eff5ece5f | ||
|
|
68aae77877 | ||
|
|
6fb9f9adf3 | ||
|
|
0497ce198d | ||
|
|
91acf71454 | ||
|
|
1885840768 | ||
|
|
d99c5f5e60 | ||
|
|
3252d48383 | ||
|
|
8e2feeb375 | ||
|
|
912a109c91 | ||
|
|
de4789822e | ||
|
|
b2b5ed2ae8 | ||
|
|
092057431c | ||
|
|
1130ba6e87 | ||
|
|
a352822afa | ||
|
|
ce63e5ee62 | ||
|
|
df53ce3e1c | ||
|
|
414fdac20a | ||
|
|
d6c37db4eb | ||
|
|
0c94a85dcc | ||
|
|
0fe233c7ed | ||
|
|
b1246b6ffc | ||
|
|
1c04ec7c55 | ||
|
|
e35f264e89 | ||
|
|
02bdaa5ddb | ||
|
|
cd230b601d | ||
|
|
4574d9d9b8 | ||
|
|
934bd4d1db | ||
|
|
66336bca0f | ||
|
|
829857be7c | ||
|
|
6e5f9e0741 | ||
|
|
19d2c8fcb9 | ||
|
|
9e12a199cf | ||
|
|
c310290bbc | ||
|
|
ff68a5182a | ||
|
|
9b7a4b79f7 | ||
|
|
58b8f4004b | ||
|
|
8477e20725 | ||
|
|
99ffbc1bfa | ||
|
|
29f1f3ea7c | ||
|
|
ce93f48a55 | ||
|
|
bf7ea31d35 | ||
|
|
0965acafd7 | ||
|
|
2d53b812ea | ||
|
|
316ae1020e | ||
|
|
b15c55fb28 | ||
|
|
c0dbda5882 | ||
|
|
9ee8e6efa7 | ||
|
|
f9e2a37816 | ||
|
|
ec33f48674 | ||
|
|
847a54493a | ||
|
|
0d0334a963 | ||
|
|
16514526c1 | ||
|
|
ef5125e972 | ||
|
|
5aaa352705 | ||
|
|
15db59f439 | ||
|
|
8448b9628e | ||
|
|
55b4f6c080 | ||
|
|
53b4151a26 | ||
|
|
e6b438a9e0 | ||
|
|
2f1c54ca93 | ||
|
|
f05bbbc2a1 | ||
|
|
42bfe19c9c | ||
|
|
22a486752b | ||
|
|
8519ad8cf1 | ||
|
|
7b9cde9946 | ||
|
|
c539cc6e57 | ||
|
|
3fc55638f9 | ||
|
|
e5a110f24f | ||
|
|
ccf132ff50 | ||
|
|
4f9334c1dd | ||
|
|
905cd9cf0d | ||
|
|
085c9e13ad | ||
|
|
7c49689738 | ||
|
|
3b2128acaa | ||
|
|
233c1c80b4 | ||
|
|
34ed045ba6 | ||
|
|
0018159c89 | ||
|
|
97bd12fc33 | ||
|
|
5a3b59ce29 | ||
|
|
88e83f9aad | ||
|
|
fadebbc17b | ||
|
|
e261ced701 | ||
|
|
03768d7124 | ||
|
|
520eb15ce9 | ||
|
|
fd4c9b5e6c | ||
|
|
803ae8a7ac | ||
|
|
97b81cf782 | ||
|
|
404dce4a32 | ||
|
|
be8c1b69dc | ||
|
|
c9067354c0 | ||
|
|
c829e857d2 | ||
|
|
842631feef | ||
|
|
87f217ca37 | ||
|
|
3cd91d87a4 | ||
|
|
d1d94570e7 | ||
|
|
bc0cb10406 | ||
|
|
6634cd1377 | ||
|
|
d6ca3891a1 | ||
|
|
99af95e0a8 | ||
|
|
fbbce29da7 | ||
|
|
688654adcc | ||
|
|
9ad0c34603 | ||
|
|
8d7fee16b8 | ||
|
|
cc68ef758f | ||
|
|
c950fe2125 | ||
|
|
e0b48f5f49 | ||
|
|
b9a2404f9c | ||
|
|
f0ef119440 | ||
|
|
45cece245c | ||
|
|
4bac50dec2 | ||
|
|
814ccf1b29 | ||
|
|
7296017ab8 | ||
|
|
d0dec2539d | ||
|
|
ae3142c2f5 | ||
|
|
a5599deb8e | ||
|
|
989439926c | ||
|
|
f636b67dca | ||
|
|
7db91a9a38 | ||
|
|
d484545bef | ||
|
|
ce7c525155 | ||
|
|
9d34038eab | ||
|
|
e91ed55963 | ||
|
|
f2e35a0c5a | ||
|
|
00ad68389c | ||
|
|
bc19f1a57d | ||
|
|
35cabf34b0 | ||
|
|
c7159721cb | ||
|
|
f8a6e9723a | ||
|
|
69c68bf300 | ||
|
|
4919b8748a | ||
|
|
43ad787bda | ||
|
|
f9ad3b59f1 | ||
|
|
2a756616f4 | ||
|
|
7fbd546d43 | ||
|
|
903c1999eb | ||
|
|
d36a076942 | ||
|
|
30f339400e | ||
|
|
af190b0422 | ||
|
|
f7824e1df5 | ||
|
|
2168145d58 | ||
|
|
ebb1323129 | ||
|
|
34ca6324c5 | ||
|
|
908931e174 | ||
|
|
1f15c9e8f1 | ||
|
|
9a0686685c | ||
|
|
ccc63966c6 | ||
|
|
18d8ab068d | ||
|
|
227396d08a | ||
|
|
dbc92572fd | ||
|
|
ea2f603cf7 | ||
|
|
a5aa9e7281 | ||
|
|
0e5ee7063f | ||
|
|
d95630c4d0 | ||
|
|
451202335d | ||
|
|
36be58f775 | ||
|
|
a23204a86c | ||
|
|
4928dab3f0 | ||
|
|
b6bf2cd950 | ||
|
|
469936308c | ||
|
|
d330b64bba | ||
|
|
258ca46428 | ||
|
|
e4998e267e | ||
|
|
adc84452d5 | ||
|
|
ce89d1c724 | ||
|
|
354660a374 | ||
|
|
a47e845847 | ||
|
|
da84e30936 | ||
|
|
0f52fdf3b6 | ||
|
|
dfe8c90da4 | ||
|
|
9ed4a15b32 | ||
|
|
961991a316 | ||
|
|
e9878f68b9 | ||
|
|
95532bcdd5 | ||
|
|
a8e81935cc | ||
|
|
2a1f6602ba | ||
|
|
d113e11c3b | ||
|
|
5a4dd8bb6a | ||
|
|
85286095d7 | ||
|
|
34d9ccbd5b | ||
|
|
d98a511757 | ||
|
|
cb93950785 | ||
|
|
ddf5324a82 | ||
|
|
67d3eef37a | ||
|
|
7fda9dba0d | ||
|
|
da2e802e29 | ||
|
|
347d449f51 | ||
|
|
41d1ceb7cd | ||
|
|
2060a698bd | ||
|
|
ff73405d92 | ||
|
|
878230ebb1 | ||
|
|
f33c694dd3 | ||
|
|
5ef109c037 | ||
|
|
373f519464 | ||
|
|
51c502486e | ||
|
|
168803ae8a | ||
|
|
a22ab7f625 | ||
|
|
4e5a12a514 | ||
|
|
6cf94fce66 | ||
|
|
0549cb5c3a | ||
|
|
58810243dc | ||
|
|
04508e8c5c | ||
|
|
2e82e5e6c2 | ||
|
|
4630b08fee | ||
|
|
73e739310e | ||
|
|
5711d9edb1 | ||
|
|
5f316f242e | ||
|
|
30c3e8eec1 | ||
|
|
2e536fc57c | ||
|
|
aada25b865 | ||
|
|
89e43cc1dc | ||
|
|
debce2e8f7 | ||
|
|
a21bd3acec | ||
|
|
a586c2c50a | ||
|
|
fc66620615 | ||
|
|
afe15e1f7a | ||
|
|
953aead1e7 | ||
|
|
b8713db19c | ||
|
|
fc993809d6 | ||
|
|
7418492ef1 | ||
|
|
305cc5514a | ||
|
|
00ae7b09da | ||
|
|
ceacce741a | ||
|
|
e26c34daf5 | ||
|
|
782b29baed | ||
|
|
4e04aac322 |
No files matched your search
@@ -1,17 +0,0 @@
|
||||
##### What version of ViaBackwards are you using? Type /ver ViaBackwards:
|
||||
|
||||
|
||||
##### What version of ViaVersion are you using? Type /ver ViaVersion:
|
||||
|
||||
|
||||
##### What version of Spigot are you using? Type /ver:
|
||||
|
||||
|
||||
##### What plugins are you using? Type /plugins:
|
||||
|
||||
|
||||
##### How/when does this error happen? login?:
|
||||
|
||||
|
||||
##### Is there an error in the console? Use pastebin.com. Is there a kick message?:
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**"
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: "'/viaversion dump' Output"
|
||||
description: |
|
||||
Run `/viaversion dump` in the console or in the chat, then copy and paste the given link here.
|
||||
placeholder: |
|
||||
https://dump.viaversion.com/...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Console Error
|
||||
description: |
|
||||
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
|
||||
If the error is small/less than 10 lines, you may put it directly into this field.
|
||||
value: |
|
||||
```
|
||||
Put the paste.gg link or text here.
|
||||
```
|
||||
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: |
|
||||
Describe the unexpected behavior.
|
||||
If you want to attach screenshots, use the comment field at the bottom of the page.
|
||||
placeholder: |
|
||||
Example: "Placing signs on 1.13.2 causes text to disappear."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: |
|
||||
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Login with a 1.13.2 client
|
||||
2. Place a sign
|
||||
3. The sign text is displayed wrong
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: |
|
||||
Describe what exactly you expected to happen.
|
||||
placeholder: |
|
||||
Example: "Placed sign text should not disappear."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Server Info
|
||||
description: |
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
placeholder: |
|
||||
Example: "I also use BungeeCord with the following plugins: x, y, z"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
description: Make sure you have followed each of the steps outlined here.
|
||||
options:
|
||||
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. BungeeCord), **not on both**.
|
||||
required: true
|
||||
- label: I have included a ViaVersion dump.
|
||||
required: true
|
||||
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
|
||||
required: true
|
||||
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Comments And Screenshots
|
||||
If needed, add **screenshots to help explain your problem** in the comment field below.
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Dev builds
|
||||
url: https://ci.viaversion.com/
|
||||
about: Before reporting a bug, please check if using master/dev builds from our ci fixes your issue.
|
||||
- name: ViaVersion Discord
|
||||
url: https://discord.gg/viaversion
|
||||
about: For smaller issues or questions, you can also join our Discord server.
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Feature Request
|
||||
description: Suggest a feature to be added
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Problem Description
|
||||
description: |
|
||||
Describe the issue you are facing or why you need the feature to be added.
|
||||
placeholder: |
|
||||
I am always frustrated with...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Solution Description
|
||||
description: |
|
||||
Describe the solution you would like to see.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: |
|
||||
Describe alternatives you have considered.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Info
|
||||
description: |
|
||||
Does the feature apply to any specific version or environment?
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,25 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: 11
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: build/libs
|
||||
+86
-103
@@ -1,105 +1,33 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Maven template
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
### NetBeans template
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
.nb-gradle/
|
||||
### Eclipse template
|
||||
### Java files ###
|
||||
*.class
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
# Package Files
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
# Ignore project files
|
||||
*.iml
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
!.idea/dictionaries/*
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
# File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
### Plugin-specific files: ###
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
@@ -113,18 +41,73 @@ atlassian-ide-plugin.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
### Java template
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
||||
|
||||
### Git ###
|
||||
# Don't exclude the .gitignore itself
|
||||
!.gitignore
|
||||
@@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
@@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
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/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,13 +1,53 @@
|
||||
# ViaBackwards
|
||||
|
||||
Allows 1.9.x on a 1.10 Spigot server.
|
||||
Requires [ViaVersion](http://viaversion.com) to be installed
|
||||
[](https://github.com/ViaVersion/ViaBackwards/releases)
|
||||
[](https://github.com/ViaVersion/ViaBackwards/actions)
|
||||
[](https://viaversion.com/discord)
|
||||
|
||||
TODO:
|
||||
- [ ] Cleanup code
|
||||
- [ ] Improve the rewriters
|
||||
- [ ] Make it possible to send metadata with the rewriteEntityId
|
||||
- [ ] Add support for sound names
|
||||
- [ ] Create JavaDocs
|
||||
- [ ] Improve the Entity tracker system to work good with multiple versions.
|
||||
- [ ] Make it possible to choose your own replacement blocks
|
||||
**Allows older Minecraft client versions to connect to newer server versions**
|
||||
|
||||
Supported Versions
|
||||
-
|
||||
**Green** = ViaVersion\
|
||||
**Purple** = ViaBackwards addition
|
||||
|
||||

|
||||
|
||||
Releases / Dev Builds
|
||||
-
|
||||
**Requires [ViaVersion](https://www.spigotmc.org/resources/viaversion.19254/) to be installed**
|
||||
|
||||
You can find the latest dev builds here:\
|
||||
**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/
|
||||
|
||||
**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/
|
||||
|
||||
**CurseForge page:** https://www.curseforge.com/minecraft/mc-mods/viabackwards
|
||||
|
||||
Known issues
|
||||
-
|
||||
* Custom 1.17+ min_y and height world values are not and will (most likely) never be supported => Clients older than 1.17 will not be able to see or interact with blocks below y=0 and above y=255
|
||||
* < 1.17 clients on 1.17+ servers might experience inventory desyncs on certain inventory click actions
|
||||
* Sound mappings are incomplete ([see here](https://github.com/ViaVersion/ViaBackwards/issues/326))
|
||||
|
||||
Other Links
|
||||
-
|
||||
**Maven:** https://repo.viaversion.com
|
||||
|
||||
**Issue tracker:** https://github.com/ViaVersion/ViaBackwards/issues
|
||||
|
||||
**List of contributors:** https://github.com/ViaVersion/ViaBackwards/graphs/contributors
|
||||
|
||||
License
|
||||
-
|
||||
This project is licensed under the [GNU General Public License](LICENSE).
|
||||
|
||||
Special Thanks
|
||||
-
|
||||

|
||||
|
||||
[YourKit](https://www.yourkit.com/) supports open source projects with innovative and intelligent tools
|
||||
for monitoring and profiling Java and .NET applications.
|
||||
YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
|
||||
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
|
||||
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// version must be manually kept in sync with the one in root project settings.gradle.kts
|
||||
implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0")
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
fun Project.publishShadowJar() {
|
||||
configurePublication {
|
||||
artifact(tasks["shadowJar"])
|
||||
artifact(tasks["sourcesJar"])
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.publishJavaComponents() {
|
||||
configurePublication {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.configurePublication(configurer: MavenPublication.() -> Unit) {
|
||||
extensions.configure<PublishingExtension> {
|
||||
publications.named<MavenPublication>("mavenJava") {
|
||||
apply(configurer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.latestCommitHash(): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun JavaPluginExtension.javaTarget(version: Int) {
|
||||
sourceCompatibility = JavaVersion.toVersion(version)
|
||||
targetCompatibility = JavaVersion.toVersion(version)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
tasks {
|
||||
// Variable replacements
|
||||
processResources {
|
||||
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
|
||||
expand("version" to project.version, "description" to project.description, "url" to "https://github.com/ViaVersion/ViaBackwards")
|
||||
}
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
javaTarget(8)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.create<MavenPublication>("mavenJava") {
|
||||
groupId = rootProject.group as String
|
||||
artifactId = project.name
|
||||
version = rootProject.version as String
|
||||
}
|
||||
repositories.maven {
|
||||
name = "Via"
|
||||
url = uri("https://repo.viaversion.com/")
|
||||
credentials(PasswordCredentials::class)
|
||||
authentication {
|
||||
create<BasicAuthentication>("basic")
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
id("vb.shadow-conventions")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").capitalize()}-${project.version}.jar")
|
||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.named
|
||||
|
||||
plugins {
|
||||
id("vb.base-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
named<Jar>("jar") {
|
||||
archiveClassifier.set("unshaded")
|
||||
from(project.rootProject.file("LICENSE"))
|
||||
}
|
||||
val shadowJar = named<ShadowJar>("shadowJar") {
|
||||
archiveClassifier.set("")
|
||||
configureRelocations()
|
||||
}
|
||||
named("build") {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
||||
fun ShadowJar.configureRelocations() {
|
||||
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
|
||||
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
id("vb.base-conventions")
|
||||
}
|
||||
|
||||
publishJavaComponents()
|
||||
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
base
|
||||
id("vb.build-logic")
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.0.1"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
projects.viabackwardsBukkit,
|
||||
projects.viabackwardsBungee,
|
||||
projects.viabackwardsFabric,
|
||||
projects.viabackwardsSponge,
|
||||
projects.viabackwardsVelocity
|
||||
).map { it.dependencyProject }
|
||||
|
||||
// Would otherwise contain api/depdency modules if at some point needed
|
||||
val special = setOf(
|
||||
projects.viabackwards
|
||||
).map { it.dependencyProject }
|
||||
|
||||
subprojects {
|
||||
when (this) {
|
||||
in platforms -> plugins.apply("vb.platform-conventions")
|
||||
in special -> plugins.apply("vb.base-conventions")
|
||||
else -> plugins.apply("vb.standard-conventions")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnly(libs.paper) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("javax.persistence", "persistence-api")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viabackwards.listener.FireDamageListener;
|
||||
import com.viaversion.viabackwards.listener.FireExtinguishListener;
|
||||
import com.viaversion.viabackwards.listener.LecternInteractListener;
|
||||
import com.viaversion.viaversion.ViaVersionPlugin;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.bukkit.platform.BukkitViaLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (!ViaVersionPlugin.getInstance().isLateBind()) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (ViaVersionPlugin.getInstance().isLateBind()) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
init(getDataFolder());
|
||||
Via.getPlatform().runSync(this::onServerLoaded);
|
||||
}
|
||||
|
||||
private void onServerLoaded() {
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion();
|
||||
if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) {
|
||||
loader.storeListener(new FireExtinguishListener(this)).register();
|
||||
}
|
||||
if (protocolVersion >= ProtocolVersion.v1_14.getVersion()) {
|
||||
loader.storeListener(new LecternInteractListener(this)).register();
|
||||
}
|
||||
if (protocolVersion >= ProtocolVersion.v1_12.getVersion()) {
|
||||
loader.storeListener(new FireDamageListener(this)).register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
getPluginLoader().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.listener;
|
||||
|
||||
import com.viaversion.viabackwards.BukkitPlugin;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class FireDamageListener extends ViaBukkitListener {
|
||||
|
||||
public FireDamageListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_11_1To1_12.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFireDamage(EntityDamageEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) return;
|
||||
|
||||
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||
if (cause != EntityDamageEvent.DamageCause.FIRE
|
||||
&& cause != EntityDamageEvent.DamageCause.FIRE_TICK
|
||||
&& cause != EntityDamageEvent.DamageCause.LAVA
|
||||
&& cause != EntityDamageEvent.DamageCause.DROWNING) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
if (isOnPipe(player)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_HURT, SoundCategory.PLAYERS, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.listener;
|
||||
|
||||
import com.viaversion.viabackwards.BukkitPlugin;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FireExtinguishListener extends ViaBukkitListener {
|
||||
|
||||
public FireExtinguishListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_15_2To1_16.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFireExtinguish(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Block relative = block.getRelative(event.getBlockFace());
|
||||
if (relative.getType() == Material.FIRE) {
|
||||
event.setCancelled(true);
|
||||
relative.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.listener;
|
||||
|
||||
import com.viaversion.viabackwards.BukkitPlugin;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Lectern;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
public class LecternInteractListener extends ViaBukkitListener {
|
||||
|
||||
public LecternInteractListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_13_2To1_14.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onLecternInteract(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null || block.getType() != Material.LECTERN) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Lectern lectern = (Lectern) block.getState();
|
||||
ItemStack book = lectern.getInventory().getItem(0);
|
||||
if (book == null) return;
|
||||
|
||||
BookMeta meta = (BookMeta) book.getItemMeta();
|
||||
|
||||
// Open a book with the text of the lectern's writable book
|
||||
ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK);
|
||||
BookMeta newBookMeta = (BookMeta) newBook.getItemMeta();
|
||||
newBookMeta.setPages(meta.getPages());
|
||||
newBookMeta.setAuthor("an upsidedown person");
|
||||
newBookMeta.setTitle("buk");
|
||||
newBook.setItemMeta(newBookMeta);
|
||||
player.openBook(newBook);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
name: ViaBackwards
|
||||
version: ${version}
|
||||
description: Allow older Minecraft versions to connect to a newer server version.
|
||||
main: com.viaversion.viabackwards.BukkitPlugin
|
||||
api-version: 1.13
|
||||
|
||||
authors: [Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1]
|
||||
website: ${url}
|
||||
|
||||
depend: [ViaVersion]
|
||||
@@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation(projects.viabackwardsCommon)
|
||||
compileOnly(libs.bungee)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
name: ViaBackwards
|
||||
main: com.viaversion.viabackwards.BungeePlugin
|
||||
author: "Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1"
|
||||
version: ${version}
|
||||
depends: [ViaVersion]
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
}
|
||||
|
||||
blossom {
|
||||
replaceToken("\$VERSION", project.version)
|
||||
replaceToken("\$IMPL_VERSION", "git-ViaBackwards-${project.version}:${rootProject.latestCommitHash()}")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(libs.viaver)
|
||||
compileOnlyApi(libs.netty)
|
||||
compileOnlyApi(libs.guava)
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsConfig;
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
|
||||
public class ViaBackwards {
|
||||
|
||||
private static ViaBackwardsPlatform platform;
|
||||
private static ViaBackwardsConfig config;
|
||||
|
||||
public static void init(ViaBackwardsPlatform platform, ViaBackwardsConfig config) {
|
||||
Preconditions.checkArgument(platform != null, "ViaBackwards is already initialized");
|
||||
|
||||
ViaBackwards.platform = platform;
|
||||
ViaBackwards.config = config;
|
||||
}
|
||||
|
||||
public static ViaBackwardsPlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public static ViaBackwardsConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
|
||||
|
||||
private boolean addCustomEnchantsToLore;
|
||||
private boolean addTeamColorToPrefix;
|
||||
private boolean fix1_13FacePlayer;
|
||||
private boolean alwaysShowOriginalMobName;
|
||||
|
||||
public ViaBackwardsConfig(File configFile) {
|
||||
super(configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
super.reloadConfig();
|
||||
loadFields();
|
||||
}
|
||||
|
||||
private void loadFields() {
|
||||
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
|
||||
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
|
||||
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCustomEnchantsToLore() {
|
||||
return addCustomEnchantsToLore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addTeamColorTo1_13Prefix() {
|
||||
return addTeamColorToPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFix1_13FacePlayer() {
|
||||
return fix1_13FacePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysShowOriginalMobName() {
|
||||
return alwaysShowOriginalMobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDefaultConfigURL() {
|
||||
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleConfig(Map<String, Object> map) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
||||
extends AbstractProtocol<C1, C2, S1, S2> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
|
||||
*/
|
||||
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
|
||||
Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
// Manually load them later, since they depend on VV's mappings
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BackwardsMappings getMappingData() { // Change return type to BackwardsMappings
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable TranslatableRewriter getTranslatableRewriter() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api;
|
||||
|
||||
public interface ViaBackwardsConfig {
|
||||
|
||||
/**
|
||||
* Mimics name and level of a custom enchant through the item's lore.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean addCustomEnchantsToLore();
|
||||
|
||||
/**
|
||||
* Writes the color of the scoreboard team after the prefix.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean addTeamColorTo1_13Prefix();
|
||||
|
||||
/**
|
||||
* Converts the new 1.13 face player packets to look packets.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isFix1_13FacePlayer();
|
||||
|
||||
/**
|
||||
* Always shows the original mob's name instead of only when hovering over them with the cursor.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean alwaysShowOriginalMobName();
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.ViaBackwardsConfig;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_3to1_14_4.Protocol1_14_3To1_14_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_15_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15to1_15_1.Protocol1_15To1_15_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_2to1_16_3.Protocol1_16_2To1_16_3;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.Protocol1_16_3To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.Protocol1_17To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.update.Version;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.0.1";
|
||||
String IMPL_VERSION = "$IMPL_VERSION";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
*/
|
||||
default void init(File dataFolder) {
|
||||
ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml"));
|
||||
config.reloadConfig();
|
||||
|
||||
ViaBackwards.init(this, config);
|
||||
|
||||
if (isOutdated()) return;
|
||||
|
||||
Via.getManager().getSubPlatforms().add(IMPL_VERSION);
|
||||
|
||||
getLogger().info("Loading translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
|
||||
ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
protocolManager.registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
|
||||
protocolManager.registerProtocol(new Protocol1_11To1_11_1(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_11_1To1_12(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12);
|
||||
protocolManager.registerProtocol(new Protocol1_12To1_12_1(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1);
|
||||
protocolManager.registerProtocol(new Protocol1_12_1To1_12_2(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_12_2To1_13(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13);
|
||||
protocolManager.registerProtocol(new Protocol1_13To1_13_1(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1);
|
||||
protocolManager.registerProtocol(new Protocol1_13_1To1_13_2(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_13_2To1_14(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14);
|
||||
protocolManager.registerProtocol(new Protocol1_14To1_14_1(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1);
|
||||
protocolManager.registerProtocol(new Protocol1_14_1To1_14_2(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2);
|
||||
protocolManager.registerProtocol(new Protocol1_14_2To1_14_3(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3);
|
||||
protocolManager.registerProtocol(new Protocol1_14_3To1_14_4(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_14_4To1_15(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15);
|
||||
protocolManager.registerProtocol(new Protocol1_15To1_15_1(), ProtocolVersion.v1_15, ProtocolVersion.v1_15_1);
|
||||
protocolManager.registerProtocol(new Protocol1_15_1To1_15_2(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
|
||||
protocolManager.registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
|
||||
protocolManager.registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
|
||||
protocolManager.registerProtocol(new Protocol1_16_2To1_16_3(), ProtocolVersion.v1_16_2, ProtocolVersion.v1_16_3);
|
||||
protocolManager.registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
|
||||
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger provided by the platform.
|
||||
*
|
||||
* @return logger instance
|
||||
*/
|
||||
Logger getLogger();
|
||||
|
||||
default boolean isOutdated() {
|
||||
String vvVersion = Via.getPlatform().getPluginVersion();
|
||||
if (vvVersion != null && new Version(vvVersion).compareTo(new Version(MINIMUM_VV_VERSION + "--")) < 0) {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER");
|
||||
getLogger().severe("LINK: https://ci.viaversion.com/");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
||||
disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the plugin.
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Returns ViaBackwards's data folder.
|
||||
*
|
||||
* @return data folder
|
||||
*/
|
||||
File getDataFolder();
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BackwardsMappings extends MappingDataBase {
|
||||
|
||||
private final Class<? extends Protocol> vvProtocolClass;
|
||||
private Int2ObjectMap<MappedItem> backwardsItemMappings;
|
||||
private Map<String, String> backwardsSoundMappings;
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass) {
|
||||
this(oldVersion, newVersion, vvProtocolClass, false);
|
||||
}
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) {
|
||||
super(oldVersion, newVersion, hasDiffFile);
|
||||
Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class));
|
||||
this.vvProtocolClass = vvProtocolClass;
|
||||
// Just re-use ViaVersion's item id map
|
||||
loadItems = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
if (diffMappings != null) {
|
||||
JsonObject diffItems = diffMappings.getAsJsonObject("items");
|
||||
if (diffItems != null) {
|
||||
backwardsItemMappings = VBMappingDataLoader.loadItemMappings(oldMappings.getAsJsonObject("items"),
|
||||
newMappings.getAsJsonObject("items"), diffItems, shouldWarnOnMissing("items"));
|
||||
}
|
||||
|
||||
JsonObject diffSounds = diffMappings.getAsJsonObject("sounds");
|
||||
if (diffSounds != null) {
|
||||
backwardsSoundMappings = VBMappingDataLoader.objectToMap(diffSounds);
|
||||
}
|
||||
}
|
||||
|
||||
// Just re-use ViaVersion's item id map
|
||||
if (vvProtocolClass != null) {
|
||||
itemMappings = Via.getManager().getProtocolManager().getProtocol(vvProtocolClass).getMappingData().getItemMappings().inverse();
|
||||
}
|
||||
|
||||
loadVBExtras(oldMappings, newMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff, shouldWarnOnMissing(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff, shouldWarnOnMissing(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject loadDiffFile() {
|
||||
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
|
||||
}
|
||||
|
||||
/**
|
||||
* To be overridden.
|
||||
*/
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
}
|
||||
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return !key.equals("blocks") && !key.equals("statistics");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Logger getLogger() {
|
||||
return ViaBackwards.getPlatform().getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getMappedItem(int) for custom backwards mappings
|
||||
*/
|
||||
@Override
|
||||
public int getNewItemId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.itemMappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.blockMappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldItemId(final int id) {
|
||||
// Warn on missing
|
||||
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
|
||||
}
|
||||
|
||||
public @Nullable MappedItem getMappedItem(int id) {
|
||||
return backwardsItemMappings != null ? backwardsItemMappings.get(id) : null;
|
||||
}
|
||||
|
||||
public @Nullable String getMappedNamedSound(String id) {
|
||||
if (backwardsItemMappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (id.indexOf(':') == -1) {
|
||||
id = "minecraft:" + id;
|
||||
}
|
||||
|
||||
return backwardsSoundMappings.get(id);
|
||||
}
|
||||
|
||||
public @Nullable Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
||||
return backwardsItemMappings;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> getBackwardsSoundMappings() {
|
||||
return backwardsSoundMappings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
public class MappedItem {
|
||||
|
||||
private final int id;
|
||||
private final String jsonName;
|
||||
|
||||
public MappedItem(int id, String name) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getJsonName() {
|
||||
return jsonName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappedLegacyBlockItem {
|
||||
|
||||
private final int id;
|
||||
private final short data;
|
||||
private final String name;
|
||||
private final Block block;
|
||||
private BlockEntityHandler blockEntityHandler;
|
||||
|
||||
public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.name = name != null ? "§f" + name : null;
|
||||
this.block = block ? new Block(id, data) : null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public short getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isBlock() {
|
||||
return block != null;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public boolean hasBlockEntityHandler() {
|
||||
return blockEntityHandler != null;
|
||||
}
|
||||
|
||||
public @Nullable BlockEntityHandler getBlockEntityHandler() {
|
||||
return blockEntityHandler;
|
||||
}
|
||||
|
||||
public void setBlockEntityHandler(@Nullable BlockEntityHandler blockEntityHandler) {
|
||||
this.blockEntityHandler = blockEntityHandler;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockEntityHandler {
|
||||
|
||||
CompoundTag handleOrNewCompoundTag(int block, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonIOException;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class VBMappingDataLoader {
|
||||
|
||||
public static JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(ViaBackwards.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) return loadData(name);
|
||||
|
||||
// Load the file from the platform's directory if present
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
ViaBackwards.getPlatform().getLogger().warning(name + " is badly formatted!");
|
||||
e.printStackTrace();
|
||||
ViaBackwards.getPlatform().getLogger().warning("Falling back to resource's file!");
|
||||
return loadData(name);
|
||||
} catch (IOException | JsonIOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JsonObject loadData(String name) {
|
||||
InputStream stream = VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name);
|
||||
try (InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int mappedId = newIdentifierMap.getInt(key);
|
||||
if (mappedId == -1) {
|
||||
if (diffIdentifiers != null) {
|
||||
// Search in diff mappings
|
||||
JsonPrimitive diffValueJson = diffIdentifiers.getAsJsonPrimitive(key);
|
||||
String diffValue = diffValueJson != null ? diffValueJson.getAsString() : null;
|
||||
|
||||
int dataIndex;
|
||||
if (diffValue == null && (dataIndex = key.indexOf('[')) != -1
|
||||
&& (diffValueJson = diffIdentifiers.getAsJsonPrimitive(key.substring(0, dataIndex))) != null) {
|
||||
// Check for wildcard mappings
|
||||
diffValue = diffValueJson.getAsString();
|
||||
|
||||
// Keep original properties if value ends with [
|
||||
if (diffValue.endsWith("[")) {
|
||||
diffValue += key.substring(dataIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (diffValue != null) {
|
||||
mappedId = newIdentifierMap.getInt(diffValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (mappedId == -1) {
|
||||
// Nothing found :(
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
output[Integer.parseInt(entry.getKey())] = mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> objectToMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.indexOf(':') == -1) {
|
||||
key = "minecraft:" + key;
|
||||
}
|
||||
String value = entry.getValue().getAsString();
|
||||
if (value.indexOf(':') == -1) {
|
||||
value = "minecraft:" + value;
|
||||
}
|
||||
mappings.put(key, value);
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
||||
return loadItemMappings(oldMapping, newMapping, diffMapping, false);
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
Int2ObjectMap<MappedItem> itemMapping = new Int2ObjectOpenHashMap<>(diffMapping.size(), 1F);
|
||||
Object2IntMap<String> newIdenfierMap = MappingDataLoader.indexedObjectToMap(newMapping);
|
||||
Object2IntMap<String> oldIdenfierMap = MappingDataLoader.indexedObjectToMap(oldMapping);
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
JsonObject object = entry.getValue().getAsJsonObject();
|
||||
String mappedIdName = object.getAsJsonPrimitive("id").getAsString();
|
||||
int mappedId = newIdenfierMap.getInt(mappedIdName);
|
||||
if (mappedId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldId = oldIdenfierMap.getInt(entry.getKey());
|
||||
if (oldId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No old entry for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
itemMapping.put(oldId, new MappedItem(mappedId, name));
|
||||
}
|
||||
|
||||
// Look for missing keys
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings()) {
|
||||
for (Object2IntMap.Entry<String> entry : oldIdenfierMap.object2IntEntrySet()) {
|
||||
if (!newIdenfierMap.containsKey(entry.getKey()) && !itemMapping.containsKey(entry.getIntValue())) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No item mapping for " + entry.getKey() + " :( ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemMapping;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VBMappings extends IntArrayMappings {
|
||||
|
||||
public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(create(size, oldMapping, newMapping, diffMapping, warnOnMissing));
|
||||
}
|
||||
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(create(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping, warnOnMissing));
|
||||
}
|
||||
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(oldMapping.size(), oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
private static int[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
int[] oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
return oldToNew;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class EntityData {
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private Object mobName;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(int id, int replacementId) {
|
||||
this.id = id;
|
||||
this.replacementId = replacementId;
|
||||
}
|
||||
|
||||
public EntityData jsonName(String name) {
|
||||
this.mobName = ChatRewriter.legacyTextToJson(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData mobName(String name) {
|
||||
this.mobName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityData spawnMetadata(MetaCreator handler) {
|
||||
this.defaultMeta = handler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasBaseMeta() {
|
||||
return this.defaultMeta != null;
|
||||
}
|
||||
|
||||
public int typeId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
public @Nullable Object mobName() {
|
||||
return mobName;
|
||||
}
|
||||
|
||||
public int replacementId() {
|
||||
return replacementId;
|
||||
}
|
||||
|
||||
public @Nullable MetaCreator defaultMeta() {
|
||||
return defaultMeta;
|
||||
}
|
||||
|
||||
public boolean isObjectType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int objectData() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityData{" +
|
||||
"id=" + id +
|
||||
", mobName='" + mobName + '\'' +
|
||||
", replacementId=" + replacementId +
|
||||
", defaultMeta=" + defaultMeta +
|
||||
'}';
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MetaCreator {
|
||||
|
||||
void createMeta(WrappedMetadata storage);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
public class EntityObjectData extends EntityData {
|
||||
private final boolean isObject;
|
||||
private final int objectData;
|
||||
|
||||
public EntityObjectData(int id, boolean isObject, int replacementId, int objectData) {
|
||||
super(id, replacementId);
|
||||
this.isObject = isObject;
|
||||
this.objectData = objectData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectType() {
|
||||
return isObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int objectData() {
|
||||
return objectData;
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EntityPositionHandler {
|
||||
|
||||
public static final double RELATIVE_MOVE_FACTOR = 32 * 128;
|
||||
private final EntityRewriterBase entityRewriter;
|
||||
private final Class<? extends EntityPositionStorage> storageClass;
|
||||
private final Supplier<? extends EntityPositionStorage> storageSupplier;
|
||||
private boolean warnedForMissingEntity;
|
||||
|
||||
public EntityPositionHandler(EntityRewriterBase entityRewriter,
|
||||
Class<? extends EntityPositionStorage> storageClass, Supplier<? extends EntityPositionStorage> storageSupplier) {
|
||||
this.entityRewriter = entityRewriter;
|
||||
this.storageClass = storageClass;
|
||||
this.storageSupplier = storageSupplier;
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) throws Exception {
|
||||
cacheEntityPosition(wrapper,
|
||||
wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative);
|
||||
}
|
||||
|
||||
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
|
||||
if (storedEntity == null) {
|
||||
if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :>
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
|
||||
if (entityId == -1 && x == 0 && y == 0 && z == 0) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
|
||||
} else if (!warnedForMissingEntity) {
|
||||
warnedForMissingEntity = true;
|
||||
ViaBackwards.getPlatform().getLogger().warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPositionStorage positionStorage = create ? storageSupplier.get() : storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
}
|
||||
|
||||
positionStorage.setCoordinates(x, y, z, relative);
|
||||
storedEntity.put(positionStorage);
|
||||
}
|
||||
|
||||
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId);
|
||||
EntityPositionStorage entityStorage;
|
||||
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
|
||||
return null;
|
||||
}
|
||||
return entityStorage;
|
||||
}
|
||||
|
||||
public static void writeFacingAngles(PacketWrapper wrapper, double x, double y, double z, double targetX, double targetY, double targetZ) {
|
||||
double dX = targetX - x;
|
||||
double dY = targetY - y;
|
||||
double dZ = targetZ - z;
|
||||
double r = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
|
||||
double yaw = -Math.atan2(dX, dZ) / Math.PI * 180;
|
||||
if (yaw < 0) {
|
||||
yaw = 360 + yaw;
|
||||
}
|
||||
double pitch = -Math.asin(dY / r) / Math.PI * 180;
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) (yaw * 256f / 360f));
|
||||
wrapper.write(Type.BYTE, (byte) (pitch * 256f / 360f));
|
||||
}
|
||||
|
||||
public static void writeFacingDegrees(PacketWrapper wrapper, double x, double y, double z, double targetX, double targetY, double targetZ) {
|
||||
double dX = targetX - x;
|
||||
double dY = targetY - y;
|
||||
double dZ = targetZ - z;
|
||||
double r = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
|
||||
double yaw = -Math.atan2(dX, dZ) / Math.PI * 180;
|
||||
if (yaw < 0) {
|
||||
yaw = 360 + yaw;
|
||||
}
|
||||
double pitch = -Math.asin(dY / r) / Math.PI * 180;
|
||||
|
||||
wrapper.write(Type.FLOAT, (float) yaw);
|
||||
wrapper.write(Type.FLOAT, (float) pitch);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
public abstract class EntityPositionStorage {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setCoordinates(double x, double y, double z, boolean relative) {
|
||||
if (relative) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
} else {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class PlayerPositionStorage implements StorableObject {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
protected PlayerPositionStorage() {
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setX(final double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(final double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(final double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setCoordinates(PacketWrapper wrapper, boolean relative) throws Exception {
|
||||
setCoordinates(wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), relative);
|
||||
}
|
||||
|
||||
public void setCoordinates(double x, double y, double z, boolean relative) {
|
||||
if (relative) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
} else {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class WrappedMetadata {
|
||||
private final List<Metadata> metadataList;
|
||||
|
||||
public WrappedMetadata(List<Metadata> metadataList) {
|
||||
this.metadataList = metadataList;
|
||||
}
|
||||
|
||||
public boolean has(Metadata data) {
|
||||
return this.metadataList.contains(data);
|
||||
}
|
||||
|
||||
public void remove(Metadata data) {
|
||||
this.metadataList.remove(data);
|
||||
}
|
||||
|
||||
public void remove(int index) {
|
||||
metadataList.removeIf(meta -> meta.id() == index);
|
||||
}
|
||||
|
||||
public void add(Metadata data) {
|
||||
this.metadataList.add(data);
|
||||
}
|
||||
|
||||
public @Nullable Metadata get(int index) {
|
||||
for (Metadata meta : this.metadataList) {
|
||||
if (index == meta.id()) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Metadata> metadataList() {
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MetaStorage{" + "metaDataList=" + metadataList + '}';
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RemovedValueException extends IOException {
|
||||
|
||||
/**
|
||||
* May be cached since it is never actually printed, only checked.
|
||||
*/
|
||||
public static final RemovedValueException EX = new RemovedValueException() {
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Rewriter to handle the addition of new enchantments.
|
||||
*/
|
||||
public class EnchantmentRewriter {
|
||||
|
||||
private final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||
private final ItemRewriter itemRewriter;
|
||||
private final boolean jsonFormat;
|
||||
|
||||
public EnchantmentRewriter(ItemRewriter itemRewriter, boolean jsonFormat) {
|
||||
this.itemRewriter = itemRewriter;
|
||||
this.jsonFormat = jsonFormat;
|
||||
}
|
||||
|
||||
public EnchantmentRewriter(ItemRewriter itemRewriter) {
|
||||
this(itemRewriter, true);
|
||||
}
|
||||
|
||||
public void registerEnchantment(String key, String replacementLore) {
|
||||
enchantmentMappings.put(key, replacementLore);
|
||||
}
|
||||
|
||||
public void handleToClient(Item item) {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
|
||||
if (tag.get("Enchantments") instanceof ListTag) {
|
||||
rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleToServer(Item item) {
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return;
|
||||
|
||||
if (tag.contains(itemRewriter.getNbtTagName() + "|Enchantments")) {
|
||||
rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(itemRewriter.getNbtTagName() + "|StoredEnchantments")) {
|
||||
rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||
ListTag enchantments = tag.get(key);
|
||||
List<Tag> loreToAdd = new ArrayList<>();
|
||||
boolean changed = false;
|
||||
|
||||
Iterator<Tag> iterator = enchantments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
||||
StringTag idTag = enchantmentEntry.get("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
String enchantmentId = idTag.getValue();
|
||||
String remappedName = enchantmentMappings.get(enchantmentId);
|
||||
if (remappedName != null) {
|
||||
if (!changed) {
|
||||
// Backup original before doing modifications
|
||||
itemRewriter.saveListTag(tag, enchantments, key);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
|
||||
int level = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
|
||||
String loreValue = remappedName + " " + getRomanNumber(level);
|
||||
if (jsonFormat) {
|
||||
loreValue = ChatRewriter.legacyTextToJsonString(loreValue);
|
||||
}
|
||||
|
||||
loreToAdd.add(new StringTag(loreValue));
|
||||
}
|
||||
}
|
||||
|
||||
if (!loreToAdd.isEmpty()) {
|
||||
// Add dummy enchant for the glow effect if there are no actual enchantments left
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new StringTag());
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
enchantments.add(dummyEnchantment);
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
} else {
|
||||
// Save original lore
|
||||
itemRewriter.saveListTag(display, loreTag, "Lore");
|
||||
}
|
||||
|
||||
loreToAdd.addAll(loreTag.getValue());
|
||||
loreTag.setValue(loreToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||
// Just restore the original tag ig present (lore is always restored in the item rewriter)
|
||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||
itemRewriter.restoreListTag(tag, key);
|
||||
}
|
||||
|
||||
public static String getRomanNumber(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return "I";
|
||||
case 2:
|
||||
return "II";
|
||||
case 3:
|
||||
return "III";
|
||||
case 4:
|
||||
return "IV";
|
||||
case 5:
|
||||
return "V";
|
||||
case 6:
|
||||
return "VI";
|
||||
case 7:
|
||||
return "VII";
|
||||
case 8:
|
||||
return "VIII";
|
||||
case 9:
|
||||
return "IX";
|
||||
case 10:
|
||||
return "X";
|
||||
default:
|
||||
return Integer.toString(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class EntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
|
||||
protected EntityRewriter(T protocol) {
|
||||
this(protocol, MetaType1_14.OptChat, MetaType1_14.Boolean);
|
||||
}
|
||||
|
||||
protected EntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
handler(getSpawnTrackerWithDataHandler(fallingBlockType));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PacketHandler getSpawnTrackerWithDataHandler(EntityType fallingBlockType) {
|
||||
return wrapper -> {
|
||||
// Check against the UNMAPPED entity type
|
||||
EntityType entityType = setOldEntityId(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
handler(wrapper -> setOldEntityId(wrapper));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private EntityType setOldEntityId(PacketWrapper wrapper) throws Exception {
|
||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = typeFromId(typeId);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
int mappedTypeId = newEntityId(entityType.getId());
|
||||
if (typeId != mappedTypeId) {
|
||||
wrapper.set(Type.VAR_INT, 1, mappedTypeId);
|
||||
}
|
||||
|
||||
return entityType;
|
||||
}
|
||||
}
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity rewriter base class.
|
||||
*
|
||||
* @see com.viaversion.viabackwards.api.rewriters.EntityRewriter
|
||||
* @see LegacyEntityRewriter
|
||||
*/
|
||||
public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends EntityRewriter<T> {
|
||||
private final Int2ObjectMap<EntityData> entityDataMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final MetaType displayNameMetaType;
|
||||
private final MetaType displayVisibilityMetaType;
|
||||
private final int displayNameIndex;
|
||||
private final int displayVisibilityIndex;
|
||||
|
||||
EntityRewriterBase(T protocol, MetaType displayNameMetaType, int displayNameIndex,
|
||||
MetaType displayVisibilityMetaType, int displayVisibilityIndex) {
|
||||
super(protocol, false);
|
||||
this.displayNameMetaType = displayNameMetaType;
|
||||
this.displayNameIndex = displayNameIndex;
|
||||
this.displayVisibilityMetaType = displayVisibilityMetaType;
|
||||
this.displayVisibilityIndex = displayVisibilityIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMetadata(int entityId, List<Metadata> metadataList, UserConnection connection) {
|
||||
super.handleMetadata(entityId, metadataList, connection);
|
||||
|
||||
EntityType type = tracker(connection).entityType(entityId);
|
||||
if (type == null) return;
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
|
||||
// Set the mapped entity name if there is no custom name set already
|
||||
Metadata meta = getMeta(displayNameIndex, metadataList);
|
||||
if (meta != null && entityData != null && entityData.mobName() != null
|
||||
&& (meta.getValue() == null || meta.getValue().toString().isEmpty())
|
||||
&& meta.metaType().typeId() == displayNameMetaType.typeId()) {
|
||||
meta.setValue(entityData.mobName());
|
||||
if (ViaBackwards.getConfig().alwaysShowOriginalMobName()) {
|
||||
removeMeta(displayVisibilityIndex, metadataList);
|
||||
metadataList.add(new Metadata(displayVisibilityIndex, displayVisibilityMetaType, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Add any other extra meta for mapped entities
|
||||
if (entityData != null) {
|
||||
//TODO only do this once for a first meta packet?
|
||||
if (entityData != null && entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected @Nullable Metadata getMeta(int metaIndex, List<Metadata> metadataList) {
|
||||
for (Metadata metadata : metadataList) {
|
||||
if (metadata.id() == metaIndex) {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void removeMeta(int metaIndex, List<Metadata> metadataList) {
|
||||
metadataList.removeIf(meta -> meta.id() == metaIndex);
|
||||
}
|
||||
|
||||
protected boolean hasData(EntityType type) {
|
||||
return entityDataMappings.containsKey(type.getId());
|
||||
}
|
||||
|
||||
protected @Nullable EntityData entityDataForType(EntityType type) {
|
||||
return entityDataMappings.get(type.getId());
|
||||
}
|
||||
|
||||
protected @Nullable StoredEntityData storedEntityData(MetaHandlerEvent event) {
|
||||
return tracker(event.user()).entityData(event.entityId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an entity type to another with extra data.
|
||||
* Note that both types should be of the same version.
|
||||
*
|
||||
* @param type entity type
|
||||
* @param mappedType mapped entity type
|
||||
* @return created entity data
|
||||
* @see #mapEntityType(EntityType, EntityType) for id only rewriting
|
||||
*/
|
||||
protected EntityData mapEntityTypeWithData(EntityType type, EntityType mappedType) {
|
||||
Preconditions.checkArgument(type.getClass() == mappedType.getClass());
|
||||
|
||||
// Already rewrite the id here
|
||||
int mappedReplacementId = newEntityId(mappedType.getId());
|
||||
EntityData data = new EntityData(type.getId(), mappedReplacementId);
|
||||
mapEntityType(type.getId(), mappedReplacementId);
|
||||
entityDataMappings.put(type.getId(), data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps entity ids based on the enum constant's names.
|
||||
*
|
||||
* @param oldTypes entity types of the higher version
|
||||
* @param newTypeClass entity types enum class of the lower version
|
||||
* @param <E> new enum type
|
||||
*/
|
||||
@Override
|
||||
public <E extends Enum<E> & EntityType> void mapTypes(EntityType[] oldTypes, Class<E> newTypeClass) {
|
||||
if (typeMappings == null) {
|
||||
typeMappings = new Int2IntOpenHashMap(oldTypes.length, 1F);
|
||||
typeMappings.defaultReturnValue(-1);
|
||||
}
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
E newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
typeMappings.put(oldType.getId(), newType.getId());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// Don't warn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockType, @Nullable MetaType particleType, @Nullable MetaType optChatType) {
|
||||
filter().handler((event, meta) -> {
|
||||
MetaType type = meta.metaType();
|
||||
if (itemType != null && type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||
} else if (blockType != null && type == blockType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (particleType != null && type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
} else if (optChatType != null && type == optChatType) {
|
||||
JsonElement text = meta.value();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ONLY TRACKS, DOESN'T REWRITE IDS
|
||||
protected PacketHandler getTrackerHandler(Type intType, int typeIndex) {
|
||||
return wrapper -> {
|
||||
Number id = (Number) wrapper.get(intType, typeIndex);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), typeFromId(id.intValue()));
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerHandler() {
|
||||
return getTrackerHandler(Type.VAR_INT, 1);
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerHandler(EntityType entityType, Type intType) {
|
||||
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
|
||||
}
|
||||
|
||||
protected PacketHandler getDimensionHandler(int index) {
|
||||
return wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, index);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||
|
||||
private final TranslatableRewriter translatableRewriter;
|
||||
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag display = item.tag() != null ? item.tag().get("display") : null;
|
||||
if (translatableRewriter != null && display != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
String newValue = translatableRewriter.processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveStringTag(display, name, "Name");
|
||||
}
|
||||
|
||||
name.setValue(newValue);
|
||||
}
|
||||
|
||||
ListTag lore = display.get("Lore");
|
||||
if (lore != null) {
|
||||
boolean changed = false;
|
||||
for (Tag loreEntryTag : lore) {
|
||||
if (!(loreEntryTag instanceof StringTag)) continue;
|
||||
|
||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
||||
String newValue = translatableRewriter.processText(loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
// Backup original lore before doing any modifications
|
||||
changed = true;
|
||||
saveListTag(display, lore, "Lore");
|
||||
}
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MappedItem data = protocol.getMappingData().getMappedItem(item.identifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
if (item.tag() == null) {
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
|
||||
// Save original id, set remapped id
|
||||
item.tag().put(nbtTagName + "|id", new IntTag(item.identifier()));
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
}
|
||||
if (!display.contains("Name")) {
|
||||
display.put("Name", new StringTag(data.getJsonName()));
|
||||
display.put(nbtTagName + "|customName", new ByteTag());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
super.handleItemToServer(item);
|
||||
if (item.tag() != null) {
|
||||
IntTag originalId = item.tag().remove(nbtTagName + "|id");
|
||||
if (originalId != null) {
|
||||
item.setIdentifier(originalId.asInt());
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends ItemRewriter<T> {
|
||||
|
||||
protected final String nbtTagName;
|
||||
protected final boolean jsonNameFormat;
|
||||
|
||||
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
|
||||
super(protocol);
|
||||
this.jsonNameFormat = jsonNameFormat;
|
||||
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public @Nullable Item handleItemToServer(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected boolean hasBackupTag(CompoundTag displayTag, String tagName) {
|
||||
return displayTag.contains(nbtTagName + "|o" + tagName);
|
||||
}
|
||||
|
||||
protected void saveStringTag(CompoundTag displayTag, StringTag original, String name) {
|
||||
// Multiple places might try to backup data
|
||||
String backupName = nbtTagName + "|o" + name;
|
||||
if (!displayTag.contains(backupName)) {
|
||||
displayTag.put(backupName, new StringTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveListTag(CompoundTag displayTag, ListTag original, String name) {
|
||||
// Multiple places might try to backup data
|
||||
String backupName = nbtTagName + "|o" + name;
|
||||
if (!displayTag.contains(backupName)) {
|
||||
// Clone all tag entries
|
||||
ListTag listTag = new ListTag();
|
||||
for (Tag tag : original.getValue()) {
|
||||
listTag.add(tag.clone());
|
||||
}
|
||||
|
||||
displayTag.put(backupName, listTag);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(Item item) {
|
||||
if (item.tag() == null) return;
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
if (display != null) {
|
||||
// Remove custom name / restore original name
|
||||
if (display.remove(nbtTagName + "|customName") != null) {
|
||||
display.remove("Name");
|
||||
} else {
|
||||
restoreStringTag(display, "Name");
|
||||
}
|
||||
|
||||
// Restore lore
|
||||
restoreListTag(display, "Lore");
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreStringTag(CompoundTag tag, String tagName) {
|
||||
StringTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new StringTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreListTag(CompoundTag tag, String tagName) {
|
||||
ListTag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
tag.put(tagName, new ListTag(original.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getNbtTagName() {
|
||||
return nbtTagName;
|
||||
}
|
||||
}
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||
|
||||
private static final Map<String, Int2ObjectMap<MappedLegacyBlockItem>> LEGACY_MAPPINGS = new HashMap<>();
|
||||
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData;
|
||||
|
||||
static {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("legacy-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
||||
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
||||
for (Map.Entry<String, JsonElement> dataEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
JsonObject object = dataEntry.getValue().getAsJsonObject();
|
||||
int id = object.getAsJsonPrimitive("id").getAsInt();
|
||||
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
|
||||
short data = jsonData != null ? jsonData.getAsShort() : 0;
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
JsonPrimitive blockField = object.getAsJsonPrimitive("block");
|
||||
boolean block = blockField != null && blockField.getAsBoolean();
|
||||
|
||||
if (dataEntry.getKey().indexOf('-') != -1) {
|
||||
// Range of ids
|
||||
String[] split = dataEntry.getKey().split("-", 2);
|
||||
int from = Integer.parseInt(split[0]);
|
||||
int to = Integer.parseInt(split[1]);
|
||||
|
||||
// Special block color handling
|
||||
if (name.contains("%color%")) {
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i, new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), block));
|
||||
}
|
||||
} else {
|
||||
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, block);
|
||||
for (int i = from; i <= to; i++) {
|
||||
mappings.put(i, mappedBlockItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mappings.put(Integer.parseInt(dataEntry.getKey()), new MappedLegacyBlockItem(id, data, name, block));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol) {
|
||||
super(protocol, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
MappedLegacyBlockItem data = replacementData.get(item.identifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
short originalData = item.data();
|
||||
item.setIdentifier(data.getId());
|
||||
// Keep original data if mapped data is set to -1
|
||||
if (data.getData() != -1) {
|
||||
item.setData(data.getData());
|
||||
}
|
||||
|
||||
// Set display name
|
||||
if (data.getName() != null) {
|
||||
if (item.tag() == null) {
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
|
||||
CompoundTag display = item.tag().get("display");
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
}
|
||||
|
||||
StringTag nameTag = display.get("Name");
|
||||
if (nameTag == null) {
|
||||
display.put("Name", nameTag = new StringTag(data.getName()));
|
||||
display.put(nbtTagName + "|customName", new ByteTag());
|
||||
}
|
||||
|
||||
// Handle colors
|
||||
String value = nameTag.getValue();
|
||||
if (value.contains("%vb_color%")) {
|
||||
display.put("Name", new StringTag(value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public int handleBlockID(int idx) {
|
||||
int type = idx >> 4;
|
||||
int meta = idx & 15;
|
||||
|
||||
Block b = handleBlock(type, meta);
|
||||
if (b == null) return idx;
|
||||
|
||||
return (b.getId() << 4 | (b.getData() & 15));
|
||||
}
|
||||
|
||||
public @Nullable Block handleBlock(int blockId, int data) {
|
||||
MappedLegacyBlockItem settings = replacementData.get(blockId);
|
||||
if (settings == null || !settings.isBlock()) return null;
|
||||
|
||||
Block block = settings.getBlock();
|
||||
// For some blocks, the data can still be useful (:
|
||||
if (block.getData() == -1) {
|
||||
return block.withData(data);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
protected void handleChunk(Chunk chunk) {
|
||||
// Map Block Entities
|
||||
Map<Pos, CompoundTag> tags = new HashMap<>();
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag xTag;
|
||||
Tag yTag;
|
||||
Tag zTag;
|
||||
if ((xTag = tag.get("x")) == null || (yTag = tag.get("y")) == null || (zTag = tag.get("z")) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Pos pos = new Pos(
|
||||
((NumberTag) xTag).asInt() & 0xF,
|
||||
((NumberTag) yTag).asInt(),
|
||||
((NumberTag) zTag).asInt() & 0xF);
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
if (pos.getY() < 0 || pos.getY() > 255) continue; // 1.17
|
||||
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
if (section == null) continue;
|
||||
|
||||
int block = section.getFlatBlock(pos.getX(), pos.getY() & 0xF, pos.getZ());
|
||||
int btype = block >> 4;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue;
|
||||
|
||||
boolean hasBlockEntityHandler = false;
|
||||
|
||||
// Map blocks
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int block = section.getPaletteEntry(j);
|
||||
int btype = block >> 4;
|
||||
int meta = block & 0xF;
|
||||
|
||||
Block b = handleBlock(btype, meta);
|
||||
if (b != null) {
|
||||
section.setPaletteEntry(j, (b.getId() << 4) | (b.getData() & 0xF));
|
||||
}
|
||||
|
||||
// We already know that is has a handler
|
||||
if (hasBlockEntityHandler) continue;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
if (settings != null && settings.hasBlockEntityHandler()) {
|
||||
hasBlockEntityHandler = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBlockEntityHandler) continue;
|
||||
|
||||
// We need to handle a Block Entity :(
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getFlatBlock(x, y, z);
|
||||
int btype = block >> 4;
|
||||
int meta = block & 15;
|
||||
|
||||
MappedLegacyBlockItem settings = replacementData.get(btype);
|
||||
if (settings == null || !settings.hasBlockEntityHandler()) continue;
|
||||
|
||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||
|
||||
// Already handled above
|
||||
if (tags.containsKey(pos)) continue;
|
||||
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("x", new IntTag(x + (chunk.getX() << 4)));
|
||||
tag.put("y", new IntTag(y + (i << 4)));
|
||||
tag.put("z", new IntTag(z + (chunk.getZ() << 4)));
|
||||
|
||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
chunk.getBlockEntities().add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected CompoundTag getNamedTag(String text) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("display", new CompoundTag());
|
||||
text = "§r" + text;
|
||||
((CompoundTag) tag.get("display")).put("Name", new StringTag(jsonNameFormat ? ChatRewriter.legacyTextToJsonString(text) : text));
|
||||
return tag;
|
||||
}
|
||||
|
||||
private static final class Pos {
|
||||
|
||||
private final int x;
|
||||
private final short y;
|
||||
private final int z;
|
||||
|
||||
private Pos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = (short) y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Pos pos = (Pos) o;
|
||||
if (x != pos.x) return false;
|
||||
if (y != pos.y) return false;
|
||||
return z == pos.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pos{" + "x=" + x + ", y=" + y + ", z=" + z + '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class LegacyEnchantmentRewriter {
|
||||
|
||||
private final Map<Short, String> enchantmentMappings = new HashMap<>();
|
||||
private final String nbtTagName;
|
||||
private Set<Short> hideLevelForEnchants;
|
||||
|
||||
public LegacyEnchantmentRewriter(String nbtTagName) {
|
||||
this.nbtTagName = nbtTagName;
|
||||
}
|
||||
|
||||
public void registerEnchantment(int id, String replacementLore) {
|
||||
enchantmentMappings.put((short) id, replacementLore);
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag enchantments = tag.get(key);
|
||||
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||
Tag idTag = ((CompoundTag) enchantmentEntry).get("id");
|
||||
if (idTag == null) continue;
|
||||
|
||||
short newId = ((NumberTag) idTag).asShort();
|
||||
String enchantmentName = enchantmentMappings.get(newId);
|
||||
if (enchantmentName != null) {
|
||||
enchantments.remove(enchantmentEntry);
|
||||
short level = ((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort();
|
||||
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
||||
lore.add(new StringTag(enchantmentName));
|
||||
} else {
|
||||
lore.add(new StringTag(enchantmentName + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
}
|
||||
remappedEnchantments.add(enchantmentEntry);
|
||||
}
|
||||
}
|
||||
if (!lore.isEmpty()) {
|
||||
if (!storedEnchant && enchantments.size() == 0) {
|
||||
CompoundTag dummyEnchantment = new CompoundTag();
|
||||
dummyEnchantment.put("id", new ShortTag((short) 0));
|
||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
||||
enchantments.add(dummyEnchantment);
|
||||
|
||||
tag.put(nbtTagName + "|dummyEnchant", new ByteTag());
|
||||
|
||||
IntTag hideFlags = tag.get("HideFlags");
|
||||
if (hideFlags == null) {
|
||||
hideFlags = new IntTag();
|
||||
} else {
|
||||
tag.put(nbtTagName + "|oldHideFlags", new IntTag(hideFlags.asByte()));
|
||||
}
|
||||
|
||||
int flags = hideFlags.asByte() | 1;
|
||||
hideFlags.setValue(flags);
|
||||
tag.put("HideFlags", hideFlags);
|
||||
}
|
||||
|
||||
tag.put(nbtTagName + "|" + key, remappedEnchantments);
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
if (display == null) {
|
||||
tag.put("display", display = new CompoundTag());
|
||||
}
|
||||
ListTag loreTag = display.get("Lore");
|
||||
if (loreTag == null) {
|
||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||
}
|
||||
|
||||
lore.addAll(loreTag.getValue());
|
||||
loreTag.setValue(lore);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
||||
ListTag enchantments = tag.get(key);
|
||||
if (enchantments == null) {
|
||||
enchantments = new ListTag(CompoundTag.class);
|
||||
}
|
||||
|
||||
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
||||
for (Tag enchantment : enchantments.clone()) {
|
||||
short id = ((NumberTag) ((CompoundTag) enchantment).get("id")).asShort();
|
||||
short level = ((NumberTag) ((CompoundTag) enchantment).get("lvl")).asShort();
|
||||
if (id == 0 && level == 0) {
|
||||
enchantments.remove(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
IntTag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||
if (hideFlags != null) {
|
||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
||||
} else {
|
||||
tag.remove("HideFlags");
|
||||
}
|
||||
}
|
||||
|
||||
CompoundTag display = tag.get("display");
|
||||
// A few null checks just to be safe, though they shouldn't actually be
|
||||
ListTag lore = display != null ? display.get("Lore") : null;
|
||||
for (Tag enchantment : remappedEnchantments.clone()) {
|
||||
enchantments.add(enchantment);
|
||||
if (lore != null && lore.size() != 0) {
|
||||
lore.remove(lore.get(0));
|
||||
}
|
||||
}
|
||||
if (lore != null && lore.size() == 0) {
|
||||
display.remove("Lore");
|
||||
if (display.isEmpty()) {
|
||||
tag.remove("display");
|
||||
}
|
||||
}
|
||||
|
||||
tag.put(key, enchantments);
|
||||
}
|
||||
|
||||
public void setHideLevelForEnchants(int... enchants) {
|
||||
this.hideLevelForEnchants = new HashSet<>();
|
||||
for (int enchant : enchants) {
|
||||
hideLevelForEnchants.add((short) enchant);
|
||||
}
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
private final Map<ObjectType, EntityData> objectTypes = new HashMap<>();
|
||||
|
||||
protected LegacyEntityRewriter(T protocol) {
|
||||
this(protocol, MetaType1_9.String, MetaType1_9.Boolean);
|
||||
}
|
||||
|
||||
protected LegacyEntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
protected EntityObjectData mapObjectType(ObjectType oldObjectType, ObjectType replacement, int data) {
|
||||
EntityObjectData entData = new EntityObjectData(oldObjectType.getId(), true, replacement.getId(), data);
|
||||
objectTypes.put(oldObjectType, entData);
|
||||
return entData;
|
||||
}
|
||||
|
||||
protected @Nullable EntityData getObjectData(ObjectType type) {
|
||||
return objectTypes.get(type);
|
||||
}
|
||||
|
||||
protected void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
if (oldMetaType != null) {
|
||||
map(oldMetaType, newMetaType);
|
||||
} else {
|
||||
map(newMetaType);
|
||||
}
|
||||
handler(wrapper -> {
|
||||
List<Metadata> metadata = wrapper.get(newMetaType, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), metadata, wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(packetType, null, metaType);
|
||||
}
|
||||
|
||||
protected PacketHandler getMobSpawnRewriter(Type<List<Metadata>> metaType) {
|
||||
return wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<Metadata> metadata = wrapper.get(metaType, 0);
|
||||
handleMetadata(entityId, metadata, wrapper.user());
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
if (entityData != null) {
|
||||
wrapper.set(Type.VAR_INT, 1, entityData.replacementId());
|
||||
if (entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadata));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectTrackerHandler() {
|
||||
return wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0)));
|
||||
}
|
||||
|
||||
protected PacketHandler getTrackerAndMetaHandler(Type<List<Metadata>> metaType, EntityType entityType) {
|
||||
return wrapper -> {
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
List<Metadata> metadata = wrapper.get(metaType, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), metadata, wrapper.user());
|
||||
};
|
||||
}
|
||||
|
||||
protected PacketHandler getObjectRewriter(Function<Byte, ObjectType> objectGetter) {
|
||||
return wrapper -> {
|
||||
ObjectType type = objectGetter.apply(wrapper.get(Type.BYTE, 0));
|
||||
if (type == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Type.BYTE, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
EntityData data = getObjectData(type);
|
||||
if (data != null) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) data.replacementId());
|
||||
if (data.objectData() != -1) {
|
||||
wrapper.set(Type.INT, 0, data.objectData());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected EntityType getObjectTypeFromId(int typeId) {
|
||||
return typeFromId(typeId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
|
||||
tracker(wrapper.user()).addEntity(entityId, type);
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@Deprecated
|
||||
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends RewriterBase<T> {
|
||||
protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64);
|
||||
|
||||
protected LegacySoundRewriter(T protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
public SoundData added(int id, int replacement) {
|
||||
return added(id, replacement, -1);
|
||||
}
|
||||
|
||||
public SoundData added(int id, int replacement, float newPitch) {
|
||||
SoundData data = new SoundData(replacement, true, newPitch, true);
|
||||
soundRewrites.put(id, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public SoundData removed(int id) {
|
||||
SoundData data = new SoundData(-1, false, -1, false);
|
||||
soundRewrites.put(id, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int handleSounds(int soundId) {
|
||||
int newSoundId = soundId;
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
if (data != null) return data.getReplacementSound();
|
||||
|
||||
for (Int2ObjectMap.Entry<SoundData> entry : soundRewrites.int2ObjectEntrySet()) {
|
||||
if (soundId > entry.getIntKey()) {
|
||||
if (entry.getValue().isAdded()) {
|
||||
newSoundId--;
|
||||
} else {
|
||||
newSoundId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return newSoundId;
|
||||
}
|
||||
|
||||
public boolean hasPitch(int soundId) {
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
return data != null && data.isChangePitch();
|
||||
}
|
||||
|
||||
public float handlePitch(int soundId) {
|
||||
SoundData data = soundRewrites.get(soundId);
|
||||
return data != null ? data.getNewPitch() : 1F;
|
||||
}
|
||||
|
||||
public static final class SoundData {
|
||||
private final int replacementSound;
|
||||
private final boolean changePitch;
|
||||
private final float newPitch;
|
||||
private final boolean added;
|
||||
|
||||
public SoundData(int replacementSound, boolean changePitch, float newPitch, boolean added) {
|
||||
this.replacementSound = replacementSound;
|
||||
this.changePitch = changePitch;
|
||||
this.newPitch = newPitch;
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public int getReplacementSound() {
|
||||
return replacementSound;
|
||||
}
|
||||
|
||||
public boolean isChangePitch() {
|
||||
return changePitch;
|
||||
}
|
||||
|
||||
public float getNewPitch() {
|
||||
return newPitch;
|
||||
}
|
||||
|
||||
public boolean isAdded() {
|
||||
return added;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
|
||||
|
||||
public final class MapColorRewriter {
|
||||
|
||||
/**
|
||||
* Returns a packethandler to rewrite map data color ids. Reading starts from the icon count.
|
||||
*
|
||||
* @param rewriter id rewriter returning mapped colors, or -1 if unmapped
|
||||
* @return packethandler to rewrite map data color ids
|
||||
*/
|
||||
public static PacketHandler getRewriteHandler(IdRewriteFunction rewriter) {
|
||||
return wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Type
|
||||
wrapper.passthrough(Type.BYTE); // X
|
||||
wrapper.passthrough(Type.BYTE); // Z
|
||||
wrapper.passthrough(Type.BYTE); // Direction
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Display Name
|
||||
}
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns < 1) return;
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int color = data[i] & 0xFF;
|
||||
int mappedColor = rewriter.rewrite(color);
|
||||
if (mappedColor != -1) {
|
||||
data[i] = (byte) mappedColor;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewriter {
|
||||
|
||||
private final BackwardsProtocol protocol;
|
||||
|
||||
public SoundRewriter(BackwardsProtocol protocol) {
|
||||
super(protocol);
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void registerNamedSound(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Sound identifier
|
||||
handler(getNamedSoundHandler());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerStopSound(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(getStopSoundHandler());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PacketHandler getNamedSoundHandler() {
|
||||
return wrapper -> {
|
||||
String soundId = wrapper.get(Type.STRING, 0);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) return;
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Type.STRING, 0, mappedId);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getStopSoundHandler() {
|
||||
return wrapper -> {
|
||||
byte flags = wrapper.passthrough(Type.BYTE);
|
||||
if ((flags & 0x02) == 0) return; // No sound specified
|
||||
|
||||
if ((flags & 0x01) != 0) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Source
|
||||
}
|
||||
|
||||
String soundId = wrapper.read(Type.STRING);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) {
|
||||
// No mapping found
|
||||
wrapper.write(Type.STRING, soundId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.write(Type.STRING, mappedId);
|
||||
} else {
|
||||
// Cancel if set to empty
|
||||
wrapper.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TranslatableRewriter extends ComponentRewriter {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
protected final Map<String, String> newTranslatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadData("translation-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Map<String, String> versionMappings = new HashMap<>();
|
||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||
for (Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol) {
|
||||
this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) {
|
||||
super(protocol);
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
} else {
|
||||
this.newTranslatables = newTranslatables;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerDisconnect(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChatMessage(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerOpenWindow(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTabList(ClientboundPacketType packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class PotionSplashHandler {
|
||||
|
||||
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 1F);
|
||||
|
||||
static {
|
||||
DATA.defaultReturnValue(-1);
|
||||
DATA.put(2039713, 5); // night vision
|
||||
DATA.put(8356754, 7); // invisibility
|
||||
DATA.put(2293580, 9); // jump boost
|
||||
DATA.put(14981690, 12); // fire resistance
|
||||
DATA.put(8171462, 14); // swiftness
|
||||
DATA.put(5926017, 17); // slowness
|
||||
DATA.put(3035801, 19); // water breathing
|
||||
DATA.put(16262179, 21); // instant health
|
||||
DATA.put(4393481, 23); // instant damage
|
||||
DATA.put(5149489, 25); // poison
|
||||
DATA.put(13458603, 28); // regeneration
|
||||
DATA.put(9643043, 31); // strength
|
||||
DATA.put(4738376, 34); // weakness
|
||||
DATA.put(3381504, 36); // luck
|
||||
}
|
||||
|
||||
public static int getOldData(int data) {
|
||||
return DATA.get(data);
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.11", "1.10", null, true);
|
||||
private final EntityPackets1_11 entityPackets = new EntityPackets1_11(this); // Required for the item rewriter
|
||||
private BlockItemPackets1_11 blockItemPackets;
|
||||
|
||||
public Protocol1_10To1_11() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
(blockItemPackets = new BlockItemPackets1_11(this)).register();
|
||||
entityPackets.register();
|
||||
new PlayerPackets1_11().register(this);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.NAMED_SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER, true));
|
||||
|
||||
if (!user.has(WindowTracker.class)) {
|
||||
user.put(new WindowTracker());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_11 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_11 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To1_11> {
|
||||
|
||||
private LegacyEnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public BlockItemPackets1_11(Protocol1_10To1_11 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
|
||||
handler(itemToClientHandler(Type.ITEM));
|
||||
|
||||
// Handle Llama
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int currentSlot = wrapper.get(Type.SHORT, 0);
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
|
||||
wrapper.set(Type.ITEM, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM, 0)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.ITEM_ARRAY); // 1 - Window Values
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
for (int i = 0; i < stacks.length; i++)
|
||||
stacks[i] = handleItemToClient(stacks[i]);
|
||||
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
stacks = Arrays.copyOf(stacks, !storage.isChested() ? 38 : 53);
|
||||
|
||||
for (int i = stacks.length - 1; i >= 0; i--) {
|
||||
stacks[getNewSlotId(storage, i)] = stacks[i];
|
||||
stacks[i] = getNewItem(storage, i, stacks[i]);
|
||||
}
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, stacks);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(itemToServerHandler(Type.ITEM));
|
||||
|
||||
// Llama slot
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
return;
|
||||
ChestedHorseStorage storage = horse.get();
|
||||
int clickSlot = wrapper.get(Type.SHORT, 0);
|
||||
int correctSlot = getOldSlotId(storage, clickSlot);
|
||||
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) correctSlot).shortValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
||||
// only patch it for signs for now
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
Tag idTag = tag.get("id");
|
||||
if (!(idTag instanceof StringTag)) continue;
|
||||
|
||||
String id = (String) idTag.getValue();
|
||||
if (id.equals("minecraft:sign")) {
|
||||
((StringTag) idTag).setValue("Sign");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Remove on shulkerbox decleration
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 10) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
// Handler Spawners
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) {
|
||||
CompoundTag tag = wrapper.get(Type.NBT, 0);
|
||||
EntityIdRewriter.toClientSpawner(tag, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.STRING); // 1 - Window Type
|
||||
map(Type.COMPONENT); // 2 - Title
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Slots
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = -1;
|
||||
// Passthrough Entity ID
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse")) {
|
||||
entityId = wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
// Track Inventory
|
||||
String inventory = wrapper.get(Type.STRING, 0);
|
||||
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
|
||||
windowTracker.setInventory(inventory);
|
||||
windowTracker.setEntityId(entityId);
|
||||
|
||||
// Change llama slotcount to the donkey one
|
||||
if (isLlama(wrapper.user())) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
|
||||
windowTracker.setInventory(null);
|
||||
windowTracker.setEntityId(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Inventory tracking
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
|
||||
windowTracker.setInventory(null);
|
||||
windowTracker.setEntityId(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle spawner block entity (map to itself with custom handler)
|
||||
MappedLegacyBlockItem data = replacementData.computeIfAbsent(52, s -> new MappedLegacyBlockItem(52, (short) -1, null, false));
|
||||
data.setBlockEntityHandler((b, tag) -> {
|
||||
EntityIdRewriter.toClientSpawner(tag, true);
|
||||
return tag;
|
||||
});
|
||||
|
||||
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName);
|
||||
enchantmentRewriter.registerEnchantment(71, "§cCurse of Vanishing");
|
||||
enchantmentRewriter.registerEnchantment(10, "§cCurse of Binding");
|
||||
|
||||
enchantmentRewriter.setHideLevelForEnchants(71, 10); // Curses do not display their level
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
EntityIdRewriter.toClientItem(item, true);
|
||||
|
||||
if (tag.get("ench") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||
EntityIdRewriter.toServerItem(item, true);
|
||||
|
||||
if (tag.contains(nbtTagName + "|ench")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private boolean isLlama(UserConnection user) {
|
||||
WindowTracker tracker = user.get(WindowTracker.class);
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
return entityData != null && entityData.type().is(Entity1_11Types.EntityType.LIAMA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Optional<ChestedHorseStorage> getChestedHorse(UserConnection user) {
|
||||
WindowTracker tracker = user.get(WindowTracker.class);
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
if (entityData != null)
|
||||
return Optional.of(entityData.get(ChestedHorseStorage.class));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private int getNewSlotId(ChestedHorseStorage storage, int slotId) {
|
||||
int totalSlots = !storage.isChested() ? 38 : 53;
|
||||
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
|
||||
int startNonExistingFormula = 2 + 3 * strength;
|
||||
int offsetForm = 15 - (3 * strength);
|
||||
|
||||
if (slotId >= startNonExistingFormula && totalSlots > (slotId + offsetForm))
|
||||
return offsetForm + slotId;
|
||||
if (slotId == 1)
|
||||
return 0;
|
||||
return slotId;
|
||||
}
|
||||
|
||||
private int getOldSlotId(ChestedHorseStorage storage, int slotId) {
|
||||
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
|
||||
int startNonExistingFormula = 2 + 3 * strength;
|
||||
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
|
||||
int offsetForm = endNonExistingFormula - startNonExistingFormula;
|
||||
|
||||
if (slotId == 1 || slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
|
||||
return 0;
|
||||
if (slotId >= endNonExistingFormula)
|
||||
return slotId - offsetForm;
|
||||
if (slotId == 0)
|
||||
return 1;
|
||||
return slotId;
|
||||
}
|
||||
|
||||
private Item getNewItem(ChestedHorseStorage storage, int slotId, Item current) {
|
||||
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
|
||||
int startNonExistingFormula = 2 + 3 * strength;
|
||||
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
|
||||
|
||||
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
|
||||
return new DataItem(166, (byte) 1, (short) 0, getNamedTag("§4SLOT DISABLED"));
|
||||
if (slotId == 1)
|
||||
return null;
|
||||
return current;
|
||||
}
|
||||
}
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.PotionSplashHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11> {
|
||||
|
||||
public EntityPackets1_11(Protocol1_10To1_11 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.POSITION);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.INT, 0);
|
||||
if (type == 2002 || type == 2007) {
|
||||
// 2007 potion id doesn't exist in 1.10
|
||||
if (type == 2007) {
|
||||
wrapper.set(Type.INT, 0, 2002);
|
||||
}
|
||||
|
||||
int mappedData = PotionSplashHandler.getOldData(wrapper.get(Type.INT, 1));
|
||||
if (mappedData != -1) {
|
||||
wrapper.set(Type.INT, 1, mappedData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - x
|
||||
map(Type.DOUBLE); // 4 - y
|
||||
map(Type.DOUBLE); // 5 - z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - data
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = protocol.getItemRewriter().handleBlock(objType, data);
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler(Type.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
List<Metadata> list = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), list, wrapper.user());
|
||||
|
||||
EntityData entityData = entityDataForType(type);
|
||||
if (entityData != null) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) entityData.replacementId());
|
||||
if (entityData.hasBaseMeta()) {
|
||||
entityData.defaultMeta().createMeta(new WrappedMetadata(list));
|
||||
}
|
||||
}
|
||||
|
||||
// Sub 1.11 clients will error if the list is empty
|
||||
if (list.isEmpty()) {
|
||||
list.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_9.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
|
||||
handler(wrapper -> {
|
||||
// Sub 1.11 clients will cry if the list is empty
|
||||
List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
if (metadata.isEmpty()) {
|
||||
metadata.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.BYTE); // 1 - Entity Status
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte b = wrapper.get(Type.BYTE, 0);
|
||||
|
||||
if (b == 35) {
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(0x1E); // Change Game State
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 10); // Play Elder Guardian animation
|
||||
wrapper.write(Type.FLOAT, 0F);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Guardian
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN);
|
||||
// Skeletons
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).mobName("Wither Skeleton").spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).mobName("Stray").spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||
// Zombies
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).mobName("Husk").spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
||||
// Horses
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
// New mobs
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Evoker");
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).mobName("Vex");
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Vindicator").spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).mobName("Llama").spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1);
|
||||
// Replace with endertorchthingies
|
||||
mapObjectType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
|
||||
// Handle ElderGuardian & target metadata
|
||||
filter().filterFamily(Entity1_11Types.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
boolean b = (boolean) meta.getValue();
|
||||
int bitmask = b ? 0x02 : 0;
|
||||
|
||||
if (event.entityType() == Entity1_11Types.EntityType.ELDER_GUARDIAN) {
|
||||
bitmask |= 0x04;
|
||||
}
|
||||
|
||||
meta.setTypeAndValue(MetaType1_9.Byte, (byte) bitmask);
|
||||
});
|
||||
|
||||
// Handle skeleton swing
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
|
||||
|
||||
/*
|
||||
ZOMBIE CHANGES
|
||||
*/
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ZOMBIE).handler((event, meta) -> {
|
||||
switch (meta.id()) {
|
||||
case 13:
|
||||
event.cancel();
|
||||
return;
|
||||
case 14:
|
||||
event.setIndex(15);
|
||||
break;
|
||||
case 15:
|
||||
event.setIndex(14);
|
||||
break;
|
||||
// Profession
|
||||
case 16:
|
||||
event.setIndex(13);
|
||||
meta.setValue(1 + (int) meta.getValue());
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Evocation Illager
|
||||
filter().type(Entity1_11Types.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
|
||||
});
|
||||
|
||||
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
||||
filter().type(Entity1_11Types.EntityType.VEX).index(12).handler((event, meta) -> {
|
||||
meta.setValue((byte) 0x00);
|
||||
});
|
||||
|
||||
// Handle VindicationIllager
|
||||
filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
|
||||
});
|
||||
|
||||
/*
|
||||
HORSES
|
||||
*/
|
||||
|
||||
// Handle horse flags
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
byte b = (byte) meta.getValue();
|
||||
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
|
||||
b |= 0x08; // Chested
|
||||
meta.setValue(b);
|
||||
}
|
||||
});
|
||||
|
||||
// Create chested horse storage
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ChestedHorseStorage.class)) {
|
||||
data.put(new ChestedHorseStorage());
|
||||
}
|
||||
});
|
||||
|
||||
// Handle horse armor
|
||||
filter().type(Entity1_11Types.EntityType.HORSE).index(16).toIndex(17);
|
||||
|
||||
// Handle chested horse
|
||||
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
boolean b = (boolean) meta.getValue();
|
||||
storage.setChested(b);
|
||||
event.cancel();
|
||||
});
|
||||
|
||||
// Get rid of Liama metadata
|
||||
filter().type(Entity1_11Types.EntityType.LIAMA).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
|
||||
int index = event.index();
|
||||
// Store them for later (:
|
||||
switch (index) {
|
||||
case 16:
|
||||
storage.setLiamaStrength((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 17:
|
||||
storage.setLiamaCarpetColor((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
case 18:
|
||||
storage.setLiamaVariant((int) meta.getValue());
|
||||
event.cancel();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Horse (Correct owner)
|
||||
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
|
||||
|
||||
// Handle villager - Change non-existing profession
|
||||
filter().type(Entity1_11Types.EntityType.VILLAGER).index(13).handler((event, meta) -> {
|
||||
if ((int) meta.getValue() == 5) {
|
||||
meta.setValue(0);
|
||||
}
|
||||
});
|
||||
|
||||
// handle new Shulker color meta
|
||||
filter().type(Entity1_11Types.EntityType.SHULKER).cancel(15);
|
||||
}
|
||||
|
||||
/*
|
||||
0 - Skeleton
|
||||
1 - Wither Skeleton
|
||||
2 - Stray
|
||||
*/
|
||||
|
||||
private Metadata getSkeletonTypeMeta(int type) {
|
||||
return new Metadata(12, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
/*
|
||||
0 - Zombie
|
||||
1-5 - Villager with profession
|
||||
6 - Husk
|
||||
*/
|
||||
private Metadata getZombieTypeMeta(int type) {
|
||||
return new Metadata(13, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
private void handleZombieType(WrappedMetadata storage, int type) {
|
||||
Metadata meta = storage.get(13);
|
||||
if (meta == null) {
|
||||
storage.add(getZombieTypeMeta(type));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Horse 0
|
||||
Donkey 1
|
||||
Mule 2
|
||||
Zombie horse 3
|
||||
Skeleton horse 4
|
||||
*/
|
||||
private Metadata getHorseMetaType(int type) {
|
||||
return new Metadata(14, MetaType1_9.VarInt, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@Override
|
||||
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
|
||||
return inputValue / 15f;
|
||||
}
|
||||
};
|
||||
|
||||
public void register(Protocol1_10To1_11 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
if (action == 2) { // Handle the new ActionBar
|
||||
JsonElement message = wrapper.read(Type.COMPONENT);
|
||||
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
|
||||
|
||||
// https://bugs.mojang.com/browse/MC-119145to
|
||||
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
|
||||
message = new JsonObject();
|
||||
message.getAsJsonObject().addProperty("text", legacy);
|
||||
|
||||
wrapper.write(Type.COMPONENT, message);
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
} else if (action > 2) {
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Collected entity id
|
||||
map(Type.VAR_INT); // 1 - Collector entity id
|
||||
|
||||
handler(wrapper -> wrapper.read(Type.VAR_INT)); // Ignore item pickup count
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11.storage;
|
||||
|
||||
public class ChestedHorseStorage {
|
||||
private boolean chested;
|
||||
private int liamaStrength;
|
||||
private int liamaCarpetColor = -1;
|
||||
private int liamaVariant;
|
||||
|
||||
public boolean isChested() {
|
||||
return chested;
|
||||
}
|
||||
|
||||
public void setChested(boolean chested) {
|
||||
this.chested = chested;
|
||||
}
|
||||
|
||||
public int getLiamaStrength() {
|
||||
return liamaStrength;
|
||||
}
|
||||
|
||||
public void setLiamaStrength(int liamaStrength) {
|
||||
this.liamaStrength = liamaStrength;
|
||||
}
|
||||
|
||||
public int getLiamaCarpetColor() {
|
||||
return liamaCarpetColor;
|
||||
}
|
||||
|
||||
public void setLiamaCarpetColor(int liamaCarpetColor) {
|
||||
this.liamaCarpetColor = liamaCarpetColor;
|
||||
}
|
||||
|
||||
public int getLiamaVariant() {
|
||||
return liamaVariant;
|
||||
}
|
||||
|
||||
public void setLiamaVariant(int liamaVariant) {
|
||||
this.liamaVariant = liamaVariant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChestedHorseStorage{" + "chested=" + chested + ", liamaStrength=" + liamaStrength + ", liamaCarpetColor=" + liamaCarpetColor + ", liamaVariant=" + liamaVariant + '}';
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_10to1_11.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WindowTracker implements StorableObject {
|
||||
private String inventory;
|
||||
private int entityId = -1;
|
||||
|
||||
public String getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(String inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WindowTracker{" + "inventory='" + inventory + '\'' + ", entityId=" + entityId + '}';
|
||||
}
|
||||
}
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.BlockItemPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
private final EntityPackets1_12 entityPackets = new EntityPackets1_12(this);
|
||||
private final BlockItemPackets1_12 blockItemPackets = new BlockItemPackets1_12(this);
|
||||
|
||||
public Protocol1_11_1To1_12() {
|
||||
super(ClientboundPackets1_12.class, ClientboundPackets1_9_3.class, ServerboundPackets1_12.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
blockItemPackets.register();
|
||||
entityPackets.register();
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
registerClientbound(ClientboundPackets1_12.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(component.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelClientbound(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_12Types.EntityType.PLAYER, true));
|
||||
|
||||
user.put(new ShoulderTracker(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_12 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_12 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdvancementTranslations {
|
||||
private static final Map<String, String> advancements = new HashMap<>();
|
||||
|
||||
static {
|
||||
add("advancements.nether.get_wither_skull.title", "Spooky Scary Skeleton");
|
||||
add("advancements.husbandry.break_diamond_hoe.description", "Completely use up a diamond hoe, and then reevaluate your life choices");
|
||||
add("advancements.nether.fast_travel.description", "Use the Nether to travel 7km in the Overworld");
|
||||
add("advancements.story.enter_the_end.description", "Enter the End Portal");
|
||||
add("advancements.story.follow_ender_eye.title", "Eye Spy");
|
||||
add("advancements.toast.task", "Advancement Made!");
|
||||
add("advancements.nether.find_fortress.description", "Break your way into a Nether Fortress");
|
||||
add("advancements.story.form_obsidian.description", "Form and mine a block of Obsidian");
|
||||
add("advancements.adventure.sniper_duel.description", "Kill a skeleton with an arrow from more than 50 meters");
|
||||
add("advancements.end.root.description", "Or the beginning?");
|
||||
add("advancements.adventure.kill_a_mob.title", "Monster Hunter");
|
||||
add("advancements.end.elytra.description", "Find an Elytra");
|
||||
add("advancements.end.dragon_breath.description", "Collect dragon's breath in a glass bottle");
|
||||
add("advancements.story.enter_the_nether.title", "We Need to Go Deeper");
|
||||
add("advancements.story.upgrade_tools.title", "Getting an Upgrade");
|
||||
add("advancements.story.lava_bucket.title", "Hot Stuff");
|
||||
add("advancements.story.shiny_gear.title", "Cover Me With Diamonds");
|
||||
add("advancements.story.smelt_iron.description", "Smelt an iron ingot");
|
||||
add("chat.type.advancement.goal", "%s has reached the goal %s");
|
||||
add("advancements.husbandry.break_diamond_hoe.title", "Serious Dedication");
|
||||
add("advancements.story.iron_tools.description", "Upgrade your pickaxe");
|
||||
add("advancements.end.respawn_dragon.title", "The End... Again...");
|
||||
add("advancements.husbandry.tame_an_animal.description", "Tame an animal");
|
||||
add("advancements.end.levitate.description", "Levitate up 50 blocks from the attacks of a Shulker");
|
||||
add("advancements.adventure.shoot_arrow.description", "Shoot something with a bow and arrow");
|
||||
add("advancements.nether.root.description", "Bring summer clothes");
|
||||
add("advancements.story.enchant_item.description", "Enchant an item at an Enchanting Table");
|
||||
add("advancements.adventure.root.title", "Adventure");
|
||||
add("advancements.adventure.trade.title", "What a Deal!");
|
||||
add("advancements.husbandry.breed_all_animals.title", "Two by Two");
|
||||
add("advancements.nether.find_fortress.title", "A Terrible Fortress");
|
||||
add("advancements.nether.create_full_beacon.title", "Beaconator");
|
||||
add("advancements.story.cure_zombie_villager.description", "Weaken and then cure a zombie villager");
|
||||
add("advancements.toast.challenge", "Challenge Complete!");
|
||||
add("advancements.nether.create_full_beacon.description", "Bring a beacon to full power");
|
||||
add("advancements.story.follow_ender_eye.description", "Follow an Ender Eye");
|
||||
add("advancements.end.find_end_city.title", "The City at the End of the Game");
|
||||
add("chat.type.advancement.challenge", "%s has completed the challenge %s");
|
||||
add("advancements.story.deflect_arrow.title", "Not Today, Thank You");
|
||||
add("advancements.adventure.kill_all_mobs.description", "Kill one of every hostile monster");
|
||||
add("advancements.story.smelt_iron.title", "Acquire Hardware");
|
||||
add("advancements.end.levitate.title", "Great View From Up Here");
|
||||
add("advancements.end.kill_dragon.title", "Free the End");
|
||||
add("advancements.end.kill_dragon.description", "Good luck");
|
||||
add("advancements.nether.brew_potion.title", "Local Brewery");
|
||||
add("advancements.story.enchant_item.title", "Enchanter");
|
||||
add("advancements.end.respawn_dragon.description", "Respawn the ender dragon");
|
||||
add("advancements.nether.uneasy_alliance.title", "Uneasy Alliance");
|
||||
add("advancements.nether.root.title", "Nether");
|
||||
add("advancements.nether.brew_potion.description", "Brew a potion");
|
||||
add("advancements.nether.obtain_blaze_rod.title", "Into Fire");
|
||||
add("advancements.nether.summon_wither.title", "Withering Heights");
|
||||
add("advancements.story.root.title", "Minecraft");
|
||||
add("advancements.husbandry.balanced_diet.description", "Eat everything that is edible, even if it's not good for you");
|
||||
add("advancements.nether.uneasy_alliance.description", "Rescue a Ghast from the Nether, bring it safely home to the Overworld... and then kill it.");
|
||||
add("advancements.husbandry.breed_all_animals.description", "Breed all the animals!");
|
||||
add("advancements.adventure.kill_all_mobs.title", "Monsters Hunted");
|
||||
add("advancements.story.cure_zombie_villager.title", "Zombie Doctor");
|
||||
add("advancements.husbandry.plant_seed.title", "A Seedy Place");
|
||||
add("advancements.end.dragon_breath.title", "You Need a Mint");
|
||||
add("advancements.story.mine_stone.title", "Stone Age");
|
||||
add("advancements.end.find_end_city.description", "Go on in, what could happen?");
|
||||
add("advancements.nether.create_beacon.description", "Construct and place a Beacon");
|
||||
add("advancements.adventure.summon_iron_golem.title", "Hired Help");
|
||||
add("advancements.end.elytra.title", "Sky's the Limit");
|
||||
add("chat.type.advancement.task", "%s has made the advancement %s");
|
||||
add("advancements.story.deflect_arrow.description", "Deflect an arrow with a shield");
|
||||
add("advancements.nether.all_effects.description", "Have every effect applied at the same time");
|
||||
add("advancements.story.enter_the_nether.description", "Build, light and enter a Nether Portal");
|
||||
add("advancements.story.mine_diamond.title", "Diamonds!");
|
||||
add("advancements.husbandry.balanced_diet.title", "A Balanced Diet");
|
||||
add("advancements.husbandry.root.title", "Husbandry");
|
||||
add("advancements.story.root.description", "The heart and story of the game");
|
||||
add("advancements.story.upgrade_tools.description", "Construct a better pickaxe");
|
||||
add("advancements.nether.all_effects.title", "How Did We Get Here?");
|
||||
add("advancements.end.enter_end_gateway.title", "Remote Getaway");
|
||||
add("advancements.story.mine_stone.description", "Mine stone with your new pickaxe");
|
||||
add("advancements.husbandry.root.description", "The world is full of friends and food");
|
||||
add("advancements.end.dragon_egg.title", "The Next Generation");
|
||||
add("advancements.toast.goal", "Goal Reached!");
|
||||
add("advancements.empty", "There doesn't seem to be anything here...");
|
||||
add("advancements.husbandry.tame_an_animal.title", "Best Friends Forever");
|
||||
add("advancements.end.root.title", "The End");
|
||||
add("advancements.husbandry.breed_an_animal.title", "The Parrots and the Bats");
|
||||
add("advancements.story.mine_diamond.description", "Acquire diamonds");
|
||||
add("advancements.adventure.sleep_in_bed.title", "Sweet dreams");
|
||||
add("advancements.nether.return_to_sender.title", "Return to Sender");
|
||||
add("advancements.story.obtain_armor.title", "Suit Up");
|
||||
add("advancements.adventure.kill_a_mob.description", "Kill any hostile monster");
|
||||
add("advancements.nether.all_potions.description", "Have every potion effect applied at the same time");
|
||||
add("advancements.story.iron_tools.title", "Isn't It Iron Pick");
|
||||
add("advancements.adventure.sleep_in_bed.description", "Change your respawn point");
|
||||
add("advancements.husbandry.plant_seed.description", "Plant a seed and watch it grow");
|
||||
add("advancements.husbandry.breed_an_animal.description", "Breed two animals together");
|
||||
add("advancements.adventure.shoot_arrow.title", "Take Aim");
|
||||
add("advancements.adventure.adventuring_time.description", "Discover every biome");
|
||||
add("advancements.adventure.adventuring_time.title", "Adventuring Time");
|
||||
add("advancements.nether.get_wither_skull.description", "Obtain a wither skeleton's skull");
|
||||
add("advancements.adventure.summon_iron_golem.description", "Summon an Iron Golem to help defend a village");
|
||||
add("advancements.nether.return_to_sender.description", "Destroy a Ghast with a fireball");
|
||||
add("advancements.adventure.trade.description", "Successfully trade with a Villager");
|
||||
add("advancements.story.obtain_armor.description", "Protect yourself with a piece of iron armor");
|
||||
add("advancements.adventure.root.description", "Adventure, exploration and combat");
|
||||
add("advancements.nether.create_beacon.title", "Bring Home the Beacon");
|
||||
add("advancements.end.dragon_egg.description", "Hold the Dragon Egg");
|
||||
add("advancements.nether.obtain_blaze_rod.description", "Relieve a Blaze of its rod");
|
||||
add("advancements.story.lava_bucket.description", "Fill a bucket with lava");
|
||||
add("advancements.story.form_obsidian.title", "Ice Bucket Challenge");
|
||||
add("advancements.story.enter_the_end.title", "The End?");
|
||||
add("advancements.nether.fast_travel.title", "Subspace Bubble");
|
||||
add("advancements.end.enter_end_gateway.description", "Escape the island");
|
||||
add("advancements.adventure.totem_of_undying.title", "Postmortal");
|
||||
add("advancements.nether.all_potions.title", "A Furious Cocktail");
|
||||
add("advancements.adventure.sniper_duel.title", "Sniper duel");
|
||||
add("advancements.nether.summon_wither.description", "Summon the Wither");
|
||||
add("advancements.adventure.totem_of_undying.description", "Use a Totem of Undying to cheat death");
|
||||
add("advancements.story.shiny_gear.description", "Diamond armor saves lives");
|
||||
}
|
||||
|
||||
private static void add(String key, String value) {
|
||||
advancements.put(key, value);
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
return advancements.get(key);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
public class BlockColors {
|
||||
private static final String[] COLORS = new String[16];
|
||||
|
||||
static {
|
||||
COLORS[0] = "White";
|
||||
COLORS[1] = "Orange";
|
||||
COLORS[2] = "Magenta";
|
||||
COLORS[3] = "Light Blue";
|
||||
COLORS[4] = "Yellow";
|
||||
COLORS[5] = "Lime";
|
||||
COLORS[6] = "Pink";
|
||||
COLORS[7] = "Gray";
|
||||
COLORS[8] = "Light Gray";
|
||||
COLORS[9] = "Cyan";
|
||||
COLORS[10] = "Purple";
|
||||
COLORS[11] = "Blue";
|
||||
COLORS[12] = "Brown";
|
||||
COLORS[13] = "Green";
|
||||
COLORS[14] = "Red";
|
||||
COLORS[15] = "Black";
|
||||
}
|
||||
|
||||
public static String get(int key) {
|
||||
return key >= 0 && key < COLORS.length ? COLORS[key] : "Unknown color";
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class MapColorMapping {
|
||||
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 1F);
|
||||
|
||||
static {
|
||||
MAPPING.defaultReturnValue(-1);
|
||||
MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
|
||||
MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
|
||||
MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
|
||||
MAPPING.put(147, 45); // (111, 94, 85) -> (111, 94, 85)
|
||||
MAPPING.put(148, 63); // (112, 58, 25) -> (112, 58, 25)
|
||||
MAPPING.put(149, 60); // (137, 71, 31) -> (137, 71, 31)
|
||||
MAPPING.put(150, 60); // (159, 82, 36) -> (159, 82, 36)
|
||||
MAPPING.put(151, 136); // (84, 43, 19) -> (84, 43, 19)
|
||||
MAPPING.put(152, 83); // (105, 61, 76) -> (105, 61, 76)
|
||||
MAPPING.put(153, 83); // (129, 75, 93) -> (129, 75, 93)
|
||||
MAPPING.put(154, 80); // (149, 87, 108) -> (149, 87, 108)
|
||||
MAPPING.put(155, 115); // (79, 46, 57) -> (79, 46, 57)
|
||||
MAPPING.put(156, 39); // (79, 76, 97) -> (79, 76, 97)
|
||||
MAPPING.put(157, 39); // (97, 93, 119) -> (97, 93, 119)
|
||||
MAPPING.put(158, 36); // (112, 108, 138) -> (112, 108, 138)
|
||||
MAPPING.put(159, 47); // (59, 57, 73) -> (59, 57, 73)
|
||||
MAPPING.put(160, 60); // (131, 94, 25) -> (131, 94, 25)
|
||||
MAPPING.put(161, 61); // (160, 115, 31) -> (160, 115, 31)
|
||||
MAPPING.put(162, 62); // (186, 133, 36) -> (186, 133, 36)
|
||||
MAPPING.put(163, 137); // (98, 70, 19) -> (98, 70, 19)
|
||||
MAPPING.put(164, 108); // (73, 83, 37) -> (73, 83, 37)
|
||||
MAPPING.put(165, 108); // (89, 101, 46) -> (89, 101, 46)
|
||||
MAPPING.put(166, 109); // (103, 117, 53) -> (103, 117, 53)
|
||||
MAPPING.put(167, 111); // (55, 62, 28) -> (55, 62, 28)
|
||||
MAPPING.put(168, 112); // (113, 54, 55) -> (113, 54, 55)
|
||||
MAPPING.put(169, 113); // (138, 66, 67) -> (138, 66, 67)
|
||||
MAPPING.put(170, 114); // (160, 77, 78) -> (160, 77, 78)
|
||||
MAPPING.put(171, 115); // (85, 41, 41) -> (85, 41, 41)
|
||||
MAPPING.put(172, 118); // (40, 29, 25) -> (40, 29, 25)
|
||||
MAPPING.put(173, 107); // (49, 35, 30) -> (49, 35, 30)
|
||||
MAPPING.put(174, 107); // (57, 41, 35) -> (57, 41, 35)
|
||||
MAPPING.put(175, 118); // (30, 22, 19) -> (30, 22, 19)
|
||||
MAPPING.put(176, 91); // (95, 76, 69) -> (95, 76, 69)
|
||||
MAPPING.put(177, 45); // (116, 92, 85) -> (116, 92, 85)
|
||||
MAPPING.put(178, 46); // (135, 107, 98) -> (135, 107, 98)
|
||||
MAPPING.put(179, 47); // (71, 57, 52) -> (71, 57, 52)
|
||||
MAPPING.put(180, 85); // (61, 65, 65) -> (61, 65, 65)
|
||||
MAPPING.put(181, 44); // (75, 79, 79) -> (75, 79, 79)
|
||||
MAPPING.put(182, 27); // (87, 92, 92) -> (87, 92, 92)
|
||||
MAPPING.put(183, 84); // (46, 49, 49) -> (46, 49, 49)
|
||||
MAPPING.put(184, 83); // (86, 52, 62) -> (86, 52, 62)
|
||||
MAPPING.put(185, 83); // (105, 63, 76) -> (105, 63, 76)
|
||||
MAPPING.put(186, 83); // (122, 73, 88) -> (122, 73, 88)
|
||||
MAPPING.put(187, 84); // (65, 39, 47) -> (65, 39, 47)
|
||||
MAPPING.put(188, 84); // (54, 44, 65) -> (54, 44, 65)
|
||||
MAPPING.put(189, 71); // (66, 53, 79) -> (66, 53, 79)
|
||||
MAPPING.put(190, 71); // (76, 62, 92) -> (76, 62, 92)
|
||||
MAPPING.put(191, 87); // (40, 33, 49) -> (40, 33, 49)
|
||||
MAPPING.put(192, 107); // (54, 35, 25) -> (54, 35, 25)
|
||||
MAPPING.put(193, 139); // (66, 43, 30) -> (66, 43, 30)
|
||||
MAPPING.put(194, 43); // (76, 50, 35) -> (76, 50, 35)
|
||||
MAPPING.put(195, 107); // (40, 26, 19) -> (40, 26, 19)
|
||||
MAPPING.put(196, 111); // (54, 58, 30) -> (54, 58, 30)
|
||||
MAPPING.put(197, 111); // (66, 71, 36) -> (66, 71, 36)
|
||||
MAPPING.put(198, 111); // (76, 82, 42) -> (76, 82, 42)
|
||||
MAPPING.put(199, 107); // (40, 43, 22) -> (40, 43, 22)
|
||||
MAPPING.put(200, 112); // (100, 42, 32) -> (100, 42, 32)
|
||||
MAPPING.put(201, 113); // (123, 52, 40) -> (123, 52, 40)
|
||||
MAPPING.put(202, 113); // (142, 60, 46) -> (142, 60, 46)
|
||||
MAPPING.put(203, 115); // (75, 32, 24) -> (75, 32, 24)
|
||||
MAPPING.put(204, 116); // (26, 16, 11) -> (26, 16, 11)
|
||||
MAPPING.put(205, 117); // (32, 19, 14) -> (32, 19, 14)
|
||||
MAPPING.put(206, 107); // (37, 22, 16) -> (37, 22, 16)
|
||||
MAPPING.put(207, 119); // (20, 12, 8) -> (20, 12, 8)
|
||||
}
|
||||
|
||||
public static int getNearestOldColor(int color) {
|
||||
return MAPPING.getOrDefault(color, color);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
public class ParrotStorage {
|
||||
private boolean tamed = true;
|
||||
private boolean sitting = true;
|
||||
|
||||
public boolean isTamed() {
|
||||
return tamed;
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed) {
|
||||
this.tamed = tamed;
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return sitting;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
|
||||
public class ShoulderTracker extends StoredObject {
|
||||
private int entityId;
|
||||
private String leftShoulder;
|
||||
private String rightShoulder;
|
||||
|
||||
public ShoulderTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12.CHAT_MESSAGE, null, getUser());
|
||||
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
|
||||
try {
|
||||
wrapper.scheduleSend(Protocol1_11_1To1_12.class);
|
||||
} catch (Exception e) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("Failed to send the shoulder indication");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Does actionbar not support json colors? :(
|
||||
private String generateString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// Empty spaces because the non-json formatting is weird
|
||||
builder.append(" ");
|
||||
if (leftShoulder == null) {
|
||||
builder.append("§4§lNothing");
|
||||
} else {
|
||||
builder.append("§2§l").append(getName(leftShoulder));
|
||||
}
|
||||
|
||||
builder.append("§8§l <- §7§lShoulders§8§l -> ");
|
||||
|
||||
if (rightShoulder == null) {
|
||||
builder.append("§4§lNothing");
|
||||
} else {
|
||||
builder.append("§2§l").append(getName(rightShoulder));
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String getName(String current) {
|
||||
if (current.startsWith("minecraft:")) {
|
||||
current = current.substring(10);
|
||||
}
|
||||
|
||||
String[] array = current.split("_");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String s : array) {
|
||||
builder.append(s.substring(0, 1).toUpperCase())
|
||||
.append(s.substring(1))
|
||||
.append(" ");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public String getLeftShoulder() {
|
||||
return leftShoulder;
|
||||
}
|
||||
|
||||
public void setLeftShoulder(String leftShoulder) {
|
||||
this.leftShoulder = leftShoulder;
|
||||
}
|
||||
|
||||
public String getRightShoulder() {
|
||||
return rightShoulder;
|
||||
}
|
||||
|
||||
public void setRightShoulder(String rightShoulder) {
|
||||
this.rightShoulder = rightShoulder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ShoulderTracker{" + "entityId=" + entityId + ", leftShoulder='" + leftShoulder + '\'' + ", rightShoulder='" + rightShoulder + '\'' + '}';
|
||||
}
|
||||
}
|
||||
+340
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
public BlockItemPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int count = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < count * 3; i++) {
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
}
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns <= 0) return;
|
||||
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
short color = (short) (data[i] & 0xFF);
|
||||
if (color > 143) {
|
||||
color = (short) MapColorMapping.getNearestOldColor(color);
|
||||
data[i] = (byte) color;
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||
// https://github.com/ViaVersion/ViaVersion/pull/754
|
||||
// Previously clients grab the item from the clicked slot *before* it has
|
||||
// been moved however now they grab the slot item *after* it has been moved
|
||||
// and send that in the packet.
|
||||
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||
|
||||
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.WINDOW_CONFIRMATION);
|
||||
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||
|
||||
wrapper.sendToServer(Protocol1_11_1To1_12.class);
|
||||
wrapper.cancel();
|
||||
confirm.sendToServer(Protocol1_11_1To1_12.class);
|
||||
return;
|
||||
|
||||
}
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Remove bed color
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 11)
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Action ID
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Open Inventory
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 2) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
CompoundTag backupTag = new CompoundTag();
|
||||
if (handleNbtToClient(item.tag(), backupTag)) {
|
||||
item.tag().put("Via|LongArrayTags", backupTag);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private boolean handleNbtToClient(CompoundTag compoundTag, CompoundTag backupTag) {
|
||||
// Long array tags were introduced in 1.12 - just remove them
|
||||
// Only save the removed tags instead of blindly copying the entire nbt again
|
||||
Iterator<Map.Entry<String, Tag>> iterator = compoundTag.iterator();
|
||||
boolean hasLongArrayTag = false;
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Tag> entry = iterator.next();
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
CompoundTag nestedBackupTag = new CompoundTag();
|
||||
backupTag.put(entry.getKey(), nestedBackupTag);
|
||||
hasLongArrayTag |= handleNbtToClient((CompoundTag) entry.getValue(), nestedBackupTag);
|
||||
} else if (entry.getValue() instanceof LongArrayTag) {
|
||||
backupTag.put(entry.getKey(), fromLongArrayTag((LongArrayTag) entry.getValue()));
|
||||
iterator.remove();
|
||||
hasLongArrayTag = true;
|
||||
}
|
||||
}
|
||||
return hasLongArrayTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
if (item.tag() != null) {
|
||||
Tag tag = item.tag().remove("Via|LongArrayTags");
|
||||
if (tag instanceof CompoundTag) {
|
||||
handleNbtToServer(item.tag(), (CompoundTag) tag);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private void handleNbtToServer(CompoundTag compoundTag, CompoundTag backupTag) {
|
||||
// Restore the removed long array tags
|
||||
for (Map.Entry<String, Tag> entry : backupTag) {
|
||||
if (entry.getValue() instanceof CompoundTag) {
|
||||
CompoundTag nestedTag = compoundTag.get(entry.getKey());
|
||||
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
|
||||
} else {
|
||||
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IntArrayTag fromLongArrayTag(LongArrayTag tag) {
|
||||
int[] intArray = new int[tag.length() * 2];
|
||||
long[] longArray = tag.getValue();
|
||||
int i = 0;
|
||||
for (long l : longArray) {
|
||||
intArray[i++] = (int) (l >> 32);
|
||||
intArray[i++] = (int) l;
|
||||
}
|
||||
return new IntArrayTag(intArray);
|
||||
}
|
||||
|
||||
private LongArrayTag fromIntArrayTag(IntArrayTag tag) {
|
||||
long[] longArray = new long[tag.length() / 2];
|
||||
int[] intArray = tag.getValue();
|
||||
for (int i = 0, j = 0; i < intArray.length; i += 2, j++) {
|
||||
longArray[j] = (long) intArray[i] << 32 | ((long) intArray[i + 1] & 0xFFFFFFFFL);
|
||||
}
|
||||
return new LongArrayTag(longArray);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
|
||||
public class ChatItemRewriter {
|
||||
|
||||
public static void toClient(JsonElement element, UserConnection user) {
|
||||
if (element instanceof JsonObject) {
|
||||
JsonObject obj = (JsonObject) element;
|
||||
if (obj.has("hoverEvent")) {
|
||||
if (obj.get("hoverEvent") instanceof JsonObject) {
|
||||
JsonObject hoverEvent = (JsonObject) obj.get("hoverEvent");
|
||||
if (hoverEvent.has("action") && hoverEvent.has("value")) {
|
||||
String type = hoverEvent.get("action").getAsString();
|
||||
if (type.equals("show_item") || type.equals("show_entity")) {
|
||||
JsonElement value = hoverEvent.get("value");
|
||||
|
||||
if (value.isJsonArray()) {
|
||||
JsonArray newArray = new JsonArray();
|
||||
|
||||
int index = 0;
|
||||
for (JsonElement valueElement : value.getAsJsonArray()) {
|
||||
if (valueElement.isJsonPrimitive() && valueElement.getAsJsonPrimitive().isString()) {
|
||||
String newValue = index + ":" + valueElement.getAsString();
|
||||
newArray.add(new JsonPrimitive(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
hoverEvent.add("value", newArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj.has("extra")) {
|
||||
toClient(obj.get("extra"), user);
|
||||
}
|
||||
} else if (element instanceof JsonArray) {
|
||||
JsonArray array = (JsonArray) element;
|
||||
for (JsonElement value : array) {
|
||||
toClient(value, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
|
||||
|
||||
private final ComponentRewriter componentRewriter = new ComponentRewriter() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ChatPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
componentRewriter.processText(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+316
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityPackets1_12 extends LegacyEntityRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
public EntityPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - x
|
||||
map(Type.DOUBLE); // 4 - y
|
||||
map(Type.DOUBLE); // 5 - z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - data
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_12Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
int objType = objectData & 4095;
|
||||
int data = objectData >> 12 & 15;
|
||||
|
||||
Block block = protocol.getItemRewriter().handleBlock(objType, data);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_12.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(getMobSpawnRewriter(Types1_12.METADATA_LIST));
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_12.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_12Types.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(getTrackerHandler(Entity1_12Types.EntityType.PLAYER, Type.INT));
|
||||
|
||||
handler(getDimensionHandler(1));
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ShoulderTracker tracker = wrapper.user().get(ShoulderTracker.class);
|
||||
tracker.setEntityId(wrapper.get(Type.INT, 0));
|
||||
}
|
||||
});
|
||||
|
||||
// Send fake inventory achievement
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
PacketWrapper wrapper = PacketWrapper.create(0x07, null, packetWrapper.user());
|
||||
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
wrapper.write(Type.STRING, "achievement.openInventory");
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
|
||||
wrapper.scheduleSend(Protocol1_11_1To1_12.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerRespawn(ClientboundPackets1_12.RESPAWN);
|
||||
registerRemoveEntities(ClientboundPackets1_12.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_12.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.get(Type.INT, 0);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String key = wrapper.read(Type.STRING);
|
||||
// Remove new attribute
|
||||
if (key.equals("generic.flyingSpeed")) {
|
||||
newSize--;
|
||||
wrapper.read(Type.DOUBLE);
|
||||
int modSize = wrapper.read(Type.VAR_INT);
|
||||
for (int j = 0; j < modSize; j++) {
|
||||
wrapper.read(Type.UUID);
|
||||
wrapper.read(Type.DOUBLE);
|
||||
wrapper.read(Type.BYTE);
|
||||
}
|
||||
} else {
|
||||
wrapper.write(Type.STRING, key);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
int modSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < modSize; j++) {
|
||||
wrapper.passthrough(Type.UUID);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newSize != size) {
|
||||
wrapper.set(Type.INT, 0, newSize);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).mobName("Parrot").spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||
mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).mobName("Illusioner");
|
||||
|
||||
// Handle Illager
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
|
||||
|
||||
filter().type(Entity1_12Types.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
|
||||
byte mask = (byte) meta.getValue();
|
||||
|
||||
if ((mask & 0x20) == 0x20) {
|
||||
mask &= ~0x20;
|
||||
}
|
||||
|
||||
meta.setValue(mask);
|
||||
});
|
||||
|
||||
// Create Parrot storage
|
||||
filter().filterFamily(Entity1_12Types.EntityType.PARROT).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
if (!data.has(ParrotStorage.class)) {
|
||||
data.put(new ParrotStorage());
|
||||
}
|
||||
});
|
||||
// Parrot remove animal metadata
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(12); // Is baby
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).index(13).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ParrotStorage storage = data.get(ParrotStorage.class);
|
||||
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
|
||||
boolean isTamed = (((byte) meta.getValue()) & 0x04) == 0x04;
|
||||
|
||||
if (!storage.isTamed() && isTamed) {
|
||||
// TODO do something to let the user know it's done
|
||||
}
|
||||
|
||||
storage.setTamed(isTamed);
|
||||
|
||||
if (isSitting) {
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x01);
|
||||
storage.setSitting(true);
|
||||
} else if (storage.isSitting()) {
|
||||
event.setIndex(12);
|
||||
meta.setValue((byte) 0x00);
|
||||
storage.setSitting(false);
|
||||
} else {
|
||||
event.cancel();
|
||||
}
|
||||
}); // Flags (Is sitting etc, might be useful in the future
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(14); // Owner
|
||||
filter().type(Entity1_12Types.EntityType.PARROT).cancel(15); // Variant
|
||||
|
||||
// Left shoulder entity data
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(15).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) meta.getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
||||
tracker.setLeftShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
|
||||
tracker.setLeftShoulder(id);
|
||||
tracker.update();
|
||||
}
|
||||
}
|
||||
|
||||
event.cancel();
|
||||
});
|
||||
|
||||
// Right shoulder entity data
|
||||
filter().type(Entity1_12Types.EntityType.PLAYER).index(16).handler((event, meta) -> {
|
||||
CompoundTag tag = (CompoundTag) event.meta().getValue();
|
||||
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
|
||||
|
||||
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
|
||||
tracker.setRightShoulder(null);
|
||||
tracker.update();
|
||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
|
||||
tracker.setRightShoulder(id);
|
||||
tracker.update();
|
||||
}
|
||||
}
|
||||
|
||||
event.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_12Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_12Types.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacySoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
public SoundPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
map(Type.INT); // 3 - y
|
||||
map(Type.INT); // 4 - z
|
||||
map(Type.FLOAT); // 5 - Volume
|
||||
map(Type.FLOAT); // 6 - Pitch
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
map(Type.INT); // 3 - y
|
||||
map(Type.INT); // 4 - z
|
||||
map(Type.FLOAT); // 5 - Volume
|
||||
map(Type.FLOAT); // 6 - Pitch
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int oldId = wrapper.get(Type.VAR_INT, 0);
|
||||
int newId = handleSounds(oldId);
|
||||
if (newId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasPitch(oldId)) {
|
||||
wrapper.set(Type.FLOAT, 1, handlePitch(oldId));
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
//TODO use the diff file to also have named sound remaps
|
||||
// (there were *A LOT* of refactored names)
|
||||
|
||||
// Replacement sounds, suggestions are always welcome
|
||||
// Automatically generated from PAaaS
|
||||
added(26, 277, 1.4f); // block.end_portal.spawn -> entity.lightning.thunder
|
||||
added(27, -1); // block.end_portal_frame.fill
|
||||
|
||||
added(72, 70); // block.note.bell -> block.note.harp
|
||||
added(73, 70); // block.note.chime -> block.note.harp
|
||||
added(74, 70); // block.note.flute -> block.note.harp
|
||||
added(75, 70); // block.note.guitar -> block.note.harp
|
||||
added(80, 70); // block.note.xylophone -> block.note.harp
|
||||
|
||||
added(150, -1); // entity.boat.paddle_land
|
||||
added(151, -1); // entity.boat.paddle_water
|
||||
|
||||
added(152, -1); // entity.bobber.retrieve
|
||||
|
||||
added(195, -1); // entity.endereye.death
|
||||
|
||||
added(274, 198, 0.8f); // entity.illusion_illager.ambient -> entity.evocation_illager.ambient
|
||||
added(275, 199, 0.8f); // entity.illusion_illager.cast_spell -> entity.evocation_illager.cast_spell
|
||||
added(276, 200, 0.8f); // entity.illusion_illager.death -> entity.evocation_illager.death
|
||||
added(277, 201, 0.8f); // entity.illusion_illager.hurt -> entity.evocation_illager.hurt
|
||||
added(278, 191, 0.9f); // entity.illusion_illager.mirror_move -> entity.endermen.teleport
|
||||
added(279, 203, 1.5f); // entity.illusion_illager.prepare_blindness -> entity.evocation_illager.prepare_summon
|
||||
added(280, 202, 0.8f); // entity.illusion_illager.prepare_mirror -> entity.evocation_illager.prepare_attack
|
||||
|
||||
added(319, 133, 0.6f); // entity.parrot.ambient -> entity.bat.ambient
|
||||
added(320, 134, 1.7f); // entity.parrot.death -> entity.bat.death
|
||||
added(321, 219, 1.5f); // entity.parrot.eat -> entity.generic.eat
|
||||
added(322, 136, 0.7f); // entity.parrot.fly -> entity.bat.loop
|
||||
added(323, 135, 1.6f); // entity.parrot.hurt -> entity.bat.hurt
|
||||
added(324, 138, 1.5f); // entity.parrot.imitate.blaze -> entity.blaze.ambient
|
||||
added(325, 163, 1.5f); // entity.parrot.imitate.creeper -> entity.creeper.primed
|
||||
added(326, 170, 1.5f); // entity.parrot.imitate.elder_guardian -> entity.elder_guardian.ambient
|
||||
added(327, 178, 1.5f); // entity.parrot.imitate.enderdragon -> entity.enderdragon.ambient
|
||||
added(328, 186, 1.5f); // entity.parrot.imitate.enderman -> entity.endermen.ambient
|
||||
added(329, 192, 1.5f); // entity.parrot.imitate.endermite -> entity.endermite.ambient
|
||||
added(330, 198, 1.5f); // entity.parrot.imitate.evocation_illager -> entity.evocation_illager.ambient
|
||||
added(331, 226, 1.5f); // entity.parrot.imitate.ghast -> entity.ghast.ambient
|
||||
added(332, 259, 1.5f); // entity.parrot.imitate.husk -> entity.husk.ambient
|
||||
added(333, 198, 1.3f); // entity.parrot.imitate.illusion_illager -> entity.evocation_illager.ambient
|
||||
added(334, 291, 1.5f); // entity.parrot.imitate.magmacube -> entity.magmacube.squish
|
||||
added(335, 321, 1.5f); // entity.parrot.imitate.polar_bear -> entity.polar_bear.ambient
|
||||
added(336, 337, 1.5f); // entity.parrot.imitate.shulker -> entity.shulker.ambient
|
||||
added(337, 347, 1.5f); // entity.parrot.imitate.silverfish -> entity.silverfish.ambient
|
||||
added(338, 351, 1.5f); // entity.parrot.imitate.skeleton -> entity.skeleton.ambient
|
||||
added(339, 363, 1.5f); // entity.parrot.imitate.slime -> entity.slime.squish
|
||||
added(340, 376, 1.5f); // entity.parrot.imitate.spider -> entity.spider.ambient
|
||||
added(341, 385, 1.5f); // entity.parrot.imitate.stray -> entity.stray.ambient
|
||||
added(342, 390, 1.5f); // entity.parrot.imitate.vex -> entity.vex.ambient
|
||||
added(343, 400, 1.5f); // entity.parrot.imitate.vindication_illager -> entity.vindication_illager.ambient
|
||||
added(344, 403, 1.5f); // entity.parrot.imitate.witch -> entity.witch.ambient
|
||||
added(345, 408, 1.5f); // entity.parrot.imitate.wither -> entity.wither.ambient
|
||||
added(346, 414, 1.5f); // entity.parrot.imitate.wither_skeleton -> entity.wither_skeleton.ambient
|
||||
added(347, 418, 1.5f); // entity.parrot.imitate.wolf -> entity.wolf.ambient
|
||||
added(348, 427, 1.5f); // entity.parrot.imitate.zombie -> entity.zombie.ambient
|
||||
added(349, 438, 1.5f); // entity.parrot.imitate.zombie_pigman -> entity.zombie_pig.ambient
|
||||
added(350, 442, 1.5f); // entity.parrot.imitate.zombie_villager -> entity.zombie_villager.ambient
|
||||
added(351, 155); // entity.parrot.step -> entity.chicken.step
|
||||
|
||||
added(368, 316); // entity.player.hurt_drown -> entity.player.hurt
|
||||
added(369, 316); // entity.player.hurt_on_fire -> entity.player.hurt
|
||||
|
||||
// No replacement sounds for these, since it could be confusing, the toast doesn't show up
|
||||
added(544, -1); // ui.toast.in
|
||||
added(545, -1); // ui.toast.out
|
||||
added(546, 317, 1.5f); // ui.toast.challenge_complete
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11to1_11_1;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||
|
||||
private final EntityPackets1_11_1 entityPackets = new EntityPackets1_11_1(this);
|
||||
private final ItemRewriter itemRewriter = new ItemPackets1_11_1(this);
|
||||
|
||||
public Protocol1_11To1_11_1() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
entityPackets.register();
|
||||
itemRewriter.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPackets1_11_1 getEntityRewriter() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
public class EntityPackets1_11_1 extends LegacyEntityRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
public EntityPackets1_11_1(Protocol1_11To1_11_1 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - x
|
||||
map(Type.DOUBLE); // 4 - y
|
||||
map(Type.DOUBLE); // 5 - z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - data
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
// Track entity
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(getMobSpawnRewriter(Types1_9.METADATA_LIST));
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING);
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_9.METADATA_LIST); // 7 - Metadata list
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||
filter().type(Entity1_11Types.EntityType.FIREWORK).cancel(7);
|
||||
|
||||
// Handle non-existing pig metadata (index 14 - boost time)
|
||||
filter().type(Entity1_11Types.EntityType.PIG).cancel(14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_11Types.getTypeFromId(typeId, true);
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
|
||||
public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<Protocol1_11To1_11_1> {
|
||||
|
||||
private LegacyEnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public ItemPackets1_11_1(Protocol1_11To1_11_1 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
|
||||
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
// Handle item metadata
|
||||
protocol.getEntityRewriter().filter().handler((event, meta) -> {
|
||||
if (meta.metaType().type().equals(Type.ITEM)) { // Is Item
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName);
|
||||
enchantmentRewriter.registerEnchantment(22, "§7Sweeping Edge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToClient(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.get("ench") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||
}
|
||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
super.handleItemToServer(item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) return item;
|
||||
|
||||
if (tag.contains(nbtTagName + "|ench")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||
}
|
||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class KeepAliveTracker implements StorableObject {
|
||||
private long keepAlive = Integer.MAX_VALUE;
|
||||
|
||||
public long getKeepAlive() {
|
||||
return keepAlive;
|
||||
}
|
||||
|
||||
public void setKeepAlive(long keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KeepAliveTracker{" + "keepAlive=" + keepAlive + '}';
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
|
||||
public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12_1, ServerboundPackets1_12_1, ServerboundPackets1_12_1> {
|
||||
|
||||
public Protocol1_12_1To1_12_2() {
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
Long keepAlive = packetWrapper.read(Type.LONG);
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(keepAlive);
|
||||
packetWrapper.write(Type.VAR_INT, keepAlive.hashCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
int keepAlive = packetWrapper.read(Type.VAR_INT);
|
||||
long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive();
|
||||
if (keepAlive != Long.hashCode(realKeepAlive)) {
|
||||
packetWrapper.cancel(); // Wrong data, cancel packet
|
||||
return;
|
||||
}
|
||||
packetWrapper.write(Type.LONG, realKeepAlive);
|
||||
// Reset KeepAliveTracker (to prevent sending same valid value in a row causing a timeout)
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Integer.MAX_VALUE);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new KeepAliveTracker());
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private final EntityRewriter entityRewriter = new EntityPackets1_13(this);
|
||||
private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this);
|
||||
|
||||
public Protocol1_12_2To1_13() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_12_1.class, ServerboundPackets1_13.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_13To1_12_2.class, () -> {
|
||||
MAPPINGS.load();
|
||||
PaintingMapping.init();
|
||||
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
|
||||
});
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this) {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null || (newTranslate = getMappingData().getTranslateMappings().get(translate)) != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
};
|
||||
translatableRewriter.registerPing();
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
|
||||
|
||||
blockItemPackets.register();
|
||||
entityRewriter.register();
|
||||
new PlayerPacket1_13(this).register();
|
||||
new SoundPackets1_13(this).register();
|
||||
|
||||
cancelClientbound(ClientboundPackets1_13.NBT_QUERY);
|
||||
cancelClientbound(ClientboundPackets1_13.CRAFT_RECIPE_RESPONSE);
|
||||
cancelClientbound(ClientboundPackets1_13.UNLOCK_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_13.ADVANCEMENTS);
|
||||
cancelClientbound(ClientboundPackets1_13.DECLARE_RECIPES);
|
||||
cancelClientbound(ClientboundPackets1_13.TAGS);
|
||||
|
||||
cancelServerbound(ServerboundPackets1_12_1.CRAFT_RECIPE_REQUEST);
|
||||
cancelServerbound(ServerboundPackets1_12_1.RECIPE_BOOK_DATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER));
|
||||
|
||||
user.put(new BackwardsBlockStorage());
|
||||
user.put(new TabCompleteStorage());
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||
user.put(new PlayerPositionStorage1_13());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPackets1_13 getItemRewriter() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int WALL_BANNER_START = 7110; // 4 each
|
||||
private static final int WALL_BANNER_STOP = 7173;
|
||||
|
||||
private static final int BANNER_START = 6854; // 16 each
|
||||
private static final int BANNER_STOP = 7109;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
// Normal banners
|
||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||
int color = (blockId - BANNER_START) >> 4;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
}
|
||||
// Wall banners
|
||||
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||
tag.put("Base", new IntTag((15 - color)));
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
}
|
||||
|
||||
// Invert colors
|
||||
Tag patternsTag = tag.get("Patterns");
|
||||
if (patternsTag instanceof ListTag) {
|
||||
for (Tag pattern : (ListTag) patternsTag) {
|
||||
if (!(pattern instanceof CompoundTag)) continue;
|
||||
|
||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
||||
c.setValue(15 - c.asInt()); // Invert color id
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
|
||||
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
int offset = blockId - 748;
|
||||
int color = offset >> 4;
|
||||
|
||||
tag.put("color", new IntTag(color));
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 1F);
|
||||
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
|
||||
|
||||
static {
|
||||
FLOWERS.put(5265, AIR);
|
||||
register(5266, "minecraft:sapling", (byte) 0);
|
||||
register(5267, "minecraft:sapling", (byte) 1);
|
||||
register(5268, "minecraft:sapling", (byte) 2);
|
||||
register(5269, "minecraft:sapling", (byte) 3);
|
||||
register(5270, "minecraft:sapling", (byte) 4);
|
||||
register(5271, "minecraft:sapling", (byte) 5);
|
||||
register(5272, "minecraft:tallgrass", (byte) 2);
|
||||
register(5273, "minecraft:yellow_flower", (byte) 0);
|
||||
register(5274, "minecraft:red_flower", (byte) 0);
|
||||
register(5275, "minecraft:red_flower", (byte) 1);
|
||||
register(5276, "minecraft:red_flower", (byte) 2);
|
||||
register(5277, "minecraft:red_flower", (byte) 3);
|
||||
register(5278, "minecraft:red_flower", (byte) 4);
|
||||
register(5279, "minecraft:red_flower", (byte) 5);
|
||||
register(5280, "minecraft:red_flower", (byte) 6);
|
||||
register(5281, "minecraft:red_flower", (byte) 7);
|
||||
register(5282, "minecraft:red_flower", (byte) 8);
|
||||
register(5283, "minecraft:red_mushroom", (byte) 0);
|
||||
register(5284, "minecraft:brown_mushroom", (byte) 0);
|
||||
register(5285, "minecraft:deadbush", (byte) 0);
|
||||
register(5286, "minecraft:cactus", (byte) 0);
|
||||
}
|
||||
|
||||
private static void register(int id, String identifier, byte data) {
|
||||
FLOWERS.put(id, new Pair<>(identifier, data));
|
||||
}
|
||||
|
||||
public static boolean isFlowah(int id) {
|
||||
return id >= 5265 && id <= 5286;
|
||||
}
|
||||
|
||||
public Pair<String, Byte> getOrDefault(int blockId) {
|
||||
Pair<String, Byte> pair = FLOWERS.get(blockId);
|
||||
return pair != null ? pair : AIR;
|
||||
}
|
||||
|
||||
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
Pair<String, Byte> item = getOrDefault(blockId);
|
||||
|
||||
tag.put("Item", new StringTag(item.getKey()));
|
||||
tag.put("Data", new IntTag(item.getValue()));
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private final Map<String, Integer> pistonIds = new HashMap<>();
|
||||
|
||||
public PistonHandler() {
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
Map<String, Integer> keyToId;
|
||||
try {
|
||||
Field field = ConnectionData.class.getDeclaredField("keyToId");
|
||||
field.setAccessible(true);
|
||||
keyToId = (Map<String, Integer>) field.get(null);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
|
||||
if (!entry.getKey().contains("piston")) continue;
|
||||
|
||||
addEntries(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
JsonObject mappings = MappingDataLoader.getMappingsCache().get("mapping-1.13.json").getAsJsonObject("blockstates");
|
||||
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
||||
String key = blockState.getValue().getAsString();
|
||||
if (!key.contains("piston")) continue;
|
||||
|
||||
addEntries(key, Integer.parseInt(blockState.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There doesn't seem to be a nicer way around it :(
|
||||
private void addEntries(String data, int id) {
|
||||
id = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(id);
|
||||
pistonIds.put(data, id);
|
||||
|
||||
String substring = data.substring(10);
|
||||
if (!substring.startsWith("piston") && !substring.startsWith("sticky_piston")) return;
|
||||
|
||||
// Swap properties and add them to the map
|
||||
String[] split = data.substring(0, data.length() - 1).split("\\[");
|
||||
String[] properties = split[1].split(",");
|
||||
data = split[0] + "[" + properties[1] + "," + properties[0] + "]";
|
||||
pistonIds.put(data, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.get("blockState");
|
||||
if (blockState == null) return tag;
|
||||
|
||||
String dataFromTag = getDataFromTag(blockState);
|
||||
if (dataFromTag == null) return tag;
|
||||
|
||||
Integer id = pistonIds.get(dataFromTag);
|
||||
if (id == null) {
|
||||
//TODO see why this could be null and if this is bad
|
||||
return tag;
|
||||
}
|
||||
|
||||
tag.put("blockId", new IntTag(id >> 4));
|
||||
tag.put("blockData", new IntTag(id & 15));
|
||||
return tag;
|
||||
}
|
||||
|
||||
// The type hasn't actually been updated in the blockstorage, so we need to construct it
|
||||
private String getDataFromTag(CompoundTag tag) {
|
||||
StringTag name = tag.get("Name");
|
||||
if (name == null) return null;
|
||||
|
||||
CompoundTag properties = tag.get("Properties");
|
||||
if (properties == null) return name.getValue();
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
||||
for (Map.Entry<String, Tag> entry : properties) {
|
||||
if (!(entry.getValue() instanceof StringTag)) continue;
|
||||
joiner.add(entry.getKey() + "=" + ((StringTag) entry.getValue()).getValue());
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||
private static final int SKULL_START = 5447;
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
int diff = blockId - SKULL_START;
|
||||
int pos = diff % 20;
|
||||
byte type = (byte) Math.floor(diff / 20f);
|
||||
|
||||
// Set type
|
||||
tag.put("SkullType", new ByteTag(type));
|
||||
|
||||
// Remove wall skulls
|
||||
if (pos < 4) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Add rotation for normal skulls
|
||||
tag.put("Rot", new ByteTag((byte) ((pos - 4) & 255)));
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
Tag dataTag = tag.get("SpawnData");
|
||||
if (dataTag instanceof CompoundTag) {
|
||||
CompoundTag data = (CompoundTag) dataTag;
|
||||
Tag idTag = data.get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
StringTag s = (StringTag) idTag;
|
||||
s.setValue(EntityNameRewrites.rewrite(s.getValue()));
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.data.VBMappings;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||
private final Int2ObjectMap<String> statisticMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final Map<String, String> translateMappings = new HashMap<>();
|
||||
private Mappings enchantmentMappings;
|
||||
|
||||
public BackwardsMappings() {
|
||||
super("1.13", "1.12", Protocol1_13To1_12_2.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
enchantmentMappings = new VBMappings(oldMappings.getAsJsonObject("enchantments"), newMappings.getAsJsonObject("enchantments"), false);
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
|
||||
statisticMappings.put(entry.getValue().intValue(), entry.getKey());
|
||||
}
|
||||
for (Map.Entry<String, String> entry : Protocol1_13To1_12_2.MAPPINGS.getTranslateMapping().entrySet()) {
|
||||
translateMappings.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
// Has lots of compat layers, so we can't use the default Via method
|
||||
private static void mapIdentifiers(int[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
int value = newIdentifierMap.getInt(key);
|
||||
short hardId = -1;
|
||||
if (value == -1) {
|
||||
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
|
||||
int propertyIndex;
|
||||
if (replacement == null && (propertyIndex = key.indexOf('[')) != -1) {
|
||||
replacement = mapping.getAsJsonPrimitive(key.substring(0, propertyIndex));
|
||||
}
|
||||
if (replacement != null) {
|
||||
if (replacement.getAsString().startsWith("id:")) {
|
||||
String id = replacement.getAsString().replace("id:", "");
|
||||
hardId = Short.parseShort(id);
|
||||
value = newIdentifierMap.getInt(oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||
} else {
|
||||
value = newIdentifierMap.getInt(replacement.getAsString());
|
||||
}
|
||||
}
|
||||
if (value == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
if (replacement != null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
output[Integer.parseInt(entry.getKey())] = hardId != -1 ? hardId : (short) value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (key.equals("blockstates")) {
|
||||
int[] oldToNew = new int[8582];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
mapIdentifiers(oldToNew, oldMappings.getAsJsonObject("blockstates"), newMappings.getAsJsonObject("blocks"), diffMappings.getAsJsonObject("blockstates"));
|
||||
return new IntArrayMappings(oldToNew);
|
||||
} else {
|
||||
return super.loadFromObject(oldMappings, newMappings, diffMappings, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockStateId(int id) {
|
||||
int mappedId = super.getNewBlockStateId(id);
|
||||
|
||||
// https://github.com/ViaVersion/ViaBackwards/issues/290
|
||||
switch (mappedId) {
|
||||
case 1595:
|
||||
case 1596:
|
||||
case 1597:
|
||||
return 1584; // brown mushroom block
|
||||
case 1611:
|
||||
case 1612:
|
||||
case 1613:
|
||||
return 1600; // red mushroom block
|
||||
default:
|
||||
return mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkValidity(int id, int mappedId, String type) {
|
||||
// Don't warn for missing ids here
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return super.shouldWarnOnMissing(key) && !key.equals("items");
|
||||
}
|
||||
|
||||
public Int2ObjectMap<String> getStatisticMappings() {
|
||||
return statisticMappings;
|
||||
}
|
||||
|
||||
public Map<String, String> getTranslateMappings() {
|
||||
return translateMappings;
|
||||
}
|
||||
|
||||
public Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntityNameRewrites {
|
||||
private static final Map<String, String> ENTITY_NAMES = new HashMap<>();
|
||||
|
||||
static {
|
||||
// CHANGED NAMES IN 1.13
|
||||
reg("commandblock_minecart", "command_block_minecart");
|
||||
reg("ender_crystal", "end_crystal");
|
||||
reg("evocation_fangs", "evoker_fangs");
|
||||
reg("evocation_illager", "evoker");
|
||||
reg("eye_of_ender_signal", "eye_of_ender");
|
||||
reg("fireworks_rocket", "firework_rocket");
|
||||
reg("illusion_illager", "illusioner");
|
||||
reg("snowman", "snow_golem");
|
||||
reg("villager_golem", "iron_golem");
|
||||
reg("vindication_illager", "vindicator");
|
||||
reg("xp_bottle", "experience_bottle");
|
||||
reg("xp_orb", "experience_orb");
|
||||
}
|
||||
|
||||
|
||||
private static void reg(String past, String future) {
|
||||
ENTITY_NAMES.put("minecraft:" + future, "minecraft:" + past);
|
||||
}
|
||||
|
||||
public static String rewrite(String entName) {
|
||||
String entityName = ENTITY_NAMES.get(entName);
|
||||
if (entityName != null) {
|
||||
return entityName;
|
||||
}
|
||||
entityName = ENTITY_NAMES.get("minecraft:" + entName);
|
||||
if (entityName != null) {
|
||||
return entityName;
|
||||
} else
|
||||
return entName;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class EntityTypeMapping {
|
||||
private static final Int2IntMap TYPES = new Int2IntOpenHashMap();
|
||||
|
||||
static {
|
||||
TYPES.defaultReturnValue(-1);
|
||||
try {
|
||||
Field field = EntityTypeRewriter.class.getDeclaredField("ENTITY_TYPES");
|
||||
field.setAccessible(true);
|
||||
Int2IntMap entityTypes = (Int2IntMap) field.get(null);
|
||||
for (Int2IntMap.Entry entry : entityTypes.int2IntEntrySet()) {
|
||||
EntityTypeMapping.TYPES.put(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getOldId(int type1_13) {
|
||||
return TYPES.get(type1_13);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NamedSoundMapping {
|
||||
private static final Map<String, String> SOUNDS = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
|
||||
field.setAccessible(true);
|
||||
Map<String, String> sounds = (Map<String, String>) field.get(null);
|
||||
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.SOUNDS.put(sound1_13, sound1_12));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOldId(String sound1_13) {
|
||||
if (sound1_13.startsWith("minecraft:")) {
|
||||
sound1_13 = sound1_13.substring(10);
|
||||
}
|
||||
return SOUNDS.get(sound1_13);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class PaintingMapping {
|
||||
private static final Int2ObjectMap<String> PAINTINGS = new Int2ObjectOpenHashMap<>(26, 1F);
|
||||
|
||||
public static void init() {
|
||||
add("Kebab");
|
||||
add("Aztec");
|
||||
add("Alban");
|
||||
add("Aztec2");
|
||||
add("Bomb");
|
||||
add("Plant");
|
||||
add("Wasteland");
|
||||
add("Pool");
|
||||
add("Courbet");
|
||||
add("Sea");
|
||||
add("Sunset");
|
||||
add("Creebet");
|
||||
add("Wanderer");
|
||||
add("Graham");
|
||||
add("Match");
|
||||
add("Bust");
|
||||
add("Stage");
|
||||
add("Void");
|
||||
add("SkullAndRoses");
|
||||
add("Wither");
|
||||
add("Fighters");
|
||||
add("Pointer");
|
||||
add("Pigscene");
|
||||
add("BurningSkull");
|
||||
add("Skeleton");
|
||||
add("DonkeyKong");
|
||||
}
|
||||
|
||||
private static void add(String motive) {
|
||||
PAINTINGS.put(PAINTINGS.size(), motive);
|
||||
}
|
||||
|
||||
public static String getStringId(int id) {
|
||||
return PAINTINGS.getOrDefault(id, "kebab");
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMapping {
|
||||
private static final ParticleData[] particles;
|
||||
|
||||
static {
|
||||
ParticleHandler blockHandler = new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
return rewrite(wrapper.read(Type.VAR_INT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
return rewrite((int) data.get(0).getValue());
|
||||
}
|
||||
|
||||
private int[] rewrite(int newType) {
|
||||
int blockType = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(newType);
|
||||
|
||||
int type = blockType >> 4;
|
||||
int meta = blockType & 15;
|
||||
return new int[]{type + (meta << 12)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockHandler() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
particles = new ParticleData[]{
|
||||
rewrite(16), // (0->16) minecraft:ambient_entity_effect -> mobSpellAmbient
|
||||
rewrite(20), // (1->20) minecraft:angry_villager -> angryVillager
|
||||
rewrite(35), // (2->35) minecraft:barrier -> barrier
|
||||
rewrite(37, blockHandler),
|
||||
// (3->37) minecraft:block -> blockcrack
|
||||
rewrite(4), // (4->4) minecraft:bubble -> bubble
|
||||
rewrite(29), // (5->29) minecraft:cloud -> cloud
|
||||
rewrite(9), // (6->9) minecraft:crit -> crit
|
||||
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||
rewrite(42), // (8->42) minecraft:dragon_breath -> dragonbreath
|
||||
rewrite(19), // (9->19) minecraft:dripping_lava -> dripLava
|
||||
rewrite(18), // (10->18) minecraft:dripping_water -> dripWater
|
||||
rewrite(30, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
float r = wrapper.read(Type.FLOAT);
|
||||
float g = wrapper.read(Type.FLOAT);
|
||||
float b = wrapper.read(Type.FLOAT);
|
||||
float scale = wrapper.read(Type.FLOAT);
|
||||
|
||||
wrapper.set(Type.FLOAT, 3, r); // 5 - Offset X index=3
|
||||
wrapper.set(Type.FLOAT, 4, g); // 6 - Offset Y index=4
|
||||
wrapper.set(Type.FLOAT, 5, b); // 7 - Offset Z index=5
|
||||
wrapper.set(Type.FLOAT, 6, scale); // 8 - Particle Data index=6
|
||||
wrapper.set(Type.INT, 1, 0); // 9 - Particle Count index=1 enable rgb particle
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
return null;
|
||||
}
|
||||
}), // (11->30) minecraft:dust -> reddust
|
||||
rewrite(13), // (12->13) minecraft:effect -> spell
|
||||
rewrite(41), // (13->41) minecraft:elder_guardian -> mobappearance
|
||||
rewrite(10), // (14->10) minecraft:enchanted_hit -> magicCrit
|
||||
rewrite(25), // (15->25) minecraft:enchant -> enchantmenttable
|
||||
rewrite(43), // (16->43) minecraft:end_rod -> endRod
|
||||
rewrite(15), // (17->15) minecraft:entity_effect -> mobSpell
|
||||
rewrite(2), // (18->2) minecraft:explosion_emitter -> hugeexplosion
|
||||
rewrite(1), // (19->1) minecraft:explosion -> largeexplode
|
||||
rewrite(46, blockHandler),
|
||||
// (20->46) minecraft:falling_dust -> fallingdust
|
||||
rewrite(3), // (21->3) minecraft:firework -> fireworksSpark
|
||||
rewrite(6), // (22->6) minecraft:fishing -> wake
|
||||
rewrite(26), // (23->26) minecraft:flame -> flame
|
||||
rewrite(21), // (24->21) minecraft:happy_villager -> happyVillager
|
||||
rewrite(34), // (25->34) minecraft:heart -> heart
|
||||
rewrite(14), // (26->14) minecraft:instant_effect -> instantSpell
|
||||
rewrite(36, new ParticleHandler() {
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
return rewrite(protocol, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
return rewrite(protocol, (Item) data.get(0).getValue());
|
||||
}
|
||||
|
||||
private int[] rewrite(Protocol1_12_2To1_13 protocol, Item newItem) {
|
||||
Item item = protocol.getItemRewriter().handleItemToClient(newItem);
|
||||
return new int[]{item.identifier(), item.data()};
|
||||
}
|
||||
}), // (27->36) minecraft:item -> iconcrack
|
||||
rewrite(33), // (28->33) minecraft:item_slime -> slime
|
||||
rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof
|
||||
rewrite(12), // (30->12) minecraft:large_smoke -> largesmoke
|
||||
rewrite(27), // (31->27) minecraft:lava -> lava
|
||||
rewrite(22), // (32->22) minecraft:mycelium -> townaura
|
||||
rewrite(23), // (33->23) minecraft:note -> note
|
||||
rewrite(0), // (34->0) minecraft:poof -> explode
|
||||
rewrite(24), // (35->24) minecraft:portal -> portal
|
||||
rewrite(39), // (36->39) minecraft:rain -> droplet
|
||||
rewrite(11), // (37->11) minecraft:smoke -> smoke
|
||||
rewrite(48), // (38->48) minecraft:spit -> spit
|
||||
rewrite(12), // (39->-1) minecraft:squid_ink -> squid_ink -> large_smoke
|
||||
rewrite(45), // (40->45) minecraft:sweep_attack -> sweepAttack
|
||||
rewrite(47), // (41->47) minecraft:totem_of_undying -> totem
|
||||
rewrite(7), // (42->7) minecraft:underwater -> suspended
|
||||
rewrite(5), // (43->5) minecraft:splash -> splash
|
||||
rewrite(17), // (44->17) minecraft:witch -> witchMagic
|
||||
rewrite(4), // (45->4) minecraft:bubble_pop -> bubble
|
||||
rewrite(4), // (46->4) minecraft:current_down -> bubble
|
||||
rewrite(4), // (47->4) minecraft:bubble_column_up -> bubble
|
||||
rewrite(18), // (48->-1) minecraft:nautilus -> nautilus -> dripWater
|
||||
rewrite(18), // (49->18) minecraft:dolphin -> dripWater
|
||||
};
|
||||
}
|
||||
|
||||
public static ParticleData getMapping(int id) {
|
||||
return particles[id];
|
||||
}
|
||||
|
||||
private static ParticleData rewrite(int replacementId) {
|
||||
return new ParticleData(replacementId);
|
||||
}
|
||||
|
||||
private static ParticleData rewrite(int replacementId, ParticleHandler handler) {
|
||||
return new ParticleData(replacementId, handler);
|
||||
}
|
||||
|
||||
public interface ParticleHandler {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
|
||||
|
||||
default boolean isBlockHandler() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ParticleData {
|
||||
private final int historyId;
|
||||
private final ParticleHandler handler;
|
||||
|
||||
private ParticleData(int historyId, ParticleHandler handler) {
|
||||
this.historyId = historyId;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private ParticleData(int historyId) {
|
||||
this(historyId, null);
|
||||
}
|
||||
|
||||
public int[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||
if (handler == null) return null;
|
||||
return handler.rewrite(protocol, wrapper);
|
||||
}
|
||||
|
||||
public int[] rewriteMeta(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data) {
|
||||
if (handler == null) return null;
|
||||
return handler.rewrite(protocol, data);
|
||||
}
|
||||
|
||||
public int getHistoryId() {
|
||||
return historyId;
|
||||
}
|
||||
|
||||
public ParticleHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1018
File diff suppressed because it is too large.
Load diff
+412
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
public EntityPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_POSITION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.FLOAT);
|
||||
map(Type.FLOAT);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
|
||||
PlayerPositionStorage1_13 playerStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
byte bitField = wrapper.get(Type.BYTE, 0);
|
||||
playerStorage.setX(toSet(bitField, 0, playerStorage.getX(), wrapper.get(Type.DOUBLE, 0)));
|
||||
playerStorage.setY(toSet(bitField, 1, playerStorage.getY(), wrapper.get(Type.DOUBLE, 1)));
|
||||
playerStorage.setZ(toSet(bitField, 2, playerStorage.getZ(), wrapper.get(Type.DOUBLE, 2)));
|
||||
}
|
||||
|
||||
private double toSet(int field, int bitIndex, double origin, double packetValue) {
|
||||
// If bit is set, coordinate is relative
|
||||
return (field & (1 << bitIndex)) != 0 ? origin + packetValue : packetValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.BYTE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.BYTE);
|
||||
map(Type.BYTE);
|
||||
map(Type.INT);
|
||||
|
||||
handler(getObjectTrackerHandler());
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Optional<Entity1_13Types.ObjectType> optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (!optionalType.isPresent()) return;
|
||||
|
||||
Entity1_13Types.ObjectType type = optionalType.get();
|
||||
if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState);
|
||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
switch (data) {
|
||||
case 3:
|
||||
data = 0;
|
||||
break;
|
||||
case 4:
|
||||
data = 1;
|
||||
break;
|
||||
case 5:
|
||||
data = 3;
|
||||
break;
|
||||
}
|
||||
wrapper.set(Type.INT, 0, data);
|
||||
} else if (type == Entity1_13Types.ObjectType.TRIDENT) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) Entity1_13Types.ObjectType.TIPPED_ARROW.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.BYTE);
|
||||
map(Type.BYTE);
|
||||
map(Type.BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
|
||||
int oldId = EntityTypeMapping.getOldId(type);
|
||||
if (oldId == -1) {
|
||||
if (!hasData(entityType)) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.12 entity type for 1.13 entity type " + type + "/" + entityType);
|
||||
}
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 1, oldId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(getMobSpawnRewriter(Types1_12.METADATA_LIST));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.BYTE);
|
||||
map(Type.BYTE);
|
||||
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_13Types.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
|
||||
handler(getTrackerHandler(Entity1_13Types.EntityType.PAINTING, Type.VAR_INT));
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int motive = wrapper.read(Type.VAR_INT);
|
||||
String title = PaintingMapping.getStringId(motive);
|
||||
wrapper.write(Type.STRING, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(getDimensionHandler(0));
|
||||
handler(wrapper -> wrapper.user().get(BackwardsBlockStorage.class).clear());
|
||||
}
|
||||
});
|
||||
|
||||
registerRemoveEntities(ClientboundPackets1_13.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
// Face Player (new packet)
|
||||
protocol.registerClientbound(ClientboundPackets1_13.FACE_PLAYER, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
|
||||
// We will just accept a possible, very minor mismatch between server and client position,
|
||||
// and will take the server's one in both cases, else we would have to cache all entities' positions.
|
||||
final int anchor = wrapper.read(Type.VAR_INT); // feet/eyes enum
|
||||
final double x = wrapper.read(Type.DOUBLE);
|
||||
final double y = wrapper.read(Type.DOUBLE);
|
||||
final double z = wrapper.read(Type.DOUBLE);
|
||||
|
||||
PlayerPositionStorage1_13 positionStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
|
||||
// Send teleport packet to client
|
||||
PacketWrapper positionAndLook = wrapper.create(ClientboundPackets1_12_1.PLAYER_POSITION);
|
||||
positionAndLook.write(Type.DOUBLE, 0D);
|
||||
positionAndLook.write(Type.DOUBLE, 0D);
|
||||
positionAndLook.write(Type.DOUBLE, 0D);
|
||||
|
||||
//TODO properly cache and calculate head position?
|
||||
EntityPositionHandler.writeFacingDegrees(positionAndLook, positionStorage.getX(),
|
||||
anchor == 1 ? positionStorage.getY() + 1.62 : positionStorage.getY(),
|
||||
positionStorage.getZ(), x, y, z);
|
||||
|
||||
positionAndLook.write(Type.BYTE, (byte) 7); // bitfield, 0=absolute, 1=relative - x,y,z relative, yaw,pitch absolute
|
||||
positionAndLook.write(Type.VAR_INT, -1);
|
||||
positionAndLook.send(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer()) {
|
||||
PacketRemapper movementRemapper = new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
handler(wrapper -> wrapper.user().get(PlayerPositionStorage1_13.class).setCoordinates(wrapper, false));
|
||||
}
|
||||
};
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLAYER_POSITION, movementRemapper); // Player Position
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLAYER_POSITION_AND_ROTATION, movementRemapper); // Player Position And Look (serverbound)
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.VEHICLE_MOVE, movementRemapper); // Vehicle Move (serverbound)
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Rewrite new Entity 'drowned'
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).mobName("Drowned");
|
||||
|
||||
// Fishy
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.COD, Entity1_13Types.EntityType.SQUID).mobName("Cod");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.SALMON, Entity1_13Types.EntityType.SQUID).mobName("Salmon");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PUFFERFISH, Entity1_13Types.EntityType.SQUID).mobName("Puffer Fish");
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TROPICAL_FISH, Entity1_13Types.EntityType.SQUID).mobName("Tropical Fish");
|
||||
|
||||
// Phantom
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).mobName("Phantom").spawnMetadata(storage -> {
|
||||
// The phantom is grey/blue so let's do yellow/blue
|
||||
storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
|
||||
});
|
||||
|
||||
// Dolphin
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).mobName("Dolphin");
|
||||
|
||||
// Turtle
|
||||
mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).mobName("Turtle");
|
||||
|
||||
// Rewrite Meta types
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
|
||||
// Rewrite optional chat to string
|
||||
if (typeId == 5) {
|
||||
// Json -> Legacy is done below
|
||||
meta.setTypeAndValue(MetaType1_12.String, meta.getValue() != null ? meta.getValue().toString() : "");
|
||||
}
|
||||
|
||||
// Rewrite items
|
||||
else if (typeId == 6) {
|
||||
Item item = (Item) meta.getValue();
|
||||
meta.setTypeAndValue(MetaType1_12.Slot, protocol.getItemRewriter().handleItemToClient(item));
|
||||
}
|
||||
|
||||
// Discontinue particles
|
||||
else if (typeId == 15) {
|
||||
event.cancel();
|
||||
}
|
||||
|
||||
// Rewrite to 1.12 ids
|
||||
else if (typeId > 5) {
|
||||
meta.setMetaType(MetaType1_12.byId(
|
||||
typeId - 1
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Rewrite Custom Name from Chat to String
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ENTITY).index(2).handler((event, meta) -> {
|
||||
String value = meta.getValue().toString();
|
||||
if (!value.isEmpty()) {
|
||||
meta.setValue(ChatRewriter.jsonToLegacyText(value));
|
||||
}
|
||||
});
|
||||
|
||||
// Handle zombie metadata
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ZOMBIE).removeIndex(15);
|
||||
|
||||
// Handle turtle metadata (Remove them all for now)
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(13); // Home pos
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(14); // Has egg
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(15); // Laying egg
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(16); // Travel pos
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(17); // Going home
|
||||
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(18); // Traveling
|
||||
|
||||
// Remove additional fish meta
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(12);
|
||||
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(13);
|
||||
|
||||
// Remove phantom size
|
||||
filter().type(Entity1_13Types.EntityType.PHANTOM).cancel(12);
|
||||
|
||||
// Remove boat splash timer
|
||||
filter().type(Entity1_13Types.EntityType.BOAT).cancel(12);
|
||||
|
||||
// Remove Trident special loyalty level
|
||||
filter().type(Entity1_13Types.EntityType.TRIDENT).cancel(7);
|
||||
|
||||
// Handle new wolf colors
|
||||
filter().type(Entity1_13Types.EntityType.WOLF).index(17).handler((event, meta) -> {
|
||||
meta.setValue(15 - (int) meta.getValue());
|
||||
});
|
||||
|
||||
// Rewrite AreaEffectCloud
|
||||
filter().type(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
|
||||
ParticleMapping.ParticleData data = ParticleMapping.getMapping(particle.getId());
|
||||
|
||||
int firstArg = 0;
|
||||
int secondArg = 0;
|
||||
int[] particleArgs = data.rewriteMeta(protocol, particle.getArguments());
|
||||
if (particleArgs != null && particleArgs.length != 0) {
|
||||
if (data.getHandler().isBlockHandler() && particleArgs[0] == 0) {
|
||||
// Air doesn't have a break particle for sub 1.13 clients -> glass pane
|
||||
particleArgs[0] = 102;
|
||||
}
|
||||
|
||||
firstArg = particleArgs[0];
|
||||
secondArg = particleArgs.length == 2 ? particleArgs[1] : 0;
|
||||
}
|
||||
|
||||
event.createExtraMeta(new Metadata(9, MetaType1_12.VarInt, data.getHistoryId()));
|
||||
event.createExtraMeta(new Metadata(10, MetaType1_12.VarInt, firstArg));
|
||||
event.createExtraMeta(new Metadata(11, MetaType1_12.VarInt, secondArg));
|
||||
|
||||
event.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return Entity1_13Types.getTypeFromId(typeId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getObjectTypeFromId(final int typeId) {
|
||||
return Entity1_13Types.getTypeFromId(typeId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int newEntityId(final int newId) {
|
||||
return EntityTypeMapping.getOldId(newId);
|
||||
}
|
||||
}
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import com.viaversion.viabackwards.utils.ChatUtil;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
|
||||
private final CommandRewriter commandRewriter = new CommandRewriter(protocol) {
|
||||
};
|
||||
|
||||
public PlayerPacket1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Login Plugin Request
|
||||
protocol.registerClientbound(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.cancel();
|
||||
packetWrapper.create(0x02, new PacketHandler() { // Plugin response
|
||||
@Override
|
||||
public void handle(PacketWrapper newWrapper) throws Exception {
|
||||
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||
}
|
||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
if (channel.equals("minecraft:trader_list")) {
|
||||
wrapper.write(Type.STRING, "MC|TrList");
|
||||
wrapper.passthrough(Type.INT); //Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
//Input Item
|
||||
Item input = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input));
|
||||
//Output Item
|
||||
Item output = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output));
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||
wrapper.passthrough(Type.INT); //Number of tools uses
|
||||
wrapper.passthrough(Type.INT); //Maximum number of trade uses
|
||||
}
|
||||
} else {
|
||||
String oldChannel = InventoryPackets.getOldPluginChannelId(channel);
|
||||
if (oldChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring outgoing plugin message with channel: " + channel);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
wrapper.write(Type.STRING, oldChannel);
|
||||
|
||||
if (oldChannel.equals("REGISTER") || oldChannel.equals("UNREGISTER")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (String s : channels) {
|
||||
String rewritten = InventoryPackets.getOldPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
map(Type.FLOAT); // 3 - Y
|
||||
map(Type.FLOAT); // 4 - Z
|
||||
map(Type.FLOAT); // 5 - Offset X
|
||||
map(Type.FLOAT); // 6 - Offset Y
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ParticleMapping.ParticleData old = ParticleMapping.getMapping(wrapper.get(Type.INT, 0));
|
||||
wrapper.set(Type.INT, 0, old.getHistoryId());
|
||||
|
||||
int[] data = old.rewriteData(protocol, wrapper);
|
||||
if (data != null) {
|
||||
if (old.getHandler().isBlockHandler() && data[0] == 0) {
|
||||
// Cancel air block particles
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i : data) {
|
||||
wrapper.write(Type.VAR_INT, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
TabCompleteStorage storage = packetWrapper.user().get(TabCompleteStorage.class);
|
||||
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||
int nPlayers = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < nPlayers; i++) {
|
||||
UUID uuid = packetWrapper.passthrough(Type.UUID);
|
||||
if (action == 0) { // Add
|
||||
String name = packetWrapper.passthrough(Type.STRING);
|
||||
storage.usernames().put(uuid, name);
|
||||
int nProperties = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < nProperties; j++) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
}
|
||||
}
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 1) { // Update Game Mode
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 2) { // Update Ping
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 3) { // Update Display Name
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 4) { // Remove Player
|
||||
storage.usernames().remove(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte mode = wrapper.get(Type.BYTE, 0);
|
||||
if (mode == 0 || mode == 2) {
|
||||
String value = wrapper.read(Type.COMPONENT).toString();
|
||||
value = ChatRewriter.jsonToLegacyText(value);
|
||||
if (value.length() > 32) {
|
||||
value = value.substring(0, 32);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, value);
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte action = wrapper.get(Type.BYTE, 0);
|
||||
if (action == 0 || action == 2) {
|
||||
String displayName = wrapper.read(Type.STRING);
|
||||
displayName = ChatRewriter.jsonToLegacyText(displayName);
|
||||
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
}
|
||||
wrapper.write(Type.STRING, displayName);
|
||||
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String nameTagVisibility = wrapper.read(Type.STRING);
|
||||
String collisionRule = wrapper.read(Type.STRING);
|
||||
|
||||
int colour = wrapper.read(Type.VAR_INT);
|
||||
if (colour == 21) {
|
||||
colour = -1;
|
||||
}
|
||||
|
||||
JsonElement prefixComponent = wrapper.read(Type.COMPONENT);
|
||||
JsonElement suffixComponent = wrapper.read(Type.COMPONENT);
|
||||
|
||||
String prefix = prefixComponent == null || prefixComponent.isJsonNull() ? "" : ChatRewriter.jsonToLegacyText(prefixComponent.toString());
|
||||
if (ViaBackwards.getConfig().addTeamColorTo1_13Prefix()) {
|
||||
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
||||
}
|
||||
|
||||
prefix = ChatUtil.removeUnusedColor(prefix, 'f', true);
|
||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||
|
||||
String suffix = suffixComponent == null || suffixComponent.isJsonNull() ? "" : ChatRewriter.jsonToLegacyText(suffixComponent.toString());
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, '\0'); // Don't remove white coloring
|
||||
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
|
||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||
|
||||
wrapper.write(Type.STRING, prefix);
|
||||
wrapper.write(Type.STRING, suffix);
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
wrapper.write(Type.STRING, nameTagVisibility);
|
||||
wrapper.write(Type.STRING, collisionRule);
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) colour);
|
||||
}
|
||||
|
||||
if (action == 0 || action == 3 || action == 4) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); //Entities
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_COMMANDS, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
|
||||
if (!storage.commands().isEmpty()) {
|
||||
storage.commands().clear();
|
||||
}
|
||||
|
||||
int size = wrapper.read(Type.VAR_INT);
|
||||
boolean initialNodes = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices
|
||||
if ((flags & 0x08) != 0) {
|
||||
wrapper.read(Type.VAR_INT); // Redirect node index
|
||||
}
|
||||
|
||||
byte nodeType = (byte) (flags & 0x03);
|
||||
if (initialNodes && nodeType == 2) {
|
||||
initialNodes = false;
|
||||
}
|
||||
|
||||
if (nodeType == 1 || nodeType == 2) { // Literal/argument node
|
||||
String name = wrapper.read(Type.STRING);
|
||||
if (nodeType == 1 && initialNodes) {
|
||||
storage.commands().add('/' + name);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeType == 2) { // Argument node
|
||||
commandRewriter.handleArgument(wrapper, wrapper.read(Type.STRING));
|
||||
}
|
||||
|
||||
if ((flags & 0x10) != 0) {
|
||||
wrapper.read(Type.STRING); // Suggestion type
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
if (storage.lastRequest() == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
if (storage.lastId() != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||
int start = wrapper.read(Type.VAR_INT);
|
||||
int length = wrapper.read(Type.VAR_INT);
|
||||
|
||||
int lastRequestPartIndex = storage.lastRequest().lastIndexOf(' ') + 1;
|
||||
if (lastRequestPartIndex != start) wrapper.cancel(); // Client only replaces after space
|
||||
|
||||
if (length != storage.lastRequest().length() - lastRequestPartIndex) {
|
||||
wrapper.cancel(); // We can't set the length in previous versions
|
||||
}
|
||||
|
||||
int count = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String match = wrapper.read(Type.STRING);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.isLastAssumeCommand() ? "/" : "") + match);
|
||||
// Ignore tooltip
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
|
||||
String command = wrapper.read(Type.STRING);
|
||||
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.OPTIONAL_POSITION);
|
||||
|
||||
if (!assumeCommand && !command.startsWith("/")) {
|
||||
// Complete usernames for non-commands
|
||||
String buffer = command.substring(command.lastIndexOf(' ') + 1);
|
||||
for (String value : storage.usernames().values()) {
|
||||
if (startsWithIgnoreCase(value, buffer)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
}
|
||||
} else if (!storage.commands().isEmpty() && !command.contains(" ")) {
|
||||
// Complete commands names with values from 'Declare Commands' packet
|
||||
for (String value : storage.commands()) {
|
||||
if (startsWithIgnoreCase(value, command)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!suggestions.isEmpty()) {
|
||||
wrapper.cancel();
|
||||
PacketWrapper response = wrapper.create(ClientboundPackets1_12_1.TAB_COMPLETE);
|
||||
response.write(Type.VAR_INT, suggestions.size());
|
||||
for (String value : suggestions) {
|
||||
response.write(Type.STRING, value);
|
||||
}
|
||||
response.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
storage.setLastRequest(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!assumeCommand && command.startsWith("/")) {
|
||||
command = command.substring(1);
|
||||
}
|
||||
|
||||
int id = ThreadLocalRandom.current().nextInt();
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
wrapper.write(Type.STRING, command);
|
||||
|
||||
storage.setLastId(id);
|
||||
storage.setLastAssumeCommand(assumeCommand);
|
||||
storage.setLastRequest(command);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
switch (channel) {
|
||||
case "MC|BSign":
|
||||
case "MC|BEdit":
|
||||
wrapper.setId(0x0B);
|
||||
Item book = wrapper.read(Type.ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, protocol.getItemRewriter().handleItemToServer(book));
|
||||
boolean signing = channel.equals("MC|BSign");
|
||||
wrapper.write(Type.BOOLEAN, signing);
|
||||
break;
|
||||
case "MC|ItemName":
|
||||
wrapper.setId(0x1C);
|
||||
break;
|
||||
case "MC|AdvCmd":
|
||||
byte type = wrapper.read(Type.BYTE);
|
||||
if (type == 0) {
|
||||
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||
//The Notchain client only uses this for command block minecarts and uses MC|AutoCmd for blocks, but the Notchian server still accepts it for either.
|
||||
//Maybe older versions used this and we need to implement this? The issues is that we would have to save the command block types
|
||||
wrapper.setId(0x22);
|
||||
wrapper.cancel();
|
||||
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||
} else if (type == 1) {
|
||||
wrapper.setId(0x23);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Entity Id
|
||||
wrapper.passthrough(Type.STRING); //Command
|
||||
wrapper.passthrough(Type.BOOLEAN); //Track Output
|
||||
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
break;
|
||||
case "MC|AutoCmd": {
|
||||
wrapper.setId(0x22);
|
||||
|
||||
int x = wrapper.read(Type.INT);
|
||||
int y = wrapper.read(Type.INT);
|
||||
int z = wrapper.read(Type.INT);
|
||||
|
||||
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
|
||||
|
||||
wrapper.passthrough(Type.STRING); //Command
|
||||
|
||||
byte flags = 0;
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Track Output
|
||||
|
||||
String mode = wrapper.read(Type.STRING);
|
||||
|
||||
int modeId = mode.equals("SEQUENCE") ? 0 : mode.equals("AUTO") ? 1 : 2;
|
||||
wrapper.write(Type.VAR_INT, modeId);
|
||||
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x02; //Is conditional
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Automatic
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
break;
|
||||
}
|
||||
case "MC|Struct": {
|
||||
wrapper.setId(0x25);
|
||||
int x = wrapper.read(Type.INT);
|
||||
int y = wrapper.read(Type.INT);
|
||||
int z = wrapper.read(Type.INT);
|
||||
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.BYTE) - 1);
|
||||
String mode = wrapper.read(Type.STRING);
|
||||
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;
|
||||
wrapper.write(Type.VAR_INT, modeId);
|
||||
wrapper.passthrough(Type.STRING); //Name
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset X
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Y
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Z
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size X
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Y
|
||||
|
||||
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Z
|
||||
|
||||
String mirror = wrapper.read(Type.STRING);
|
||||
int mirrorId = mode.equals("NONE") ? 0 : mode.equals("LEFT_RIGHT") ? 1 : 2;
|
||||
String rotation = wrapper.read(Type.STRING);
|
||||
int rotationId = mode.equals("NONE") ? 0 : mode.equals("CLOCKWISE_90") ? 1 : mode.equals("CLOCKWISE_180") ? 2 : 3;
|
||||
wrapper.passthrough(Type.STRING); //Metadata
|
||||
|
||||
byte flags = 0;
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Ignore entities
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x02; //Show air
|
||||
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Show bounding box
|
||||
wrapper.passthrough(Type.FLOAT); //Integrity
|
||||
|
||||
wrapper.passthrough(Type.VAR_LONG); //Seed
|
||||
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
break;
|
||||
}
|
||||
case "MC|Beacon":
|
||||
wrapper.setId(0x20);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Primary Effect
|
||||
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Secondary Effect
|
||||
|
||||
break;
|
||||
case "MC|TrSel":
|
||||
wrapper.setId(0x1F);
|
||||
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Slot
|
||||
|
||||
break;
|
||||
case "MC|PickItem":
|
||||
wrapper.setId(0x15);
|
||||
break;
|
||||
default:
|
||||
String newChannel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
if (newChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring incoming plugin message with channel: " + channel);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
wrapper.write(Type.STRING, newChannel);
|
||||
|
||||
if (newChannel.equals("minecraft:register") || newChannel.equals("minecraft:unregister")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (String s : channels) {
|
||||
String rewritten = InventoryPackets.getNewPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
if (!rewrittenChannels.isEmpty()) {
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STATISTICS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int size = wrapper.get(Type.VAR_INT, 0);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int categoryId = wrapper.read(Type.VAR_INT);
|
||||
int statisticId = wrapper.read(Type.VAR_INT);
|
||||
|
||||
String name = "";
|
||||
// categories 0-7 (items, blocks, entities) - probably not feasible
|
||||
switch (categoryId) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
wrapper.read(Type.VAR_INT); // remove value
|
||||
newSize--;
|
||||
continue;
|
||||
case 8:
|
||||
name = protocol.getMappingData().getStatisticMappings().get(statisticId);
|
||||
if (name == null) {
|
||||
wrapper.read(Type.VAR_INT);
|
||||
newSize--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, name); // string id
|
||||
wrapper.passthrough(Type.VAR_INT); // value
|
||||
}
|
||||
|
||||
if (newSize != size) {
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean startsWithIgnoreCase(String string, String prefix) {
|
||||
if (string.length() < prefix.length()) {
|
||||
return false;
|
||||
}
|
||||
return string.regionMatches(true, 0, prefix, 0, prefix.length());
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class SoundPackets1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
|
||||
|
||||
public SoundPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
handler(wrapper -> {
|
||||
String newSound = wrapper.get(Type.STRING, 0);
|
||||
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||
if (oldSound != null || (oldSound = protocol.getMappingData().getMappedNamedSound(newSound)) != null) {
|
||||
wrapper.set(Type.STRING, 0, oldSound);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown named sound in 1.13->1.12 protocol: " + newSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Stop Sound -> Plugin Message
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STOP_SOUND, ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|StopSound");
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String source;
|
||||
if ((flags & 0x01) != 0) {
|
||||
source = SOUND_SOURCES[wrapper.read(Type.VAR_INT)];
|
||||
} else {
|
||||
source = "";
|
||||
}
|
||||
|
||||
String sound;
|
||||
if ((flags & 0x02) != 0) {
|
||||
String newSound = wrapper.read(Type.STRING);
|
||||
sound = protocol.getMappingData().getMappedNamedSound(newSound);
|
||||
if (sound == null) {
|
||||
sound = "";
|
||||
}
|
||||
} else {
|
||||
sound = "";
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, source);
|
||||
wrapper.write(Type.STRING, sound);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||
int oldSound = protocol.getMappingData().getSoundMappings().getNewId(newSound);
|
||||
if (oldSound == -1) {
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 0, oldSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BannerHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.BedHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.PistonHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.SkullHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.SpawnerHandler;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsBlockEntityProvider implements Provider {
|
||||
private final Map<String, BackwardsBlockEntityProvider.BackwardsBlockEntityHandler> handlers = new HashMap<>();
|
||||
|
||||
public BackwardsBlockEntityProvider() {
|
||||
handlers.put("minecraft:flower_pot", new FlowerPotHandler()); // TODO requires special treatment, manually send
|
||||
handlers.put("minecraft:bed", new BedHandler());
|
||||
handlers.put("minecraft:banner", new BannerHandler());
|
||||
handlers.put("minecraft:skull", new SkullHandler());
|
||||
handlers.put("minecraft:mob_spawner", new SpawnerHandler());
|
||||
handlers.put("minecraft:piston", new PistonHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block entity handler is present
|
||||
*
|
||||
* @param key Id of the NBT data ex: minecraft:bed
|
||||
* @return true if present
|
||||
*/
|
||||
public boolean isHandled(String key) {
|
||||
return handlers.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform blocks to block entities!
|
||||
*
|
||||
* @param user The user
|
||||
* @param position The position of the block entity
|
||||
* @param tag The block entity tag
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||
if (handler == null) {
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
BackwardsBlockStorage storage = user.get(BackwardsBlockStorage.class);
|
||||
Integer blockId = storage.get(position);
|
||||
if (blockId == null) {
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
return handler.transform(user, blockId, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform blocks to block entities!
|
||||
*
|
||||
* @param user The user
|
||||
* @param position The position of the block entity
|
||||
* @param id The block entity id
|
||||
*/
|
||||
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("id", new StringTag(id));
|
||||
tag.put("x", new IntTag(Math.toIntExact(position.getX())));
|
||||
tag.put("y", new IntTag(Math.toIntExact(position.getY())));
|
||||
tag.put("z", new IntTag(Math.toIntExact(position.getZ())));
|
||||
|
||||
return this.transform(user, position, tag);
|
||||
}
|
||||
|
||||
public interface BackwardsBlockEntityHandler {
|
||||
CompoundTag transform(UserConnection user, int blockId, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BackwardsBlockStorage implements StorableObject {
|
||||
// This BlockStorage is very exclusive (;
|
||||
private static final IntSet WHITELIST = new IntOpenHashSet(779);
|
||||
|
||||
static {
|
||||
// Flower pots
|
||||
for (int i = 5265; i <= 5286; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
|
||||
// Add those beds
|
||||
for (int i = 0; i < (16 * 16); i++) {
|
||||
WHITELIST.add(748 + i);
|
||||
}
|
||||
|
||||
// Add the banners
|
||||
for (int i = 6854; i <= 7173; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
|
||||
// Spawner
|
||||
WHITELIST.add(1647);
|
||||
|
||||
// Skulls
|
||||
for (int i = 5447; i <= 5566; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
|
||||
// pistons
|
||||
for (int i = 1028; i <= 1039; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
for (int i = 1047; i <= 1082; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
for (int i = 1099; i <= 1110; i++) {
|
||||
WHITELIST.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<Position, Integer> blocks = new ConcurrentHashMap<>();
|
||||
|
||||
public void checkAndStore(Position position, int block) {
|
||||
if (!WHITELIST.contains(block)) {
|
||||
// Remove if not whitelisted
|
||||
blocks.remove(position);
|
||||
return;
|
||||
}
|
||||
|
||||
blocks.put(position, block);
|
||||
}
|
||||
|
||||
public boolean isWelcome(int block) {
|
||||
return WHITELIST.contains(block);
|
||||
}
|
||||
|
||||
public Integer get(Position position) {
|
||||
return blocks.get(position);
|
||||
}
|
||||
|
||||
public int remove(Position position) {
|
||||
return blocks.remove(position);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
blocks.clear();
|
||||
}
|
||||
|
||||
public Map<Position, Integer> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
||||
|
||||
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
||||
|
||||
public PlayerPositionStorage1_13() {
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TabCompleteStorage implements StorableObject {
|
||||
private final Map<UUID, String> usernames = new HashMap<>();
|
||||
private final Set<String> commands = new HashSet<>();
|
||||
private int lastId;
|
||||
private String lastRequest;
|
||||
private boolean lastAssumeCommand;
|
||||
|
||||
public Map<UUID, String> usernames() {
|
||||
return usernames;
|
||||
}
|
||||
|
||||
public Set<String> commands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public int lastId() {
|
||||
return lastId;
|
||||
}
|
||||
|
||||
public void setLastId(final int lastId) {
|
||||
this.lastId = lastId;
|
||||
}
|
||||
|
||||
public String lastRequest() {
|
||||
return lastRequest;
|
||||
}
|
||||
|
||||
public void setLastRequest(String lastRequest) {
|
||||
this.lastRequest = lastRequest;
|
||||
}
|
||||
|
||||
public boolean isLastAssumeCommand() {
|
||||
return lastAssumeCommand;
|
||||
}
|
||||
|
||||
public void setLastAssumeCommand(boolean lastAssumeCommand) {
|
||||
this.lastAssumeCommand = lastAssumeCommand;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion 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.viaversion.viabackwards.protocol.protocol1_12to1_12_1;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
|
||||
public class Protocol1_12To1_12_1 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12, ServerboundPackets1_12_1, ServerboundPackets1_12> {
|
||||
|
||||
public Protocol1_12To1_12_1() {
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
cancelClientbound(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE);
|
||||
cancelServerbound(ServerboundPackets1_12.PREPARE_CRAFTING_GRID);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 209 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user