Compare commits
756 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33080a4e1c | ||
|
|
dae6cc8e20 | ||
|
|
a2159d62e5 | ||
|
|
a092a0ba94 | ||
|
|
33faf5c9b0 | ||
|
|
d927207b67 | ||
|
|
b9f0da7d27 | ||
|
|
1c36bf3300 | ||
|
|
cca137d526 | ||
|
|
24da012903 | ||
|
|
0eb7a5aed6 | ||
|
|
5cbf1eef5f | ||
|
|
ed4fba330d | ||
|
|
9046eb500b | ||
|
|
011b7427e2 | ||
|
|
13caaf6fa7 | ||
|
|
a98677dbda | ||
|
|
6c1f0d3711 | ||
|
|
e1e6a08eb2 | ||
|
|
7b21b0401d | ||
|
|
4c935fc447 | ||
|
|
3d221dcda4 | ||
|
|
ac6c413fb8 | ||
|
|
17a07ba85e | ||
|
|
ca6f7003a5 | ||
|
|
d402ba61cc | ||
|
|
081fae98c4 | ||
|
|
014d3b3a99 | ||
|
|
19fe29ad1e | ||
|
|
8bcbd0231e | ||
|
|
01c0e321b5 | ||
|
|
5f721b544e | ||
|
|
57d4a79496 | ||
|
|
9541a45451 | ||
|
|
bba4c09195 | ||
|
|
06c62029c5 | ||
|
|
6f251b64f1 | ||
|
|
551b6b88d2 | ||
|
|
07cbc47fb2 | ||
|
|
fe6ca97f21 | ||
|
|
1b481c6765 | ||
|
|
1c5e0b4d68 | ||
|
|
bc849daccb | ||
|
|
f5b4de023f | ||
|
|
6dc7a7788e | ||
|
|
0e51a73149 | ||
|
|
44a092cd94 | ||
|
|
7000b6cda2 | ||
|
|
7a17f7d253 | ||
|
|
821e73c1d3 | ||
|
|
784bc52d6d | ||
|
|
4338e34734 | ||
|
|
61147536e5 | ||
|
|
6b9737eb3f | ||
|
|
fe54372a53 | ||
|
|
21e9c0b7c1 | ||
|
|
8bf977060e | ||
|
|
074ec333cf | ||
|
|
d505ec4f9f | ||
|
|
4d127acb9a | ||
|
|
df900c9e64 | ||
|
|
93a090c56e | ||
|
|
8b43d93259 | ||
|
|
053662d0af | ||
|
|
af943a8253 | ||
|
|
8151444671 | ||
|
|
f32147d9d5 | ||
|
|
515e0364f7 | ||
|
|
09239f8180 | ||
|
|
0d9f233e33 | ||
|
|
e034437c63 | ||
|
|
72be046f34 | ||
|
|
3ba8824eb0 | ||
|
|
b51a261bd1 | ||
|
|
38602dd141 | ||
|
|
cdbec60da0 | ||
|
|
2b41012c5b | ||
|
|
6bb87d0a64 | ||
|
|
b16f9edd2c | ||
|
|
ce4b1e09ed | ||
|
|
01658286af | ||
|
|
aa90c8b7cd | ||
|
|
eba1011fd6 | ||
|
|
96a424c25a | ||
|
|
f4dd100345 | ||
|
|
cd4205c361 | ||
|
|
b81bcf8c6d | ||
|
|
4259764b70 | ||
|
|
8f761f7dff | ||
|
|
cbbaf2aa2f | ||
|
|
dd9b84646a | ||
|
|
94131fd705 | ||
|
|
6d8914e6c9 | ||
|
|
63ee687cee | ||
|
|
ab779dc850 | ||
|
|
c2f35ae46f | ||
|
|
199e0e5ed3 | ||
|
|
a8155b4b0b | ||
|
|
fdd78cf110 | ||
|
|
afff6395d1 | ||
|
|
4d3d48e962 | ||
|
|
36290e4e53 | ||
|
|
fd6923dd28 | ||
|
|
9c64067d49 | ||
|
|
f4d2ea7923 | ||
|
|
ce3d3bb244 | ||
|
|
fa71e7d84f | ||
|
|
b0115b8b4c | ||
|
|
3902b2db3b | ||
|
|
4ff61f96df | ||
|
|
f998dce614 | ||
|
|
2b9084d2f3 | ||
|
|
b3605546ac | ||
|
|
96097ab726 | ||
|
|
be142d79bc | ||
|
|
0fd241a9ba | ||
|
|
7b192f17e8 | ||
|
|
cc015846d2 | ||
|
|
e785bd13f5 | ||
|
|
eb6c0a39ea | ||
|
|
86525f98ec | ||
|
|
94bf703dde | ||
|
|
14bb0a0a80 | ||
|
|
1ee6e04f00 | ||
|
|
ee6796d5e2 | ||
|
|
81d7f3c319 | ||
|
|
9822962d98 | ||
|
|
ce606f826b | ||
|
|
4c4bc8058b | ||
|
|
f0210f7c5f | ||
|
|
aef84eceb8 | ||
|
|
a6ea9ed3a6 | ||
|
|
0815e3c195 | ||
|
|
a1c03eb601 | ||
|
|
1e43563cc3 | ||
|
|
63f3f9123a | ||
|
|
4860d3bd18 | ||
|
|
7fa6593bdc | ||
|
|
e1dd580df8 | ||
|
|
f19e63d6e9 | ||
|
|
130873d91d | ||
|
|
9611cb9057 | ||
|
|
023aa78d8b | ||
|
|
39a231eae0 | ||
|
|
aca6922be0 | ||
|
|
1a52537d0c | ||
|
|
479b4e3349 | ||
|
|
a1e2b018a2 | ||
|
|
aa0f664cda | ||
|
|
2e2f4aee1b | ||
|
|
18474d872c | ||
|
|
44327c009a | ||
|
|
de554655a5 | ||
|
|
bd0c7b9391 | ||
|
|
8d32db5206 | ||
|
|
a6954aa719 | ||
|
|
b4d203ab99 | ||
|
|
bb924ad83f | ||
|
|
79da32cc60 | ||
|
|
c7fe9c3171 | ||
|
|
d70da4f37d | ||
|
|
ccc1b04e81 | ||
|
|
352e428890 | ||
|
|
4679e12588 | ||
|
|
6861bfd4e6 | ||
|
|
0dd4834e18 | ||
|
|
da58988f01 | ||
|
|
b2f3880722 | ||
|
|
0293a76702 | ||
|
|
6a13e94c4f | ||
|
|
79d448e5f4 | ||
|
|
264b3db63c | ||
|
|
c8cd4b5f28 | ||
|
|
c9e81897a5 | ||
|
|
c738007538 | ||
|
|
da8bf6b1b3 | ||
|
|
1501d721e7 | ||
|
|
482d874af2 | ||
|
|
7dcd7384f1 | ||
|
|
2a5ef35794 | ||
|
|
0f09a46540 | ||
|
|
a6d4708ccf | ||
|
|
77303b4a62 | ||
|
|
0ffbb0c151 | ||
|
|
e05010c9d2 | ||
|
|
d0a1c241a4 | ||
|
|
4ea8f23fc7 | ||
|
|
54da0d24a3 | ||
|
|
58ebd5f9a6 | ||
|
|
d60a0bee9e | ||
|
|
e9e26c981a | ||
|
|
5f12f04e87 | ||
|
|
7b7be32ca7 | ||
|
|
a14166b1e2 | ||
|
|
166eb97c3f | ||
|
|
920ce745c2 | ||
|
|
c931cde3ae | ||
|
|
f7a577e163 | ||
|
|
9bf3a041d4 | ||
|
|
85eb7d8043 | ||
|
|
b338dcc9de | ||
|
|
7d9b8ee4f3 | ||
|
|
0f61aaafb8 | ||
|
|
0927e0e017 | ||
|
|
783a7cedc3 | ||
|
|
b1ee23ad50 | ||
|
|
9118e0b368 | ||
|
|
5a0ccac0a1 | ||
|
|
c8419dc362 | ||
|
|
9127ba2fce | ||
|
|
36858ca219 | ||
|
|
30469e2de2 | ||
|
|
79c433b14d | ||
|
|
bc419cfd1a | ||
|
|
09fbf675ec | ||
|
|
2ee119fc64 | ||
|
|
83265fcb54 | ||
|
|
e8b4f4d2b6 | ||
|
|
714c6773c3 | ||
|
|
2fac594315 | ||
|
|
4bec49de5b | ||
|
|
4eaa6e20c3 | ||
|
|
315cc26525 | ||
|
|
794a761243 | ||
|
|
5da14fcb3f | ||
|
|
1047d4ade9 | ||
|
|
0b8fa3ffe3 | ||
|
|
498e4e2d6c | ||
|
|
850c414e8f | ||
|
|
d5a8ed5cb1 | ||
|
|
dd8406c39a | ||
|
|
13469053b9 | ||
|
|
c4c85b4f49 | ||
|
|
af0c3bbd5c | ||
|
|
2fcf9ace64 | ||
|
|
47e1c67bd8 | ||
|
|
7e3aa6efdd | ||
|
|
7a2f26ef62 | ||
|
|
b64154e3b3 | ||
|
|
26256e7155 | ||
|
|
6599736e00 | ||
|
|
343bb20bd8 | ||
|
|
518fa1c74d | ||
|
|
0b72a8b4b3 | ||
|
|
c013d1e0d9 | ||
|
|
fe51220e3c | ||
|
|
44d757347b | ||
|
|
c136182e17 | ||
|
|
a1a9b4e6b9 | ||
|
|
f49df63183 | ||
|
|
96414b37f3 | ||
|
|
544168ff45 | ||
|
|
e0a618a791 | ||
|
|
3333797144 | ||
|
|
f7f003c0f9 | ||
|
|
236d02cb47 | ||
|
|
6e97fe2210 | ||
|
|
6741666c24 | ||
|
|
fcadf68c90 | ||
|
|
65cd6a92d3 | ||
|
|
a09bb0d538 | ||
|
|
2bf475d840 | ||
|
|
76cdaaace6 | ||
|
|
ce59ef559f | ||
|
|
fc3f183dce | ||
|
|
6b6eea2d8c | ||
|
|
e54652941b | ||
|
|
867c01ff86 | ||
|
|
87a9e67ba8 | ||
|
|
bf076f6246 | ||
|
|
75b54dfaec | ||
|
|
71a2219b07 | ||
|
|
ccc3de2d7c | ||
|
|
af11e64cec | ||
|
|
2c3dc5d6b1 | ||
|
|
71482cc984 | ||
|
|
3329db1dae | ||
|
|
926e2d5620 | ||
|
|
d2de8828e7 | ||
|
|
9fcae6560e | ||
|
|
2e8fdd43ee | ||
|
|
27e39c8083 | ||
|
|
a8f373d568 | ||
|
|
71491a7922 | ||
|
|
170c2d35c2 | ||
|
|
bc49b2d5ba | ||
|
|
f58b6b41cb | ||
|
|
ac1ac50158 | ||
|
|
d4103a924d | ||
|
|
bd64f73842 | ||
|
|
cac653ddd9 | ||
|
|
04ff365890 | ||
|
|
54ed6ce5a5 | ||
|
|
32ac46c8a9 | ||
|
|
7ab2cd2a45 | ||
|
|
a07fae6cdd | ||
|
|
3f6af51713 | ||
|
|
8c4e778506 | ||
|
|
65902d556e | ||
|
|
aada9731a6 | ||
|
|
49658078b9 | ||
|
|
bcd097c6cb | ||
|
|
cfec67f1f9 | ||
|
|
aaaf0f8839 | ||
|
|
ee83471bf6 | ||
|
|
610fe6439f | ||
|
|
bd1dcff385 | ||
|
|
226ede7ba2 | ||
|
|
89fb5cecd5 | ||
|
|
a75317cc2c | ||
|
|
ee6df270ce | ||
|
|
e09541151f | ||
|
|
74e0552be0 | ||
|
|
909ab553eb | ||
|
|
866408aece | ||
|
|
2215f170df | ||
|
|
a5601fd89a | ||
|
|
fa8f2632f5 | ||
|
|
52d8d271f1 | ||
|
|
b240e8420a | ||
|
|
25024b58de | ||
|
|
ba31d209c9 | ||
|
|
7974d9135b | ||
|
|
a5a795a22c | ||
|
|
416b5b66d2 | ||
|
|
88e41f37b1 | ||
|
|
7cfa837604 | ||
|
|
6b7aca3081 | ||
|
|
580af2ab06 | ||
|
|
d144d30890 | ||
|
|
ecac546c6d | ||
|
|
76297e8176 | ||
|
|
d90f391b5e | ||
|
|
d80ae57964 | ||
|
|
74d7483b3c | ||
|
|
b3c580e657 | ||
|
|
8050b69f2f | ||
|
|
459720c348 | ||
|
|
a73f5c1359 | ||
|
|
71cb0f6d36 | ||
|
|
0d15225b1d | ||
|
|
826f3788d0 | ||
|
|
2133ab39b7 | ||
|
|
558c14a375 | ||
|
|
882ac41291 | ||
|
|
66c7a3f513 | ||
|
|
5904441a7e | ||
|
|
c465228531 | ||
|
|
81b22019dd | ||
|
|
3e47d485f9 | ||
|
|
701bc772a8 | ||
|
|
3ae05b7348 | ||
|
|
2e186019f5 | ||
|
|
4c6f321cff | ||
|
|
c72eb3e195 | ||
|
|
a4237bf1f9 | ||
|
|
e767e34b92 | ||
|
|
8ac82ebe2a | ||
|
|
0ed6ccab71 | ||
|
|
bf25d7328e | ||
|
|
a47b0c0581 | ||
|
|
596849c7e6 | ||
|
|
76914b7859 | ||
|
|
3dbbe053d7 | ||
|
|
c474cdb1f8 | ||
|
|
3de02cbf21 | ||
|
|
26fefc70f0 | ||
|
|
4086c9f4b5 | ||
|
|
c947c77853 | ||
|
|
9be44c0371 | ||
|
|
5412fa6cfd | ||
|
|
6e7320b954 | ||
|
|
fbb2d37634 | ||
|
|
7afe16fc10 | ||
|
|
b19f241d81 | ||
|
|
583ce80003 | ||
|
|
195c33407e | ||
|
|
600c5b77ad | ||
|
|
f1084fab76 | ||
|
|
bd65e32407 | ||
|
|
e4416f424a | ||
|
|
73ec110b22 | ||
|
|
0bce801a3f | ||
|
|
e8e00e8dfb | ||
|
|
cc4335e48e | ||
|
|
5427911da3 | ||
|
|
c808d5a42d | ||
|
|
3b46dbd6a1 | ||
|
|
e63b2f1bf1 | ||
|
|
d32e822057 | ||
|
|
2b672998e1 | ||
|
|
e18dc7c7e7 | ||
|
|
16dcd2f44d | ||
|
|
eb9f755b54 | ||
|
|
29a9e6e1d1 | ||
|
|
1f52f706ed | ||
|
|
bf12763a10 | ||
|
|
963641a818 | ||
|
|
3e94d92fbd | ||
|
|
a72040f83d | ||
|
|
84d8f826ff | ||
|
|
70d216b29f | ||
|
|
66356d5334 | ||
|
|
d9625dfe78 | ||
|
|
6d847577d8 | ||
|
|
8fd687f9d7 | ||
|
|
f7a9380b9d | ||
|
|
5617c595b2 | ||
|
|
8770524679 | ||
|
|
a8ddb2fcf1 | ||
|
|
76c4ca9ba6 | ||
|
|
ed2b0f0bb9 | ||
|
|
6702b44b3e | ||
|
|
c486d8241e | ||
|
|
d2bb8c374e | ||
|
|
530cecea5b | ||
|
|
266e2dada9 | ||
|
|
ce73d34627 | ||
|
|
11af0a7aac | ||
|
|
46c2d8f7c7 | ||
|
|
38127011fb | ||
|
|
89b5ce4b63 | ||
|
|
4fe9c180d5 | ||
|
|
f094e83e4d | ||
|
|
5b6c9fc348 | ||
|
|
3f1ee100bf | ||
|
|
41b1106c72 | ||
|
|
b27d95a615 | ||
|
|
5b8a83853d | ||
|
|
d0548b2715 | ||
|
|
bffeb9c862 | ||
|
|
dbd760fbcb | ||
|
|
a84b3bfc7a | ||
|
|
e8d3bf509c | ||
|
|
b2583773d5 | ||
|
|
9ecd24c755 | ||
|
|
f1bacd6210 | ||
|
|
a21ec54d4f | ||
|
|
0b4efb24ae | ||
|
|
c473914d05 | ||
|
|
90a1fa8337 | ||
|
|
99cb7f5142 | ||
|
|
4026b850f8 | ||
|
|
aac7ebf6dd | ||
|
|
8d481ba394 | ||
|
|
24fa75c24e | ||
|
|
cf38d593b8 | ||
|
|
36f608c63c | ||
|
|
1d88564a72 | ||
|
|
503f2fb197 | ||
|
|
bb000c4e3f | ||
|
|
4868ed7560 | ||
|
|
7017e9e2ea | ||
|
|
a18eb90702 | ||
|
|
9d1d4fe0d9 | ||
|
|
1a430dc2cf | ||
|
|
e37a09a1c8 | ||
|
|
d0d8b12fb8 | ||
|
|
9a29f9ce57 | ||
|
|
42513e4b56 | ||
|
|
67fa91abe8 | ||
|
|
d8348ad292 | ||
|
|
6faa7344aa | ||
|
|
299540725e | ||
|
|
0ef08142fd | ||
|
|
c0761c0eef | ||
|
|
8694d926c4 | ||
|
|
46f8829951 | ||
|
|
4c4bce3561 | ||
|
|
68e8717b5c | ||
|
|
b484e6fa3f | ||
|
|
aa8773a67e | ||
|
|
a822d3ef05 | ||
|
|
311cf81e8a | ||
|
|
bf9ee918f3 | ||
|
|
92ba76e7a1 | ||
|
|
3326339263 | ||
|
|
52cafbc7aa | ||
|
|
efb316de14 | ||
|
|
3cf944398f | ||
|
|
d2bfd47039 | ||
|
|
920cb6556b | ||
|
|
cd3ae2a7f5 | ||
|
|
b12fedb2d9 | ||
|
|
1cae7ad6b1 | ||
|
|
7dd881aa9a | ||
|
|
c7ad235110 | ||
|
|
a989547976 | ||
|
|
fa75880626 | ||
|
|
529895f970 | ||
|
|
3d5de440fd | ||
|
|
568bb1b0e8 | ||
|
|
b9ae8306dd | ||
|
|
4aededff46 | ||
|
|
ed8f9863e3 | ||
|
|
e85de55c8f | ||
|
|
adbf927270 | ||
|
|
dfe171a5c2 | ||
|
|
b55e449398 | ||
|
|
62b11c0a8a | ||
|
|
90cb11f55e | ||
|
|
40a66b0306 | ||
|
|
8c899698e0 | ||
|
|
58fa1571f3 | ||
|
|
2cbe77aa04 | ||
|
|
a0c2935580 | ||
|
|
798f25ff81 | ||
|
|
57b2e360ca | ||
|
|
ee23d59e11 | ||
|
|
04e7da9b73 | ||
|
|
5382d265f2 | ||
|
|
0e1534613c | ||
|
|
d799fac688 | ||
|
|
913247996e | ||
|
|
dc3bab26de | ||
|
|
5c1cf050e2 | ||
|
|
747bee41b7 | ||
|
|
246c00c773 | ||
|
|
272dd79426 | ||
|
|
b953da0341 | ||
|
|
c2a6445c9e | ||
|
|
b177ae7ee6 | ||
|
|
22bd5be5a9 | ||
|
|
90fa347fc2 | ||
|
|
68a9a1439a | ||
|
|
8947eff3b1 | ||
|
|
06b3c5ddb5 | ||
|
|
5fb8a1d3d1 | ||
|
|
b4d307d4cc | ||
|
|
306bd18a40 | ||
|
|
1968f47fc9 | ||
|
|
9b42aa3634 | ||
|
|
9faa0ddc62 | ||
|
|
6a2cd9d3ba | ||
|
|
9028564c10 | ||
|
|
8f2b23f8f9 | ||
|
|
b471d7419e | ||
|
|
5179cfc5ba | ||
|
|
784b2f541d | ||
|
|
735cf47c35 | ||
|
|
056742479e | ||
|
|
840b7e6987 | ||
|
|
a87772c98c | ||
|
|
c15f1e8276 | ||
|
|
49148dfb7a | ||
|
|
177f5de2bd | ||
|
|
96360ddb24 | ||
|
|
f5f2e4970e | ||
|
|
742256c130 | ||
|
|
b4a622d319 | ||
|
|
b0c4752397 | ||
|
|
bf78a4dfad | ||
|
|
8d7841b069 | ||
|
|
396eaa148c | ||
|
|
2a244f1e53 | ||
|
|
847181ada4 | ||
|
|
f274f5a0ef | ||
|
|
bb41883070 | ||
|
|
fca5457ab9 | ||
|
|
4f355ed4a2 | ||
|
|
b1452c714a | ||
|
|
aba48cca53 | ||
|
|
772d5fb0cc | ||
|
|
6b6f8cadb2 | ||
|
|
82ab79e915 | ||
|
|
863471b5f1 | ||
|
|
314f280400 | ||
|
|
b75f4bf9a9 | ||
|
|
253d67ce78 | ||
|
|
1753bc18c1 | ||
|
|
eceba13164 | ||
|
|
3c6c640f50 | ||
|
|
30e3018966 | ||
|
|
5ab0bb3c0d | ||
|
|
0de1517bd8 | ||
|
|
39c6d81b9e | ||
|
|
1c1fbe83ec | ||
|
|
ccd56e0368 | ||
|
|
38c7f226cb | ||
|
|
f5446cc415 | ||
|
|
aa2e680568 | ||
|
|
bc651cb774 | ||
|
|
20b03d0004 | ||
|
|
b005ce8e6b | ||
|
|
979b8b2663 | ||
|
|
69b1decbba | ||
|
|
d32c92cbde | ||
|
|
cef88cde20 | ||
|
|
a5b9885767 | ||
|
|
2daedecf92 | ||
|
|
db24822d2f | ||
|
|
aa3833915b | ||
|
|
59320d9b85 | ||
|
|
0c0bbeff27 | ||
|
|
ceda14096c | ||
|
|
9dfcef6356 | ||
|
|
d5b393d6bd | ||
|
|
ae3fc14b52 | ||
|
|
e2cdd6a7f9 | ||
|
|
261d02e67b | ||
|
|
f8681d179d | ||
|
|
f23630064e | ||
|
|
a6ce4694fc | ||
|
|
bec7f9be96 | ||
|
|
09e94eaa8e | ||
|
|
14bc65468a | ||
|
|
56d109bf0a | ||
|
|
a965859095 | ||
|
|
5f29bb3e7f | ||
|
|
1ad6a0d5b5 | ||
|
|
863ae447b9 | ||
|
|
f727e71eaf | ||
|
|
4dd922f1b5 | ||
|
|
14f006c3a5 | ||
|
|
f95dc40f4c | ||
|
|
200211c186 | ||
|
|
81786f7a7c | ||
|
|
1381d8d94c | ||
|
|
5ca214534d | ||
|
|
85ea21e83b | ||
|
|
1dca02517e | ||
|
|
7d572d748b | ||
|
|
fbcae10f96 | ||
|
|
b109fc7420 | ||
|
|
c74c01271d | ||
|
|
a4495ce80a | ||
|
|
f5478f6169 | ||
|
|
ae1e229619 | ||
|
|
bc5982b994 | ||
|
|
702b916948 | ||
|
|
8ed2431f37 | ||
|
|
e971d5d43f | ||
|
|
ee9519d891 | ||
|
|
58bb209158 | ||
|
|
23dc97ad5e | ||
|
|
84b580b001 | ||
|
|
227b303669 | ||
|
|
712a0a3905 | ||
|
|
76427b8ecb | ||
|
|
8b6d621d20 | ||
|
|
7898b24bac | ||
|
|
39648c5dc6 | ||
|
|
83e6b2fdfe | ||
|
|
816727d65b | ||
|
|
0e012adb6c | ||
|
|
539b0e64c8 | ||
|
|
258700ee7b | ||
|
|
1da72ba473 | ||
|
|
c2c69f243e | ||
|
|
dffbb8e4c8 | ||
|
|
c45cbebcce | ||
|
|
bebdede33b | ||
|
|
251110c4f8 | ||
|
|
50d37bb311 | ||
|
|
bbb73008ac | ||
|
|
c324f11a96 | ||
|
|
c4eb6be0fe | ||
|
|
64200030d2 | ||
|
|
4d7e74365b | ||
|
|
b9b25e7e6b | ||
|
|
8a4f48f08d | ||
|
|
ae9ab03e51 | ||
|
|
02478ee887 | ||
|
|
57f238de7d | ||
|
|
77938a77e8 | ||
|
|
d41aa5f9ae | ||
|
|
0ef3386ebf | ||
|
|
9703de86d3 | ||
|
|
764e8d7daa | ||
|
|
18f5c129a4 | ||
|
|
807d6a0cf4 | ||
|
|
a0ab2a8ba7 | ||
|
|
90d0fb7efb | ||
|
|
fe4290b218 | ||
|
|
cc04342358 | ||
|
|
66da826eab | ||
|
|
2afdaa1ac9 | ||
|
|
d4947c3c47 | ||
|
|
35efd9293b | ||
|
|
d89aa887fb | ||
|
|
801727dca6 | ||
|
|
44963fa4c7 | ||
|
|
a2534a8227 | ||
|
|
4f9268e571 | ||
|
|
e343756e44 | ||
|
|
9480f0d2bc | ||
|
|
fb2a808f5c | ||
|
|
24c0ec905e | ||
|
|
bca6a580e3 | ||
|
|
1d0413f159 | ||
|
|
72d8863862 | ||
|
|
c15dac3582 | ||
|
|
efe06264bd | ||
|
|
d5e155d77f | ||
|
|
bf68afdda3 | ||
|
|
a61b82748c | ||
|
|
245b2483ab | ||
|
|
87dbf1dbba | ||
|
|
101f7cb7e2 | ||
|
|
c795913259 | ||
|
|
64eabf71f2 | ||
|
|
2760354943 | ||
|
|
28c2586452 | ||
|
|
21d8c11cfe | ||
|
|
862746038d | ||
|
|
2bd81b08c2 | ||
|
|
16aee33bdf | ||
|
|
f4161ed61c | ||
|
|
bfa0861065 | ||
|
|
86d1512e5b | ||
|
|
5c83ee2648 | ||
|
|
7ba987e7f7 | ||
|
|
b22e93d6d0 | ||
|
|
70b74d39fc | ||
|
|
0236cb35d9 | ||
|
|
b0066a93ca | ||
|
|
e25bf9f077 | ||
|
|
147df1ffb2 | ||
|
|
4c96759ed5 | ||
|
|
8e2df3a030 | ||
|
|
58a5720b6b | ||
|
|
eedf993d7a | ||
|
|
d058cbf501 | ||
|
|
d2413e1677 | ||
|
|
3cb1984892 | ||
|
|
17207d44e6 | ||
|
|
36cfcbbbe3 | ||
|
|
1a6c0cd4d9 | ||
|
|
5a97c512f7 | ||
|
|
57a3330200 | ||
|
|
07ce0a47f7 | ||
|
|
b9f7a05e2a | ||
|
|
7f73b4554a | ||
|
|
f2e02794b8 | ||
|
|
0a2e45b64b | ||
|
|
a017e14a48 | ||
|
|
5ef03ba1d5 | ||
|
|
6a402b4a2b | ||
|
|
5daaaf5282 | ||
|
|
6f7729e34e | ||
|
|
043d6ffd20 | ||
|
|
a8404a7286 | ||
|
|
58d9134286 | ||
|
|
f25786635b | ||
|
|
6d1130d2c3 | ||
|
|
d9effc4a29 | ||
|
|
cf2765e017 | ||
|
|
06dd07dbc6 | ||
|
|
14daf2ce85 | ||
|
|
f9a3a3b78b | ||
|
|
2ba0e6ada6 | ||
|
|
943b75455b | ||
|
|
2b56d68f7d | ||
|
|
93217a3ae3 | ||
|
|
ba5c8ffaa6 | ||
|
|
653861107d |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Please file a separate report for each issue
|
||||
title: Please add a brief but descriptive title
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Some information
|
||||
Operating system:
|
||||
Java version:
|
||||
Minecraft version:
|
||||
Baritone version:
|
||||
Forge mods (if used):
|
||||
|
||||
## Exception, error or logs
|
||||
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
|
||||
|
||||
## How to reproduce
|
||||
Add your steps to reproduce the issue/bug experienced here.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
|
||||
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
name: Question
|
||||
about: Please file a separate report for each question
|
||||
title: Please add a brief but descriptive title
|
||||
labels: question
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## What do you need help with?
|
||||
With as much detail as possible, describe your question and what you may need help with.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Suggestion
|
||||
about: Please file a separate report for each suggestion
|
||||
title: Please add a brief but descriptive title
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Describe your suggestion
|
||||
With as much detail as possible, describe what your suggestion would do for Baritone.
|
||||
|
||||
## Settings
|
||||
If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.
|
||||
|
||||
## Context
|
||||
Describe how your suggestion would improve Baritone, or the reason behind it being added.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<!-- No UwU's or OwO's allowed -->
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,4 +18,4 @@ classes/
|
||||
|
||||
# Copyright Files
|
||||
!/.idea/copyright/Baritone.xml
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
|
||||
@@ -9,6 +9,7 @@ install:
|
||||
- travis_retry docker build -t cabaletta/baritone .
|
||||
|
||||
script:
|
||||
- docker run --rm cabaletta/baritone ./gradlew javadoc
|
||||
- docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||
- docker cp baritone:/code/dist dist
|
||||
- ls dist
|
||||
|
||||
83
CODE_OF_CONDUCT.md
Normal file
83
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* No Anime
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* Anime
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* ~~Trolling, insulting/derogatory comments, and personal or political attacks~~
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
Project maintainers have the right and responsibility to immediately remove
|
||||
without any sort of dispute any issues or pull requests that do not align
|
||||
with their corresponding templates. Absolutely no leniancy shall be accepted
|
||||
with these terms.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at complaints@leijurv.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
11
Dockerfile
11
Dockerfile
@@ -1,17 +1,16 @@
|
||||
FROM debian:jessie
|
||||
FROM debian:stretch
|
||||
|
||||
RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list
|
||||
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update -y
|
||||
|
||||
RUN apt install --target-release jessie-backports \
|
||||
RUN apt install \
|
||||
openjdk-8-jdk \
|
||||
ca-certificates-java \
|
||||
--assume-yes
|
||||
|
||||
RUN apt install -qq --force-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
|
||||
COPY . /code
|
||||
|
||||
@@ -21,4 +20,4 @@ WORKDIR /code
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build
|
||||
|
||||
10
FEATURES.md
10
FEATURES.md
@@ -4,13 +4,14 @@
|
||||
- **Block breaking** Baritone considers breaking blocks as part of its path. It also takes into account your current tool set and hot bar. For example, if you have a Eff V diamond pick, it may choose to mine through a stone barrier, while if you only had a wood pick it might be faster to climb over it.
|
||||
- **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. <a href="https://www.youtube.com/watch?v=F6FbI1L9UmU">Example</a>
|
||||
- **Falling** Baritone will fall up to 3 blocks onto solid ground (configurable, if you have Feather Falling and/or don't mind taking a little damage). If you have a water bucket on your hotbar, it will fall up to 23 blocks and place the bucket beneath it. It will fall an unlimited distance into existing still water.
|
||||
- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`).
|
||||
- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). Baritone can break its fall by grabbing ladders / vines midair, and understands when that is and isn't possible.
|
||||
- **Opening fence gates and doors**
|
||||
- **Slabs and stairs**
|
||||
- **Falling blocks** Baritone understands the costs of breaking blocks with falling blocks on top, and includes all of their break costs. Additionally, since it avoids breaking any blocks touching a liquid, it won't break the bottom of a gravel stack below a lava lake (anymore).
|
||||
- **Avoiding dangerous blocks** Obviously, it knows not to walk through fire or on magma, not to corner over lava (that deals some damage), not to break any blocks touching a liquid (it might drown), etc.
|
||||
- **Parkour** Sprint jumping over 1, 2, or 3 block gaps
|
||||
- **Parkour place** Sprint jumping over a 3 block gap and placing the block to land on while executing the jump. It's really cool.
|
||||
- **Pigs** It can sort of control pigs. I wouldn't rely on it though.
|
||||
|
||||
# Pathing method
|
||||
Baritone uses A*, with some modifications:
|
||||
@@ -21,9 +22,9 @@ Baritone uses A*, with some modifications:
|
||||
- **Backtrack cost favoring** While calculating the next segment, Baritone favors backtracking its current segment. The cost is decreased heavily, but is still positive (this won't cause it to backtrack if it doesn't need to). This allows it to splice and jump onto the next segment as early as possible, if the next segment begins with a backtrack of the current one. <a href="https://www.youtube.com/watch?v=CGiMcb8-99Y">Example</a>
|
||||
- **Backtrack detection and pausing** While path calculation happens on a separate thread, the main game thread has access to the latest node considered, and the best path so far (those are rendered light blue and dark blue respectively). When the current best path (rendered dark blue) passes through the player's current position on the current path segment, path execution is paused (if it's safe to do so), because there's no point continuing forward if we're about to turn around and go back that same way. Note that the current best path as reported by the path calculation thread takes into account the incremental cost backoff system, so it's accurate to what the path calculation thread will actually pick once it finishes.
|
||||
|
||||
# Configuring Baritone
|
||||
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>.
|
||||
To change a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `pathTimeoutMS 250`). It's case insensitive.
|
||||
# Chat control
|
||||
|
||||
- [Baritone chat control usage](USAGE.md)
|
||||
|
||||
# Goals
|
||||
The pathing goal can be set to any of these options:
|
||||
@@ -46,7 +47,6 @@ Things it doesn't have yet
|
||||
See <a href="https://github.com/cabaletta/baritone/issues">issues</a> for more.
|
||||
|
||||
Things it may not ever have, from most likely to least likely =(
|
||||
- Pigs
|
||||
- Boats
|
||||
- Horses (2x3 path instead of 1x2)
|
||||
- Elytra
|
||||
|
||||
96
INSTALL.md
96
INSTALL.md
@@ -1,96 +0,0 @@
|
||||
# Integration between Baritone and Impact
|
||||
Impact 4.4 has Baritone included.
|
||||
|
||||
These instructions apply to Impact 4.3 (and potentially other hacked clients).
|
||||
|
||||
To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`).
|
||||
|
||||
|
||||
## An Introduction
|
||||
There are some basic steps to getting Baritone setup with Impact.
|
||||
- Acquiring a build of Baritone
|
||||
- Placing Baritone in the libraries directory
|
||||
- Modifying the Impact Profile JSON to run baritone
|
||||
- How to use Baritone
|
||||
|
||||
## Acquiring a build of Baritone
|
||||
There are two methods of acquiring a build of Baritone
|
||||
|
||||
### Official Release (Not always up to date)
|
||||
https://github.com/cabaletta/baritone/releases
|
||||
|
||||
For Impact 4.3, there is no Baritone integration yet, so you will want `baritone-standalone-X.Y.Z.jar`.
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
|
||||
|
||||
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone . && docker run --rm cabaletta/baritone cat /code/dist/checksums.txt` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
|
||||
|
||||
### Building Baritone yourself
|
||||
There are a few steps to this
|
||||
- Clone this repository
|
||||
- Setup the project as instructed in the README
|
||||
- Run the ``build`` gradle task. You can either do this using IntelliJ's gradle UI or through a
|
||||
command line
|
||||
- Windows: ``gradlew build``
|
||||
- Mac/Linux: ``./gradlew build``
|
||||
- The build should be exported into ``/build/libs/baritone-X.Y.Z.jar``
|
||||
|
||||
## Placing Baritone in the libraries directory
|
||||
``/libraries`` is a neat directory in your <a href="https://minecraft.gamepedia.com/.minecraft">Minecraft Installation Directory</a>
|
||||
that contains all of the dependencies that are required from the game and some mods. This is where we will be
|
||||
putting baritone.
|
||||
- Locate the ``libraries`` folder, it should be in the Minecraft Installation Directory
|
||||
- Create 3 new subdirectories starting from ``libraries``
|
||||
- ``cabaletta``
|
||||
- ``baritone``
|
||||
- ``X.Y.Z``
|
||||
- Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder
|
||||
- The full path should look like ``<Minecraft>/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar``
|
||||
|
||||
## Modifying the Impact Profile JSON to run baritone
|
||||
The final step is "registering" the Baritone library with Impact, so that it loads on launch.
|
||||
- Ensure your Minecraft launcher is closed
|
||||
- Navigate back to the Minecraft Installation Directory
|
||||
- Find the ``versions`` directory, and open in
|
||||
- In here there should be a ``1.12.2-Impact_4.3`` folder.
|
||||
- If you don't have any Impact folder or have a version older than 4.3, you can download Impact <a href="https://impactdevelopment.github.io">here</a>.
|
||||
- Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json``
|
||||
- Open the JSON file with a text editor that supports your system's line endings
|
||||
- For example, Notepad on Windows likely will NOT work for this. You should instead use a Text Editor like
|
||||
<a href="https://notepad-plus-plus.org/">Notepad++</a> if you're on Windows. (For other systems, I'm not sure
|
||||
what would work the best so you may have to do some research.)
|
||||
- Find the ``libraries`` array in the JSON. It should look something like this.
|
||||
```
|
||||
"libraries": [
|
||||
{
|
||||
"name": "net.minecraft:launchwrapper:1.12"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDevelopment:Impact:4.3-1.12.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDeveloment:ClientAPI:3.0.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
...
|
||||
```
|
||||
- Create two new objects in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably.
|
||||
```
|
||||
{
|
||||
"name": "cabaletta:baritone:X.Y.Z"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDevelopment:SimpleTweaker:1.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
```
|
||||
- Now find the ``"minecraftArguments": "..."`` text near the top.
|
||||
- At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like:
|
||||
- ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"``
|
||||
- If you didn't close your launcher for this step, restart it now.
|
||||
- You can now launch Impact 4.3 as normal, and Baritone should start up
|
||||
|
||||
## How to use Baritone
|
||||
Instructions on how to use Baritone are limited, and you may have to read a little bit of code (Really nothing much
|
||||
just plain English), you can view that <a href="https://github.com/cabaletta/baritone#chat-control">here</a>.
|
||||
BIN
LICENSE-Part-2.jpg
Normal file
BIN
LICENSE-Part-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
88
README.md
88
README.md
@@ -1,62 +1,72 @@
|
||||
# Baritone
|
||||
[](https://travis-ci.com/cabaletta/baritone)
|
||||
[](https://github.com/cabaletta/baritone/releases)
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone)
|
||||
[](https://github.com/cabaletta/baritone/issues)
|
||||
[](https://minecraft.gamepedia.com/1.12.2)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||
[](https://github.com/cabaletta/baritone/pulls/)
|
||||

|
||||

|
||||

|
||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||
[](https://github.com/cabaletta/baritone/commit/)
|
||||
[](https://impactdevelopment.github.io/)
|
||||
[](https://github.com/fr1kin/ForgeHax/)
|
||||
[](https://gitlab.com/emc-mods-indrit/baritone_api)
|
||||
[](https://wweclient.com/)
|
||||
[](https://futureclient.net/)
|
||||
[](http://forthebadge.com/)
|
||||
[](http://forthebadge.com/)
|
||||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
|
||||
|
||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
|
||||
|
||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||
|
||||
# Getting Started
|
||||
|
||||
Here are some links to help to get started:
|
||||
|
||||
- [Features](FEATURES.md)
|
||||
|
||||
- [Installation](INSTALL.md)
|
||||
- [Installation & setup](SETUP.md)
|
||||
|
||||
There's also some useful information down below
|
||||
- [API Javadocs](https://baritone.leijurv.com/)
|
||||
|
||||
# Setup
|
||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
||||
|
||||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
- [Usage (chat control)](USAGE.md)
|
||||
|
||||
Running Baritone:
|
||||
# API
|
||||
|
||||
```
|
||||
$ gradlew runClient
|
||||
```
|
||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
||||
jar.
|
||||
|
||||
Building Baritone:
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
For example, to replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`).
|
||||
|
||||
## IntelliJ's Gradle UI
|
||||
- Open the project in IntelliJ as a Gradle project
|
||||
- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns`
|
||||
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
|
||||
- Select the "Minecraft Client" launch config
|
||||
- In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`.
|
||||
|
||||
# Chat control
|
||||
[Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java)
|
||||
|
||||
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
||||
|
||||
# API example
|
||||
Below is an example of basic usage for changing some settings, and then pathing to a X/Z goal.
|
||||
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L;
|
||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
||||
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
|
||||
```
|
||||
@@ -65,11 +75,11 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd
|
||||
|
||||
## Can I use Baritone as a library in my custom utility client?
|
||||
|
||||
Sure! (As long as usage is in compliance with the LGPL 3 License)
|
||||
That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License)
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pain)
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
|
||||
106
SETUP.md
Normal file
106
SETUP.md
Normal file
@@ -0,0 +1,106 @@
|
||||
# Installation
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||
|
||||
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
## Prebuilt official releases
|
||||
These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself)
|
||||
|
||||
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
|
||||
|
||||
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
|
||||
|
||||
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
|
||||
|
||||
|
||||
## Artifacts
|
||||
|
||||
Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
|
||||
|
||||
**The Forge release can simply be added as a Forge mod.**
|
||||
|
||||
If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar`
|
||||
|
||||
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
||||
- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration.
|
||||
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
|
||||
- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone.
|
||||
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
||||
|
||||
## More Info
|
||||
To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal.
|
||||
|
||||
You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`.
|
||||
|
||||
## Build it yourself
|
||||
- Clone or download Baritone
|
||||
|
||||

|
||||
- If you choose to download, make sure you extract the ZIP archive.
|
||||
- Follow one of the instruction sets below, based on your preference
|
||||
|
||||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
|
||||
Setting up the Environment:
|
||||
|
||||
```
|
||||
$ gradlew setupDecompWorkspace
|
||||
$ gradlew --refresh-dependencies
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
$ gradlew runClient
|
||||
```
|
||||
|
||||
For information on how to build baritone, see [Building Baritone](#building-baritone)
|
||||
|
||||
## IntelliJ
|
||||
- Open the project in IntelliJ as a Gradle project
|
||||
|
||||

|
||||
|
||||
- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns`
|
||||
|
||||

|
||||
|
||||
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
|
||||
|
||||

|
||||
|
||||
- Select the "Minecraft Client" launch config
|
||||
|
||||

|
||||
|
||||
- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config
|
||||
|
||||

|
||||
|
||||
- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`.
|
||||
|
||||

|
||||
|
||||
# Building
|
||||
|
||||
Make sure that you have properly [setup](#setup) the environment before trying to build it.
|
||||
|
||||
## Command Line
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
## IntelliJ
|
||||
|
||||
- Navigate to the gradle tasks on the right tab as follows
|
||||
|
||||

|
||||
|
||||
- Double click on **build** to run it
|
||||
82
USAGE.md
Normal file
82
USAGE.md
Normal file
@@ -0,0 +1,82 @@
|
||||
(assuming you already have Baritone [set up](SETUP.md))
|
||||
|
||||
# Prefix
|
||||
|
||||
Baritone's chat control prefix is `#` by default. In Impact, you can also use `.b` as a prefix. (for example, `.b click` instead of `#click`)
|
||||
|
||||
Baritone commands can also by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of "goal" it goes into public chat, which is bad, so using `#` is suggested.
|
||||
|
||||
To disable direct chat control (with no prefix), turn off the `chatControl` setting. To disable chat control with the `#` prefix, turn off the `prefixControl` setting. In Impact, `.b` cannot be disabled. Be careful that you don't leave yourself with all control methods disabled (if you do, reset your settings by deleting the file `minecraft/baritone/settings.txt` and relaunching).
|
||||
|
||||
# Commands
|
||||
|
||||
**All** of these commands may need a prefix before them, as above ^.
|
||||
|
||||
`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java#L47).
|
||||
|
||||
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
|
||||
|
||||
Some common examples:
|
||||
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
|
||||
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
|
||||
- `goal` to set the goal to your player's feet
|
||||
- `goal clear` to clear the goal
|
||||
- `cancel` or `stop` to stop everything
|
||||
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
||||
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
|
||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
|
||||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `schematica` to build the schematic that is currently open in schematica
|
||||
- `tunnel` to dig just straight ahead and make a tunnel
|
||||
- `farm` to automatically harvest, replant, or bone meal crops
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
|
||||
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.
|
||||
- `version` to get the version of Baritone you're running
|
||||
- `damn` daniel
|
||||
|
||||
|
||||
For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java).
|
||||
|
||||
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>. If you find HTML easier to read than Javadoc, you can look <a href="https://baritone.leijurv.com/baritone/api/Settings.html#field.detail">here</a>.
|
||||
|
||||
There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links.
|
||||
- `allowBreak`
|
||||
- `allowSprint`
|
||||
- `allowPlace`
|
||||
- `allowParkour`
|
||||
- `allowParkourPlace`
|
||||
- `blockPlacementPenalty`
|
||||
- `renderCachedChunks` (and `cachedChunksOpacity`) <-- very fun but you need a beefy computer
|
||||
- `avoidance` (avoidance of mobs / mob spawners)
|
||||
- `legitMine`
|
||||
- `followRadius`
|
||||
- `backfill` (fill in tunnels behind you)
|
||||
- `buildInLayers`
|
||||
- `buildRepeatDistance` and `buildRepeatDirection`
|
||||
- `worldExploringChunkOffset`
|
||||
- `acceptableThrowawayItems`
|
||||
- `blocksToAvoidBreaking`
|
||||
|
||||
|
||||
|
||||
|
||||
# Troubleshooting / common issues
|
||||
|
||||
## Why doesn't Baritone respond to any of my chat commands?
|
||||
This could be one of many things.
|
||||
|
||||
First, make sure it's actually installed. An easy way to check is seeing if it created the folder `baritone` in your Minecraft folder.
|
||||
|
||||
Second, make sure that you're using the prefix properly, and that chat control is enabled in the way you expect.
|
||||
|
||||
For example, Impact disables direct chat control. (i.e. anything typed in chat without a prefix will be ignored and sent publicly). **This is a saved setting**, so if you run Impact once, `chatControl` will be off from then on, **even in other clients**.
|
||||
So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Minecraft folder to undo that (specifically, remove the line `chatControl false` then restart your client).
|
||||
|
||||
|
||||
## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?
|
||||
These are custom commands that they added; those aren't from Baritone.
|
||||
The equivalent you're looking for is `goal x z` then `path`.
|
||||
255
build.gradle
255
build.gradle
@@ -1,115 +1,140 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.0.0-hotfix-2'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'SpongePowered'
|
||||
url = 'http://repo.spongepowered.org/maven'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = '1.12.2'
|
||||
mappings = 'stable_39'
|
||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||
runDir = 'run'
|
||||
|
||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||
makeObfSourceJar = true
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv notch
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
|
||||
jar {
|
||||
from sourceSets.launch.output, sourceSets.api.output
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
versionManifest 'https://launchermeta.mojang.com/mc/game/version_manifest.json'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.2.9'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'SpongePowered'
|
||||
url = 'http://repo.spongepowered.org/maven'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = '1.12.2'
|
||||
mappings = 'stable_39'
|
||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||
runDir = 'run'
|
||||
|
||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||
makeObfSourceJar = true
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv searge
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
|
||||
options.linkSource true
|
||||
options.encoding "UTF-8" // allow emoji in comments :^)
|
||||
source = sourceSets.api.allJava
|
||||
classpath += sourceSets.api.compileClasspath
|
||||
}
|
||||
|
||||
jar {
|
||||
from sourceSets.launch.output, sourceSets.api.output
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.gradle.task;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.gradle.api.DefaultTask;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,7 +24,6 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -34,8 +31,6 @@ import java.util.List;
|
||||
*/
|
||||
class BaritoneGradleTask extends DefaultTask {
|
||||
|
||||
protected static final JsonParser PARSER = new JsonParser();
|
||||
|
||||
protected static final String
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
@@ -45,26 +40,28 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
|
||||
VERSION_MANIFEST = "version_manifest.json",
|
||||
|
||||
TEMP_LIBRARY_DIR = "tempLibraries/",
|
||||
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, proguardOut;
|
||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgeApiPath, artifactForgeStandalonePath, proguardOut;
|
||||
|
||||
protected void verifyArtifacts() throws IllegalStateException {
|
||||
this.artifactName = getProject().getName();
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
this.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
|
||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||
|
||||
@@ -95,8 +92,4 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
protected Path getBuildFile(String file) {
|
||||
return getRelativeFile("build/libs/" + file);
|
||||
}
|
||||
|
||||
protected JsonElement readJson(List<String> lines) {
|
||||
return PARSER.parse(String.join("\n", lines));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,11 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
super.verifyArtifacts();
|
||||
|
||||
// Define the distribution file paths
|
||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
Path forgeApi = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API));
|
||||
Path forgeStandalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
|
||||
// NIO will not automatically create directories
|
||||
Path dir = getRelativeFile("dist/");
|
||||
@@ -53,12 +55,14 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
}
|
||||
|
||||
// Copy build jars to dist/
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactForgeApiPath, forgeApi, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactForgeStandalonePath, forgeStandalone, REPLACE_EXISTING);
|
||||
|
||||
// Calculate all checksums and format them like "shasum"
|
||||
List<String> shasum = Stream.of(api, standalone, unoptimized)
|
||||
List<String> shasum = Stream.of(api, forgeApi, standalone, forgeStandalone, unoptimized)
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -18,21 +18,26 @@
|
||||
package baritone.gradle.task;
|
||||
|
||||
import baritone.gradle.util.Determinizer;
|
||||
import com.google.gson.*;
|
||||
import baritone.gradle.util.MappingType;
|
||||
import baritone.gradle.util.ReobfWrapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.internal.plugins.DefaultConvention;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.internal.Pair;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -52,12 +57,10 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
@Input
|
||||
private String extract;
|
||||
|
||||
@Input
|
||||
private String versionManifest;
|
||||
|
||||
private Map<String, String> versionDownloadMap;
|
||||
private List<String> requiredLibraries;
|
||||
|
||||
private File mixin;
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.verifyArtifacts();
|
||||
@@ -67,7 +70,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
downloadProguard();
|
||||
extractProguard();
|
||||
generateConfigs();
|
||||
downloadVersionManifest();
|
||||
acquireDependencies();
|
||||
proguardApi();
|
||||
proguardStandalone();
|
||||
@@ -79,7 +81,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Files.delete(this.artifactUnoptimizedPath);
|
||||
}
|
||||
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
||||
}
|
||||
|
||||
private void downloadProguard() throws Exception {
|
||||
@@ -132,20 +134,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
});
|
||||
}
|
||||
|
||||
private void downloadVersionManifest() throws Exception {
|
||||
Path manifestJson = getTemporaryFile(VERSION_MANIFEST);
|
||||
write(new URL(this.versionManifest).openStream(), manifestJson);
|
||||
|
||||
// Place all the versions in the map with their download URL
|
||||
this.versionDownloadMap = new HashMap<>();
|
||||
JsonObject json = readJson(Files.readAllLines(manifestJson)).getAsJsonObject();
|
||||
JsonArray versions = json.getAsJsonArray("versions");
|
||||
versions.forEach(element -> {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
this.versionDownloadMap.put(object.get("id").getAsString(), object.get("url").getAsString());
|
||||
});
|
||||
}
|
||||
|
||||
private void acquireDependencies() throws Exception {
|
||||
|
||||
// Create a map of all of the dependencies that we are able to access in this project
|
||||
@@ -163,15 +151,13 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
|
||||
// Iterate the required libraries to copy them to tempLibraries
|
||||
for (String lib : this.requiredLibraries) {
|
||||
// Download the version jar from the URL acquired from the version manifest
|
||||
if (lib.startsWith("minecraft")) {
|
||||
String version = lib.split("-")[1];
|
||||
Path versionJar = getTemporaryFile("tempLibraries/" + lib + ".jar");
|
||||
if (!Files.exists(versionJar)) {
|
||||
JsonObject versionJson = PARSER.parse(new InputStreamReader(new URL(this.versionDownloadMap.get(version)).openStream())).getAsJsonObject();
|
||||
String url = versionJson.getAsJsonObject("downloads").getAsJsonObject("client").getAsJsonPrimitive("url").getAsString();
|
||||
write(new URL(url).openStream(), versionJar);
|
||||
}
|
||||
// copy from the forgegradle cache
|
||||
if (lib.equals("minecraft")) {
|
||||
Path cachedJar = getMinecraftJar();
|
||||
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
||||
// TODO: maybe try not to copy every time
|
||||
Files.copy(cachedJar, inTempDir, REPLACE_EXISTING);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -189,20 +175,111 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
// Find the library jar file, and copy it to tempLibraries
|
||||
for (File file : pair.getLeft().files(pair.getRight())) {
|
||||
if (file.getName().startsWith(lib)) {
|
||||
if (lib.contains("mixin")) {
|
||||
mixin = file;
|
||||
}
|
||||
Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mixin == null) {
|
||||
throw new IllegalStateException("Unable to find mixin jar");
|
||||
}
|
||||
}
|
||||
|
||||
// a bunch of epic stuff to get the path to the cached jar
|
||||
private Path getMinecraftJar() throws Exception {
|
||||
MappingType mappingType;
|
||||
try {
|
||||
mappingType = getMappingType();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to get mapping type, assuming NOTCH.");
|
||||
mappingType = MappingType.NOTCH;
|
||||
}
|
||||
|
||||
String suffix;
|
||||
switch (mappingType) {
|
||||
case NOTCH:
|
||||
suffix = "";
|
||||
break;
|
||||
case SEARGE:
|
||||
suffix = "-srgBin";
|
||||
break;
|
||||
case CUSTOM:
|
||||
throw new IllegalStateException("Custom mappings not supported!");
|
||||
default:
|
||||
throw new IllegalStateException("Unknown mapping type: " + mappingType);
|
||||
}
|
||||
|
||||
DefaultConvention convention = (DefaultConvention) this.getProject().getConvention();
|
||||
Object extension = convention.getAsMap().get("minecraft");
|
||||
Objects.requireNonNull(extension);
|
||||
|
||||
// for some reason cant use Class.forName
|
||||
Class<?> class_baseExtension = extension.getClass().getSuperclass().getSuperclass().getSuperclass(); // <-- cursed
|
||||
Field f_replacer = class_baseExtension.getDeclaredField("replacer");
|
||||
f_replacer.setAccessible(true);
|
||||
Object replacer = f_replacer.get(extension);
|
||||
Class<?> class_replacementProvider = replacer.getClass();
|
||||
Field replacement_replaceMap = class_replacementProvider.getDeclaredField("replaceMap");
|
||||
replacement_replaceMap.setAccessible(true);
|
||||
|
||||
Map<String, Object> replacements = (Map) replacement_replaceMap.get(replacer);
|
||||
String cacheDir = replacements.get("CACHE_DIR").toString() + "/net/minecraft";
|
||||
String mcVersion = replacements.get("MC_VERSION").toString();
|
||||
String mcpInsert = replacements.get("MAPPING_CHANNEL").toString() + "/" + replacements.get("MAPPING_VERSION").toString();
|
||||
String fullJarName = "minecraft-" + mcVersion + suffix + ".jar";
|
||||
|
||||
String baseDir = String.format("%s/minecraft/%s/", cacheDir, mcVersion);
|
||||
|
||||
String jarPath;
|
||||
if (mappingType == MappingType.SEARGE) {
|
||||
jarPath = String.format("%s/%s/%s", baseDir, mcpInsert, fullJarName);
|
||||
} else {
|
||||
jarPath = baseDir + fullJarName;
|
||||
}
|
||||
jarPath = jarPath
|
||||
.replace("/", File.separator)
|
||||
.replace("\\", File.separator); // hecking regex
|
||||
|
||||
return new File(jarPath).toPath();
|
||||
}
|
||||
|
||||
// throws IllegalStateException if mapping type is ambiguous or it fails to find it
|
||||
private MappingType getMappingType() {
|
||||
// if it fails to find this then its probably a forgegradle version problem
|
||||
Set<Object> reobf = (NamedDomainObjectContainer<Object>) this.getProject().getExtensions().getByName("reobf");
|
||||
|
||||
List<MappingType> mappingTypes = getUsedMappingTypes(reobf);
|
||||
long mappingTypesUsed = mappingTypes.size();
|
||||
if (mappingTypesUsed == 0) {
|
||||
throw new IllegalStateException("Failed to find mapping type (no jar task?)");
|
||||
}
|
||||
if (mappingTypesUsed > 1) {
|
||||
throw new IllegalStateException("Ambiguous mapping type (multiple jars with different mapping types?)");
|
||||
}
|
||||
|
||||
return mappingTypes.get(0);
|
||||
}
|
||||
|
||||
private List<MappingType> getUsedMappingTypes(Set<Object> reobf) {
|
||||
return reobf.stream()
|
||||
.map(ReobfWrapper::new)
|
||||
.map(ReobfWrapper::getMappingType)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void proguardApi() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Optional.empty());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Optional.of(mixin));
|
||||
}
|
||||
|
||||
private void proguardStandalone() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Optional.empty());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Optional.of(mixin));
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
@@ -219,10 +296,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
public void setVersionManifest(String versionManifest) {
|
||||
this.versionManifest = versionManifest;
|
||||
}
|
||||
|
||||
private void runProguard(Path config) throws Exception {
|
||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||
if (Files.exists(this.proguardOut)) {
|
||||
@@ -235,8 +308,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
.start();
|
||||
|
||||
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
|
||||
this.printOutputLog(p.getInputStream());
|
||||
this.printOutputLog(p.getErrorStream());
|
||||
this.printOutputLog(p.getInputStream(), System.out);
|
||||
this.printOutputLog(p.getErrorStream(), System.err);
|
||||
|
||||
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
|
||||
int exitCode = p.waitFor();
|
||||
@@ -245,14 +318,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
}
|
||||
}
|
||||
|
||||
private void printOutputLog(InputStream stream) {
|
||||
private void printOutputLog(InputStream stream, PrintStream outerr) {
|
||||
new Thread(() -> {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
outerr.println(line);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@@ -39,7 +36,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class Determinizer {
|
||||
|
||||
public static void determinize(String inputPath, String outputPath) throws IOException {
|
||||
public static void determinize(String inputPath, String outputPath, Optional<File> toInclude) throws IOException {
|
||||
System.out.println("Running Determinizer");
|
||||
System.out.println(" Input path: " + inputPath);
|
||||
System.out.println(" Output path: " + outputPath);
|
||||
@@ -66,10 +63,30 @@ public class Determinizer {
|
||||
if (entry.getName().endsWith(".refmap.json")) {
|
||||
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
||||
jos.write(writeSorted(object).getBytes());
|
||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && toInclude.isPresent()) { // only replace for forge jar
|
||||
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
|
||||
copy(jarFile.getInputStream(entry), cancer);
|
||||
String manifest = new String(cancer.toByteArray());
|
||||
if (!manifest.contains("baritone.launch.BaritoneTweaker")) {
|
||||
throw new IllegalStateException("unable to replace");
|
||||
}
|
||||
manifest = manifest.replace("baritone.launch.BaritoneTweaker", "org.spongepowered.asm.launch.MixinTweaker");
|
||||
jos.write(manifest.getBytes());
|
||||
} else {
|
||||
copy(jarFile.getInputStream(entry), jos);
|
||||
}
|
||||
}
|
||||
if (toInclude.isPresent()) {
|
||||
try (JarFile mixin = new JarFile(toInclude.get())) {
|
||||
for (JarEntry entry : mixin.stream().sorted(Comparator.comparing(JarEntry::getName)).collect(Collectors.toList())) {
|
||||
if (entry.getName().startsWith("META-INF") && !entry.getName().startsWith("META-INF/services")) {
|
||||
continue;
|
||||
}
|
||||
jos.putNextEntry(entry);
|
||||
copy(mixin.getInputStream(entry), jos);
|
||||
}
|
||||
}
|
||||
}
|
||||
jos.finish();
|
||||
}
|
||||
}
|
||||
|
||||
29
buildSrc/src/main/java/baritone/gradle/util/MappingType.java
Normal file
29
buildSrc/src/main/java/baritone/gradle/util/MappingType.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.gradle.util;
|
||||
|
||||
/**
|
||||
* All credits go to AsmLibGradle and its contributors.
|
||||
*
|
||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/MappingType.java">Original Source</a>
|
||||
*/
|
||||
public enum MappingType {
|
||||
SEARGE,
|
||||
NOTCH,
|
||||
CUSTOM // forgegradle
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.gradle.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* All credits go to AsmLibGradle and its contributors.
|
||||
*
|
||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/ReobfWrapper.java">Original Source</a>
|
||||
*/
|
||||
public class ReobfWrapper {
|
||||
|
||||
private final Object instance;
|
||||
private final Class<?> type;
|
||||
|
||||
public ReobfWrapper(Object instance) {
|
||||
this.instance = instance;
|
||||
Objects.requireNonNull(instance);
|
||||
this.type = instance.getClass();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
try {
|
||||
Field nameField = type.getDeclaredField("name");
|
||||
nameField.setAccessible(true);
|
||||
return (String) nameField.get(this.instance);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public MappingType getMappingType() {
|
||||
try {
|
||||
Field enumField = type.getDeclaredField("mappingType");
|
||||
enumField.setAccessible(true);
|
||||
Enum<?> aEnum = (Enum<?>) enumField.get(this.instance);
|
||||
MappingType mappingType = MappingType.values()[aEnum.ordinal()];
|
||||
if (!aEnum.name().equals(mappingType.name())) {
|
||||
throw new IllegalStateException("ForgeGradle ReobfMappingType is not equivalent to MappingType (version error?)");
|
||||
}
|
||||
return mappingType;
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
gradle/wrapper/gradle-wrapper.properties
vendored
12
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Tue Jul 31 21:56:56 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
#Tue Jul 31 21:56:56 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
|
||||
168
gradlew.bat
vendored
168
gradlew.bat
vendored
@@ -1,84 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
14
scripts/proguard.pro
vendored
14
scripts/proguard.pro
vendored
@@ -12,14 +12,16 @@
|
||||
-flattenpackagehierarchy
|
||||
-repackageclasses 'baritone'
|
||||
|
||||
# lwjgl is weird
|
||||
-dontwarn org.lwjgl.**
|
||||
|
||||
-keep class baritone.api.** { *; } # this is the keep api
|
||||
|
||||
# service provider needs these class names
|
||||
-keep class baritone.BaritoneProvider
|
||||
-keep class baritone.api.IBaritoneProvider
|
||||
|
||||
# hack
|
||||
-keep class baritone.utils.ExampleBaritoneControl { *; } # have to include this string to remove this keep in the standalone build: # this is the keep api
|
||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||
|
||||
# setting names are reflected from field names, so keep field names
|
||||
-keepclassmembers class baritone.api.Settings {
|
||||
@@ -29,9 +31,15 @@
|
||||
# need to keep mixin names
|
||||
-keep class baritone.launch.** { *; }
|
||||
|
||||
#try to keep usage of schematica in separate classes
|
||||
-keep class baritone.utils.schematic.schematica.**
|
||||
#proguard doesnt like it when it cant find our fake schematica classes
|
||||
-dontwarn baritone.utils.schematic.schematica.**
|
||||
|
||||
# copy all necessary libraries into tempLibraries to build
|
||||
|
||||
-libraryjars 'tempLibraries/minecraft-1.12.2.jar'
|
||||
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
||||
-libraryjars 'tempLibraries/minecraft.jar'
|
||||
|
||||
-libraryjars 'tempLibraries/SimpleTweaker-1.2.jar'
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
|
||||
@@ -23,9 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* API exposure for various things implemented in Baritone.
|
||||
* <p>
|
||||
* W.I.P
|
||||
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
|
||||
@@ -18,14 +18,11 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IMemoryBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.process.IFollowProcess;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.process.IMineProcess;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.*;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
|
||||
@@ -36,28 +33,13 @@ import baritone.api.utils.IPlayerContext;
|
||||
public interface IBaritone {
|
||||
|
||||
/**
|
||||
* @return The {@link IFollowProcess} instance
|
||||
* @see IFollowProcess
|
||||
* Call as soon as Minecraft is ready, initializes all of the processes, behaviors, etc. This will
|
||||
* only effectively be ran once, any additional calls are redundant because the initialization state
|
||||
* is saved.
|
||||
* <p>
|
||||
* Or whenever your overeager utility client wants.
|
||||
*/
|
||||
IFollowProcess getFollowProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link ILookBehavior} instance
|
||||
* @see ILookBehavior
|
||||
*/
|
||||
ILookBehavior getLookBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IMemoryBehavior} instance
|
||||
* @see IMemoryBehavior
|
||||
*/
|
||||
IMemoryBehavior getMemoryBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IMineProcess} instance
|
||||
* @see IMineProcess
|
||||
*/
|
||||
IMineProcess getMineProcess();
|
||||
void init();
|
||||
|
||||
/**
|
||||
* @return The {@link IPathingBehavior} instance
|
||||
@@ -65,19 +47,89 @@ public interface IBaritone {
|
||||
*/
|
||||
IPathingBehavior getPathingBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link ILookBehavior} instance
|
||||
* @see ILookBehavior
|
||||
*/
|
||||
ILookBehavior getLookBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IFollowProcess} instance
|
||||
* @see IFollowProcess
|
||||
*/
|
||||
IFollowProcess getFollowProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IMineProcess} instance
|
||||
* @see IMineProcess
|
||||
*/
|
||||
IMineProcess getMineProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IBuilderProcess} instance
|
||||
* @see IBuilderProcess
|
||||
*/
|
||||
IBuilderProcess getBuilderProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IExploreProcess} instance
|
||||
* @see IExploreProcess
|
||||
*/
|
||||
IExploreProcess getExploreProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IFarmProcess} instance
|
||||
* @see IFarmProcess
|
||||
*/
|
||||
IFarmProcess getFarmProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link ICustomGoalProcess} instance
|
||||
* @see ICustomGoalProcess
|
||||
*/
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IGetToBlockProcess} instance
|
||||
* @see IGetToBlockProcess
|
||||
*/
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IWorldProvider} instance
|
||||
* @see IWorldProvider
|
||||
*/
|
||||
IWorldProvider getWorldProvider();
|
||||
|
||||
/**
|
||||
* Returns the {@link IPathingControlManager} for this {@link IBaritone} instance, which is responsible
|
||||
* for managing the {@link IBaritoneProcess}es which control the {@link IPathingBehavior} state.
|
||||
*
|
||||
* @return The {@link IPathingControlManager} instance
|
||||
* @see IPathingControlManager
|
||||
*/
|
||||
IPathingControlManager getPathingControlManager();
|
||||
|
||||
/**
|
||||
* @return The {@link IInputOverrideHandler} instance
|
||||
* @see IInputOverrideHandler
|
||||
*/
|
||||
IInputOverrideHandler getInputOverrideHandler();
|
||||
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IPlayerContext} instance
|
||||
* @see IPlayerContext
|
||||
*/
|
||||
IPlayerContext getPlayerContext();
|
||||
|
||||
/**
|
||||
* @return The {@link IEventBus} instance
|
||||
* @see IEventBus
|
||||
*/
|
||||
IEventBus getGameEventHandler();
|
||||
|
||||
/**
|
||||
* Open click
|
||||
*/
|
||||
void openClick();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Leijurv
|
||||
* Provides the present {@link IBaritone} instances
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public interface IBaritoneProvider {
|
||||
|
||||
@@ -47,7 +49,8 @@ public interface IBaritoneProvider {
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
||||
* replaced with {@code #getBaritoneForUser(IBaritoneUser)} when {@code bot-system} is merged.
|
||||
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
||||
* {@code bot-system} is merged into {@code master}.
|
||||
*
|
||||
* @param player The player
|
||||
* @return The {@link IBaritone} instance.
|
||||
@@ -58,7 +61,7 @@ public interface IBaritoneProvider {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No baritone for player " + player);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,9 +18,13 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.event.listener.IGameEventListener;
|
||||
|
||||
/**
|
||||
* A behavior is simply a type that is able to listen to events.
|
||||
*
|
||||
* @author Brady
|
||||
* @see IGameEventListener
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IBehavior extends AbstractGameEventListener {}
|
||||
|
||||
@@ -37,7 +37,26 @@ public interface IPathingBehavior extends IBehavior {
|
||||
*
|
||||
* @return The estimated remaining ticks in the current segment.
|
||||
*/
|
||||
Optional<Double> ticksRemainingInSegment();
|
||||
default Optional<Double> ticksRemainingInSegment() {
|
||||
return ticksRemainingInSegment(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the estimated remaining ticks in the current pathing
|
||||
* segment. Given that the return type is an optional, {@link Optional#empty()}
|
||||
* will be returned in the case that there is no current segment being pathed.
|
||||
*
|
||||
* @param includeCurrentMovement whether or not to include the entirety of the cost of the currently executing movement in the total
|
||||
* @return The estimated remaining ticks in the current segment.
|
||||
*/
|
||||
default Optional<Double> ticksRemainingInSegment(boolean includeCurrentMovement) {
|
||||
IPathExecutor current = getCurrent();
|
||||
if (current == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
int start = includeCurrentMovement ? current.getPosition() : current.getPosition() + 1;
|
||||
return Optional.of(current.getPath().ticksRemainingFrom(start));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current pathing goal
|
||||
@@ -47,7 +66,9 @@ public interface IPathingBehavior extends IBehavior {
|
||||
/**
|
||||
* @return Whether or not a path is currently being executed.
|
||||
*/
|
||||
boolean isPathing();
|
||||
default boolean isPathing() {
|
||||
return getCurrent() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the pathing behavior or the current path calculation, and all processes that could be controlling path.
|
||||
@@ -59,6 +80,13 @@ public interface IPathingBehavior extends IBehavior {
|
||||
*/
|
||||
boolean cancelEverything();
|
||||
|
||||
/**
|
||||
* PLEASE never call this
|
||||
* <p>
|
||||
* If cancelEverything was like "kill" this is "sudo kill -9". Or shutting off your computer.
|
||||
*/
|
||||
void forceCancel();
|
||||
|
||||
/**
|
||||
* Returns the current path, from the current path executor, if there is one.
|
||||
*
|
||||
|
||||
@@ -37,12 +37,12 @@ public interface ICachedRegion extends IBlockTypeAccess {
|
||||
boolean isCached(int blockX, int blockZ);
|
||||
|
||||
/**
|
||||
* The X coordinate of this region
|
||||
* @return The X coordinate of this region
|
||||
*/
|
||||
int getX();
|
||||
|
||||
/**
|
||||
* The Z coordinate of this region
|
||||
* @return The Z coordinate of this region
|
||||
*/
|
||||
int getZ();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package baritone.api.cache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -68,7 +68,7 @@ public interface ICachedWorld {
|
||||
* @param maxRegionDistanceSq The maximum region distance, squared
|
||||
* @return The locations found that match the special block
|
||||
*/
|
||||
LinkedList<BlockPos> getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq);
|
||||
ArrayList<BlockPos> getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq);
|
||||
|
||||
/**
|
||||
* Reloads all of the cached regions in this world from disk. Anything that is not saved
|
||||
@@ -81,4 +81,6 @@ public interface ICachedWorld {
|
||||
* in a new thread by default.
|
||||
*/
|
||||
void save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.behavior;
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.behavior.memory.IRememberedInventory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -26,7 +25,7 @@ import java.util.Map;
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IMemoryBehavior extends IBehavior {
|
||||
public interface IContainerMemory {
|
||||
|
||||
/**
|
||||
* Gets a remembered inventory by its block position.
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.behavior.memory;
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
10
src/api/java/baritone/api/cache/IWorldData.java
vendored
10
src/api/java/baritone/api/cache/IWorldData.java
vendored
@@ -27,13 +27,19 @@ public interface IWorldData {
|
||||
* Returns the cached world for this world. A cached world is a simplified format
|
||||
* of a regular world, intended for use on multiplayer servers where chunks are not
|
||||
* traditionally stored to disk, allowing for long distance pathing with minimal disk usage.
|
||||
*
|
||||
* @return The cached world for this world
|
||||
*/
|
||||
ICachedWorld getCachedWorld();
|
||||
|
||||
/**
|
||||
* Returns the waypoint collection for this world.
|
||||
*
|
||||
* @return The waypoint collection for this world
|
||||
*/
|
||||
IWaypointCollection getWaypoints();
|
||||
|
||||
/**
|
||||
* @return The {@link IContainerMemory} instance
|
||||
* @see IContainerMemory
|
||||
*/
|
||||
IContainerMemory getContainerMemory();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.api.cache;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,4 +43,18 @@ public interface IWorldScanner {
|
||||
* @return The matching block positions
|
||||
*/
|
||||
List<BlockPos> scanChunkRadius(IPlayerContext ctx, List<Block> blocks, int max, int yLevelThreshold, int maxSearchRadius);
|
||||
|
||||
/**
|
||||
* Scans a single chunk for the specified blocks.
|
||||
*
|
||||
* @param ctx The {@link IPlayerContext} containing player and world info that the
|
||||
* scan is based upon
|
||||
* @param blocks The blocks to scan for
|
||||
* @param pos The position of the target chunk
|
||||
* @param max The maximum number of blocks to scan before cutoff
|
||||
* @param yLevelThreshold If a block is found within this Y level, the current result will be
|
||||
* returned, if the value is negative, then this condition doesn't apply.
|
||||
* @return The matching block positions
|
||||
*/
|
||||
List<BlockPos> scanChunk(IPlayerContext ctx, List<Block> blocks, ChunkPos pos, int max, int yLevelThreshold);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.cache;
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -47,7 +46,7 @@ public class Waypoint implements IWaypoint {
|
||||
* @param location The waypoint location
|
||||
* @param creationTimestamp When the waypoint was created
|
||||
*/
|
||||
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
||||
public Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
||||
this.name = name;
|
||||
this.tag = tag;
|
||||
this.location = location;
|
||||
@@ -20,7 +20,7 @@ package baritone.api.event.events;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Called when the local player interacts with a block, can be either {@link Type#BREAK} or {@link Type#USE}.
|
||||
* Called when the local player interacts with a block, can be either {@link Type#START_BREAK} or {@link Type#USE}.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 8/22/2018
|
||||
@@ -59,9 +59,9 @@ public final class BlockInteractEvent {
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* We're breaking the target block.
|
||||
* We're starting to break the target block.
|
||||
*/
|
||||
BREAK,
|
||||
START_BREAK,
|
||||
|
||||
/**
|
||||
* We're right clicking on the target block. Either placing or interacting with.
|
||||
|
||||
@@ -17,22 +17,20 @@
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.ManagedPlayerEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public final class ChatEvent extends ManagedPlayerEvent.Cancellable {
|
||||
public final class ChatEvent extends Cancellable {
|
||||
|
||||
/**
|
||||
* The message being sent
|
||||
*/
|
||||
private final String message;
|
||||
|
||||
public ChatEvent(EntityPlayerSP player, String message) {
|
||||
super(player);
|
||||
public ChatEvent(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ public final class ChunkEvent {
|
||||
private final EventState state;
|
||||
|
||||
/**
|
||||
* The type of chunk event that occurred;
|
||||
* The type of chunk event that occurred
|
||||
*
|
||||
* @see Type
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
|
||||
@@ -18,22 +18,19 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.api.event.events.type.ManagedPlayerEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/21/2018
|
||||
*/
|
||||
public final class PlayerUpdateEvent extends ManagedPlayerEvent {
|
||||
public final class PlayerUpdateEvent {
|
||||
|
||||
/**
|
||||
* The state of the event
|
||||
*/
|
||||
private final EventState state;
|
||||
|
||||
public PlayerUpdateEvent(EntityPlayerSP player, EventState state) {
|
||||
super(player);
|
||||
public PlayerUpdateEvent(EventState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.ManagedPlayerEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -26,7 +24,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
* @author Brady
|
||||
* @since 8/21/2018
|
||||
*/
|
||||
public final class RotationMoveEvent extends ManagedPlayerEvent {
|
||||
public final class RotationMoveEvent {
|
||||
|
||||
/**
|
||||
* The type of event
|
||||
@@ -38,8 +36,7 @@ public final class RotationMoveEvent extends ManagedPlayerEvent {
|
||||
*/
|
||||
private float yaw;
|
||||
|
||||
public RotationMoveEvent(EntityPlayerSP player, Type type, float yaw) {
|
||||
super(player);
|
||||
public RotationMoveEvent(Type type, float yaw) {
|
||||
this.type = type;
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
35
src/api/java/baritone/api/event/events/SprintStateEvent.java
Normal file
35
src/api/java/baritone/api/event/events/SprintStateEvent.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 1/18/2019
|
||||
*/
|
||||
public final class SprintStateEvent {
|
||||
|
||||
private Boolean state;
|
||||
|
||||
public final void setState(boolean state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public final Boolean getState() {
|
||||
return this.state;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.event.events.type;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
/**
|
||||
* An event that has a reference to a locally managed player.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 10/11/2018
|
||||
*/
|
||||
public class ManagedPlayerEvent {
|
||||
|
||||
protected final EntityPlayerSP player;
|
||||
|
||||
public ManagedPlayerEvent(EntityPlayerSP player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public final EntityPlayerSP getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static class Cancellable extends ManagedPlayerEvent implements ICancellable {
|
||||
|
||||
/**
|
||||
* Whether or not this event has been cancelled
|
||||
*/
|
||||
private boolean cancelled;
|
||||
|
||||
public Cancellable(EntityPlayerSP player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void cancel() {
|
||||
this.cancelled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
||||
@Override
|
||||
default void onPlayerUpdate(PlayerUpdateEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onProcessKeyBinds() {}
|
||||
|
||||
@Override
|
||||
default void onSendChatMessage(ChatEvent event) {}
|
||||
|
||||
@@ -60,6 +57,9 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
||||
@Override
|
||||
default void onPlayerRotationMove(RotationMoveEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onPlayerSprintState(SprintStateEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onBlockInteract(BlockInteractEvent event) {}
|
||||
|
||||
|
||||
@@ -23,13 +23,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiGameOver;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -40,6 +36,7 @@ public interface IGameEventListener {
|
||||
/**
|
||||
* Run once per game tick before screen input is handled.
|
||||
*
|
||||
* @param event The event
|
||||
* @see Minecraft#runTick()
|
||||
*/
|
||||
void onTick(TickEvent event);
|
||||
@@ -47,20 +44,15 @@ public interface IGameEventListener {
|
||||
/**
|
||||
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#onUpdate()
|
||||
*/
|
||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||
|
||||
/**
|
||||
* Run once per game tick from before keybinds are processed.
|
||||
*
|
||||
* @see Minecraft#processKeyBinds()
|
||||
*/
|
||||
void onProcessKeyBinds();
|
||||
|
||||
/**
|
||||
* Runs whenever the client player sends a message to the server.
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#sendChatMessage(String)
|
||||
*/
|
||||
void onSendChatMessage(ChatEvent event);
|
||||
@@ -68,6 +60,7 @@ public interface IGameEventListener {
|
||||
/**
|
||||
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
|
||||
*
|
||||
* @param event The event
|
||||
* @see WorldClient#doPreChunk(int, int, boolean)
|
||||
*/
|
||||
void onChunkEvent(ChunkEvent event);
|
||||
@@ -77,13 +70,14 @@ public interface IGameEventListener {
|
||||
* <p>
|
||||
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
|
||||
*
|
||||
* @see EntityRenderer#renderWorldPass(int, float, long)
|
||||
* @param event The event
|
||||
*/
|
||||
void onRenderPass(RenderEvent event);
|
||||
|
||||
/**
|
||||
* Runs before and after whenever a new world is loaded
|
||||
*
|
||||
* @param event The event
|
||||
* @see Minecraft#loadWorld(WorldClient, String)
|
||||
*/
|
||||
void onWorldEvent(WorldEvent event);
|
||||
@@ -91,7 +85,7 @@ public interface IGameEventListener {
|
||||
/**
|
||||
* Runs before a outbound packet is sent
|
||||
*
|
||||
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see GenericFutureListener
|
||||
*/
|
||||
@@ -100,7 +94,7 @@ public interface IGameEventListener {
|
||||
/**
|
||||
* Runs before an inbound packet is processed
|
||||
*
|
||||
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see GenericFutureListener
|
||||
*/
|
||||
@@ -110,31 +104,37 @@ public interface IGameEventListener {
|
||||
* Run once per game tick from before and after the player's moveRelative method is called
|
||||
* and before and after the player jumps.
|
||||
*
|
||||
* @param event The event
|
||||
* @see Entity#moveRelative(float, float, float, float)
|
||||
* @see EntityLivingBase#jump()
|
||||
*/
|
||||
void onPlayerRotationMove(RotationMoveEvent event);
|
||||
|
||||
/**
|
||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate}
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#onLivingUpdate()
|
||||
*/
|
||||
void onPlayerSprintState(SprintStateEvent event);
|
||||
|
||||
/**
|
||||
* Called when the local player interacts with a block, whether it is breaking or opening/placing.
|
||||
*
|
||||
* @see Minecraft#clickMouse()
|
||||
* @see Minecraft#rightClickMouse()
|
||||
* @param event The event
|
||||
*/
|
||||
void onBlockInteract(BlockInteractEvent event);
|
||||
|
||||
/**
|
||||
* Called when the local player dies, as indicated by the creation of the {@link GuiGameOver} screen.
|
||||
*
|
||||
* @see GuiGameOver(ITextComponent)
|
||||
* @see ITextComponent
|
||||
* @see GuiGameOver
|
||||
*/
|
||||
void onPlayerDeath();
|
||||
|
||||
/**
|
||||
* When the pathfinder's state changes
|
||||
*
|
||||
* @param event
|
||||
* @param event The event
|
||||
*/
|
||||
void onPathEvent(PathEvent event);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.movement.IMovement;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -52,6 +51,8 @@ public interface IPath {
|
||||
/**
|
||||
* This path is actually going to be executed in the world. Do whatever additional processing is required.
|
||||
* (as opposed to Path objects that are just constructed every frame for rendering)
|
||||
*
|
||||
* @return The result of path post processing
|
||||
*/
|
||||
default IPath postProcess() {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -109,8 +110,9 @@ public interface IPath {
|
||||
default double ticksRemainingFrom(int pathPosition) {
|
||||
double sum = 0;
|
||||
//this is fast because we aren't requesting recalculation, it's just cached
|
||||
for (int i = pathPosition; i < movements().size(); i++) {
|
||||
sum += movements().get(i).getCost();
|
||||
List<IMovement> movements = movements();
|
||||
for (int i = pathPosition; i < movements.size(); i++) {
|
||||
sum += movements.get(i).getCost();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@@ -118,10 +120,13 @@ public interface IPath {
|
||||
/**
|
||||
* Cuts off this path at the loaded chunk border, and returns the resulting path. Default
|
||||
* implementation just returns this path, without the intended functionality.
|
||||
* <p>
|
||||
* The argument is supposed to be a BlockStateInterface LOL LOL LOL LOL LOL
|
||||
*
|
||||
* @param bsi The block state lookup, highly cursed
|
||||
* @return The result of this cut-off operation
|
||||
*/
|
||||
default IPath cutoffAtLoadedChunks(World world) {
|
||||
default IPath cutoffAtLoadedChunks(Object bsi) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -129,6 +134,7 @@ public interface IPath {
|
||||
* Cuts off this path using the min length and cutoff factor settings, and returns the resulting path.
|
||||
* Default implementation just returns this path, without the intended functionality.
|
||||
*
|
||||
* @param destination The end goal of this path
|
||||
* @return The result of this cut-off operation
|
||||
* @see Settings#pathCutoffMinimumLength
|
||||
* @see Settings#pathCutoffFactor
|
||||
|
||||
@@ -34,6 +34,8 @@ public interface IPathFinder {
|
||||
/**
|
||||
* Calculate the path in full. Will take several seconds.
|
||||
*
|
||||
* @param primaryTimeout If a path is found, the path finder will stop after this amount of time
|
||||
* @param failureTimeout If a path isn't found, the path finder will continue for this amount of time
|
||||
* @return The final path
|
||||
*/
|
||||
PathCalculationResult calculate(long primaryTimeout, long failureTimeout);
|
||||
|
||||
@@ -22,10 +22,26 @@ import baritone.api.process.PathingCommand;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author leijurv
|
||||
*/
|
||||
public interface IPathingControlManager {
|
||||
|
||||
/**
|
||||
* Registers a process with this pathing control manager. See {@link IBaritoneProcess} for more details.
|
||||
*
|
||||
* @param process The process
|
||||
* @see IBaritoneProcess
|
||||
*/
|
||||
void registerProcess(IBaritoneProcess process);
|
||||
|
||||
/**
|
||||
* @return The most recent {@link IBaritoneProcess} that had control
|
||||
*/
|
||||
Optional<IBaritoneProcess> mostRecentInControl();
|
||||
|
||||
/**
|
||||
* @return The most recent pathing command executed
|
||||
*/
|
||||
Optional<PathingCommand> mostRecentCommand();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public interface Goal {
|
||||
* Returns whether or not the specified position
|
||||
* meets the requirement for this goal based.
|
||||
*
|
||||
* @param x The goal X position
|
||||
* @param y The goal Y position
|
||||
* @param z The goal Z position
|
||||
* @return Whether or not it satisfies this goal
|
||||
*/
|
||||
boolean isInGoal(int x, int y, int z);
|
||||
@@ -37,6 +40,9 @@ public interface Goal {
|
||||
/**
|
||||
* Estimate the number of ticks it will take to get to the goal
|
||||
*
|
||||
* @param x The goal X position
|
||||
* @param y The goal Y position
|
||||
* @param z The goal Z position
|
||||
* @return The estimate number of ticks to satisfy the goal
|
||||
*/
|
||||
double heuristic(int x, int y, int z);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GoalAxis implements Goal {
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
|
||||
return y == BaritoneAPI.getSettings().axisHeight.value && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +39,7 @@ public class GoalAxis implements Goal {
|
||||
|
||||
double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2));
|
||||
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y);
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,17 +30,17 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
/**
|
||||
* The X block position of this goal
|
||||
*/
|
||||
private final int x;
|
||||
public final int x;
|
||||
|
||||
/**
|
||||
* The Y block position of this goal
|
||||
*/
|
||||
private final int y;
|
||||
public final int y;
|
||||
|
||||
/**
|
||||
* The Z block position of this goal
|
||||
*/
|
||||
private final int z;
|
||||
public final int z;
|
||||
|
||||
public GoalBlock(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
@@ -28,9 +28,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public GoalGetToBlock(BlockPos pos) {
|
||||
this.x = pos.getX();
|
||||
|
||||
@@ -61,6 +61,6 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", rangeSq=" + rangeSq +
|
||||
'}';
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
|
||||
*/
|
||||
public class GoalStrictDirection implements Goal {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final int dx;
|
||||
public final int dz;
|
||||
|
||||
public GoalStrictDirection(BlockPos origin, EnumFacing direction) {
|
||||
x = origin.getX();
|
||||
y = origin.getY();
|
||||
z = origin.getZ();
|
||||
dx = direction.getXOffset();
|
||||
dz = direction.getZOffset();
|
||||
if (dx == 0 && dz == 0) {
|
||||
throw new IllegalArgumentException(direction + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {
|
||||
int distanceFromStartInDesiredDirection = (x - this.x) * dx + (z - this.z) * dz;
|
||||
|
||||
int distanceFromStartInIncorrectDirection = Math.abs((x - this.x) * dz) + Math.abs((z - this.z) * dx);
|
||||
|
||||
int verticalDistanceFromStart = Math.abs(y - this.y);
|
||||
|
||||
// we want heuristic to decrease as desiredDirection increases
|
||||
double heuristic = -distanceFromStartInDesiredDirection * 100;
|
||||
|
||||
heuristic += distanceFromStartInIncorrectDirection * 1000;
|
||||
heuristic += verticalDistanceFromStart * 1000;
|
||||
return heuristic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalStrictDirection{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", dx=" + dx +
|
||||
", dz=" + dz +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -31,17 +31,17 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
/**
|
||||
* The X block position of this goal
|
||||
*/
|
||||
private final int x;
|
||||
protected final int x;
|
||||
|
||||
/**
|
||||
* The Y block position of this goal
|
||||
*/
|
||||
private final int y;
|
||||
protected final int y;
|
||||
|
||||
/**
|
||||
* The Z block position of this goal
|
||||
*/
|
||||
private final int z;
|
||||
protected final int z;
|
||||
|
||||
public GoalTwoBlocks(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class GoalXZ implements Goal {
|
||||
diagonal = z;
|
||||
}
|
||||
diagonal *= SQRT_2;
|
||||
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune
|
||||
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune
|
||||
}
|
||||
|
||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
/**
|
||||
* The target Y level
|
||||
*/
|
||||
private final int level;
|
||||
public final int level;
|
||||
|
||||
public GoalYLevel(int level) {
|
||||
this.level = level;
|
||||
|
||||
@@ -20,8 +20,6 @@ package baritone.api.pathing.movement;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/8/2018
|
||||
@@ -47,10 +45,6 @@ public interface IMovement {
|
||||
*/
|
||||
boolean safeToCancel();
|
||||
|
||||
double recalculateCost();
|
||||
|
||||
double calculateCostWithoutCaching();
|
||||
|
||||
boolean calculatedWhileLoaded();
|
||||
|
||||
BetterBlockPos getSrc();
|
||||
@@ -58,10 +52,4 @@ public interface IMovement {
|
||||
BetterBlockPos getDest();
|
||||
|
||||
BlockPos getDirection();
|
||||
|
||||
List<BlockPos> toBreak();
|
||||
|
||||
List<BlockPos> toPlace();
|
||||
|
||||
List<BlockPos> toWalkInto();
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ import baritone.api.pathing.calc.IPath;
|
||||
public interface IPathExecutor {
|
||||
|
||||
IPath getPath();
|
||||
|
||||
int getPosition();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.event.events.PathEvent;
|
||||
|
||||
@@ -25,8 +24,10 @@ import baritone.api.event.events.PathEvent;
|
||||
* A process that can control the PathingBehavior.
|
||||
* <p>
|
||||
* Differences between a baritone process and a behavior:
|
||||
* Only one baritone process can be active at a time
|
||||
* PathingBehavior can only be controlled by a process
|
||||
* <ul>
|
||||
* <li>Only one baritone process can be active at a time</li>
|
||||
* <li>PathingBehavior can only be controlled by a process</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* That's it actually
|
||||
*
|
||||
@@ -34,6 +35,16 @@ import baritone.api.event.events.PathEvent;
|
||||
*/
|
||||
public interface IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Default priority. Most normal processes should have this value.
|
||||
* <p>
|
||||
* Some examples of processes that should have different values might include some kind of automated mob avoidance
|
||||
* that would be temporary and would forcefully take control. Same for something that pauses pathing for auto eat, etc.
|
||||
* <p>
|
||||
* The value is -1 beacuse that's what Impact 4.5's beta auto walk returns and I want to tie with it.
|
||||
*/
|
||||
double DEFAULT_PRIORITY = -1;
|
||||
|
||||
/**
|
||||
* Would this process like to be in control?
|
||||
*
|
||||
@@ -81,19 +92,23 @@ public interface IBaritoneProcess {
|
||||
*
|
||||
* @return A double representing the priority
|
||||
*/
|
||||
double priority();
|
||||
|
||||
/**
|
||||
* Returns which bot this process is associated with. (5000000iq forward thinking)
|
||||
*
|
||||
* @return The Bot associated with this process
|
||||
*/
|
||||
IBaritone associatedWith();
|
||||
default double priority() {
|
||||
return DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user-friendly name for this process. Suitable for a HUD.
|
||||
*
|
||||
* @return A display name that's suitable for a HUD
|
||||
*/
|
||||
String displayName();
|
||||
default String displayName() {
|
||||
if (!isActive()) {
|
||||
// i love it when impcat's scuffed HUD calls displayName for inactive processes for 1 tick too long
|
||||
// causing NPEs when the displayname relies on fields that become null when inactive
|
||||
return "INACTIVE";
|
||||
}
|
||||
return displayName0();
|
||||
}
|
||||
|
||||
String displayName0();
|
||||
}
|
||||
|
||||
64
src/api/java/baritone/api/process/IBuilderProcess.java
Normal file
64
src/api/java/baritone/api/process/IBuilderProcess.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.utils.ISchematic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 1/15/2019
|
||||
*/
|
||||
public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
|
||||
*
|
||||
* @param name A user-friendly name for the schematic
|
||||
* @param schematic The object representation of the schematic
|
||||
* @param origin The origin position of the schematic being built
|
||||
*/
|
||||
void build(String name, ISchematic schematic, Vec3i origin);
|
||||
|
||||
/**
|
||||
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
|
||||
*
|
||||
* @param name A user-friendly name for the schematic
|
||||
* @param schematic The file path of the schematic
|
||||
* @param origin The origin position of the schematic being built
|
||||
* @return Whether or not the schematic was able to load from file
|
||||
*/
|
||||
boolean build(String name, File schematic, Vec3i origin);
|
||||
|
||||
default boolean build(String schematicFile, BlockPos origin) {
|
||||
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
|
||||
return build(schematicFile, file, origin);
|
||||
}
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void pause();
|
||||
|
||||
void resume();
|
||||
|
||||
void clearArea(BlockPos corner1, BlockPos corner2);
|
||||
}
|
||||
26
src/api/java/baritone/api/process/IExploreProcess.java
Normal file
26
src/api/java/baritone/api/process/IExploreProcess.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IExploreProcess extends IBaritoneProcess {
|
||||
void explore(int centerX, int centerZ);
|
||||
|
||||
void applyJsonFilter(Path path, boolean invert) throws Exception;
|
||||
}
|
||||
22
src/api/java/baritone/api/process/IFarmProcess.java
Normal file
22
src/api/java/baritone/api/process/IFarmProcess.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
public interface IFarmProcess extends IBaritoneProcess {
|
||||
void farm();
|
||||
}
|
||||
@@ -25,4 +25,6 @@ import net.minecraft.block.Block;
|
||||
public interface IGetToBlockProcess extends IBaritoneProcess {
|
||||
|
||||
void getToBlock(Block block);
|
||||
|
||||
boolean blacklistClosest();
|
||||
}
|
||||
|
||||
@@ -53,4 +53,9 @@ public class PathingCommand {
|
||||
this.goal = goal;
|
||||
this.commandType = commandType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return commandType + " " + goal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,5 +51,10 @@ public enum PathingCommandType {
|
||||
* <p>
|
||||
* Cancel the current path if the goals are not equal
|
||||
*/
|
||||
FORCE_REVALIDATE_GOAL_AND_PATH
|
||||
FORCE_REVALIDATE_GOAL_AND_PATH,
|
||||
|
||||
/**
|
||||
* Go and ask the next process what to do
|
||||
*/
|
||||
DEFER
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ public final class BetterBlockPos extends BlockPos {
|
||||
}
|
||||
|
||||
public static long longHash(int x, int y, int z) {
|
||||
// TODO use the same thing as BlockPos.fromLong();
|
||||
// invertibility would be incredibly useful
|
||||
/*
|
||||
* This is the hashcode implementation of Vec3i (the superclass of the class which I shall not name)
|
||||
*
|
||||
|
||||
63
src/api/java/baritone/api/utils/BlockUtils.java
Normal file
63
src/api/java/baritone/api/utils/BlockUtils.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockUtils {
|
||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||
|
||||
public static String blockToString(Block block) {
|
||||
ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
|
||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||
if (!loc.getNamespace().equals("minecraft")) {
|
||||
// Baritone is running on top of forge with mods installed, perhaps?
|
||||
name = loc.toString(); // include the namespace with the colon
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Block stringToBlockRequired(String name) {
|
||||
Block block = stringToBlockNullable(name);
|
||||
Objects.requireNonNull(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
public static Block stringToBlockNullable(String name) {
|
||||
// do NOT just replace this with a computeWithAbsent, it isn't thread safe
|
||||
Block block = resourceCache.get(name); // map is never mutated in place so this is safe
|
||||
if (block != null) {
|
||||
return block;
|
||||
}
|
||||
if (resourceCache.containsKey(name)) {
|
||||
return null; // cached as null
|
||||
}
|
||||
block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
|
||||
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||
copy.put(name, block);
|
||||
resourceCache = copy;
|
||||
return block;
|
||||
}
|
||||
|
||||
private BlockUtils() {}
|
||||
}
|
||||
749
src/api/java/baritone/api/utils/ExampleBaritoneControl.java
Normal file
749
src/api/java/baritone/api/utils/ExampleBaritoneControl.java
Normal file
@@ -0,0 +1,749 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IRememberedInventory;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.pathing.goals.*;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.commons.lang3.math.NumberUtils.isCreatable;
|
||||
|
||||
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
|
||||
private static final String COMMAND_PREFIX = "#";
|
||||
|
||||
public final IBaritone baritone;
|
||||
public final IPlayerContext ctx;
|
||||
|
||||
public ExampleBaritoneControl(IBaritone baritone) {
|
||||
this.baritone = baritone;
|
||||
this.ctx = baritone.getPlayerContext();
|
||||
baritone.getGameEventHandler().registerEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendChatMessage(ChatEvent event) {
|
||||
String msg = event.getMessage();
|
||||
if (BaritoneAPI.getSettings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) {
|
||||
if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) {
|
||||
logDirect("Invalid command");
|
||||
}
|
||||
event.cancel(); // always cancel if using prefixControl
|
||||
return;
|
||||
}
|
||||
if (!BaritoneAPI.getSettings().chatControl.value && !BaritoneAPI.getSettings().removePrefix.value) {
|
||||
return;
|
||||
}
|
||||
if (runCommand(msg)) {
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =)
|
||||
String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL
|
||||
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
List<Settings.Setting<Boolean>> toggleable = BaritoneAPI.getSettings().getAllValuesByType(Boolean.class);
|
||||
for (Settings.Setting<Boolean> setting : toggleable) {
|
||||
if (msg.equalsIgnoreCase(setting.getName())) {
|
||||
setting.value ^= true;
|
||||
logDirect("Toggled " + setting.getName() + " to " + setting.value);
|
||||
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (msg.equals("baritone") || msg.equals("modifiedsettings") || msg.startsWith("settings m") || msg.equals("modified")) {
|
||||
logDirect("All settings that have been modified from their default values:");
|
||||
for (Settings.Setting<?> setting : SettingsUtil.modifiedSettings(BaritoneAPI.getSettings())) {
|
||||
logDirect(setting.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("settings")) {
|
||||
String rest = msg.substring("settings".length());
|
||||
try {
|
||||
int page = Integer.parseInt(rest.trim());
|
||||
int min = page * 10;
|
||||
int max = Math.min(BaritoneAPI.getSettings().allSettings.size(), (page + 1) * 10);
|
||||
logDirect("Settings " + min + " to " + (max - 1) + ":");
|
||||
for (int i = min; i < max; i++) {
|
||||
logDirect(BaritoneAPI.getSettings().allSettings.get(i).toString());
|
||||
}
|
||||
} catch (Exception ex) { // NumberFormatException | ArrayIndexOutOfBoundsException and probably some others I'm forgetting lol
|
||||
ex.printStackTrace();
|
||||
logDirect("All settings:");
|
||||
for (Settings.Setting<?> setting : BaritoneAPI.getSettings().allSettings) {
|
||||
logDirect(setting.toString());
|
||||
}
|
||||
logDirect("To get one page of ten settings at a time, do settings <num>");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("") || msg.equals("help") || msg.equals("?")) {
|
||||
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
TextComponentString helpLink = new TextComponentString(" Click here for instructions on how to use Baritone (https://github.com/cabaletta/baritone/blob/master/USAGE.md)");
|
||||
helpLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/cabaletta/baritone/blob/master/USAGE.md"));
|
||||
component.appendSibling(helpLink);
|
||||
BaritoneAPI.getSettings().logger.value.accept(component);
|
||||
return true;
|
||||
}
|
||||
if (msg.contains(" ")) {
|
||||
String settingName = msg.substring(0, msg.indexOf(' '));
|
||||
String settingValue = msg.substring(msg.indexOf(' ') + 1);
|
||||
Settings.Setting setting = BaritoneAPI.getSettings().byLowerName.get(settingName);
|
||||
if (setting != null) {
|
||||
if (settingValue.equals("reset")) {
|
||||
logDirect("Resetting setting " + settingName + " to default value.");
|
||||
setting.reset();
|
||||
} else {
|
||||
try {
|
||||
SettingsUtil.parseAndApply(BaritoneAPI.getSettings(), settingName, settingValue);
|
||||
} catch (Exception ex) {
|
||||
logDirect("Unable to parse setting");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||
logDirect(setting.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (BaritoneAPI.getSettings().byLowerName.containsKey(msg)) {
|
||||
Settings.Setting<?> setting = BaritoneAPI.getSettings().byLowerName.get(msg);
|
||||
logDirect(setting.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.startsWith("goal")) {
|
||||
String rest = msg.substring(4).trim();
|
||||
Goal goal;
|
||||
if (rest.equals("clear") || rest.equals("none")) {
|
||||
goal = null;
|
||||
} else {
|
||||
String[] params = rest.split(" ");
|
||||
if (params[0].equals("")) {
|
||||
params = new String[]{};
|
||||
}
|
||||
goal = parseGoal(params);
|
||||
if (goal == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
customGoalProcess.setGoal(goal);
|
||||
logDirect("Goal: " + goal);
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("crash")) {
|
||||
StringBuilder meme = new StringBuilder();
|
||||
CrashReport rep = new CrashReport("Manually triggered debug crash", new Throwable());
|
||||
mc.addGraphicsAndWorldToCrashReport(rep);
|
||||
new ReportedException(rep).printStackTrace();
|
||||
rep.getSectionsInStringBuilder(meme);
|
||||
System.out.println(meme);
|
||||
logDirect(meme.toString());
|
||||
logDirect("ok");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("path")) {
|
||||
if (pathingBehavior.getGoal() == null) {
|
||||
logDirect("No goal.");
|
||||
} else if (pathingBehavior.getGoal().isInGoal(ctx.playerFeet())) {
|
||||
logDirect("Already in goal");
|
||||
} else if (pathingBehavior.isPathing()) {
|
||||
logDirect("Currently executing a path. Please cancel it first.");
|
||||
} else {
|
||||
customGoalProcess.setGoalAndPath(pathingBehavior.getGoal());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*if (msg.equals("fullpath")) {
|
||||
if (pathingBehavior.getGoal() == null) {
|
||||
logDirect("No goal.");
|
||||
} else {
|
||||
logDirect("Started segmented calculator");
|
||||
SegmentedCalculator.calculateSegmentsThreaded(pathingBehavior.pathStart(), pathingBehavior.getGoal(), new CalculationContext(baritone, true), ipath -> {
|
||||
logDirect("Found a path");
|
||||
logDirect("Ends at " + ipath.getDest());
|
||||
logDirect("Length " + ipath.length());
|
||||
logDirect("Estimated time " + ipath.ticksRemainingFrom(0));
|
||||
pathingBehavior.secretCursedFunctionDoNotCall(ipath); // it's okay when *I* do it
|
||||
}, () -> {
|
||||
logDirect("Path calculation failed, no path");
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
if (msg.equals("proc")) {
|
||||
Optional<IBaritoneProcess> proc = baritone.getPathingControlManager().mostRecentInControl();
|
||||
if (!proc.isPresent()) {
|
||||
logDirect("No process is in control");
|
||||
return true;
|
||||
}
|
||||
IBaritoneProcess p = proc.get();
|
||||
logDirect("Class: " + p.getClass());
|
||||
logDirect("Priority: " + p.priority());
|
||||
logDirect("Temporary: " + p.isTemporary());
|
||||
logDirect("Display name: " + p.displayName());
|
||||
logDirect("Command: " + baritone.getPathingControlManager().mostRecentCommand());
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("version")) {
|
||||
String version = ExampleBaritoneControl.class.getPackage().getImplementationVersion();
|
||||
if (version == null) {
|
||||
logDirect("No version detected. Either dev environment or broken install.");
|
||||
} else {
|
||||
logDirect("You are using Baritone v" + version);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("repack") || msg.equals("rescan")) {
|
||||
logDirect("Queued " + repack() + " chunks for repacking");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("build")) {
|
||||
String file;
|
||||
BlockPos origin;
|
||||
try {
|
||||
String[] coords = msg.substring("build".length()).trim().split(" ");
|
||||
file = coords[0] + ".schematic";
|
||||
origin = new BlockPos(parseOrDefault(coords[1], ctx.playerFeet().x, 1), parseOrDefault(coords[2], ctx.playerFeet().y, 1), parseOrDefault(coords[3], ctx.playerFeet().z, 1));
|
||||
} catch (Exception ex) {
|
||||
file = msg.substring(5).trim() + ".schematic";
|
||||
origin = ctx.playerFeet();
|
||||
}
|
||||
logDirect("Loading '" + file + "' to build from origin " + origin);
|
||||
boolean success = baritone.getBuilderProcess().build(file, origin);
|
||||
logDirect(success ? "Loaded" : "Unable to load");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("schematica")) {
|
||||
baritone.getBuilderProcess().buildOpenSchematic();
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("come")) {
|
||||
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
|
||||
logDirect("Coming");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("axis") || msg.equals("highway")) {
|
||||
customGoalProcess.setGoalAndPath(new GoalAxis());
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("cancel") || msg.equals("stop")) {
|
||||
pathingBehavior.cancelEverything();
|
||||
logDirect("ok canceled");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("forcecancel")) {
|
||||
pathingBehavior.cancelEverything();
|
||||
pathingBehavior.forceCancel();
|
||||
logDirect("ok force canceled");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("gc")) {
|
||||
System.gc();
|
||||
logDirect("Called System.gc();");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("invert")) {
|
||||
Goal goal = pathingBehavior.getGoal();
|
||||
BlockPos runAwayFrom;
|
||||
if (goal instanceof GoalXZ) {
|
||||
runAwayFrom = new BlockPos(((GoalXZ) goal).getX(), 0, ((GoalXZ) goal).getZ());
|
||||
} else if (goal instanceof GoalBlock) {
|
||||
runAwayFrom = ((GoalBlock) goal).getGoalPos();
|
||||
} else {
|
||||
logDirect("Goal must be GoalXZ or GoalBlock to invert");
|
||||
logDirect("Inverting goal of player feet");
|
||||
runAwayFrom = ctx.playerFeet();
|
||||
}
|
||||
customGoalProcess.setGoalAndPath(new GoalRunAway(1, runAwayFrom) {
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("cleararea")) {
|
||||
String suffix = msg.substring("cleararea".length());
|
||||
BlockPos corner1;
|
||||
BlockPos corner2;
|
||||
if (suffix.isEmpty()) {
|
||||
// clear the area from the current goal to here
|
||||
Goal goal = baritone.getPathingBehavior().getGoal();
|
||||
if (!(goal instanceof GoalBlock)) {
|
||||
logDirect("Need to specify goal of opposite corner");
|
||||
return true;
|
||||
}
|
||||
corner1 = ((GoalBlock) goal).getGoalPos();
|
||||
corner2 = ctx.playerFeet();
|
||||
} else {
|
||||
try {
|
||||
String[] spl = suffix.split(" ");
|
||||
corner1 = ctx.playerFeet();
|
||||
corner2 = new BlockPos(Integer.parseInt(spl[0]), Integer.parseInt(spl[1]), Integer.parseInt(spl[2]));
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {
|
||||
logDirect("unable to parse");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
baritone.getBuilderProcess().clearArea(corner1, corner2);
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("resume")) {
|
||||
baritone.getBuilderProcess().resume();
|
||||
logDirect("resumed");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("pause")) {
|
||||
baritone.getBuilderProcess().pause();
|
||||
logDirect("paused");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("reset")) {
|
||||
for (Settings.Setting setting : BaritoneAPI.getSettings().allSettings) {
|
||||
setting.reset();
|
||||
}
|
||||
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||
logDirect("Baritone settings reset");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("tunnel")) {
|
||||
customGoalProcess.setGoalAndPath(new GoalStrictDirection(ctx.playerFeet(), ctx.player().getHorizontalFacing()));
|
||||
logDirect("tunneling");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("render")) {
|
||||
BetterBlockPos pf = ctx.playerFeet();
|
||||
int dist = (Minecraft.getMinecraft().gameSettings.renderDistanceChunks + 1) * 16;
|
||||
Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pf.x - dist, pf.y - 256, pf.z - dist, pf.x + dist, pf.y + 256, pf.z + dist);
|
||||
logDirect("okay");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("farm")) {
|
||||
baritone.getFarmProcess().farm();
|
||||
logDirect("farming");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("chests")) {
|
||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
||||
logDirect(entry.getKey() + "");
|
||||
log(entry.getValue().getContents());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("followentities")) {
|
||||
baritone.getFollowProcess().follow(Entity.class::isInstance);
|
||||
logDirect("Following any entities");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("followplayers")) {
|
||||
baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A
|
||||
logDirect("Following any players");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("followentity")) {
|
||||
String name = msg.substring(12).trim();
|
||||
Optional<Entity> toFollow = Optional.empty();
|
||||
for (Entity entity : ctx.world().loadedEntityList) {
|
||||
String entityName = entity.getName().trim().toLowerCase();
|
||||
if ((entityName.contains(name) || name.contains(entityName)) && !(entity instanceof EntityItem || entity instanceof EntityPlayer)) { // We dont want it following players while `#follow` exists.
|
||||
toFollow = Optional.of(entity);
|
||||
}
|
||||
}
|
||||
if (!toFollow.isPresent()) {
|
||||
logDirect("Entity not found");
|
||||
return true;
|
||||
}
|
||||
Entity effectivelyFinal = toFollow.get();
|
||||
baritone.getFollowProcess().follow(effectivelyFinal::equals);
|
||||
logDirect("Following entity " + toFollow.get());
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("follow")) {
|
||||
String name = msg.substring(6).trim();
|
||||
Optional<Entity> toFollow = Optional.empty();
|
||||
if (name.length() == 0) {
|
||||
toFollow = ctx.getSelectedEntity();
|
||||
} else {
|
||||
for (EntityPlayer pl : ctx.world().playerEntities) {
|
||||
String theirName = pl.getName().trim().toLowerCase();
|
||||
if (!theirName.equals(ctx.player().getName().trim().toLowerCase()) && (theirName.contains(name) || name.contains(theirName))) { // don't follow ourselves lol
|
||||
toFollow = Optional.of(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!toFollow.isPresent()) {
|
||||
logDirect("Not found");
|
||||
return true;
|
||||
}
|
||||
Entity effectivelyFinal = toFollow.get();
|
||||
baritone.getFollowProcess().follow(effectivelyFinal::equals);
|
||||
logDirect("Following " + toFollow.get());
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("explorefilter")) {
|
||||
// explorefilter blah.json
|
||||
// means that entries in blah.json are already explored
|
||||
// explorefilter blah.json invert
|
||||
// means that entries in blah.json are NOT already explored
|
||||
String path = msg.substring("explorefilter".length()).trim();
|
||||
String[] parts = path.split(" ");
|
||||
Path path1 = Minecraft.getMinecraft().gameDir.toPath().resolve(parts[0]);
|
||||
boolean invert = parts.length > 1;
|
||||
try {
|
||||
baritone.getExploreProcess().applyJsonFilter(path1, invert);
|
||||
logDirect("Loaded filter. Inverted: " + invert);
|
||||
if (invert) {
|
||||
logDirect("Chunks on this list will be treated as possibly unexplored, all others will be treated as certainly explored");
|
||||
} else {
|
||||
logDirect("Chunks on this list will be treated as certainly explored, all others will be treated as possibly unexplored");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logDirect("Unable to load " + path1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("reloadall")) {
|
||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().reloadAllFromDisk();
|
||||
logDirect("ok");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("saveall")) {
|
||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().save();
|
||||
logDirect("ok");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("explore")) {
|
||||
String rest = msg.substring("explore".length()).trim();
|
||||
int centerX;
|
||||
int centerZ;
|
||||
try {
|
||||
centerX = Integer.parseInt(rest.split(" ")[0]);
|
||||
centerZ = Integer.parseInt(rest.split(" ")[1]);
|
||||
} catch (Exception ex) {
|
||||
centerX = ctx.playerFeet().x;
|
||||
centerZ = ctx.playerFeet().z;
|
||||
}
|
||||
baritone.getExploreProcess().explore(centerX, centerZ);
|
||||
logDirect("Exploring from " + centerX + "," + centerZ);
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("blacklist")) {
|
||||
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
||||
if (!proc.isActive()) {
|
||||
logDirect("GetToBlockProcess is not currently active");
|
||||
return true;
|
||||
}
|
||||
if (proc.blacklistClosest()) {
|
||||
logDirect("Blacklisted closest instances");
|
||||
} else {
|
||||
logDirect("No known locations, unable to blacklist");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("find")) {
|
||||
repack();
|
||||
String blockType = msg.substring(4).trim();
|
||||
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
|
||||
logDirect("Have " + locs.size() + " locations");
|
||||
for (BlockPos pos : locs) {
|
||||
Block actually = ctx.world().getBlockState(pos).getBlock();
|
||||
if (!BlockUtils.blockToString(actually).equalsIgnoreCase(blockType)) {
|
||||
logDebug("Was looking for " + blockType + " but actually found " + actually + " " + BlockUtils.blockToString(actually));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("mine")) {
|
||||
repack();
|
||||
String[] blockTypes = msg.substring(4).trim().split(" ");
|
||||
try {
|
||||
int quantity = Integer.parseInt(blockTypes[1]);
|
||||
Block block = BlockUtils.stringToBlockRequired(blockTypes[0]);
|
||||
baritone.getMineProcess().mine(quantity, block);
|
||||
logDirect("Will mine " + quantity + " " + blockTypes[0]);
|
||||
return true;
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
|
||||
for (String s : blockTypes) {
|
||||
if (BlockUtils.stringToBlockNullable(s) == null) {
|
||||
logDirect(s + " isn't a valid block name");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
baritone.getMineProcess().mineByName(0, blockTypes);
|
||||
logDirect("Started mining blocks of type " + Arrays.toString(blockTypes));
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("click")) {
|
||||
baritone.openClick();
|
||||
logDirect("aight dude");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("thisway") || msg.startsWith("forward")) {
|
||||
try {
|
||||
Goal goal = GoalXZ.fromDirection(ctx.playerFeetAsVec(), ctx.player().rotationYaw, Double.parseDouble(msg.substring(7).trim()));
|
||||
customGoalProcess.setGoal(goal);
|
||||
logDirect("Goal: " + goal);
|
||||
} catch (NumberFormatException ex) {
|
||||
logDirect("Error unable to parse '" + msg.substring(7).trim() + "' to a double.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("list") || msg.startsWith("get ") || msg.startsWith("show")) {
|
||||
String waypointType = msg.substring(4).trim();
|
||||
if (waypointType.endsWith("s")) {
|
||||
// for example, "show deaths"
|
||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
||||
}
|
||||
IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
|
||||
if (tag == null) {
|
||||
logDirect("Not a valid tag. Tags are: " + Arrays.asList(IWaypoint.Tag.values()).toString().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag);
|
||||
// might as well show them from oldest to newest
|
||||
List<IWaypoint> sorted = new ArrayList<>(waypoints);
|
||||
sorted.sort(Comparator.comparingLong(IWaypoint::getCreationTimestamp));
|
||||
logDirect("Waypoints under tag " + tag + ":");
|
||||
for (IWaypoint waypoint : sorted) {
|
||||
logDirect(waypoint.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("save")) {
|
||||
String name = msg.substring(4).trim();
|
||||
BlockPos pos = ctx.playerFeet();
|
||||
if (name.contains(" ")) {
|
||||
logDirect("Name contains a space, assuming it's in the format 'save waypointName X Y Z'");
|
||||
String[] parts = name.split(" ");
|
||||
if (parts.length != 4) {
|
||||
logDirect("Unable to parse, expected four things");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
pos = new BlockPos(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]));
|
||||
} catch (NumberFormatException ex) {
|
||||
logDirect("Unable to parse coordinate integers");
|
||||
return true;
|
||||
}
|
||||
name = parts[0];
|
||||
}
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, IWaypoint.Tag.USER, pos));
|
||||
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("delete")) {
|
||||
String name = msg.substring(6).trim();
|
||||
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
|
||||
if (waypoint == null) {
|
||||
logDirect("No user defined position under the name '" + name + "' found.");
|
||||
return true;
|
||||
}
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().removeWaypoint(waypoint);
|
||||
logDirect("Deleted user defined position under name '" + name + "'.");
|
||||
return true;
|
||||
}
|
||||
if (msg.startsWith("goto")) {
|
||||
repack();
|
||||
String waypointType = msg.substring(4).trim();
|
||||
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
|
||||
// for example, "show deaths"
|
||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
||||
}
|
||||
IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
|
||||
IWaypoint waypoint;
|
||||
if (tag == null) {
|
||||
String mining = waypointType;
|
||||
Block block = BlockUtils.stringToBlockNullable(mining);
|
||||
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||
if (block == null) {
|
||||
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
||||
if (waypoint == null) {
|
||||
Goal goal = parseGoal(waypointType.split(" "));
|
||||
if (goal != null) {
|
||||
logDirect("Going to " + goal);
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
baritone.getGetToBlockProcess().getToBlock(block);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(tag);
|
||||
if (waypoint == null) {
|
||||
logDirect("None saved for tag " + tag);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Goal goal = waypoint.getTag() == IWaypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation());
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("spawn") || msg.equals("bed")) {
|
||||
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.BED);
|
||||
if (waypoint == null) {
|
||||
BlockPos spawnPoint = ctx.player().getBedLocation();
|
||||
// for some reason the default spawnpoint is underground sometimes
|
||||
Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getZ());
|
||||
logDirect("spawn not saved, defaulting to world spawn. set goal to " + goal);
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
} else {
|
||||
Goal goal = new GoalGetToBlock(waypoint.getLocation());
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
logDirect("Set goal to most recent bed " + goal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("sethome")) {
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", IWaypoint.Tag.HOME, ctx.playerFeet()));
|
||||
logDirect("Saved. Say home to set goal.");
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("home")) {
|
||||
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.HOME);
|
||||
if (waypoint == null) {
|
||||
logDirect("home not saved");
|
||||
} else {
|
||||
Goal goal = new GoalBlock(waypoint.getLocation());
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
logDirect("Going to saved home " + goal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (msg.equals("damn")) {
|
||||
logDirect("daniel");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int repack() {
|
||||
ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider();
|
||||
int playerChunkX = ctx.playerFeet().getX() >> 4;
|
||||
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
|
||||
int count = 0;
|
||||
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
||||
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
||||
Chunk chunk = cli.getLoadedChunk(x, z);
|
||||
if (chunk != null && !chunk.isEmpty()) {
|
||||
count++;
|
||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private int parseOrDefault(String str, int i, double dimensionFactor) {
|
||||
return str.equals("~") ? i : str.startsWith("~") ? (int) (Integer.parseInt(str.substring(1)) * dimensionFactor) + i : (int) (Integer.parseInt(str) * dimensionFactor);
|
||||
}
|
||||
|
||||
private void log(List<ItemStack> stacks) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (!stack.isEmpty()) {
|
||||
logDirect(stack.getCount() + "x " + stack.getDisplayName() + "@" + stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Goal parseGoal(String[] params) {
|
||||
Goal goal;
|
||||
try {
|
||||
BetterBlockPos playerFeet = ctx.playerFeet();
|
||||
|
||||
int length = params.length - 1; // length has to be smaller when a dimension parameter is added
|
||||
if (params.length < 1 || (isCreatable(params[params.length - 1]) || params[params.length - 1].startsWith("~"))) {
|
||||
length = params.length;
|
||||
}
|
||||
switch (length) {
|
||||
case 0:
|
||||
goal = new GoalBlock(playerFeet);
|
||||
break;
|
||||
case 1:
|
||||
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y, 1));
|
||||
break;
|
||||
case 2:
|
||||
goal = new GoalXZ(parseOrDefault(params[0], playerFeet.x, calculateDimensionFactor(params[params.length - 1])), parseOrDefault(params[1], playerFeet.z, calculateDimensionFactor(params[params.length - 1])));
|
||||
break;
|
||||
case 3:
|
||||
goal = new GoalBlock(new BlockPos(parseOrDefault(params[0], playerFeet.x, calculateDimensionFactor(params[params.length - 1])), parseOrDefault(params[1], playerFeet.y, 1), parseOrDefault(params[2], playerFeet.z, calculateDimensionFactor(params[params.length - 1]))));
|
||||
break;
|
||||
default:
|
||||
logDirect("unable to understand lol");
|
||||
return null;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
logDirect("unable to parse integer " + ex);
|
||||
return null;
|
||||
}
|
||||
return goal;
|
||||
}
|
||||
|
||||
|
||||
private double calculateDimensionFactor(String to) {
|
||||
return Math.pow(8, ctx.world().provider.getDimensionType().getId() - getDimensionByName(to.toLowerCase()).getId());
|
||||
}
|
||||
|
||||
private DimensionType getDimensionByName(String name) {
|
||||
if ("the_end".contains(name)) {
|
||||
return DimensionType.THE_END;
|
||||
}
|
||||
if ("the_overworld".contains(name) || "surface".contains(name)) {
|
||||
return DimensionType.OVERWORLD;
|
||||
}
|
||||
if ("the_nether".contains(name) || "hell".contains(name)) {
|
||||
return DimensionType.NETHER;
|
||||
}
|
||||
return ctx.world().provider.getDimensionType();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +1,72 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public interface Helper {
|
||||
|
||||
/**
|
||||
* Instance of {@link Helper}. Used for static-context reference.
|
||||
*/
|
||||
Helper HELPER = new Helper() {};
|
||||
|
||||
ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format(
|
||||
"%s[%sBaritone%s]%s",
|
||||
TextFormatting.DARK_PURPLE,
|
||||
TextFormatting.LIGHT_PURPLE,
|
||||
TextFormatting.DARK_PURPLE,
|
||||
TextFormatting.GRAY
|
||||
));
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/**
|
||||
* Send a message to chat only if chatDebug is on
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
default void logDebug(String message) {
|
||||
if (!Baritone.settings().chatDebug.get()) {
|
||||
//System.out.println("Suppressed debug message:");
|
||||
//System.out.println(message);
|
||||
return;
|
||||
}
|
||||
logDirect(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command)
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
default void logDirect(String message) {
|
||||
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(new TextComponentString(" " + message));
|
||||
Baritone.settings().logger.get().accept(component);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public interface Helper {
|
||||
|
||||
/**
|
||||
* Instance of {@link Helper}. Used for static-context reference.
|
||||
*/
|
||||
Helper HELPER = new Helper() {};
|
||||
|
||||
ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format(
|
||||
"%s[%sBaritone%s]%s",
|
||||
TextFormatting.DARK_PURPLE,
|
||||
TextFormatting.LIGHT_PURPLE,
|
||||
TextFormatting.DARK_PURPLE,
|
||||
TextFormatting.GRAY
|
||||
));
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/**
|
||||
* Send a message to chat only if chatDebug is on
|
||||
*
|
||||
* @param message The message to display in chat
|
||||
*/
|
||||
default void logDebug(String message) {
|
||||
if (!BaritoneAPI.getSettings().chatDebug.value) {
|
||||
//System.out.println("Suppressed debug message:");
|
||||
//System.out.println(message);
|
||||
return;
|
||||
}
|
||||
logDirect(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command)
|
||||
*
|
||||
* @param message The message to display in chat
|
||||
*/
|
||||
default void logDirect(String message) {
|
||||
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(new TextComponentString(" " + message));
|
||||
Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ package baritone.api.utils;
|
||||
|
||||
import baritone.api.behavior.IBehavior;
|
||||
import baritone.api.utils.input.Input;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -27,10 +26,6 @@ import net.minecraft.client.settings.KeyBinding;
|
||||
*/
|
||||
public interface IInputOverrideHandler extends IBehavior {
|
||||
|
||||
default boolean isInputForcedDown(KeyBinding key) {
|
||||
return isInputForcedDown(Input.getInputForBind(key));
|
||||
}
|
||||
|
||||
boolean isInputForcedDown(Input input);
|
||||
|
||||
void setInputForceState(Input input, boolean forced);
|
||||
|
||||
@@ -20,7 +20,6 @@ package baritone.api.utils;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -37,7 +36,7 @@ public interface IPlayerContext {
|
||||
|
||||
EntityPlayerSP player();
|
||||
|
||||
PlayerControllerMP playerController();
|
||||
IPlayerController playerController();
|
||||
|
||||
World world();
|
||||
|
||||
@@ -72,20 +71,26 @@ public interface IPlayerContext {
|
||||
* @return The position of the highlighted block
|
||||
*/
|
||||
default Optional<BlockPos> getSelectedBlock() {
|
||||
if (objectMouseOver() != null && objectMouseOver().typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return Optional.of(objectMouseOver().getBlockPos());
|
||||
RayTraceResult result = objectMouseOver();
|
||||
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return Optional.of(result.getBlockPos());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default boolean isLookingAt(BlockPos pos) {
|
||||
return getSelectedBlock().equals(Optional.of(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity that the crosshair is currently placed over. Updated once per tick.
|
||||
*
|
||||
* @return The entity
|
||||
*/
|
||||
default Optional<Entity> getSelectedEntity() {
|
||||
if (objectMouseOver() != null && objectMouseOver().typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||
return Optional.of(objectMouseOver().entityHit);
|
||||
RayTraceResult result = objectMouseOver();
|
||||
if (result != null && result.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||
return Optional.of(result.entityHit);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
55
src/api/java/baritone/api/utils/IPlayerController.java
Normal file
55
src/api/java/baritone/api/utils/IPlayerController.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 12/14/2018
|
||||
*/
|
||||
public interface IPlayerController {
|
||||
|
||||
boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side);
|
||||
|
||||
void resetBlockRemoving();
|
||||
|
||||
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player);
|
||||
|
||||
void setGameType(GameType type);
|
||||
|
||||
GameType getGameType();
|
||||
|
||||
default double getBlockReachDistance() {
|
||||
return this.getGameType().isCreative() ? 5.0F : 4.5F;
|
||||
}
|
||||
|
||||
EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand);
|
||||
|
||||
EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand);
|
||||
}
|
||||
85
src/api/java/baritone/api/utils/ISchematic.java
Normal file
85
src/api/java/baritone/api/utils/ISchematic.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Basic representation of a schematic. Provides the dimensions and
|
||||
* the desired statefor a given position relative to the origin.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public interface ISchematic {
|
||||
|
||||
/**
|
||||
* Does the block at this coordinate matter to the schematic?
|
||||
* <p>
|
||||
* Normally just a check for if the coordinate is in the cube.
|
||||
* <p>
|
||||
* However, in the case of something like a map art, anything that's below the level of the map art doesn't matter,
|
||||
* so this function should return false in that case. (i.e. it doesn't really have to be air below the art blocks)
|
||||
*
|
||||
* @param x The x position of the block, relative to the origin
|
||||
* @param y The y position of the block, relative to the origin
|
||||
* @param z The z position of the block, relative to the origin
|
||||
* @return Whether or not the specified position is within the bounds of this schematic
|
||||
*/
|
||||
default boolean inSchematic(int x, int y, int z) {
|
||||
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
||||
}
|
||||
|
||||
default int size(EnumFacing.Axis axis) {
|
||||
switch (axis) {
|
||||
case X:
|
||||
return widthX();
|
||||
case Y:
|
||||
return heightY();
|
||||
case Z:
|
||||
return lengthZ();
|
||||
default:
|
||||
throw new UnsupportedOperationException(axis + "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the desired block state at a given (X, Y, Z) position relative to the origin (0, 0, 0).
|
||||
*
|
||||
* @param x The x position of the block, relative to the origin
|
||||
* @param y The y position of the block, relative to the origin
|
||||
* @param z The z position of the block, relative to the origin
|
||||
* @return The desired block state at the specified position
|
||||
*/
|
||||
IBlockState desiredState(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return The width (X axis length) of this schematic
|
||||
*/
|
||||
int widthX();
|
||||
|
||||
/**
|
||||
* @return The height (Y axis length) of this schematic
|
||||
*/
|
||||
int heightY();
|
||||
|
||||
/**
|
||||
* @return The length (Z axis length) of this schematic
|
||||
*/
|
||||
int lengthZ();
|
||||
}
|
||||
37
src/api/java/baritone/api/utils/MyChunkPos.java
Normal file
37
src/api/java/baritone/api/utils/MyChunkPos.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Need a non obfed chunkpos that we can load using GSON
|
||||
*/
|
||||
public class MyChunkPos {
|
||||
|
||||
@SerializedName("x")
|
||||
public int x;
|
||||
|
||||
@SerializedName("z")
|
||||
public int z;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + ", " + z;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package baritone.api.utils;
|
||||
|
||||
import baritone.api.pathing.calc.IPath;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PathCalculationResult {
|
||||
@@ -31,11 +32,9 @@ public class PathCalculationResult {
|
||||
}
|
||||
|
||||
public PathCalculationResult(Type type, IPath path) {
|
||||
Objects.requireNonNull(type);
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("come on");
|
||||
}
|
||||
}
|
||||
|
||||
public final Optional<IPath> getPath() {
|
||||
|
||||
@@ -34,7 +34,9 @@ public final class RayTraceUtils {
|
||||
* any entity collisions can be ignored, because this method will not recognize if an
|
||||
* entity is in the way or not. The local player's block reach distance will be used.
|
||||
*
|
||||
* @param rotation The rotation to raytrace towards
|
||||
* @param entity The entity representing the raytrace source
|
||||
* @param rotation The rotation to raytrace towards
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The calculated raytrace result
|
||||
*/
|
||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
|
||||
|
||||
@@ -110,6 +110,21 @@ public class Rotation {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is really close to
|
||||
*
|
||||
* @param other another rotation
|
||||
* @return are they really close
|
||||
*/
|
||||
public boolean isReallyCloseTo(Rotation other) {
|
||||
return yawIsReallyClose(other) && Math.abs(this.pitch - other.pitch) < 0.01;
|
||||
}
|
||||
|
||||
public boolean yawIsReallyClose(Rotation other) {
|
||||
float yawDiff = Math.abs(normalizeYaw(yaw) - normalizeYaw(other.yaw)); // you cant fool me
|
||||
return (yawDiff < 0.01 || yawDiff > 359.99);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the specified pitch value between -90 and 90.
|
||||
*
|
||||
@@ -131,9 +146,14 @@ public class Rotation {
|
||||
if (newYaw < -180F) {
|
||||
newYaw += 360F;
|
||||
}
|
||||
if (newYaw >= 180F) {
|
||||
if (newYaw > 180F) {
|
||||
newYaw -= 360F;
|
||||
}
|
||||
return newYaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Yaw: " + yaw + ", Pitch: " + pitch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ public final class RotationUtils {
|
||||
* @return The wrapped angles
|
||||
*/
|
||||
public static Rotation wrapAnglesToRelative(Rotation current, Rotation target) {
|
||||
if (current.yawIsReallyClose(target)) {
|
||||
return new Rotation(current.getYaw(), target.getPitch());
|
||||
}
|
||||
return target.subtract(current).normalize().add(current);
|
||||
}
|
||||
|
||||
@@ -102,7 +105,7 @@ public final class RotationUtils {
|
||||
* @param dest The destination position
|
||||
* @return The rotation from the origin to the destination
|
||||
*/
|
||||
public static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest) {
|
||||
private static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest) {
|
||||
double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z};
|
||||
double yaw = MathHelper.atan2(delta[0], -delta[2]);
|
||||
double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
|
||||
@@ -127,6 +130,16 @@ public final class RotationUtils {
|
||||
return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx Context for the viewing entity
|
||||
* @param pos The target block position
|
||||
* @return The optional rotation
|
||||
* @see #reachable(EntityPlayerSP, BlockPos, double)
|
||||
*/
|
||||
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
|
||||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified entity is able to reach the center of any of the sides
|
||||
* of the specified block. It first checks if the block center is reachable, and if so,
|
||||
@@ -134,13 +147,14 @@ public final class RotationUtils {
|
||||
* side that is reachable. The return type will be {@link Optional#empty()} if the entity is
|
||||
* unable to reach any of the sides of the block.
|
||||
*
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
|
||||
if (pos.equals(baritone.getPlayerContext().getSelectedBlock().orElse(null))) {
|
||||
if (baritone.getPlayerContext().isLookingAt(pos)) {
|
||||
/*
|
||||
* why add 0.0001?
|
||||
* to indicate that we actually have a desired pitch
|
||||
@@ -178,13 +192,14 @@ public final class RotationUtils {
|
||||
* the given offsetted position. The return type will be {@link Optional#empty()} if
|
||||
* the entity is unable to reach the block with the offset applied.
|
||||
*
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param offsetPos The position of the block with the offset applied.
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param offsetPos The position of the block with the offset applied.
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
|
||||
Rotation rotation = calcRotationFromVec3d(entity.getPositionEyes(1.0F), offsetPos);
|
||||
Rotation rotation = calcRotationFromVec3d(entity.getPositionEyes(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
||||
//System.out.println(result);
|
||||
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
@@ -202,8 +217,9 @@ public final class RotationUtils {
|
||||
* Determines if the specified entity is able to reach the specified block where it is
|
||||
* looking at the direct center of it's hitbox.
|
||||
*
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param entity The viewing entity
|
||||
* @param pos The target block position
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) {
|
||||
|
||||
@@ -18,124 +18,251 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||
|
||||
public class SettingsUtil {
|
||||
|
||||
private static final File settingsFile = new File(new File(Minecraft.getMinecraft().gameDir, "baritone"), "settings.txt");
|
||||
private static final Path SETTINGS_PATH = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt");
|
||||
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space
|
||||
|
||||
private static final Map<Class<?>, SettingsIO> map;
|
||||
private static boolean isComment(String line) {
|
||||
return line.startsWith("#") || line.startsWith("//");
|
||||
}
|
||||
|
||||
private static void forEachLine(Path file, Consumer<String> consumer) throws IOException {
|
||||
try (BufferedReader scan = Files.newBufferedReader(file)) {
|
||||
String line;
|
||||
while ((line = scan.readLine()) != null) {
|
||||
if (line.isEmpty() || isComment(line)) {
|
||||
continue;
|
||||
}
|
||||
consumer.accept(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void readAndApply(Settings settings) {
|
||||
try (Scanner scan = new Scanner(settingsFile)) {
|
||||
while (scan.hasNextLine()) {
|
||||
String line = scan.nextLine();
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
try {
|
||||
forEachLine(SETTINGS_PATH, line -> {
|
||||
Matcher matcher = SETTING_PATTERN.matcher(line);
|
||||
if (!matcher.matches()) {
|
||||
System.out.println("Invalid syntax in setting file: " + line);
|
||||
return;
|
||||
}
|
||||
if (line.startsWith("#") || line.startsWith("//")) {
|
||||
continue;
|
||||
}
|
||||
int space = line.indexOf(" ");
|
||||
if (space == -1) {
|
||||
System.out.println("Skipping invalid line with no space: " + line);
|
||||
continue;
|
||||
}
|
||||
String settingName = line.substring(0, space).trim().toLowerCase();
|
||||
String settingValue = line.substring(space).trim();
|
||||
|
||||
String settingName = matcher.group("setting").toLowerCase();
|
||||
String settingValue = matcher.group("value");
|
||||
try {
|
||||
parseAndApply(settings, settingName, settingValue);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("Unable to parse line " + line);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (NoSuchFileException ignored) {
|
||||
System.out.println("Baritone settings file not found, resetting.");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("Exception while reading Baritone settings, some settings may be reset to default values!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void save(Settings settings) {
|
||||
try (FileOutputStream out = new FileOutputStream(settingsFile)) {
|
||||
for (Settings.Setting setting : settings.allSettings) {
|
||||
if (setting.get() == null) {
|
||||
System.out.println("NULL SETTING?" + setting.getName());
|
||||
continue;
|
||||
}
|
||||
if (setting.getName().equals("logger")) {
|
||||
continue; // NO
|
||||
}
|
||||
if (setting.value == setting.defaultValue) {
|
||||
continue;
|
||||
}
|
||||
SettingsIO io = map.get(setting.getValueClass());
|
||||
if (io == null) {
|
||||
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting + " " + setting.getName());
|
||||
}
|
||||
out.write((setting.getName() + " " + io.toString.apply(setting.get()) + "\n").getBytes());
|
||||
try (BufferedWriter out = Files.newBufferedWriter(SETTINGS_PATH)) {
|
||||
for (Settings.Setting setting : modifiedSettings(settings)) {
|
||||
out.write(settingToString(setting) + "\n");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Exception thrown while saving Baritone settings!");
|
||||
ex.printStackTrace();
|
||||
System.out.println("Exception while saving Baritone settings!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
|
||||
public static List<Settings.Setting> modifiedSettings(Settings settings) {
|
||||
List<Settings.Setting> modified = new ArrayList<>();
|
||||
for (Settings.Setting setting : settings.allSettings) {
|
||||
if (setting.value == null) {
|
||||
System.out.println("NULL SETTING?" + setting.getName());
|
||||
continue;
|
||||
}
|
||||
if (setting.getName().equals("logger")) {
|
||||
continue; // NO
|
||||
}
|
||||
if (setting.value == setting.defaultValue) {
|
||||
continue;
|
||||
}
|
||||
modified.add(setting);
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
public static String settingToString(Settings.Setting setting) throws IllegalStateException {
|
||||
if (setting.getName().equals("logger")) {
|
||||
return "logger";
|
||||
}
|
||||
Parser io = Parser.getParser(setting.getType());
|
||||
if (io == null) {
|
||||
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName());
|
||||
}
|
||||
return setting.getName() + " " + io.toString(new ParserContext(setting), setting.value);
|
||||
}
|
||||
|
||||
public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
|
||||
Settings.Setting setting = settings.byLowerName.get(settingName);
|
||||
if (setting == null) {
|
||||
throw new IllegalStateException("No setting by that name");
|
||||
}
|
||||
Class intendedType = setting.getValueClass();
|
||||
SettingsIO ioMethod = map.get(intendedType);
|
||||
Object parsed = ioMethod.parser.apply(settingValue);
|
||||
ISettingParser ioMethod = Parser.getParser(setting.getType());
|
||||
Object parsed = ioMethod.parse(new ParserContext(setting), settingValue);
|
||||
if (!intendedType.isInstance(parsed)) {
|
||||
throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass());
|
||||
}
|
||||
setting.value = parsed;
|
||||
}
|
||||
|
||||
private enum SettingsIO {
|
||||
private interface ISettingParser<T> {
|
||||
|
||||
T parse(ParserContext context, String raw);
|
||||
|
||||
String toString(ParserContext context, T value);
|
||||
|
||||
boolean accepts(Type type);
|
||||
}
|
||||
|
||||
private static class ParserContext {
|
||||
|
||||
private final Settings.Setting<?> setting;
|
||||
|
||||
private ParserContext(Settings.Setting<?> setting) {
|
||||
this.setting = setting;
|
||||
}
|
||||
|
||||
private Settings.Setting<?> getSetting() {
|
||||
return this.setting;
|
||||
}
|
||||
}
|
||||
|
||||
private enum Parser implements ISettingParser {
|
||||
|
||||
DOUBLE(Double.class, Double::parseDouble),
|
||||
BOOLEAN(Boolean.class, Boolean::parseBoolean),
|
||||
INTEGER(Integer.class, Integer::parseInt),
|
||||
FLOAT(Float.class, Float::parseFloat),
|
||||
LONG(Long.class, Long::parseLong),
|
||||
ENUMFACING(EnumFacing.class, EnumFacing::byName),
|
||||
COLOR(
|
||||
Color.class,
|
||||
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||
),
|
||||
VEC3I(
|
||||
Vec3i.class,
|
||||
str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||
vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ()
|
||||
),
|
||||
BLOCK(
|
||||
Block.class,
|
||||
str -> BlockUtils.stringToBlockRequired(str.trim()),
|
||||
BlockUtils::blockToString
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> Item.getByNameOrId(str.trim()),
|
||||
item -> Item.REGISTRY.getNameForObject(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
@Override
|
||||
public Object parse(ParserContext context, String raw) {
|
||||
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
|
||||
Parser parser = Parser.getParser(type);
|
||||
|
||||
ITEM_LIST(ArrayList.class, str -> Stream.of(str.split(",")).map(Item::getByNameOrId).collect(Collectors.toCollection(ArrayList::new)), list -> ((ArrayList<Item>) list).stream().map(Item.REGISTRY::getNameForObject).map(ResourceLocation::toString).collect(Collectors.joining(","))),
|
||||
COLOR(Color.class, str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])), color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue());
|
||||
return Arrays.stream(raw.split(","))
|
||||
.map(s -> parser.parse(context, s))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ParserContext context, Object value) {
|
||||
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
|
||||
Parser parser = Parser.getParser(type);
|
||||
|
||||
Class<?> klass;
|
||||
Function<String, Object> parser;
|
||||
Function<Object, String> toString;
|
||||
return ((List<?>) value).stream()
|
||||
.map(o -> parser.toString(context, o))
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
<T> SettingsIO(Class<T> klass, Function<String, T> parser) {
|
||||
@Override
|
||||
public boolean accepts(Type type) {
|
||||
return List.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
|
||||
}
|
||||
};
|
||||
|
||||
private final Class<?> klass;
|
||||
private final Function<String, Object> parser;
|
||||
private final Function<Object, String> toString;
|
||||
|
||||
Parser() {
|
||||
this.klass = null;
|
||||
this.parser = null;
|
||||
this.toString = null;
|
||||
}
|
||||
|
||||
<T> Parser(Class<T> klass, Function<String, T> parser) {
|
||||
this(klass, parser, Object::toString);
|
||||
}
|
||||
|
||||
<T> SettingsIO(Class<T> klass, Function<String, T> parser, Function<T, String> toString) {
|
||||
<T> Parser(Class<T> klass, Function<String, T> parser, Function<T, String> toString) {
|
||||
this.klass = klass;
|
||||
this.parser = parser::apply;
|
||||
this.toString = x -> toString.apply((T) x);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
HashMap<Class<?>, SettingsIO> tempMap = new HashMap<>();
|
||||
for (SettingsIO type : SettingsIO.values()) {
|
||||
tempMap.put(type.klass, type);
|
||||
@Override
|
||||
public Object parse(ParserContext context, String raw) {
|
||||
Object parsed = this.parser.apply(raw);
|
||||
Objects.requireNonNull(parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ParserContext context, Object value) {
|
||||
return this.toString.apply(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(Type type) {
|
||||
return type instanceof Class && this.klass.isAssignableFrom((Class) type);
|
||||
}
|
||||
|
||||
public static Parser getParser(Type type) {
|
||||
return Arrays.stream(values())
|
||||
.filter(parser -> parser.accepts(type))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
map = Collections.unmodifiableMap(tempMap);
|
||||
}
|
||||
}
|
||||
|
||||
44
src/api/java/baritone/api/utils/TypeUtils.java
Normal file
44
src/api/java/baritone/api/utils/TypeUtils.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 4/20/2019
|
||||
*/
|
||||
public final class TypeUtils {
|
||||
|
||||
private TypeUtils() {}
|
||||
|
||||
/**
|
||||
* Resolves the "base type" for the specified type. For example, if the specified
|
||||
* type is {@code List<String>}, then {@code List.class} will be returned. If the
|
||||
* specified type is already a class, then it is directly returned.
|
||||
*
|
||||
* @param type The type to resolve
|
||||
* @return The base class
|
||||
*/
|
||||
public static Class<?> resolveBaseClass(Type type) {
|
||||
return type instanceof Class ? (Class<?>) type
|
||||
: type instanceof ParameterizedType ? (Class<?>) ((ParameterizedType) type).getRawType()
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,8 @@ public final class VecUtils {
|
||||
/**
|
||||
* Calculates the center of the block at the specified position's bounding box
|
||||
*
|
||||
* @param pos The block position
|
||||
* @param world The world that the block is in, used to provide the bounding box
|
||||
* @param pos The block position
|
||||
* @return The center of the block's bounding box
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
@@ -81,10 +82,9 @@ public final class VecUtils {
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double distanceToCenter(BlockPos pos, double x, double y, double z) {
|
||||
Vec3d center = getBlockPosCenter(pos);
|
||||
double xdiff = x - center.x;
|
||||
double ydiff = y - center.y;
|
||||
double zdiff = z - center.z;
|
||||
double xdiff = pos.getX() + 0.5 - x;
|
||||
double ydiff = pos.getY() + 0.5 - y;
|
||||
double zdiff = pos.getZ() + 0.5 - z;
|
||||
return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,6 @@
|
||||
|
||||
package baritone.api.utils.input;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* An {@link Enum} representing the inputs that control the player's
|
||||
* behavior. This includes moving, interacting with blocks, jumping,
|
||||
@@ -36,84 +27,45 @@ public enum Input {
|
||||
/**
|
||||
* The move forward input
|
||||
*/
|
||||
MOVE_FORWARD(s -> s.keyBindForward),
|
||||
MOVE_FORWARD,
|
||||
|
||||
/**
|
||||
* The move back input
|
||||
*/
|
||||
MOVE_BACK(s -> s.keyBindBack),
|
||||
MOVE_BACK,
|
||||
|
||||
/**
|
||||
* The move left input
|
||||
*/
|
||||
MOVE_LEFT(s -> s.keyBindLeft),
|
||||
MOVE_LEFT,
|
||||
|
||||
/**
|
||||
* The move right input
|
||||
*/
|
||||
MOVE_RIGHT(s -> s.keyBindRight),
|
||||
MOVE_RIGHT,
|
||||
|
||||
/**
|
||||
* The attack input
|
||||
*/
|
||||
CLICK_LEFT(s -> s.keyBindAttack),
|
||||
CLICK_LEFT,
|
||||
|
||||
/**
|
||||
* The use item input
|
||||
*/
|
||||
CLICK_RIGHT(s -> s.keyBindUseItem),
|
||||
CLICK_RIGHT,
|
||||
|
||||
/**
|
||||
* The jump input
|
||||
*/
|
||||
JUMP(s -> s.keyBindJump),
|
||||
JUMP,
|
||||
|
||||
/**
|
||||
* The sneak input
|
||||
*/
|
||||
SNEAK(s -> s.keyBindSneak),
|
||||
SNEAK,
|
||||
|
||||
/**
|
||||
* The sprint input
|
||||
*/
|
||||
SPRINT(s -> s.keyBindSprint);
|
||||
|
||||
/**
|
||||
* Map of {@link KeyBinding} to {@link Input}. Values should be queried through {@link #getInputForBind(KeyBinding)}
|
||||
*/
|
||||
private static final Map<KeyBinding, Input> bindToInputMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The actual game {@link KeyBinding} being forced.
|
||||
*/
|
||||
private final KeyBinding keyBinding;
|
||||
|
||||
Input(Function<GameSettings, KeyBinding> keyBindingMapper) {
|
||||
/*
|
||||
|
||||
Here, a Function is used because referring to a static field in this enum for the game instance,
|
||||
as it was before, wouldn't be possible in an Enum constructor unless the static field was in an
|
||||
interface that this class implemented. (Helper acted as this interface) I didn't feel like making
|
||||
an interface with a game instance field just to not have to do this.
|
||||
|
||||
*/
|
||||
this.keyBinding = keyBindingMapper.apply(Minecraft.getMinecraft().gameSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The actual game {@link KeyBinding} being forced.
|
||||
*/
|
||||
public final KeyBinding getKeyBinding() {
|
||||
return this.keyBinding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the {@link Input} constant that is associated with the specified {@link KeyBinding}.
|
||||
*
|
||||
* @param binding The {@link KeyBinding} to find the associated {@link Input} for
|
||||
* @return The {@link Input} associated with the specified {@link KeyBinding}
|
||||
*/
|
||||
public static Input getInputForBind(KeyBinding binding) {
|
||||
return bindToInputMap.computeIfAbsent(binding, b -> Arrays.stream(values()).filter(input -> input.keyBinding == b).findFirst().orElse(null));
|
||||
}
|
||||
SPRINT
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ChunkRenderContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@Mixin(ChunkRenderContainer.class)
|
||||
public class MixinChunkRenderContainer {
|
||||
|
||||
@Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
|
||||
method = "preRenderChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/chunk/RenderChunk.getPosition()Lnet/minecraft/util/math/BlockPos;"
|
||||
)
|
||||
)
|
||||
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
||||
GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
return renderChunkIn.getPosition();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ChunkRenderWorker.class)
|
||||
public abstract class MixinChunkRenderWorker {
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean isChunkExisting(BlockPos pos, World worldIn);
|
||||
|
||||
@Redirect(
|
||||
method = "processTask",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z"
|
||||
)
|
||||
)
|
||||
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||
return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world);
|
||||
}
|
||||
}
|
||||
|
||||
return this.isChunkExisting(pos, world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static org.spongepowered.asm.lib.Opcodes.GETFIELD;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/21/2018
|
||||
*/
|
||||
@Mixin(Entity.class)
|
||||
public class MixinEntity {
|
||||
|
||||
@Shadow
|
||||
public float rotationYaw;
|
||||
|
||||
/**
|
||||
* Event called to override the movement direction when walking
|
||||
*/
|
||||
private RotationMoveEvent motionUpdateRotationEvent;
|
||||
|
||||
@Inject(
|
||||
method = "moveRelative",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||
// noinspection ConstantConditions
|
||||
if (EntityPlayerSP.class.isInstance(this)) {
|
||||
this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "moveRelative",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = GETFIELD,
|
||||
target = "net/minecraft/entity/Entity.rotationYaw:F"
|
||||
)
|
||||
)
|
||||
private float overrideYaw(Entity self) {
|
||||
if (self instanceof EntityPlayerSP) {
|
||||
return this.motionUpdateRotationEvent.getYaw();
|
||||
}
|
||||
return self.rotationYaw;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -55,8 +56,11 @@ public abstract class MixinEntityLivingBase extends Entity {
|
||||
private void preMoveRelative(CallbackInfo ci) {
|
||||
// noinspection ConstantConditions
|
||||
if (EntityPlayerSP.class.isInstance(this)) {
|
||||
this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone != null) {
|
||||
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
||||
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +73,30 @@ public abstract class MixinEntityLivingBase extends Entity {
|
||||
)
|
||||
)
|
||||
private float overrideYaw(EntityLivingBase self) {
|
||||
if (self instanceof EntityPlayerSP) {
|
||||
if (self instanceof EntityPlayerSP && BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) != null) {
|
||||
return this.jumpRotationEvent.getYaw();
|
||||
}
|
||||
return self.rotationYaw;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "travel",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/entity/EntityLivingBase.moveRelative(FFFF)V"
|
||||
)
|
||||
)
|
||||
private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) {
|
||||
// noinspection ConstantConditions
|
||||
if (!EntityPlayerSP.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) == null) {
|
||||
moveRelative(strafe, up, forward, friction);
|
||||
return;
|
||||
}
|
||||
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
||||
float originalYaw = this.rotationYaw;
|
||||
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
||||
this.moveRelative(strafe, up, forward, friction);
|
||||
this.rotationYaw = originalYaw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.api.event.events.PlayerUpdateEvent;
|
||||
import baritone.api.event.events.SprintStateEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.PlayerCapabilities;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -43,8 +46,12 @@ public class MixinEntityPlayerSP {
|
||||
cancellable = true
|
||||
)
|
||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent((EntityPlayerSP) (Object) this, msg);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onSendChatMessage(event);
|
||||
ChatEvent event = new ChatEvent(msg);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
baritone.getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -60,7 +67,10 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private void onPreUpdate(CallbackInfo ci) {
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.PRE));
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -73,7 +83,10 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private void onPostUpdate(CallbackInfo ci) {
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.POST));
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
@@ -84,7 +97,47 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private boolean isAllowFlying(PlayerCapabilities capabilities) {
|
||||
IPathingBehavior pathingBehavior = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getPathingBehavior();
|
||||
return !pathingBehavior.isPathing() && capabilities.allowFlying;
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone == null) {
|
||||
return capabilities.allowFlying;
|
||||
}
|
||||
return !baritone.getPathingBehavior().isPathing() && capabilities.allowFlying;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onLivingUpdate",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z"
|
||||
)
|
||||
)
|
||||
private boolean isKeyDown(KeyBinding keyBinding) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone == null) {
|
||||
return keyBinding.isKeyDown();
|
||||
}
|
||||
SprintStateEvent event = new SprintStateEvent();
|
||||
baritone.getGameEventHandler().onPlayerSprintState(event);
|
||||
if (event.getState() != null) {
|
||||
return event.getState();
|
||||
}
|
||||
if (baritone != BaritoneAPI.getProvider().getPrimaryBaritone()) {
|
||||
// hitting control shouldn't make all bots sprint
|
||||
return false;
|
||||
}
|
||||
return keyBinding.isKeyDown();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "updateRidden",
|
||||
at = @At(
|
||||
value = "HEAD"
|
||||
)
|
||||
)
|
||||
private void updateRidden(CallbackInfo cb) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (baritone != null) {
|
||||
((LookBehavior) baritone.getLookBehavior()).pig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
@Mixin(KeyBinding.class)
|
||||
public class MixinKeyBinding {
|
||||
|
||||
@Inject(
|
||||
method = "isKeyDown",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void isKeyDown(CallbackInfoReturnable<Boolean> cir) {
|
||||
// only the primary baritone forces keys
|
||||
if (BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,15 +96,6 @@ public class MixinMinecraft {
|
||||
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "processKeyBinds",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void runTickKeyboard(CallbackInfo ci) {
|
||||
// keyboard input is only the primary baritone
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onProcessKeyBinds();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
|
||||
at = @At("HEAD")
|
||||
@@ -164,7 +155,7 @@ public class MixinMinecraft {
|
||||
)
|
||||
private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
|
||||
// clickMouse is only for the main player
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK));
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.START_BREAK));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
|
||||
89
src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
Normal file
89
src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 1/29/2019
|
||||
*/
|
||||
@Mixin(RenderChunk.class)
|
||||
public class MixinRenderChunk {
|
||||
|
||||
@Redirect(
|
||||
method = "rebuildChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/world/ChunkCache.isEmpty()Z"
|
||||
)
|
||||
)
|
||||
private boolean isEmpty(ChunkCache chunkCache) {
|
||||
if (!chunkCache.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||
BlockPos position = ((RenderChunk) (Object) this).getPosition();
|
||||
// RenderChunk extends from -1,-1,-1 to +16,+16,+16
|
||||
// then the constructor of ChunkCache extends it one more (presumably to get things like the connected status of fences? idk)
|
||||
// so if ANY of the adjacent chunks are loaded, we are unempty
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
if (baritone.bsi.isLoaded(16 * dx + position.getX(), 16 * dz + position.getZ())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "rebuildChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/world/ChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"
|
||||
)
|
||||
)
|
||||
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||
return baritone.bsi.get0(pos);
|
||||
}
|
||||
}
|
||||
|
||||
return chunkCache.getBlockState(pos);
|
||||
}
|
||||
}
|
||||
47
src/launch/java/baritone/launch/mixins/MixinRenderList.java
Normal file
47
src/launch/java/baritone/launch/mixins/MixinRenderList.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@Mixin(RenderList.class)
|
||||
public class MixinRenderList {
|
||||
|
||||
@Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
|
||||
method = "renderChunkLayer",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
|
||||
)
|
||||
)
|
||||
private void popMatrix() {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
// reset the blend func to normal (not dependent on constant alpha)
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.VboRenderList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@Mixin(VboRenderList.class)
|
||||
public class MixinVboRenderList {
|
||||
|
||||
@Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
|
||||
method = "renderChunkLayer",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
|
||||
)
|
||||
)
|
||||
private void popMatrix() {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||
// reset the blend func to normal (not dependent on constant alpha)
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,17 @@
|
||||
"MixinBlockPos",
|
||||
"MixinChunkProviderClient",
|
||||
"MixinChunkProviderServer",
|
||||
"MixinEntity",
|
||||
"MixinChunkRenderContainer",
|
||||
"MixinChunkRenderWorker",
|
||||
"MixinEntityLivingBase",
|
||||
"MixinEntityPlayerSP",
|
||||
"MixinEntityRenderer",
|
||||
"MixinKeyBinding",
|
||||
"MixinMinecraft",
|
||||
"MixinNetHandlerPlayClient",
|
||||
"MixinNetworkManager",
|
||||
"MixinRenderChunk",
|
||||
"MixinRenderList",
|
||||
"MixinVboRenderList",
|
||||
"MixinWorldClient"
|
||||
]
|
||||
}
|
||||
@@ -1,213 +1,237 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.Behavior;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import baritone.behavior.MemoryBehavior;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.CustomGoalProcess;
|
||||
import baritone.process.FollowProcess;
|
||||
import baritone.process.GetToBlockProcess;
|
||||
import baritone.process.MineProcess;
|
||||
import baritone.utils.BaritoneAutoTest;
|
||||
import baritone.utils.ExampleBaritoneControl;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.utils.PathingControlManager;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
public class Baritone implements IBaritone {
|
||||
|
||||
private static ThreadPoolExecutor threadPool;
|
||||
private static File dir;
|
||||
|
||||
static {
|
||||
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
|
||||
dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||
if (!Files.exists(dir.toPath())) {
|
||||
try {
|
||||
Files.createDirectories(dir.toPath());
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not {@link Baritone#init()} has been called yet
|
||||
*/
|
||||
private boolean initialized;
|
||||
|
||||
private GameEventHandler gameEventHandler;
|
||||
|
||||
private List<Behavior> behaviors;
|
||||
private PathingBehavior pathingBehavior;
|
||||
private LookBehavior lookBehavior;
|
||||
private MemoryBehavior memoryBehavior;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
|
||||
private FollowProcess followProcess;
|
||||
private MineProcess mineProcess;
|
||||
private GetToBlockProcess getToBlockProcess;
|
||||
private CustomGoalProcess customGoalProcess;
|
||||
|
||||
private PathingControlManager pathingControlManager;
|
||||
|
||||
private IPlayerContext playerContext;
|
||||
private WorldProvider worldProvider;
|
||||
|
||||
Baritone() {
|
||||
this.gameEventHandler = new GameEventHandler(this);
|
||||
}
|
||||
|
||||
public synchronized void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Define this before behaviors try and get it, or else it will be null and the builds will fail!
|
||||
this.playerContext = PrimaryPlayerContext.INSTANCE;
|
||||
|
||||
this.behaviors = new ArrayList<>();
|
||||
{
|
||||
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
||||
pathingBehavior = new PathingBehavior(this);
|
||||
lookBehavior = new LookBehavior(this);
|
||||
memoryBehavior = new MemoryBehavior(this);
|
||||
inputOverrideHandler = new InputOverrideHandler(this);
|
||||
new ExampleBaritoneControl(this);
|
||||
}
|
||||
|
||||
this.pathingControlManager = new PathingControlManager(this);
|
||||
{
|
||||
followProcess = new FollowProcess(this);
|
||||
mineProcess = new MineProcess(this);
|
||||
customGoalProcess = new CustomGoalProcess(this); // very high iq
|
||||
getToBlockProcess = new GetToBlockProcess(this);
|
||||
}
|
||||
|
||||
this.worldProvider = new WorldProvider();
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public PathingControlManager getPathingControlManager() {
|
||||
return this.pathingControlManager;
|
||||
}
|
||||
|
||||
public List<Behavior> getBehaviors() {
|
||||
return this.behaviors;
|
||||
}
|
||||
|
||||
public void registerBehavior(Behavior behavior) {
|
||||
this.behaviors.add(behavior);
|
||||
this.gameEventHandler.registerEventListener(behavior);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
||||
return this.customGoalProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetToBlockProcess getGetToBlockProcess() { // Iffy
|
||||
return this.getToBlockProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerContext getPlayerContext() {
|
||||
return this.playerContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FollowProcess getFollowProcess() {
|
||||
return this.followProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LookBehavior getLookBehavior() {
|
||||
return this.lookBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemoryBehavior getMemoryBehavior() {
|
||||
return this.memoryBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MineProcess getMineProcess() {
|
||||
return this.mineProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingBehavior getPathingBehavior() {
|
||||
return this.pathingBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldProvider getWorldProvider() {
|
||||
return this.worldProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventBus getGameEventHandler() {
|
||||
return this.gameEventHandler;
|
||||
}
|
||||
|
||||
public static Settings settings() {
|
||||
return BaritoneAPI.getSettings();
|
||||
}
|
||||
|
||||
public static File getDir() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static Executor getExecutor() {
|
||||
return threadPool;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone 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 Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.utils.ExampleBaritoneControl;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
public class Baritone implements IBaritone {
|
||||
|
||||
private static ThreadPoolExecutor threadPool;
|
||||
private static File dir;
|
||||
|
||||
static {
|
||||
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
|
||||
dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||
if (!Files.exists(dir.toPath())) {
|
||||
try {
|
||||
Files.createDirectories(dir.toPath());
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not {@link Baritone#init()} has been called yet
|
||||
*/
|
||||
private boolean initialized;
|
||||
|
||||
private GameEventHandler gameEventHandler;
|
||||
|
||||
private PathingBehavior pathingBehavior;
|
||||
private LookBehavior lookBehavior;
|
||||
private MemoryBehavior memoryBehavior;
|
||||
private InventoryBehavior inventoryBehavior;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
|
||||
private FollowProcess followProcess;
|
||||
private MineProcess mineProcess;
|
||||
private GetToBlockProcess getToBlockProcess;
|
||||
private CustomGoalProcess customGoalProcess;
|
||||
private BuilderProcess builderProcess;
|
||||
private ExploreProcess exploreProcess;
|
||||
private BackfillProcess backfillProcess;
|
||||
private FarmProcess farmProcess;
|
||||
|
||||
private PathingControlManager pathingControlManager;
|
||||
|
||||
private IPlayerContext playerContext;
|
||||
private WorldProvider worldProvider;
|
||||
|
||||
public BlockStateInterface bsi;
|
||||
|
||||
Baritone() {
|
||||
this.gameEventHandler = new GameEventHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Define this before behaviors try and get it, or else it will be null and the builds will fail!
|
||||
this.playerContext = PrimaryPlayerContext.INSTANCE;
|
||||
|
||||
{
|
||||
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
||||
pathingBehavior = new PathingBehavior(this);
|
||||
lookBehavior = new LookBehavior(this);
|
||||
memoryBehavior = new MemoryBehavior(this);
|
||||
inventoryBehavior = new InventoryBehavior(this);
|
||||
inputOverrideHandler = new InputOverrideHandler(this);
|
||||
new ExampleBaritoneControl(this);
|
||||
}
|
||||
|
||||
this.pathingControlManager = new PathingControlManager(this);
|
||||
{
|
||||
followProcess = new FollowProcess(this);
|
||||
mineProcess = new MineProcess(this);
|
||||
customGoalProcess = new CustomGoalProcess(this); // very high iq
|
||||
getToBlockProcess = new GetToBlockProcess(this);
|
||||
builderProcess = new BuilderProcess(this);
|
||||
exploreProcess = new ExploreProcess(this);
|
||||
backfillProcess = new BackfillProcess(this);
|
||||
farmProcess = new FarmProcess(this);
|
||||
}
|
||||
|
||||
this.worldProvider = new WorldProvider();
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingControlManager getPathingControlManager() {
|
||||
return this.pathingControlManager;
|
||||
}
|
||||
|
||||
public void registerBehavior(Behavior behavior) {
|
||||
this.gameEventHandler.registerEventListener(behavior);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGoalProcess getCustomGoalProcess() {
|
||||
return this.customGoalProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetToBlockProcess getGetToBlockProcess() {
|
||||
return this.getToBlockProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerContext getPlayerContext() {
|
||||
return this.playerContext;
|
||||
}
|
||||
|
||||
public MemoryBehavior getMemoryBehavior() {
|
||||
return this.memoryBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FollowProcess getFollowProcess() {
|
||||
return this.followProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuilderProcess getBuilderProcess() {
|
||||
return this.builderProcess;
|
||||
}
|
||||
|
||||
public InventoryBehavior getInventoryBehavior() {
|
||||
return this.inventoryBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LookBehavior getLookBehavior() {
|
||||
return this.lookBehavior;
|
||||
}
|
||||
|
||||
public ExploreProcess getExploreProcess() {
|
||||
return this.exploreProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MineProcess getMineProcess() {
|
||||
return this.mineProcess;
|
||||
}
|
||||
|
||||
public FarmProcess getFarmProcess() {
|
||||
return this.farmProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingBehavior getPathingBehavior() {
|
||||
return this.pathingBehavior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldProvider getWorldProvider() {
|
||||
return this.worldProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventBus getGameEventHandler() {
|
||||
return this.gameEventHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openClick() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
Helper.mc.addScheduledTask(() -> Helper.mc.displayGuiScreen(new GuiClick()));
|
||||
} catch (Exception ignored) {}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static Settings settings() {
|
||||
return BaritoneAPI.getSettings();
|
||||
}
|
||||
|
||||
public static File getDir() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static Executor getExecutor() {
|
||||
return threadPool;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
public final class BaritoneProvider implements IBaritoneProvider {
|
||||
|
||||
private final Baritone primary = new Baritone();
|
||||
private final List<IBaritone> all = Collections.singletonList(primary);
|
||||
|
||||
@Override
|
||||
public IBaritone getPrimaryBaritone() {
|
||||
@@ -40,8 +41,7 @@ public final class BaritoneProvider implements IBaritoneProvider {
|
||||
|
||||
@Override
|
||||
public List<IBaritone> getAllBaritones() {
|
||||
// TODO return a CopyOnWriteArrayList
|
||||
return Collections.singletonList(primary);
|
||||
return all;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user