mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be0a6819ac | ||
|
|
82a7ee1416 | ||
|
|
b4feee8046 | ||
|
|
df8954869a | ||
|
|
8a552136a2 | ||
|
|
34ec627457 | ||
|
|
28dd76ebbf | ||
|
|
b639bcb5c7 | ||
|
|
7538cf5501 | ||
|
|
1112819fc8 | ||
|
|
cdd38270e9 | ||
|
|
20e309c339 | ||
|
|
5f87bde00e | ||
|
|
a4e574fa6b | ||
|
|
ec7cb00f86 | ||
|
|
ebe375dac0 | ||
|
|
4a2572d545 | ||
|
|
55db597baa | ||
|
|
c24d05173f | ||
|
|
d711982a1c | ||
|
|
8a38416e0f | ||
|
|
a784bdb0d0 | ||
|
|
dc9a7f6ad5 | ||
|
|
417798f2eb | ||
|
|
394e76eed3 | ||
|
|
9e476551be | ||
|
|
1dc421e6a4 | ||
|
|
e431bb1caa | ||
|
|
8bd517ca91 | ||
|
|
69ddf58600 | ||
|
|
1e040c9f1f | ||
|
|
11bdf592c8 | ||
|
|
f4a827ab01 | ||
|
|
827ca83cfd | ||
|
|
e9f8acd191 | ||
|
|
febfd5ab62 | ||
|
|
4ca2a8058f | ||
|
|
4acafcccfd | ||
|
|
937b719e24 | ||
|
|
2b5bfd923c | ||
|
|
249aaa5806 | ||
|
|
46f57e6a9a | ||
|
|
cfd79130de | ||
|
|
6a25c99097 | ||
|
|
95be0d87d9 | ||
|
|
6125ec3bc8 | ||
|
|
9944a8252a | ||
|
|
fd544dd414 | ||
|
|
c00777e6ea | ||
|
|
b2cea78006 | ||
|
|
79272361f0 | ||
|
|
fe4be54774 | ||
|
|
eecb8cc783 | ||
|
|
5e2e404828 | ||
|
|
96303f6570 | ||
|
|
166feefc02 | ||
|
|
cd67762bee | ||
|
|
347a0b3c0d | ||
|
|
be1698bb15 | ||
|
|
a3e9d7a397 | ||
|
|
b2dbe9de51 | ||
|
|
a31adc2823 | ||
|
|
30a33f5c3e | ||
|
|
b01a217f45 | ||
|
|
69136fce19 | ||
|
|
ee21224fff | ||
|
|
804f390064 | ||
|
|
ca2023fa80 | ||
|
|
4e562664f4 | ||
|
|
c8d3ad1d1c | ||
|
|
b7379953d5 | ||
|
|
9d7f5dd32a | ||
|
|
049ed79e7b | ||
|
|
675bf8bde2 | ||
|
|
8dc58ad469 | ||
|
|
827c963d7e | ||
|
|
2ac616b293 | ||
|
|
dcfbc08504 | ||
|
|
19f470ee8c | ||
|
|
a96d078a7a | ||
|
|
b375da6962 | ||
|
|
d17f10d80c | ||
|
|
a336e443f7 | ||
|
|
c5a1c90366 | ||
|
|
95c0aa1e98 | ||
|
|
559b801cc4 | ||
|
|
aa97ddad8b | ||
|
|
d612dc3a6d | ||
|
|
9165d4c3a1 | ||
|
|
12d0f96fc2 | ||
|
|
bec9d6f534 | ||
|
|
892c3669e0 | ||
|
|
ce13efbac9 | ||
|
|
1018b077dc | ||
|
|
9746db5129 | ||
|
|
c4de1f33ba | ||
|
|
a8a4623d24 | ||
|
|
10b51f257f | ||
|
|
52d7df06da | ||
|
|
fcc819584a | ||
|
|
4721d4c461 | ||
|
|
dbdc345d4a | ||
|
|
14c6fc3388 | ||
|
|
33419ed5b1 | ||
|
|
9ec1e24dc5 | ||
|
|
06804675be | ||
|
|
2f43f9910d | ||
|
|
ea9a72af85 | ||
|
|
9a92363e15 | ||
|
|
94389d0efd | ||
|
|
9080886c1a | ||
|
|
13ca55f34d | ||
|
|
5dbea18e30 | ||
|
|
30cfd848d8 | ||
|
|
80d08dbf3a | ||
|
|
7d4c238165 | ||
|
|
0ea9401d90 | ||
|
|
4bdfd8674d | ||
|
|
3e9e0a6447 | ||
|
|
76da41dd46 | ||
|
|
6ddf56ef15 | ||
|
|
eeec737188 | ||
|
|
119ac8f4ab | ||
|
|
bdf0d9cf22 | ||
|
|
bd58ced0e4 | ||
|
|
5af6649435 | ||
|
|
695e1fbb94 | ||
|
|
b027a92dd2 | ||
|
|
be5446b91c | ||
|
|
064ae6961b | ||
|
|
22d609ed6c | ||
|
|
315bbb74ff | ||
|
|
4e4d31b68c | ||
|
|
1a17fa6129 | ||
|
|
ca9df21258 | ||
|
|
93d7fa54fc | ||
|
|
f235d80d9f | ||
|
|
be34dd89a9 | ||
|
|
6663f23e13 | ||
|
|
f9f7ef2580 | ||
|
|
86352e9c19 | ||
|
|
8c8b31435b | ||
|
|
16b3e2780e | ||
|
|
1121f18413 | ||
|
|
96804fb4df | ||
|
|
03a6dbb405 | ||
|
|
77e8c72589 | ||
|
|
043e49a694 | ||
|
|
5169f1f6fe | ||
|
|
2bd83b26aa | ||
|
|
e6c1814122 | ||
|
|
7f2892de7e | ||
|
|
439ba462d6 | ||
|
|
7c6ae3e61e | ||
|
|
f9b894ecbf | ||
|
|
df53db351e | ||
|
|
9aa04c8036 | ||
|
|
626496cec0 | ||
|
|
022482a3bd | ||
|
|
dd228a9ac1 | ||
|
|
a6d1646591 | ||
|
|
39f9f393db | ||
|
|
d35784eb14 | ||
|
|
31fb15c88d | ||
|
|
29f175743b | ||
|
|
33499db93f | ||
|
|
84381553a9 | ||
|
|
2a7dde3d2e | ||
|
|
aa4f24c915 | ||
|
|
1d87831773 | ||
|
|
65e99f9b58 | ||
|
|
b98991dc70 | ||
|
|
435e65eb18 | ||
|
|
8211a5048a | ||
|
|
167f14f4a1 | ||
|
|
f332642409 | ||
|
|
77d41023b5 | ||
|
|
da2594289c | ||
|
|
6f3da80b5a | ||
|
|
474b47ea51 | ||
|
|
b6ce4fb066 | ||
|
|
1406f2bf1f | ||
|
|
5125775992 | ||
|
|
929c7b7a0b | ||
|
|
7bf02e7dcd | ||
|
|
9d0d249eaf | ||
|
|
c4b1df1fc7 | ||
|
|
b3f253df61 | ||
|
|
dc099069fa | ||
|
|
e80c785563 | ||
|
|
1f9611204f | ||
|
|
0120f6274d | ||
|
|
c0e74bc8a8 | ||
|
|
80feb0aeb2 | ||
|
|
f47429717d | ||
|
|
0239a736ec | ||
|
|
5c488c9007 | ||
|
|
53c039680c | ||
|
|
7379e8b9a4 | ||
|
|
2a0d9e8dac | ||
|
|
aacba8e38e | ||
|
|
f4fd1c2f16 | ||
|
|
813f3d630d | ||
|
|
76cea5a7da | ||
|
|
e33f794298 | ||
|
|
72d05d17a9 | ||
|
|
19f9b309a6 | ||
|
|
5b53616a47 | ||
|
|
5f9e6f3b56 | ||
|
|
0ad8e2c27f | ||
|
|
55f29764f8 | ||
|
|
a4f7087b92 | ||
|
|
a95b968c13 | ||
|
|
802298d99d | ||
|
|
5363dc5d99 | ||
|
|
9602c22083 | ||
|
|
17500032ae | ||
|
|
65bc41281f | ||
|
|
ba15737fe3 | ||
|
|
58f93263e2 | ||
|
|
d97f28141c | ||
|
|
0340664dbf | ||
|
|
d2cfda3fb4 | ||
|
|
48225e1bea | ||
|
|
37ea725749 | ||
|
|
733b812c7b | ||
|
|
9ab29ea8fe | ||
|
|
fe26b77e3b | ||
|
|
b8eca88f75 | ||
|
|
e039531497 | ||
|
|
9017e24b40 | ||
|
|
75570079ae | ||
|
|
e2167140db | ||
|
|
a89ce2d6f1 | ||
|
|
007cd42ec6 | ||
|
|
d16a8d6d5d | ||
|
|
69321a363e | ||
|
|
0e1ee4b1d2 | ||
|
|
cc1a9be2b4 | ||
|
|
1d7da4c595 | ||
|
|
1ac432c594 | ||
|
|
276871d5a3 | ||
|
|
8460227ddf | ||
|
|
f450d4025d | ||
|
|
93a815957d | ||
|
|
84b7cdc1cd | ||
|
|
83fee0b3d4 | ||
|
|
aeaebf5785 | ||
|
|
d88e660cbb | ||
|
|
ab949c7cca | ||
|
|
7728dde36b | ||
|
|
004ab59e6f | ||
|
|
7bfd2b8f34 | ||
|
|
f169c99348 | ||
|
|
d3d3bdc769 | ||
|
|
0a0f3232ea | ||
|
|
50d75a27e1 | ||
|
|
19f8d2a793 | ||
|
|
f173bde812 | ||
|
|
dd10933ab0 | ||
|
|
9ffa44f254 | ||
|
|
d8f41adf39 | ||
|
|
c3e84646db | ||
|
|
2094f99640 | ||
|
|
94f3bdaa69 | ||
|
|
7220e9d0b0 | ||
|
|
020102d87f | ||
|
|
f101700969 | ||
|
|
c4b148b84b | ||
|
|
b6a9274870 | ||
|
|
830d9699e3 | ||
|
|
fc68b81b21 | ||
|
|
2904772b16 | ||
|
|
e120b57032 | ||
|
|
b86b56260d | ||
|
|
b222b23557 | ||
|
|
8ec4253068 | ||
|
|
74ca88b7be | ||
|
|
a1119cd77a | ||
|
|
545723dc8c | ||
|
|
b64f4780c5 | ||
|
|
1c98b29087 | ||
|
|
33880331d2 | ||
|
|
74a43877e4 | ||
|
|
7542fbea48 | ||
|
|
2d9a1bc6f9 | ||
|
|
a57a240c13 | ||
|
|
b7fb6484d7 | ||
|
|
1a539ffebc | ||
|
|
27220a5ad8 | ||
|
|
e975fc8252 | ||
|
|
d85ea5a3b0 | ||
|
|
ccb7345084 | ||
|
|
93c00b67d9 | ||
|
|
cd393bbfdc | ||
|
|
fd045d4628 | ||
|
|
47e076071b | ||
|
|
a73e003dd3 | ||
|
|
949984268d | ||
|
|
114acfca3b | ||
|
|
56e538e8a9 | ||
|
|
fa46f3dd49 | ||
|
|
6ec5a8f2c1 | ||
|
|
49b596dda3 | ||
|
|
0c5ced1bbf | ||
|
|
4a09a2420d | ||
|
|
0ff8a596fc | ||
|
|
bca20ace4e | ||
|
|
f3b53001c9 | ||
|
|
15bac0eeaa | ||
|
|
1782973a29 | ||
|
|
9a4a501a95 | ||
|
|
9bbfbd5479 | ||
|
|
8c68731838 | ||
|
|
0d7f507f4e | ||
|
|
f78b943bdf | ||
|
|
160f3f88f9 | ||
|
|
45e38859ed | ||
|
|
38a5400a8c | ||
|
|
acd18455c2 | ||
|
|
5a7facc20f | ||
|
|
f54998a6b7 | ||
|
|
7d00d015f3 | ||
|
|
fed7beab89 | ||
|
|
cf3e9d1e0c | ||
|
|
749c9063af | ||
|
|
1af6632a29 | ||
|
|
7e79243bca | ||
|
|
36f9c804d9 | ||
|
|
06fe9ccda0 | ||
|
|
53eedb0f10 | ||
|
|
6e0e67b14d | ||
|
|
22f7f4649b | ||
|
|
8a77681574 | ||
|
|
6982c5dd56 | ||
|
|
7205c30ece | ||
|
|
80baad974e | ||
|
|
ae160cad12 | ||
|
|
6ff6277efa | ||
|
|
74f9ef838a | ||
|
|
395f89c973 | ||
|
|
8536521b7b | ||
|
|
b1659300e0 | ||
|
|
93226bbcff | ||
|
|
51fa230e7b | ||
|
|
5f292895cb | ||
|
|
9cfe741cea | ||
|
|
bed38d4253 | ||
|
|
37f226eda5 | ||
|
|
59b4affbe7 | ||
|
|
5477a36656 | ||
|
|
5648336893 | ||
|
|
f5b53d5d10 | ||
|
|
10448c1ac9 | ||
|
|
5243275db2 | ||
|
|
3041c2022b | ||
|
|
09be003d61 | ||
|
|
3fe5ddd68f | ||
|
|
935cb6782d | ||
|
|
9b421b54a7 | ||
|
|
6e23030595 | ||
|
|
78d69db79e | ||
|
|
9177ac1b2e | ||
|
|
248d207dbc | ||
|
|
03082c361a | ||
|
|
65372e3123 | ||
|
|
0f923fa51f | ||
|
|
d1e3567c6b | ||
|
|
af75547d37 | ||
|
|
37be3aff2d | ||
|
|
b9b17d8331 | ||
|
|
2a433a5c8c | ||
|
|
e344fd08a5 | ||
|
|
0484f695fb | ||
|
|
e55bd86dff | ||
|
|
b1247df4dc | ||
|
|
91dda36b08 | ||
|
|
ac19d1bf2b | ||
|
|
e0e0302ece | ||
|
|
6eb3e20abb | ||
|
|
738491c25d | ||
|
|
2686b7a9ab | ||
|
|
4b93e3a224 | ||
|
|
873c490470 | ||
|
|
11e3281b3f | ||
|
|
ce6c664acd | ||
|
|
c75eb9e7cf | ||
|
|
2353cd982a | ||
|
|
dbcf8bd075 | ||
|
|
9f3141ea16 | ||
|
|
c382527ba2 | ||
|
|
45f8dc5245 | ||
|
|
43391c009c | ||
|
|
15733a18e4 | ||
|
|
f68344cd7c | ||
|
|
e421ea164c | ||
|
|
178e3d244a | ||
|
|
bd5e107628 | ||
|
|
a477671c03 | ||
|
|
887bc37209 | ||
|
|
47f05a4fcd | ||
|
|
47ba5b7a89 | ||
|
|
05480843cd | ||
|
|
0e1ed8c936 | ||
|
|
edf41bda19 | ||
|
|
051416b823 | ||
|
|
84fe2cbcc4 | ||
|
|
4ff0d246ce | ||
|
|
9051021474 | ||
|
|
cc473be332 | ||
|
|
b1f73a0760 | ||
|
|
de03eb6e3c | ||
|
|
bef8c2da3d | ||
|
|
3820d1b66f | ||
|
|
7dbae7ea4a | ||
|
|
be5885155c | ||
|
|
5dac065994 | ||
|
|
1d7db95539 | ||
|
|
de24783152 | ||
|
|
bfeec0c7bd | ||
|
|
2e42340dfa | ||
|
|
16b82bb97b | ||
|
|
d76ee4edd7 | ||
|
|
cf09f3eeb9 | ||
|
|
d8eaeabf3c | ||
|
|
600e68cace | ||
|
|
625cd746ef | ||
|
|
fc000fe913 | ||
|
|
e3db429763 | ||
|
|
e803006360 | ||
|
|
07ffc890e5 | ||
|
|
5a20705f05 | ||
|
|
aaa1deeef2 | ||
|
|
50197b1fa5 | ||
|
|
797791c2af | ||
|
|
c2de232703 | ||
|
|
9118c3dd24 | ||
|
|
c6d512afe8 | ||
|
|
5037adede9 | ||
|
|
a5aca97e31 | ||
|
|
edca0c7293 | ||
|
|
132cc3659d | ||
|
|
680c4062f4 | ||
|
|
e1efab0452 | ||
|
|
bd428de4fa | ||
|
|
978b3c7fb1 | ||
|
|
fe43088c96 | ||
|
|
a3c4ffd2c1 | ||
|
|
a8e68328c4 | ||
|
|
8bad5b1f13 | ||
|
|
54b4089afd | ||
|
|
493608e1b5 | ||
|
|
0984777c98 | ||
|
|
97a2b9a448 | ||
|
|
399bc6c9c3 | ||
|
|
20702456ac | ||
|
|
b4a6d186de | ||
|
|
8f9e52c260 | ||
|
|
e62805f1d7 | ||
|
|
ff752ab14b | ||
|
|
19a38f5cb9 | ||
|
|
7592bbe87e | ||
|
|
30bad1e26d | ||
|
|
5104824a1b | ||
|
|
4ffcdaa6da | ||
|
|
95d2b6ae89 | ||
|
|
d21c05b9ea | ||
|
|
97dfcbc52b | ||
|
|
532d153d33 | ||
|
|
849e718a42 | ||
|
|
720966544d | ||
|
|
7717795f42 | ||
|
|
daa817bbdf | ||
|
|
fba168051a | ||
|
|
941b9a1d1f | ||
|
|
27798c5804 | ||
|
|
9d84b5df31 | ||
|
|
00797fdb3a | ||
|
|
8d617767ad | ||
|
|
c9f9fd01b5 | ||
|
|
2450693f7d | ||
|
|
cf7784ac4b | ||
|
|
e3137213e5 | ||
|
|
7b43b9f8c0 | ||
|
|
daa85d3c5b | ||
|
|
9e8c4c3a58 | ||
|
|
24f3ef5ffe | ||
|
|
a3edfd3748 | ||
|
|
96b9a057b7 | ||
|
|
638d1d31de | ||
|
|
00013865b0 | ||
|
|
6722e7a428 | ||
|
|
0f56b4c4ee | ||
|
|
201349f8de | ||
|
|
065ebde57e | ||
|
|
6b3f2f46fa | ||
|
|
e4ffbeb329 | ||
|
|
60ee0bcdb3 | ||
|
|
2a2306d6e1 | ||
|
|
fc3fa13bf3 | ||
|
|
aab8adb884 | ||
|
|
2ad347b043 | ||
|
|
d26e285e09 | ||
|
|
91a2b02590 | ||
|
|
a567ddaa10 | ||
|
|
68e71009f3 | ||
|
|
0227bfe9ee | ||
|
|
df57e0a1ba | ||
|
|
68ea1b654c | ||
|
|
ff86201523 | ||
|
|
8e5138da27 | ||
|
|
a690a7526a | ||
|
|
517bbc8b5b | ||
|
|
ce3d8b40cf | ||
|
|
45152c6073 | ||
|
|
46c9dec421 | ||
|
|
a0b0e6788d | ||
|
|
b00c91af3c | ||
|
|
d11a582a25 | ||
|
|
bf1a0461cb | ||
|
|
4aa53dbb00 | ||
|
|
a79e4b3722 | ||
|
|
d1016f752e | ||
|
|
ab29145328 | ||
|
|
99e7fad655 | ||
|
|
d5aa0c4a91 | ||
|
|
20d231bbed | ||
|
|
5db6f158f8 | ||
|
|
88d02712db | ||
|
|
7858abe96d | ||
|
|
b0e35f358e | ||
|
|
80d2730fec | ||
|
|
3b64ea6305 | ||
|
|
5f1a7326c7 | ||
|
|
af9bb9641b | ||
|
|
fc6b38d7f2 | ||
|
|
4887a5e0e7 | ||
|
|
97d4652f5f | ||
|
|
41a6d70aee | ||
|
|
99917e569c | ||
|
|
30227a1e28 | ||
|
|
a1110b92d0 | ||
|
|
438e3886cc | ||
|
|
fa6ca9c275 | ||
|
|
71baebcc93 | ||
|
|
e7b5dcb149 | ||
|
|
29e52e963d | ||
|
|
3dc8d2b293 | ||
|
|
29be40adec | ||
|
|
272ea75aab | ||
|
|
cbac95de0f | ||
|
|
87d89fb09a | ||
|
|
7bca3684bd | ||
|
|
6cfc88e707 | ||
|
|
8179a504cb | ||
|
|
baf32612db | ||
|
|
9cf9305fd0 | ||
|
|
4700973dff | ||
|
|
648d53ffe1 | ||
|
|
c7ed9f690e | ||
|
|
ca2ed1ff7a | ||
|
|
80eb12e59d | ||
|
|
631230b298 | ||
|
|
6d15febdb3 | ||
|
|
56397043bb | ||
|
|
469527890f | ||
|
|
2ffdfb9582 | ||
|
|
4178885e29 | ||
|
|
20f78ac724 | ||
|
|
b117722d84 | ||
|
|
2acf2110ef | ||
|
|
6345f2670c | ||
|
|
9114bec81d | ||
|
|
9ac626d2a9 | ||
|
|
457909b6d5 | ||
|
|
07b62b77e6 | ||
|
|
e374f62037 | ||
|
|
0209daec36 | ||
|
|
1b89f931eb | ||
|
|
a3e4b75c59 | ||
|
|
45b90a0d45 | ||
|
|
fd9bf64d53 | ||
|
|
5dbea9ea8d | ||
|
|
28f7b5d885 | ||
|
|
0c0603dc91 | ||
|
|
f24991f3bb | ||
|
|
a39f1cbe1a | ||
|
|
6fd01a13ee | ||
|
|
6829324f5a | ||
|
|
eb9c966095 | ||
|
|
f0bab0fb38 | ||
|
|
d5cb0935e9 | ||
|
|
d4f79882f9 | ||
|
|
8d3685439e | ||
|
|
68cf703435 | ||
|
|
bcdd04d549 | ||
|
|
ec7d9d4179 | ||
|
|
765da1aca8 | ||
|
|
7fa42ca064 | ||
|
|
c23ea1e733 | ||
|
|
0f48e851a3 | ||
|
|
549007a4a6 | ||
|
|
932e7c84b3 | ||
|
|
999b5df933 | ||
|
|
29396b6235 | ||
|
|
4ce32c3663 | ||
|
|
8084cc5499 | ||
|
|
988fc97af1 | ||
|
|
5f082045b0 | ||
|
|
abc98ba56b | ||
|
|
e35c5c9ae4 | ||
|
|
926fa5d5a6 | ||
|
|
99d8fa1a6b | ||
|
|
1a317a7306 | ||
|
|
fa01ba3221 | ||
|
|
766019e1fc | ||
|
|
a7e4cdcc49 | ||
|
|
6551ccc247 | ||
|
|
c3e4d303e9 | ||
|
|
9e763a8334 | ||
|
|
035c01e222 | ||
|
|
1fa88ebd56 | ||
|
|
4fce4eb10b | ||
|
|
2e694d3a6d | ||
|
|
e8966a05f5 | ||
|
|
a377727ac4 | ||
|
|
385fb64ab7 | ||
|
|
f2216f4e25 | ||
|
|
0fc1ea01d1 | ||
|
|
ea23cd4779 | ||
|
|
903a400132 | ||
|
|
940f3ed731 | ||
|
|
9d8817b5db | ||
|
|
10204f8d82 | ||
|
|
746d702058 | ||
|
|
3c5728f070 | ||
|
|
8c8ef2d9e1 | ||
|
|
6a25490d7f | ||
|
|
6a0b16817d | ||
|
|
677e2104a0 | ||
|
|
438c969fef | ||
|
|
4af0bfd661 | ||
|
|
03c2a3d3a8 | ||
|
|
9a6d1c390e | ||
|
|
0512a47eba | ||
|
|
699a5c3c18 | ||
|
|
5a552b9f8d | ||
|
|
aa5b9d12ea | ||
|
|
a3b1007633 | ||
|
|
bdd0af5280 | ||
|
|
5e554530ac | ||
|
|
713c24d916 | ||
|
|
c359a38d9f | ||
|
|
d84a88d78d | ||
|
|
cf9b1b2193 | ||
|
|
25605505d5 | ||
|
|
0d2a0deef3 | ||
|
|
b6dc5381ca | ||
|
|
559bacbd98 | ||
|
|
19444ffa18 | ||
|
|
db3d202c4e | ||
|
|
2f5172f907 | ||
|
|
f6cb5268a2 | ||
|
|
fcee09cab2 | ||
|
|
dd1d8737ad | ||
|
|
3e48066021 | ||
|
|
0d16042705 | ||
|
|
52b8070692 | ||
|
|
23541ab175 | ||
|
|
c7a17946a5 | ||
|
|
208ca23515 | ||
|
|
6329c0fcf2 | ||
|
|
202ae50820 | ||
|
|
58e5f33fad | ||
|
|
2ce4f5ece5 | ||
|
|
aca45340bf | ||
|
|
30d4520c6b | ||
|
|
daff482092 | ||
|
|
a740044e21 | ||
|
|
1a4955f9fd | ||
|
|
2c4042c17c | ||
|
|
e95ba8a3dc | ||
|
|
63cb030cba | ||
|
|
743fc70a7f | ||
|
|
c14ffa3264 | ||
|
|
3f292d5d42 | ||
|
|
886e89ccb2 | ||
|
|
977428e42c | ||
|
|
1c02312ae6 | ||
|
|
8fbd84515f | ||
|
|
f93289e01c | ||
|
|
982ed69776 | ||
|
|
1f46169e1e | ||
|
|
7bac75f370 | ||
|
|
06d9b6531c | ||
|
|
2991e767dd | ||
|
|
a901d80dd5 | ||
|
|
d86f58a0df | ||
|
|
0ad574257e | ||
|
|
4839d18c73 | ||
|
|
e539e7ecbb | ||
|
|
1b618fae90 | ||
|
|
f12a93fe1e | ||
|
|
617159c825 | ||
|
|
c72d6e9122 | ||
|
|
69ae178bf4 | ||
|
|
d391299340 | ||
|
|
40091678a8 | ||
|
|
2b43aa6301 | ||
|
|
44d9fff2b4 | ||
|
|
509a28efd3 | ||
|
|
c4e000dbe7 | ||
|
|
0bcc2e3fbd | ||
|
|
e6c440a4f7 | ||
|
|
575af22cee | ||
|
|
dea08be906 | ||
|
|
0f27975f77 | ||
|
|
2d30419a31 | ||
|
|
68ce113c5b | ||
|
|
ad7e4e95ae | ||
|
|
345387645e | ||
|
|
380366e25f | ||
|
|
1936eb1f36 | ||
|
|
088fc6b67f | ||
|
|
983a47a7d6 | ||
|
|
c1840abb0a | ||
|
|
2c054fca76 | ||
|
|
d5b94aa9c8 | ||
|
|
c4c760bfb3 | ||
|
|
dd0260c476 | ||
|
|
ca62702ff9 | ||
|
|
0d50b4c39f | ||
|
|
c37e44efb6 | ||
|
|
df04ae11ef | ||
|
|
6e8b976089 | ||
|
|
bc878ddf19 | ||
|
|
3096608d4a | ||
|
|
7c99b756f9 | ||
|
|
90035ab084 | ||
|
|
b6c12f5fff | ||
|
|
4b9920bcb3 | ||
|
|
1e053298be | ||
|
|
ca031ca33f | ||
|
|
ecb56054bc | ||
|
|
53747b0cb5 | ||
|
|
e1b0a8c153 | ||
|
|
fc189c9aaf | ||
|
|
e8ce61d4cd | ||
|
|
ac61018806 | ||
|
|
18e97a487d | ||
|
|
c3b1f47754 | ||
|
|
503d277033 | ||
|
|
40de19f16e | ||
|
|
83ebdcd8f2 | ||
|
|
47a1f7529a | ||
|
|
747cb0f151 | ||
|
|
30b530836a | ||
|
|
49596dcacc | ||
|
|
5df687dddc | ||
|
|
599a754b60 | ||
|
|
eaac0c17a4 | ||
|
|
faaebe7a07 | ||
|
|
6256ba336e | ||
|
|
5987d917b8 | ||
|
|
738abbb360 | ||
|
|
1558362583 | ||
|
|
5b67354e24 | ||
|
|
dec91dec68 | ||
|
|
1933d05e36 | ||
|
|
9e5ecaaf75 | ||
|
|
3701ec06d0 | ||
|
|
5d0fb2967c | ||
|
|
5c88451f6f | ||
|
|
cfc53c939e | ||
|
|
3ba78225c3 | ||
|
|
d8e6181058 | ||
|
|
bb4e78da90 | ||
|
|
4dd32d6f72 | ||
|
|
68b0075fe6 | ||
|
|
f9686cf098 | ||
|
|
ca28877fd5 | ||
|
|
c18d26c7d8 | ||
|
|
241db39cea | ||
|
|
31da9a4878 | ||
|
|
0e65f20f22 | ||
|
|
d8d70e8b35 | ||
|
|
5d62261082 | ||
|
|
a72b774acf | ||
|
|
b1042f2c3c | ||
|
|
124c78b926 | ||
|
|
7332bf91d5 | ||
|
|
33307fb1bd | ||
|
|
1ef8b75cbb | ||
|
|
f4a85e5f03 | ||
|
|
7f8b30aed3 | ||
|
|
b8ea220925 | ||
|
|
1e1644f6d4 | ||
|
|
fab4ce894a | ||
|
|
f2f7ab80f6 | ||
|
|
c044f3b0c4 | ||
|
|
ebd463e92f | ||
|
|
69ba974960 | ||
|
|
dbee8a24d8 | ||
|
|
2373dab982 | ||
|
|
1ebfef5ec9 | ||
|
|
ff7a2fe4d6 | ||
|
|
862289cf56 | ||
|
|
e3068d7db2 | ||
|
|
29ad7a39de | ||
|
|
3484200f80 | ||
|
|
acaa470dea | ||
|
|
3bf6c17bb8 | ||
|
|
ca8a418364 | ||
|
|
6422310453 | ||
|
|
ebf489be8c | ||
|
|
c8967fa176 | ||
|
|
51d08ad8ab | ||
|
|
dc664ba597 | ||
|
|
8e74ba8c24 | ||
|
|
ec3e8c2039 | ||
|
|
6cbd418703 | ||
|
|
6c8342b74e | ||
|
|
c345dfb0c6 | ||
|
|
8adc546d92 | ||
|
|
25a9e477cb | ||
|
|
886de4ee43 | ||
|
|
c98abaaa42 | ||
|
|
a8bd5e7ece | ||
|
|
a328364999 | ||
|
|
94cbf72e39 | ||
|
|
8248eb6ea1 | ||
|
|
408104dbaf | ||
|
|
5978670897 | ||
|
|
01d14004a9 | ||
|
|
940bbc4e91 | ||
|
|
7070bd0340 | ||
|
|
5e9380ab85 | ||
|
|
9c759294c6 | ||
|
|
b294f4d894 | ||
|
|
ca980a56bc | ||
|
|
8482293b40 | ||
|
|
dc5a06aab4 | ||
|
|
35bd69808c | ||
|
|
4f12261080 | ||
|
|
fbdfc0f95c | ||
|
|
48735c3946 | ||
|
|
c985225d0c | ||
|
|
48ff897ed1 | ||
|
|
9db568d49d | ||
|
|
896e785994 | ||
|
|
78cdb705d4 | ||
|
|
136452840d | ||
|
|
b3631b707c | ||
|
|
f4bab8b8c1 | ||
|
|
2392a4c184 | ||
|
|
476b7056fb | ||
|
|
d510978446 | ||
|
|
583ff81dba | ||
|
|
01a862db30 | ||
|
|
dfbd61436b | ||
|
|
f03745ce45 | ||
|
|
48cf910626 | ||
|
|
0492b25335 | ||
|
|
6d9cb0a646 | ||
|
|
571ecafdbc | ||
|
|
dee844e232 | ||
|
|
07bcff5067 | ||
|
|
7fa3594c04 | ||
|
|
6fda1e968d | ||
|
|
af8074cc39 | ||
|
|
71a4828809 | ||
|
|
79ce18ac3e | ||
|
|
bb83e11a7c | ||
|
|
0f888dde49 | ||
|
|
f4215d121c | ||
|
|
60eecb98a6 | ||
|
|
3cc76a3f60 | ||
|
|
ffdeeb95b7 | ||
|
|
58335d7bc0 | ||
|
|
b0c9d7cce9 | ||
|
|
281ef5a152 | ||
|
|
9183c2fa0d | ||
|
|
389751beae | ||
|
|
2b4e3bcf54 | ||
|
|
3dce85c49f | ||
|
|
185ce79a68 | ||
|
|
f777aba227 | ||
|
|
5efa373d7f | ||
|
|
b6cd19b4ae | ||
|
|
fc5573333d | ||
|
|
55fe7c470f | ||
|
|
3ef1d6919c | ||
|
|
e1863383ff | ||
|
|
4dc34b7d5b | ||
|
|
2c8c022034 | ||
|
|
b5b43a5a36 | ||
|
|
c09fe57031 | ||
|
|
68524ddde9 | ||
|
|
55bdd4d937 | ||
|
|
3f089e3add | ||
|
|
ddb90a69d3 | ||
|
|
bdce8d0494 | ||
|
|
734a3d76aa | ||
|
|
a4aa85259e | ||
|
|
ea1c7a7339 | ||
|
|
185f7344fa | ||
|
|
26e4bf92a0 | ||
|
|
68cb017be1 | ||
|
|
68ff1afac1 | ||
|
|
0d448a5e4f | ||
|
|
d9f6659f2c | ||
|
|
bae2ee0420 | ||
|
|
799e864d93 | ||
|
|
aa38f62bae | ||
|
|
06c3e255b3 | ||
|
|
d5e20b13b9 | ||
|
|
c83d4d29e4 | ||
|
|
ee1c06085b | ||
|
|
336d53b692 | ||
|
|
95c58ba75c | ||
|
|
56857cf5e7 | ||
|
|
838998b885 | ||
|
|
a9b3b48273 | ||
|
|
a788e8a475 | ||
|
|
b7e1cc5f6b | ||
|
|
e784a7f606 | ||
|
|
3e9bc3c434 | ||
|
|
dd340b8ef2 | ||
|
|
7deb479676 | ||
|
|
1ab40e0b3f | ||
|
|
283c3d1664 | ||
|
|
5291ea7270 | ||
|
|
0c1c1b65e1 | ||
|
|
b0787e9f40 | ||
|
|
dc0eacb80f | ||
|
|
8c04651301 | ||
|
|
94621fecd1 | ||
|
|
5e392e3300 | ||
|
|
88595dd26b | ||
|
|
4323c6d845 | ||
|
|
81ec8b99ac | ||
|
|
1af7b7603d | ||
|
|
0fd8fa2211 | ||
|
|
5048739b7f | ||
|
|
44f3f9e2d0 | ||
|
|
ed1c55508f | ||
|
|
50e411b82a | ||
|
|
a8a0306f98 | ||
|
|
19b7d26bc2 | ||
|
|
c7940e70ed | ||
|
|
58ede2c80a | ||
|
|
e83e00520f | ||
|
|
9a50c208f0 | ||
|
|
7acb380ba8 | ||
|
|
48fa2f458c | ||
|
|
318fc6ffe8 | ||
|
|
b009cedc0c | ||
|
|
c6dd475610 | ||
|
|
61285a098a | ||
|
|
995a8b8d35 | ||
|
|
5d33697cb1 | ||
|
|
ae09fc6b6d | ||
|
|
cd826f7bcf | ||
|
|
283ece29e8 | ||
|
|
1918148b8e | ||
|
|
e17714583f | ||
|
|
4c05c63a04 | ||
|
|
0bdc2d04b4 | ||
|
|
57d4d60a33 | ||
|
|
731e1920d2 | ||
|
|
7411b444d3 | ||
|
|
ae3d002ac6 | ||
|
|
1bd70ac5ab | ||
|
|
c90b1732e9 | ||
|
|
fcd9582133 | ||
|
|
9d82d822db | ||
|
|
186d91c03f | ||
|
|
eec5809097 | ||
|
|
4582a29ec1 | ||
|
|
2f83234ccb | ||
|
|
bef52c945b | ||
|
|
1de4ad735b | ||
|
|
00fc29d40d | ||
|
|
27afdc8a27 | ||
|
|
eff42f6066 | ||
|
|
b99453d568 | ||
|
|
9f5ce12754 | ||
|
|
cb21e95e0b | ||
|
|
e6f032db1b | ||
|
|
86e9425638 | ||
|
|
53ac33a84c | ||
|
|
5cf2af569f | ||
|
|
a46b7cb67a | ||
|
|
3d78f30d18 | ||
|
|
ad64d383e1 | ||
|
|
0a7f5ff9fa | ||
|
|
ce28c5794d | ||
|
|
e55c7c889b | ||
|
|
0633e8218f | ||
|
|
0fdfe1fd59 | ||
|
|
2cc264645b | ||
|
|
983e0a93db | ||
|
|
d88e4fbf36 | ||
|
|
f79da3edf7 | ||
|
|
8742d74e93 | ||
|
|
ff80ab6a23 | ||
|
|
8c37d642fe | ||
|
|
06a30e9f23 | ||
|
|
650e7dc16e | ||
|
|
d41fad51c2 | ||
|
|
0463949ac3 | ||
|
|
5f0fd4b706 | ||
|
|
201c368325 | ||
|
|
3fe08f149d | ||
|
|
61bea2bfda | ||
|
|
f720140481 | ||
|
|
66a2d38ab8 | ||
|
|
bed266f310 | ||
|
|
719f08ea5e | ||
|
|
3992ea5c59 | ||
|
|
a01c1cdc3a | ||
|
|
7a8ae9f56b | ||
|
|
765efc3c72 | ||
|
|
bc23c1ddb2 | ||
|
|
87e2fcb4e5 | ||
|
|
478b7e7ccc | ||
|
|
0574db134c | ||
|
|
358211ca66 | ||
|
|
c8e5007913 | ||
|
|
943fedb073 | ||
|
|
13ae8e41ee | ||
|
|
ac8b196b8c | ||
|
|
2c3183bdae | ||
|
|
53349603e2 | ||
|
|
c284de366b | ||
|
|
e81c330694 | ||
|
|
790da699dd | ||
|
|
7915397377 | ||
|
|
b2a5d34679 | ||
|
|
73bb18e78b | ||
|
|
9701148819 | ||
|
|
f1dbc8b117 | ||
|
|
b8131e6e67 | ||
|
|
f4598a97f7 | ||
|
|
c90d42973d | ||
|
|
ff0bb8c83c | ||
|
|
e5acea60e6 | ||
|
|
216b536967 | ||
|
|
0a819da0e7 | ||
|
|
bdad2af27b | ||
|
|
60513446fa | ||
|
|
be415091cd | ||
|
|
9067dbf6a0 | ||
|
|
359be1a880 | ||
|
|
99624bf3b5 | ||
|
|
252b94a110 | ||
|
|
448d996a45 | ||
|
|
b9e5dfd286 | ||
|
|
d966746fbf | ||
|
|
89baeb3d5d | ||
|
|
89006458a2 | ||
|
|
389bc1ecea | ||
|
|
1e0437208b | ||
|
|
256bd01e0c | ||
|
|
ef7b035f02 | ||
|
|
83a0dc2ef9 | ||
|
|
c10174d50d | ||
|
|
5a3b375147 | ||
|
|
656ff25ae1 | ||
|
|
19059b054e | ||
|
|
45bc487fc0 | ||
|
|
9c74a31ca2 | ||
|
|
8c3e511538 | ||
|
|
5fb948fb35 | ||
|
|
a14c2233e0 | ||
|
|
f01b87fac7 | ||
|
|
40bdde2043 | ||
|
|
0a8a601877 | ||
|
|
002e29958e | ||
|
|
604987a005 | ||
|
|
7e3e6b1969 | ||
|
|
d821514372 | ||
|
|
37a896fe1b | ||
|
|
e1cdb2e558 | ||
|
|
c30b27fcfe | ||
|
|
9542f51cd0 | ||
|
|
a7b56f0975 | ||
|
|
ed3dc8c7d3 | ||
|
|
ed6ce87c22 | ||
|
|
4bd7427b70 | ||
|
|
0b1196db3f | ||
|
|
b25ed7ef91 | ||
|
|
dc95130526 | ||
|
|
d5ee80a70a | ||
|
|
5dc944c1c3 | ||
|
|
da22fd40bf | ||
|
|
1434419e47 | ||
|
|
3385e62aa7 | ||
|
|
40f2276e88 | ||
|
|
35cd89c00c | ||
|
|
892fea3df9 | ||
|
|
2d32929dc5 | ||
|
|
728b4857c3 | ||
|
|
9fa4641cb0 | ||
|
|
fc04a65a0f | ||
|
|
a93d7d20ee | ||
|
|
b74b72e44c | ||
|
|
850c73b73f | ||
|
|
d736e26e0c | ||
|
|
d97f47141e | ||
|
|
a7df63e1a1 | ||
|
|
d3e8804dbf | ||
|
|
c509cac02b | ||
|
|
4b5bf760ec | ||
|
|
c57c6213ea | ||
|
|
fb30820e2b | ||
|
|
61b612c88a | ||
|
|
d3edc9dcdc | ||
|
|
ba2485b807 | ||
|
|
60c6635af5 | ||
|
|
9c5134fb6b | ||
|
|
eae0858de6 | ||
|
|
d7949d5316 | ||
|
|
8c44d6d4cb | ||
|
|
049fae5c65 | ||
|
|
41f8459a41 | ||
|
|
5cd82f16f2 | ||
|
|
444ba7a7d5 | ||
|
|
dcd5f1d711 | ||
|
|
18ce494cba | ||
|
|
9e39570d49 | ||
|
|
6a1337aa92 | ||
|
|
605c4a0adf | ||
|
|
7c90d9f3e8 | ||
|
|
01a0674490 | ||
|
|
e482793f69 | ||
|
|
de14670d4d | ||
|
|
9209c3cbfe | ||
|
|
a7204b5cd3 | ||
|
|
616416569b | ||
|
|
cab1b9716c | ||
|
|
bda3f1b7c6 | ||
|
|
416bf9e3bf | ||
|
|
102e0095a7 | ||
|
|
1fcfd54584 | ||
|
|
441a9c9024 | ||
|
|
f68fdcf703 | ||
|
|
d8137f7bcf | ||
|
|
42c27b8845 | ||
|
|
8408539f1c | ||
|
|
1f0467b864 | ||
|
|
1aae18d4bc | ||
|
|
45902676fd | ||
|
|
931105123e | ||
|
|
cf35019d07 | ||
|
|
c636f6edd6 | ||
|
|
58b28569e2 | ||
|
|
73bb013b25 | ||
|
|
d6da893c0c | ||
|
|
47a7d8e2b7 | ||
|
|
cb0cf2f04f | ||
|
|
a4cf5951ca | ||
|
|
822dce47cd | ||
|
|
2ea475ad31 | ||
|
|
eed92ba07c | ||
|
|
a86317efc8 | ||
|
|
ca973f053f | ||
|
|
119e4a6924 | ||
|
|
aef224221f | ||
|
|
18d0f7ba0d | ||
|
|
dd9077d52d | ||
|
|
01cb2117cc | ||
|
|
574f890e58 | ||
|
|
e70cc4fcae | ||
|
|
d02da21a7a | ||
|
|
817546e4c8 | ||
|
|
1a7e05a3da | ||
|
|
f19fed0853 | ||
|
|
06f67f7696 | ||
|
|
501f1dc8dc | ||
|
|
8b5a5ecd74 | ||
|
|
cb3ff19801 | ||
|
|
f30d7bc845 | ||
|
|
c0aa4c8517 | ||
|
|
e868739675 | ||
|
|
991682956d | ||
|
|
e168d8e593 | ||
|
|
273b1b110a | ||
|
|
bbc92fa51c | ||
|
|
8515b9dd10 | ||
|
|
a56f894e39 | ||
|
|
592b957b77 | ||
|
|
65cfef1b2e | ||
|
|
914fe91db5 | ||
|
|
0c19ccc11a | ||
|
|
3560e47a77 | ||
|
|
c33cd678f0 | ||
|
|
a67cce2f91 | ||
|
|
72bc39d831 | ||
|
|
abf010ac48 | ||
|
|
2baa05ace9 | ||
|
|
fa708f93ee | ||
|
|
a0a3f9dbfb | ||
|
|
bda875166a | ||
|
|
e376172312 | ||
|
|
d20b1f271e | ||
|
|
67da3182c1 | ||
|
|
1280dea111 | ||
|
|
3920b7aaa3 | ||
|
|
52890edfac | ||
|
|
ed3aea0980 | ||
|
|
3f70fd49ff | ||
|
|
7496e3dbdf | ||
|
|
7c401e9a35 | ||
|
|
a02bec7ebe | ||
|
|
254c1d1531 | ||
|
|
971de3e1d0 | ||
|
|
7d2c8fa6ef | ||
|
|
ac210a3201 | ||
|
|
a79975b3ea | ||
|
|
aa7380acc6 | ||
|
|
cdbd842494 | ||
|
|
323fdb014d | ||
|
|
3f735b715b | ||
|
|
4ecb04ed9f | ||
|
|
e0361047f7 | ||
|
|
37016ca77f | ||
|
|
98ef5049f4 | ||
|
|
98a470d813 | ||
|
|
944d760855 | ||
|
|
e0e999da0d | ||
|
|
2f486f2bdd | ||
|
|
7e4101b3ad | ||
|
|
d8d30e1f82 | ||
|
|
36470f69ad | ||
|
|
5fa732d223 | ||
|
|
5e7279b0a2 | ||
|
|
4764136d47 | ||
|
|
10a06157aa | ||
|
|
d7ba9a50df | ||
|
|
18400e8457 | ||
|
|
f5375783c6 | ||
|
|
8045e48952 | ||
|
|
be18bdee88 | ||
|
|
1e34f331da | ||
|
|
d99a55a7d1 | ||
|
|
0141a959eb | ||
|
|
d04c849a23 | ||
|
|
329e04b068 | ||
|
|
d0c7a496f7 | ||
|
|
ff6fa31b1d | ||
|
|
554952e02a | ||
|
|
00845d5252 | ||
|
|
7113f4400c | ||
|
|
7292b63052 | ||
|
|
7cfc5c3316 | ||
|
|
1d0c67d67b | ||
|
|
47e6b34d2b | ||
|
|
3003e33074 | ||
|
|
7bd7b059c4 | ||
|
|
230d69b772 | ||
|
|
cbfa572acb | ||
|
|
8f5a2be6fd | ||
|
|
45f5f0904a | ||
|
|
6db8b3c26d | ||
|
|
b4ccafe718 | ||
|
|
3c73dc2d0b | ||
|
|
58494f8878 | ||
|
|
cb70702ab5 | ||
|
|
7f1ea578d6 | ||
|
|
dd7e7fc122 | ||
|
|
0bcc60fbe3 | ||
|
|
7766eed754 | ||
|
|
5fa02f53d9 | ||
|
|
176e331fc4 | ||
|
|
d846f23e80 | ||
|
|
af717ad788 | ||
|
|
2a4e05c982 | ||
|
|
c219416bb8 | ||
|
|
8d1ff45c71 | ||
|
|
245d0b6282 | ||
|
|
bbdf52e038 | ||
|
|
237f9dec5a | ||
|
|
d6dc438859 | ||
|
|
1469df26db | ||
|
|
b7f6fbcfcb | ||
|
|
329f26ee20 | ||
|
|
57cd8324dc | ||
|
|
8aafbb9441 | ||
|
|
e4c2d0a779 | ||
|
|
59a213bdaa | ||
|
|
4b564b91bf | ||
|
|
4abfedea68 | ||
|
|
7d971a3262 | ||
|
|
b4474a4882 | ||
|
|
d1ac90bb3e | ||
|
|
785d9b8deb | ||
|
|
ab92801740 | ||
|
|
1d6536a53b | ||
|
|
60315d079b | ||
|
|
1a833a9267 | ||
|
|
70be790b2a | ||
|
|
2e2c57dbd1 | ||
|
|
3fa507d6d1 | ||
|
|
e47fa70279 | ||
|
|
e248503b0a | ||
|
|
3f2c66dca5 | ||
|
|
bd1769b11f | ||
|
|
af98088d04 | ||
|
|
aa076695b9 | ||
|
|
869964cb2f | ||
|
|
579c3ecc0e | ||
|
|
63b2ad36e1 | ||
|
|
ae01194a5e | ||
|
|
3c006c4ca4 | ||
|
|
738d54ff4c | ||
|
|
044bb1c395 | ||
|
|
180f16161c | ||
|
|
7f9e8d059b | ||
|
|
36ccb3bbfe | ||
|
|
1e6f3fc893 | ||
|
|
b4d0ee9b3b | ||
|
|
3e516e54b2 | ||
|
|
3baa00decb | ||
|
|
09a96670e6 | ||
|
|
78455ac3c0 | ||
|
|
2ec74e5c22 | ||
|
|
9d56309a05 | ||
|
|
4139504202 | ||
|
|
2f547c8c56 | ||
|
|
ca72710937 | ||
|
|
9a1688599a | ||
|
|
d6c3df32d6 | ||
|
|
28c0ffe333 | ||
|
|
586c24f9d6 | ||
|
|
31c0a70f8e | ||
|
|
64a92530d9 | ||
|
|
4441935a4a | ||
|
|
f1feac76b3 | ||
|
|
d9c4446ccc | ||
|
|
f83500db11 | ||
|
|
fd02d81e73 | ||
|
|
0d379fdd6b | ||
|
|
f6fd800242 | ||
|
|
c25214aaf4 | ||
|
|
c6afb2be3f | ||
|
|
13501a8b05 | ||
|
|
dae5994e9d | ||
|
|
b28a418bd9 | ||
|
|
64f69cf5c9 | ||
|
|
8084ca43b9 | ||
|
|
2e5f25d8ae | ||
|
|
04b0d24678 | ||
|
|
153e7a1806 | ||
|
|
065ebd748a | ||
|
|
79c17cb542 | ||
|
|
9245975955 | ||
|
|
6ea19ec8bf | ||
|
|
b527bf8ab3 | ||
|
|
0b1b3c68fa | ||
|
|
d930c8ae8b | ||
|
|
053c5300ed | ||
|
|
e8ae18efda | ||
|
|
39965c55ac | ||
|
|
f87dca2ad4 | ||
|
|
3e02903d19 | ||
|
|
febae7f8f2 | ||
|
|
71dd5c9f4d | ||
|
|
aa91af865d | ||
|
|
9119e395d4 | ||
|
|
68433924c7 | ||
|
|
87b67cb45a | ||
|
|
77dd9eb883 | ||
|
|
e000fd2f8f | ||
|
|
e4d20a80ed | ||
|
|
36866fed10 | ||
|
|
55691fce4e | ||
|
|
d2a3b5bed8 | ||
|
|
6365674a2a | ||
|
|
7a02ccc3a8 | ||
|
|
2918864248 | ||
|
|
9fbfe2b98e | ||
|
|
b40e2cc59e | ||
|
|
3eac9c536b | ||
|
|
ad32b01d85 | ||
|
|
da33233762 | ||
|
|
c2a7fe4019 | ||
|
|
0067d3edce | ||
|
|
ebf038231e | ||
|
|
f767b7096c | ||
|
|
161227b1de | ||
|
|
8e43dfa7a6 | ||
|
|
0a11ffb827 | ||
|
|
3c55b46ca0 | ||
|
|
7d21e5d328 | ||
|
|
043069dc8a | ||
|
|
ea26434987 | ||
|
|
9ee34f57f5 | ||
|
|
d539dc12a1 | ||
|
|
c578cae676 | ||
|
|
8b74b32909 | ||
|
|
1d1133123b | ||
|
|
0bdafb976e | ||
|
|
13f9418201 | ||
|
|
a771a3ea06 | ||
|
|
39633eef4f | ||
|
|
1f11ac76fa | ||
|
|
2e1456517a | ||
|
|
4db208332e | ||
|
|
659091c565 | ||
|
|
c8c54113d0 | ||
|
|
69f8e57cea | ||
|
|
06a6fac23a | ||
|
|
fa939a890c | ||
|
|
2c8ab76240 | ||
|
|
7a651b8c1f | ||
|
|
d04df43b27 | ||
|
|
d3c9db906f | ||
|
|
f6e2c5c1f0 | ||
|
|
cc682fd786 | ||
|
|
6643997304 | ||
|
|
7b867d0069 | ||
|
|
a15c4dc9b0 | ||
|
|
7c11fe1022 | ||
|
|
66f816971f | ||
|
|
98c6d5a5f6 | ||
|
|
0b2a98f956 | ||
|
|
c01b336095 | ||
|
|
040cc4bf16 | ||
|
|
eefc4d3e84 | ||
|
|
c3c979f11a | ||
|
|
276d0c49c1 | ||
|
|
7c840dce35 | ||
|
|
2bee5f7ac6 | ||
|
|
60524f0f3e | ||
|
|
1170772a4f | ||
|
|
f4d2d1a24b | ||
|
|
ff2e35c243 | ||
|
|
0d1a2f2af3 | ||
|
|
3b029ba031 | ||
|
|
cd21f7b927 | ||
|
|
755eff7415 | ||
|
|
0d3f28bd52 | ||
|
|
56a3926b86 | ||
|
|
220bf8730a | ||
|
|
118eac8f39 | ||
|
|
99452a8b45 | ||
|
|
eb42614288 | ||
|
|
5238eca241 | ||
|
|
94af6c7f9d | ||
|
|
f2b54acd67 | ||
|
|
497bc10d0a | ||
|
|
c1bb5cb250 | ||
|
|
51910fe83b | ||
|
|
958bbf6c9a | ||
|
|
e98951ee65 | ||
|
|
3765d912a5 | ||
|
|
849bc00b46 | ||
|
|
f3715c3e2e | ||
|
|
985a48f02e | ||
|
|
4e196a445a | ||
|
|
36d2e67b07 | ||
|
|
34568a0a74 | ||
|
|
f7acc73282 | ||
|
|
60926ad6ea | ||
|
|
f734e614e4 | ||
|
|
997a15c0f2 | ||
|
|
1b40618f02 | ||
|
|
58c78560fa | ||
|
|
1d1ec57909 | ||
|
|
fd9c83b65f | ||
|
|
6baddc7e26 | ||
|
|
e9580877b4 | ||
|
|
440649bb95 | ||
|
|
48846bc0ba | ||
|
|
558e1d2fb0 | ||
|
|
0b26047ea8 | ||
|
|
7f5a57f4af | ||
|
|
dc12cda505 | ||
|
|
b4cf6f7f36 | ||
|
|
f2f04407a4 | ||
|
|
8a11e3bac4 | ||
|
|
4879b0611a | ||
|
|
d11a67499d | ||
|
|
b3b8c78527 | ||
|
|
0bfa76251d | ||
|
|
a992a4325b | ||
|
|
c1225f3876 | ||
|
|
152836c907 | ||
|
|
e47a4ea514 | ||
|
|
52b6da1759 | ||
|
|
f13465012b | ||
|
|
b7b5dd5bea | ||
|
|
7265900c62 | ||
|
|
7a77298a60 | ||
|
|
0177e7558e | ||
|
|
719ea50d1a | ||
|
|
bbf1ea41b8 | ||
|
|
eb22f42fea | ||
|
|
dd32e74e34 | ||
|
|
e1b4a150c3 | ||
|
|
76d912c0ba | ||
|
|
a3c8e04ee6 | ||
|
|
bf9158172f | ||
|
|
b687180e12 | ||
|
|
47a11b9a7e | ||
|
|
b6ddb0a7cf | ||
|
|
acb7acd661 | ||
|
|
7c0d94ce9c | ||
|
|
763b3e806e | ||
|
|
b5264cacf0 | ||
|
|
f1552ef20d | ||
|
|
de7eeed916 | ||
|
|
93eabce1bc | ||
|
|
e693dd4923 | ||
|
|
7f9acac469 | ||
|
|
506d5b18de | ||
|
|
5110796591 | ||
|
|
eafeba9fed | ||
|
|
b7a1676b15 | ||
|
|
72b63e7b36 | ||
|
|
fe3fcef7a9 | ||
|
|
714b09ddcb |
No files matched your search
@@ -13,3 +13,11 @@
|
|||||||
*.pyd binary
|
*.pyd binary
|
||||||
*.cfg text eol=lf
|
*.cfg text eol=lf
|
||||||
*.py text eol=lf
|
*.py text eol=lf
|
||||||
|
*.jks binary
|
||||||
|
|
||||||
|
# Disable autocrlf on generated files, they always generate with LF
|
||||||
|
src/generated/**/.cache/cache text eol=lf
|
||||||
|
src/generated/**/*.json text eol=lf
|
||||||
|
src/generated_test/**/.cache/cache text eol=lf
|
||||||
|
src/generated_test/**/*.json text eol=lf
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<!-- Thank you for reporting! -->
|
|
||||||
|
|
||||||
<!-- Please go to the forum first for support with crashes and issues. -->
|
|
||||||
<!-- http://www.minecraftforge.net/forum/forum/18-support-bug-reports/ -->
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Want to request a feature?
|
||||||
|
title: ''
|
||||||
|
labels: Feature
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Please note, feature requests that are submitted as GitHub issues here are rarely implemented. -->
|
||||||
|
<!-- If you'd like to see something in Forge, you should be ready to implement it as a PR. -->
|
||||||
|
<!-- If you're not sure, open a Draft PR or discuss it in the Discord server. -->
|
||||||
|
<!-- Discord: https://discord.gg/UvedJ9m -->
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
name: Issue report
|
||||||
|
about: Visit the forum first for issues with crashes.
|
||||||
|
title: ''
|
||||||
|
labels: Triage
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Thank you for reporting! -->
|
||||||
|
|
||||||
|
<!-- For support with crashes and issues, please create a post on the forum instead: -->
|
||||||
|
<!-- https://www.minecraftforge.net/forum/forum/18-support-bug-reports/ -->
|
||||||
|
|
||||||
|
**Minecraft Version:** {Minecraft version}
|
||||||
|
|
||||||
|
**Forge Version:** {Forge version. *Version number, not latest/rb*}
|
||||||
|
|
||||||
|
**Logs:** {Link(s) to GitHub Gist with full latest.log and/or crash report}
|
||||||
|
|
||||||
|
**Steps to Reproduce:**
|
||||||
|
1. Do this
|
||||||
|
2. Then do that
|
||||||
|
3. ...
|
||||||
|
|
||||||
|
**Description of issue:**
|
||||||
+3
-5
@@ -6,15 +6,15 @@ staleLabel: Stale
|
|||||||
unmarkComment: false
|
unmarkComment: false
|
||||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||||
limitPerRun: 1
|
limitPerRun: 1
|
||||||
|
# Issues with these labels will never be considered stale. Set to `[]` to disable
|
||||||
|
exemptLabels:
|
||||||
|
- Assigned
|
||||||
|
|
||||||
pulls:
|
pulls:
|
||||||
# Number of days of inactivity before a Pull Request becomes stale
|
# Number of days of inactivity before a Pull Request becomes stale
|
||||||
daysUntilStale: 60
|
daysUntilStale: 60
|
||||||
# Number of days of inactivity before a stale Pull Request is closed
|
# Number of days of inactivity before a stale Pull Request is closed
|
||||||
daysUntilClose: 14
|
daysUntilClose: 14
|
||||||
# Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
|
||||||
exemptLabels:
|
|
||||||
- Assigned
|
|
||||||
# Comment to post when marking as stale. Set to `false` to disable
|
# Comment to post when marking as stale. Set to `false` to disable
|
||||||
markComment: >
|
markComment: >
|
||||||
This pull request has been automatically marked as stale because it has not had recent
|
This pull request has been automatically marked as stale because it has not had recent
|
||||||
@@ -30,8 +30,6 @@ issues:
|
|||||||
daysUntilStale: 180
|
daysUntilStale: 180
|
||||||
# Number of days of inactivity before a stale Issue is closed
|
# Number of days of inactivity before a stale Issue is closed
|
||||||
daysUntilClose: 14
|
daysUntilClose: 14
|
||||||
# Issues with these labels will never be considered stale. Set to `[]` to disable
|
|
||||||
exemptLabels: []
|
|
||||||
# Comment to post when marking as stale. Set to `false` to disable
|
# Comment to post when marking as stale. Set to `false` to disable
|
||||||
markComment: >
|
markComment: >
|
||||||
This issue has been automatically marked as stale because it has not had activity
|
This issue has been automatically marked as stale because it has not had activity
|
||||||
|
|||||||
+17
-12
@@ -9,33 +9,38 @@
|
|||||||
|
|
||||||
#idea
|
#idea
|
||||||
/.idea
|
/.idea
|
||||||
|
/*/out
|
||||||
/classes
|
/classes
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
#gradle
|
#gradle
|
||||||
/build
|
/build
|
||||||
/.gradle
|
/.gradle
|
||||||
/mdk/.gradle
|
/*/build
|
||||||
/mdk/build
|
/*/.gradle
|
||||||
|
|
||||||
|
# Projects repo, either ignore it, or ignore patches.
|
||||||
|
/projects/mcp/
|
||||||
|
/projects/clean/
|
||||||
|
/projects/forge/
|
||||||
|
/projects/fmlonly/
|
||||||
|
#/patches/
|
||||||
|
|
||||||
#occupational hazards
|
#occupational hazards
|
||||||
/projects/
|
/projects/**/build/
|
||||||
|
/projects/**/out/
|
||||||
|
/projects/**/run/
|
||||||
|
/projects/**/*.launch
|
||||||
/repo/
|
/repo/
|
||||||
/buildSrc
|
src/generated/resources/.cache/
|
||||||
|
|
||||||
#Patch rejects
|
#Patch rejects
|
||||||
/patches-/
|
/patches-/
|
||||||
*.patch.rej
|
#*.patch.rej
|
||||||
|
/projects/*/rejects/
|
||||||
|
|
||||||
# FML changelog
|
# FML changelog
|
||||||
changelog.txt
|
changelog.txt
|
||||||
/patches_old/
|
|
||||||
/patches_old_bak/
|
|
||||||
/patches/minecraft.old/
|
|
||||||
/projects.old/
|
|
||||||
*.py
|
*.py
|
||||||
*.7z
|
*.7z
|
||||||
/logs/
|
/logs/
|
||||||
|
|
||||||
gradle.properties
|
|
||||||
!/mdk/gradle.properties
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
language: java
|
|
||||||
jdk: oraclejdk8
|
|
||||||
|
|
||||||
env:
|
|
||||||
- BUILD_NUMBER=9999
|
|
||||||
|
|
||||||
before_cache:
|
|
||||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
|
||||||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
|
||||||
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/providedDummy.jar
|
|
||||||
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/compileDummy.jar
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.gradle/caches/
|
|
||||||
- $HOME/.gradle/wrapper/
|
|
||||||
- $TRAVIS_BUILD_DIR/build/localCache/Forge/
|
|
||||||
|
|
||||||
before_install: chmod +x gradlew
|
|
||||||
install:
|
|
||||||
- ./gradlew --refresh-dependencies
|
|
||||||
- ./gradlew ciWriteBuildNumber
|
|
||||||
script:
|
|
||||||
- travis_wait ./gradlew build -x createExe -S
|
|
||||||
- ./gradlew -p projects/Forge test -S -i
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
Contributing to Forge
|
|
||||||
=====================
|
|
||||||
|
|
||||||
1) Keep patches to Minecraft classes minimal. If you need a lot of things done, you may either add to relevant forge classes or make a new class.
|
|
||||||
|
|
||||||
2) An example mod must be provided for all PRs adding events/hooks to Forge. Whether it's a full mod using your proposed hooks, or just a pastebin containing a simple example, an example mod is required. Please also explain in detail what your new hook does.
|
|
||||||
|
|
||||||
3) Follow Forge coding guidelines (braces on newlines, spaces instead of tabs, etc)
|
|
||||||
|
|
||||||
For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge)
|
|
||||||
|
|
||||||
|
|
||||||
Contributor License Agreement
|
|
||||||
=============================
|
|
||||||
- You grant Forge a license to use your code contributed to the primary codebase (everything **not** under patches) in Forge, under the LGPLv2.1 license.
|
|
||||||
- You assign copyright ownership of your contributions to the patches codebase (everything under patches) to Forge, where it will be licensed under the LGPLv2.1 license.
|
|
||||||
|
|
||||||
Additionally, while 1.9.4 is being maintained, you will be asked to acknowledge these two additional clauses.
|
|
||||||
- You grant Forge a license to use your code contributed to the primary codebase (everything **not** under patches) in Forge, under the MinecraftForge license.
|
|
||||||
- You grant assign copyright ownership of your contributions to the patches codebase (everything under patches) to Forge, where it will be licensed under the MinecraftForge license.
|
|
||||||
|
|
||||||
"Forge" is Forge Development LLC, a legally incorporated entity in Oregon, USA.
|
|
||||||
+1
-1
@@ -10,7 +10,7 @@ alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptian
|
|||||||
of me taking over the project, who knows what Minecraft modding would be today.
|
of me taking over the project, who knows what Minecraft modding would be today.
|
||||||
|
|
||||||
Secondly, someone who has worked with me, and developed some of the core features
|
Secondly, someone who has worked with me, and developed some of the core features
|
||||||
that allow modding to he as functional, and as simple as it is, cpw. For developing
|
that allow modding to be as functional, and as simple as it is, cpw. For developing
|
||||||
FML, which stabelized the client and server modding ecosystem. As well as the base
|
FML, which stabelized the client and server modding ecosystem. As well as the base
|
||||||
loading system that allows us to modify Minecraft's code as elegently as possible.
|
loading system that allows us to modify Minecraft's code as elegently as possible.
|
||||||
|
|
||||||
|
|||||||
Vendored
+97
-37
@@ -1,65 +1,125 @@
|
|||||||
@Library('forge-shared-library')_
|
@Library('forge-shared-library')_
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'gradlewrapper:latest'
|
image 'gradle:7-jdk16'
|
||||||
args '-v gradlecache:/gradlecache'
|
//args '-v forgegc:/home/gradle/.gradle_cache/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
GRADLE_ARGS = --no-daemon' // No daemon for now as FG3 kinda derps. //'-Dorg.gradle.daemon.idletimeout=5000'
|
GRADLE_ARGS = '--no-daemon --console=plain' // No daemon for now as FG3 kinda derps. //'-Dorg.gradle.daemon.idletimeout=5000'
|
||||||
|
DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook')
|
||||||
|
DISCORD_PREFIX = "Job: Forge Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}"
|
||||||
|
JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png'
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('fetch') {
|
stage('notify_start') {
|
||||||
|
when {
|
||||||
|
not {
|
||||||
|
changeRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
git(url: 'https://github.com/MinecraftForge/MinecraftForge.git', changelog: true)
|
discordSend(
|
||||||
|
title: "${DISCORD_PREFIX} Started",
|
||||||
|
successful: true,
|
||||||
|
result: 'ABORTED', //White border
|
||||||
|
thumbnail: JENKINS_HEAD,
|
||||||
|
webhookURL: DISCORD_WEBHOOK
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cache(maxCacheSize: 250/*MB*/, caches: [
|
/*
|
||||||
[$class: 'ArbitraryFileCache', excludes: 'log.txt', includes: '**/*', path: '${WORKSPACE}/projects/forge/build/extractRangeMap'] //Cache the rangemap to help speed up builds
|
stage('pull_cache') {
|
||||||
]){
|
steps {
|
||||||
stage('buildandtest') {
|
sh 'cp -r /home/gradle/.gradle_cache/jdks/ /home/gradle/.gradle/jdks/'
|
||||||
steps {
|
sh 'cp -r /home/gradle/.gradle_cache/wrapper/ /home/gradle/.gradle/wrapper/'
|
||||||
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test'
|
sh 'cp -r /home/gradle/.gradle_cache/caches/ /home/gradle/.gradle/caches/'
|
||||||
script {
|
}
|
||||||
env.MYVERSION = sh(returnStdout: true, script: './gradlew properties -q | grep "version:" | awk \'{print $2}\'').trim()
|
}
|
||||||
}
|
*/
|
||||||
|
stage('setup') {
|
||||||
|
steps {
|
||||||
|
withGradle {
|
||||||
|
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue setup'
|
||||||
}
|
}
|
||||||
post {
|
script {
|
||||||
success {
|
env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "^version:" | cut -d" " -f2').trim()
|
||||||
writeChangelog(currentBuild, 'build/changelog.txt')
|
env.FMLONLY_VERSION = sh(returnStdout: true, script: './gradlew :fmlonly:properties -q | grep "^version:" | cut -d" " -f2').trim()
|
||||||
archiveArtifacts artifacts: 'build/changelog.txt', fingerprint: false
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('changelog') {
|
||||||
|
when {
|
||||||
|
not {
|
||||||
|
changeRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
writeChangelog(currentBuild, 'build/changelog.txt')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('publish') {
|
||||||
|
when {
|
||||||
|
not {
|
||||||
|
changeRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
environment {
|
||||||
|
CROWDIN = credentials('forge-crowdin')
|
||||||
|
KEYSTORE = credentials('forge-jenkins-keystore-old')
|
||||||
|
KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||||
|
KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) {
|
||||||
|
withGradle {
|
||||||
|
sh './gradlew ${GRADLE_ARGS} publish -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('publish') {
|
post {
|
||||||
when {
|
success {
|
||||||
not {
|
build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:forge ${env.MYVERSION} latest")], propagate: false, wait: false
|
||||||
changeRequest()
|
build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:fmlonly ${env.FMLONLY_VERSION} latest")], propagate: false, wait: false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
environment {
|
}
|
||||||
FORGE_MAVEN = credentials('forge-maven-forge-user')
|
}
|
||||||
CROWDIN = credentials('forge-crowdin')
|
stage('test_publish_pr') { //Publish to local repo to test full process, but don't include credentials so it can't sign/publish to maven
|
||||||
KEYSTORE = credentials('forge-jenkins-keystore-old')
|
when {
|
||||||
KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass')
|
changeRequest()
|
||||||
KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass')
|
}
|
||||||
}
|
environment {
|
||||||
steps {
|
CROWDIN = credentials('forge-crowdin')
|
||||||
sh './gradlew ${GRADLE_ARGS} forge:publish -PforgeMavenUser=${FORGE_MAVEN_USR} -PforgeMavenPassword=${FORGE_MAVEN_PSW} -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}'
|
}
|
||||||
//We're testing so use the test group
|
steps {
|
||||||
sh 'curl --user ${FORGE_MAVEN} http://files.minecraftforge.net/maven/manage/promote/latest/net.minecraftforge.test.forge/${MYVERSION}'
|
withGradle {
|
||||||
|
sh './gradlew ${GRADLE_ARGS} publish -PcrowdinKey=${CROWDIN}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
archiveArtifacts artifacts: 'build/libs/**/*.jar', fingerprint: true
|
script {
|
||||||
junit 'build/test-results/*/*.xml'
|
archiveArtifacts artifacts: 'projects/forge/build/libs/**/*.*', fingerprint: true, onlyIfSuccessful: true, allowEmptyArchive: true
|
||||||
jacoco sourcePattern: '**/src/*/java'
|
|
||||||
|
if (env.CHANGE_ID == null) { // This is unset for non-PRs
|
||||||
|
discordSend(
|
||||||
|
title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
|
||||||
|
description: '```\n' + getChanges(currentBuild) + '\n```',
|
||||||
|
successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"),
|
||||||
|
result: currentBuild.currentResult,
|
||||||
|
thumbnail: JENKINS_HEAD,
|
||||||
|
webhookURL: DISCORD_WEBHOOK
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Minecraft Forge
|
Minecraft Forge
|
||||||
Copyright (c) 2016-2018.
|
Copyright (c) 2016-${year}.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@ parts herein are licensed under the terms of the LGPL 2.1 found
|
|||||||
here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and
|
here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and
|
||||||
copied below.
|
copied below.
|
||||||
|
|
||||||
Homepage: http://MinecraftForge.net/
|
Homepage: http://minecraftforge.net/
|
||||||
http://github.com/MinecraftForge/MinecraftForge
|
https://github.com/MinecraftForge/MinecraftForge
|
||||||
|
|
||||||
|
|
||||||
A note on authorship:
|
A note on authorship:
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# How to install Forge: For Players
|
|
||||||
|
|
||||||
Go to [the Forge website](http://files.minecraftforge.net)
|
|
||||||
and select the minecraft version you wish to get forge for from the list.
|
|
||||||
|
|
||||||
You can download the installer for the *Recommended Build* or the
|
|
||||||
*Latest build* there. Latest builds may have newer features but may be
|
|
||||||
more unstable as a result. The installer will attempt to install forge
|
|
||||||
into your vanilla launcher environment, where you can then create a new
|
|
||||||
profile using that version and play the game!
|
|
||||||
|
|
||||||
For support and questions, visit [the Support Forum](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/).
|
|
||||||
|
|
||||||
Here is a short video from Rorax showing how to install and setup Forge:
|
|
||||||
|
|
||||||
[](https://www.youtube.com/watch?v=lB3ArN_-3Oc)
|
|
||||||
|
|
||||||
# How to install Forge: For Modders
|
|
||||||
|
|
||||||
[See the "Getting Started" section in the Forge Documentation](http://mcforge.readthedocs.io/en/latest/gettingstarted/).
|
|
||||||
|
|
||||||
# How to install Forge: For those wishing to work on Forge itself
|
|
||||||
|
|
||||||
If you wish to actually inspect Forge, submit PRs or otherwise work
|
|
||||||
with Forge itself, you're in the right place!
|
|
||||||
|
|
||||||
[See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/).
|
|
||||||
|
|
||||||
## Pull requests
|
|
||||||
|
|
||||||
[See the "Making Changes and Pull Requests" section in the Forge documentation](http://mcforge.readthedocs.io/en/latest/forgedev/#making-changes-and-pull-requests).
|
|
||||||
|
|
||||||
### Contributor License Agreement
|
|
||||||
We require all contributors to acknowledge the [Forge Contributor
|
|
||||||
License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge). Please ensure you have a valid email address
|
|
||||||
associated with your github account to do this. If you have previously
|
|
||||||
signed it, you should be OK.
|
|
||||||
+1330
-789
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
|||||||
|
/.gradle/
|
||||||
|
/build/
|
||||||
|
/out/
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
repositories {
|
||||||
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.ow2.asm:asm:9.1'
|
||||||
|
implementation 'org.ow2.asm:asm-tree:9.1'
|
||||||
|
implementation 'net.minecraftforge:srgutils:0.4.+'
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.json.JsonBuilder
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.objectweb.asm.ClassReader
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
import org.objectweb.asm.tree.ClassNode
|
||||||
|
import org.objectweb.asm.tree.FieldNode
|
||||||
|
import org.objectweb.asm.tree.MethodNode
|
||||||
|
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
|
abstract class BytecodeFinder extends DefaultTask {
|
||||||
|
@InputFile abstract RegularFileProperty getJar()
|
||||||
|
@OutputFile abstract RegularFileProperty getOutput()
|
||||||
|
|
||||||
|
BytecodeFinder() {
|
||||||
|
output.convention(project.layout.buildDirectory.dir(name).map { it.file("output.json") })
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
Util.init()
|
||||||
|
|
||||||
|
def outputFile = output.get().asFile
|
||||||
|
if (outputFile.exists())
|
||||||
|
outputFile.delete()
|
||||||
|
|
||||||
|
pre()
|
||||||
|
|
||||||
|
jar.get().asFile.withInputStream { i ->
|
||||||
|
new ZipInputStream(i).withCloseable { zin ->
|
||||||
|
ZipEntry zein
|
||||||
|
while ((zein = zin.nextEntry) != null) {
|
||||||
|
if (zein.name.endsWith('.class')) {
|
||||||
|
def node = new ClassNode(Opcodes.ASM9)
|
||||||
|
new ClassReader(zin).accept(node, 0)
|
||||||
|
process(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post()
|
||||||
|
outputFile.text = new JsonBuilder(getData()).toPrettyString()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected process(ClassNode node) {
|
||||||
|
if (node.fields != null) node.fields.each { process(node, it) }
|
||||||
|
if (node.methods != null) node.methods.each { process(node, it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected pre() {}
|
||||||
|
protected process(ClassNode parent, FieldNode node) {}
|
||||||
|
protected process(ClassNode parent, MethodNode node) {}
|
||||||
|
protected post() {}
|
||||||
|
protected abstract Object getData()
|
||||||
|
}
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import net.minecraftforge.srgutils.IMappingFile
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
|
abstract class CheckATs extends DefaultTask {
|
||||||
|
@InputFile abstract RegularFileProperty getInheritance()
|
||||||
|
@InputFiles abstract ConfigurableFileCollection getAts()
|
||||||
|
@InputFile @Optional abstract RegularFileProperty getMappings()
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
def mappings = mappings.map { IMappingFile.load(it.asFile) }.getOrNull()
|
||||||
|
Util.init()
|
||||||
|
def parse = { line ->
|
||||||
|
def idx = line.indexOf('#')
|
||||||
|
def comment = idx == -1 ? null : line.substring(idx)
|
||||||
|
if (idx != -1) line = line.substring(0, idx - 1)
|
||||||
|
def (modifier, cls, desc) = (line.trim() + ' ').split(' ', -1)
|
||||||
|
def key = cls + (desc.isEmpty() ? '' : ' ' + desc)
|
||||||
|
return [modifier, cls, desc, comment, key]
|
||||||
|
}
|
||||||
|
def accessLevel = { access ->
|
||||||
|
if ((access & Opcodes.ACC_PUBLIC) != 0) return 3
|
||||||
|
if ((access & Opcodes.ACC_PROTECTED) != 0) return 2
|
||||||
|
if ((access & Opcodes.ACC_PRIVATE) != 0) return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
def accessStr = { access ->
|
||||||
|
if (access.endsWith('-f') || access.endsWith('+f'))
|
||||||
|
return 4
|
||||||
|
switch (access.toLowerCase()) {
|
||||||
|
case 'public': return 3
|
||||||
|
case 'protected': return 2
|
||||||
|
case 'default': return 1
|
||||||
|
case 'private': return 0
|
||||||
|
default: return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def json = inheritance.get().asFile.json()
|
||||||
|
|
||||||
|
ats.each { f ->
|
||||||
|
TreeMap lines = [:]
|
||||||
|
def group = null
|
||||||
|
for (def line : f.readLines()) {
|
||||||
|
if (line.isEmpty()) continue
|
||||||
|
if (line.startsWith('#group ')) {
|
||||||
|
def (modifier, cls, desc, comment, key) = parse.call(line.substring(7))
|
||||||
|
|
||||||
|
if (desc != '*' && desc != '*()' && desc != '<init>')
|
||||||
|
throw new IllegalStateException('Invalid group: ' + line)
|
||||||
|
|
||||||
|
group = [modifier: modifier, cls: cls, desc: desc, comment: comment,
|
||||||
|
existing: [] as Set,
|
||||||
|
children: [] as TreeSet,
|
||||||
|
group: true
|
||||||
|
]
|
||||||
|
if (lines.containsKey(key))
|
||||||
|
throw new IllegalStateException('Duplicate group: ' + line)
|
||||||
|
|
||||||
|
lines[key] = group
|
||||||
|
} else if (group != null) {
|
||||||
|
if (line.startsWith('#endgroup')) {
|
||||||
|
group = null
|
||||||
|
} else {
|
||||||
|
def (modifier, cls, desc, comment, key) = parse.call(line)
|
||||||
|
group['existing'].add(key)
|
||||||
|
}
|
||||||
|
} else if (line.startsWith('#endgroup')) {
|
||||||
|
throw new IllegalStateException('Invalid group ending: ' + line)
|
||||||
|
} else if (line.startsWith('#')) {
|
||||||
|
//Nom
|
||||||
|
} else {
|
||||||
|
def (modifier, cls, desc, comment, key) = parse.call(line)
|
||||||
|
if (lines.containsKey(key)) {
|
||||||
|
println('Duplicate: ' + line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lines[key] = [modifier: modifier, cls: cls, desc: desc, comment: comment, group: false]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process Groups, this will remove any entries outside the group that is covered by the group
|
||||||
|
for (def key : new ArrayList<>(lines.keySet())) {
|
||||||
|
def entry = lines.get(key)
|
||||||
|
if (entry != null && entry['group']) {
|
||||||
|
def cls = entry['cls']
|
||||||
|
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
||||||
|
if (jcls == null) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Group: ' + key)
|
||||||
|
} else if ('*' == entry['desc']) {
|
||||||
|
if (!jcls.containsKey('fields')) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Group, Class has no fields: ' + key)
|
||||||
|
} else {
|
||||||
|
jcls['fields'].each { field, value ->
|
||||||
|
def fkey = cls + ' ' + field
|
||||||
|
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
||||||
|
if (lines.containsKey(fkey)) {
|
||||||
|
lines.remove(fkey)
|
||||||
|
} else if (!entry['existing'].contains(fkey)) {
|
||||||
|
println('Added: ' + fkey)
|
||||||
|
}
|
||||||
|
entry['children'].add(fkey)
|
||||||
|
} else if (lines.containsKey(fkey)) {
|
||||||
|
lines.remove(fkey)
|
||||||
|
println('Removed: ' + fkey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||||
|
}
|
||||||
|
} else if ('*()' == entry['desc']) {
|
||||||
|
if (!jcls.containsKey('methods')) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Group, Class has no methods: ' + key)
|
||||||
|
} else {
|
||||||
|
jcls['methods'].each{ mtd, value ->
|
||||||
|
if (mtd.startsWith('<clinit>') || mtd.startsWith('lambda$'))
|
||||||
|
return
|
||||||
|
key = cls + ' ' + mtd.replace(' ', '')
|
||||||
|
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
||||||
|
if (lines.containsKey(key)) {
|
||||||
|
lines.remove(key)
|
||||||
|
} else if (!entry['existing'].contains(key)) {
|
||||||
|
println('Added: ' + key)
|
||||||
|
}
|
||||||
|
entry['children'].add(key)
|
||||||
|
} else if (lines.containsKey(key)) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Removed: ' + key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||||
|
}
|
||||||
|
} else if ('<init>' == entry['desc']) { //Make all public non-abstract subclasses
|
||||||
|
json.each{ tcls,value ->
|
||||||
|
if (!value.containsKey('methods') || ((value['access'] & Opcodes.ACC_ABSTRACT) != 0))
|
||||||
|
return
|
||||||
|
def parents = [] as Set
|
||||||
|
def parent = tcls
|
||||||
|
while (parent != null && json.containsKey(parent)) {
|
||||||
|
parents.add(parent)
|
||||||
|
def p = json[parent]
|
||||||
|
parent = p == null ? null : p['superName']
|
||||||
|
}
|
||||||
|
if (parents.contains(cls.replaceAll('\\.', '/'))) {
|
||||||
|
value['methods'].each{ mtd, v ->
|
||||||
|
if (mtd.startsWith('<init>')) {
|
||||||
|
def child = tcls.replaceAll('/', '\\.') + ' ' + mtd.replace(' ', '')
|
||||||
|
if (accessLevel.call(v['access']) < 3) {
|
||||||
|
if (lines.containsKey(child)) {
|
||||||
|
lines.remove(child)
|
||||||
|
} else if (!entry['existing'].contains(child)) {
|
||||||
|
println('Added: ' + child)
|
||||||
|
}
|
||||||
|
entry['children'].add(child)
|
||||||
|
} else if (lines.containsKey(child)) {
|
||||||
|
lines.remove(child)
|
||||||
|
println('Removed: ' + child)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process normal lines, remove invalid and remove narrowing
|
||||||
|
for (def key : new ArrayList<>(lines.keySet())) {
|
||||||
|
def entry = lines.get(key)
|
||||||
|
if (entry != null && !entry['group']) {
|
||||||
|
def cls = entry['cls']
|
||||||
|
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
||||||
|
if (jcls == null) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid: ' + key)
|
||||||
|
} else if (entry['desc'] == '') {
|
||||||
|
if (accessLevel.call(jcls['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Narrowing: ' + key)
|
||||||
|
}
|
||||||
|
} else if (!entry['desc'].contains('(')) {
|
||||||
|
if (!jcls.containsKey('fields') || !jcls['fields'].containsKey(entry['desc'])) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid: ' + key)
|
||||||
|
} else {
|
||||||
|
def value = jcls['fields'][entry['desc']]
|
||||||
|
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Narrowing: ' + key)
|
||||||
|
println(entry.comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
def jdesc = entry['desc'].replace('(', ' (')
|
||||||
|
if (!jcls.containsKey('methods') || !jcls['methods'].containsKey(jdesc)) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid: ' + key)
|
||||||
|
} else {
|
||||||
|
def value = jcls['methods'][jdesc]
|
||||||
|
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||||
|
lines.remove(key)
|
||||||
|
println('Invalid Narrowing: ' + key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def data = []
|
||||||
|
def remapComment = { entry ->
|
||||||
|
if (!mappings || !entry || !entry.desc) return null
|
||||||
|
def comment = entry.comment?.substring(1)?.trim()
|
||||||
|
def jsonCls = json.get(entry.cls.replaceAll('\\.', '/'))
|
||||||
|
def mappingsClass = mappings?.getClass(jsonCls.name)
|
||||||
|
if (!mappingsClass) return entry.comment
|
||||||
|
def idx = entry.desc.indexOf('(')
|
||||||
|
def mappedName = idx == -1
|
||||||
|
? mappingsClass.remapField(entry.desc)
|
||||||
|
: mappingsClass.remapMethod(entry.desc.substring(0, idx), entry.desc.substring(idx))
|
||||||
|
if (!mappedName) return entry.comment
|
||||||
|
if (mappedName == '<init>')
|
||||||
|
mappedName = 'constructor'
|
||||||
|
|
||||||
|
if (comment?.startsWith(mappedName))
|
||||||
|
return '# ' + comment
|
||||||
|
if (comment && comment.indexOf(' ') != -1) {
|
||||||
|
def split = comment.split(" - ").toList()
|
||||||
|
if (split[0].indexOf(' ') != -1)
|
||||||
|
// The first string is more than one word, so append before it
|
||||||
|
return "# ${mappedName} - ${comment}"
|
||||||
|
split.remove(0)
|
||||||
|
return "# ${mappedName} - ${String.join(' - ', split)}"
|
||||||
|
}
|
||||||
|
return '# ' + mappedName
|
||||||
|
}
|
||||||
|
lines.each { key,value ->
|
||||||
|
if (!value.group) {
|
||||||
|
def comment = remapComment.call(value)
|
||||||
|
data.add(value.modifier + ' ' + key + (comment ? ' ' + comment : ''))
|
||||||
|
} else {
|
||||||
|
data.add('#group ' + value.modifier + ' ' + key + (value.comment == null ? '' : ' ' + value.comment))
|
||||||
|
value.children.each {
|
||||||
|
def line = value.modifier + ' ' + it
|
||||||
|
def (modifier, cls, desc, comment) = parse.call(line)
|
||||||
|
comment = remapComment.call([modifier: modifier, cls: cls, desc: desc, comment: comment])
|
||||||
|
data.add(line + (comment ? ' ' + comment : ''))
|
||||||
|
}
|
||||||
|
data.add('#endgroup')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.text = data.join('\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
import org.objectweb.asm.ClassReader
|
||||||
|
import org.objectweb.asm.ClassVisitor
|
||||||
|
import org.objectweb.asm.MethodVisitor
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
import org.objectweb.asm.Type
|
||||||
|
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
|
abstract class CheckExcs extends DefaultTask {
|
||||||
|
@InputFile abstract RegularFileProperty getBinary()
|
||||||
|
@InputFiles abstract ConfigurableFileCollection getExcs()
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
Util.init()
|
||||||
|
def known = []
|
||||||
|
binary.get().asFile.withInputStream { i ->
|
||||||
|
new ZipInputStream(i).withCloseable { zin ->
|
||||||
|
def visitor = new ClassVisitor(Opcodes.ASM9) {
|
||||||
|
private String cls
|
||||||
|
@Override
|
||||||
|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||||
|
this.cls = name
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||||
|
known.add(this.cls + '.' + name + descriptor)
|
||||||
|
super.visitMethod(access, name, descriptor, signature, exceptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ZipEntry zein
|
||||||
|
while ((zein = zin.nextEntry) != null) {
|
||||||
|
if (zein.name.endsWith('.class')) {
|
||||||
|
ClassReader reader = new ClassReader(zin)
|
||||||
|
reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
excs.each { f ->
|
||||||
|
def lines = []
|
||||||
|
f.eachLine { line ->
|
||||||
|
def idx = line.indexOf('#')
|
||||||
|
if (idx == 0 || line.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def comment = idx == -1 ? null : line.substring(idx)
|
||||||
|
if (idx != -1) line = line.substring(0, idx - 1)
|
||||||
|
|
||||||
|
if (!line.contains('=')) {
|
||||||
|
println('Invalid: ' + line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def (key, value) = line.split('=', 2)
|
||||||
|
if (!known.contains(key)) {
|
||||||
|
println('Unknown: ' + line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def (cls, desc) = key.split('\\.', 2)
|
||||||
|
if (!desc.contains('(')) {
|
||||||
|
println('Invalid: ' + line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def name = desc.split('\\(', 2)[0]
|
||||||
|
desc = '(' + desc.split('\\(', 2)[1]
|
||||||
|
|
||||||
|
def (exceptions, args) = value.contains('|') ? value.split('|', 2) : [value, '']
|
||||||
|
|
||||||
|
if (args.split(',').length != Type.getArgumentTypes(desc).length) {
|
||||||
|
println('Invalid: ' + line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
lines.add(line)
|
||||||
|
}
|
||||||
|
f.text = lines.sort().join('\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputDirectory
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
abstract class CheckPatches extends DefaultTask {
|
||||||
|
@InputDirectory abstract DirectoryProperty getPatchDir()
|
||||||
|
@Input boolean autoFix = false
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
def hasS2SArtifact = [
|
||||||
|
Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewArea.java.patch"),
|
||||||
|
Paths.get("patches/minecraft/net/minecraft/data/models/blockstates/Variant.java.patch")
|
||||||
|
]
|
||||||
|
|
||||||
|
def verified = true;
|
||||||
|
patchDir.get().asFileTree.each { patch ->
|
||||||
|
def patchPath = project.rootDir.toPath().relativize(patch.toPath())
|
||||||
|
verified &= verifyPatch(patch, autoFix, patchPath.toString(), hasS2SArtifact.contains(patchPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!verified)
|
||||||
|
throw new RuntimeException('One or more patches failed verification. Check the log for errors.')
|
||||||
|
}
|
||||||
|
|
||||||
|
def verifyPatch(patch, fix, patchPath, hasS2SArtifact) {
|
||||||
|
def hunk_start_pattern = Pattern.compile('^@@ -[0-9,]* \\+[0-9,_]* @@$')
|
||||||
|
def white_space_pattern = Pattern.compile('^[+\\-]\\s*$')
|
||||||
|
def import_pattern = Pattern.compile('^[+\\-]\\s*import.*')
|
||||||
|
def field_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^=;]*)(=.*)?;\\s*$')
|
||||||
|
def method_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^(]*)[(]([^)]*)?[)]\\s*[{]\\s*$')
|
||||||
|
def class_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final[\\s]*)?(class|interface)([^{]*)[{]\\s*$')
|
||||||
|
|
||||||
|
def accessMap = [("private"):0, (null):1, ("protected"):2, ("public"):3]
|
||||||
|
|
||||||
|
def hasProblem = false;
|
||||||
|
def lines = patch.readLines()
|
||||||
|
|
||||||
|
def hunksStart = 0
|
||||||
|
def onlyWhiteSpace = false
|
||||||
|
|
||||||
|
def didFix = false
|
||||||
|
def newLines = []
|
||||||
|
def whiteSpaceErrors = []
|
||||||
|
|
||||||
|
// First two lines are file name ++/-- and we do not care
|
||||||
|
newLines.add(lines[0] + '\n')
|
||||||
|
newLines.add(lines[1] + '\n')
|
||||||
|
|
||||||
|
int i = 2
|
||||||
|
for (; i < lines.size(); ++i) {
|
||||||
|
def line = lines[i]
|
||||||
|
newLines.add(line + '\n')
|
||||||
|
|
||||||
|
if (hunk_start_pattern.matcher(line).find()) {
|
||||||
|
if (onlyWhiteSpace) {
|
||||||
|
if (fix || hasS2SArtifact) {
|
||||||
|
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||||
|
def toRemove = i - hunksStart;
|
||||||
|
while (toRemove-- > 0)
|
||||||
|
newLines.remove(newLines.size() - 1)
|
||||||
|
didFix = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!whiteSpaceErrors.empty)
|
||||||
|
hasProblem = true
|
||||||
|
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
||||||
|
whiteSpaceErrors.clear()
|
||||||
|
}
|
||||||
|
hunksStart = i
|
||||||
|
onlyWhiteSpace = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.startsWithAny('+','-')) {
|
||||||
|
def prefixChange = false
|
||||||
|
def prevLine = lines[i - 1]
|
||||||
|
|
||||||
|
if (line.charAt(0) == (char)'+' && prevLine.charAt(0) == (char)'-') {
|
||||||
|
def prevTrim = prevLine.substring(1).replaceAll("\\s", "")
|
||||||
|
def currTrim = line.substring(1).replaceAll("\\s", "")
|
||||||
|
|
||||||
|
if (prevTrim.equals(currTrim)) {
|
||||||
|
prefixChange = true
|
||||||
|
}
|
||||||
|
|
||||||
|
def pMatcher = field_pattern.matcher(prevLine)
|
||||||
|
def cMatcher = field_pattern.matcher(line)
|
||||||
|
|
||||||
|
if (pMatcher.find() && cMatcher.find() &&
|
||||||
|
pMatcher.group(6) == cMatcher.group(6) && // = ...
|
||||||
|
pMatcher.group(5) == cMatcher.group(5) && // field name
|
||||||
|
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||||
|
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||||
|
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
|
||||||
|
pMatcher = method_pattern.matcher(prevLine)
|
||||||
|
cMatcher = method_pattern.matcher(line)
|
||||||
|
|
||||||
|
if (pMatcher.find() && cMatcher.find() &&
|
||||||
|
pMatcher.group(6) == cMatcher.group(6) && // params
|
||||||
|
pMatcher.group(5) == cMatcher.group(5) && // <T> void name
|
||||||
|
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||||
|
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||||
|
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
|
||||||
|
pMatcher = class_pattern.matcher(prevLine)
|
||||||
|
cMatcher = class_pattern.matcher(line)
|
||||||
|
|
||||||
|
if (pMatcher.find() && cMatcher.find() &&
|
||||||
|
pMatcher.group(6) == cMatcher.group(6) && // ClassName<> extends ...
|
||||||
|
pMatcher.group(5) == cMatcher.group(5) && // class | interface
|
||||||
|
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||||
|
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||||
|
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.charAt(0) == (char)'-' && i + 1 < lines.size()) {
|
||||||
|
def nextLine = lines[i + 1]
|
||||||
|
if (nextLine.charAt(0) == (char)'+') {
|
||||||
|
def nextTrim = nextLine.substring(1).replaceAll("\\s", "")
|
||||||
|
def currTrim = line.substring(1).replaceAll("\\s", "")
|
||||||
|
|
||||||
|
if (nextTrim.equals(currTrim)) {
|
||||||
|
prefixChange = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def isWhiteSpaceChange = white_space_pattern.matcher(line).find()
|
||||||
|
|
||||||
|
if (!prefixChange && !isWhiteSpaceChange) {
|
||||||
|
onlyWhiteSpace = hasS2SArtifact && import_pattern.matcher(line).find()
|
||||||
|
}
|
||||||
|
else if (isWhiteSpaceChange) {
|
||||||
|
def prevLineChange = prevLine.startsWithAny('+','-')
|
||||||
|
def nextLineChange = i + 1 < lines.size() && lines[i + 1].startsWithAny('+','-')
|
||||||
|
|
||||||
|
if (!prevLineChange && !nextLineChange) {
|
||||||
|
whiteSpaceErrors.add(String.format("Patch contains white space change in valid hunk at line %d (cannot auto fix), file: %s", i + 1, patchPath))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.contains("\t")) {
|
||||||
|
if (!fix) {
|
||||||
|
logger.lifecycle("Patch contains tabs on line {}, file: {}", i + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.lifecycle("Fixing tabs on line {}, file: {}", i + 1, patchPath)
|
||||||
|
line = line.replaceAll('\t', ' ')
|
||||||
|
newLines.remove(newLines.size() - 1)
|
||||||
|
newLines.add(line + '\n')
|
||||||
|
didFix = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import_pattern.matcher(line).find() && !hasS2SArtifact) {
|
||||||
|
logger.lifecycle("Patch contains import change on line {}, file: {}", i + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyWhiteSpace) {
|
||||||
|
if (fix || hasS2SArtifact) {
|
||||||
|
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||||
|
def toRemove = i - hunksStart;
|
||||||
|
while (toRemove-- > 0)
|
||||||
|
newLines.remove(newLines.size() - 1)
|
||||||
|
didFix = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||||
|
hasProblem = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!whiteSpaceErrors.empty)
|
||||||
|
hasProblem = true
|
||||||
|
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (didFix) {
|
||||||
|
if (newLines.size() <= 2) {
|
||||||
|
logger.lifecycle("Patch is now empty removing, file: {}", patchPath)
|
||||||
|
Files.delete(patch.toPath())
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!hasS2SArtifact)
|
||||||
|
logger.lifecycle("*** Updating patch file. Please run setup then genPatches again. ***")
|
||||||
|
patch.withWriter('UTF-8') { writer ->
|
||||||
|
newLines.each { l -> writer.write(l) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !hasProblem
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
abstract class CheckSAS extends DefaultTask {
|
||||||
|
@InputFile abstract RegularFileProperty getInheritance()
|
||||||
|
@InputFiles abstract ConfigurableFileCollection getSass()
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
Util.init()
|
||||||
|
def json = inheritance.get().asFile.json()
|
||||||
|
|
||||||
|
sass.each { f ->
|
||||||
|
def lines = []
|
||||||
|
f.eachLine { line ->
|
||||||
|
if (line[0] == '\t') return //Skip any tabbed lines, those are ones we add
|
||||||
|
def idx = line.indexOf('#')
|
||||||
|
if (idx == 0 || line.isEmpty()) {
|
||||||
|
lines.add(line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def comment = idx == -1 ? null : line.substring(idx)
|
||||||
|
if (idx != -1) line = line.substring(0, idx - 1)
|
||||||
|
def (cls, desc) = (line.trim() + ' ').split(' ', -1)
|
||||||
|
cls = cls.replaceAll('\\.', '/')
|
||||||
|
desc = desc.replace('(', ' (')
|
||||||
|
|
||||||
|
if (json[cls] == null || (!desc.isEmpty() && (json[cls]['methods'] == null || json[cls]['methods'][desc] == null))) {
|
||||||
|
println('Invalid: ' + line)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Class SAS
|
||||||
|
if (desc.isEmpty()) {
|
||||||
|
lines.add(cls + (comment == null ? '' : ' ' + comment))
|
||||||
|
if (json[cls]['methods'] != null)
|
||||||
|
(json[cls]['methods'] as TreeMap).each {
|
||||||
|
findChildMethods(json, cls, it.key).each { lines.add('\t' + it) }
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Method SAS
|
||||||
|
lines.add(cls + ' ' + desc.replace(' ', '') + (comment == null ? '' : ' ' + comment))
|
||||||
|
findChildMethods(json, cls, desc).each { lines.add('\t' + it) }
|
||||||
|
}
|
||||||
|
f.text = lines.join('\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static findChildMethods(json, cls, desc)
|
||||||
|
{
|
||||||
|
return json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls}
|
||||||
|
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer
|
||||||
|
|
||||||
|
public class ClosureHelper {
|
||||||
|
BiConsumer<String, Closure> callback
|
||||||
|
|
||||||
|
public ClosureHelper(Closure cl, BiConsumer<String, Closure> callback) {
|
||||||
|
this.callback = callback
|
||||||
|
apply(this, cl)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def methodMissing(String name, Object args) {
|
||||||
|
if (!args.class.isArray()) return
|
||||||
|
Object[] aargs = (Object[])args
|
||||||
|
|
||||||
|
if (aargs.length == 1 && aargs[0] instanceof Closure) {
|
||||||
|
this.callback.accept(name, (Closure)aargs[0])
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException('Unknown method: "' + name + '" with arguments ' + args + ' for ' + this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> T apply(T obj, Closure cl) {
|
||||||
|
cl.delegate = obj
|
||||||
|
cl.resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
|
cl()
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
|
abstract class Crowdin extends DefaultTask {
|
||||||
|
@Input abstract Property<String> getId()
|
||||||
|
@Input @Optional abstract Property<String> getKey()
|
||||||
|
@Input boolean json = true
|
||||||
|
@OutputFile abstract RegularFileProperty getOutput()
|
||||||
|
@OutputFile abstract RegularFileProperty getExport()
|
||||||
|
|
||||||
|
Crowdin() {
|
||||||
|
outputs.upToDateWhen{ false }
|
||||||
|
id.convention('minecraft-forge')
|
||||||
|
output.convention(project.layout.buildDirectory.dir(name).map {it.file("output.zip") })
|
||||||
|
export.convention(project.layout.buildDirectory.dir(name).map {it.file("export.json") })
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
def run() {
|
||||||
|
File outputFile = output.get().asFile
|
||||||
|
File exportFile = export.get().asFile
|
||||||
|
if (outputFile.exists())
|
||||||
|
outputFile.delete()
|
||||||
|
|
||||||
|
if (!key.isPresent())
|
||||||
|
return
|
||||||
|
String key = this.key.get()
|
||||||
|
String id = this.id.get()
|
||||||
|
|
||||||
|
// Force an export
|
||||||
|
new URL("https://api.crowdin.com/api/project/${id}/export?key=${key}").withInputStream { i ->
|
||||||
|
exportFile.withOutputStream { it << i }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exportFile.text.contains('success')) {
|
||||||
|
throw new RuntimeException("Crowdin export failed, see ${exportFile} for more info")
|
||||||
|
}
|
||||||
|
|
||||||
|
new URL("https://api.crowdin.com/api/project/${id}/download/all.zip?key=${key}").withInputStream { i ->
|
||||||
|
new ZipInputStream(i).withCloseable { zin ->
|
||||||
|
outputFile.withOutputStream { out ->
|
||||||
|
new ZipOutputStream(out).withCloseable { zout ->
|
||||||
|
ZipEntry zein
|
||||||
|
while ((zein = zin.nextEntry) != null) {
|
||||||
|
if (zein.isDirectory()) {
|
||||||
|
zout.putNextEntry(new ZipEntry(zein.name))
|
||||||
|
} else {
|
||||||
|
// 1.13+ uses json
|
||||||
|
if (zein.name.endsWith('.json') == json) {
|
||||||
|
ZipEntry zeout = new ZipEntry(json ? zein.name.toLowerCase() : zein.name)
|
||||||
|
zeout.time = 1
|
||||||
|
zout.putNextEntry(zeout)
|
||||||
|
zout << zin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.OutputFiles
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
abstract class DownloadLibraries extends DefaultTask {
|
||||||
|
@InputFile abstract RegularFileProperty getInput()
|
||||||
|
@OutputDirectory abstract DirectoryProperty getOutput()
|
||||||
|
@OutputFile abstract RegularFileProperty getLibrariesOutput()
|
||||||
|
|
||||||
|
DownloadLibraries() {
|
||||||
|
output.convention(project.layout.buildDirectory.dir(name))
|
||||||
|
librariesOutput.convention(project.layout.buildDirectory.dir(name).map(d -> d.file('libraries.txt')))
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
def run() {
|
||||||
|
Util.init()
|
||||||
|
File outputDir = output.get().asFile
|
||||||
|
def libraries = new ArrayList()
|
||||||
|
|
||||||
|
def json = input.get().asFile.json().libraries.each { lib ->
|
||||||
|
//TODO: Thread?
|
||||||
|
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
|
||||||
|
artifacts.each{ art ->
|
||||||
|
def target = new File(outputDir, art.path)
|
||||||
|
libraries.add(target.absolutePath)
|
||||||
|
if (!target.exists() || !art.sha1.equals(target.sha1())) {
|
||||||
|
project.logger.lifecycle("Downloading ${art.url}")
|
||||||
|
if (!target.parentFile.exists()) {
|
||||||
|
target.parentFile.mkdirs()
|
||||||
|
}
|
||||||
|
new URL(art.url).withInputStream { i ->
|
||||||
|
target.withOutputStream { it << i }
|
||||||
|
}
|
||||||
|
if (!art.sha1.equals(target.sha1())) {
|
||||||
|
throw new IllegalStateException("Failed to download ${art.url} to ${target.canonicalPath} SHA Mismatch")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Files.write(librariesOutput.get().asFile.toPath(), libraries)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.transform.EqualsAndHashCode
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import java.util.HashMap
|
||||||
|
import java.util.TreeMap
|
||||||
|
import java.util.TreeSet
|
||||||
|
import java.util.function.BiConsumer
|
||||||
|
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
import org.objectweb.asm.Type
|
||||||
|
import org.objectweb.asm.tree.ClassNode
|
||||||
|
import org.objectweb.asm.tree.FieldNode
|
||||||
|
import org.objectweb.asm.tree.MethodNode
|
||||||
|
|
||||||
|
import static org.objectweb.asm.Opcodes.*
|
||||||
|
|
||||||
|
abstract class FieldCompareFinder extends BytecodeFinder {
|
||||||
|
@Nested
|
||||||
|
Map<String, Search> fields = [:] as HashMap
|
||||||
|
@Internal
|
||||||
|
Map<Search, String> fieldsReverse = [:] as HashMap
|
||||||
|
@Internal
|
||||||
|
Map<String, Set<ObjectTarget>> targets = [:] as TreeMap
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected pre() {
|
||||||
|
//fields.each{ k,v -> logger.lifecycle("Fields: " + k + ' ' + v) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected process(ClassNode parent, MethodNode node) {
|
||||||
|
def last = null
|
||||||
|
def parentInstance = new ObjectTarget(owner: parent.name, name: '', desc: '')
|
||||||
|
for (int x = 0; x < node.instructions.size(); x++) {
|
||||||
|
def current = node.instructions.get(x)
|
||||||
|
if (current.opcode == IF_ACMPEQ || current.opcode == IF_ACMPNE) {
|
||||||
|
if (last != null && (last.opcode == GETSTATIC || last.opcode == GETFIELD)) {
|
||||||
|
def target = new Search(cls: last.owner, name: last.name)
|
||||||
|
def wanted = fieldsReverse.get(target)
|
||||||
|
def original = fields.get(wanted)
|
||||||
|
def instance = new ObjectTarget(owner: parent.name, name: node.name, desc: node.desc)
|
||||||
|
if (wanted != null && (original.blacklist == null || (!original.blacklist.contains(instance) && !original.blacklist.contains(parentInstance)))) {
|
||||||
|
targets.computeIfAbsent(wanted, { k -> new TreeSet() }).add(instance)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last = current
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
|
@Override
|
||||||
|
protected Object getData() {
|
||||||
|
def ret = [:] as HashMap
|
||||||
|
targets.forEach{ k, v ->
|
||||||
|
def e = fields.get(k)
|
||||||
|
ret[k] = [
|
||||||
|
cls: e.cls,
|
||||||
|
name: e.name,
|
||||||
|
replacement: e.replacement,
|
||||||
|
targets: v
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
@EqualsAndHashCode(excludes = ['replacement', 'blacklist'])
|
||||||
|
public static class Search {
|
||||||
|
@Input
|
||||||
|
String cls
|
||||||
|
|
||||||
|
@Input
|
||||||
|
String name
|
||||||
|
|
||||||
|
@Input
|
||||||
|
String replacement
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@Optional
|
||||||
|
Set<ObjectTarget> blacklist
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString() {
|
||||||
|
return cls + '.' + name
|
||||||
|
}
|
||||||
|
|
||||||
|
def blacklist(def owner, def name, def desc) {
|
||||||
|
if (blacklist == null)
|
||||||
|
blacklist = new HashSet()
|
||||||
|
blacklist.add(new ObjectTarget(owner: owner, name: name, desc: desc))
|
||||||
|
}
|
||||||
|
def blacklist(def owner) {
|
||||||
|
blacklist(owner, '', '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def fields(Closure cl) {
|
||||||
|
new ClosureHelper(cl, {name, ccl ->
|
||||||
|
def search = ClosureHelper.apply(new Search(), ccl)
|
||||||
|
this.fields.put(name, search)
|
||||||
|
this.fieldsReverse.put(search, name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.bundling.Zip
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
import org.gradle.api.provider.SetProperty
|
||||||
|
|
||||||
|
abstract class InstallerJar extends Zip {
|
||||||
|
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
||||||
|
|
||||||
|
InstallerJar() {
|
||||||
|
archiveClassifier.set('installer')
|
||||||
|
archiveExtension.set('jar') // Needs to be Zip task to not override Manifest, so set extension
|
||||||
|
destinationDirectory.set(project.layout.buildDirectory.dir('libs'))
|
||||||
|
|
||||||
|
def installerJson = project.tasks.installerJson
|
||||||
|
def launcherJson = project.tasks.launcherJson
|
||||||
|
def downloadInstaller = project.tasks.downloadInstaller
|
||||||
|
|
||||||
|
dependsOn(installerJson, launcherJson, downloadInstaller)
|
||||||
|
from(installerJson, launcherJson)
|
||||||
|
|
||||||
|
from(project.rootProject.file('/src/main/resources/url.png'))
|
||||||
|
project.afterEvaluate {
|
||||||
|
from(project.zipTree(downloadInstaller.output)) {
|
||||||
|
duplicatesStrategy = 'exclude'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!System.env.MAVEN_USER) {
|
||||||
|
dependsOn(project.universalJar)
|
||||||
|
from(project.universalJar) {
|
||||||
|
into '/maven/' + project.group.replace('.', '/') + '/' + project.universalJar.archiveBaseName.get() + '/' + project.version + '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
packedDependencies.get().forEach {
|
||||||
|
def jarTask = project.rootProject.getTasks().findByPath(it)
|
||||||
|
dependsOn(jarTask)
|
||||||
|
from(jarTask) {
|
||||||
|
into '/maven/' + jarTask.project.group.replace('.', '/') + '/' + jarTask.archiveBaseName.get() + '/' + jarTask.project.version + '/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.json.JsonBuilder
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.provider.SetProperty
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
abstract class InstallerJson extends DefaultTask {
|
||||||
|
@OutputFile abstract RegularFileProperty getOutput()
|
||||||
|
@InputFiles abstract ConfigurableFileCollection getInput()
|
||||||
|
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
||||||
|
@Input @Optional final Map<String, Object> libraries = new LinkedHashMap<>()
|
||||||
|
@Input Map<String, Object> json = new LinkedHashMap<>()
|
||||||
|
@InputFile abstract RegularFileProperty getIcon()
|
||||||
|
@Input abstract Property<String> getLauncherJsonName()
|
||||||
|
@Input abstract Property<String> getLogo()
|
||||||
|
@Input abstract Property<String> getMirrors()
|
||||||
|
@Input abstract Property<String> getWelcome()
|
||||||
|
|
||||||
|
InstallerJson() {
|
||||||
|
getLauncherJsonName().convention('/version.json')
|
||||||
|
getLogo().convention('/big_logo.png')
|
||||||
|
getMirrors().convention('https://files.minecraftforge.net/mirrors-2.0.json')
|
||||||
|
getWelcome().convention("Welcome to the simple ${project.name.capitalize()} installer.")
|
||||||
|
|
||||||
|
getOutput().convention(project.layout.buildDirectory.file('install_profile.json'))
|
||||||
|
|
||||||
|
['client', 'server'].each { side ->
|
||||||
|
['slim', 'extra'].each { type ->
|
||||||
|
def tsk = project.tasks.getByName("download${side.capitalize()}${type.capitalize()}")
|
||||||
|
dependsOn(tsk)
|
||||||
|
input.from(tsk.output)
|
||||||
|
}
|
||||||
|
def tsk = project.tasks.getByName("create${side.capitalize()}SRG")
|
||||||
|
dependsOn(tsk)
|
||||||
|
input.from(tsk.output)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
project.afterEvaluate {
|
||||||
|
(packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]).forEach {
|
||||||
|
dependsOn(it)
|
||||||
|
input.from it.archiveFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
def libs = libraries
|
||||||
|
for (def child : packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]) {
|
||||||
|
def dep = Util.getMavenDep(child)
|
||||||
|
def path = Util.getMavenPath(child)
|
||||||
|
libs.put(dep.toString(), [
|
||||||
|
name: dep,
|
||||||
|
downloads: [
|
||||||
|
artifact: [
|
||||||
|
path: path,
|
||||||
|
url: "https://maven.minecraftforge.net/${path}",
|
||||||
|
sha1: child.archiveFile.get().asFile.sha1(),
|
||||||
|
size: child.archiveFile.get().asFile.length()
|
||||||
|
]
|
||||||
|
]
|
||||||
|
])
|
||||||
|
}
|
||||||
|
json.libraries = libs.values().sort{a,b -> a.name.compareTo(b.name)}
|
||||||
|
json.icon = "data:image/png;base64," + new String(Base64.getEncoder().encode(Files.readAllBytes(icon.get().asFile.toPath())))
|
||||||
|
json.json = launcherJsonName.get()
|
||||||
|
json.logo = logo.get()
|
||||||
|
if (!mirrors.get().isEmpty())
|
||||||
|
json.mirrorList = mirrors.get()
|
||||||
|
json.welcome = welcome.get()
|
||||||
|
|
||||||
|
Files.writeString(output.get().getAsFile().toPath(), new JsonBuilder(json).toPrettyString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.json.JsonBuilder
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.provider.SetProperty
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
import static net.minecraftforge.forge.tasks.Util.getArtifacts
|
||||||
|
import static net.minecraftforge.forge.tasks.Util.iso8601Now
|
||||||
|
|
||||||
|
abstract class LauncherJson extends DefaultTask {
|
||||||
|
@OutputFile abstract RegularFileProperty getOutput()
|
||||||
|
@InputFiles abstract ConfigurableFileCollection getInput()
|
||||||
|
@Input Map<String, Object> json = new LinkedHashMap<>()
|
||||||
|
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
||||||
|
|
||||||
|
@Internal final vanilla = project.project(':mcp').file('build/mcp/downloadJson/version.json')
|
||||||
|
@Internal final timestamp = iso8601Now()
|
||||||
|
@Internal final comment = [
|
||||||
|
"Please do not automate the download and installation of Forge.",
|
||||||
|
"Our efforts are supported by ads from the download page.",
|
||||||
|
"If you MUST automate this, please consider supporting the project through https://www.patreon.com/LexManos/"
|
||||||
|
]
|
||||||
|
@Internal final id = "${project.rootProject.ext.MC_VERSION}-${project.name}${project.version.substring(project.rootProject.ext.MC_VERSION.length())}"
|
||||||
|
|
||||||
|
LauncherJson() {
|
||||||
|
getOutput().convention(project.layout.buildDirectory.file('version.json'))
|
||||||
|
|
||||||
|
dependsOn(':fmlloader:jar', 'universalJar')
|
||||||
|
getInput().from(project.tasks.universalJar.archiveFile,
|
||||||
|
project.project(':fmlloader').jar.archiveFile,
|
||||||
|
vanilla)
|
||||||
|
|
||||||
|
project.afterEvaluate {
|
||||||
|
packedDependencies.get().forEach {
|
||||||
|
def jarTask = project.rootProject.tasks.findByPath(it)
|
||||||
|
dependsOn(jarTask)
|
||||||
|
input.from jarTask.archiveFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
if (!json.libraries)
|
||||||
|
json.libraries = []
|
||||||
|
def libs = [:]
|
||||||
|
getArtifacts(project, project.configurations.installer, false).each { key, lib -> libs[key] = lib }
|
||||||
|
getArtifacts(project, project.configurations.moduleonly, false).each { key, lib -> libs[key] = lib }
|
||||||
|
|
||||||
|
packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) }.forEach {
|
||||||
|
def path = Util.getMavenPath(it)
|
||||||
|
def key = Util.getMavenDep(it)
|
||||||
|
|
||||||
|
libs[key] = [
|
||||||
|
name: key,
|
||||||
|
downloads: [
|
||||||
|
artifact: [
|
||||||
|
path: path,
|
||||||
|
url: "https://maven.minecraftforge.net/${path}",
|
||||||
|
sha1: it.archiveFile.get().asFile.sha1(),
|
||||||
|
size: it.archiveFile.get().asFile.length()
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
libs.each { key, lib -> json.libraries.add(lib) }
|
||||||
|
Files.writeString(output.get().asFile.toPath(), new JsonBuilder(json).toPrettyString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.transform.EqualsAndHashCode
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.Nested
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class ObjectTarget implements Comparable<ObjectTarget> {
|
||||||
|
@Input
|
||||||
|
String owner
|
||||||
|
|
||||||
|
@Input
|
||||||
|
String name
|
||||||
|
|
||||||
|
@Input
|
||||||
|
@Optional
|
||||||
|
String desc
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString() {
|
||||||
|
if (desc == null)
|
||||||
|
return owner + '.' + name
|
||||||
|
return owner + '.' + name + desc
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int compareTo(ObjectTarget o) {
|
||||||
|
return toString().compareTo(o.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.security.MessageDigest
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
static void init() {
|
||||||
|
File.metaClass.sha1 = { ->
|
||||||
|
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
||||||
|
delegate.eachByte 4096, {bytes, size ->
|
||||||
|
md.update(bytes, 0, size)
|
||||||
|
}
|
||||||
|
return md.digest().collect {String.format "%02x", it}.join()
|
||||||
|
}
|
||||||
|
|
||||||
|
File.metaClass.json = { -> new JsonSlurper().parseText(delegate.text) }
|
||||||
|
|
||||||
|
Date.metaClass.iso8601 = { ->
|
||||||
|
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
|
def result = format.format(delegate)
|
||||||
|
return result[0..21] + ':' + result[22..-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
String.metaClass.rsplit = { String del, int limit = -1 ->
|
||||||
|
def lst = new ArrayList()
|
||||||
|
def x = 0, idx
|
||||||
|
def tmp = delegate
|
||||||
|
while ((idx = tmp.lastIndexOf(del)) != -1 && (limit == -1 || x++ < limit)) {
|
||||||
|
lst.add(0, tmp.substring(idx + del.length(), tmp.length()))
|
||||||
|
tmp = tmp.substring(0, idx)
|
||||||
|
}
|
||||||
|
lst.add(0, tmp)
|
||||||
|
return lst
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getClasspath(project, libs, artifact) {
|
||||||
|
def ret = []
|
||||||
|
artifactTree(project, artifact).each { key, lib ->
|
||||||
|
libs[lib.name] = lib
|
||||||
|
if (lib.name != artifact)
|
||||||
|
ret.add(lib.name)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
public static def getArtifacts(project, config, classifiers) {
|
||||||
|
def ret = [:]
|
||||||
|
config.resolvedConfiguration.resolvedArtifacts.each {
|
||||||
|
def art = [
|
||||||
|
group: it.moduleVersion.id.group,
|
||||||
|
name: it.moduleVersion.id.name,
|
||||||
|
version: it.moduleVersion.id.version,
|
||||||
|
classifier: it.classifier,
|
||||||
|
extension: it.extension,
|
||||||
|
file: it.file
|
||||||
|
]
|
||||||
|
def key = art.group + ':' + art.name
|
||||||
|
def folder = "${art.group.replace('.', '/')}/${art.name}/${art.version}/"
|
||||||
|
def filename = "${art.name}-${art.version}"
|
||||||
|
if (art.classifier != null)
|
||||||
|
filename += "-${art.classifier}"
|
||||||
|
filename += ".${art.extension}"
|
||||||
|
def path = "${folder}${filename}"
|
||||||
|
def url = "https://libraries.minecraft.net/${path}"
|
||||||
|
if (!checkExists(url)) {
|
||||||
|
url = "https://maven.minecraftforge.net/${path}"
|
||||||
|
}
|
||||||
|
//TODO remove when Mojang launcher is updated
|
||||||
|
if (!classifiers && art.classifier != null) {
|
||||||
|
//Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
||||||
|
// However, keep the path normal so that our mirror system works.
|
||||||
|
art.version = "${art.version}-${art.classifier}"
|
||||||
|
art.classifier = null
|
||||||
|
art.extension = 'jar'
|
||||||
|
}
|
||||||
|
ret[key] = [
|
||||||
|
name: "${art.group}:${art.name}:${art.version}" + (art.classifier == null ? '' : ":${art.classifier}") + (art.extension == 'jar' ? '' : "@${art.extension}"),
|
||||||
|
downloads: [
|
||||||
|
artifact: [
|
||||||
|
path: path,
|
||||||
|
url: url,
|
||||||
|
sha1: sha1(art.file),
|
||||||
|
size: art.file.length()
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
public static def getMavenPath(task) {
|
||||||
|
def classifier = task.archiveClassifier.get()
|
||||||
|
def dep = "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
||||||
|
return "${task.project.group.replace('.', '/')}/${task.project.name}/${task.project.version}/${task.project.name}-${task.project.version}".toString() + (classifier == '' ? '' : '-' + classifier) + '.jar'
|
||||||
|
}
|
||||||
|
|
||||||
|
public static def getMavenDep(task) {
|
||||||
|
def classifier = task.archiveClassifier.get()
|
||||||
|
return "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static def iso8601Now() { new Date().iso8601() }
|
||||||
|
|
||||||
|
public static def sha1(file) {
|
||||||
|
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
||||||
|
file.eachByte 4096, {bytes, size ->
|
||||||
|
md.update(bytes, 0, size)
|
||||||
|
}
|
||||||
|
return md.digest().collect {String.format "%02x", it}.join()
|
||||||
|
}
|
||||||
|
|
||||||
|
private static def artifactTree(project, artifact) {
|
||||||
|
if (!project.ext.has('tree_resolver'))
|
||||||
|
project.ext.tree_resolver = 1
|
||||||
|
def cfg = project.configurations.create('tree_resolver_' + project.ext.tree_resolver++)
|
||||||
|
def dep = project.dependencies.create(artifact)
|
||||||
|
cfg.dependencies.add(dep)
|
||||||
|
def files = cfg.resolve()
|
||||||
|
return getArtifacts(project, cfg, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkExists(url) {
|
||||||
|
try {
|
||||||
|
def code = new URL(url).openConnection().with {
|
||||||
|
requestMethod = 'HEAD'
|
||||||
|
connect()
|
||||||
|
responseCode
|
||||||
|
}
|
||||||
|
return code == 200
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.toString().contains('unable to find valid certification path to requested target'))
|
||||||
|
throw new RuntimeException('Failed to connect to ' + url + ': Missing certificate root authority, try updating java')
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
Contributing to Forge
|
||||||
|
=====================
|
||||||
|
|
||||||
|
1) Keep patches to Minecraft classes minimal. If you need a lot of things done, you may either add to relevant forge classes or make a new class.
|
||||||
|
|
||||||
|
2) An example mod must be provided for all PRs adding events/hooks to Forge. Whether it's a full mod using your proposed hooks, or just a pastebin containing a simple example, an example mod is required. Please also explain in detail what your new hook does.
|
||||||
|
|
||||||
|
3) Follow Forge coding guidelines (braces on newlines, spaces instead of tabs, etc)
|
||||||
|
|
||||||
|
For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge)
|
||||||
|
|
||||||
|
|
||||||
|
Contributor License Agreement
|
||||||
|
=============================
|
||||||
|
- You grant Forge a license to use your code contributed to the primary codebase (everything **not** under patches) in Forge, under the LGPLv2.1 license.
|
||||||
|
- You assign copyright ownership of your contributions to the patches codebase (everything under patches) to Forge, where it will be licensed under the LGPLv2.1 license.
|
||||||
|
|
||||||
|
"Forge" is Forge Development LLC, a legally incorporated entity in Oregon, USA.
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,68 @@
|
|||||||
|

|
||||||
|
|
||||||
|
MinecraftForge
|
||||||
|
=============
|
||||||
|
[](https://files.minecraftforge.net)
|
||||||
|
[](https://files.minecraftforge.net) [](https://discord.gg/UvedJ9m) [](https://www.patreon.com/LexManos)
|
||||||
|
|
||||||
|
Forge is a free, open-source modding API all of your favourite mods use!
|
||||||
|
|
||||||
|
| Version | Support |
|
||||||
|
| ------------- | ------------- |
|
||||||
|
| 1.17.x | Active |
|
||||||
|
| 1.16.x | LTS |
|
||||||
|
|
||||||
|
* [Download]
|
||||||
|
* [Forum]
|
||||||
|
* [Discord]
|
||||||
|
* [Documentation]
|
||||||
|
|
||||||
|
#### Notes:
|
||||||
|
- Introduced in 1.13 was a new FML, information found [here](NewFML.md).
|
||||||
|
|
||||||
|
# Installing Forge
|
||||||
|
|
||||||
|
Go to [the Forge website](https://files.minecraftforge.net)
|
||||||
|
and select the Minecraft version you wish to get Forge for from the list.
|
||||||
|
|
||||||
|
You can download the installer for the *Recommended Build* or the
|
||||||
|
*Latest build* there. Latest builds may have newer features but may be
|
||||||
|
more unstable as a result. The installer will attempt to install Forge
|
||||||
|
into your vanilla launcher environment, where you can then create a new
|
||||||
|
profile using that version and play the game!
|
||||||
|
|
||||||
|
For support and questions, visit [the Support Forum](https://www.minecraftforge.net/forum/forum/18-support-bug-reports/).
|
||||||
|
|
||||||
|
[Here is a short video from Rorax showing how to install and setup Forge.](https://www.youtube.com/watch?v=lB3ArN_-3Oc)
|
||||||
|
|
||||||
|
# Creating Mods
|
||||||
|
|
||||||
|
[See the "Getting Started" section in the Forge Documentation](https://mcforge.readthedocs.io/en/latest/gettingstarted/).
|
||||||
|
|
||||||
|
# Contribute to Forge
|
||||||
|
|
||||||
|
If you wish to actually inspect Forge, submit PRs or otherwise work
|
||||||
|
with Forge itself, you're in the right place!
|
||||||
|
|
||||||
|
[See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/).
|
||||||
|
|
||||||
|
### Pull requests
|
||||||
|
|
||||||
|
[See the "Making Changes and Pull Requests" section in the Forge documentation](https://mcforge.readthedocs.io/en/latest/forgedev/#making-changes-and-pull-requests).
|
||||||
|
|
||||||
|
Please read the contributing guidelines found [here](CONTRIBUTING.md) before making a pull request.
|
||||||
|
|
||||||
|
### Contributor License Agreement
|
||||||
|
We require all contributors to acknowledge the [Forge Contributor
|
||||||
|
License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge). Please ensure you have a valid email address
|
||||||
|
associated with your GitHub account to do this. If you have previously
|
||||||
|
signed it, you should be OK.
|
||||||
|
|
||||||
|
#### Donate
|
||||||
|
*Forge is a large project with many collaborators working on it around the clock. Forge is and will always remain free to use and modify. However, it costs money to run such a large project as this, so please consider [becoming a patron](https://www.patreon.com/LexManos).*
|
||||||
|
|
||||||
|
[Download]: https://files.minecraftforge.net/
|
||||||
|
[Forum]: https://www.minecraftforge.net/forum/
|
||||||
|
[Discord]: https://discord.gg/UvedJ9m
|
||||||
|
[Documentation]: https://mcforge.readthedocs.io
|
||||||
File renamed without changes.
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
|
||||||
|
<svg enable-background="new 164.072 372.466 294.41 46.56" version="1.1" viewBox="164.072 372.466 294.41 46.56" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="#DFA86A">
|
||||||
|
<polygon points="266.16 417.99 277.12 417.99 277.12 401.05 295.09 401.05 295.09 390.78 277.12 390.78 277.12 383.77 296.18 383.77 296.18 373.5 266.16 373.5"/>
|
||||||
|
<path d="m337.33 378.7c-2.103-2.057-4.629-3.64-7.51-4.704-2.743-1.015-5.786-1.528-9.041-1.528l-0.356 2e-3c-3.362 0-6.503 0.556-9.338 1.651-2.857 1.106-5.357 2.707-7.434 4.761-2.073 2.052-3.714 4.559-4.877 7.45-1.158 2.876-1.748 6.104-1.748 9.59 0 3.417 0.59 6.582 1.753 9.403 1.163 2.829 2.807 5.297 4.88 7.329 2.073 2.03 4.572 3.621 7.425 4.724 2.834 1.096 5.975 1.651 9.339 1.651h0.023c3.402-0.043 6.57-0.639 9.42-1.772 2.863-1.142 5.375-2.757 7.465-4.804 2.091-2.051 3.742-4.524 4.91-7.358 1.162-2.823 1.75-5.987 1.75-9.402 0-3.487-0.588-6.705-1.748-9.568-1.168-2.874-2.82-5.371-4.913-7.425zm-4.644 16.762c0 1.96-0.302 3.782-0.896 5.413-0.587 1.607-1.42 3.011-2.479 4.167-1.05 1.147-2.335 2.065-3.821 2.728-1.479 0.656-3.164 0.99-5.008 0.99-1.84 0-3.514-0.333-4.973-0.988-1.47-0.662-2.747-1.578-3.799-2.729-1.062-1.156-1.895-2.559-2.479-4.167-0.595-1.63-0.896-3.451-0.896-5.413 0-1.801 0.298-3.497 0.887-5.044 0.584-1.536 1.419-2.894 2.479-4.037 1.048-1.132 2.323-2.03 3.792-2.674 1.465-0.642 3.145-0.968 4.988-0.968 1.848 0 3.539 0.326 5.025 0.971 1.481 0.643 2.766 1.541 3.812 2.671 1.062 1.143 1.896 2.501 2.479 4.036 0.589 1.548 0.889 3.245 0.889 5.044z"/>
|
||||||
|
<path d="m376.27 395.65c1.902-2.327 2.867-5.221 2.867-8.603 0-2.614-0.508-4.84-1.506-6.613-0.997-1.762-2.354-3.188-4.035-4.234-1.603-0.995-3.445-1.705-5.482-2.114-1.938-0.388-3.969-0.583-6.037-0.583h-16.021v44.487h10.961v-17.282h2.35l9.447 17.282h13.127l-11.199-18.646c2.262-0.728 4.116-1.964 5.528-3.694zm-19.254-12.223h4.426c0.844 0 1.73 0.054 2.636 0.16 0.784 0.094 1.503 0.283 2.132 0.568 0.496 0.225 0.888 0.553 1.193 0.998 0.283 0.415 0.428 1.031 0.428 1.836 0 0.931-0.16 1.643-0.459 2.06-0.34 0.472-0.771 0.813-1.32 1.046-0.686 0.289-1.459 0.477-2.301 0.554-0.975 0.089-1.963 0.136-2.938 0.136h-3.795l-2e-3 -7.358z"/>
|
||||||
|
<path d="m394.82 386.38c1.05-1.132 2.325-2.03 3.793-2.674 1.464-0.642 3.144-0.968 4.988-0.968 1.843 0 3.611 0.311 5.26 0.921 1.609 0.599 2.992 1.449 4.107 2.531l1.314 1.278 8.019-8.105-1.454-1.298c-2.355-2.103-5.066-3.586-8.058-4.407-2.879-0.789-5.987-1.189-9.247-1.189-3.361 0-6.503 0.556-9.339 1.651-2.856 1.106-5.355 2.707-7.431 4.761-2.074 2.052-3.716 4.559-4.88 7.45-1.158 2.876-1.746 6.104-1.746 9.59 0 3.417 0.59 6.582 1.752 9.403 1.164 2.829 2.807 5.297 4.88 7.329 2.073 2.03 4.572 3.621 7.425 4.724 2.832 1.096 5.975 1.651 9.339 1.651 6.501 0 12.475-1.432 17.751-4.25l0.979-0.522v-23.814h-19.313v10.27h8.354v6.639c-0.871 0.397-1.834 0.709-2.881 0.933-1.5 0.314-3.127 0.478-4.83 0.478-1.841 0-3.514-0.333-4.973-0.988-1.472-0.662-2.748-1.578-3.801-2.729-1.06-1.156-1.893-2.559-2.478-4.167-0.595-1.63-0.896-3.451-0.896-5.413 0-1.801 0.299-3.497 0.887-5.044 0.586-1.54 1.421-2.897 2.479-4.041z"/>
|
||||||
|
<polygon points="437.69 407.72 437.69 400.36 456.41 400.36 456.41 390.09 437.69 390.09 437.69 383.77 457.44 383.77 457.44 373.5 426.72 373.5 426.72 417.99 458.48 417.99 458.48 407.72"/>
|
||||||
|
</g>
|
||||||
|
<path d="m243.63 379.09l-37.842-1.852 46.229-0.034v-3.727h-52.125l-1e-3 7.798v6.201c0 0.115-1.52-9.144-1.87-11.734h-4.098v13.029c0 0.123-1.753-10.888-1.939-12.264h-27.914c1.902 1.648 12.401 10.598 19.865 14.28 3.741 1.846 8.33 1.86 12.414 1.974 2.075 0.06 4.25 0.217 5.803 1.754 2.255 2.236 2.758 5.704 0.814 8.33-1.922 2.594-7.335 3.156-7.335 3.156l-4.509 5.531v6.424h10.251l0.319-6.348 8.863-6.285c-0.946 0.757-3.058 2.783-6.229 7.666-0.717 1.102-1.275 2.306-1.711 3.49 2.238-1.896 6.84-3.194 12.153-3.194 5.307 0 9.903 1.295 12.146 3.188-0.437-1.185-0.994-2.385-1.709-3.483-3.172-4.883-5.284-6.909-6.229-7.666l8.863 6.285 0.32 6.348h9.565v-6.424l-4.507-5.531s-6.675-0.425-8.423-3.156c-5.032-7.869 2.115-20.082 18.836-23.756z" fill="#1E2D41"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,64 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.github.ben-manes.versions'
|
||||||
|
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
||||||
|
}
|
||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'org.javamodularity.moduleplugin'
|
||||||
|
|
||||||
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly('org.jetbrains:annotations:21.0.1')
|
||||||
|
implementation(project(':fmlloader'))
|
||||||
|
api('net.minecraftforge:eventbus:5.0.+')
|
||||||
|
implementation('commons-io:commons-io:2.5')
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
archiveClassifier = 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
MANIFESTS = [
|
||||||
|
'': [
|
||||||
|
'FMLModType': 'LIBRARY',
|
||||||
|
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
'Git-Commit': GIT_INFO.abbreviatedId,
|
||||||
|
'Git-Branch': GIT_INFO.branch,
|
||||||
|
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}"
|
||||||
|
] as LinkedHashMap,
|
||||||
|
'net/minecraftforge/fml/loading/': [
|
||||||
|
'Specification-Title': 'FMLLoader',
|
||||||
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
|
'Specification-Version': '1',
|
||||||
|
'Implementation-Title': 'FML Loader',
|
||||||
|
'Implementation-Version': '1.0',
|
||||||
|
'Implementation-Vendor': 'Forge'
|
||||||
|
] as LinkedHashMap
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.doFirst {
|
||||||
|
MANIFESTS.each { pkg, values ->
|
||||||
|
if (pkg == '')
|
||||||
|
manifest.attributes(values)
|
||||||
|
else
|
||||||
|
manifest.attributes(values, pkg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << '-Xlint:unchecked'
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives jar
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing.publications.mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
artifact sourcesJar
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
|
import net.minecraftforge.eventbus.api.BusBuilder;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.config.IConfigEvent;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class Bindings {
|
||||||
|
private static final Bindings INSTANCE = new Bindings();
|
||||||
|
|
||||||
|
private final IBindingsProvider provider;
|
||||||
|
|
||||||
|
private Bindings() {
|
||||||
|
final var providers = ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(FMLLoader.getGameLayer(), IBindingsProvider.class), sce->{}).toList();
|
||||||
|
if (providers.size() != 1) {
|
||||||
|
throw new IllegalStateException("Could not find bindings provider");
|
||||||
|
}
|
||||||
|
this.provider = providers.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<IEventBus> getForgeBus() {
|
||||||
|
return INSTANCE.provider.getForgeBusSupplier();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<I18NParser> getMessageParser() {
|
||||||
|
return INSTANCE.provider.getMessageParser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration() {
|
||||||
|
return INSTANCE.provider.getConfigConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class CrashReportCallables {
|
||||||
|
private static final List<ISystemReportExtender> crashCallables = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
|
public static void registerCrashCallable(ISystemReportExtender callable)
|
||||||
|
{
|
||||||
|
crashCallables.add(callable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator) {
|
||||||
|
registerCrashCallable(new ISystemReportExtender() {
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return headerName;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String get() {
|
||||||
|
return reportGenerator.get();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ISystemReportExtender> allCrashCallables() {
|
||||||
|
return List.copyOf(crashCallables);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.Logging.LOADING;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.google.common.base.Stopwatch;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility for running code on the main launch thread at the next available
|
||||||
|
* opportunity. There is no guaranteed order that work from various mods will be
|
||||||
|
* run, but your own work will be run sequentially.
|
||||||
|
* <p>
|
||||||
|
* <strong>Use of this class after startup is not possible.</strong> At that
|
||||||
|
* point, {@code ReentrantBlockableEventLoop} should be used instead.
|
||||||
|
* <p>
|
||||||
|
* Exceptions from tasks will be handled gracefully, causing a mod loading
|
||||||
|
* error. Tasks that take egregiously long times to run will be logged.
|
||||||
|
*/
|
||||||
|
public class DeferredWorkQueue
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
private static final Map<ModLoadingStage, DeferredWorkQueue> workQueues = new HashMap<>();
|
||||||
|
|
||||||
|
private final ConcurrentLinkedDeque<TaskInfo> tasks = new ConcurrentLinkedDeque<>();
|
||||||
|
private final ModLoadingStage modLoadingStage;
|
||||||
|
|
||||||
|
public DeferredWorkQueue(ModLoadingStage modLoadingStage) {
|
||||||
|
this.modLoadingStage = modLoadingStage;
|
||||||
|
workQueues.put(modLoadingStage, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
|
public static Optional<DeferredWorkQueue> lookup(Optional<ModLoadingStage> parallelClass) {
|
||||||
|
return Optional.ofNullable(workQueues.get(parallelClass.orElse(null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runTasks() {
|
||||||
|
if (tasks.isEmpty()) return;
|
||||||
|
LOGGER.debug(LOADING, "Dispatching synchronous work for work queue {}: {} jobs", modLoadingStage, tasks.size());
|
||||||
|
Stopwatch timer = Stopwatch.createStarted();
|
||||||
|
tasks.forEach(t->makeRunnable(t, Runnable::run));
|
||||||
|
timer.stop();
|
||||||
|
LOGGER.debug(LOADING, "Synchronous work queue completed in {}", timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void makeRunnable(TaskInfo ti, Executor executor) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
Stopwatch timer = Stopwatch.createStarted();
|
||||||
|
ModLoadingContext.get().setActiveContainer(ti.owner);
|
||||||
|
try {
|
||||||
|
ti.task.run();
|
||||||
|
} finally {
|
||||||
|
ModLoadingContext.get().setActiveContainer(null);
|
||||||
|
}
|
||||||
|
timer.stop();
|
||||||
|
if (timer.elapsed(TimeUnit.SECONDS) >= 1) {
|
||||||
|
LOGGER.warn(LOADING, "Mod '{}' took {} to run a deferred task.", ti.owner.getModId(), timer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> enqueueWork(final ModContainer modInfo, final Runnable work) {
|
||||||
|
return CompletableFuture.runAsync(work, r->tasks.add(new TaskInfo(modInfo, r)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> CompletableFuture<T> enqueueWork(final ModContainer modInfo, final Supplier<T> work) {
|
||||||
|
return CompletableFuture.supplyAsync(work, r->tasks.add(new TaskInfo(modInfo, r)));
|
||||||
|
}
|
||||||
|
|
||||||
|
record TaskInfo(ModContainer owner, Runnable task) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.invoke.SerializedLambda;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to execute code conditionally based on sidedness.
|
||||||
|
* <ul>
|
||||||
|
* <li>When you want to call something on one side and return a result {@link #safeCallWhenOn(Dist, Supplier)}</li>
|
||||||
|
* <li>When you want to call one thing on one side, another thing on the other and return a result {@link #safeRunForDist(Supplier, Supplier)}</li>
|
||||||
|
* <li>When you want to run something on one side {@link #safeRunWhenOn(Dist, Supplier)}</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public final class DistExecutor
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private DistExecutor() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the callable in the supplier only on the specified {@link Dist}.
|
||||||
|
* This method is NOT sided-safe and special care needs to be taken in code using this method that implicit class
|
||||||
|
* loading is not triggered by the Callable.
|
||||||
|
*
|
||||||
|
* This method can cause unexpected ClassNotFound exceptions.
|
||||||
|
*
|
||||||
|
* Use {@link #safeCallWhenOn(Dist, Supplier)} where possible.
|
||||||
|
*
|
||||||
|
* @param dist The dist to run on
|
||||||
|
* @param toRun A supplier of the callable to run (Supplier wrapper to ensure classloading only on the appropriate dist)
|
||||||
|
* @param <T> The return type from the callable
|
||||||
|
* @return The callable's result
|
||||||
|
* @deprecated use {@link #safeCallWhenOn(Dist, Supplier)} instead. This remains for advanced use cases.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> T callWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
||||||
|
return unsafeCallWhenOn(dist, toRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T unsafeCallWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
||||||
|
if (dist == FMLEnvironment.dist) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return toRun.get().call();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the SafeCallable when on the correct {@link Dist}.
|
||||||
|
*
|
||||||
|
* <strong>The lambda supplied here is required to be a method reference to a method defined in
|
||||||
|
* another class, otherwise an invalid SafeReferent error will be thrown</strong>
|
||||||
|
* @param dist the dist which this will run on
|
||||||
|
* @param toRun the SafeCallable to run and return the result from
|
||||||
|
* @param <T> The type of the SafeCallable
|
||||||
|
* @return the result of the SafeCallable or null if on the wrong side
|
||||||
|
*/
|
||||||
|
public static <T> T safeCallWhenOn(Dist dist, Supplier<SafeCallable<T>> toRun) {
|
||||||
|
validateSafeReferent(toRun);
|
||||||
|
return callWhenOn(dist, toRun::get);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #callWhenOn(Dist, Supplier)}.
|
||||||
|
*
|
||||||
|
* This method can cause unexpected ClassNotFound exceptions.
|
||||||
|
*
|
||||||
|
* @see #callWhenOn(Dist, Supplier)
|
||||||
|
* @param dist Dist to run this code on
|
||||||
|
* @param toRun The code to run
|
||||||
|
* @deprecated use {@link #safeRunWhenOn(Dist, Supplier)} where possible. Advanced uses only.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void runWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
||||||
|
unsafeRunWhenOn(dist, toRun);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #unsafeCallWhenOn(Dist, Supplier)}.
|
||||||
|
*
|
||||||
|
* This method can cause unexpected ClassNotFoundException problems in common scenarios. Understand the pitfalls of
|
||||||
|
* the way the class verifier works to load classes before using this.
|
||||||
|
*
|
||||||
|
* Use {@link #safeRunWhenOn(Dist, Supplier)} if you can.
|
||||||
|
*
|
||||||
|
* @see #unsafeCallWhenOn(Dist, Supplier)
|
||||||
|
* @param dist Dist to run this code on
|
||||||
|
* @param toRun The code to run
|
||||||
|
*/
|
||||||
|
public static void unsafeRunWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
||||||
|
if (dist == FMLEnvironment.dist) {
|
||||||
|
toRun.get().run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the supplied SafeRunnable when on the correct Dist.
|
||||||
|
* @param dist The dist to run on
|
||||||
|
* @param toRun The code to run
|
||||||
|
*/
|
||||||
|
public static void safeRunWhenOn(Dist dist, Supplier<SafeRunnable> toRun) {
|
||||||
|
validateSafeReferent(toRun);
|
||||||
|
if (dist == FMLEnvironment.dist) {
|
||||||
|
toRun.get().run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Executes one of the two suppliers, based on which side is active.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Example (replacement for old SidedProxy):<br/>
|
||||||
|
* {@code Proxy p = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
||||||
|
*
|
||||||
|
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
||||||
|
*
|
||||||
|
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||||
|
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||||
|
* @param <T> The common type to return
|
||||||
|
* @return The returned instance
|
||||||
|
* @deprecated Use {@link #safeRunForDist(Supplier, Supplier)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> T runForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
||||||
|
return unsafeRunForDist(clientTarget, serverTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsafe version of {@link #safeRunForDist(Supplier, Supplier)}. Use only when you know what you're doing
|
||||||
|
* and understand why the verifier can cause unexpected ClassNotFoundException crashes even when code is apparently
|
||||||
|
* not sided. Ensure you test both sides fully to be confident in using this.
|
||||||
|
*
|
||||||
|
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||||
|
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||||
|
* @param <T> The common type to return
|
||||||
|
* @return The returned instance
|
||||||
|
*/
|
||||||
|
public static <T> T unsafeRunForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
||||||
|
switch (FMLEnvironment.dist)
|
||||||
|
{
|
||||||
|
case CLIENT:
|
||||||
|
return clientTarget.get().get();
|
||||||
|
case DEDICATED_SERVER:
|
||||||
|
return serverTarget.get().get();
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("UNSIDED?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Executes one of the two suppliers, based on which side is active.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Example (replacement for old SidedProxy):<br/>
|
||||||
|
* {@code Proxy p = DistExecutor.safeRunForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
||||||
|
*
|
||||||
|
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
||||||
|
*
|
||||||
|
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
||||||
|
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
||||||
|
* @param <T> The common type to return
|
||||||
|
* @return The returned instance
|
||||||
|
*/
|
||||||
|
public static <T> T safeRunForDist(Supplier<SafeSupplier<T>> clientTarget, Supplier<SafeSupplier<T>> serverTarget) {
|
||||||
|
validateSafeReferent(clientTarget);
|
||||||
|
validateSafeReferent(serverTarget);
|
||||||
|
switch (FMLEnvironment.dist)
|
||||||
|
{
|
||||||
|
case CLIENT:
|
||||||
|
return clientTarget.get().get();
|
||||||
|
case DEDICATED_SERVER:
|
||||||
|
return serverTarget.get().get();
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("UNSIDED?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A safe referent. This will assert that it is being called via a separated class method reference. This will
|
||||||
|
* avoid the common pitfalls of {@link #callWhenOn(Dist, Supplier)} above.
|
||||||
|
*
|
||||||
|
* SafeReferents assert that they are defined as a separate method outside the scope of the calling class.
|
||||||
|
*
|
||||||
|
* <strong>Implementations need to be defined in a separate class to the referring site, with appropriate
|
||||||
|
* visibility to be accessible at the callsite (generally, avoid private methods).</strong>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Valid:<br/>
|
||||||
|
*
|
||||||
|
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->AnotherClass::clientOnlyMethod);}
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Invalid:<br/>
|
||||||
|
*
|
||||||
|
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->()->Minecraft.getInstance().world);}
|
||||||
|
*/
|
||||||
|
public interface SafeReferent {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SafeCallable version of {@link SafeReferent}.
|
||||||
|
* @see SafeReferent
|
||||||
|
* @param <T> The return type of the Callable
|
||||||
|
*/
|
||||||
|
public interface SafeCallable<T> extends SafeReferent, Callable<T>, Serializable {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SafeSupplier version of {@link SafeReferent}
|
||||||
|
* @param <T> The return type of the Supplier
|
||||||
|
*/
|
||||||
|
public interface SafeSupplier<T> extends SafeReferent, Supplier<T>, Serializable {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SafeRunnable version of {@link SafeReferent}
|
||||||
|
*/
|
||||||
|
public interface SafeRunnable extends SafeReferent, Runnable, Serializable {}
|
||||||
|
|
||||||
|
private static final void validateSafeReferent(Supplier<? extends SafeReferent> safeReferentSupplier) {
|
||||||
|
if (FMLEnvironment.production) return;
|
||||||
|
final SafeReferent setter;
|
||||||
|
try {
|
||||||
|
setter = safeReferentSupplier.get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Typically a class cast exception, just return out, expected.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Class<?> cl = setter.getClass(); cl != null; cl = cl.getSuperclass()) {
|
||||||
|
try {
|
||||||
|
Method m = cl.getDeclaredMethod("writeReplace");
|
||||||
|
m.setAccessible(true);
|
||||||
|
Object replacement = m.invoke(setter);
|
||||||
|
if (!(replacement instanceof SerializedLambda))
|
||||||
|
break;// custom interface implementation
|
||||||
|
SerializedLambda l = (SerializedLambda) replacement;
|
||||||
|
if (Objects.equals(l.getCapturingClass(), l.getImplClass())) {
|
||||||
|
LOGGER.fatal("Detected unsafe referent usage, please view the code at {}",Thread.currentThread().getStackTrace()[3]);
|
||||||
|
throw new RuntimeException("Unsafe Referent usage found in safe referent method");
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
public interface I18NParser {
|
||||||
|
String parseMessage(String i18nMessage, Object... args);
|
||||||
|
String stripControlCodes(String toStrip);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.config.IConfigEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface IBindingsProvider {
|
||||||
|
Supplier<IEventBus> getForgeBusSupplier();
|
||||||
|
Supplier<I18NParser> getMessageParser();
|
||||||
|
Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration();
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface IExtensionPoint<T extends Record>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Compatibility display test for the mod.
|
||||||
|
* Used for displaying compatibility with remote servers with the same mod, and on disk saves.
|
||||||
|
*
|
||||||
|
* The supplier provides my "local" version for sending across the network or writing to disk
|
||||||
|
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for network, false for local save)
|
||||||
|
* and returns true if the version is compatible.
|
||||||
|
*
|
||||||
|
* <p>Return {@code net.minecraftforge.fmllegacy.network.FMLNetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored
|
||||||
|
* as a server side only mod.</p>
|
||||||
|
* <p>Return true in the predicate for all values of the input string (when network boolean is true) if you are client side,
|
||||||
|
* and don't care about matching any potential server version.</p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Examples: A server only mod
|
||||||
|
* </p>
|
||||||
|
* <pre>{@code
|
||||||
|
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
||||||
|
* ()->FMLNetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod
|
||||||
|
* (s,b)->true // i accept anything from the server or the save, if I'm asked
|
||||||
|
* )
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Examples: A client only mod
|
||||||
|
* </p>
|
||||||
|
* <pre>{@code
|
||||||
|
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
||||||
|
* ()->"anything. i don't care", // if i'm actually on the server, this string is sent but i'm a client only mod, so it won't be
|
||||||
|
* (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server
|
||||||
|
* )
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public interface IModLoadingState {
|
||||||
|
String name();
|
||||||
|
String previous();
|
||||||
|
ModLoadingPhase phase();
|
||||||
|
Function<ModList, String> message();
|
||||||
|
Optional<Consumer<ModList>> inlineRunnable();
|
||||||
|
|
||||||
|
default <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor) {
|
||||||
|
return buildTransition(syncExecutor, parallelExecutor, e->CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e));
|
||||||
|
}
|
||||||
|
|
||||||
|
<T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IModStateProvider {
|
||||||
|
List<IModLoadingState> getAllStates();
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public interface IModStateTransition {
|
||||||
|
static IModStateTransition buildNoopTransition() {
|
||||||
|
return new NoopTransition();
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T extends Event & IModBusEvent> CompletableFuture<List<Throwable>> build(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
||||||
|
List<CompletableFuture<List<Throwable>>> cfs = new ArrayList<>();
|
||||||
|
this.eventFunctionStream().get()
|
||||||
|
.map(f->(EventGenerator<T>)f)
|
||||||
|
.reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail))
|
||||||
|
.ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, nextModLoadingStage(), null));
|
||||||
|
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
||||||
|
final CompletableFuture<List<Throwable>> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList);
|
||||||
|
final CompletableFuture<List<Throwable>> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> {
|
||||||
|
postSyncTask.apply(syncExecutor);
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
|
||||||
|
}
|
||||||
|
|
||||||
|
default BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextModLoadingStage() {
|
||||||
|
return ModLoadingStage::nextState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Event & IModBusEvent> EventGenerator<T> addCompletableFutureTaskForModDispatch(final Executor syncExecutor, final Executor parallelExecutor, final List<CompletableFuture<List<Throwable>>> completeableFutures, final EventGenerator<T> eventGenerator, BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState, final EventGenerator<T> nextGenerator) {
|
||||||
|
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)preDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
||||||
|
completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor)));
|
||||||
|
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)postDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
||||||
|
return nextGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
Supplier<Stream<EventGenerator<?>>> eventFunctionStream();
|
||||||
|
ThreadSelector threadSelector();
|
||||||
|
BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator();
|
||||||
|
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook();
|
||||||
|
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook();
|
||||||
|
|
||||||
|
interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> {
|
||||||
|
static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
|
||||||
|
return fn::apply;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
record NoopTransition() implements IModStateTransition {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<Stream<EventGenerator<?>>> eventFunctionStream() {
|
||||||
|
return Stream::of;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThreadSelector threadSelector() {
|
||||||
|
return ThreadSelector.SYNC;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator() {
|
||||||
|
return (e, t) -> t.thenApplyAsync(Function.identity(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook() {
|
||||||
|
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook() {
|
||||||
|
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface ISystemReportExtender extends Supplier<String>
|
||||||
|
{
|
||||||
|
String getLabel();
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Spliterator;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
public class InterModComms
|
||||||
|
{
|
||||||
|
public record IMCMessage(String senderModId, String modId, String method, Supplier<?> messageSupplier) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated: use {@link #senderModId()}
|
||||||
|
* @return The modid of the sender. This is supplied by the caller, or by the active mod container context.
|
||||||
|
* Consider it unreliable.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final String getSenderModId() {
|
||||||
|
return this.senderModId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated: use {@link #modId()}
|
||||||
|
* @return The modid being sent to.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final String getModId() {
|
||||||
|
return this.modId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated: use {@link #method()}
|
||||||
|
* @return The method being sent to.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final String getMethod() {
|
||||||
|
return this.method;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param <T> The type of the message.
|
||||||
|
* @return A {@link Supplier} of the message.
|
||||||
|
* Use {@link #messageSupplier()}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Deprecated
|
||||||
|
public final <T> Supplier<T> getMessageSupplier() {
|
||||||
|
return (Supplier<T>) this.messageSupplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ConcurrentMap<String, ConcurrentLinkedQueue<IMCMessage>> containerQueues = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send IMC to remote. Sender will default to the active modcontainer, or minecraft if not.
|
||||||
|
*
|
||||||
|
* @param modId the mod id to send to
|
||||||
|
* @param method the method name to send
|
||||||
|
* @param thing the thing associated with the method name
|
||||||
|
* @return true if the message was enqueued for sending (the target modid is loaded)
|
||||||
|
*/
|
||||||
|
public static boolean sendTo(final String modId, final String method, final Supplier<?> thing) {
|
||||||
|
if (!ModList.get().isLoaded(modId)) return false;
|
||||||
|
containerQueues.computeIfAbsent(modId, k->new ConcurrentLinkedQueue<>()).add(new IMCMessage(ModLoadingContext.get().getActiveContainer().getModId(), modId, method, thing));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send IMC to remote.
|
||||||
|
*
|
||||||
|
* @param senderModId the mod id you are sending from
|
||||||
|
* @param modId the mod id to send to
|
||||||
|
* @param method the method name to send
|
||||||
|
* @param thing the thing associated with the method name
|
||||||
|
* @return true if the message was enqueued for sending (the target modid is loaded)
|
||||||
|
*/
|
||||||
|
public static boolean sendTo(final String senderModId, final String modId, final String method, final Supplier<?> thing) {
|
||||||
|
if (!ModList.get().isLoaded(modId)) return false;
|
||||||
|
containerQueues.computeIfAbsent(modId, k->new ConcurrentLinkedQueue<>()).add(new IMCMessage(senderModId, modId, method, thing));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve pending messages for your modid. Use the predicate to filter the method name.
|
||||||
|
*
|
||||||
|
* @param modId the modid you are querying for
|
||||||
|
* @param methodMatcher a predicate for the method you are interested in
|
||||||
|
* @return All messages passing the supplied method predicate
|
||||||
|
*/
|
||||||
|
public static Stream<IMCMessage> getMessages(final String modId, final Predicate<String> methodMatcher) {
|
||||||
|
ConcurrentLinkedQueue<IMCMessage> queue = containerQueues.get(modId);
|
||||||
|
if (queue == null) return Stream.empty();
|
||||||
|
return StreamSupport.stream(new QueueFilteringSpliterator(queue, methodMatcher), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all message for your modid.
|
||||||
|
*
|
||||||
|
* @param modId the modid you are querying for
|
||||||
|
* @return All messages
|
||||||
|
*/
|
||||||
|
public static Stream<IMCMessage> getMessages(final String modId) {
|
||||||
|
return getMessages(modId, s->Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class QueueFilteringSpliterator implements Spliterator<IMCMessage>
|
||||||
|
{
|
||||||
|
private final ConcurrentLinkedQueue<IMCMessage> queue;
|
||||||
|
private final Predicate<String> methodFilter;
|
||||||
|
private final Iterator<IMCMessage> iterator;
|
||||||
|
|
||||||
|
public QueueFilteringSpliterator(final ConcurrentLinkedQueue<IMCMessage> queue, final Predicate<String> methodFilter) {
|
||||||
|
this.queue = queue;
|
||||||
|
this.iterator = queue.iterator();
|
||||||
|
this.methodFilter = methodFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int characteristics() {
|
||||||
|
return Spliterator.CONCURRENT | Spliterator.NONNULL | Spliterator.ORDERED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long estimateSize() {
|
||||||
|
return queue.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tryAdvance(final Consumer<? super IMCMessage> action)
|
||||||
|
{
|
||||||
|
IMCMessage next;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!iterator.hasNext())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
next = this.iterator.next();
|
||||||
|
}
|
||||||
|
while (!methodFilter.test(next.method));
|
||||||
|
action.accept(next);
|
||||||
|
this.iterator.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Spliterator<IMCMessage> trySplit() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-1
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class LoadingFailedException extends RuntimeException {
|
public class LoadingFailedException extends RuntimeException {
|
||||||
private final List<ModLoadingException> loadingExceptions;
|
private final List<ModLoadingException> loadingExceptions;
|
||||||
@@ -31,4 +32,9 @@ public class LoadingFailedException extends RuntimeException {
|
|||||||
public List<ModLoadingException> getErrors() {
|
public List<ModLoadingException> getErrors() {
|
||||||
return this.loadingExceptions;
|
return this.loadingExceptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return "Loading errors encountered: " + this.loadingExceptions.stream().map(ModLoadingException::getMessage).collect(Collectors.joining(",\n\t", "[\n\t", "\n]"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -19,12 +19,8 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.apache.logging.log4j.Marker;
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
import org.apache.logging.log4j.core.config.Configurator;
|
|
||||||
|
|
||||||
public class Logging
|
public class Logging
|
||||||
{
|
{
|
||||||
@@ -35,6 +31,7 @@ public class Logging
|
|||||||
public static final Marker SPLASH = MarkerManager.getMarker("SPLASH");
|
public static final Marker SPLASH = MarkerManager.getMarker("SPLASH");
|
||||||
public static final Marker CAPABILITIES = MarkerManager.getMarker("CAPABILITIES");
|
public static final Marker CAPABILITIES = MarkerManager.getMarker("CAPABILITIES");
|
||||||
public static final Marker MODELLOADING = MarkerManager.getMarker("MODELLOADING");
|
public static final Marker MODELLOADING = MarkerManager.getMarker("MODELLOADING");
|
||||||
|
public static final Marker FORGEMOD = MarkerManager.getMarker("FORGEMOD").addParents(LOADING);
|
||||||
|
|
||||||
// --log CORE:+DEBUG,SCAN:-OFF
|
// --log CORE:+DEBUG,SCAN:-OFF
|
||||||
// forge log debug 5
|
// forge log debug 5
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
public enum LogicalSide
|
||||||
|
{
|
||||||
|
CLIENT, SERVER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the logical side is a server.
|
||||||
|
*/
|
||||||
|
public boolean isServer()
|
||||||
|
{
|
||||||
|
return !isClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the logical side is a client.
|
||||||
|
*/
|
||||||
|
public boolean isClient()
|
||||||
|
{
|
||||||
|
return this == CLIENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.config.IConfigEvent;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The container that wraps around mods in the system.
|
||||||
|
* <p>
|
||||||
|
* The philosophy is that individual mod implementation technologies should not
|
||||||
|
* impact the actual loading and management of mod code. This class provides
|
||||||
|
* a mechanism by which we can wrap actual mod code so that the loader and other
|
||||||
|
* facilities can treat mods at arms length.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author cpw
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class ModContainer
|
||||||
|
{
|
||||||
|
protected final String modId;
|
||||||
|
protected final String namespace;
|
||||||
|
protected final IModInfo modInfo;
|
||||||
|
protected ModLoadingStage modLoadingStage;
|
||||||
|
protected Supplier<?> contextExtension;
|
||||||
|
protected final Map<ModLoadingStage, Runnable> activityMap = new HashMap<>();
|
||||||
|
protected final Map<Class<? extends IExtensionPoint<?>>, Supplier<?>> extensionPoints = new IdentityHashMap<>();
|
||||||
|
protected final EnumMap<ModConfig.Type, ModConfig> configs = new EnumMap<>(ModConfig.Type.class);
|
||||||
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
|
protected Optional<Consumer<IConfigEvent>> configHandler = Optional.empty();
|
||||||
|
|
||||||
|
public ModContainer(IModInfo info)
|
||||||
|
{
|
||||||
|
this.modId = info.getModId();
|
||||||
|
// TODO: Currently not reading namespace from configuration..
|
||||||
|
this.namespace = this.modId;
|
||||||
|
this.modInfo = info;
|
||||||
|
this.modLoadingStage = ModLoadingStage.CONSTRUCT;
|
||||||
|
// default displaytest extension checks for version string match
|
||||||
|
registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(()->this.modInfo.getVersion().toString(),
|
||||||
|
(incoming, isNetwork)->Objects.equals(incoming, this.modInfo.getVersion().toString())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Errored container state, used for filtering. Does nothing.
|
||||||
|
*/
|
||||||
|
ModContainer()
|
||||||
|
{
|
||||||
|
this.modLoadingStage = ModLoadingStage.ERROR;
|
||||||
|
modId = "BROKEN";
|
||||||
|
namespace = "BROKEN";
|
||||||
|
modInfo = null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the modid for this mod
|
||||||
|
*/
|
||||||
|
public final String getModId()
|
||||||
|
{
|
||||||
|
return modId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the resource prefix for the mod
|
||||||
|
*/
|
||||||
|
public final String getNamespace()
|
||||||
|
{
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The current loading stage for this mod
|
||||||
|
*/
|
||||||
|
public ModLoadingStage getCurrentState()
|
||||||
|
{
|
||||||
|
return modLoadingStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Event & IModBusEvent> CompletableFuture<Void> buildTransitionHandler(
|
||||||
|
final ModContainer target,
|
||||||
|
final IModStateTransition.EventGenerator<T> eventGenerator,
|
||||||
|
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChangeHandler,
|
||||||
|
final Executor executor) {
|
||||||
|
return CompletableFuture
|
||||||
|
.runAsync(() -> {
|
||||||
|
ModLoadingContext.get().setActiveContainer(target);
|
||||||
|
target.activityMap.getOrDefault(target.modLoadingStage, ()->{}).run();
|
||||||
|
target.acceptEvent(eventGenerator.apply(target));
|
||||||
|
}, executor)
|
||||||
|
.whenComplete((mc, exception) -> {
|
||||||
|
target.modLoadingStage = stateChangeHandler.apply(target.modLoadingStage, exception);
|
||||||
|
ModLoadingContext.get().setActiveContainer(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModInfo getModInfo()
|
||||||
|
{
|
||||||
|
return modInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends Record> Optional<T> getCustomExtension(Class<? extends IExtensionPoint<T>> point) {
|
||||||
|
return Optional.ofNullable((T)extensionPoints.getOrDefault(point,()-> null).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Record & IExtensionPoint<T>> void registerExtensionPoint(Class<? extends IExtensionPoint<T>> point, Supplier<T> extension)
|
||||||
|
{
|
||||||
|
extensionPoints.put(point, extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConfig(final ModConfig modConfig) {
|
||||||
|
configs.put(modConfig.getType(), modConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispatchConfigEvent(IConfigEvent event) {
|
||||||
|
configHandler.ifPresent(configHandler->configHandler.accept(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this mod match the supplied mod?
|
||||||
|
*
|
||||||
|
* @param mod to compare
|
||||||
|
* @return if the mod matches
|
||||||
|
*/
|
||||||
|
public abstract boolean matches(Object mod);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mod object instance
|
||||||
|
*/
|
||||||
|
public abstract Object getMod();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept an arbitrary event for processing by the mod. Probably posted to an event bus in the lower level container.
|
||||||
|
* @param e Event to accept
|
||||||
|
*/
|
||||||
|
protected <T extends Event & IModBusEvent> void acceptEvent(T e) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.CompletionStage;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ForkJoinPool;
|
||||||
|
import java.util.concurrent.ForkJoinWorkerThread;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Master list of all mods - game-side version. This is classloaded in the game scope and
|
||||||
|
* can dispatch game level events as a result.
|
||||||
|
*/
|
||||||
|
public class ModList
|
||||||
|
{
|
||||||
|
private static Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static ModList INSTANCE;
|
||||||
|
private final List<IModFileInfo> modFiles;
|
||||||
|
private final List<IModInfo> sortedList;
|
||||||
|
private final Map<String, ModFileInfo> fileById;
|
||||||
|
private List<ModContainer> mods;
|
||||||
|
private Map<String, ModContainer> indexedMods;
|
||||||
|
private List<ModFileScanData> modFileScanData;
|
||||||
|
|
||||||
|
private ModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
||||||
|
{
|
||||||
|
this.modFiles = modFiles.stream().map(ModFile::getModFileInfo).map(ModFileInfo.class::cast).collect(Collectors.toList());
|
||||||
|
this.sortedList = sortedList.stream().
|
||||||
|
map(ModInfo.class::cast).
|
||||||
|
collect(Collectors.toList());
|
||||||
|
this.fileById = this.modFiles.stream().map(IModFileInfo::getMods).flatMap(Collection::stream).
|
||||||
|
map(ModInfo.class::cast).
|
||||||
|
collect(Collectors.toMap(ModInfo::getModId, ModInfo::getOwningFile));
|
||||||
|
CrashReportCallables.registerCrashCallable("Mod List", this::crashReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getModContainerState(String modId) {
|
||||||
|
return getModContainerById(modId).map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fileToLine(IModFile mf) {
|
||||||
|
return String.format("%-50.50s|%-30.30s|%-30.30s|%-20.20s|%-10.10s|Manifest: %s", mf.getFileName(),
|
||||||
|
mf.getModInfos().get(0).getDisplayName(),
|
||||||
|
mf.getModInfos().get(0).getModId(),
|
||||||
|
mf.getModInfos().get(0).getVersion(),
|
||||||
|
getModContainerState(mf.getModInfos().get(0).getModId()),
|
||||||
|
((ModFileInfo)mf.getModFileInfo()).getCodeSigningFingerprint().orElse("NOSIGNATURE"));
|
||||||
|
}
|
||||||
|
private String crashReport() {
|
||||||
|
return "\n"+applyForEachModFile(this::fileToLine).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModList of(List<ModFile> modFiles, List<ModInfo> sortedList)
|
||||||
|
{
|
||||||
|
INSTANCE = new ModList(modFiles, sortedList);
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModList get() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ForkJoinWorkerThread newForkJoinWorkerThread(ForkJoinPool pool) {
|
||||||
|
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
||||||
|
thread.setName("modloading-worker-" + thread.getPoolIndex());
|
||||||
|
// The default sets it to the SystemClassloader, so copy the current one.
|
||||||
|
thread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IModFileInfo> getModFiles()
|
||||||
|
{
|
||||||
|
return modFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModFileInfo getModFileById(String modid)
|
||||||
|
{
|
||||||
|
return this.fileById.get(modid);
|
||||||
|
}
|
||||||
|
|
||||||
|
<T extends Event & IModBusEvent> Function<Executor, CompletableFuture<List<Throwable>>> futureVisitor(
|
||||||
|
final IModStateTransition.EventGenerator<T> eventGenerator,
|
||||||
|
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChange) {
|
||||||
|
return executor -> gather(
|
||||||
|
this.mods.stream()
|
||||||
|
.map(mod -> ModContainer.buildTransitionHandler(mod, eventGenerator, stateChange, executor))
|
||||||
|
.collect(Collectors.toList()))
|
||||||
|
.thenComposeAsync(ModList::completableFutureFromExceptionList, executor);
|
||||||
|
}
|
||||||
|
static CompletionStage<List<Throwable>> completableFutureFromExceptionList(List<? extends Map.Entry<?, Throwable>> t) {
|
||||||
|
if (t.stream().noneMatch(e->e.getValue()!=null)) {
|
||||||
|
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||||
|
} else {
|
||||||
|
final List<Throwable> throwables = t.stream().filter(e -> e.getValue() != null).map(Map.Entry::getValue).collect(Collectors.toList());
|
||||||
|
CompletableFuture<List<Throwable>> cf = new CompletableFuture<>();
|
||||||
|
final RuntimeException accumulator = new RuntimeException();
|
||||||
|
cf.completeExceptionally(accumulator);
|
||||||
|
throwables.forEach(exception -> {
|
||||||
|
if (exception instanceof CompletionException) {
|
||||||
|
exception = exception.getCause();
|
||||||
|
}
|
||||||
|
if (exception.getSuppressed().length!=0) {
|
||||||
|
Arrays.stream(exception.getSuppressed()).forEach(accumulator::addSuppressed);
|
||||||
|
} else {
|
||||||
|
accumulator.addSuppressed(exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return cf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static <V> CompletableFuture<List<Map.Entry<V, Throwable>>> gather(List<? extends CompletableFuture<? extends V>> futures) {
|
||||||
|
List<Map.Entry<V, Throwable>> list = new ArrayList<>(futures.size());
|
||||||
|
CompletableFuture<?>[] results = new CompletableFuture[futures.size()];
|
||||||
|
futures.forEach(future -> {
|
||||||
|
int i = list.size();
|
||||||
|
list.add(null);
|
||||||
|
results[i] = future.whenComplete((result, exception) -> list.set(i, new AbstractMap.SimpleImmutableEntry<>(result, exception)));
|
||||||
|
});
|
||||||
|
return CompletableFuture.allOf(results).handle((r, th)->null).thenApply(res -> list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoadedMods(final List<ModContainer> modContainers)
|
||||||
|
{
|
||||||
|
this.mods = modContainers;
|
||||||
|
this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> Optional<T> getModObjectById(String modId)
|
||||||
|
{
|
||||||
|
return getModContainerById(modId).map(ModContainer::getMod).map(o -> (T) o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<? extends ModContainer> getModContainerById(String modId)
|
||||||
|
{
|
||||||
|
return Optional.ofNullable(this.indexedMods.get(modId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<? extends ModContainer> getModContainerByObject(Object obj)
|
||||||
|
{
|
||||||
|
return mods.stream().filter(mc -> mc.getMod() == obj).findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IModInfo> getMods()
|
||||||
|
{
|
||||||
|
return this.sortedList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLoaded(String modTarget)
|
||||||
|
{
|
||||||
|
return this.indexedMods.containsKey(modTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size()
|
||||||
|
{
|
||||||
|
return mods.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ModFileScanData> getAllScanData()
|
||||||
|
{
|
||||||
|
if (modFileScanData == null)
|
||||||
|
{
|
||||||
|
modFileScanData = this.sortedList.stream().
|
||||||
|
map(IModInfo::getOwningFile).
|
||||||
|
filter(Objects::nonNull).
|
||||||
|
map(IModFileInfo::getFile).
|
||||||
|
distinct().
|
||||||
|
map(IModFile::getScanResult).
|
||||||
|
collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return modFileScanData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEachModFile(Consumer<IModFile> fileConsumer)
|
||||||
|
{
|
||||||
|
modFiles.stream().map(IModFileInfo::getFile).forEach(fileConsumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Stream<T> applyForEachModFile(Function<IModFile, T> function) {
|
||||||
|
return modFiles.stream().map(IModFileInfo::getFile).map(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEachModContainer(BiConsumer<String, ModContainer> modContainerConsumer) {
|
||||||
|
indexedMods.forEach(modContainerConsumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
||||||
|
return indexedMods.values().stream().map(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class UncaughtModLoadingException extends ModLoadingException {
|
||||||
|
public UncaughtModLoadingException(ModLoadingStage stage, Throwable originalException) {
|
||||||
|
super(null, stage, "fml.modloading.uncaughterror", originalException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,333 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.Logging.CORE;
|
||||||
|
import static net.minecraftforge.fml.Logging.LOADING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads mods.
|
||||||
|
*
|
||||||
|
* Dispatch cycle is seen in {@code #loadMods()} and {@code #finishMods()}
|
||||||
|
*
|
||||||
|
* Overall sequence for loadMods is:
|
||||||
|
* <dl>
|
||||||
|
* <dt>CONSTRUCT</dt>
|
||||||
|
* <dd>Constructs the mod instance. Mods can typically setup basic environment such as Event listeners
|
||||||
|
* and Configuration specifications here.</dd>
|
||||||
|
* <dt>Automated dispatches</dt>
|
||||||
|
* <dd>Dispatches automated elements : {@code net.minecraftforge.fml.common.Mod.EventBusSubscriber},
|
||||||
|
* {@code net.minecraftforge.event.RegistryEvent}, {@code net.minecraftforge.common.capabilities.CapabilityInject}
|
||||||
|
* and others</dd>
|
||||||
|
* <dt>CONFIG_LOAD</dt>
|
||||||
|
* <dd>Dispatches ConfigLoadEvent to mods</dd>
|
||||||
|
* <dt>COMMON_SETUP</dt>
|
||||||
|
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} to mods</dd>
|
||||||
|
* <dt>SIDED_SETUP</dt>
|
||||||
|
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent} or
|
||||||
|
* {@code net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent} to mods</dd>
|
||||||
|
* </dl>
|
||||||
|
*
|
||||||
|
* Overall sequence for finishMods is:
|
||||||
|
* <dl>
|
||||||
|
* <dt>ENQUEUE_IMC</dt>
|
||||||
|
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent} to mods,
|
||||||
|
* for enqueuing {@link InterModComms} messages for other mods to receive subsequently</dd>
|
||||||
|
* <dt>PROCESS_IMC</dt>
|
||||||
|
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.InterModProcessEvent} to mods,
|
||||||
|
* for processing {@link InterModComms} messages received from other mods prior to this event</dd>
|
||||||
|
* <dt>COMPLETE</dt>
|
||||||
|
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent} to mods,
|
||||||
|
* and completes the mod loading sequence.</dd>
|
||||||
|
* </dl>
|
||||||
|
*/
|
||||||
|
public class ModLoader
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static ModLoader INSTANCE;
|
||||||
|
private final LoadingModList loadingModList;
|
||||||
|
|
||||||
|
private final List<ModLoadingException> loadingExceptions;
|
||||||
|
private final List<ModLoadingWarning> loadingWarnings;
|
||||||
|
private final ModStateManager stateManager;
|
||||||
|
private boolean loadingStateValid;
|
||||||
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
|
private final Optional<Consumer<String>> statusConsumer = StartupMessageManager.modLoaderConsumer();
|
||||||
|
private ModList modList;
|
||||||
|
|
||||||
|
private ModLoader()
|
||||||
|
{
|
||||||
|
INSTANCE = this;
|
||||||
|
this.loadingModList = FMLLoader.getLoadingModList();
|
||||||
|
this.loadingExceptions = FMLLoader.getLoadingModList().getErrors().stream()
|
||||||
|
.flatMap(ModLoadingException::fromEarlyException)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
this.loadingWarnings = FMLLoader.getLoadingModList().getBrokenFiles().stream()
|
||||||
|
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
FMLLoader.getLoadingModList().getModFiles().stream()
|
||||||
|
.filter(ModFileInfo::missingLicense) //Search for files with missing licenses
|
||||||
|
.filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(thisModInfo -> this.loadingExceptions.stream().map(ModLoadingException::getModInfo).anyMatch(otherInfo -> otherInfo == thisModInfo))) //Ignore files where any other mod already encountered an error
|
||||||
|
.map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile()))
|
||||||
|
.forEach(this.loadingExceptions::add);
|
||||||
|
this.stateManager = new ModStateManager();
|
||||||
|
CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
|
||||||
|
CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
|
||||||
|
CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
|
||||||
|
CrashReportCallables.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList);
|
||||||
|
CrashReportCallables.registerCrashCallable("FML Language Providers", this::computeLanguageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String computeLanguageList() {
|
||||||
|
return "\n"+FMLLoader.getLanguageLoadingProvider().applyForEach(lp->lp.name() +"@"+ lp.getClass().getPackage().getImplementationVersion()).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String computeModLauncherServiceList() {
|
||||||
|
final List<Map<String, String>> mods = FMLLoader.modLauncherModList();
|
||||||
|
return "\n"+mods.stream().map(mod->mod.getOrDefault("file","nofile")+
|
||||||
|
" "+mod.getOrDefault("name", "missing")+
|
||||||
|
" "+mod.getOrDefault("type","NOTYPE")+
|
||||||
|
" "+mod.getOrDefault("description", "")).
|
||||||
|
collect(Collectors.joining("\n\t\t","\t\t",""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModLoader get()
|
||||||
|
{
|
||||||
|
return INSTANCE == null ? INSTANCE = new ModLoader() : INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run on the primary starting thread by ClientModLoader and ServerModLoader
|
||||||
|
* @param syncExecutor An executor to run tasks on the main thread
|
||||||
|
* @param parallelExecutor An executor to run tasks on a parallel loading thread pool
|
||||||
|
* @param periodicTask Optional periodic task to perform on the main thread while other activities run
|
||||||
|
*/
|
||||||
|
public void gatherAndInitializeMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||||
|
loadingStateValid = true;
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Waiting for scan to complete"));
|
||||||
|
FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask);
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Loading mods"));
|
||||||
|
final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList(),
|
||||||
|
loadingModList.getMods());
|
||||||
|
if (!this.loadingExceptions.isEmpty()) {
|
||||||
|
LOGGER.fatal(CORE, "Error during pre-loading phase", loadingExceptions.get(0));
|
||||||
|
modList.setLoadedMods(Collections.emptyList());
|
||||||
|
loadingStateValid = false;
|
||||||
|
throw new LoadingFailedException(loadingExceptions);
|
||||||
|
}
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Building Mod List"));
|
||||||
|
final List<ModContainer> modContainers = loadingModList.getModFiles().stream()
|
||||||
|
.map(ModFileInfo::getFile)
|
||||||
|
.map(this::buildMods)
|
||||||
|
.<ModContainer>mapMulti(Iterable::forEach)
|
||||||
|
.toList();
|
||||||
|
if (!loadingExceptions.isEmpty()) {
|
||||||
|
LOGGER.fatal(CORE, "Failed to initialize mod containers", loadingExceptions.get(0));
|
||||||
|
modList.setLoadedMods(Collections.emptyList());
|
||||||
|
loadingStateValid = false;
|
||||||
|
throw new LoadingFailedException(loadingExceptions);
|
||||||
|
}
|
||||||
|
modList.setLoadedMods(modContainers);
|
||||||
|
this.modList = modList;
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Dispatching gathering events"));
|
||||||
|
stateManager.getStates(ModLoadingPhase.GATHER).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Gathering phase complete"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Performing load phase"));
|
||||||
|
stateManager.getStates(ModLoadingPhase.LOAD).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Mod setup complete"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Performing completion phase"));
|
||||||
|
stateManager.getStates(ModLoadingPhase.COMPLETE).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
||||||
|
statusConsumer.ifPresent(c->c.accept(String.format("Mod loading complete - %d mods loaded", this.modList.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker) {
|
||||||
|
if (!isLoadingStateValid()) {
|
||||||
|
LOGGER.error("Cowardly refusing to process mod state change request from {}", state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList)));
|
||||||
|
state.inlineRunnable().ifPresent(a->a.accept(this.modList));
|
||||||
|
state.buildTransition(syncExecutor, parallelExecutor).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
||||||
|
if (!isLoadingStateValid()) {
|
||||||
|
LOGGER.error("Cowardly refusing to process mod state change request from {}", state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList)));
|
||||||
|
state.inlineRunnable().ifPresent(a->a.accept(this.modList));
|
||||||
|
state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<List<Throwable>> transition) {
|
||||||
|
while (!transition.isDone()) {
|
||||||
|
syncExecutor.drive(ticker);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
transition.join();
|
||||||
|
} catch (CompletionException e) {
|
||||||
|
loadingStateValid = false;
|
||||||
|
Throwable t = e.getCause();
|
||||||
|
final List<Throwable> notModLoading = Arrays.stream(t.getSuppressed())
|
||||||
|
.filter(obj -> !(obj instanceof ModLoadingException))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (!notModLoading.isEmpty()) {
|
||||||
|
LOGGER.fatal("Encountered non-modloading exceptions!", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<ModLoadingException> modLoadingExceptions = Arrays.stream(t.getSuppressed())
|
||||||
|
.filter(ModLoadingException.class::isInstance)
|
||||||
|
.map(ModLoadingException.class::cast)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
LOGGER.fatal(LOADING,"Failed to complete lifecycle event {}, {} errors found", state.name(), modLoadingExceptions.size());
|
||||||
|
throw new LoadingFailedException(modLoadingExceptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ModContainer> buildMods(final ModFile modFile)
|
||||||
|
{
|
||||||
|
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
||||||
|
|
||||||
|
LOGGER.trace(LOADING, "ModContainer is {}", ModContainer.class.getClassLoader());
|
||||||
|
final List<ModContainer> containers = modFile.getScanResult().getTargets()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(e -> buildModContainerFromTOML(modFile, modInfoMap, e))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (containers.size() != modInfoMap.size()) {
|
||||||
|
LOGGER.fatal(LOADING,"File {} constructed {} mods: {}, but had {} mods specified: {}",
|
||||||
|
modFile.getFilePath(),
|
||||||
|
containers.size(), containers.stream().map(c -> c != null ? c.getModId() : "(null)").sorted().collect(Collectors.toList()),
|
||||||
|
modInfoMap.size(), modInfoMap.values().stream().map(IModInfo::getModId).sorted().collect(Collectors.toList()));
|
||||||
|
loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
||||||
|
}
|
||||||
|
// remove errored mod containers
|
||||||
|
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModContainer buildModContainerFromTOML(final ModFile modFile, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
||||||
|
try {
|
||||||
|
final String modId = idToProviderEntry.getKey();
|
||||||
|
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
||||||
|
IModInfo info = Optional.ofNullable(modInfoMap.get(modId)).
|
||||||
|
// throw a missing metadata error if there is no matching modid in the modInfoMap from the mods.toml file
|
||||||
|
orElseThrow(()->new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingmetadata", null, modId));
|
||||||
|
return languageLoader.loadMod(info, modFile.getScanResult(), FMLLoader.getGameLayer());
|
||||||
|
} catch (ModLoadingException mle) {
|
||||||
|
// exceptions are caught and added to the error list for later handling
|
||||||
|
loadingExceptions.add(mle);
|
||||||
|
// return an errored container instance here, because we tried and failed building a container.
|
||||||
|
return new ErroredModContainer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the current mod loading state is valid. Use if you interact with vanilla systems directly during loading
|
||||||
|
* and don't want to cause extraneous crashes due to trying to do things that aren't possible in a "broken load"
|
||||||
|
*/
|
||||||
|
public static boolean isLoadingStateValid() {
|
||||||
|
return get().loadingStateValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Event & IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
|
||||||
|
if (!loadingStateValid) {
|
||||||
|
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(generator.apply(mc)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Event & IModBusEvent> void postEvent(T e) {
|
||||||
|
if (!loadingStateValid) {
|
||||||
|
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ModLoadingWarning> getWarnings()
|
||||||
|
{
|
||||||
|
return ImmutableList.copyOf(this.loadingWarnings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addWarning(ModLoadingWarning warning)
|
||||||
|
{
|
||||||
|
this.loadingWarnings.add(warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean runningDataGen = false;
|
||||||
|
|
||||||
|
public static boolean isDataGenRunning () {
|
||||||
|
return runningDataGen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ErroredModContainer extends ModContainer {
|
||||||
|
public ErroredModContainer() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(final Object mod) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getMod() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.config.IConfigSpec;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ModLoadingContext
|
||||||
|
{
|
||||||
|
private static final ThreadLocal<ModLoadingContext> context = ThreadLocal.withInitial(ModLoadingContext::new);
|
||||||
|
private Object languageExtension;
|
||||||
|
private ModLoadingStage stage;
|
||||||
|
|
||||||
|
public static ModLoadingContext get() {
|
||||||
|
return context.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModContainer activeContainer;
|
||||||
|
|
||||||
|
public void setActiveContainer(final ModContainer container) {
|
||||||
|
this.activeContainer = container;
|
||||||
|
this.languageExtension = container == null ? null : container.contextExtension.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModContainer getActiveContainer() {
|
||||||
|
return activeContainer == null ? ModList.get().getModContainerById("minecraft").orElseThrow(()->new RuntimeException("Where is minecraft???!")) : activeContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActiveNamespace() {
|
||||||
|
return activeContainer == null ? "minecraft" : activeContainer.getNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an {@link IExtensionPoint} with the mod container.
|
||||||
|
* @param point The extension point to register
|
||||||
|
* @param extension An extension operator
|
||||||
|
* @param <T> The type signature of the extension operator
|
||||||
|
*/
|
||||||
|
public <T extends Record & IExtensionPoint<T>> void registerExtensionPoint(Class<? extends IExtensionPoint<T>> point, Supplier<T> extension) {
|
||||||
|
getActiveContainer().registerExtensionPoint(point, extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {
|
||||||
|
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec, String fileName) {
|
||||||
|
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> T extension() {
|
||||||
|
return (T)languageExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
|
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General purpose mod loading error message
|
||||||
|
*/
|
||||||
|
public class ModLoadingException extends RuntimeException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 2048947398536935507L;
|
||||||
|
/**
|
||||||
|
* Mod Info for mod with issue
|
||||||
|
*/
|
||||||
|
private final IModInfo modInfo;
|
||||||
|
/**
|
||||||
|
* The stage where this error was encountered
|
||||||
|
*/
|
||||||
|
private final ModLoadingStage errorStage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I18N message to use for display
|
||||||
|
*/
|
||||||
|
private final String i18nMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context for message display
|
||||||
|
*/
|
||||||
|
private final List<Object> context;
|
||||||
|
|
||||||
|
public ModLoadingException(final IModInfo modInfo, final ModLoadingStage errorStage, final String i18nMessage, final Throwable originalException, Object... context) {
|
||||||
|
super("Mod Loading Exception", originalException);
|
||||||
|
this.modInfo = modInfo;
|
||||||
|
this.errorStage = errorStage;
|
||||||
|
this.i18nMessage = i18nMessage;
|
||||||
|
this.context = Arrays.asList(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<ModLoadingException> fromEarlyException(final EarlyLoadingException e) {
|
||||||
|
return e.getAllData().stream().map(ed->new ModLoadingException(ed.getModInfo(), ModLoadingStage.VALIDATE, ed.getI18message(), e.getCause(), ed.getArgs()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getI18NMessage() {
|
||||||
|
return i18nMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getContext() {
|
||||||
|
return context.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatToString() {
|
||||||
|
return Bindings.getMessageParser().get().parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, errorStage, getCause()), context.stream()).toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return formatToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModInfo getModInfo() {
|
||||||
|
return modInfo;
|
||||||
|
}
|
||||||
|
public String getCleanMessage() {
|
||||||
|
return Bindings.getMessageParser().get().stripControlCodes(formatToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
public enum ModLoadingPhase {
|
||||||
|
ERROR, // Special state for error handling
|
||||||
|
GATHER,
|
||||||
|
LOAD,
|
||||||
|
COMPLETE,
|
||||||
|
DONE;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
public enum ModLoadingStage
|
||||||
|
{
|
||||||
|
ERROR,
|
||||||
|
VALIDATE,
|
||||||
|
CONSTRUCT,
|
||||||
|
COMMON_SETUP,
|
||||||
|
SIDED_SETUP,
|
||||||
|
ENQUEUE_IMC,
|
||||||
|
PROCESS_IMC,
|
||||||
|
COMPLETE,
|
||||||
|
DONE;
|
||||||
|
|
||||||
|
private final DeferredWorkQueue deferredWorkQueue;
|
||||||
|
|
||||||
|
ModLoadingStage() {
|
||||||
|
deferredWorkQueue = new DeferredWorkQueue(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModLoadingStage nextState(Throwable exception) {
|
||||||
|
return exception != null ? ERROR : values()[this.ordinal()+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModLoadingStage currentState(Throwable exception) {
|
||||||
|
return exception != null ? ERROR : this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeferredWorkQueue getDeferredWorkQueue() {
|
||||||
|
return deferredWorkQueue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public record ModLoadingState(String name, String previous, Function<ModList, String> message, ModLoadingPhase phase, Optional<Consumer<ModList>> inlineRunnable, Optional<IModStateTransition> transition) implements IModLoadingState {
|
||||||
|
@Override
|
||||||
|
public <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
||||||
|
return transition.map(t->t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
|
||||||
|
return new ModLoadingState(name, previous, ml->"", phase, Optional.empty(), Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase, IModStateTransition transition) {
|
||||||
|
return new ModLoadingState(name, previous, ml->"Processing transition "+name, phase, Optional.empty(), Optional.of(transition));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModLoadingState withTransition(final String name, final String previous, final Function<ModList, String> message, final ModLoadingPhase phase, IModStateTransition transition) {
|
||||||
|
return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition));
|
||||||
|
}
|
||||||
|
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase, Consumer<ModList> inline) {
|
||||||
|
return new ModLoadingState(name, previous, ml->"Processing work "+name, phase, Optional.of(inline), Optional.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import com.google.common.collect.Streams;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class ModLoadingWarning
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Mod Info for mod with warning
|
||||||
|
*/
|
||||||
|
private final IModInfo modInfo;
|
||||||
|
/**
|
||||||
|
* The stage where this warning was encountered
|
||||||
|
*/
|
||||||
|
private final ModLoadingStage warningStage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I18N message to use for display
|
||||||
|
*/
|
||||||
|
private final String i18nMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context for message display
|
||||||
|
*/
|
||||||
|
private final List<Object> context;
|
||||||
|
|
||||||
|
public ModLoadingWarning(final IModInfo modInfo, final ModLoadingStage warningStage, final String i18nMessage, Object... context) {
|
||||||
|
this.modInfo = modInfo;
|
||||||
|
this.warningStage = warningStage;
|
||||||
|
this.i18nMessage = i18nMessage;
|
||||||
|
this.context = Arrays.asList(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatToString() {
|
||||||
|
return Bindings.getMessageParser().get().parseMessage(i18nMessage, Streams.concat(Stream.of(modInfo, warningStage), context.stream()).toArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import com.google.common.graph.GraphBuilder;
|
||||||
|
import com.google.common.graph.MutableGraph;
|
||||||
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
|
public class ModStateManager {
|
||||||
|
static ModStateManager INSTANCE;
|
||||||
|
private final EnumMap<ModLoadingPhase, List<IModLoadingState>> stateMap;
|
||||||
|
|
||||||
|
public ModStateManager() {
|
||||||
|
INSTANCE = this;
|
||||||
|
final var sp = ServiceLoader.load(FMLLoader.getGameLayer(), IModStateProvider.class);
|
||||||
|
this.stateMap = ServiceLoaderUtils.streamWithErrorHandling(sp, sce->{})
|
||||||
|
.map(IModStateProvider::getAllStates)
|
||||||
|
.<IModLoadingState>mapMulti(Iterable::forEach)
|
||||||
|
.collect(Collectors.groupingBy(IModLoadingState::phase, ()->new EnumMap<>(ModLoadingPhase.class), Collectors.toUnmodifiableList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IModLoadingState> getStates(final ModLoadingPhase phase) {
|
||||||
|
var nodes = stateMap.get(phase);
|
||||||
|
var lookup = nodes.stream().collect(Collectors.toMap(IModLoadingState::name, Function.identity()));
|
||||||
|
|
||||||
|
var graph = GraphBuilder.directed().allowsSelfLoops(false).<IModLoadingState>build();
|
||||||
|
var dummy = ModLoadingState.empty("", "", phase);
|
||||||
|
nodes.forEach(graph::addNode);
|
||||||
|
graph.addNode(dummy);
|
||||||
|
nodes.forEach(n->graph.putEdge(lookup.getOrDefault(n.previous(), dummy), n));
|
||||||
|
return TopologicalSort.topologicalSort(graph, Comparator.comparingInt(nodes::indexOf)).stream().filter(st->st!=dummy).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import java.util.concurrent.locks.LockSupport;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.Logging.LOADING;
|
||||||
|
|
||||||
|
public class ModWorkManager {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static final long PARK_TIME = TimeUnit.MILLISECONDS.toNanos(1);
|
||||||
|
public interface DrivenExecutor extends Executor {
|
||||||
|
boolean selfDriven();
|
||||||
|
boolean driveOne();
|
||||||
|
|
||||||
|
default void drive(Runnable ticker) {
|
||||||
|
if (!selfDriven()) {
|
||||||
|
while (driveOne()) {
|
||||||
|
ticker.run();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// park for a bit so other threads can schedule
|
||||||
|
LockSupport.parkNanos(PARK_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class SyncExecutor implements DrivenExecutor {
|
||||||
|
private ConcurrentLinkedDeque<Runnable> tasks = new ConcurrentLinkedDeque<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean driveOne() {
|
||||||
|
final Runnable task = tasks.pollFirst();
|
||||||
|
if (task != null) {
|
||||||
|
task.run();
|
||||||
|
}
|
||||||
|
return task != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean selfDriven() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final Runnable command) {
|
||||||
|
tasks.addLast(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class WrappingExecutor implements DrivenExecutor {
|
||||||
|
private final Executor wrapped;
|
||||||
|
|
||||||
|
public WrappingExecutor(final Executor executor) {
|
||||||
|
this.wrapped = executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean selfDriven() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean driveOne() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final Runnable command) {
|
||||||
|
wrapped.execute(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SyncExecutor syncExecutor;
|
||||||
|
|
||||||
|
public static DrivenExecutor syncExecutor() {
|
||||||
|
if (syncExecutor == null)
|
||||||
|
syncExecutor = new SyncExecutor();
|
||||||
|
return syncExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DrivenExecutor wrappedExecutor(Executor executor) {
|
||||||
|
return new WrappingExecutor(executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ForkJoinPool parallelThreadPool;
|
||||||
|
public static Executor parallelExecutor() {
|
||||||
|
if (parallelThreadPool == null) {
|
||||||
|
final int loadingThreadCount = FMLConfig.loadingThreadCount();
|
||||||
|
LOGGER.debug(LOADING, "Using {} threads for parallel mod-loading", loadingThreadCount);
|
||||||
|
parallelThreadPool = new ForkJoinPool(loadingThreadCount, ModWorkManager::newForkJoinWorkerThread, null, false);
|
||||||
|
}
|
||||||
|
return parallelThreadPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ForkJoinWorkerThread newForkJoinWorkerThread(ForkJoinPool pool) {
|
||||||
|
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
||||||
|
thread.setName("modloading-worker-" + thread.getPoolIndex());
|
||||||
|
// The default sets it to the SystemClassloader, so copy the current one.
|
||||||
|
thread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class StartupMessageManager {
|
||||||
|
public static void addModMessage(final String message) {
|
||||||
|
net.minecraftforge.fml.loading.progress.StartupMessageManager.addModMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Consumer<String>> modLoaderConsumer() {
|
||||||
|
return net.minecraftforge.fml.loading.progress.StartupMessageManager.modLoaderConsumer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Consumer<String>> mcLoaderConsumer() {
|
||||||
|
return net.minecraftforge.fml.loading.progress.StartupMessageManager.mcLoaderConsumer();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
|
|
||||||
|
public enum ThreadSelector implements BinaryOperator<Executor> {
|
||||||
|
SYNC((sync, parallel) -> sync),
|
||||||
|
PARALLEL((sync, parallel) -> parallel);
|
||||||
|
|
||||||
|
private final BinaryOperator<Executor> selector;
|
||||||
|
|
||||||
|
ThreadSelector(final BinaryOperator<Executor> selector) {
|
||||||
|
this.selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Executor apply(final Executor sync, final Executor parallel) {
|
||||||
|
return this.selector.apply(sync, parallel);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.maven.artifact.versioning.ComparableVersion;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.VersionChecker.Status.*;
|
||||||
|
|
||||||
|
public class VersionChecker
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static final int MAX_HTTP_REDIRECTS = Integer.getInteger("http.maxRedirects", 20);
|
||||||
|
private static final int HTTP_TIMEOUT_SECS = Integer.getInteger("http.timeoutSecs", 15);
|
||||||
|
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
PENDING(),
|
||||||
|
FAILED(),
|
||||||
|
UP_TO_DATE(),
|
||||||
|
OUTDATED(3, true),
|
||||||
|
AHEAD(),
|
||||||
|
BETA(),
|
||||||
|
BETA_OUTDATED(6, true);
|
||||||
|
|
||||||
|
final int sheetOffset;
|
||||||
|
final boolean draw, animated;
|
||||||
|
|
||||||
|
Status()
|
||||||
|
{
|
||||||
|
this(0, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status(int sheetOffset)
|
||||||
|
{
|
||||||
|
this(sheetOffset, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status(int sheetOffset, boolean animated)
|
||||||
|
{
|
||||||
|
this(sheetOffset, true, animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status(int sheetOffset, boolean draw, boolean animated)
|
||||||
|
{
|
||||||
|
this.sheetOffset = sheetOffset;
|
||||||
|
this.draw = draw;
|
||||||
|
this.animated = animated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSheetOffset()
|
||||||
|
{
|
||||||
|
return sheetOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldDraw()
|
||||||
|
{
|
||||||
|
return draw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAnimated()
|
||||||
|
{
|
||||||
|
return animated;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public record CheckResult(VersionChecker.Status status, ComparableVersion target, Map<ComparableVersion, String> changes, String url) {}
|
||||||
|
|
||||||
|
public static void startVersionCheck()
|
||||||
|
{
|
||||||
|
new Thread("Forge Version Check")
|
||||||
|
{
|
||||||
|
private HttpClient client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!FMLConfig.runVersionCheck())
|
||||||
|
{
|
||||||
|
LOGGER.info("Global Forge version check system disabled, no further processing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS)).build();
|
||||||
|
gatherMods().forEach(this::process);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the response body as a String for the given URL while following redirects
|
||||||
|
*/
|
||||||
|
private String openUrlString(URL url) throws IOException, URISyntaxException, InterruptedException {
|
||||||
|
URL currentUrl = url;
|
||||||
|
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
||||||
|
{
|
||||||
|
var request = HttpRequest.newBuilder()
|
||||||
|
.uri(currentUrl.toURI())
|
||||||
|
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
||||||
|
.setHeader("Accept-Encoding", "gzip")
|
||||||
|
.GET()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
|
||||||
|
|
||||||
|
int responseCode = response.statusCode();
|
||||||
|
if (responseCode >= 300 && responseCode <= 399)
|
||||||
|
{
|
||||||
|
String newLocation = response.headers().firstValue("Location")
|
||||||
|
.orElseThrow(() -> new IOException("Got a 3xx response code but Location header was null while trying to fetch " + url));
|
||||||
|
currentUrl = new URL(currentUrl, newLocation);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean isGzipEncoded = response.headers().firstValue("Content-Encoding").orElse("").equals("gzip");
|
||||||
|
|
||||||
|
final String bodyStr;
|
||||||
|
try (InputStream inStream = isGzipEncoded ? new GZIPInputStream(response.body()) : response.body())
|
||||||
|
{
|
||||||
|
try (var bufferedReader = new BufferedReader(new InputStreamReader(inStream)))
|
||||||
|
{
|
||||||
|
bodyStr = bufferedReader.lines().collect(Collectors.joining("\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bodyStr;
|
||||||
|
}
|
||||||
|
throw new IOException("Too many redirects while trying to fetch " + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void process(IModInfo mod)
|
||||||
|
{
|
||||||
|
Status status = PENDING;
|
||||||
|
ComparableVersion target = null;
|
||||||
|
Map<ComparableVersion, String> changes = null;
|
||||||
|
String display_url = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (mod.getUpdateURL().isEmpty()) return;
|
||||||
|
URL url = mod.getUpdateURL().get();
|
||||||
|
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
||||||
|
|
||||||
|
String data = openUrlString(url);
|
||||||
|
|
||||||
|
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> json = new Gson().fromJson(data, Map.class);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, String> promos = (Map<String, String>)json.get("promos");
|
||||||
|
display_url = (String)json.get("homepage");
|
||||||
|
|
||||||
|
var mcVersion = FMLLoader.versionInfo().mcVersion();
|
||||||
|
String rec = promos.get(mcVersion + "-recommended");
|
||||||
|
String lat = promos.get(mcVersion + "-latest");
|
||||||
|
ComparableVersion current = new ComparableVersion(mod.getVersion().toString());
|
||||||
|
|
||||||
|
if (rec != null)
|
||||||
|
{
|
||||||
|
ComparableVersion recommended = new ComparableVersion(rec);
|
||||||
|
int diff = recommended.compareTo(current);
|
||||||
|
|
||||||
|
if (diff == 0)
|
||||||
|
status = UP_TO_DATE;
|
||||||
|
else if (diff < 0)
|
||||||
|
{
|
||||||
|
status = AHEAD;
|
||||||
|
if (lat != null)
|
||||||
|
{
|
||||||
|
ComparableVersion latest = new ComparableVersion(lat);
|
||||||
|
if (current.compareTo(latest) < 0)
|
||||||
|
{
|
||||||
|
status = OUTDATED;
|
||||||
|
target = latest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = OUTDATED;
|
||||||
|
target = recommended;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (lat != null)
|
||||||
|
{
|
||||||
|
ComparableVersion latest = new ComparableVersion(lat);
|
||||||
|
if (current.compareTo(latest) < 0)
|
||||||
|
status = BETA_OUTDATED;
|
||||||
|
else
|
||||||
|
status = BETA;
|
||||||
|
target = latest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = BETA;
|
||||||
|
|
||||||
|
LOGGER.info("[{}] Found status: {} Current: {} Target: {}", mod.getModId(), status, current, target);
|
||||||
|
|
||||||
|
changes = new LinkedHashMap<>();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, String> tmp = (Map<String, String>)json.get(mcVersion);
|
||||||
|
if (tmp != null)
|
||||||
|
{
|
||||||
|
List<ComparableVersion> ordered = new ArrayList<>();
|
||||||
|
for (String key : tmp.keySet())
|
||||||
|
{
|
||||||
|
ComparableVersion ver = new ComparableVersion(key);
|
||||||
|
if (ver.compareTo(current) > 0 && (target == null || ver.compareTo(target) < 1))
|
||||||
|
{
|
||||||
|
ordered.add(ver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(ordered);
|
||||||
|
|
||||||
|
for (ComparableVersion ver : ordered)
|
||||||
|
{
|
||||||
|
changes.put(ver, tmp.get(ver.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to process update information", e);
|
||||||
|
status = FAILED;
|
||||||
|
}
|
||||||
|
results.put(mod, new CheckResult(status, target, changes, display_url));
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gather a list of mods that have opted in to this update system by providing a URL.
|
||||||
|
private static List<IModInfo> gatherMods()
|
||||||
|
{
|
||||||
|
List<IModInfo> ret = new LinkedList<>();
|
||||||
|
for (IModInfo info : ModList.get().getMods()) {
|
||||||
|
if (info.getUpdateURL().isPresent())
|
||||||
|
ret.add(info);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<IModInfo, CheckResult> results = new ConcurrentHashMap<>();
|
||||||
|
private static final CheckResult PENDING_CHECK = new CheckResult(PENDING, null, null, null);
|
||||||
|
|
||||||
|
public static CheckResult getResult(IModInfo mod)
|
||||||
|
{
|
||||||
|
return results.getOrDefault(mod, PENDING_CHECK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.config;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.ConfigFormat;
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import com.electronwill.nightconfig.core.file.FileWatcher;
|
||||||
|
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||||
|
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||||
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.config.ConfigTracker.CONFIG;
|
||||||
|
|
||||||
|
public class ConfigFileTypeHandler {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
static ConfigFileTypeHandler TOML = new ConfigFileTypeHandler();
|
||||||
|
private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||||
|
|
||||||
|
public Function<ModConfig, CommentedFileConfig> reader(Path configBasePath) {
|
||||||
|
return (c) -> {
|
||||||
|
final Path configPath = configBasePath.resolve(c.getFileName());
|
||||||
|
final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync().
|
||||||
|
preserveInsertionOrder().
|
||||||
|
autosave().
|
||||||
|
onFileNotFound((newfile, configFormat)-> setupConfigFile(c, newfile, configFormat)).
|
||||||
|
writingMode(WritingMode.REPLACE).
|
||||||
|
build();
|
||||||
|
LOGGER.debug(CONFIG, "Built TOML config for {}", configPath.toString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
configData.load();
|
||||||
|
}
|
||||||
|
catch (ParsingException ex)
|
||||||
|
{
|
||||||
|
throw new ConfigLoadingException(c, ex);
|
||||||
|
}
|
||||||
|
LOGGER.debug(CONFIG, "Loaded TOML config file {}", configPath.toString());
|
||||||
|
try {
|
||||||
|
FileWatcher.defaultInstance().addWatch(configPath, new ConfigWatcher(c, configData, Thread.currentThread().getContextClassLoader()));
|
||||||
|
LOGGER.debug(CONFIG, "Watching TOML config file {} for changes", configPath.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Couldn't watch config file", e);
|
||||||
|
}
|
||||||
|
return configData;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unload(Path configBasePath, ModConfig config) {
|
||||||
|
Path configPath = configBasePath.resolve(config.getFileName());
|
||||||
|
try {
|
||||||
|
FileWatcher.defaultInstance().removeWatch(configBasePath.resolve(config.getFileName()));
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOGGER.error("Failed to remove config {} from tracker!", configPath.toString(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean setupConfigFile(final ModConfig modConfig, final Path file, final ConfigFormat<?> conf) throws IOException {
|
||||||
|
Path p = defaultConfigPath.resolve(modConfig.getFileName());
|
||||||
|
if (Files.exists(p)) {
|
||||||
|
LOGGER.info(CONFIG, "Loading default config file from path {}", p);
|
||||||
|
Files.copy(p, file);
|
||||||
|
} else {
|
||||||
|
Files.createFile(file);
|
||||||
|
conf.initEmptyFile(file);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void backUpConfig(final CommentedFileConfig commentedFileConfig)
|
||||||
|
{
|
||||||
|
backUpConfig(commentedFileConfig, 5); //TODO: Think of a way for mods to set their own preference (include a sanity check as well, no disk stuffing)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void backUpConfig(final CommentedFileConfig commentedFileConfig, final int maxBackups)
|
||||||
|
{
|
||||||
|
Path bakFileLocation = commentedFileConfig.getNioPath().getParent();
|
||||||
|
String bakFileName = FilenameUtils.removeExtension(commentedFileConfig.getFile().getName());
|
||||||
|
String bakFileExtension = FilenameUtils.getExtension(commentedFileConfig.getFile().getName()) + ".bak";
|
||||||
|
Path bakFile = bakFileLocation.resolve(bakFileName + "-1" + "." + bakFileExtension);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for(int i = maxBackups; i > 0; i--)
|
||||||
|
{
|
||||||
|
Path oldBak = bakFileLocation.resolve(bakFileName + "-" + i + "." + bakFileExtension);
|
||||||
|
if(Files.exists(oldBak))
|
||||||
|
{
|
||||||
|
if(i >= maxBackups)
|
||||||
|
Files.delete(oldBak);
|
||||||
|
else
|
||||||
|
Files.move(oldBak, bakFileLocation.resolve(bakFileName + "-" + (i + 1) + "." + bakFileExtension));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Files.copy(commentedFileConfig.getNioPath(), bakFile);
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
LOGGER.warn(CONFIG, "Failed to back up config file {}", commentedFileConfig.getNioPath(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConfigWatcher implements Runnable {
|
||||||
|
private final ModConfig modConfig;
|
||||||
|
private final CommentedFileConfig commentedFileConfig;
|
||||||
|
private final ClassLoader realClassLoader;
|
||||||
|
|
||||||
|
ConfigWatcher(final ModConfig modConfig, final CommentedFileConfig commentedFileConfig, final ClassLoader classLoader) {
|
||||||
|
this.modConfig = modConfig;
|
||||||
|
this.commentedFileConfig = commentedFileConfig;
|
||||||
|
this.realClassLoader = classLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Force the regular classloader onto the special thread
|
||||||
|
Thread.currentThread().setContextClassLoader(realClassLoader);
|
||||||
|
if (!this.modConfig.getSpec().isCorrecting()) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.commentedFileConfig.load();
|
||||||
|
if(!this.modConfig.getSpec().isCorrect(commentedFileConfig))
|
||||||
|
{
|
||||||
|
LOGGER.warn(CONFIG, "Configuration file {} is not correct. Correcting", commentedFileConfig.getFile().getAbsolutePath());
|
||||||
|
ConfigFileTypeHandler.backUpConfig(commentedFileConfig);
|
||||||
|
this.modConfig.getSpec().correct(commentedFileConfig);
|
||||||
|
commentedFileConfig.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ParsingException ex)
|
||||||
|
{
|
||||||
|
throw new ConfigLoadingException(modConfig, ex);
|
||||||
|
}
|
||||||
|
LOGGER.debug(CONFIG, "Config file {} changed, sending notifies", this.modConfig.getFileName());
|
||||||
|
this.modConfig.getSpec().afterReload();
|
||||||
|
this.modConfig.fireEvent(IConfigEvent.reloading(this.modConfig));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConfigLoadingException extends RuntimeException
|
||||||
|
{
|
||||||
|
public ConfigLoadingException(ModConfig config, Exception cause)
|
||||||
|
{
|
||||||
|
super("Failed loading config file " + config.getFileName() + " of type " + config.getType() + " for modid " + config.getModId(), cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.config;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.Marker;
|
||||||
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class ConfigTracker {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
static final Marker CONFIG = MarkerManager.getMarker("CONFIG");
|
||||||
|
public static final ConfigTracker INSTANCE = new ConfigTracker();
|
||||||
|
private final ConcurrentHashMap<String, ModConfig> fileMap;
|
||||||
|
private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets;
|
||||||
|
private final ConcurrentHashMap<String, Map<ModConfig.Type, ModConfig>> configsByMod;
|
||||||
|
|
||||||
|
private ConfigTracker() {
|
||||||
|
this.fileMap = new ConcurrentHashMap<>();
|
||||||
|
this.configSets = new EnumMap<>(ModConfig.Type.class);
|
||||||
|
this.configsByMod = new ConcurrentHashMap<>();
|
||||||
|
this.configSets.put(ModConfig.Type.CLIENT, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||||
|
this.configSets.put(ModConfig.Type.COMMON, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||||
|
// this.configSets.put(ModConfig.Type.PLAYER, new ConcurrentSkipListSet<>());
|
||||||
|
this.configSets.put(ModConfig.Type.SERVER, Collections.synchronizedSet(new LinkedHashSet<>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void trackConfig(final ModConfig config) {
|
||||||
|
if (this.fileMap.containsKey(config.getFileName())) {
|
||||||
|
LOGGER.error(CONFIG,"Detected config file conflict {} between {} and {}", config.getFileName(), this.fileMap.get(config.getFileName()).getModId(), config.getModId());
|
||||||
|
throw new RuntimeException("Config conflict detected!");
|
||||||
|
}
|
||||||
|
this.fileMap.put(config.getFileName(), config);
|
||||||
|
this.configSets.get(config.getType()).add(config);
|
||||||
|
this.configsByMod.computeIfAbsent(config.getModId(), (k)->new EnumMap<>(ModConfig.Type.class)).put(config.getType(), config);
|
||||||
|
LOGGER.debug(CONFIG, "Config file {} for {} tracking", config.getFileName(), config.getModId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||||
|
LOGGER.debug(CONFIG, "Loading configs type {}", type);
|
||||||
|
this.configSets.get(type).forEach(config -> openConfig(config, configBasePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||||
|
LOGGER.debug(CONFIG, "Unloading configs type {}", type);
|
||||||
|
this.configSets.get(type).forEach(config -> closeConfig(config, configBasePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openConfig(final ModConfig config, final Path configBasePath) {
|
||||||
|
LOGGER.trace(CONFIG, "Loading config file type {} at {} for {}", config.getType(), config.getFileName(), config.getModId());
|
||||||
|
final CommentedFileConfig configData = config.getHandler().reader(configBasePath).apply(config);
|
||||||
|
config.setConfigData(configData);
|
||||||
|
config.fireEvent(IConfigEvent.loading(config));
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeConfig(final ModConfig config, final Path configBasePath) {
|
||||||
|
if (config.getConfigData() != null) {
|
||||||
|
LOGGER.trace(CONFIG, "Closing config file type {} at {} for {}", config.getType(), config.getFileName(), config.getModId());
|
||||||
|
config.save();
|
||||||
|
config.getHandler().unload(configBasePath, config);
|
||||||
|
config.setConfigData(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadDefaultServerConfigs() {
|
||||||
|
configSets.get(ModConfig.Type.SERVER).forEach(modConfig -> {
|
||||||
|
final CommentedConfig commentedConfig = CommentedConfig.inMemory();
|
||||||
|
modConfig.getSpec().correct(commentedConfig);
|
||||||
|
modConfig.setConfigData(commentedConfig);
|
||||||
|
modConfig.fireEvent(IConfigEvent.loading(modConfig));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigFileName(String modId, ModConfig.Type type) {
|
||||||
|
return Optional.ofNullable(configsByMod.getOrDefault(modId, Collections.emptyMap()).getOrDefault(type, null)).
|
||||||
|
map(ModConfig::getFullPath).map(Object::toString).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<ModConfig.Type, Set<ModConfig>> configSets() {
|
||||||
|
return configSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConcurrentHashMap<String, ModConfig> fileMap() {
|
||||||
|
return fileMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.minecraftforge.fml.config;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.Bindings;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public interface IConfigEvent {
|
||||||
|
record ConfigConfig(Function<ModConfig, IConfigEvent> loading, Function<ModConfig, IConfigEvent> reloading) {}
|
||||||
|
ConfigConfig CONFIGCONFIG = Bindings.getConfigConfiguration().get();
|
||||||
|
|
||||||
|
static IConfigEvent reloading(ModConfig modConfig) {
|
||||||
|
return CONFIGCONFIG.reloading().apply(modConfig);
|
||||||
|
}
|
||||||
|
static IConfigEvent loading(ModConfig modConfig) {
|
||||||
|
return CONFIGCONFIG.loading().apply(modConfig);
|
||||||
|
}
|
||||||
|
ModConfig getConfig();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
default <T extends Event & IConfigEvent> T self() {
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.minecraftforge.fml.config;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||||
|
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
|
|
||||||
|
public interface IConfigSpec<T extends IConfigSpec<T>> extends UnmodifiableConfig {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
default T self() {
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void acceptConfig(CommentedConfig data);
|
||||||
|
|
||||||
|
boolean isCorrecting();
|
||||||
|
|
||||||
|
boolean isCorrect(CommentedConfig commentedFileConfig);
|
||||||
|
|
||||||
|
int correct(CommentedConfig commentedFileConfig);
|
||||||
|
|
||||||
|
void afterReload();
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.config;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import com.electronwill.nightconfig.toml.TomlFormat;
|
||||||
|
import net.minecraftforge.fml.ModContainer;
|
||||||
|
import net.minecraftforge.fml.loading.StringUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
public class ModConfig
|
||||||
|
{
|
||||||
|
private final Type type;
|
||||||
|
private final IConfigSpec<?> spec;
|
||||||
|
private final String fileName;
|
||||||
|
private final ModContainer container;
|
||||||
|
private final ConfigFileTypeHandler configHandler;
|
||||||
|
private CommentedConfig configData;
|
||||||
|
private Callable<Void> saveHandler;
|
||||||
|
|
||||||
|
public ModConfig(final Type type, final IConfigSpec<?> spec, final ModContainer container, final String fileName) {
|
||||||
|
this.type = type;
|
||||||
|
this.spec = spec;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.container = container;
|
||||||
|
this.configHandler = ConfigFileTypeHandler.TOML;
|
||||||
|
ConfigTracker.INSTANCE.trackConfig(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModConfig(final Type type, final IConfigSpec<?> spec, final ModContainer activeContainer) {
|
||||||
|
this(type, spec, activeContainer, defaultConfigName(type, activeContainer.getModId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String defaultConfigName(Type type, String modId) {
|
||||||
|
// config file name would be "forge-client.toml" and "forge-server.toml"
|
||||||
|
return String.format("%s-%s.toml", modId, type.extension());
|
||||||
|
}
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigFileTypeHandler getHandler() {
|
||||||
|
return configHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends IConfigSpec<T>> IConfigSpec<T> getSpec() {
|
||||||
|
return (IConfigSpec<T>) spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModId() {
|
||||||
|
return container.getModId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommentedConfig getConfigData() {
|
||||||
|
return this.configData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConfigData(final CommentedConfig configData) {
|
||||||
|
this.configData = configData;
|
||||||
|
this.spec.acceptConfig(this.configData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fireEvent(final IConfigEvent configEvent) {
|
||||||
|
this.container.dispatchConfigEvent(configEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
((CommentedFileConfig)this.configData).save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getFullPath() {
|
||||||
|
return ((CommentedFileConfig)this.configData).getNioPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void acceptSyncedConfig(byte[] bytes) {
|
||||||
|
setConfigData(TomlFormat.instance().createParser().parse(new ByteArrayInputStream(bytes)));
|
||||||
|
fireEvent(IConfigEvent.reloading(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
/**
|
||||||
|
* Common mod config for configuration that needs to be loaded on both environments.
|
||||||
|
* Loaded on both servers and clients.
|
||||||
|
* Stored in the global config directory.
|
||||||
|
* Not synced.
|
||||||
|
* Suffix is "-common" by default.
|
||||||
|
*/
|
||||||
|
COMMON,
|
||||||
|
/**
|
||||||
|
* Client config is for configuration affecting the ONLY client state such as graphical options.
|
||||||
|
* Only loaded on the client side.
|
||||||
|
* Stored in the global config directory.
|
||||||
|
* Not synced.
|
||||||
|
* Suffix is "-client" by default.
|
||||||
|
*/
|
||||||
|
CLIENT,
|
||||||
|
// /**
|
||||||
|
// * Player type config is configuration that is associated with a player.
|
||||||
|
// * Preferences around machine states, for example.
|
||||||
|
// */
|
||||||
|
// PLAYER,
|
||||||
|
/**
|
||||||
|
* Server type config is configuration that is associated with a server instance.
|
||||||
|
* Only loaded during server startup.
|
||||||
|
* Stored in a server/save specific "serverconfig" directory.
|
||||||
|
* Synced to clients during connection.
|
||||||
|
* Suffix is "-server" by default.
|
||||||
|
*/
|
||||||
|
SERVER;
|
||||||
|
|
||||||
|
public String extension() {
|
||||||
|
return StringUtils.toLowerCase(name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface for events dispatched on the ModLifecycle event bus instead of the primary event bus
|
||||||
|
*/
|
||||||
|
public interface IModBusEvent {
|
||||||
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common;
|
package net.minecraftforge.fml.util;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common;
|
package net.minecraftforge.fml.util;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
+2
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,8 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common;
|
package net.minecraftforge.fml.util;
|
||||||
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
|
|
||||||
|
|
||||||
|
|
||||||
public class LoaderException extends EnhancedRuntimeException
|
public class LoaderException extends EnhancedRuntimeException
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common;
|
package net.minecraftforge.fml.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent LoaderException from adding its own stack trace to the wrapped throwable's stack trace.
|
* Prevent LoaderException from adding its own stack trace to the wrapped throwable's stack trace.
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.util;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.INameMappingService;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.Marker;
|
||||||
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some reflection helper code.
|
||||||
|
* This may not work properly in Java 9 with its new, more restrictive, reflection management.
|
||||||
|
* As such, if issues are encountered, please report them and we can see what we can do to expand
|
||||||
|
* the compatibility.
|
||||||
|
*
|
||||||
|
* In other cases, AccessTransformers may be used.
|
||||||
|
*
|
||||||
|
* All field and method names should be passed in as SRG names, and this will automatically resolve if MCP mappings are detected.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"serial", "unchecked", "unused", "WeakerAccess"})
|
||||||
|
public class ObfuscationReflectionHelper
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static final Marker REFLECTION = MarkerManager.getMarker("REFLECTION");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remaps a name using the SRG naming function
|
||||||
|
* @param domain The {@link INameMappingService.Domain} to use to remap the name.
|
||||||
|
* @param name The name to try and remap.
|
||||||
|
* @return The remapped name, or the original name if it couldn't be remapped.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static String remapName(INameMappingService.Domain domain, String name)
|
||||||
|
{
|
||||||
|
return FMLLoader.getNameFunction("srg").map(f->f.apply(domain, name)).orElse(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value a field with the specified name in the given class.
|
||||||
|
* Note: For performance, use {@link #findField(Class, String)} if you are getting the value more than once.
|
||||||
|
* <p>
|
||||||
|
* Throws an exception if the field is not found or the value of the field cannot be gotten.
|
||||||
|
*
|
||||||
|
* @param classToAccess The class to find the field on.
|
||||||
|
* @param instance The instance of the {@code classToAccess}.
|
||||||
|
* @param fieldName The SRG (unmapped) name of the field to find (e.g. "f_46443_").
|
||||||
|
* @param <T> The type of the value.
|
||||||
|
* @param <E> The type of the {@code classToAccess}.
|
||||||
|
* @return The value of the field with the specified name in the {@code classToAccess}.
|
||||||
|
* @throws UnableToAccessFieldException If there was a problem getting the field.
|
||||||
|
* @throws UnableToAccessFieldException If there was a problem getting the value.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String fieldName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (T) findField(classToAccess, fieldName).get(instance);
|
||||||
|
}
|
||||||
|
catch (UnableToFindFieldException e)
|
||||||
|
{
|
||||||
|
LOGGER.error(REFLECTION,"Unable to locate field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e)
|
||||||
|
{
|
||||||
|
LOGGER.error(REFLECTION,"Unable to access field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e);
|
||||||
|
throw new UnableToAccessFieldException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value a field with the specified name in the given class.
|
||||||
|
* Note: For performance, use {@link #findField(Class, String)} if you are setting the value more than once.
|
||||||
|
* <p>
|
||||||
|
* Throws an exception if the field is not found or the value of the field cannot be set.
|
||||||
|
*
|
||||||
|
* @param classToAccess The class to find the field on.
|
||||||
|
* @param instance The instance of the {@code classToAccess}.
|
||||||
|
* @param value The new value for the field
|
||||||
|
* @param fieldName The name of the field in the {@code classToAccess}.
|
||||||
|
* @param <T> The type of the value.
|
||||||
|
* @param <E> The type of the {@code classToAccess}.
|
||||||
|
* @throws UnableToFindFieldException If there was a problem getting the field.
|
||||||
|
* @throws UnableToAccessFieldException If there was a problem setting the value of the field.
|
||||||
|
*/
|
||||||
|
public static <T, E> void setPrivateValue(@NotNull final Class<? super T> classToAccess, @NotNull final T instance, @Nullable final E value, @NotNull final String fieldName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
findField(classToAccess, fieldName).set(instance, value);
|
||||||
|
}
|
||||||
|
catch (UnableToFindFieldException e)
|
||||||
|
{
|
||||||
|
LOGGER.error("Unable to locate any field {} on type {}", fieldName, classToAccess.getName(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e)
|
||||||
|
{
|
||||||
|
LOGGER.error("Unable to set any field {} on type {}", fieldName, classToAccess.getName(), e);
|
||||||
|
throw new UnableToAccessFieldException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a method with the specified name and parameters in the given class and makes it accessible.
|
||||||
|
* Note: For performance, store the returned value and avoid calling this repeatedly.
|
||||||
|
* <p>
|
||||||
|
* Throws an exception if the method is not found.
|
||||||
|
*
|
||||||
|
* @param clazz The class to find the method on.
|
||||||
|
* @param methodName The SRG (unmapped) name of the method to find (e.g. "m_5776_").
|
||||||
|
* @param parameterTypes The parameter types of the method to find.
|
||||||
|
* @return The method with the specified name and parameters in the given class.
|
||||||
|
* @throws NullPointerException If {@code clazz} is null.
|
||||||
|
* @throws NullPointerException If {@code methodName} is null.
|
||||||
|
* @throws IllegalArgumentException If {@code methodName} is empty.
|
||||||
|
* @throws NullPointerException If {@code parameterTypes} is null.
|
||||||
|
* @throws UnableToFindMethodException If the method could not be found.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static Method findMethod(@NotNull final Class<?> clazz, @NotNull final String methodName, @NotNull final Class<?>... parameterTypes)
|
||||||
|
{
|
||||||
|
Preconditions.checkNotNull(clazz, "Class to find method on cannot be null.");
|
||||||
|
Preconditions.checkNotNull(methodName, "Name of method to find cannot be null.");
|
||||||
|
Preconditions.checkArgument(!methodName.isEmpty(), "Name of method to find cannot be empty.");
|
||||||
|
Preconditions.checkNotNull(parameterTypes, "Parameter types of method to find cannot be null.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Method m = clazz.getDeclaredMethod(remapName(INameMappingService.Domain.METHOD, methodName), parameterTypes);
|
||||||
|
m.setAccessible(true);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new UnableToFindMethodException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a constructor with the specified parameter types in the given class and makes it accessible.
|
||||||
|
* Note: For performance, store the returned value and avoid calling this repeatedly.
|
||||||
|
* <p>
|
||||||
|
* Throws an exception if the constructor is not found.
|
||||||
|
*
|
||||||
|
* @param clazz The class to find the constructor in.
|
||||||
|
* @param parameterTypes The parameter types of the constructor.
|
||||||
|
* @param <T> The type.
|
||||||
|
* @return The constructor with the specified parameters in the given class.
|
||||||
|
* @throws NullPointerException If {@code clazz} is null.
|
||||||
|
* @throws NullPointerException If {@code parameterTypes} is null.
|
||||||
|
* @throws UnknownConstructorException If the constructor could not be found.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static <T> Constructor<T> findConstructor(@NotNull final Class<T> clazz, @NotNull final Class<?>... parameterTypes)
|
||||||
|
{
|
||||||
|
Preconditions.checkNotNull(clazz, "Class to find constructor on cannot be null.");
|
||||||
|
Preconditions.checkNotNull(parameterTypes, "Parameter types of constructor to find cannot be null.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Constructor<T> constructor = clazz.getDeclaredConstructor(parameterTypes);
|
||||||
|
constructor.setAccessible(true);
|
||||||
|
return constructor;
|
||||||
|
}
|
||||||
|
catch (final NoSuchMethodException e)
|
||||||
|
{
|
||||||
|
final StringBuilder desc = new StringBuilder();
|
||||||
|
desc.append(clazz.getSimpleName());
|
||||||
|
|
||||||
|
StringJoiner joiner = new StringJoiner(", ", "(", ")");
|
||||||
|
for (Class<?> type : parameterTypes)
|
||||||
|
{
|
||||||
|
joiner.add(type.getSimpleName());
|
||||||
|
}
|
||||||
|
desc.append(joiner);
|
||||||
|
|
||||||
|
throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a field with the specified name in the given class and makes it accessible.
|
||||||
|
* Note: For performance, store the returned value and avoid calling this repeatedly.
|
||||||
|
* <p>
|
||||||
|
* Throws an exception if the field is not found.
|
||||||
|
*
|
||||||
|
* @param clazz The class to find the field on.
|
||||||
|
* @param fieldName The SRG (unmapped) name of the field to find (e.g. "f_46443_").
|
||||||
|
* @param <T> The type.
|
||||||
|
* @return The constructor with the specified parameters in the given class.
|
||||||
|
* @throws NullPointerException If {@code clazz} is null.
|
||||||
|
* @throws NullPointerException If {@code fieldName} is null.
|
||||||
|
* @throws IllegalArgumentException If {@code fieldName} is empty.
|
||||||
|
* @throws UnableToFindFieldException If the field could not be found.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static <T> Field findField(@NotNull final Class<? super T> clazz, @NotNull final String fieldName)
|
||||||
|
{
|
||||||
|
Preconditions.checkNotNull(clazz, "Class to find field on cannot be null.");
|
||||||
|
Preconditions.checkNotNull(fieldName, "Name of field to find cannot be null.");
|
||||||
|
Preconditions.checkArgument(!fieldName.isEmpty(), "Name of field to find cannot be empty.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Field f = clazz.getDeclaredField(remapName(INameMappingService.Domain.FIELD, fieldName));
|
||||||
|
f.setAccessible(true);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new UnableToFindFieldException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnableToAccessFieldException extends RuntimeException
|
||||||
|
{
|
||||||
|
private UnableToAccessFieldException(Exception e)
|
||||||
|
{
|
||||||
|
super(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnableToFindFieldException extends RuntimeException
|
||||||
|
{
|
||||||
|
private UnableToFindFieldException(Exception e)
|
||||||
|
{
|
||||||
|
super(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnableToFindMethodException extends RuntimeException
|
||||||
|
{
|
||||||
|
public UnableToFindMethodException(Throwable failed)
|
||||||
|
{
|
||||||
|
super(failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnknownConstructorException extends RuntimeException
|
||||||
|
{
|
||||||
|
public UnknownConstructorException(final String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common.thread;
|
package net.minecraftforge.fml.util.thread;
|
||||||
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
|
||||||
+4
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,14 +17,13 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common.thread;
|
package net.minecraftforge.fml.util.thread;
|
||||||
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread group and factory combination which belongs to a {@link LogicalSide}.
|
* A thread group and factory combination which belongs to a {@link LogicalSide}.
|
||||||
*/
|
*/
|
||||||
@@ -49,7 +48,7 @@ public final class SidedThreadGroup extends ThreadGroup implements ThreadFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(@Nonnull final Runnable runnable)
|
public Thread newThread(@NotNull final Runnable runnable)
|
||||||
{
|
{
|
||||||
return new Thread(this, runnable);
|
return new Thread(this, runnable);
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml.common.thread;
|
package net.minecraftforge.fml.util.thread;
|
||||||
|
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.github.ben-manes.versions'
|
||||||
|
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
||||||
|
}
|
||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'org.javamodularity.moduleplugin'
|
||||||
|
|
||||||
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
configurations.forEach{ it.transitive = false }
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation('net.sf.jopt-simple:jopt-simple:5.0.4')
|
||||||
|
compileOnly('org.jetbrains:annotations:21.0.0')
|
||||||
|
api("org.ow2.asm:asm:${ASM_VERSION}")
|
||||||
|
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
||||||
|
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
||||||
|
api('net.minecraftforge:forgespi:4.0.+')
|
||||||
|
api('org.apache.logging.log4j:log4j-api:2.14.1')
|
||||||
|
api('com.google.guava:guava:21.0')
|
||||||
|
api('com.google.code.gson:gson:2.8.0')
|
||||||
|
api('org.apache.maven:maven-artifact:3.8.1')
|
||||||
|
api('org.apache.commons:commons-lang3:3.8.1')
|
||||||
|
api('com.electronwill.night-config:core:3.6.3')
|
||||||
|
api('com.electronwill.night-config:toml:3.6.3')
|
||||||
|
api('cpw.mods:modlauncher:9.0.+')
|
||||||
|
api('net.minecraftforge:coremods:5.0.+')
|
||||||
|
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
||||||
|
implementation('org.apache.logging.log4j:log4j-core:2.14.1')
|
||||||
|
annotationProcessor('org.apache.logging.log4j:log4j-core:2.14.1')
|
||||||
|
implementation('net.minecraftforge:accesstransformers:8.0.4')
|
||||||
|
implementation('net.minecrell:terminalconsoleappender:1.2.0')
|
||||||
|
// implementation('org.jline:jline:3.12.+')
|
||||||
|
testCompileOnly('org.jetbrains:annotations:21.0.0')
|
||||||
|
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
archiveClassifier = 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
MANIFESTS = [
|
||||||
|
'/': [
|
||||||
|
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
'Git-Commit': GIT_INFO.abbreviatedId,
|
||||||
|
'Git-Branch': GIT_INFO.branch,
|
||||||
|
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
||||||
|
] as LinkedHashMap,
|
||||||
|
'net/minecraftforge/fml/loading/': [
|
||||||
|
'Specification-Title': 'FMLLoader',
|
||||||
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
|
'Specification-Version': '1',
|
||||||
|
'Implementation-Title': 'FML Loader',
|
||||||
|
'Implementation-Version': '1.0',
|
||||||
|
'Implementation-Vendor': 'Forge'
|
||||||
|
] as LinkedHashMap
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.doFirst {
|
||||||
|
MANIFESTS.each { pkg, values ->
|
||||||
|
manifest.attributes(values, pkg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << '-Xlint:unchecked'
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives jar
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing.publications.mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
artifact sourcesJar
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.common.asm;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AnnotationNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the final modifier from fields with the @CapabilityInject annotation, prevents the JITer from in lining them so our runtime replacements can work.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "1.18", forRemoval = true)
|
||||||
|
public class CapabilityInjectDefinalize implements ILaunchPluginService {
|
||||||
|
|
||||||
|
private final String CAP = "Lnet/minecraftforge/common/capabilities/Capability;"; //Don't directly reference this to prevent class loading.
|
||||||
|
private final String CAP_INJECT = "Lnet/minecraftforge/common/capabilities/CapabilityInject;"; //Don't directly reference this to prevent class loading.
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "capability_inject_definalize";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||||
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||||
|
{
|
||||||
|
return isEmpty ? NAY : YAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasHolder(List<AnnotationNode> lst)
|
||||||
|
{
|
||||||
|
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(CAP_INJECT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
|
||||||
|
{
|
||||||
|
final int flags = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
|
||||||
|
final AtomicBoolean changed = new AtomicBoolean();
|
||||||
|
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.equals(CAP) && hasHolder(f.visibleAnnotations)).forEach(f ->
|
||||||
|
{
|
||||||
|
int prev = f.access;
|
||||||
|
f.access &= ~Opcodes.ACC_FINAL; //Strip final
|
||||||
|
f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime.
|
||||||
|
changed.compareAndSet(false, prev != f.access);
|
||||||
|
});
|
||||||
|
|
||||||
|
return changed.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.common.asm;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.signature.SignatureReader;
|
||||||
|
import org.objectweb.asm.signature.SignatureVisitor;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements getType() in CapabilityToken subclasses.
|
||||||
|
*
|
||||||
|
* Using the class's signature to determine the generic type of TypeToken, and then implements getType() using that value.
|
||||||
|
* <pre>
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* <code>new CapabilityToken<String>(){}</code>
|
||||||
|
* Has the signature <code>"CapabilityToken<Ljava/lang/String;>"</code>
|
||||||
|
*
|
||||||
|
* Implements the method:
|
||||||
|
* <code>public String getType() {
|
||||||
|
* return "java/lang/String";
|
||||||
|
* }</code>
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||||
|
|
||||||
|
private final String FUNC_NAME = "getType";
|
||||||
|
private final String FUNC_DESC = "()Ljava/lang/String;";
|
||||||
|
private final String CAP_INJECT = "net/minecraftforge/common/capabilities/CapabilityToken"; //Don't directly reference this to prevent class loading.
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "capability_token_subclass";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||||
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||||
|
{
|
||||||
|
return isEmpty ? NAY : YAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
|
||||||
|
{
|
||||||
|
if (CAP_INJECT.equals(classNode.name))
|
||||||
|
{
|
||||||
|
for (MethodNode mtd : classNode.methods)
|
||||||
|
{
|
||||||
|
if (FUNC_NAME.equals(mtd.name) && FUNC_DESC.equals(mtd.desc))
|
||||||
|
{
|
||||||
|
mtd.access &= ~Opcodes.ACC_FINAL; // We have it final in code so people don't override it, cuz that'd be stupid, and make our transformer more complicated.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ComputeFlags.SIMPLE_REWRITE;
|
||||||
|
}
|
||||||
|
else if (CAP_INJECT.equals(classNode.superName))
|
||||||
|
{
|
||||||
|
Holder cls = new Holder();
|
||||||
|
|
||||||
|
SignatureReader reader = new SignatureReader(classNode.signature); // Having a node version of this would probably be useful.
|
||||||
|
reader.accept(new SignatureVisitor(Opcodes.ASM9)
|
||||||
|
{
|
||||||
|
Deque<String> stack = new ArrayDeque<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitClassType(final String name)
|
||||||
|
{
|
||||||
|
stack.push(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitInnerClassType(final String name)
|
||||||
|
{
|
||||||
|
stack.push(stack.pop() + '$' + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitEnd()
|
||||||
|
{
|
||||||
|
var val = stack.pop();
|
||||||
|
if (!stack.isEmpty() && CAP_INJECT.equals(stack.peek()))
|
||||||
|
cls.value = val;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (cls.value == null)
|
||||||
|
throw new IllegalStateException("Could not find signature for CapabilityToken on " + classNode.name + " from " + classNode.signature);
|
||||||
|
|
||||||
|
var mtd = classNode.visitMethod(Opcodes.ACC_PUBLIC, FUNC_NAME, FUNC_DESC, null, new String[0]);
|
||||||
|
mtd.visitLdcInsn(cls.value);
|
||||||
|
mtd.visitInsn(Opcodes.ARETURN);
|
||||||
|
mtd.visitEnd();
|
||||||
|
return ComputeFlags.COMPUTE_MAXS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ComputeFlags.NO_REWRITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Holder {
|
||||||
|
String value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.common.asm;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AnnotationNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the final modifier from fields with the @ObjectHolder annotation, prevents the JITer from in lining them so our runtime replacements can work.
|
||||||
|
* Will also de-finalize all fields in on class level annotations.
|
||||||
|
*/
|
||||||
|
public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||||
|
|
||||||
|
private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "object_holder_definalize";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||||
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||||
|
{
|
||||||
|
return isEmpty ? NAY : YAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasHolder(List<AnnotationNode> lst)
|
||||||
|
{
|
||||||
|
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getValue(List<AnnotationNode> lst)
|
||||||
|
{
|
||||||
|
AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get();
|
||||||
|
if (ann.values != null)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < ann.values.size() - 1; x += 2) {
|
||||||
|
if (ann.values.get(x).equals("value")) {
|
||||||
|
return (String)ann.values.get(x + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
|
||||||
|
{
|
||||||
|
final AtomicBoolean changes = new AtomicBoolean();
|
||||||
|
//Must be public static finals, and non-array objects
|
||||||
|
final int flags = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
|
||||||
|
|
||||||
|
//Fix Annotated Fields before injecting from class level
|
||||||
|
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f ->
|
||||||
|
{
|
||||||
|
int prev = f.access;
|
||||||
|
f.access &= ~Opcodes.ACC_FINAL; //Strip final
|
||||||
|
f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime. ? Good idea?
|
||||||
|
changes.compareAndSet(false, prev != f.access);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasHolder(classNode.visibleAnnotations)) //Class level, de-finalize all fields and add @ObjectHolder to them!
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
String value = getValue(classNode.visibleAnnotations);
|
||||||
|
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f ->
|
||||||
|
{
|
||||||
|
int prev = f.access;
|
||||||
|
f.access &= ~Opcodes.ACC_FINAL;
|
||||||
|
f.access |= Opcodes.ACC_SYNTHETIC;
|
||||||
|
/*if (!hasHolder(f.visibleAnnotations)) //Add field level annotation, doesn't do anything until after we figure out how ASMDataTable is gatherered
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
f.visitAnnotation(OBJECT_HOLDER, true);
|
||||||
|
else
|
||||||
|
f.visitAnnotation(OBJECT_HOLDER, true).visit("value", value + ":" + f.name.toLowerCase());
|
||||||
|
}*/
|
||||||
|
changes.compareAndSet(false, prev != f.access);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.common.asm;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.objectweb.asm.Label;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifies specified enums to allow runtime extension by making the $VALUES field non-final and
|
||||||
|
* injecting constructor calls which are not valid in normal java code.
|
||||||
|
*/
|
||||||
|
public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private final Type STRING = Type.getType(String.class);
|
||||||
|
private final Type ENUM = Type.getType(Enum.class);
|
||||||
|
private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
|
||||||
|
private final Type ARRAY_UTILS = Type.getType("Lorg/apache/commons/lang3/ArrayUtils;"); //Don't directly reference this to prevent class loading.
|
||||||
|
private final String ADD_DESC = Type.getMethodDescriptor(Type.getType(Object[].class), Type.getType(Object[].class), Type.getType(Object.class));
|
||||||
|
private final Type UNSAFE_HACKS = Type.getType("Lnet/minecraftforge/fml/unsafe/UnsafeHacks;"); //Again, not direct reference to prevent class loading.
|
||||||
|
private final String CLEAN_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Class.class));
|
||||||
|
private final String NAME_DESC = Type.getMethodDescriptor(STRING);
|
||||||
|
private final String EQUALS_DESC = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, STRING);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "runtime_enum_extender";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||||
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||||
|
{
|
||||||
|
return isEmpty ? NAY : YAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
|
||||||
|
{
|
||||||
|
if ((classNode.access & Opcodes.ACC_ENUM) == 0)
|
||||||
|
return ComputeFlags.NO_REWRITE;
|
||||||
|
|
||||||
|
Type array = Type.getType("[" + classType.getDescriptor());
|
||||||
|
final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
|
||||||
|
|
||||||
|
FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null);
|
||||||
|
|
||||||
|
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
|
||||||
|
return ComputeFlags.NO_REWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Static methods named "create" with first argument as a string
|
||||||
|
List<MethodNode> candidates = classNode.methods.stream()
|
||||||
|
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (candidates.isEmpty()) {
|
||||||
|
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates.forEach(mtd ->
|
||||||
|
{
|
||||||
|
Type[] args = Type.getArgumentTypes(mtd.desc);
|
||||||
|
if (args.length == 0 || !args[0].equals(STRING)) {
|
||||||
|
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
||||||
|
sb.append("Enum has create method without String as first parameter:\n");
|
||||||
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
|
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
||||||
|
}));
|
||||||
|
throw new IllegalStateException("Enum has create method without String as first parameter: " + mtd.name + mtd.desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Type ret = Type.getReturnType(mtd.desc);
|
||||||
|
if (!ret.equals(classType)) {
|
||||||
|
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
||||||
|
sb.append("Enum has create method with incorrect return type:\n");
|
||||||
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
|
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
||||||
|
sb.append(" Found: ").append(ret.getClassName()).append(", Expected: ").append(classType.getClassName());
|
||||||
|
}));
|
||||||
|
throw new IllegalStateException("Enum has create method with incorrect return type: " + mtd.name + mtd.desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Type[] ctrArgs = new Type[args.length + 1];
|
||||||
|
ctrArgs[0] = STRING;
|
||||||
|
ctrArgs[1] = Type.INT_TYPE;
|
||||||
|
for (int x = 1; x < args.length; x++)
|
||||||
|
ctrArgs[1 + x] = args[x];
|
||||||
|
|
||||||
|
String desc = Type.getMethodDescriptor(Type.VOID_TYPE, ctrArgs);
|
||||||
|
|
||||||
|
MethodNode ctr = classNode.methods.stream().filter(m -> m.name.equals("<init>") && m.desc.equals(desc)).findFirst().orElse(null);
|
||||||
|
if (ctr == null)
|
||||||
|
{
|
||||||
|
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
||||||
|
sb.append("Enum has create method with no matching constructor:\n");
|
||||||
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
|
sb.append(" Candidate: ").append(mtd.desc).append("\n");
|
||||||
|
sb.append(" Target: ").append(desc).append("\n");
|
||||||
|
classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n"));
|
||||||
|
}));
|
||||||
|
throw new IllegalStateException("Enum has create method with no matching constructor: " + desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values == null)
|
||||||
|
{
|
||||||
|
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
||||||
|
sb.append("Enum has create method but we could not find $VALUES. Found:\n");
|
||||||
|
classNode.fields.stream().filter(f -> (f.access & Opcodes.ACC_STATIC) != 0).
|
||||||
|
forEach(m -> sb.append(" ").append(m.name).append(" ").append(m.desc).append("\n"));
|
||||||
|
}));
|
||||||
|
throw new IllegalStateException("Enum has create method but we could not find $VALUES");
|
||||||
|
}
|
||||||
|
|
||||||
|
values.access &= values.access & ~Opcodes.ACC_FINAL; //Strip the final so JITer doesn't inline things.
|
||||||
|
|
||||||
|
mtd.access |= Opcodes.ACC_SYNCHRONIZED;
|
||||||
|
mtd.instructions.clear();
|
||||||
|
InstructionAdapter ins = new InstructionAdapter(mtd);
|
||||||
|
|
||||||
|
int vars = 0;
|
||||||
|
for (Type arg : args)
|
||||||
|
vars += arg.getSize();
|
||||||
|
|
||||||
|
{
|
||||||
|
vars += 1; //int x
|
||||||
|
Label for_start = new Label();
|
||||||
|
Label for_condition = new Label();
|
||||||
|
Label for_inc = new Label();
|
||||||
|
|
||||||
|
ins.iconst(0);
|
||||||
|
ins.store(vars, Type.INT_TYPE);
|
||||||
|
ins.goTo(for_condition);
|
||||||
|
//if (!VALUES[x].name().equalsIgnoreCase(name)) goto for_inc
|
||||||
|
ins.mark(for_start);
|
||||||
|
ins.getstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
ins.load(vars, Type.INT_TYPE);
|
||||||
|
ins.aload(array);
|
||||||
|
ins.invokevirtual(ENUM.getInternalName(), "name", NAME_DESC, false);
|
||||||
|
ins.load(0, STRING);
|
||||||
|
ins.invokevirtual(STRING.getInternalName(), "equalsIgnoreCase", EQUALS_DESC, false);
|
||||||
|
ins.ifeq(for_inc);
|
||||||
|
//return VALUES[x];
|
||||||
|
ins.getstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
ins.load(vars, Type.INT_TYPE);
|
||||||
|
ins.aload(array);
|
||||||
|
ins.areturn(classType);
|
||||||
|
//x++
|
||||||
|
ins.mark(for_inc);
|
||||||
|
ins.iinc(vars, 1);
|
||||||
|
//if (x < VALUES.length) goto for_start
|
||||||
|
ins.mark(for_condition);
|
||||||
|
ins.load(vars, Type.INT_TYPE);
|
||||||
|
ins.getstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
ins.arraylength();
|
||||||
|
ins.ificmplt(for_start);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
vars += 1; //enum ret;
|
||||||
|
//ret = new ThisType(name, VALUES.length, args..)
|
||||||
|
ins.anew(classType);
|
||||||
|
ins.dup();
|
||||||
|
ins.load(0, STRING);
|
||||||
|
ins.getstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
ins.arraylength();
|
||||||
|
int idx = 1;
|
||||||
|
for (int x = 1; x < args.length; x++)
|
||||||
|
{
|
||||||
|
ins.load(idx, args[x]);
|
||||||
|
idx += args[x].getSize();
|
||||||
|
}
|
||||||
|
ins.invokespecial(classType.getInternalName(), "<init>", desc, false);
|
||||||
|
ins.store(vars, classType);
|
||||||
|
// VALUES = ArrayUtils.add(VALUES, ret)
|
||||||
|
ins.getstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
ins.load(vars, classType);
|
||||||
|
ins.invokestatic(ARRAY_UTILS.getInternalName(), "add", ADD_DESC, false);
|
||||||
|
ins.checkcast(array);
|
||||||
|
ins.putstatic(classType.getInternalName(), values.name, values.desc);
|
||||||
|
//EnumHelper.cleanEnumCache(ThisType.class)
|
||||||
|
ins.visitLdcInsn(classType);
|
||||||
|
ins.invokestatic(UNSAFE_HACKS.getInternalName(), "cleanEnumCache", CLEAN_DESC, false);
|
||||||
|
//init ret
|
||||||
|
ins.load(vars, classType);
|
||||||
|
ins.invokeinterface(MARKER_IFACE.getInternalName(), "init", "()V");
|
||||||
|
//return ret
|
||||||
|
ins.load(vars, classType);
|
||||||
|
ins.areturn(classType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ComputeFlags.COMPUTE_FRAMES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.message.Message;
|
import org.apache.logging.log4j.message.Message;
|
||||||
import org.apache.logging.log4j.util.StringBuilderFormattable;
|
import org.apache.logging.log4j.util.StringBuilderFormattable;
|
||||||
@@ -25,6 +25,8 @@ import org.apache.logging.log4j.util.StringBuilderFormattable;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class AdvancedLogMessageAdapter implements Message, StringBuilderFormattable {
|
public class AdvancedLogMessageAdapter implements Message, StringBuilderFormattable {
|
||||||
|
private static final long serialVersionUID = -8291754833965087436L;
|
||||||
|
|
||||||
private static final Object[] EMPTY = new Object[0];
|
private static final Object[] EMPTY = new Object[0];
|
||||||
|
|
||||||
private final Consumer<StringBuilder> logMessageBuilder;
|
private final Consumer<StringBuilder> logMessageBuilder;
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
public class BackgroundWaiter {
|
||||||
|
private static ExecutorService runner = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
public static void runAndTick(Runnable r, Runnable tick) {
|
||||||
|
final Future<?> work = runner.submit(r);
|
||||||
|
do {
|
||||||
|
tick.run();
|
||||||
|
try {
|
||||||
|
Thread.sleep(50);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
} while (!work.isDone());
|
||||||
|
try {
|
||||||
|
runner.shutdown();
|
||||||
|
work.get();
|
||||||
|
} catch (ExecutionException ee) {
|
||||||
|
throw new RuntimeException(ee.getCause());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-4
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,12 +29,17 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class EarlyLoadingException extends RuntimeException {
|
public class EarlyLoadingException extends RuntimeException {
|
||||||
public static class ExceptionData {
|
public static class ExceptionData {
|
||||||
|
private final IModInfo modInfo;
|
||||||
|
|
||||||
private final String i18message;
|
private final String i18message;
|
||||||
private final Object[] args;
|
private final Object[] args;
|
||||||
|
|
||||||
public ExceptionData(final String message, Object... args) {
|
public ExceptionData(final String message, Object... args) {
|
||||||
|
this(message, null, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExceptionData(final String message, final IModInfo modInfo, Object... args) {
|
||||||
this.i18message = message;
|
this.i18message = message;
|
||||||
|
this.modInfo = modInfo;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +50,10 @@ public class EarlyLoadingException extends RuntimeException {
|
|||||||
public Object[] getArgs() {
|
public Object[] getArgs() {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IModInfo getModInfo() {
|
||||||
|
return modInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private final List<ExceptionData> errorMessages;
|
private final List<ExceptionData> errorMessages;
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.ConfigSpec;
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import com.electronwill.nightconfig.core.file.FileNotFoundAction;
|
||||||
|
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||||
|
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
|
public class FMLConfig
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static FMLConfig INSTANCE = new FMLConfig();
|
||||||
|
private static ConfigSpec configSpec = new ConfigSpec();
|
||||||
|
static {
|
||||||
|
configSpec.define("splashscreen", Boolean.TRUE);
|
||||||
|
configSpec.define("maxThreads", -1);
|
||||||
|
configSpec.define("versionCheck", Boolean.TRUE);
|
||||||
|
configSpec.define("defaultConfigPath", "defaultconfigs");
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommentedFileConfig configData;
|
||||||
|
|
||||||
|
private void loadFrom(final Path configFile)
|
||||||
|
{
|
||||||
|
configData = CommentedFileConfig.builder(configFile).sync()
|
||||||
|
.onFileNotFound(FileNotFoundAction.copyData(Objects.requireNonNull(getClass().getResourceAsStream("/META-INF/defaultfmlconfig.toml"))))
|
||||||
|
.autosave().autoreload()
|
||||||
|
.writingMode(WritingMode.REPLACE)
|
||||||
|
.build();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
configData.load();
|
||||||
|
}
|
||||||
|
catch (ParsingException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Failed to load FML config from " + configFile.toString(), e);
|
||||||
|
}
|
||||||
|
if (!configSpec.isCorrect(configData)) {
|
||||||
|
LOGGER.warn(CORE, "Configuration file {} is not correct. Correcting", configFile);
|
||||||
|
configSpec.correct(configData, (action, path, incorrectValue, correctedValue) ->
|
||||||
|
LOGGER.warn(CORE, "Incorrect key {} was corrected from {} to {}", path, incorrectValue, correctedValue));
|
||||||
|
}
|
||||||
|
configData.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load()
|
||||||
|
{
|
||||||
|
final Path configFile = FMLPaths.FMLCONFIG.get();
|
||||||
|
INSTANCE.loadFrom(configFile);
|
||||||
|
LOGGER.trace(CORE, "Loaded FML config from {}", FMLPaths.FMLCONFIG.get());
|
||||||
|
LOGGER.trace(CORE, "Splash screen is {}", FMLConfig::splashScreenEnabled);
|
||||||
|
LOGGER.trace(CORE, "Max threads for mod loading computed at {}", FMLConfig::loadingThreadCount);
|
||||||
|
LOGGER.trace(CORE, "Version check is {}", FMLConfig::runVersionCheck);
|
||||||
|
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig::defaultConfigPath);
|
||||||
|
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean splashScreenEnabled() {
|
||||||
|
return INSTANCE.configData.<Boolean>getOptional("splashscreen").orElse(Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int loadingThreadCount() {
|
||||||
|
int val = INSTANCE.configData.<Integer>getOptional("maxThreads").orElse(-1);
|
||||||
|
if (val <= 0) return Runtime.getRuntime().availableProcessors();
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean runVersionCheck() {
|
||||||
|
return INSTANCE.configData.<Boolean>getOptional("versionCheck").orElse(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String defaultConfigPath() {
|
||||||
|
return INSTANCE.configData.<String>getOptional("defaultConfigPath").orElse("defaultconfigs");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.IEnvironment;
|
||||||
|
import cpw.mods.modlauncher.api.TypesafeMap;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.forgespi.Environment;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class FMLEnvironment
|
||||||
|
{
|
||||||
|
public static final Dist dist = FMLLoader.getDist();
|
||||||
|
public static final String naming = FMLLoader.getNaming();
|
||||||
|
public static final boolean production = FMLLoader.isProduction() || System.getProperties().containsKey("production");
|
||||||
|
public static final boolean secureJarsEnabled = FMLLoader.isSecureJarEnabled();
|
||||||
|
|
||||||
|
static void setupInteropEnvironment(IEnvironment environment) {
|
||||||
|
environment.computePropertyIfAbsent(IEnvironment.Keys.NAMING.get(), v->naming);
|
||||||
|
environment.computePropertyIfAbsent(Environment.Keys.DIST.get(), v->dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Keys {
|
||||||
|
public static final Supplier<TypesafeMap.Key<ClassLoader>> LOCATORCLASSLOADER = IEnvironment.buildKey("LOCATORCLASSLOADER",ClassLoader.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.Launcher;
|
||||||
|
import cpw.mods.modlauncher.api.*;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
|
import net.minecraftforge.accesstransformer.service.AccessTransformerService;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.*;
|
||||||
|
import net.minecraftforge.fml.loading.progress.EarlyProgressVisualization;
|
||||||
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
|
import net.minecraftforge.fml.loading.targets.CommonLaunchHandler;
|
||||||
|
import net.minecraftforge.forgespi.Environment;
|
||||||
|
import net.minecraftforge.forgespi.coremod.ICoreModProvider;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||||
|
|
||||||
|
public class FMLLoader
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static AccessTransformerService accessTransformer;
|
||||||
|
private static ModDiscoverer modDiscoverer;
|
||||||
|
private static ICoreModProvider coreModProvider;
|
||||||
|
private static ILaunchPluginService eventBus;
|
||||||
|
private static LanguageLoadingProvider languageLoadingProvider;
|
||||||
|
private static Dist dist;
|
||||||
|
private static String naming;
|
||||||
|
private static LoadingModList loadingModList;
|
||||||
|
private static RuntimeDistCleaner runtimeDistCleaner;
|
||||||
|
private static Path gamePath;
|
||||||
|
private static VersionInfo versionInfo;
|
||||||
|
private static String launchHandlerName;
|
||||||
|
private static CommonLaunchHandler commonLaunchHandler;
|
||||||
|
public static Runnable progressWindowTick;
|
||||||
|
private static ModValidator modValidator;
|
||||||
|
public static BackgroundScanHandler backgroundScanHandler;
|
||||||
|
private static boolean production;
|
||||||
|
private static IModuleLayerManager moduleLayerManager;
|
||||||
|
|
||||||
|
static void onInitialLoad(IEnvironment environment, Set<String> otherServices) throws IncompatibleEnvironmentException
|
||||||
|
{
|
||||||
|
final String version = LauncherVersion.getVersion();
|
||||||
|
LOGGER.debug(CORE,"FML {} loading", version);
|
||||||
|
final Package modLauncherPackage = ITransformationService.class.getPackage();
|
||||||
|
LOGGER.debug(CORE,"FML found ModLauncher version : {}", modLauncherPackage.getImplementationVersion());
|
||||||
|
if (!modLauncherPackage.isCompatibleWith("4.0")) {
|
||||||
|
LOGGER.fatal(CORE,"Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor());
|
||||||
|
throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> {
|
||||||
|
LOGGER.fatal(CORE,"Access Transformer library is missing, we need this to run");
|
||||||
|
return new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run");
|
||||||
|
});
|
||||||
|
|
||||||
|
final Package atPackage = accessTransformer.getClass().getPackage();
|
||||||
|
LOGGER.debug(CORE,"FML found AccessTransformer version : {}", atPackage.getImplementationVersion());
|
||||||
|
if (!atPackage.isCompatibleWith("1.0")) {
|
||||||
|
LOGGER.fatal(CORE,"Found incompatible AccessTransformer specification : {}, version {} from {}", atPackage.getSpecificationVersion(), atPackage.getImplementationVersion(), atPackage.getImplementationVendor());
|
||||||
|
throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> {
|
||||||
|
LOGGER.fatal(CORE,"Event Bus library is missing, we need this to run");
|
||||||
|
return new IncompatibleEnvironmentException("Missing EventBus, cannot run");
|
||||||
|
});
|
||||||
|
|
||||||
|
final Package eventBusPackage = eventBus.getClass().getPackage();
|
||||||
|
LOGGER.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion());
|
||||||
|
if (!eventBusPackage.isCompatibleWith("1.0")) {
|
||||||
|
LOGGER.fatal(CORE,"Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor());
|
||||||
|
throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
runtimeDistCleaner = (RuntimeDistCleaner)environment.findLaunchPlugin("runtimedistcleaner").orElseThrow(()-> {
|
||||||
|
LOGGER.fatal(CORE,"Dist Cleaner is missing, we need this to run");
|
||||||
|
return new IncompatibleEnvironmentException("Missing DistCleaner, cannot run!");
|
||||||
|
});
|
||||||
|
LOGGER.debug(CORE, "Found Runtime Dist Cleaner");
|
||||||
|
|
||||||
|
var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.fatal(CORE, "Failed to load a coremod library, expect problems", sce)).toList();
|
||||||
|
|
||||||
|
if (coreModProviders.isEmpty()) {
|
||||||
|
LOGGER.fatal(CORE, "Found no coremod provider. Cannot run");
|
||||||
|
throw new IncompatibleEnvironmentException("No coremod library found");
|
||||||
|
} else if (coreModProviders.size() > 1) {
|
||||||
|
LOGGER.fatal(CORE, "Found multiple coremod providers : {}. Cannot run", coreModProviders.stream().map(p -> p.getClass().getName()).collect(Collectors.toList()));
|
||||||
|
throw new IncompatibleEnvironmentException("Multiple coremod libraries found");
|
||||||
|
}
|
||||||
|
|
||||||
|
coreModProvider = coreModProviders.get(0);
|
||||||
|
final Package coremodPackage = coreModProvider.getClass().getPackage();
|
||||||
|
LOGGER.debug(CORE,"FML found CoreMod version : {}", coremodPackage.getImplementationVersion());
|
||||||
|
|
||||||
|
|
||||||
|
LOGGER.debug(CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion());
|
||||||
|
LOGGER.debug(CORE, "Found ForgeSPI package specification {}", Environment.class.getPackage().getSpecificationVersion());
|
||||||
|
if (Integer.parseInt(Environment.class.getPackage().getSpecificationVersion()) < 2) {
|
||||||
|
LOGGER.fatal(CORE, "Found an out of date ForgeSPI implementation: {}, loading cannot continue", Environment.class.getPackage().getSpecificationVersion());
|
||||||
|
throw new IncompatibleEnvironmentException("ForgeSPI is out of date, we cannot continue");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class.forName("com.electronwill.nightconfig.core.Config", false, environment.getClass().getClassLoader());
|
||||||
|
Class.forName("com.electronwill.nightconfig.toml.TomlFormat", false, environment.getClass().getClassLoader());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
LOGGER.fatal(CORE, "Failed to load NightConfig");
|
||||||
|
throw new IncompatibleEnvironmentException("Missing NightConfig");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setupLaunchHandler(final IEnvironment environment, final Map<String, Object> arguments)
|
||||||
|
{
|
||||||
|
final String launchTarget = environment.getProperty(IEnvironment.Keys.LAUNCHTARGET.get()).orElse("MISSING");
|
||||||
|
arguments.put("launchTarget", launchTarget);
|
||||||
|
final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget);
|
||||||
|
LOGGER.debug(CORE, "Using {} as launch service", launchTarget);
|
||||||
|
if (launchHandler.isEmpty()) {
|
||||||
|
LOGGER.fatal(CORE,"Missing LaunchHandler {}, cannot continue", launchTarget);
|
||||||
|
throw new RuntimeException("Missing launch handler: " + launchTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
|
||||||
|
LOGGER.fatal(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName());
|
||||||
|
throw new RuntimeException("Incompatible launch handler found");
|
||||||
|
}
|
||||||
|
commonLaunchHandler = (CommonLaunchHandler)launchHandler.get();
|
||||||
|
launchHandlerName = launchHandler.get().name();
|
||||||
|
gamePath = environment.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElse(Paths.get(".").toAbsolutePath());
|
||||||
|
|
||||||
|
naming = commonLaunchHandler.getNaming();
|
||||||
|
dist = commonLaunchHandler.getDist();
|
||||||
|
production = commonLaunchHandler.isProduction();
|
||||||
|
|
||||||
|
versionInfo = new VersionInfo(arguments);
|
||||||
|
|
||||||
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Early Loading!"));
|
||||||
|
accessTransformer.getExtension().accept(Pair.of(naming, "srg"));
|
||||||
|
|
||||||
|
LOGGER.debug(CORE,"Received command line version data : {}", versionInfo);
|
||||||
|
|
||||||
|
runtimeDistCleaner.getExtension().accept(dist);
|
||||||
|
}
|
||||||
|
public static List<ITransformationService.Resource> beginModScan(final Map<String,?> arguments)
|
||||||
|
{
|
||||||
|
LOGGER.debug(SCAN,"Scanning for Mod Locators");
|
||||||
|
modDiscoverer = new ModDiscoverer(arguments);
|
||||||
|
modValidator = modDiscoverer.discoverMods();
|
||||||
|
var pluginResources = modValidator.getPluginResources();
|
||||||
|
return List.of(pluginResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ITransformationService.Resource> completeScan(IModuleLayerManager layerManager) {
|
||||||
|
progressWindowTick = EarlyProgressVisualization.INSTANCE.accept(dist, commonLaunchHandler.isData(), versionInfo.mcVersion());
|
||||||
|
moduleLayerManager = layerManager;
|
||||||
|
languageLoadingProvider = new LanguageLoadingProvider();
|
||||||
|
backgroundScanHandler = modValidator.stage2Validation();
|
||||||
|
loadingModList = backgroundScanHandler.getLoadingModList();
|
||||||
|
return List.of(modValidator.getModResources());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICoreModProvider getCoreModProvider() {
|
||||||
|
return coreModProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LanguageLoadingProvider getLanguageLoadingProvider()
|
||||||
|
{
|
||||||
|
return languageLoadingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ModDiscoverer getModDiscoverer() {
|
||||||
|
return modDiscoverer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommonLaunchHandler getLaunchHandler() {
|
||||||
|
return commonLaunchHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addAccessTransformer(Path atPath, ModFile modName)
|
||||||
|
{
|
||||||
|
LOGGER.debug(SCAN, "Adding Access Transformer in {}", modName.getFilePath());
|
||||||
|
accessTransformer.offerResource(atPath, modName.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dist getDist()
|
||||||
|
{
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void beforeStart(ClassLoader launchClassLoader)
|
||||||
|
{
|
||||||
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Launching minecraft"));
|
||||||
|
progressWindowTick.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LoadingModList getLoadingModList()
|
||||||
|
{
|
||||||
|
return loadingModList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path getGamePath()
|
||||||
|
{
|
||||||
|
return gamePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getNaming() {
|
||||||
|
return naming;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<BiFunction<INameMappingService.Domain, String, String>> getNameFunction(final String naming) {
|
||||||
|
return Launcher.INSTANCE.environment().findNameMapping(naming);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLauncherInfo() {
|
||||||
|
return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MLIMPL_VERSION.get()).orElse("MISSING");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Map<String, String>> modLauncherModList() {
|
||||||
|
return Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MODLIST.get()).orElseGet(Collections::emptyList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String launcherHandlerName() {
|
||||||
|
return launchHandlerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProduction() {
|
||||||
|
return production;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSecureJarEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModuleLayer getGameLayer() {
|
||||||
|
return moduleLayerManager.getLayer(IModuleLayerManager.Layer.GAME).orElseThrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VersionInfo versionInfo() {
|
||||||
|
return versionInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-10
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minecraft Forge
|
* Minecraft Forge
|
||||||
* Copyright (c) 2016-2018.
|
* Copyright (c) 2016-2021.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -20,17 +20,14 @@
|
|||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.IEnvironment;
|
import cpw.mods.modlauncher.api.IEnvironment;
|
||||||
import net.minecraftforge.fml.FileUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static net.minecraftforge.fml.Logging.CORE;
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
public enum FMLPaths
|
public enum FMLPaths
|
||||||
{
|
{
|
||||||
@@ -53,16 +50,16 @@ public enum FMLPaths
|
|||||||
this.isDirectory = true;
|
this.isDirectory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path computePath(String... path)
|
|
||||||
{
|
|
||||||
return Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
FMLPaths(boolean isDir, FMLPaths parent, String... path) {
|
FMLPaths(boolean isDir, FMLPaths parent, String... path) {
|
||||||
this.relativePath = parent.relativePath.resolve(computePath(path));
|
this.relativePath = parent.relativePath.resolve(computePath(path));
|
||||||
this.isDirectory = isDir;
|
this.isDirectory = isDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Path computePath(String... path)
|
||||||
|
{
|
||||||
|
return Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length));
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup(IEnvironment env) {
|
public static void setup(IEnvironment env) {
|
||||||
final Path rootPath = env.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElseThrow(() -> new RuntimeException("No game path found"));
|
final Path rootPath = env.getProperty(IEnvironment.Keys.GAMEDIR.get()).orElseThrow(() -> new RuntimeException("No game path found"));
|
||||||
|
|
||||||
@@ -82,6 +79,14 @@ public enum FMLPaths
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Path getOrCreateGameRelativePath(Path path, String name) {
|
||||||
|
return FileUtils.getOrCreateDirectory(FMLPaths.GAMEDIR.get().resolve(path), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path relative() {
|
||||||
|
return relativePath;
|
||||||
|
}
|
||||||
|
|
||||||
public Path get() {
|
public Path get() {
|
||||||
return absolutePath;
|
return absolutePath;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.*;
|
||||||
|
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||||
|
import joptsimple.OptionSpecBuilder;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.forgespi.Environment;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
|
public class FMLServiceProvider implements ITransformationService
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private ArgumentAcceptingOptionSpec<String> modsOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> modListsOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> mavenRootsOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> forgeOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> mcOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> forgeGroupOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> mcpOption;
|
||||||
|
private ArgumentAcceptingOptionSpec<String> mappingsOption;
|
||||||
|
private List<String> modsArgumentList;
|
||||||
|
private List<String> modListsArgumentList;
|
||||||
|
private List<String> mavenRootsArgumentList;
|
||||||
|
private String targetForgeVersion;
|
||||||
|
private String targetMcVersion;
|
||||||
|
private String targetMcpVersion;
|
||||||
|
private String targetMcpMappings;
|
||||||
|
private String targetForgeGroup;
|
||||||
|
private Map<String, Object> arguments;
|
||||||
|
|
||||||
|
public FMLServiceProvider()
|
||||||
|
{
|
||||||
|
final String markerselection = System.getProperty("forge.logging.markers", "");
|
||||||
|
Arrays.stream(markerselection.split(",")).forEach(marker -> System.setProperty("forge.logging.marker." + marker.toLowerCase(Locale.ROOT), "ACCEPT"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "fml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(IEnvironment environment) {
|
||||||
|
LOGGER.debug(CORE, "Setting up basic FML game directories");
|
||||||
|
FMLPaths.setup(environment);
|
||||||
|
LOGGER.debug(CORE, "Loading configuration");
|
||||||
|
FMLConfig.load();
|
||||||
|
LOGGER.debug(CORE, "Preparing ModFile");
|
||||||
|
environment.computePropertyIfAbsent(Environment.Keys.MODFILEFACTORY.get(), k->ModFile.buildFactory());
|
||||||
|
arguments = new HashMap<>();
|
||||||
|
arguments.put("modLists", modListsArgumentList);
|
||||||
|
arguments.put("mods", modsArgumentList);
|
||||||
|
arguments.put("mavenRoots", mavenRootsArgumentList);
|
||||||
|
arguments.put("forgeVersion", targetForgeVersion);
|
||||||
|
arguments.put("forgeGroup", targetForgeGroup);
|
||||||
|
arguments.put("mcVersion", targetMcVersion);
|
||||||
|
arguments.put("mcpVersion", targetMcpVersion);
|
||||||
|
arguments.put("mcpMappings", targetMcpMappings);
|
||||||
|
LOGGER.debug(CORE, "Preparing launch handler");
|
||||||
|
FMLLoader.setupLaunchHandler(environment, arguments);
|
||||||
|
FMLEnvironment.setupInteropEnvironment(environment);
|
||||||
|
Environment.build(environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Resource> beginScanning(final IEnvironment environment) {
|
||||||
|
LOGGER.debug(CORE,"Initiating mod scan");
|
||||||
|
return FMLLoader.beginModScan(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Resource> completeScan(final IModuleLayerManager layerManager) {
|
||||||
|
return FMLLoader.completeScan(layerManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad(IEnvironment environment, Set<String> otherServices) throws IncompatibleEnvironmentException
|
||||||
|
{
|
||||||
|
// LOGGER.debug("Injecting tracing printstreams for STDOUT/STDERR.");
|
||||||
|
// System.setOut(new TracingPrintStream(LogManager.getLogger("STDOUT"), System.out));
|
||||||
|
// System.setErr(new TracingPrintStream(LogManager.getLogger("STDERR"), System.err));
|
||||||
|
FMLLoader.onInitialLoad(environment, otherServices);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void arguments(BiFunction<String, String, OptionSpecBuilder> argumentBuilder)
|
||||||
|
{
|
||||||
|
forgeOption = argumentBuilder.apply("forgeVersion", "Forge Version number").withRequiredArg().ofType(String.class).required();
|
||||||
|
forgeGroupOption = argumentBuilder.apply("forgeGroup", "Forge Group (for testing)").withRequiredArg().ofType(String.class).defaultsTo("net.minecraftforge");
|
||||||
|
mcOption = argumentBuilder.apply("mcVersion", "Minecraft Version number").withRequiredArg().ofType(String.class).required();
|
||||||
|
mcpOption = argumentBuilder.apply("mcpVersion", "MCP Version number").withRequiredArg().ofType(String.class).required();
|
||||||
|
mappingsOption = argumentBuilder.apply("mcpMappings", "MCP Mappings Channel and Version").withRequiredArg().ofType(String.class);
|
||||||
|
modsOption = argumentBuilder.apply("mods", "List of mods to add").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",");
|
||||||
|
modListsOption = argumentBuilder.apply("modLists", "JSON modlists").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",");
|
||||||
|
mavenRootsOption = argumentBuilder.apply("mavenRoots", "Maven root directories").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void argumentValues(OptionResult option)
|
||||||
|
{
|
||||||
|
modsArgumentList = option.values(modsOption);
|
||||||
|
modListsArgumentList = option.values(modListsOption);
|
||||||
|
mavenRootsArgumentList = option.values(mavenRootsOption);
|
||||||
|
targetForgeVersion = option.value(forgeOption);
|
||||||
|
targetForgeGroup = option.value(forgeGroupOption);
|
||||||
|
targetMcVersion = option.value(mcOption);
|
||||||
|
targetMcpVersion = option.value(mcpOption);
|
||||||
|
targetMcpMappings = option.value(mappingsOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<ITransformer> transformers()
|
||||||
|
{
|
||||||
|
LOGGER.debug(CORE, "Loading coremod transformers");
|
||||||
|
return new ArrayList<>(FMLLoader.getCoreModProvider().getCoreModTransformers());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
|
public class FileUtils
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
|
||||||
|
if (!Files.isDirectory(dirPath.getParent())) {
|
||||||
|
getOrCreateDirectory(dirPath.getParent(), "parent of "+dirLabel);
|
||||||
|
}
|
||||||
|
if (!Files.isDirectory(dirPath))
|
||||||
|
{
|
||||||
|
LOGGER.debug(CORE,"Making {} directory : {}", dirLabel, dirPath);
|
||||||
|
try {
|
||||||
|
Files.createDirectory(dirPath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (e instanceof FileAlreadyExistsException) {
|
||||||
|
LOGGER.fatal(CORE,"Failed to create {} directory - there is a file in the way", dirLabel);
|
||||||
|
} else {
|
||||||
|
LOGGER.fatal(CORE,"Problem with creating {} directory (Permissions?)", dirLabel, e);
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Problem creating directory", e);
|
||||||
|
}
|
||||||
|
LOGGER.debug(CORE,"Created {} directory : {}", dirLabel, dirPath);
|
||||||
|
} else {
|
||||||
|
LOGGER.debug(CORE,"Found existing {} directory : {}", dirLabel, dirPath);
|
||||||
|
}
|
||||||
|
return dirPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String fileExtension(final Path path) {
|
||||||
|
String fileName = path.getFileName().toString();
|
||||||
|
int idx = fileName.lastIndexOf('.');
|
||||||
|
if (idx > -1) {
|
||||||
|
return fileName.substring(idx+1);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds Version data from a package, with possible default values
|
||||||
|
*/
|
||||||
|
public class JarVersionLookupHandler {
|
||||||
|
public static Optional<String> getImplementationVersion(final String pkgName) {
|
||||||
|
// Note that with Java 9, you'll probably want the module's version data, hence pulling this out
|
||||||
|
final String pkgVersion = Package.getPackage(pkgName).getImplementationVersion();
|
||||||
|
return Optional.ofNullable(pkgVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<String> getSpecificationVersion(final String pkgName) {
|
||||||
|
// Note that with Java 9, you'll probably want the module's version data, hence pulling this out
|
||||||
|
final String pkgVersion = Package.getPackage(pkgName).getSpecificationVersion();
|
||||||
|
return Optional.ofNullable(pkgVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<String> getImplementationVersion(final Class<?> clazz) {
|
||||||
|
// With java 9 we'll use the module's version if it exists in preference.
|
||||||
|
final String pkgVersion = clazz.getPackage().getImplementationVersion();
|
||||||
|
return Optional.ofNullable(pkgVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<String> getImplementationTitle(final Class<?> clazz) {
|
||||||
|
// With java 9 we'll use the module's version if it exists in preference.
|
||||||
|
final String pkgVersion = clazz.getPackage().getImplementationTitle();
|
||||||
|
return Optional.ofNullable(pkgVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Optional<String> getSpecificationVersion(final Class<?> clazz) {
|
||||||
|
// With java 9 we'll use the module's version if it exists in preference.
|
||||||
|
final String pkgVersion = clazz.getPackage().getSpecificationVersion();
|
||||||
|
return Optional.ofNullable(pkgVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.Launcher;
|
||||||
|
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
||||||
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
||||||
|
|
||||||
|
public class LanguageLoadingProvider
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private final List<IModLanguageProvider> languageProviders = new ArrayList<>();
|
||||||
|
private final ServiceLoader<IModLanguageProvider> serviceLoader;
|
||||||
|
private final Map<String, ModLanguageWrapper> languageProviderMap = new HashMap<>();
|
||||||
|
private List<Path> languagePaths = new ArrayList<>();
|
||||||
|
|
||||||
|
public void forEach(final Consumer<IModLanguageProvider> consumer)
|
||||||
|
{
|
||||||
|
languageProviders.forEach(consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Stream<T> applyForEach(final Function<IModLanguageProvider, T> function) {
|
||||||
|
return languageProviders.stream().map(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ModLanguageWrapper {
|
||||||
|
private final IModLanguageProvider modLanguageProvider;
|
||||||
|
|
||||||
|
private final ArtifactVersion version;
|
||||||
|
public ModLanguageWrapper(IModLanguageProvider modLanguageProvider, ArtifactVersion version)
|
||||||
|
{
|
||||||
|
this.modLanguageProvider = modLanguageProvider;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
public ArtifactVersion getVersion()
|
||||||
|
{
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModLanguageProvider getModLanguageProvider()
|
||||||
|
{
|
||||||
|
return modLanguageProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LanguageLoadingProvider() {
|
||||||
|
var sl = Launcher.INSTANCE.environment().findModuleLayerManager().flatMap(lm->lm.getLayer(IModuleLayerManager.Layer.PLUGIN)).orElseThrow();
|
||||||
|
serviceLoader = ServiceLoader.load(sl, IModLanguageProvider.class);
|
||||||
|
loadLanguageProviders();
|
||||||
|
}
|
||||||
|
private void loadLanguageProviders() {
|
||||||
|
LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.fatal("Problem with language loaders")).count());
|
||||||
|
serviceLoader.forEach(languageProviders::add);
|
||||||
|
|
||||||
|
languageProviders.forEach(lp -> {
|
||||||
|
final Path lpPath;
|
||||||
|
try {
|
||||||
|
lpPath = Paths.get(lp.getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new RuntimeException("Huh?", e);
|
||||||
|
}
|
||||||
|
Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass());
|
||||||
|
String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null);
|
||||||
|
if (impl == null) {
|
||||||
|
LOGGER.fatal(CORE, "Found unversioned language provider {}", lp.name());
|
||||||
|
throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name());
|
||||||
|
}
|
||||||
|
LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl);
|
||||||
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Loaded language provider "+lp.name()+ " " + impl));
|
||||||
|
languageProviderMap.put(lp.name(), new ModLanguageWrapper(lp, new DefaultArtifactVersion(impl)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void addForgeLanguage(final Path forgePath) {
|
||||||
|
if (!languageProviderMap.containsKey("javafml")) {
|
||||||
|
LOGGER.debug(CORE,"Adding forge as a language from {}", forgePath.toString());
|
||||||
|
addLanguagePaths(Stream.of(forgePath));
|
||||||
|
serviceLoader.reload();
|
||||||
|
loadLanguageProviders();
|
||||||
|
} else {
|
||||||
|
LOGGER.debug(CORE, "Skipping adding forge jar - javafml is already present");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addLanguagePaths(final Stream<Path> langPaths) {
|
||||||
|
languageProviders.clear();
|
||||||
|
languageProviderMap.clear();
|
||||||
|
// langPaths.peek(languagePaths::add).map(Path::toFile).map(File::toURI).map(rethrowFunction(URI::toURL)).forEach(languageClassLoader::addURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdditionalLanguages(List<ModFile> modFiles)
|
||||||
|
{
|
||||||
|
if (modFiles==null) return;
|
||||||
|
Stream<Path> langPaths = modFiles.stream().map(ModFile::getFilePath);
|
||||||
|
addLanguagePaths(langPaths);
|
||||||
|
serviceLoader.reload();
|
||||||
|
loadLanguageProviders();
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<Path> getLibraries() {
|
||||||
|
return languagePaths.stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModLanguageProvider findLanguage(ModFile mf, String modLoader, VersionRange modLoaderVersion) {
|
||||||
|
final String languageFileName = mf.getLocator() instanceof ExplodedDirectoryLocator ? "in-development" : mf.getFileName();
|
||||||
|
final ModLanguageWrapper mlw = languageProviderMap.get(modLoader);
|
||||||
|
if (mlw == null) {
|
||||||
|
LOGGER.error(LOADING,"Missing language {} version {} wanted by {}", modLoader, modLoaderVersion, languageFileName);
|
||||||
|
throw new EarlyLoadingException("Missing language "+modLoader, null, Collections.singletonList(new EarlyLoadingException.ExceptionData("fml.language.missingversion", modLoader, modLoaderVersion, languageFileName, "null")));
|
||||||
|
}
|
||||||
|
if (!VersionSupportMatrix.testVersionSupportMatrix(modLoaderVersion, modLoader, "languageloader", (llid, range) -> range.containsVersion(mlw.getVersion()))) {
|
||||||
|
LOGGER.error(LOADING,"Missing language {} version {} wanted by {}, found {}", modLoader, modLoaderVersion, languageFileName, mlw.getVersion());
|
||||||
|
throw new EarlyLoadingException("Missing language "+ modLoader + " matching range "+modLoaderVersion + " found "+mlw.getVersion(), null, Collections.singletonList(new EarlyLoadingException.ExceptionData("fml.language.missingversion", modLoader, modLoaderVersion, languageFileName, mlw.getVersion())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mlw.getModLanguageProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
|
public class LauncherVersion {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static final String launcherVersion;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String vers = JarVersionLookupHandler.getImplementationVersion(LauncherVersion.class).orElse(System.getenv("LAUNCHER_VERSION"));
|
||||||
|
if (vers == null) throw new RuntimeException("Missing FMLLauncher version, cannot continue");
|
||||||
|
launcherVersion = vers;
|
||||||
|
LOGGER.debug(CORE, "Found FMLLauncher version {}", launcherVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersion()
|
||||||
|
{
|
||||||
|
return launcherVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Minecraft Forge
|
||||||
|
* Copyright (c) 2016-2021.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
|
public class LibraryFinder {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static Path libsPath;
|
||||||
|
static Path findLibsPath() {
|
||||||
|
if (libsPath == null) {
|
||||||
|
libsPath = Path.of(System.getProperty("libraryDirectory","crazysnowmannonsense/cheezwhizz"));
|
||||||
|
if (!Files.isDirectory(libsPath)) {
|
||||||
|
throw new IllegalStateException("Missing libraryDirectory system property, cannot continue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return libsPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not used anywhere in Forge's codebase, scheduled for deletion unless a good need is expressed.
|
||||||
|
@Deprecated(forRemoval = true, since = "1.17.1")
|
||||||
|
public static Path findJarPathFor(final String className, final String jarName) {
|
||||||
|
final URL resource = LibraryFinder.class.getClassLoader().getResource(className);
|
||||||
|
return findJarPathFor(className, jarName, resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only used in ClasspathLocator now, so moved too a private method and depreciated this.
|
||||||
|
* Scheduled for deletion unless a good need is expressed.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "1.17.1")
|
||||||
|
public static Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
||||||
|
try {
|
||||||
|
Path path;
|
||||||
|
final URI uri = resource.toURI();
|
||||||
|
if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) {
|
||||||
|
int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/");
|
||||||
|
path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl)));
|
||||||
|
} else {
|
||||||
|
path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length())));
|
||||||
|
}
|
||||||
|
LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
||||||
|
return path;
|
||||||
|
} catch (NullPointerException | URISyntaxException e) {
|
||||||
|
LOGGER.fatal(CORE, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
||||||
|
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Path getForgeLibraryPath(final String mcVersion, final String forgeVersion, final String forgeGroup) {
|
||||||
|
Path forgePath = findLibsPath().resolve(MavenCoordinateResolver.get(forgeGroup, "forge", "", "universal", mcVersion+"-"+forgeVersion));
|
||||||
|
LOGGER.debug(CORE, "Found forge path {} is {}", forgePath, pathStatus(forgePath));
|
||||||
|
return forgePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String pathStatus(final Path path) {
|
||||||
|
return Files.exists(path) ? "present" : "missing";
|
||||||
|
}
|
||||||
|
|
||||||
|
static Path[] getMCPaths(final String mcVersion, final String mcpVersion, final String forgeVersion, final String forgeGroup, final String type) {
|
||||||
|
Path srgMcPath = findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraft", type, "", "srg", mcVersion+"-"+mcpVersion));
|
||||||
|
Path mcExtrasPath = findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraft", type, "", "extra", mcVersion+"-"+mcpVersion));
|
||||||
|
Path patchedBinariesPath = findLibsPath().resolve(MavenCoordinateResolver.get(forgeGroup, "forge", "", type, mcVersion+"-"+forgeVersion));
|
||||||
|
LOGGER.debug(CORE,"SRG MC at {} is {}", srgMcPath.toString(), pathStatus(srgMcPath));
|
||||||
|
LOGGER.debug(CORE,"MC Extras at {} is {}", mcExtrasPath.toString(), pathStatus(mcExtrasPath));
|
||||||
|
LOGGER.debug(CORE,"Forge patches at {} is {}", patchedBinariesPath.toString(), pathStatus(patchedBinariesPath));
|
||||||
|
return new Path[] { patchedBinariesPath, mcExtrasPath, srgMcPath };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path findPathForMaven(final String group, final String artifact, final String extension, final String classifier, final String version) {
|
||||||
|
return findLibsPath().resolve(MavenCoordinateResolver.get(group, artifact, extension, classifier, version));
|
||||||
|
}
|
||||||
|
public static Path findPathForMaven(final String maven) {
|
||||||
|
return findLibsPath().resolve(MavenCoordinateResolver.get(maven));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 2800 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user