Compare commits
723 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
6faa7344aa | ||
|
|
c0761c0eef | ||
|
|
46f8829951 | ||
|
|
b484e6fa3f | ||
|
|
aa8773a67e | ||
|
|
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 | ||
|
|
b4d307d4cc | ||
|
|
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 | ||
|
|
f274f5a0ef | ||
|
|
bb41883070 | ||
|
|
fca5457ab9 | ||
|
|
4f355ed4a2 | ||
|
|
b1452c714a | ||
|
|
aba48cca53 | ||
|
|
772d5fb0cc | ||
|
|
6b6f8cadb2 | ||
|
|
82ab79e915 | ||
|
|
863471b5f1 | ||
|
|
314f280400 | ||
|
|
b75f4bf9a9 | ||
|
|
253d67ce78 | ||
|
|
1753bc18c1 | ||
|
|
eceba13164 | ||
|
|
3c6c640f50 | ||
|
|
30e3018966 | ||
|
|
5ab0bb3c0d | ||
|
|
0de1517bd8 | ||
|
|
39c6d81b9e | ||
|
|
38c7f226cb | ||
|
|
f5446cc415 | ||
|
|
aa2e680568 | ||
|
|
bc651cb774 | ||
|
|
20b03d0004 | ||
|
|
b005ce8e6b | ||
|
|
979b8b2663 | ||
|
|
69b1decbba | ||
|
|
d32c92cbde | ||
|
|
a5b9885767 | ||
|
|
2daedecf92 | ||
|
|
db24822d2f | ||
|
|
59320d9b85 | ||
|
|
9dfcef6356 | ||
|
|
ae3fc14b52 | ||
|
|
f8681d179d | ||
|
|
f23630064e | ||
|
|
bec7f9be96 | ||
|
|
09e94eaa8e | ||
|
|
5f29bb3e7f | ||
|
|
1ad6a0d5b5 | ||
|
|
f727e71eaf | ||
|
|
14f006c3a5 | ||
|
|
200211c186 | ||
|
|
5ca214534d | ||
|
|
85ea21e83b | ||
|
|
7d572d748b | ||
|
|
fbcae10f96 | ||
|
|
a4495ce80a | ||
|
|
f5478f6169 | ||
|
|
ae1e229619 | ||
|
|
bc5982b994 | ||
|
|
e971d5d43f | ||
|
|
ee9519d891 | ||
|
|
58bb209158 | ||
|
|
23dc97ad5e | ||
|
|
84b580b001 | ||
|
|
227b303669 | ||
|
|
712a0a3905 | ||
|
|
76427b8ecb | ||
|
|
8b6d621d20 | ||
|
|
7898b24bac | ||
|
|
39648c5dc6 | ||
|
|
83e6b2fdfe | ||
|
|
816727d65b | ||
|
|
0e012adb6c | ||
|
|
539b0e64c8 | ||
|
|
258700ee7b | ||
|
|
1da72ba473 | ||
|
|
c2c69f243e | ||
|
|
dffbb8e4c8 | ||
|
|
bebdede33b | ||
|
|
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 | ||
|
|
9c5274dde4 | ||
|
|
002c678b4a | ||
|
|
038533c33f | ||
|
|
50d4b5b4ed | ||
|
|
7632d667c9 | ||
|
|
5aa78cd478 | ||
|
|
84cd4b1acb | ||
|
|
b705279153 | ||
|
|
d854750ee8 | ||
|
|
653861107d | ||
|
|
4502adda28 | ||
|
|
a98c5d7d99 | ||
|
|
c81a00268a | ||
|
|
dd47e20070 | ||
|
|
f05613147e | ||
|
|
6ed8d617cd | ||
|
|
b228f4c6fb | ||
|
|
70f8d1d4ae | ||
|
|
0d7131413a | ||
|
|
b5a4e65fbf | ||
|
|
7c51106d27 | ||
|
|
1e9786d5b9 | ||
|
|
4b8c85f8a6 | ||
|
|
aed8dae175 | ||
|
|
8db26af36c | ||
|
|
cfa874982c | ||
|
|
2a674cb869 | ||
|
|
fb971301a4 | ||
|
|
3bb16de67e | ||
|
|
033da7e737 | ||
|
|
14650f93c5 | ||
|
|
e5184efdaa | ||
|
|
d95a72f2cc | ||
|
|
16e3fd9305 | ||
|
|
4fb6c71174 | ||
|
|
12bbd57a24 | ||
|
|
689dc74330 | ||
|
|
6caae889b7 | ||
|
|
ce0e8b4cd1 | ||
|
|
737c632227 | ||
|
|
04e87c9810 | ||
|
|
57c0613843 | ||
|
|
f5d0143b09 | ||
|
|
237f1846d3 | ||
|
|
f6dee1ecb7 | ||
|
|
f808fc9802 | ||
|
|
8385bc35ed | ||
|
|
80d6d7fd58 | ||
|
|
b56cdcda52 | ||
|
|
ea81cd76ca | ||
|
|
c3a3670785 | ||
|
|
e4045e1343 | ||
|
|
5a52cea415 | ||
|
|
933b295c40 | ||
|
|
ce6ec00a89 | ||
|
|
b53f3925a4 | ||
|
|
e93fd596ff | ||
|
|
57b60c734b | ||
|
|
c74ccaafbf | ||
|
|
f6891feb64 | ||
|
|
2675852dbe | ||
|
|
0302c6f14b | ||
|
|
a0dd43244c | ||
|
|
3ccb0c74c6 | ||
|
|
f9270a7ed0 | ||
|
|
d79d56c2f9 | ||
|
|
a8f09a7fe9 | ||
|
|
94bf8d4bbd | ||
|
|
5e2f40a322 | ||
|
|
17161fd576 | ||
|
|
d3db551cc9 | ||
|
|
72058c792a | ||
|
|
ef5e3ab06e | ||
|
|
71e7f0a04c | ||
|
|
bae34e5b80 | ||
|
|
1ab3e61984 | ||
|
|
e81b6d4d96 | ||
|
|
83f14b10bb | ||
|
|
7fecd1a5dd | ||
|
|
0ce4107d56 | ||
|
|
66769365d0 | ||
|
|
e3cb164723 | ||
|
|
903b1b16a4 | ||
|
|
e81d0a0b1b | ||
|
|
51243f0981 | ||
|
|
fad5a6deac | ||
|
|
355443e440 | ||
|
|
45e4239b26 | ||
|
|
a83074e773 | ||
|
|
f854d886d1 | ||
|
|
73d4e9bbb9 | ||
|
|
232644feb0 | ||
|
|
1c80950a70 | ||
|
|
0bd46e88a5 | ||
|
|
b054e9dbe8 | ||
|
|
3ddf6b2335 | ||
|
|
1a1686b7c3 | ||
|
|
dd08b2c825 | ||
|
|
a2a60e9847 | ||
|
|
13505a052f | ||
|
|
f2dcdda9b3 | ||
|
|
dc6389c46f | ||
|
|
7dc89b0190 | ||
|
|
5b395ce3da | ||
|
|
40da7b3734 | ||
|
|
842e50adb9 | ||
|
|
96da078219 | ||
|
|
4a1951b027 | ||
|
|
83348e6b3c | ||
|
|
a1778f401f | ||
|
|
9c93d3a474 | ||
|
|
cbc8a6d45b | ||
|
|
382c7e7888 | ||
|
|
ae200a56b0 | ||
|
|
c50af5acfd | ||
|
|
527691a2ec | ||
|
|
a182c22d36 | ||
|
|
aac0d623fa | ||
|
|
604ef2bb64 | ||
|
|
6ca7f47bf9 | ||
|
|
a1b71219cb | ||
|
|
d59c7cb7a8 | ||
|
|
d121ca182f | ||
|
|
2aee91be10 | ||
|
|
99da815f49 | ||
|
|
ebd3ce42d0 | ||
|
|
fdee1b9453 | ||
|
|
472e89239c | ||
|
|
5692e79e02 | ||
|
|
52246e41c8 | ||
|
|
2da3222115 | ||
|
|
4d0bfce712 | ||
|
|
cb153e039b | ||
|
|
8aa5a6756a | ||
|
|
23286dd8b8 | ||
|
|
30408384c6 | ||
|
|
e11e3dfd86 | ||
|
|
2c39cd06ed | ||
|
|
75a224cef1 | ||
|
|
0373f1875f | ||
|
|
fffd016008 | ||
|
|
f286c400a3 | ||
|
|
c0e0f8dc2a | ||
|
|
ffb044ffc6 | ||
|
|
1c4f029bf4 | ||
|
|
6812d2ba7d | ||
|
|
c0b5d60715 | ||
|
|
c814874cb6 | ||
|
|
cd3aef47a5 | ||
|
|
338fdb509a | ||
|
|
660efe5e16 | ||
|
|
58a2965fea | ||
|
|
c614d7ec6a | ||
|
|
e017238aca | ||
|
|
c37a5ba956 | ||
|
|
da5969c2fd | ||
|
|
990107a1fa | ||
|
|
42eb86b624 | ||
|
|
b65a199e54 | ||
|
|
88e3bcdf63 | ||
|
|
0fbfa32e6b | ||
|
|
20405716bc | ||
|
|
8da7406e8f | ||
|
|
97fd3df8f7 | ||
|
|
b9b33b5351 | ||
|
|
19ecb1bbb3 | ||
|
|
f6043f4ac6 | ||
|
|
ed1941abdb | ||
|
|
24d24728dc | ||
|
|
77db4cd19f | ||
|
|
adbb03e5cb | ||
|
|
f0226f1ea7 | ||
|
|
be5df2677b | ||
|
|
3d4a856bb2 | ||
|
|
1b1233d26a | ||
|
|
c4b0e0a810 | ||
|
|
1dee8ef355 | ||
|
|
8cee173f92 | ||
|
|
19e0e6d962 | ||
|
|
ef8fd70475 | ||
|
|
6df05f4b7f | ||
|
|
4e1491a0cc | ||
|
|
55091154c4 | ||
|
|
a0b1cb2993 | ||
|
|
7617081637 | ||
|
|
96e7f37799 | ||
|
|
a0bf22de86 | ||
|
|
9a1aecc002 | ||
|
|
ad941fcbb2 | ||
|
|
e5ca30dc26 | ||
|
|
a23eadf5cf | ||
|
|
82417f4f85 | ||
|
|
af788133c2 | ||
|
|
a6dc156a79 | ||
|
|
25bebdc172 | ||
|
|
b55d96169f | ||
|
|
1a809fa7a3 | ||
|
|
313a5fddbe | ||
|
|
732d806820 | ||
|
|
11ed8a2f21 | ||
|
|
3aa8f51015 | ||
|
|
85b038dada | ||
|
|
dd25527a62 | ||
|
|
ac372bc6fc | ||
|
|
63ce4fe0bd | ||
|
|
398169f68e | ||
|
|
46a24af373 | ||
|
|
0cd9bb658f | ||
|
|
b0678fd259 | ||
|
|
9cb4a1779e | ||
|
|
3cb4700b16 | ||
|
|
94921fe03f | ||
|
|
0202865837 | ||
|
|
b9b911eb3b | ||
|
|
54fb2c5f81 | ||
|
|
2df97ff986 | ||
|
|
4374619ba2 | ||
|
|
6b6ebd6968 | ||
|
|
b41fdc2bbd | ||
|
|
3cac37d1a5 | ||
|
|
2f7259714a | ||
|
|
c1076461e2 | ||
|
|
6fdf845349 | ||
|
|
c80b855dab | ||
|
|
83fc11e75b | ||
|
|
9654892e54 | ||
|
|
b46fad1442 | ||
|
|
ff652dbe40 | ||
|
|
897483884a | ||
|
|
ba68990ef8 | ||
|
|
de29a6532f | ||
|
|
9045791e7f | ||
|
|
ab2fa0ba88 | ||
|
|
56b67cbc47 | ||
|
|
b6a1608e73 | ||
|
|
6277c20e4c | ||
|
|
2fc282477d | ||
|
|
917f393f7a | ||
|
|
045504ecf7 | ||
|
|
7efc0ae8ca | ||
|
|
3958dce341 | ||
|
|
d1a9012deb | ||
|
|
dbde993a76 | ||
|
|
96c66d2809 | ||
|
|
df1633b2a1 | ||
|
|
24f18f0ac2 | ||
|
|
416fea2aa5 | ||
|
|
93286a646f | ||
|
|
8fba36c05e | ||
|
|
b443be1795 | ||
|
|
4892192c6c | ||
|
|
6b7a8e2bd3 | ||
|
|
c5f5445f4b | ||
|
|
8a65f43a0b | ||
|
|
76e4a1a649 | ||
|
|
5167c0c886 | ||
|
|
9d3d8f6c82 | ||
|
|
7e4a1169af | ||
|
|
773ad89951 | ||
|
|
c2adcdb051 | ||
|
|
b75bc6d03d | ||
|
|
e3b80f11ad | ||
|
|
f33a2ef11b | ||
|
|
130b21f738 | ||
|
|
ee954d6a4e | ||
|
|
54215bdb18 | ||
|
|
0db18a7caf | ||
|
|
a1c0f4dbb4 | ||
|
|
db7d3184c9 | ||
|
|
7dfe6ac3ca | ||
|
|
8fd921c60e | ||
|
|
fec29d03fd | ||
|
|
9bd205f190 | ||
|
|
089037663e | ||
|
|
8c0bc3e2ef | ||
|
|
db21045cfb | ||
|
|
fbf0f2271c | ||
|
|
7e78ed2139 | ||
|
|
5676acbba6 | ||
|
|
43b155d7b8 | ||
|
|
93158226b6 | ||
|
|
d3bf4ef198 | ||
|
|
fc9d13a03c | ||
|
|
22d2036657 | ||
|
|
9e15960581 | ||
|
|
738ce25ff0 | ||
|
|
5da9347e2c | ||
|
|
771e892b31 | ||
|
|
9df5f942de | ||
|
|
0fb5f3233f | ||
|
|
f17ce87e45 | ||
|
|
a497a944a6 | ||
|
|
2e69bbe371 | ||
|
|
875f01c358 | ||
|
|
8e1d827819 | ||
|
|
6a4a8ab2d9 | ||
|
|
8278576227 | ||
|
|
7d0aa4d7a5 | ||
|
|
2b4512ee3f | ||
|
|
413e505683 | ||
|
|
0f1edba5f1 | ||
|
|
e23a9c976a | ||
|
|
1449edb8af | ||
|
|
d177db5a35 | ||
|
|
1245e222a7 | ||
|
|
336154fd9b | ||
|
|
0ee14b4b90 | ||
|
|
5a9e5cdac4 | ||
|
|
10bb177664 | ||
|
|
69762bf4b4 | ||
|
|
e17cc79cb3 | ||
|
|
60c29fd159 | ||
|
|
7481c98dbc | ||
|
|
796b45601e | ||
|
|
b5347cebc3 | ||
|
|
65ce5ca752 | ||
|
|
d1e62ef8f2 | ||
|
|
db8daf4c59 | ||
|
|
80240cb9f2 | ||
|
|
4da0731664 | ||
|
|
af357d4d8e | ||
|
|
8c76573395 | ||
|
|
939e9c32d5 | ||
|
|
e4ef659756 | ||
|
|
4b61452c62 | ||
|
|
d5130aa6ba | ||
|
|
6c9f317f31 | ||
|
|
1ab5609d4e | ||
|
|
78b626af23 | ||
|
|
046de84360 | ||
|
|
ca48dabcc7 | ||
|
|
9880a4e948 | ||
|
|
cb589219d8 | ||
|
|
6fff4c5254 | ||
|
|
4049c116d9 | ||
|
|
b720742f53 | ||
|
|
c1af050fa6 | ||
|
|
39f415d4be | ||
|
|
4590b9f6da | ||
|
|
ee6e0b1784 | ||
|
|
820c108548 | ||
|
|
239bb14e3a | ||
|
|
1bd7c8455f | ||
|
|
6986f179cd | ||
|
|
28af41b789 | ||
|
|
36bdaa99ec | ||
|
|
1ee44024b2 | ||
|
|
cd926283b3 | ||
|
|
04d210bd8b | ||
|
|
38895beb5d | ||
|
|
3fdc4d6ee0 | ||
|
|
baf27363aa | ||
|
|
da137f35de | ||
|
|
feeeae5918 | ||
|
|
02a04773c6 | ||
|
|
7e7b9f4fdb | ||
|
|
85e4a57c76 | ||
|
|
6fd7b2a7f3 | ||
|
|
24be1d0ff3 | ||
|
|
2867e0626f | ||
|
|
f0c3e59a6f | ||
|
|
4e11d92d19 | ||
|
|
07eee481cb | ||
|
|
8f146d1a2b | ||
|
|
1cc03e3aca | ||
|
|
023822b5d9 | ||
|
|
41ffd4455d | ||
|
|
810b92fbad | ||
|
|
6db31cbe74 | ||
|
|
b55a102d37 | ||
|
|
f338cdd2e5 | ||
|
|
76365a4564 | ||
|
|
109cffc3de | ||
|
|
c67339dc42 | ||
|
|
f56766be26 | ||
|
|
b1e1cc43e0 | ||
|
|
13aaec07cd | ||
|
|
08b9eab9f3 | ||
|
|
09ac3c615c | ||
|
|
19ce1cf4a7 | ||
|
|
d58ad6f68f | ||
|
|
866648192b | ||
|
|
3184eaf595 | ||
|
|
b12c2ea62f | ||
|
|
bcb95c55c9 | ||
|
|
229739575c | ||
|
|
4b76af2487 | ||
|
|
c383186808 | ||
|
|
2f602f8718 | ||
|
|
015462eddb | ||
|
|
de6d6c8714 | ||
|
|
1b2304146b | ||
|
|
f28cdc531f | ||
|
|
2aa4770b45 | ||
|
|
1d931a4bb6 | ||
|
|
9094c712d6 | ||
|
|
40a3177ae7 | ||
|
|
8ef89a8c80 | ||
|
|
ceb9ad9aa8 | ||
|
|
dec1877123 | ||
|
|
34aa7cb6b5 | ||
|
|
730ebb0070 | ||
|
|
c4a3820c6a | ||
|
|
d4a846a672 | ||
|
|
a125170840 | ||
|
|
d5d1d65bf3 | ||
|
|
fb45d73406 | ||
|
|
5ec3971380 | ||
|
|
63b6169475 | ||
|
|
ab0d713882 | ||
|
|
19661cc99c | ||
|
|
d58656571a | ||
|
|
4900c76752 | ||
|
|
d899ff7f7b | ||
|
|
36651553fe | ||
|
|
d9596fcac9 | ||
|
|
aa7b77b413 | ||
|
|
b3f06c6fac | ||
|
|
3483be4bed | ||
|
|
d7a0d26fd2 | ||
|
|
90666cdfc1 | ||
|
|
3072de610c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,8 @@
|
||||
**/*.swp
|
||||
|
||||
run/
|
||||
autotest/
|
||||
dist/
|
||||
|
||||
# Gradle
|
||||
build/
|
||||
|
||||
@@ -6,12 +6,11 @@ services:
|
||||
- docker
|
||||
|
||||
install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install jshon
|
||||
- docker build -t cabaletta/baritone .
|
||||
- travis_retry docker build -t cabaletta/baritone .
|
||||
|
||||
script:
|
||||
- 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; sh scripts/build.sh; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||
- 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
|
||||
- cat dist/checksums.txt
|
||||
|
||||
12
Dockerfile
12
Dockerfile
@@ -13,14 +13,12 @@ RUN apt install --target-release jessie-backports \
|
||||
|
||||
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 --force-yes unzip wget
|
||||
|
||||
ADD . /code
|
||||
|
||||
RUN echo "\nrunClient {\nargs \"--width\",\"128\",\"--height\",\"128\"\n}" >> /code/build.gradle
|
||||
|
||||
RUN dpkg -i /code/scripts/xvfb_1.16.4-1_amd64.deb
|
||||
COPY . /code
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# this .deb is specially patched to support lwjgl
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
19
FEATURES.md
19
FEATURES.md
@@ -10,17 +10,21 @@
|
||||
- **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 modified version of A*.
|
||||
Baritone uses A*, with some modifications:
|
||||
|
||||
- **Incremental cost backoff** Since most of the time Baritone only knows the terrain up to the render distance, it can't calculate a full path to the goal. Therefore it needs to select a segment to execute first (assuming it will calculate the next segment at the end of this one). It uses incremental cost backoff to select the best node by varying metrics, then paths to that node. This is unchanged from MineBot and I made a <a href="https://docs.google.com/document/d/1WVHHXKXFdCR1Oz__KtK8sFqyvSwJN_H4lftkHFgmzlc/edit">write-up</a> that still applies. In essence, it keeps track of the best node by various increasing coefficients, then picks the node with the least coefficient that goes at least 5 blocks from the starting position.
|
||||
- **Segmented calculation** Traditional A* calculates until the most promising node is in the goal, however in the environment of Minecraft with a limited render distance, we don't know the environment all the way to our goal. Baritone has three possible ways for path calculation to end: finding a path all the way to the goal, running out of time, or getting to the render distance. In the latter two scenarios, the selection of which segment to actually execute falls to the next item (incremental cost backoff). Whenever the path calculation thread finds that the best / most promising node is at the edge of loaded chunks, it increments a counter. If this happens more than 50 times (configurable), path calculation exits early. This happens with very low render distances. Otherwise, calculation continues until the timeout is hit (also configurable) or we find a path all the way to the goal.
|
||||
- **Incremental cost backoff** When path calculation exits early without getting all the way to the goal, Baritone it needs to select a segment to execute first (assuming it will calculate the next segment at the end of this one). It uses incremental cost backoff to select the best node by varying metrics, then paths to that node. This is unchanged from MineBot and I made a <a href="https://docs.google.com/document/d/1WVHHXKXFdCR1Oz__KtK8sFqyvSwJN_H4lftkHFgmzlc/edit">write-up</a> that still applies. In essence, it keeps track of the best node by various increasing coefficients, then picks the node with the least coefficient that goes at least 5 blocks from the starting position.
|
||||
- **Minimum improvement repropagation** The pathfinder ignores alternate routes that provide minimal improvements (less than 0.01 ticks of improvement), because the calculation cost of repropagating this to all connected nodes is much higher than the half-millisecond path time improvement it would get.
|
||||
- **Backtrack cost favoring** While calculating the next segment, Baritone favors backtracking its current segment slightly, as a tiebreaker. 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 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/main/java/baritone/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:
|
||||
@@ -30,6 +34,7 @@ The pathing goal can be set to any of these options:
|
||||
- **GoalTwoBlocks** a block position that the player should stand in, either at foot or eye level
|
||||
- **GoalGetToBlock** a block position that the player should stand adjacent to, below, or on top of
|
||||
- **GoalNear** a block position that the player should get within a certain radius of, used for following entities
|
||||
- **GoalAxis** a block position on an axis or diagonal axis (so x=0, z=0, or x=z), and y=120 (configurable)
|
||||
|
||||
And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one of which satisfies the goal. For example, `mine diamond_ore` creates a `GoalComposite` of `GoalTwoBlocks`s for every diamond ore location it knows of.
|
||||
|
||||
@@ -38,12 +43,10 @@ And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one o
|
||||
Things it doesn't have yet
|
||||
- Trapdoors
|
||||
- Sprint jumping in a 1x2 corridor
|
||||
- Parkour (jumping over gaps of any length) [IN PROGRESS]
|
||||
|
||||
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
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Integration between Baritone and Impact
|
||||
Impact 4.4 will have Baritone included on release, however, if you're impatient, you can install Baritone into Impact 4.3 right now!
|
||||
Impact 4.4 has Baritone included.
|
||||
|
||||
These instructions apply to Impact 4.3.
|
||||
|
||||
For Forge follow the instructions in [Setup](SETUP.md).
|
||||
|
||||
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.
|
||||
@@ -9,25 +15,19 @@ There are some basic steps to getting Baritone setup with Impact.
|
||||
- How to use Baritone
|
||||
|
||||
## Acquiring a build of Baritone
|
||||
There are 3 methods of acquiring a build of Baritone (While it is still in development)
|
||||
There are two methods of acquiring a build of Baritone
|
||||
|
||||
### Official Build (Not always up to date)
|
||||
Download the "official" jar (as of commit <a href="https://github.com/cabaletta/baritone/commit/61cf103df451a5aafa6bfbe5ed089043212f0b42">61cf103</a>,
|
||||
built on September 24) from <a href="https://www.dropbox.com/s/imc6xwwpwsh3i0y/baritone-1.0.0.jar?dl=0">here</a>.
|
||||
### 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`. **For the rest of this guide, replace `X.Y.Z` with the actual numeric version you are using.**
|
||||
|
||||
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).
|
||||
|
||||
### 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``
|
||||
|
||||
### Cutting Edge Release
|
||||
If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit
|
||||
from his Jenkins server, found <a href="https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/">here</a>.
|
||||
You can either build Baritone through a command line or through IntelliJ's UI, information on that can be found [here](SETUP.md#building).
|
||||
|
||||
## Placing Baritone in the libraries directory
|
||||
``/libraries`` is a neat directory in your <a href="https://minecraft.gamepedia.com/.minecraft">Minecraft Installation Directory</a>
|
||||
@@ -38,7 +38,7 @@ putting baritone.
|
||||
- ``cabaletta``
|
||||
- ``baritone``
|
||||
- ``X.Y.Z``
|
||||
- Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder
|
||||
- Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder, renamed like so:
|
||||
- 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
|
||||
@@ -69,18 +69,22 @@ The final step is "registering" the Baritone library with Impact, so that it loa
|
||||
},
|
||||
...
|
||||
```
|
||||
- Create a new object in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably.
|
||||
- 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"``
|
||||
- ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweaker"``
|
||||
- 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>.
|
||||
|
||||
- [Baritone chat control usage](USAGE.md)
|
||||
82
README.md
82
README.md
@@ -1,71 +1,69 @@
|
||||
# Baritone
|
||||
[](https://travis-ci.com/cabaletta/baritone)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](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://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://minecraft.gamepedia.com/1.12.2)
|
||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||
[](https://github.com/cabaletta/baritone/commit/)
|
||||
[](https://github.com/EmotionalLove/Asuna/)
|
||||
[](https://impactdevelopment.github.io/)
|
||||
[](https://github.com/zeroeightysix/KAMI/)
|
||||
[](https://wweclient.com/)
|
||||
[](https://futureclient.net/)
|
||||
[](https://github.com/fr1kin/ForgeHax)
|
||||
|
||||
<!---
|
||||
Plutie's jenkins is dead right now, so here's the old badge that was used:
|
||||
[](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/)
|
||||
--->
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Unofficial Jenkins: []()
|
||||
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.
|
||||
|
||||
A Minecraft pathfinder bot. 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).
|
||||
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 [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day for the last 6 months =D 🦀
|
||||
|
||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||
|
||||
Here are some links to help to get started:
|
||||
|
||||
- [Features](FEATURES.md)
|
||||
|
||||
- [Baritone + Impact](IMPACT.md)
|
||||
- [Setup](SETUP.md)
|
||||
|
||||
There's also some useful information down below
|
||||
- [Installation](INSTALL.md)
|
||||
|
||||
# Setup
|
||||
- [Javadocs](https://baritone.leijurv.com/)
|
||||
|
||||
## IntelliJ's Gradle UI
|
||||
- Open the project in IntelliJ as a Gradle project
|
||||
- Run the Gradle task `setupDecompWorkspace`
|
||||
- Run the Gradle task `genIntellijRuns`
|
||||
- Refresh the Gradle project (or just restart IntelliJ)
|
||||
- Select the "Minecraft Client" launch config and run
|
||||
|
||||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
$ gradlew run
|
||||
```
|
||||
|
||||
Setting up for IntelliJ:
|
||||
```
|
||||
$ gradlew setupDecompWorkspace
|
||||
$ gradlew --refresh-dependencies
|
||||
$ gradlew genIntellijRuns
|
||||
```
|
||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#allowBreak)
|
||||
|
||||
# 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.
|
||||
- [Baritone chat control usage](USAGE.md)
|
||||
|
||||
# API example
|
||||
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L;
|
||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
||||
|
||||
BaritoneAPI.getPathingBehavior().setGoal(new GoalXZ(10000, 20000));
|
||||
BaritoneAPI.getPathingBehavior().path();
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
|
||||
```
|
||||
|
||||
# FAQ
|
||||
|
||||
## Can I use Baritone as a library in my hacked client?
|
||||
## 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 License)
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
@@ -73,4 +71,4 @@ Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pai
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
It's named for FitMC's deep sultry voice.
|
||||
It's named for FitMC's deep sultry voice.
|
||||
|
||||
95
SETUP.md
Normal file
95
SETUP.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# Setup
|
||||
|
||||
## Prebuilt
|
||||
(not always completely up to date with latest features)
|
||||
|
||||
Download from the [Releases](https://github.com/cabaletta/baritone/releases)
|
||||
|
||||
The Forge releases 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`
|
||||
|
||||
Previously (Baritone v1.1.2 and below), it was not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. Forge 14.23.4.2743 or **older** worked with Baritone v1.1.2 and lower. Newer versions of Forge "worked", sort of, but Baritone's movement became unreliable and `freeLook` must be off.
|
||||
|
||||
## 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).
|
||||
|
||||
- **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.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"`).
|
||||
|
||||
Impact 4.4 **only** works with builds from the quite outdated `impact4.4-compat` branch. If you must have the latest Baritone features with Impact, and can't wait for 4.5, consider creating a standalone (non forge) build then adding it to Impact 4.**3** via the instructions in [Install](INSTALL.md).
|
||||
|
||||
## 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
|
||||
79
USAGE.md
Normal file
79
USAGE.md
Normal file
@@ -0,0 +1,79 @@
|
||||
(assuming you already have Baritone [set up](SETUP.md))
|
||||
|
||||
# Prefix
|
||||
|
||||
Baritone commands can 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.
|
||||
|
||||
Therefore you can use a prefix before your messages.
|
||||
|
||||
On Baritone v1.1.0 and newer: The prefix is `#` by default. Anything beginning with `#` isn't sent, and is only interpreted by Baritone.
|
||||
For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting.
|
||||
|
||||
**Only** in Impact 4.4 is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat.
|
||||
|
||||
Other clients like Kami and Asuna have their own custom things (like `-path`), and can disable direct chat control entirely.
|
||||
|
||||
|
||||
|
||||
# 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/main/java/baritone/utils/ExampleBaritoneControl.java#L53).
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
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 go to a certain coordinate
|
||||
- `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.)
|
||||
- `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time).
|
||||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `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.
|
||||
- `render` to rerender the world in case `renderCachedChunks` is being glitchy
|
||||
- `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/main/java/baritone/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#allowBreak">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`
|
||||
- `renderCachedChunks` (and `cachedChunksOpacity`) <-- very fun but you need a beefy computer
|
||||
- `avoidance`
|
||||
- `legitMine`
|
||||
- `followRadius`
|
||||
|
||||
|
||||
|
||||
# Troubleshooting / common issues
|
||||
|
||||
## Baritone highlights a block in green but gets completely stuck? Also I'm using Baritone with Future?
|
||||
Baritone is trying to right click to place a block there, but it can't since there's a conflicting mixin. Baritone can't force click right click when Future is also installed. Left click **does work** on recent Baritone even with Future, however. For now, turn off `allowPlace` and Baritone will only search for paths that don't require placing blocks to complete. `allowBreak` can remain on.
|
||||
|
||||
## 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`.
|
||||
51
build.gradle
51
build.gradle
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '0.0.3'
|
||||
version '1.1.5'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -37,6 +37,10 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'
|
||||
@@ -44,6 +48,7 @@ apply plugin: 'org.spongepowered.mixin'
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -54,10 +59,12 @@ sourceSets {
|
||||
|
||||
minecraft {
|
||||
version = '1.12.2'
|
||||
mappings = 'snapshot_20180731'
|
||||
mappings = 'stable_39'
|
||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||
runDir = 'run'
|
||||
makeObfSourceJar = false
|
||||
|
||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||
makeObfSourceJar = true
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -67,9 +74,15 @@ repositories {
|
||||
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'
|
||||
@@ -82,10 +95,40 @@ dependencies {
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv notch
|
||||
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
|
||||
}
|
||||
|
||||
jar {
|
||||
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)
|
||||
|
||||
3
buildSrc/.gitignore
vendored
Normal file
3
buildSrc/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
build/
|
||||
.gradle/
|
||||
out/
|
||||
25
buildSrc/build.gradle
Normal file
25
buildSrc/build.gradle
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
compile group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.task;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/12/2018
|
||||
*/
|
||||
class BaritoneGradleTask extends DefaultTask {
|
||||
|
||||
protected static final String
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
||||
PROGUARD_CONFIG_DEST = "template.pro",
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
|
||||
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_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, 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.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
|
||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||
|
||||
if (!Files.exists(this.artifactPath)) {
|
||||
throw new IllegalStateException("Artifact not found! Run build first!");
|
||||
}
|
||||
}
|
||||
|
||||
protected void write(InputStream stream, Path file) throws Exception {
|
||||
if (Files.exists(file)) {
|
||||
Files.delete(file);
|
||||
}
|
||||
Files.copy(stream, file);
|
||||
}
|
||||
|
||||
protected String formatVersion(String string) {
|
||||
return String.format(string, this.artifactName, this.artifactVersion);
|
||||
}
|
||||
|
||||
protected Path getRelativeFile(String file) {
|
||||
return Paths.get(new File(file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getTemporaryFile(String file) {
|
||||
return Paths.get(new File(getTemporaryDir(), file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getBuildFile(String file) {
|
||||
return getRelativeFile("build/libs/" + file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.task;
|
||||
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/12/2018
|
||||
*/
|
||||
public class CreateDistTask extends BaritoneGradleTask {
|
||||
|
||||
private static MessageDigest SHA1_DIGEST;
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
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 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/");
|
||||
if (!Files.exists(dir)) {
|
||||
Files.createDirectory(dir);
|
||||
}
|
||||
|
||||
// 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.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, forgeApi, standalone, forgeStandalone, unoptimized)
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
shasum.forEach(System.out::println);
|
||||
|
||||
// Write the checksums to a file
|
||||
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
|
||||
}
|
||||
|
||||
private static synchronized String sha1(Path path) {
|
||||
try {
|
||||
if (SHA1_DIGEST == null) {
|
||||
SHA1_DIGEST = MessageDigest.getInstance("SHA-1");
|
||||
}
|
||||
return DatatypeConverter.printHexBinary(SHA1_DIGEST.digest(Files.readAllBytes(path))).toLowerCase();
|
||||
} catch (Exception e) {
|
||||
// haha no thanks
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
333
buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java
Normal file
333
buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java
Normal file
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* 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.task;
|
||||
|
||||
import baritone.gradle.util.Determinizer;
|
||||
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;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/11/2018
|
||||
*/
|
||||
public class ProguardTask extends BaritoneGradleTask {
|
||||
|
||||
private static final Pattern TEMP_LIBRARY_PATTERN = Pattern.compile("-libraryjars 'tempLibraries\\/([a-zA-Z0-9/_\\-\\.]+)\\.jar'");
|
||||
|
||||
@Input
|
||||
private String url;
|
||||
|
||||
@Input
|
||||
private String extract;
|
||||
|
||||
private List<String> requiredLibraries;
|
||||
|
||||
private File mixin;
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.verifyArtifacts();
|
||||
|
||||
// "Haha brady why don't you make separate tasks"
|
||||
processArtifact();
|
||||
downloadProguard();
|
||||
extractProguard();
|
||||
generateConfigs();
|
||||
acquireDependencies();
|
||||
proguardApi();
|
||||
proguardStandalone();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void processArtifact() throws Exception {
|
||||
if (Files.exists(this.artifactUnoptimizedPath)) {
|
||||
Files.delete(this.artifactUnoptimizedPath);
|
||||
}
|
||||
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
||||
}
|
||||
|
||||
private void downloadProguard() throws Exception {
|
||||
Path proguardZip = getTemporaryFile(PROGUARD_ZIP);
|
||||
if (!Files.exists(proguardZip)) {
|
||||
write(new URL(this.url).openStream(), proguardZip);
|
||||
}
|
||||
}
|
||||
|
||||
private void extractProguard() throws Exception {
|
||||
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
|
||||
if (!Files.exists(proguardJar)) {
|
||||
ZipFile zipFile = new ZipFile(getTemporaryFile(PROGUARD_ZIP).toFile());
|
||||
ZipEntry zipJarEntry = zipFile.getEntry(this.extract);
|
||||
write(zipFile.getInputStream(zipJarEntry), proguardJar);
|
||||
zipFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void generateConfigs() throws Exception {
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
|
||||
// Setup the template that will be used to derive the API and Standalone configs
|
||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||
template.add(0, "-injars " + this.artifactPath.toString());
|
||||
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
|
||||
|
||||
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
|
||||
Process p = new ProcessBuilder("java", "-verbose").start();
|
||||
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
||||
template.add(2, "-libraryjars '" + out + "'");
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||
|
||||
// For the Standalone config, don't keep the API package
|
||||
List<String> standalone = new ArrayList<>(template);
|
||||
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
this.requiredLibraries = new ArrayList<>();
|
||||
template.forEach(line -> {
|
||||
if (!line.startsWith("#")) {
|
||||
Matcher m = TEMP_LIBRARY_PATTERN.matcher(line);
|
||||
if (m.find()) {
|
||||
this.requiredLibraries.add(m.group(1));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void acquireDependencies() throws Exception {
|
||||
|
||||
// Create a map of all of the dependencies that we are able to access in this project
|
||||
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
||||
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
||||
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config ->
|
||||
config.getAllDependencies().forEach(dependency ->
|
||||
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), Pair.of(config, dependency))));
|
||||
|
||||
// Create the directory if it doesn't already exist
|
||||
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
||||
if (!Files.exists(tempLibraries)) {
|
||||
Files.createDirectory(tempLibraries);
|
||||
}
|
||||
|
||||
// Iterate the required libraries to copy them to tempLibraries
|
||||
for (String lib : this.requiredLibraries) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Find a configuration/dependency pair that matches the desired library
|
||||
Pair<Configuration, Dependency> pair = null;
|
||||
for (Map.Entry<String, Pair<Configuration, Dependency>> entry : dependencyLookupMap.entrySet()) {
|
||||
if (entry.getKey().startsWith(lib)) {
|
||||
pair = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// The pair must be non-null
|
||||
Objects.requireNonNull(pair);
|
||||
|
||||
// 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(), 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(), Optional.empty());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Optional.of(mixin));
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
try {
|
||||
Files.delete(this.proguardOut);
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setExtract(String extract) {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
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)) {
|
||||
Files.delete(this.proguardOut);
|
||||
}
|
||||
|
||||
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
|
||||
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
|
||||
.directory(getTemporaryFile("").toFile()) // Set the working directory to the temporary folder]
|
||||
.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(), 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();
|
||||
if (exitCode != 0) {
|
||||
throw new IllegalStateException("Proguard exited with code " + exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void printOutputLog(InputStream stream, PrintStream outerr) {
|
||||
new Thread(() -> {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
outerr.println(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
160
buildSrc/src/main/java/baritone/gradle/util/Determinizer.java
Normal file
160
buildSrc/src/main/java/baritone/gradle/util/Determinizer.java
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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 com.google.gson.*;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Make a .jar file deterministic by sorting all entries by name, and setting all the last modified times to 42069.
|
||||
* This makes the build 100% reproducible since the timestamp when you built it no longer affects the final file.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Determinizer {
|
||||
|
||||
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);
|
||||
|
||||
try (
|
||||
JarFile jarFile = new JarFile(new File(inputPath));
|
||||
JarOutputStream jos = new JarOutputStream(new FileOutputStream(new File(outputPath)))
|
||||
) {
|
||||
|
||||
List<JarEntry> entries = jarFile.stream()
|
||||
.sorted(Comparator.comparing(JarEntry::getName))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (JarEntry entry : entries) {
|
||||
if (entry.getName().equals("META-INF/fml_cache_annotation.json")) {
|
||||
continue;
|
||||
}
|
||||
if (entry.getName().equals("META-INF/fml_cache_class_versions.json")) {
|
||||
continue;
|
||||
}
|
||||
JarEntry clone = new JarEntry(entry.getName());
|
||||
clone.setTime(42069);
|
||||
jos.putNextEntry(clone);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream is, OutputStream os) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
private static String writeSorted(JsonObject in) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
||||
JsonWriter jw = new JsonWriter(writer);
|
||||
ORDERED_JSON_WRITER.write(jw, in);
|
||||
return writer.toString() + "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* All credits go to GSON and its contributors. GSON is licensed under the Apache 2.0 License.
|
||||
* This implementation has been modified to write {@link JsonObject} keys in order.
|
||||
*
|
||||
* @see <a href="https://github.com/google/gson/blob/master/LICENSE">GSON License</a>
|
||||
* @see <a href="https://github.com/google/gson/blob/master/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java#L698">Original Source</a>
|
||||
*/
|
||||
private static final TypeAdapter<JsonElement> ORDERED_JSON_WRITER = new TypeAdapter<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public JsonElement read(JsonReader in) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, JsonElement value) throws IOException {
|
||||
if (value == null || value.isJsonNull()) {
|
||||
out.nullValue();
|
||||
} else if (value.isJsonPrimitive()) {
|
||||
JsonPrimitive primitive = value.getAsJsonPrimitive();
|
||||
if (primitive.isNumber()) {
|
||||
out.value(primitive.getAsNumber());
|
||||
} else if (primitive.isBoolean()) {
|
||||
out.value(primitive.getAsBoolean());
|
||||
} else {
|
||||
out.value(primitive.getAsString());
|
||||
}
|
||||
|
||||
} else if (value.isJsonArray()) {
|
||||
out.beginArray();
|
||||
for (JsonElement e : value.getAsJsonArray()) {
|
||||
write(out, e);
|
||||
}
|
||||
out.endArray();
|
||||
|
||||
} else if (value.isJsonObject()) {
|
||||
out.beginObject();
|
||||
|
||||
List<Map.Entry<String, JsonElement>> entries = new ArrayList<>(value.getAsJsonObject().entrySet());
|
||||
entries.sort(Comparator.comparing(Map.Entry::getKey));
|
||||
for (Map.Entry<String, JsonElement> e : entries) {
|
||||
out.name(e.getKey());
|
||||
write(out, e.getValue());
|
||||
}
|
||||
out.endObject();
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("Couldn't write " + value.getClass());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
set -e # this makes the whole script fail immediately if any one of these commands fails
|
||||
./gradlew build
|
||||
export VERSION=$(cat build.gradle | grep "version '" | cut -d "'" -f 2-2)
|
||||
|
||||
wget -nv https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip
|
||||
unzip proguard6.0.3.zip 2>&1 > /dev/null
|
||||
cd build/libs
|
||||
echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version
|
||||
cat ../../scripts/proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" >> api.pro # remove default rt jar and injar lines
|
||||
echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location
|
||||
tail api.pro # debug, print out what the previous two commands generated
|
||||
cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api
|
||||
wget -nv https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry
|
||||
mv tempLibraries.zip?dl=1 tempLibraries.zip
|
||||
unzip tempLibraries.zip
|
||||
mkdir ../../dist
|
||||
java -jar ../../proguard6.0.3/lib/proguard.jar @api.pro
|
||||
mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-api-$VERSION.jar
|
||||
java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro
|
||||
mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar
|
||||
mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar
|
||||
cd ../../dist
|
||||
shasum * | tee checksums.txt
|
||||
cd ..
|
||||
44
scripts/proguard.pro
vendored
44
scripts/proguard.pro
vendored
@@ -1,7 +1,3 @@
|
||||
-injars baritone-0.0.2.jar
|
||||
-outjars Obfuscated
|
||||
|
||||
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
|
||||
@@ -12,14 +8,21 @@
|
||||
-overloadaggressively
|
||||
-dontusemixedcaseclassnames
|
||||
|
||||
# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with minecraft's obfd classes
|
||||
# instead of renaming to a, b, c, rename to baritone.a, baritone.b, baritone.c so as to not conflict with minecraft's obfd classes
|
||||
-flattenpackagehierarchy
|
||||
-repackageclasses 'baritone'
|
||||
|
||||
#-keep class baritone.behavior.** { *; }
|
||||
-keep class baritone.api.** { *; }
|
||||
#-keep class baritone.* { *; }
|
||||
#-keep class baritone.pathing.goals.** { *; }
|
||||
# lwjgl is weird
|
||||
-dontwarn org.lwjgl.opengl.GL14
|
||||
|
||||
-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
|
||||
|
||||
# setting names are reflected from field names, so keep field names
|
||||
-keepclassmembers class baritone.api.Settings {
|
||||
@@ -30,9 +33,11 @@
|
||||
-keep class baritone.launch.** { *; }
|
||||
|
||||
# copy all necessary libraries into tempLibraries to build
|
||||
-libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' # this is the rt jar
|
||||
|
||||
-libraryjars 'tempLibraries/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'
|
||||
|
||||
-libraryjars 'tempLibraries/authlib-1.5.25.jar'
|
||||
-libraryjars 'tempLibraries/codecjorbis-20101023.jar'
|
||||
@@ -48,22 +53,21 @@
|
||||
-libraryjars 'tempLibraries/httpclient-4.3.3.jar'
|
||||
-libraryjars 'tempLibraries/httpcore-4.3.2.jar'
|
||||
-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar'
|
||||
-libraryjars 'tempLibraries/java-objc-bridge-1.0.0-natives-osx.jar'
|
||||
-libraryjars 'tempLibraries/java-objc-bridge-1.0.0.jar'
|
||||
-libraryjars 'tempLibraries/jinput-2.0.5.jar'
|
||||
-libraryjars 'tempLibraries/jinput-platform-2.0.5-natives-osx.jar'
|
||||
-libraryjars 'tempLibraries/jna-4.4.0.jar'
|
||||
-libraryjars 'tempLibraries/jopt-simple-5.0.3.jar'
|
||||
-libraryjars 'tempLibraries/jsr305-3.0.1-sources.jar'
|
||||
-libraryjars 'tempLibraries/jsr305-3.0.1.jar'
|
||||
-libraryjars 'tempLibraries/jutils-1.0.0.jar'
|
||||
-libraryjars 'tempLibraries/libraryjavasound-20101123.jar'
|
||||
-libraryjars 'tempLibraries/librarylwjglopenal-20100824.jar'
|
||||
-libraryjars 'tempLibraries/log4j-api-2.8.1.jar'
|
||||
-libraryjars 'tempLibraries/log4j-core-2.8.1.jar'
|
||||
-libraryjars 'tempLibraries/lwjgl-2.9.2-nightly-20140822.jar'
|
||||
-libraryjars 'tempLibraries/lwjgl-platform-2.9.2-nightly-20140822-natives-osx.jar'
|
||||
-libraryjars 'tempLibraries/lwjgl_util-2.9.2-nightly-20140822.jar'
|
||||
|
||||
# startsWith is used to check the library, and mac/linux differ in which version they use
|
||||
# this is FINE
|
||||
-libraryjars 'tempLibraries/lwjgl-.jar'
|
||||
-libraryjars 'tempLibraries/lwjgl_util-.jar'
|
||||
|
||||
-libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar'
|
||||
-libraryjars 'tempLibraries/oshi-core-1.1.jar'
|
||||
-libraryjars 'tempLibraries/patchy-1.1.jar'
|
||||
@@ -72,8 +76,8 @@
|
||||
-libraryjars 'tempLibraries/soundsystem-20120107.jar'
|
||||
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
||||
|
||||
-libraryjars 'tempLibraries/mixin-0.7.8-SNAPSHOT.jar'
|
||||
-libraryjars 'tempLibraries/launchwrapper-1.12.jar'
|
||||
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
||||
-libraryjars 'tempLibraries/launchwrapper-1.11.jar' # TODO why does only 1.11.jar exist?
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.behavior.*;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* API exposure for various things implemented in Baritone.
|
||||
@@ -28,72 +30,25 @@ import baritone.api.cache.IWorldProvider;
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public class BaritoneAPI {
|
||||
public final class BaritoneAPI {
|
||||
|
||||
// General
|
||||
private static final Settings settings = new Settings();
|
||||
private static IWorldProvider worldProvider;
|
||||
private static final IBaritoneProvider provider;
|
||||
private static final Settings settings;
|
||||
|
||||
// Behaviors
|
||||
private static IFollowBehavior followBehavior;
|
||||
private static ILookBehavior lookBehavior;
|
||||
private static IMemoryBehavior memoryBehavior;
|
||||
private static IMineBehavior mineBehavior;
|
||||
private static IPathingBehavior pathingBehavior;
|
||||
static {
|
||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||
provider = instances.next();
|
||||
|
||||
public static IFollowBehavior getFollowBehavior() {
|
||||
return followBehavior;
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings);
|
||||
}
|
||||
|
||||
public static ILookBehavior getLookBehavior() {
|
||||
return lookBehavior;
|
||||
}
|
||||
|
||||
public static IMemoryBehavior getMemoryBehavior() {
|
||||
return memoryBehavior;
|
||||
}
|
||||
|
||||
public static IMineBehavior getMineBehavior() {
|
||||
return mineBehavior;
|
||||
}
|
||||
|
||||
public static IPathingBehavior getPathingBehavior() {
|
||||
return pathingBehavior;
|
||||
public static IBaritoneProvider getProvider() {
|
||||
return BaritoneAPI.provider;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
return BaritoneAPI.settings;
|
||||
}
|
||||
|
||||
public static IWorldProvider getWorldProvider() {
|
||||
return worldProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* FOR INTERNAL USE ONLY
|
||||
*/
|
||||
public static void registerProviders(
|
||||
IWorldProvider worldProvider
|
||||
) {
|
||||
BaritoneAPI.worldProvider = worldProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* FOR INTERNAL USE ONLY
|
||||
*/
|
||||
// @formatter:off
|
||||
public static void registerDefaultBehaviors(
|
||||
IFollowBehavior followBehavior,
|
||||
ILookBehavior lookBehavior,
|
||||
IMemoryBehavior memoryBehavior,
|
||||
IMineBehavior mineBehavior,
|
||||
IPathingBehavior pathingBehavior
|
||||
) {
|
||||
BaritoneAPI.followBehavior = followBehavior;
|
||||
BaritoneAPI.lookBehavior = lookBehavior;
|
||||
BaritoneAPI.memoryBehavior = memoryBehavior;
|
||||
BaritoneAPI.mineBehavior = mineBehavior;
|
||||
BaritoneAPI.pathingBehavior = pathingBehavior;
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
79
src/api/java/baritone/api/IBaritone.java
Normal file
79
src/api/java/baritone/api/IBaritone.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.process.IFollowProcess;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.process.IMineProcess;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/29/2018
|
||||
*/
|
||||
public interface IBaritone {
|
||||
|
||||
/**
|
||||
* @return The {@link IFollowProcess} instance
|
||||
* @see IFollowProcess
|
||||
*/
|
||||
IFollowProcess getFollowProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link ILookBehavior} instance
|
||||
* @see ILookBehavior
|
||||
*/
|
||||
ILookBehavior getLookBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IMineProcess} instance
|
||||
* @see IMineProcess
|
||||
*/
|
||||
IMineProcess getMineProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IPathingBehavior} instance
|
||||
* @see IPathingBehavior
|
||||
*/
|
||||
IPathingBehavior getPathingBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IWorldProvider} instance
|
||||
* @see IWorldProvider
|
||||
*/
|
||||
IWorldProvider getWorldProvider();
|
||||
|
||||
IPathingControlManager getPathingControlManager();
|
||||
|
||||
IInputOverrideHandler getInputOverrideHandler();
|
||||
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
IPlayerContext getPlayerContext();
|
||||
|
||||
IEventBus getGameEventHandler();
|
||||
}
|
||||
71
src/api/java/baritone/api/IBaritoneProvider.java
Normal file
71
src/api/java/baritone/api/IBaritoneProvider.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Leijurv
|
||||
*/
|
||||
public interface IBaritoneProvider {
|
||||
|
||||
/**
|
||||
* Returns the primary {@link IBaritone} instance. This instance is persistent, and
|
||||
* is represented by the local player that is created by the game itself, not a "bot"
|
||||
* player through Baritone.
|
||||
*
|
||||
* @return The primary {@link IBaritone} instance.
|
||||
*/
|
||||
IBaritone getPrimaryBaritone();
|
||||
|
||||
/**
|
||||
* Returns all of the active {@link IBaritone} instances. This includes the local one
|
||||
* returned by {@link #getPrimaryBaritone()}.
|
||||
*
|
||||
* @return All active {@link IBaritone} instances.
|
||||
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
||||
*/
|
||||
List<IBaritone> getAllBaritones();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param player The player
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||
for (IBaritone baritone : getAllBaritones()) {
|
||||
if (player.equals(baritone.getPlayerContext().player())) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No baritone for player " + player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link IWorldScanner} instance. This is not a type returned by
|
||||
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
|
||||
*
|
||||
* @return The {@link IWorldScanner} instance.
|
||||
*/
|
||||
IWorldScanner getWorldScanner();
|
||||
}
|
||||
@@ -33,45 +33,67 @@ import java.util.function.Consumer;
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Settings {
|
||||
public final class Settings {
|
||||
|
||||
/**
|
||||
* Allow Baritone to break blocks
|
||||
*/
|
||||
public Setting<Boolean> allowBreak = new Setting<>(true);
|
||||
public final Setting<Boolean> allowBreak = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow Baritone to sprint
|
||||
*/
|
||||
public Setting<Boolean> allowSprint = new Setting<>(true);
|
||||
public final Setting<Boolean> allowSprint = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow Baritone to place blocks
|
||||
*/
|
||||
public Setting<Boolean> allowPlace = new Setting<>(true);
|
||||
public final Setting<Boolean> allowPlace = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow Baritone to move items in your inventory to your hotbar
|
||||
*/
|
||||
public final Setting<Boolean> allowInventory = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* It doesn't actually take twenty ticks to place a block, this cost is so high
|
||||
* because we want to generally conserve blocks which might be limited
|
||||
*/
|
||||
public Setting<Double> blockPlacementPenalty = new Setting<>(20D);
|
||||
public final Setting<Double> blockPlacementPenalty = new Setting<>(20D);
|
||||
|
||||
/**
|
||||
* This is just a tiebreaker to make it less likely to break blocks if it can avoid it.
|
||||
* For example, fire has a break cost of 0, this makes it nonzero, so all else being equal
|
||||
* it will take an otherwise equivalent route that doesn't require it to put out fire.
|
||||
*/
|
||||
public final Setting<Double> blockBreakAdditionalPenalty = new Setting<>(2D);
|
||||
|
||||
/**
|
||||
* Additional penalty for hitting the space bar (ascend, pillar, or parkour) because it uses hunger
|
||||
*/
|
||||
public final Setting<Double> jumpPenalty = new Setting<>(2D);
|
||||
|
||||
/**
|
||||
* Walking on water uses up hunger really quick, so penalize it
|
||||
*/
|
||||
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(5D);
|
||||
|
||||
/**
|
||||
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
|
||||
* Reliability: questionable.
|
||||
*/
|
||||
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
|
||||
public final Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow Baritone to assume it can walk on still water just like any other block.
|
||||
* This functionality is assumed to be provided by a separate library that might have imported Baritone.
|
||||
*/
|
||||
public Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Assume step functionality; don't jump on an Ascend.
|
||||
*/
|
||||
public Setting<Boolean> assumeStep = new Setting<>(false);
|
||||
public final Setting<Boolean> assumeStep = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Assume safe walk functionality; don't sneak on a backplace traverse.
|
||||
@@ -80,12 +102,28 @@ public class Settings {
|
||||
* it won't sneak right click, it'll just right click, which means it'll open the chest instead of placing
|
||||
* against it. That's why this defaults to off.
|
||||
*/
|
||||
public Setting<Boolean> assumeSafeWalk = new Setting<>(false);
|
||||
public final Setting<Boolean> assumeSafeWalk = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* If true, parkour is allowed to make jumps when standing on blocks at the maximum height, so player feet is y=256
|
||||
* <p>
|
||||
* Defaults to false because this fails on constantiam
|
||||
*/
|
||||
public final Setting<Boolean> allowJumpAt256 = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow descending diagonally
|
||||
* <p>
|
||||
* Safer than allowParkour yet still slightly unsafe, can make contact with unchecked adjacent blocks, so it's unsafe in the nether.
|
||||
* <p>
|
||||
* For a generic "take some risks" mode I'd turn on this one, parkour, and parkour place.
|
||||
*/
|
||||
public final Setting<Boolean> allowDiagonalDescend = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
||||
*/
|
||||
public Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
Item.getItemFromBlock(Blocks.DIRT),
|
||||
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
||||
Item.getItemFromBlock(Blocks.NETHERRACK)
|
||||
@@ -94,31 +132,42 @@ public class Settings {
|
||||
/**
|
||||
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
|
||||
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
|
||||
* <p>
|
||||
* Never turn this on lol
|
||||
*/
|
||||
public Setting<Boolean> allowVines = new Setting<>(false);
|
||||
public final Setting<Boolean> allowVines = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Slab behavior is complicated, disable this for higher path reliability. Leave enabled if you have bottom slabs
|
||||
* everywhere in your base.
|
||||
*/
|
||||
public Setting<Boolean> allowWalkOnBottomSlab = new Setting<>(true);
|
||||
public final Setting<Boolean> allowWalkOnBottomSlab = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* You know what it is
|
||||
* <p>
|
||||
* But it's very unreliable and falls off when cornering like all the time so.
|
||||
* <p>
|
||||
* It also overshoots the landing pretty much always (making contact with the next block over), so be careful
|
||||
*/
|
||||
public Setting<Boolean> allowParkour = new Setting<>(false);
|
||||
public final Setting<Boolean> allowParkour = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Like parkour, but even more unreliable!
|
||||
* Actually pretty reliable.
|
||||
* <p>
|
||||
* Doesn't make it any more dangerous compared to just normal allowParkour th
|
||||
*/
|
||||
public Setting<Boolean> allowParkourPlace = new Setting<>(false);
|
||||
public final Setting<Boolean> allowParkourPlace = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
|
||||
*/
|
||||
public Setting<Boolean> considerPotionEffects = new Setting<>(true);
|
||||
public final Setting<Boolean> considerPotionEffects = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Sprint and jump a block early on ascends wherever possible
|
||||
*/
|
||||
public final Setting<Boolean> sprintAscends = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* This is the big A* setting.
|
||||
@@ -135,83 +184,139 @@ public class Settings {
|
||||
* <p>
|
||||
* Finding the optimal path is worth it, so it's the default.
|
||||
*/
|
||||
public Setting<Double> costHeuristic = new Setting<>(3.5D);
|
||||
public final Setting<Double> costHeuristic = new Setting<>(3.563);
|
||||
|
||||
// a bunch of obscure internal A* settings that you probably don't want to change
|
||||
/**
|
||||
* The maximum number of times it will fetch outside loaded or cached chunks before assuming that
|
||||
* pathing has reached the end of the known area, and should therefore stop.
|
||||
*/
|
||||
public Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
|
||||
public final Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
|
||||
|
||||
/**
|
||||
* Set to 1.0 to effectively disable this feature
|
||||
*
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/18">Issue #18</a>
|
||||
*/
|
||||
public Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.9);
|
||||
public final Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.5);
|
||||
|
||||
/**
|
||||
* Toggle the following 4 settings
|
||||
* <p>
|
||||
* They have a noticeable performance impact, so they default off
|
||||
* <p>
|
||||
* Specifically, building up the avoidance map on the main thread before pathing starts actually takes a noticeable
|
||||
* amount of time, especially when there are a lot of mobs around, and your game jitters for like 200ms while doing so
|
||||
*/
|
||||
public final Setting<Boolean> avoidance = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Set to 1.0 to effectively disable this feature
|
||||
* <p>
|
||||
* Set below 1.0 to go out of your way to walk near mob spawners
|
||||
*/
|
||||
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
|
||||
|
||||
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
|
||||
|
||||
/**
|
||||
* Set to 1.0 to effectively disable this feature
|
||||
* <p>
|
||||
* Set below 1.0 to go out of your way to walk near mobs
|
||||
*/
|
||||
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
|
||||
|
||||
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
||||
|
||||
/**
|
||||
* When running a goto towards a container block (chest, ender chest, furnace, etc),
|
||||
* right click and open it once you arrive.
|
||||
*/
|
||||
public final Setting<Boolean> rightClickContainerOnArrival = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When running a goto towards a nether portal block, walk all the way into the portal
|
||||
* instead of stopping one block before.
|
||||
*/
|
||||
public final Setting<Boolean> enterPortal = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Don't repropagate cost improvements below 0.01 ticks. They're all just floating point inaccuracies,
|
||||
* and there's no point.
|
||||
*/
|
||||
public Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
|
||||
public final Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is
|
||||
* entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified.
|
||||
* <p>
|
||||
* This is much safer to leave off now, and makes pathing more efficient. More explanation in the issue.
|
||||
*
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/144">Issue #144</a>
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/114">Issue #114</a>
|
||||
*/
|
||||
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
|
||||
public final Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* If a movement's cost increases by more than this amount between calculation and execution (due to changes
|
||||
* in the environment / world), cancel and recalculate
|
||||
*/
|
||||
public Setting<Double> maxCostIncrease = new Setting<>(10D);
|
||||
public final Setting<Double> maxCostIncrease = new Setting<>(10D);
|
||||
|
||||
/**
|
||||
* Stop 5 movements before anything that made the path COST_INF.
|
||||
* For example, if lava has spread across the path, don't walk right up to it then recalculate, it might
|
||||
* still be spreading lol
|
||||
*/
|
||||
public Setting<Integer> costVerificationLookahead = new Setting<>(5);
|
||||
public final Setting<Integer> costVerificationLookahead = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* Static cutoff factor. 0.9 means cut off the last 10% of all paths, regardless of chunk load state
|
||||
*/
|
||||
public Setting<Double> pathCutoffFactor = new Setting<>(0.9);
|
||||
public final Setting<Double> pathCutoffFactor = new Setting<>(0.9);
|
||||
|
||||
/**
|
||||
* Only apply static cutoff for paths of at least this length (in terms of number of movements)
|
||||
*/
|
||||
public Setting<Integer> pathCutoffMinimumLength = new Setting<>(30);
|
||||
public final Setting<Integer> pathCutoffMinimumLength = new Setting<>(30);
|
||||
|
||||
/**
|
||||
* Start planning the next path once the remaining movements tick estimates sum up to less than this value
|
||||
*/
|
||||
public Setting<Integer> planningTickLookAhead = new Setting<>(100);
|
||||
public final Setting<Integer> planningTickLookahead = new Setting<>(150);
|
||||
|
||||
/**
|
||||
* Default size of the Long2ObjectOpenHashMap used in pathing
|
||||
*/
|
||||
public final Setting<Integer> pathingMapDefaultSize = new Setting<>(1024);
|
||||
|
||||
/**
|
||||
* Load factor coefficient for the Long2ObjectOpenHashMap used in pathing
|
||||
* <p>
|
||||
* Decrease for faster map operations, but higher memory usage
|
||||
*/
|
||||
public final Setting<Float> pathingMapLoadFactor = new Setting<>(0.75f);
|
||||
|
||||
/**
|
||||
* How far are you allowed to fall onto solid ground (without a water bucket)?
|
||||
* 3 won't deal any damage. But if you just want to get down the mountain quickly and you have
|
||||
* Feather Falling IV, you might set it a bit higher, like 4 or 5.
|
||||
*/
|
||||
public Setting<Integer> maxFallHeightNoWater = new Setting<>(3);
|
||||
public final Setting<Integer> maxFallHeightNoWater = new Setting<>(3);
|
||||
|
||||
/**
|
||||
* How far are you allowed to fall onto solid ground (with a water bucket)?
|
||||
* It's not that reliable, so I've set it below what would kill an unarmored player (23)
|
||||
*/
|
||||
public Setting<Integer> maxFallHeightBucket = new Setting<>(20);
|
||||
public final Setting<Integer> maxFallHeightBucket = new Setting<>(20);
|
||||
|
||||
/**
|
||||
* Is it okay to sprint through a descend followed by a diagonal?
|
||||
* The player overshoots the landing, but not enough to fall off. And the diagonal ensures that there isn't
|
||||
* lava or anything that's !canWalkInto in that space, so it's technically safe, just a little sketchy.
|
||||
* <p>
|
||||
* Note: this is *not* related to the allowDiagonalDescend setting, that is a completely different thing.
|
||||
*/
|
||||
public Setting<Boolean> allowOvershootDiagonalDescend = new Setting<>(true);
|
||||
public final Setting<Boolean> allowOvershootDiagonalDescend = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* If your goal is a GoalBlock in an unloaded chunk, assume it's far enough away that the Y coord
|
||||
@@ -220,89 +325,145 @@ public class Settings {
|
||||
* of considering the Y coord. The reasoning is that if your X and Z are 10,000 blocks away,
|
||||
* your Y coordinate's accuracy doesn't matter at all until you get much much closer.
|
||||
*/
|
||||
public Setting<Boolean> simplifyUnloadedYCoord = new Setting<>(true);
|
||||
public final Setting<Boolean> simplifyUnloadedYCoord = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* If a movement takes this many ticks more than its initial cost estimate, cancel it
|
||||
*/
|
||||
public Setting<Integer> movementTimeoutTicks = new Setting<>(100);
|
||||
public final Setting<Integer> movementTimeoutTicks = new Setting<>(100);
|
||||
|
||||
/**
|
||||
* Pathing can never take longer than this
|
||||
* Pathing ends after this amount of time, but only if a path has been found
|
||||
* <p>
|
||||
* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
|
||||
*/
|
||||
public Setting<Long> pathTimeoutMS = new Setting<>(2000L);
|
||||
public final Setting<Long> primaryTimeoutMS = new Setting<>(500L);
|
||||
|
||||
/**
|
||||
* Planning ahead while executing a segment can never take longer than this
|
||||
* Pathing can never take longer than this, even if that means failing to find any path at all
|
||||
*/
|
||||
public Setting<Long> planAheadTimeoutMS = new Setting<>(4000L);
|
||||
public final Setting<Long> failureTimeoutMS = new Setting<>(2000L);
|
||||
|
||||
/**
|
||||
* Planning ahead while executing a segment ends after this amount of time, but only if a path has been found
|
||||
* <p>
|
||||
* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
|
||||
*/
|
||||
public final Setting<Long> planAheadPrimaryTimeoutMS = new Setting<>(4000L);
|
||||
|
||||
/**
|
||||
* Planning ahead while executing a segment can never take longer than this, even if that means failing to find any path at all
|
||||
*/
|
||||
public final Setting<Long> planAheadFailureTimeoutMS = new Setting<>(5000L);
|
||||
|
||||
/**
|
||||
* For debugging, consider nodes much much slower
|
||||
*/
|
||||
public Setting<Boolean> slowPath = new Setting<>(false);
|
||||
public final Setting<Boolean> slowPath = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Milliseconds between each node
|
||||
*/
|
||||
public Setting<Long> slowPathTimeDelayMS = new Setting<>(100L);
|
||||
public final Setting<Long> slowPathTimeDelayMS = new Setting<>(100L);
|
||||
|
||||
/**
|
||||
* The alternative timeout number when slowPath is on
|
||||
*/
|
||||
public Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||
|
||||
/**
|
||||
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||
*/
|
||||
public Setting<Boolean> chunkCaching = new Setting<>(true);
|
||||
public final Setting<Boolean> chunkCaching = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* On save, delete from RAM any cached regions that are more than 1024 blocks away from the player
|
||||
* <p>
|
||||
* Temporarily disabled
|
||||
*
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/248">Issue #248</a>
|
||||
*/
|
||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Cancel baritone on left click, as a form of "panic button"
|
||||
*/
|
||||
public final Setting<Boolean> clickCancel = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Remember the contents of containers (chests, echests, furnaces)
|
||||
* <p>
|
||||
* Really buggy since the packet stuff is multithreaded badly thanks to brady
|
||||
*/
|
||||
public final Setting<Boolean> containerMemory = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Print all the debug messages to chat
|
||||
*/
|
||||
public Setting<Boolean> chatDebug = new Setting<>(true);
|
||||
public final Setting<Boolean> chatDebug = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow chat based control of Baritone. Most likely should be disabled when Baritone is imported for use in
|
||||
* something else
|
||||
*/
|
||||
public Setting<Boolean> chatControl = new Setting<>(true);
|
||||
public final Setting<Boolean> chatControl = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* A second override over chatControl to force it on
|
||||
*/
|
||||
public Setting<Boolean> removePrefix = new Setting<>(false);
|
||||
public final Setting<Boolean> removePrefix = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Render the path
|
||||
*/
|
||||
public Setting<Boolean> renderPath = new Setting<>(true);
|
||||
public final Setting<Boolean> renderPath = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render the goal
|
||||
*/
|
||||
public Setting<Boolean> renderGoal = new Setting<>(true);
|
||||
public final Setting<Boolean> renderGoal = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Ignore depth when rendering the goal
|
||||
*/
|
||||
public final Setting<Boolean> renderGoalIgnoreDepth = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Renders X/Z type Goals with the vanilla beacon beam effect. Combining this with
|
||||
* {@link #renderGoalIgnoreDepth} will cause strange render clipping.
|
||||
*/
|
||||
public final Setting<Boolean> renderGoalXZBeacon = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Ignore depth when rendering the selection boxes (to break, to place, to walk into)
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionBoxesIgnoreDepth = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Ignore depth when rendering the path
|
||||
*/
|
||||
public final Setting<Boolean> renderPathIgnoreDepth = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Line width of the path when rendered, in pixels
|
||||
*/
|
||||
public Setting<Float> pathRenderLineWidthPixels = new Setting<>(5F);
|
||||
public final Setting<Float> pathRenderLineWidthPixels = new Setting<>(5F);
|
||||
|
||||
/**
|
||||
* Line width of the goal when rendered, in pixels
|
||||
*/
|
||||
public Setting<Float> goalRenderLineWidthPixels = new Setting<>(3F);
|
||||
public final Setting<Float> goalRenderLineWidthPixels = new Setting<>(3F);
|
||||
|
||||
/**
|
||||
* Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead.
|
||||
* Improves FPS.
|
||||
*/
|
||||
public Setting<Boolean> fadePath = new Setting<>(false);
|
||||
public final Setting<Boolean> fadePath = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Move without having to force the client-sided rotations
|
||||
*/
|
||||
public Setting<Boolean> freeLook = new Setting<>(true);
|
||||
public final Setting<Boolean> freeLook = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
|
||||
@@ -310,37 +471,83 @@ public class Settings {
|
||||
* At the moment this will silently set the player's rotations when using freeLook so you're not sprinting in
|
||||
* directions other than forward, which is picken up by more "advanced" anticheats like AAC, but not NCP.
|
||||
*/
|
||||
public Setting<Boolean> antiCheatCompatibility = new Setting<>(true);
|
||||
public final Setting<Boolean> antiCheatCompatibility = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Exclusively use cached chunks for pathing
|
||||
*/
|
||||
public Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
||||
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Continue sprinting while in water
|
||||
*/
|
||||
public final Setting<Boolean> sprintInWater = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When GetToBlockProcess fails to calculate a path, instead of just giving up, mark the closest instances
|
||||
* of that block as "unreachable" and go towards the next closest
|
||||
*/
|
||||
public final Setting<Boolean> blacklistOnGetToBlockFailure = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see <a href="https://github.com/cabaletta/baritone/issues/327">this issue</a>.
|
||||
* <p>
|
||||
* Can be very useful on servers with low render distance. After enabling, you may need to reload the world in order for it to have an effect
|
||||
* (e.g. disconnect and reconnect, enter then exit the nether, die and respawn, etc). This may literally kill your FPS and CPU because
|
||||
* every chunk gets recompiled twice as much as normal, since the cached version comes into range, then the normal one comes from the server for real.
|
||||
* <p>
|
||||
* Note that flowing water is cached as AVOID, which is rendered as lava. As you get closer, you may therefore see lava falls being replaced with water falls.
|
||||
* <p>
|
||||
* SOLID is rendered as stone in the overworld, netherrack in the nether, and end stone in the end
|
||||
*/
|
||||
public Setting<Boolean> renderCachedChunks = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* 0.0f = not visible, fully transparent
|
||||
* 1.0f = fully opaque
|
||||
*/
|
||||
public Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
|
||||
|
||||
/**
|
||||
* If true, Baritone will not allow you to left or right click while pathing
|
||||
*/
|
||||
public Setting<Boolean> suppressClicks = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Whether or not to use the "#" command prefix
|
||||
*/
|
||||
public Setting<Boolean> prefix = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* {@code true}: can mine blocks when in inventory, chat, or tabbed away in ESC menu
|
||||
* <p>
|
||||
* {@code false}: works on cosmic prisons
|
||||
* <p>
|
||||
* LOL
|
||||
*/
|
||||
public Setting<Boolean> leftClickWorkaround = new Setting<>(true);
|
||||
public final Setting<Boolean> prefixControl = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Don't stop walking forward when you need to break blocks in your way
|
||||
*/
|
||||
public Setting<Boolean> walkWhileBreaking = new Setting<>(true);
|
||||
public final Setting<Boolean> walkWhileBreaking = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* If we are more than 300 movements into the current path, discard the oldest segments, as they are no longer useful
|
||||
*/
|
||||
public final Setting<Integer> maxPathHistoryLength = new Setting<>(300);
|
||||
|
||||
/**
|
||||
* If the current path is too long, cut off this many movements from the beginning.
|
||||
*/
|
||||
public final Setting<Integer> pathHistoryCutoffAmount = new Setting<>(50);
|
||||
|
||||
/**
|
||||
* Rescan for the goal once every 5 ticks.
|
||||
* Set to 0 to disable.
|
||||
*/
|
||||
public Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
||||
public final Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
|
||||
*/
|
||||
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
|
||||
*/
|
||||
public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
|
||||
@@ -355,95 +562,157 @@ public class Settings {
|
||||
* <p>
|
||||
* Also on cosmic prisons this should be set to true since you don't actually mine the ore it just gets replaced with stone.
|
||||
*/
|
||||
public Setting<Boolean> cancelOnGoalInvalidation = new Setting<>(true);
|
||||
public final Setting<Boolean> cancelOnGoalInvalidation = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The "axis" command (aka GoalAxis) will go to a axis, or diagonal axis, at this Y level.
|
||||
*/
|
||||
public Setting<Integer> axisHeight = new Setting<>(120);
|
||||
public final Setting<Integer> axisHeight = new Setting<>(120);
|
||||
|
||||
/**
|
||||
* Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit"
|
||||
* where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player
|
||||
* couldn't. If you don't want it to look like you're X-Raying, turn this on
|
||||
*/
|
||||
public final Setting<Boolean> legitMine = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* What Y level to go to for legit strip mining
|
||||
*/
|
||||
public final Setting<Integer> legitMineYLevel = new Setting<>(11);
|
||||
|
||||
/**
|
||||
* Magically see ores that are separated diagonally from existing ores. Basically like mining around the ores that it finds
|
||||
* in case there's one there touching it diagonally, except it checks it un-legit-ly without having the mine blocks to see it.
|
||||
* You can decide whether this looks plausible or not.
|
||||
* <p>
|
||||
* This is disabled because it results in some weird behavior. For example, it can """see""" the top block of a vein of iron_ore
|
||||
* through a lava lake. This isn't an issue normally since it won't consider anything touching lava, so it just ignores it.
|
||||
* However, this setting expands that and allows it to see the entire vein so it'll mine under the lava lake to get the iron that
|
||||
* it can reach without mining blocks adjacent to lava. This really defeats the purpose of legitMine since a player could never
|
||||
* do that lol, so thats one reason why its disabled
|
||||
*/
|
||||
public final Setting<Boolean> legitMineIncludeDiagonals = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When mining block of a certain type, try to mine two at once instead of one.
|
||||
* If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks
|
||||
* If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks
|
||||
*/
|
||||
public Setting<Boolean> forceInternalMining = new Setting<>(true);
|
||||
public final Setting<Boolean> forceInternalMining = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Modification to the previous setting, only has effect if forceInternalMining is true
|
||||
* If true, only apply the previous setting if the block adjacent to the goal isn't air.
|
||||
*/
|
||||
public Setting<Boolean> internalMiningAirException = new Setting<>(true);
|
||||
public final Setting<Boolean> internalMiningAirException = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The actual GoalNear is set this distance away from the entity you're following
|
||||
* <p>
|
||||
* For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target.
|
||||
*/
|
||||
public Setting<Double> followOffsetDistance = new Setting<>(0D);
|
||||
public final Setting<Double> followOffsetDistance = new Setting<>(0D);
|
||||
|
||||
/**
|
||||
* The actual GoalNear is set in this direction from the entity you're following
|
||||
* The actual GoalNear is set in this direction from the entity you're following. This value is in degrees.
|
||||
*/
|
||||
public Setting<Float> followOffsetDirection = new Setting<>(0F);
|
||||
public final Setting<Float> followOffsetDirection = new Setting<>(0F);
|
||||
|
||||
/**
|
||||
* The radius (for the GoalNear) of how close to your target position you actually have to be
|
||||
*/
|
||||
public Setting<Integer> followRadius = new Setting<>(3);
|
||||
public final Setting<Integer> followRadius = new Setting<>(3);
|
||||
|
||||
/**
|
||||
* Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds
|
||||
* -1 to disable
|
||||
* <p>
|
||||
* I would highly suggest leaving this setting disabled (-1).
|
||||
* <p>
|
||||
* The only valid reason I can think of enable this setting is if you are extremely low on disk space and you play on multiplayer,
|
||||
* and can't take (average) 300kb saved for every 512x512 area. (note that more complicated terrain is less compressible and will take more space)
|
||||
* <p>
|
||||
* However, simply discarding old chunks because they are old is inadvisable. Baritone is extremely good at correcting
|
||||
* itself and its paths as it learns new information, as new chunks load. There is no scenario in which having an
|
||||
* incorrect cache can cause Baritone to get stuck, take damage, or perform any action it wouldn't otherwise, everything
|
||||
* is rechecked once the real chunk is in range.
|
||||
* <p>
|
||||
* Having a robust cache greatly improves long distance pathfinding, as it's able to go around large scale obstacles
|
||||
* before they're in render distance. In fact, when the chunkCaching setting is disabled and Baritone starts anew
|
||||
* every time, or when you enter a completely new and very complicated area, it backtracks far more often because it
|
||||
* has to build up that cache from scratch. But after it's gone through an area just once, the next time will have zero
|
||||
* backtracking, since the entire area is now known and cached.
|
||||
*/
|
||||
public final Setting<Long> cachedChunksExpirySeconds = new Setting<>(-1L);
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will log to chat. This function can be added to
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||
|
||||
/**
|
||||
* The color of the current path
|
||||
*/
|
||||
public Setting<Color> colorCurrentPath = new Setting<>(Color.RED);
|
||||
public final Setting<Color> colorCurrentPath = new Setting<>(Color.RED);
|
||||
|
||||
/**
|
||||
* The color of the next path
|
||||
*/
|
||||
public Setting<Color> colorNextPath = new Setting<>(Color.MAGENTA);
|
||||
public final Setting<Color> colorNextPath = new Setting<>(Color.MAGENTA);
|
||||
|
||||
/**
|
||||
* The color of the blocks to break
|
||||
*/
|
||||
public Setting<Color> colorBlocksToBreak = new Setting<>(Color.RED);
|
||||
public final Setting<Color> colorBlocksToBreak = new Setting<>(Color.RED);
|
||||
|
||||
/**
|
||||
* The color of the blocks to place
|
||||
*/
|
||||
public Setting<Color> colorBlocksToPlace = new Setting<>(Color.GREEN);
|
||||
public final Setting<Color> colorBlocksToPlace = new Setting<>(Color.GREEN);
|
||||
|
||||
/**
|
||||
* The color of the blocks to walk into
|
||||
*/
|
||||
public Setting<Color> colorBlocksToWalkInto = new Setting<>(Color.MAGENTA);
|
||||
public final Setting<Color> colorBlocksToWalkInto = new Setting<>(Color.MAGENTA);
|
||||
|
||||
/**
|
||||
* The color of the best path so far
|
||||
*/
|
||||
public Setting<Color> colorBestPathSoFar = new Setting<>(Color.BLUE);
|
||||
public final Setting<Color> colorBestPathSoFar = new Setting<>(Color.BLUE);
|
||||
|
||||
/**
|
||||
* The color of the path to the most recent considered node
|
||||
*/
|
||||
public Setting<Color> colorMostRecentConsidered = new Setting<>(Color.CYAN);
|
||||
public final Setting<Color> colorMostRecentConsidered = new Setting<>(Color.CYAN);
|
||||
|
||||
/**
|
||||
* The color of the goal box
|
||||
*/
|
||||
public Setting<Color> colorGoalBox = new Setting<>(Color.GREEN);
|
||||
public final Setting<Color> colorGoalBox = new Setting<>(Color.GREEN);
|
||||
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
*/
|
||||
public final Map<String, Setting<?>> byLowerName;
|
||||
|
||||
/**
|
||||
* A list of all settings
|
||||
*/
|
||||
public final List<Setting<?>> allSettings;
|
||||
|
||||
public class Setting<T> {
|
||||
public void reset() {
|
||||
for (Setting setting : allSettings) {
|
||||
setting.value = setting.defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public final class Setting<T> {
|
||||
public T value;
|
||||
public final T defaultValue;
|
||||
private String name;
|
||||
private final Class<T> klass;
|
||||
|
||||
@@ -453,6 +722,7 @@ public class Settings {
|
||||
throw new IllegalArgumentException("Cannot determine value type class from null");
|
||||
}
|
||||
this.value = value;
|
||||
this.defaultValue = value;
|
||||
this.klass = (Class<T>) value.getClass();
|
||||
}
|
||||
|
||||
@@ -476,7 +746,7 @@ public class Settings {
|
||||
|
||||
// here be dragons
|
||||
|
||||
{
|
||||
Settings() {
|
||||
Field[] temp = getClass().getFields();
|
||||
HashMap<String, Setting<?>> tmpByName = new HashMap<>();
|
||||
List<Setting<?>> tmpAll = new ArrayList<>();
|
||||
@@ -511,6 +781,4 @@ public class Settings {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Settings() { }
|
||||
}
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.utils.interfaces.Toggleable;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IBehavior extends AbstractGameEventListener, Toggleable {}
|
||||
public interface IBehavior extends AbstractGameEventListener {}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface ILookBehavior extends IBehavior {
|
||||
* otherwise, it should be {@code false};
|
||||
*
|
||||
* @param rotation The target rotations
|
||||
* @param force Whether or not to "force" the rotations
|
||||
* @param force Whether or not to "force" the rotations
|
||||
*/
|
||||
void updateTarget(Rotation rotation, boolean force);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.pathing.calc.IPath;
|
||||
import baritone.api.pathing.calc.IPathFinder;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.path.IPathExecutor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -34,35 +37,72 @@ public interface IPathingBehavior extends IBehavior {
|
||||
*
|
||||
* @return The estimated remaining ticks in the current segment.
|
||||
*/
|
||||
Optional<Double> ticksRemainingInSegment();
|
||||
default Optional<Double> ticksRemainingInSegment() {
|
||||
return ticksRemainingInSegment(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pathing goal.
|
||||
* 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 goal The pathing goal
|
||||
* @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.
|
||||
*/
|
||||
void setGoal(Goal goal);
|
||||
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
|
||||
*/
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* Begins pathing. Calculation will start in a new thread, and once completed,
|
||||
* movement will commence. Returns whether or not the operation was successful.
|
||||
*
|
||||
* @return Whether or not the operation was successful
|
||||
*/
|
||||
boolean path();
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* Cancels the pathing behavior or the current path calculation, and all processes that could be controlling path.
|
||||
* <p>
|
||||
* Basically, "MAKE IT STOP".
|
||||
*
|
||||
* @return Whether or not the pathing behavior was canceled. All processes are guaranteed to be canceled, but the
|
||||
* PathingBehavior might be in the middle of an uncancelable action like a parkour jump
|
||||
*/
|
||||
void cancel();
|
||||
boolean cancelEverything();
|
||||
|
||||
/**
|
||||
* Returns the current path, from the current path executor, if there is one.
|
||||
*
|
||||
* @return The current path
|
||||
*/
|
||||
default Optional<IPath> getPath() {
|
||||
return Optional.ofNullable(getCurrent()).map(IPathExecutor::getPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current path finder being executed
|
||||
*/
|
||||
Optional<? extends IPathFinder> getInProgress();
|
||||
|
||||
/**
|
||||
* @return The current path executor
|
||||
*/
|
||||
IPathExecutor getCurrent();
|
||||
|
||||
/**
|
||||
* Returns the next path executor, created when planning ahead.
|
||||
*
|
||||
* @return The next path executor
|
||||
*/
|
||||
IPathExecutor getNext();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/4/2018 2:01 AM
|
||||
* @since 8/4/2018
|
||||
*/
|
||||
public interface IBlockTypeAccess {
|
||||
|
||||
|
||||
@@ -29,21 +29,20 @@ public interface ICachedRegion extends IBlockTypeAccess {
|
||||
* however, the block coordinates should in on a scale from 0 to 511 (inclusive)
|
||||
* because region sizes are 512x512 blocks.
|
||||
*
|
||||
* @see ICachedWorld#isCached(int, int)
|
||||
*
|
||||
* @param blockX The block X coordinate
|
||||
* @param blockZ The block Z coordinate
|
||||
* @return Whether or not the specified XZ location is cached
|
||||
* @see ICachedWorld#isCached(int, int)
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -61,12 +61,14 @@ public interface ICachedWorld {
|
||||
* information that is returned by this method may not be up to date, because
|
||||
* older cached chunks can contain data that is much more likely to have changed.
|
||||
*
|
||||
* @param block The special block to search for
|
||||
* @param maximum The maximum number of position results to receive
|
||||
* @param block The special block to search for
|
||||
* @param maximum The maximum number of position results to receive
|
||||
* @param centerX The x block coordinate center of the search
|
||||
* @param centerZ The z block coordinate center of the search
|
||||
* @param maxRegionDistanceSq The maximum region distance, squared
|
||||
* @return The locations found that match the special block
|
||||
*/
|
||||
LinkedList<BlockPos> getLocationsOf(String block, int maximum, int maxRegionDistanceSq);
|
||||
LinkedList<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
|
||||
|
||||
@@ -15,16 +15,17 @@
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IMemoryBehavior extends IBehavior {
|
||||
public interface IContainerMemory {
|
||||
|
||||
/**
|
||||
* Gets a remembered inventory by its block position.
|
||||
@@ -33,4 +34,11 @@ public interface IMemoryBehavior extends IBehavior {
|
||||
* @return The remembered inventory
|
||||
*/
|
||||
IRememberedInventory getInventoryByPos(BlockPos pos);
|
||||
|
||||
/**
|
||||
* Gets the map of all block positions to their remembered inventories.
|
||||
*
|
||||
* @return Map of block positions to their respective remembered inventories
|
||||
*/
|
||||
Map<BlockPos, IRememberedInventory> getRememberedInventories();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -50,19 +50,17 @@ public interface IWaypointCollection {
|
||||
/**
|
||||
* Gets all of the waypoints that have the specified tag
|
||||
*
|
||||
* @see IWaypointCollection#getAllWaypoints()
|
||||
*
|
||||
* @param tag The tag
|
||||
* @return All of the waypoints with the specified tag
|
||||
* @see IWaypointCollection#getAllWaypoints()
|
||||
*/
|
||||
Set<IWaypoint> getByTag(IWaypoint.Tag tag);
|
||||
|
||||
/**
|
||||
* Gets all of the waypoints in this collection, regardless of the tag.
|
||||
*
|
||||
* @see IWaypointCollection#getByTag(IWaypoint.Tag)
|
||||
*
|
||||
* @return All of the waypoints in this collection
|
||||
* @see IWaypointCollection#getByTag(IWaypoint.Tag)
|
||||
*/
|
||||
Set<IWaypoint> getAllWaypoints();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
60
src/api/java/baritone/api/cache/IWorldScanner.java
vendored
Normal file
60
src/api/java/baritone/api/cache/IWorldScanner.java
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/6/2018
|
||||
*/
|
||||
public interface IWorldScanner {
|
||||
|
||||
/**
|
||||
* Scans the world, up to the specified max chunk radius, 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 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.
|
||||
* @param maxSearchRadius The maximum chunk search radius
|
||||
* @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);
|
||||
}
|
||||
@@ -20,6 +20,8 @@ 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#START_BREAK} or {@link Type#USE}.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 8/22/2018
|
||||
*/
|
||||
@@ -57,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.
|
||||
|
||||
@@ -21,7 +21,7 @@ import baritone.api.event.events.type.Cancellable;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018 6:39 PM
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public final class ChatEvent extends Cancellable {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import baritone.api.event.events.type.EventState;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/2/2018 12:32 AM
|
||||
* @since 8/2/2018
|
||||
*/
|
||||
public final class ChunkEvent {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -94,7 +96,16 @@ public final class ChunkEvent {
|
||||
|
||||
/**
|
||||
* When the chunk is being populated with blocks, tile entities, etc.
|
||||
* <p>
|
||||
* And it's a full chunk
|
||||
*/
|
||||
POPULATE
|
||||
POPULATE_FULL,
|
||||
|
||||
/**
|
||||
* When the chunk is being populated with blocks, tile entities, etc.
|
||||
* <p>
|
||||
* And it's a partial chunk
|
||||
*/
|
||||
POPULATE_PARTIAL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,31 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/6/2018 9:31 PM
|
||||
* @since 8/6/2018
|
||||
*/
|
||||
public final class PacketEvent {
|
||||
|
||||
private final NetworkManager networkManager;
|
||||
|
||||
private final EventState state;
|
||||
|
||||
private final Packet<?> packet;
|
||||
|
||||
public PacketEvent(EventState state, Packet<?> packet) {
|
||||
public PacketEvent(NetworkManager networkManager, EventState state, Packet<?> packet) {
|
||||
this.networkManager = networkManager;
|
||||
this.state = state;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public final NetworkManager getNetworkManager() {
|
||||
return this.networkManager;
|
||||
}
|
||||
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package baritone.api.event.events;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/5/2018 12:28 AM
|
||||
* @since 8/5/2018
|
||||
*/
|
||||
public final class RenderEvent {
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -33,20 +32,29 @@ public final class RotationMoveEvent {
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* The state of the event
|
||||
* The yaw rotation
|
||||
*/
|
||||
private final EventState state;
|
||||
private float yaw;
|
||||
|
||||
public RotationMoveEvent(EventState state, Type type) {
|
||||
this.state = state;
|
||||
public RotationMoveEvent(Type type, float yaw) {
|
||||
this.type = type;
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The state of the event
|
||||
* Set the yaw movement rotation
|
||||
*
|
||||
* @param yaw Yaw rotation
|
||||
*/
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
public final void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The yaw rotation
|
||||
*/
|
||||
public final float getYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,20 +15,21 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
package baritone.api.event.events;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 10:10 PM
|
||||
* @since 1/18/2019
|
||||
*/
|
||||
public class BaritoneTweakerOptifine extends BaritoneTweaker {
|
||||
public final class SprintStateEvent {
|
||||
|
||||
@Override
|
||||
public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
this.args = new ArrayList<>();
|
||||
private Boolean state;
|
||||
|
||||
public final void setState(boolean state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public final Boolean getState() {
|
||||
return this.state;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/4/2018 3:13 AM
|
||||
* @since 8/4/2018
|
||||
*/
|
||||
public final class WorldEvent {
|
||||
|
||||
|
||||
@@ -19,25 +19,21 @@ package baritone.api.event.events.type;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018 6:41 PM
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public class Cancellable {
|
||||
public class Cancellable implements ICancellable {
|
||||
|
||||
/**
|
||||
* Whether or not this event has been cancelled
|
||||
*/
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Cancels this event
|
||||
*/
|
||||
@Override
|
||||
public final void cancel() {
|
||||
this.cancelled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not this event has been cancelled
|
||||
*/
|
||||
@Override
|
||||
public final boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@@ -19,19 +19,17 @@ package baritone.api.event.events.type;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/2/2018 12:34 AM
|
||||
* @since 8/2/2018
|
||||
*/
|
||||
public enum EventState {
|
||||
|
||||
/**
|
||||
* Indicates that whatever movement the event is being
|
||||
* dispatched as a result of is about to occur.
|
||||
* Before the dispatching of what the event is targetting
|
||||
*/
|
||||
PRE,
|
||||
|
||||
/**
|
||||
* Indicates that whatever movement the event is being
|
||||
* dispatched as a result of has already occurred.
|
||||
* After the dispatching of what the event is targetting
|
||||
*/
|
||||
POST
|
||||
}
|
||||
|
||||
@@ -15,30 +15,21 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.behavior;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
package baritone.api.event.events.type;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
* @since 10/11/2018
|
||||
*/
|
||||
public interface IFollowBehavior extends IBehavior {
|
||||
public interface ICancellable {
|
||||
|
||||
/**
|
||||
* Set the follow target to the specified entity;
|
||||
*
|
||||
* @param entity The entity to follow
|
||||
*/
|
||||
void follow(Entity entity);
|
||||
|
||||
/**
|
||||
* @return The entity that is currently being followed
|
||||
*/
|
||||
Entity following();
|
||||
|
||||
/**
|
||||
* Cancels the follow behavior, this will clear the current follow target.
|
||||
* Cancels this event
|
||||
*/
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* @return Whether or not this event has been cancelled
|
||||
*/
|
||||
boolean isCancelled();
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import baritone.api.event.events.*;
|
||||
*
|
||||
* @author Brady
|
||||
* @see IGameEventListener
|
||||
* @since 8/1/2018 6:29 PM
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
public interface AbstractGameEventListener extends IGameEventListener {
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
|
||||
36
src/api/java/baritone/api/event/listener/IEventBus.java
Normal file
36
src/api/java/baritone/api/event/listener/IEventBus.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.listener;
|
||||
|
||||
/**
|
||||
* A type of {@link IGameEventListener} that can have additional listeners
|
||||
* registered so that they receive the events that are dispatched to this
|
||||
* listener.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 11/14/2018
|
||||
*/
|
||||
public interface IEventBus extends IGameEventListener {
|
||||
|
||||
/**
|
||||
* Registers the specified {@link IGameEventListener} to this event bus
|
||||
*
|
||||
* @param listener The listener
|
||||
*/
|
||||
void registerEventListener(IGameEventListener listener);
|
||||
}
|
||||
@@ -23,23 +23,20 @@ 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
|
||||
* @since 7/31/2018 11:05 PM
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
179
src/api/java/baritone/api/pathing/calc/IPath.java
Normal file
179
src/api/java/baritone/api/pathing/calc/IPath.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* 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.calc;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.movement.IMovement;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author leijurv, Brady
|
||||
*/
|
||||
public interface IPath {
|
||||
|
||||
/**
|
||||
* Ordered list of movements to carry out.
|
||||
* movements.get(i).getSrc() should equal positions.get(i)
|
||||
* movements.get(i).getDest() should equal positions.get(i+1)
|
||||
* movements.size() should equal positions.size()-1
|
||||
*
|
||||
* @return All of the movements to carry out
|
||||
*/
|
||||
List<IMovement> movements();
|
||||
|
||||
/**
|
||||
* All positions along the way.
|
||||
* Should begin with the same as getSrc and end with the same as getDest
|
||||
*
|
||||
* @return All of the positions along this path
|
||||
*/
|
||||
List<BetterBlockPos> positions();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of positions in this path. Equivalent to {@code positions().size()}.
|
||||
*
|
||||
* @return Number of positions in this path
|
||||
*/
|
||||
default int length() {
|
||||
return positions().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The goal that this path was calculated towards
|
||||
*/
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* Returns the number of nodes that were considered during calculation before
|
||||
* this path was found.
|
||||
*
|
||||
* @return The number of nodes that were considered before finding this path
|
||||
*/
|
||||
int getNumNodesConsidered();
|
||||
|
||||
/**
|
||||
* Returns the start position of this path. This is the first element in the
|
||||
* {@link List} that is returned by {@link IPath#positions()}.
|
||||
*
|
||||
* @return The start position of this path
|
||||
*/
|
||||
default BetterBlockPos getSrc() {
|
||||
return positions().get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end position of this path. This is the last element in the
|
||||
* {@link List} that is returned by {@link IPath#positions()}.
|
||||
*
|
||||
* @return The end position of this path.
|
||||
*/
|
||||
default BetterBlockPos getDest() {
|
||||
List<BetterBlockPos> pos = positions();
|
||||
return pos.get(pos.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the estimated number of ticks to complete the path from the given node index.
|
||||
*
|
||||
* @param pathPosition The index of the node we're calculating from
|
||||
* @return The estimated number of ticks remaining frm the given position
|
||||
*/
|
||||
default double ticksRemainingFrom(int pathPosition) {
|
||||
double sum = 0;
|
||||
//this is fast because we aren't requesting recalculation, it's just cached
|
||||
List<IMovement> movements = movements();
|
||||
for (int i = pathPosition; i < movements.size(); i++) {
|
||||
sum += movements.get(i).getCost();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(Object bsi) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
default IPath staticCutoff(Goal destination) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs a series of checks to ensure that the assembly of the path went as expected.
|
||||
*/
|
||||
default void sanityCheck() {
|
||||
List<BetterBlockPos> path = positions();
|
||||
List<IMovement> movements = movements();
|
||||
if (!getSrc().equals(path.get(0))) {
|
||||
throw new IllegalStateException("Start node does not equal first path element");
|
||||
}
|
||||
if (!getDest().equals(path.get(path.size() - 1))) {
|
||||
throw new IllegalStateException("End node does not equal last path element");
|
||||
}
|
||||
if (path.size() != movements.size() + 1) {
|
||||
throw new IllegalStateException("Size of path array is unexpected");
|
||||
}
|
||||
HashSet<BetterBlockPos> seenSoFar = new HashSet<>();
|
||||
for (int i = 0; i < path.size() - 1; i++) {
|
||||
BetterBlockPos src = path.get(i);
|
||||
BetterBlockPos dest = path.get(i + 1);
|
||||
IMovement movement = movements.get(i);
|
||||
if (!src.equals(movement.getSrc())) {
|
||||
throw new IllegalStateException("Path source is not equal to the movement source");
|
||||
}
|
||||
if (!dest.equals(movement.getDest())) {
|
||||
throw new IllegalStateException("Path destination is not equal to the movement destination");
|
||||
}
|
||||
if (seenSoFar.contains(src)) {
|
||||
throw new IllegalStateException("Path doubles back on itself, making a loop");
|
||||
}
|
||||
seenSoFar.add(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.pathing.calc;
|
||||
package baritone.api.pathing.calc;
|
||||
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.pathing.path.IPath;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import baritone.api.utils.PathCalculationResult;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -30,16 +29,16 @@ import java.util.Optional;
|
||||
*/
|
||||
public interface IPathFinder {
|
||||
|
||||
BlockPos getStart();
|
||||
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
Optional<IPath> calculate(long timeout);
|
||||
PathCalculationResult calculate(long primaryTimeout, long failureTimeout);
|
||||
|
||||
/**
|
||||
* Intended to be called concurrently with calculatePath from a different thread to tell if it's finished yet
|
||||
@@ -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.api.pathing.calc;
|
||||
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
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);
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A composite of many goals, any one of which satisfies the composite.
|
||||
@@ -40,14 +37,6 @@ public class GoalComposite implements Goal {
|
||||
this.goals = goals;
|
||||
}
|
||||
|
||||
public GoalComposite(BlockPos... blocks) {
|
||||
this(Arrays.asList(blocks));
|
||||
}
|
||||
|
||||
public GoalComposite(Collection<BlockPos> blocks) {
|
||||
this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
for (Goal goal : goals) {
|
||||
|
||||
@@ -48,10 +48,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
int xDiff = x - this.x;
|
||||
int yDiff = y - this.y;
|
||||
int zDiff = z - this.z;
|
||||
if (yDiff < 0) {
|
||||
yDiff++;
|
||||
}
|
||||
return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1;
|
||||
return Math.abs(xDiff) + Math.abs(yDiff < 0 ? yDiff + 1 : yDiff) + Math.abs(zDiff) <= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +56,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
int xDiff = x - this.x;
|
||||
int yDiff = y - this.y;
|
||||
int zDiff = z - this.z;
|
||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||
return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,16 +32,26 @@ public class GoalRunAway implements Goal {
|
||||
|
||||
private final double distanceSq;
|
||||
|
||||
private final Integer maintainY;
|
||||
|
||||
public GoalRunAway(double distance, BlockPos... from) {
|
||||
this(distance, null, from);
|
||||
}
|
||||
|
||||
public GoalRunAway(double distance, Integer maintainY, BlockPos... from) {
|
||||
if (from.length == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.from = from;
|
||||
this.distanceSq = distance * distance;
|
||||
this.maintainY = maintainY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
if (maintainY != null && maintainY != y) {
|
||||
return false;
|
||||
}
|
||||
for (BlockPos p : from) {
|
||||
int diffX = x - p.getX();
|
||||
int diffZ = z - p.getZ();
|
||||
@@ -62,11 +72,19 @@ public class GoalRunAway implements Goal {
|
||||
min = h;
|
||||
}
|
||||
}
|
||||
return -min;
|
||||
min = -min;
|
||||
if (maintainY != null) {
|
||||
min = min * 0.6 + GoalYLevel.calculate(maintainY, y) * 1.5;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalRunAwayFrom" + Arrays.asList(from);
|
||||
if (maintainY != null) {
|
||||
return "GoalRunAwayFromMaintainY y=" + maintainY + ", " + Arrays.asList(from);
|
||||
} else {
|
||||
return "GoalRunAwayFrom" + Arrays.asList(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +63,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
int xDiff = x - this.x;
|
||||
int yDiff = y - this.y;
|
||||
int zDiff = z - this.z;
|
||||
if (yDiff < 0) {
|
||||
yDiff++;
|
||||
}
|
||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||
return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,21 +23,21 @@ public interface ActionCosts {
|
||||
* These costs are measured roughly in ticks btw
|
||||
*/
|
||||
double WALK_ONE_BLOCK_COST = 20 / 4.317; // 4.633
|
||||
double WALK_ONE_IN_WATER_COST = 20 / 2.2;
|
||||
double WALK_ONE_IN_WATER_COST = 20 / 2.2; // 9.091
|
||||
double WALK_ONE_OVER_SOUL_SAND_COST = WALK_ONE_BLOCK_COST * 2; // 0.4 in BlockSoulSand but effectively about half
|
||||
double SPRINT_ONE_OVER_SOUL_SAND_COST = WALK_ONE_OVER_SOUL_SAND_COST * 0.75;
|
||||
double LADDER_UP_ONE_COST = 20 / 2.35;
|
||||
double LADDER_DOWN_ONE_COST = 20 / 3.0;
|
||||
double SNEAK_ONE_BLOCK_COST = 20 / 1.3;
|
||||
double LADDER_UP_ONE_COST = 20 / 2.35; // 8.511
|
||||
double LADDER_DOWN_ONE_COST = 20 / 3.0; // 6.667
|
||||
double SNEAK_ONE_BLOCK_COST = 20 / 1.3; // 15.385
|
||||
double SPRINT_ONE_BLOCK_COST = 20 / 5.612; // 3.564
|
||||
double SPRINT_MULTIPLIER = SPRINT_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST; // 0.769
|
||||
/**
|
||||
* To walk off an edge you need to walk 0.5 to the edge then 0.3 to start falling off
|
||||
*/
|
||||
double WALK_OFF_BLOCK_COST = WALK_ONE_BLOCK_COST * 0.8;
|
||||
double WALK_OFF_BLOCK_COST = WALK_ONE_BLOCK_COST * 0.8; // 3.706
|
||||
/**
|
||||
* To walk the rest of the way to be centered on the new block
|
||||
*/
|
||||
double CENTER_AFTER_FALL_COST = WALK_ONE_BLOCK_COST - WALK_OFF_BLOCK_COST;
|
||||
double CENTER_AFTER_FALL_COST = WALK_ONE_BLOCK_COST - WALK_OFF_BLOCK_COST; // 0.927
|
||||
|
||||
/**
|
||||
* don't make this Double.MAX_VALUE because it's added to other things, maybe other COST_INFs,
|
||||
|
||||
59
src/api/java/baritone/api/pathing/movement/IMovement.java
Normal file
59
src/api/java/baritone/api/pathing/movement/IMovement.java
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.movement;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/8/2018
|
||||
*/
|
||||
public interface IMovement {
|
||||
|
||||
double getCost();
|
||||
|
||||
MovementStatus update();
|
||||
|
||||
/**
|
||||
* Resets the current state status to {@link MovementStatus#PREPPING}
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Resets the cache for special break, place, and walk into blocks
|
||||
*/
|
||||
void resetBlockCache();
|
||||
|
||||
/**
|
||||
* @return Whether or not it is safe to cancel the current movement state
|
||||
*/
|
||||
boolean safeToCancel();
|
||||
|
||||
double recalculateCost();
|
||||
|
||||
double calculateCostWithoutCaching();
|
||||
|
||||
boolean calculatedWhileLoaded();
|
||||
|
||||
BetterBlockPos getSrc();
|
||||
|
||||
BetterBlockPos getDest();
|
||||
|
||||
BlockPos getDirection();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.movement;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/8/2018
|
||||
*/
|
||||
public enum MovementStatus {
|
||||
|
||||
/**
|
||||
* We are preparing the movement to be executed. This is when any blocks obstructing the destination are broken.
|
||||
*/
|
||||
PREPPING(false),
|
||||
|
||||
/**
|
||||
* We are waiting for the movement to begin, after {@link MovementStatus#PREPPING}.
|
||||
*/
|
||||
WAITING(false),
|
||||
|
||||
/**
|
||||
* The movement is currently in progress, after {@link MovementStatus#WAITING}
|
||||
*/
|
||||
RUNNING(false),
|
||||
|
||||
/**
|
||||
* The movement has been completed and we are at our destination
|
||||
*/
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* There was a change in state between calculation and actual
|
||||
* movement execution, and the movement has now become impossible.
|
||||
*/
|
||||
UNREACHABLE(true),
|
||||
|
||||
/**
|
||||
* Unused
|
||||
*/
|
||||
FAILED(true),
|
||||
|
||||
/**
|
||||
* "Unused"
|
||||
*/
|
||||
CANCELED(true);
|
||||
|
||||
/**
|
||||
* Whether or not this status indicates a complete movement.
|
||||
*/
|
||||
private final boolean complete;
|
||||
|
||||
MovementStatus(boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
public final boolean isComplete() {
|
||||
return this.complete;
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,17 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
package baritone.api.pathing.path;
|
||||
|
||||
import baritone.api.pathing.calc.IPath;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
* @since 10/8/2018
|
||||
*/
|
||||
public class Logger {
|
||||
public interface IPathExecutor {
|
||||
|
||||
IPath getPath();
|
||||
|
||||
int getPosition();
|
||||
}
|
||||
93
src/api/java/baritone/api/process/IBaritoneProcess.java
Normal file
93
src/api/java/baritone/api/process/IBaritoneProcess.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.behavior.IPathingBehavior;
|
||||
import baritone.api.event.events.PathEvent;
|
||||
|
||||
/**
|
||||
* A process that can control the PathingBehavior.
|
||||
* <p>
|
||||
* Differences between a baritone process and a behavior:
|
||||
* <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
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public interface IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Would this process like to be in control?
|
||||
*
|
||||
* @return Whether or not this process would like to be in contorl.
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
/**
|
||||
* Called when this process is in control of pathing; Returns what Baritone should do.
|
||||
*
|
||||
* @param calcFailed {@code true} if this specific process was in control last tick,
|
||||
* and there was a {@link PathEvent#CALC_FAILED} event last tick
|
||||
* @param isSafeToCancel {@code true} if a {@link PathingCommandType#REQUEST_PAUSE} would happen this tick, and
|
||||
* {@link IPathingBehavior} wouldn't actually tick. {@code false} if the PathExecutor reported
|
||||
* pausing would be unsafe at the end of the last tick. Effectively "could request cancel or
|
||||
* pause and have it happen right away"
|
||||
* @return What the {@link IPathingBehavior} should do
|
||||
*/
|
||||
PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel);
|
||||
|
||||
/**
|
||||
* Returns whether or not this process should be treated as "temporary".
|
||||
* <p>
|
||||
* If a process is temporary, it doesn't call {@link #onLostControl} on the processes that aren't execute because of it.
|
||||
* <p>
|
||||
* For example, {@code CombatPauserProcess} and {@code PauseForAutoEatProcess} should return {@code true} always,
|
||||
* and should return {@link #isActive} {@code true} only if there's something in range this tick, or if the player would like
|
||||
* to start eating this tick. {@code PauseForAutoEatProcess} should only actually right click once onTick is called with
|
||||
* {@code isSafeToCancel} true though.
|
||||
*
|
||||
* @return Whethor or not if this control is temporary
|
||||
*/
|
||||
boolean isTemporary();
|
||||
|
||||
/**
|
||||
* Called if {@link #isActive} returned {@code true}, but another non-temporary
|
||||
* process has control. Effectively the same as cancel. You want control but you
|
||||
* don't get it.
|
||||
*/
|
||||
void onLostControl();
|
||||
|
||||
/**
|
||||
* Used to determine which Process gains control if multiple are reporting {@link #isActive()}. The one
|
||||
* that returns the highest value will be given control.
|
||||
*
|
||||
* @return A double representing the priority
|
||||
*/
|
||||
double 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();
|
||||
}
|
||||
@@ -15,40 +15,36 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.interfaces;
|
||||
package baritone.api.process;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/20/2018
|
||||
*/
|
||||
public interface Toggleable {
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
|
||||
public interface ICustomGoalProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Toggles the enabled state of this {@link Toggleable}.
|
||||
* Sets the pathing goal
|
||||
*
|
||||
* @return The new state.
|
||||
* @param goal The new goal
|
||||
*/
|
||||
boolean toggle();
|
||||
void setGoal(Goal goal);
|
||||
|
||||
/**
|
||||
* Sets the enabled state of this {@link Toggleable}.
|
||||
* Starts path calculation and execution.
|
||||
*/
|
||||
void path();
|
||||
|
||||
/**
|
||||
* @return The current goal
|
||||
*/
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* Sets the goal and begins the path execution.
|
||||
*
|
||||
* @return The new state.
|
||||
* @param goal The new goal
|
||||
*/
|
||||
boolean setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* @return Whether or not this {@link Toggleable} object is enabled
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Called when the state changes from disabled to enabled
|
||||
*/
|
||||
default void onEnable() {}
|
||||
|
||||
/**
|
||||
* Called when the state changes from enabled to disabled
|
||||
*/
|
||||
default void onDisable() {}
|
||||
default void setGoalAndPath(Goal goal) {
|
||||
this.setGoal(goal);
|
||||
this.path();
|
||||
}
|
||||
}
|
||||
51
src/api/java/baritone/api/process/IFollowProcess.java
Normal file
51
src/api/java/baritone/api/process/IFollowProcess.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 net.minecraft.entity.Entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IFollowProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Set the follow target to any entities matching this predicate
|
||||
*
|
||||
* @param filter the predicate
|
||||
*/
|
||||
void follow(Predicate<Entity> filter);
|
||||
|
||||
/**
|
||||
* @return The entities that are currently being followed. null if not currently following, empty if nothing matches the predicate
|
||||
*/
|
||||
List<Entity> following();
|
||||
|
||||
Predicate<Entity> currentFilter();
|
||||
|
||||
/**
|
||||
* Cancels the follow behavior, this will clear the current follow target.
|
||||
*/
|
||||
default void cancel() {
|
||||
onLostControl();
|
||||
}
|
||||
}
|
||||
28
src/api/java/baritone/api/process/IGetToBlockProcess.java
Normal file
28
src/api/java/baritone/api/process/IGetToBlockProcess.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* but it rescans the world every once in a while so it doesn't get fooled by its cache
|
||||
*/
|
||||
public interface IGetToBlockProcess extends IBaritoneProcess {
|
||||
|
||||
void getToBlock(Block block);
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.behavior;
|
||||
package baritone.api.process;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.block.Block;
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IMineBehavior extends IBehavior {
|
||||
public interface IMineProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Begin to search for and mine the specified blocks until
|
||||
@@ -31,9 +31,9 @@ public interface IMineBehavior extends IBehavior {
|
||||
* are mined. This is based on the first target block to mine.
|
||||
*
|
||||
* @param quantity The number of items to get from blocks mined
|
||||
* @param blocks The blocks to mine
|
||||
* @param blocks The blocks to mine
|
||||
*/
|
||||
void mine(int quantity, String... blocks);
|
||||
void mineByName(int quantity, String... blocks);
|
||||
|
||||
/**
|
||||
* Begin to search for and mine the specified blocks until
|
||||
@@ -41,7 +41,7 @@ public interface IMineBehavior extends IBehavior {
|
||||
* are mined. This is based on the first target block to mine.
|
||||
*
|
||||
* @param quantity The number of items to get from blocks mined
|
||||
* @param blocks The blocks to mine
|
||||
* @param blocks The blocks to mine
|
||||
*/
|
||||
void mine(int quantity, Block... blocks);
|
||||
|
||||
@@ -50,8 +50,8 @@ public interface IMineBehavior extends IBehavior {
|
||||
*
|
||||
* @param blocks The blocks to mine
|
||||
*/
|
||||
default void mine(String... blocks) {
|
||||
this.mine(0, blocks);
|
||||
default void mineByName(String... blocks) {
|
||||
mineByName(0, blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,11 +60,13 @@ public interface IMineBehavior extends IBehavior {
|
||||
* @param blocks The blocks to mine
|
||||
*/
|
||||
default void mine(Block... blocks) {
|
||||
this.mine(0, blocks);
|
||||
mine(0, blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current mining task
|
||||
*/
|
||||
void cancel();
|
||||
default void cancel() {
|
||||
onLostControl();
|
||||
}
|
||||
}
|
||||
56
src/api/java/baritone/api/process/PathingCommand.java
Normal file
56
src/api/java/baritone/api/process/PathingCommand.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.pathing.goals.Goal;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author leijurv
|
||||
*/
|
||||
public class PathingCommand {
|
||||
|
||||
/**
|
||||
* The target goal, may be {@code null}.
|
||||
*/
|
||||
public final Goal goal;
|
||||
|
||||
/**
|
||||
* The command type.
|
||||
*
|
||||
* @see PathingCommandType
|
||||
*/
|
||||
public final PathingCommandType commandType;
|
||||
|
||||
/**
|
||||
* Create a new {@link PathingCommand}.
|
||||
*
|
||||
* @param goal The target goal, may be {@code null}.
|
||||
* @param commandType The command type, cannot be {@code null}.
|
||||
* @throws NullPointerException if {@code commandType} is {@code null}.
|
||||
* @see Goal
|
||||
* @see PathingCommandType
|
||||
*/
|
||||
public PathingCommand(Goal goal, PathingCommandType commandType) {
|
||||
Objects.requireNonNull(commandType);
|
||||
|
||||
this.goal = goal;
|
||||
this.commandType = commandType;
|
||||
}
|
||||
}
|
||||
55
src/api/java/baritone/api/process/PathingCommandType.java
Normal file
55
src/api/java/baritone/api/process/PathingCommandType.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.process;
|
||||
|
||||
import baritone.api.Settings;
|
||||
|
||||
public enum PathingCommandType {
|
||||
|
||||
/**
|
||||
* Set the goal and path.
|
||||
* <p>
|
||||
* If you use this alongside a {@code null} goal, it will continue along its current path and current goal.
|
||||
*/
|
||||
SET_GOAL_AND_PATH,
|
||||
|
||||
/**
|
||||
* Has no effect on the current goal or path, just requests a pause
|
||||
*/
|
||||
REQUEST_PAUSE,
|
||||
|
||||
/**
|
||||
* Set the goal (regardless of {@code null}), and request a cancel of the current path (when safe)
|
||||
*/
|
||||
CANCEL_AND_SET_GOAL,
|
||||
|
||||
/**
|
||||
* Set the goal and path.
|
||||
* <p>
|
||||
* If {@link Settings#cancelOnGoalInvalidation} is {@code true}, revalidate the
|
||||
* current goal, and cancel if it's no longer valid, or if the new goal is {@code null}.
|
||||
*/
|
||||
REVALIDATE_GOAL_AND_PATH,
|
||||
|
||||
/**
|
||||
* Set the goal and path.
|
||||
* <p>
|
||||
* Cancel the current path if the goals are not equal
|
||||
*/
|
||||
FORCE_REVALIDATE_GOAL_AND_PATH
|
||||
}
|
||||
@@ -15,9 +15,8 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.pathing;
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@@ -36,14 +35,12 @@ public final class BetterBlockPos extends BlockPos {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final long hashCode;
|
||||
|
||||
public BetterBlockPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.hashCode = AbstractNodeCostSearch.posHash(x, y, z);
|
||||
}
|
||||
|
||||
public BetterBlockPos(double x, double y, double z) {
|
||||
@@ -56,7 +53,30 @@ public final class BetterBlockPos extends BlockPos {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) hashCode;
|
||||
return (int) longHash(x, y, z);
|
||||
}
|
||||
|
||||
public static long longHash(BetterBlockPos pos) {
|
||||
return longHash(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
public static long longHash(int x, int y, int z) {
|
||||
/*
|
||||
* This is the hashcode implementation of Vec3i (the superclass of the class which I shall not name)
|
||||
*
|
||||
* public int hashCode() {
|
||||
* return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||
* }
|
||||
*
|
||||
* That is terrible and has tons of collisions and makes the HashMap terribly inefficient.
|
||||
*
|
||||
* That's why we grab out the X, Y, Z and calculate our own hashcode
|
||||
*/
|
||||
long hash = 3241;
|
||||
hash = 3457689L * hash + x;
|
||||
hash = 8734625L * hash + y;
|
||||
hash = 2873465L * hash + z;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,9 +86,6 @@ public final class BetterBlockPos extends BlockPos {
|
||||
}
|
||||
if (o instanceof BetterBlockPos) {
|
||||
BetterBlockPos oth = (BetterBlockPos) o;
|
||||
if (oth.hashCode != hashCode) {
|
||||
return false;
|
||||
}
|
||||
return oth.x == x && oth.y == y && oth.z == z;
|
||||
}
|
||||
// during path execution, like "if (whereShouldIBe.equals(whereAmI)) {"
|
||||
37
src/api/java/baritone/api/utils/IInputOverrideHandler.java
Normal file
37
src/api/java/baritone/api/utils/IInputOverrideHandler.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 baritone.api.behavior.IBehavior;
|
||||
import baritone.api.utils.input.Input;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 11/12/2018
|
||||
*/
|
||||
public interface IInputOverrideHandler extends IBehavior {
|
||||
|
||||
Boolean isInputForcedDown(KeyBinding key);
|
||||
|
||||
boolean isInputForcedDown(Input input);
|
||||
|
||||
void setInputForceState(Input input, boolean forced);
|
||||
|
||||
void clearAllKeys();
|
||||
}
|
||||
91
src/api/java/baritone/api/utils/IPlayerContext.java
Normal file
91
src/api/java/baritone/api/utils/IPlayerContext.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.cache.IWorldData;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 11/12/2018
|
||||
*/
|
||||
public interface IPlayerContext {
|
||||
|
||||
EntityPlayerSP player();
|
||||
|
||||
IPlayerController playerController();
|
||||
|
||||
World world();
|
||||
|
||||
IWorldData worldData();
|
||||
|
||||
RayTraceResult objectMouseOver();
|
||||
|
||||
default BetterBlockPos playerFeet() {
|
||||
// TODO find a better way to deal with soul sand!!!!!
|
||||
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) {
|
||||
return feet.up();
|
||||
}
|
||||
return feet;
|
||||
}
|
||||
|
||||
default Vec3d playerFeetAsVec() {
|
||||
return new Vec3d(player().posX, player().posY, player().posZ);
|
||||
}
|
||||
|
||||
default Vec3d playerHead() {
|
||||
return new Vec3d(player().posX, player().posY + player().getEyeHeight(), player().posZ);
|
||||
}
|
||||
|
||||
default Rotation playerRotations() {
|
||||
return new Rotation(player().rotationYaw, player().rotationPitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block that the crosshair is currently placed over. Updated once per tick.
|
||||
*
|
||||
* @return The position of the highlighted block
|
||||
*/
|
||||
default Optional<BlockPos> getSelectedBlock() {
|
||||
if (objectMouseOver() != null && objectMouseOver().typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return Optional.of(objectMouseOver().getBlockPos());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
46
src/api/java/baritone/api/utils/IPlayerController.java
Normal file
46
src/api/java/baritone/api/utils/IPlayerController.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.GameType;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
55
src/api/java/baritone/api/utils/PathCalculationResult.java
Normal file
55
src/api/java/baritone/api/utils/PathCalculationResult.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 baritone.api.pathing.calc.IPath;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PathCalculationResult {
|
||||
|
||||
private final IPath path;
|
||||
private final Type type;
|
||||
|
||||
public PathCalculationResult(Type type) {
|
||||
this(type, null);
|
||||
}
|
||||
|
||||
public PathCalculationResult(Type type, IPath path) {
|
||||
Objects.requireNonNull(type);
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public final Optional<IPath> getPath() {
|
||||
return Optional.ofNullable(this.path);
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
SUCCESS_TO_GOAL,
|
||||
SUCCESS_SEGMENT,
|
||||
FAILURE,
|
||||
CANCELLATION,
|
||||
EXCEPTION,
|
||||
}
|
||||
}
|
||||
52
src/api/java/baritone/api/utils/RayTraceUtils.java
Normal file
52
src/api/java/baritone/api/utils/RayTraceUtils.java
Normal file
@@ -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.api.utils;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/25/2018
|
||||
*/
|
||||
public final class RayTraceUtils {
|
||||
|
||||
private RayTraceUtils() {}
|
||||
|
||||
/**
|
||||
* Performs a block raytrace with the specified rotations. This should only be used when
|
||||
* 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 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) {
|
||||
Vec3d start = entity.getPositionEyes(1.0F);
|
||||
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
||||
Vec3d end = start.add(
|
||||
direction.x * blockReachDistance,
|
||||
direction.y * blockReachDistance,
|
||||
direction.z * blockReachDistance
|
||||
);
|
||||
return entity.world.rayTraceBlocks(start, end, false, false, true);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class Rotation {
|
||||
public Rotation clamp() {
|
||||
return new Rotation(
|
||||
this.yaw,
|
||||
RotationUtils.clampPitch(this.pitch)
|
||||
clampPitch(this.pitch)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Rotation {
|
||||
*/
|
||||
public Rotation normalize() {
|
||||
return new Rotation(
|
||||
RotationUtils.normalizeYaw(this.yaw),
|
||||
normalizeYaw(this.yaw),
|
||||
this.pitch
|
||||
);
|
||||
}
|
||||
@@ -105,8 +105,55 @@ public class Rotation {
|
||||
*/
|
||||
public Rotation normalizeAndClamp() {
|
||||
return new Rotation(
|
||||
RotationUtils.normalizeYaw(this.yaw),
|
||||
RotationUtils.clampPitch(this.pitch)
|
||||
normalizeYaw(this.yaw),
|
||||
clampPitch(this.pitch)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param pitch The input pitch
|
||||
* @return The clamped pitch
|
||||
*/
|
||||
public static float clampPitch(float pitch) {
|
||||
return Math.max(-90, Math.min(90, pitch));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the specified yaw value between -180 and 180.
|
||||
*
|
||||
* @param yaw The input yaw
|
||||
* @return The normalized yaw
|
||||
*/
|
||||
public static float normalizeYaw(float yaw) {
|
||||
float newYaw = yaw % 360F;
|
||||
if (newYaw < -180F) {
|
||||
newYaw += 360F;
|
||||
}
|
||||
if (newYaw > 180F) {
|
||||
newYaw -= 360F;
|
||||
}
|
||||
return newYaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Yaw: " + yaw + ", Pitch: " + pitch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,38 +17,212 @@
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import net.minecraft.block.BlockFire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/25/2018
|
||||
*/
|
||||
public final class RotationUtils {
|
||||
|
||||
/**
|
||||
* Constant that a degree value is multiplied by to get the equivalent radian value
|
||||
*/
|
||||
public static final double DEG_TO_RAD = Math.PI / 180.0;
|
||||
|
||||
/**
|
||||
* Constant that a radian value is multiplied by to get the equivalent degree value
|
||||
*/
|
||||
public static final double RAD_TO_DEG = 180.0 / Math.PI;
|
||||
|
||||
/**
|
||||
* Offsets from the root block position to the center of each side.
|
||||
*/
|
||||
private static final Vec3d[] BLOCK_SIDE_MULTIPLIERS = new Vec3d[]{
|
||||
new Vec3d(0.5, 0, 0.5), // Down
|
||||
new Vec3d(0.5, 1, 0.5), // Up
|
||||
new Vec3d(0.5, 0.5, 0), // North
|
||||
new Vec3d(0.5, 0.5, 1), // South
|
||||
new Vec3d(0, 0.5, 0.5), // West
|
||||
new Vec3d(1, 0.5, 0.5) // East
|
||||
};
|
||||
|
||||
private RotationUtils() {}
|
||||
|
||||
/**
|
||||
* Clamps the specified pitch value between -90 and 90.
|
||||
* Calculates the rotation from BlockPos<sub>dest</sub> to BlockPos<sub>orig</sub>
|
||||
*
|
||||
* @param pitch The input pitch
|
||||
* @return The clamped pitch
|
||||
* @param orig The origin position
|
||||
* @param dest The destination position
|
||||
* @return The rotation from the origin to the destination
|
||||
*/
|
||||
public static float clampPitch(float pitch) {
|
||||
return Math.max(-90, Math.min(90, pitch));
|
||||
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
|
||||
return calcRotationFromVec3d(new Vec3d(orig), new Vec3d(dest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the specified yaw value between -180 and 180.
|
||||
* Wraps the target angles to a relative value from the current angles. This is done by
|
||||
* subtracting the current from the target, normalizing it, and then adding the current
|
||||
* angles back to it.
|
||||
*
|
||||
* @param yaw The input yaw
|
||||
* @return The normalized yaw
|
||||
* @param current The current angles
|
||||
* @param target The target angles
|
||||
* @return The wrapped angles
|
||||
*/
|
||||
public static float normalizeYaw(float yaw) {
|
||||
float newYaw = yaw % 360F;
|
||||
if (newYaw < -180F) {
|
||||
newYaw += 360F;
|
||||
public static Rotation wrapAnglesToRelative(Rotation current, Rotation target) {
|
||||
if (current.yawIsReallyClose(target)) {
|
||||
return new Rotation(current.getYaw(), target.getPitch());
|
||||
}
|
||||
if (newYaw >= 180F) {
|
||||
newYaw -= 360F;
|
||||
return target.subtract(current).normalize().add(current);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the rotation from Vec<sub>dest</sub> to Vec<sub>orig</sub> and makes the
|
||||
* return value relative to the specified current rotations.
|
||||
*
|
||||
* @param orig The origin position
|
||||
* @param dest The destination position
|
||||
* @param current The current rotations
|
||||
* @return The rotation from the origin to the destination
|
||||
* @see #wrapAnglesToRelative(Rotation, Rotation)
|
||||
*/
|
||||
public static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest, Rotation current) {
|
||||
return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the rotation from Vec<sub>dest</sub> to Vec<sub>orig</sub>
|
||||
*
|
||||
* @param orig The origin position
|
||||
* @param dest The destination position
|
||||
* @return The rotation from the origin to the destination
|
||||
*/
|
||||
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]);
|
||||
double pitch = MathHelper.atan2(delta[1], dist);
|
||||
return new Rotation(
|
||||
(float) (yaw * RAD_TO_DEG),
|
||||
(float) (pitch * RAD_TO_DEG)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the look vector for the specified yaw/pitch rotations.
|
||||
*
|
||||
* @param rotation The input rotation
|
||||
* @return Look vector for the rotation
|
||||
*/
|
||||
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
|
||||
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
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,
|
||||
* that rotation will be returned. If not, it will return the first center of a given
|
||||
* 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 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))) {
|
||||
/*
|
||||
* why add 0.0001?
|
||||
* to indicate that we actually have a desired pitch
|
||||
* the way we indicate that the pitch can be whatever and we only care about the yaw
|
||||
* is by setting the desired pitch to the current pitch
|
||||
* setting the desired pitch to the current pitch + 0.0001 means that we do have a desired pitch, it's
|
||||
* just what it currently is
|
||||
*
|
||||
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
|
||||
*/
|
||||
return Optional.of(new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F));
|
||||
}
|
||||
return newYaw;
|
||||
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance);
|
||||
//System.out.println("center: " + possibleRotation);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
}
|
||||
|
||||
IBlockState state = entity.world.getBlockState(pos);
|
||||
AxisAlignedBB aabb = state.getBoundingBox(entity.world, pos);
|
||||
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
||||
double xDiff = aabb.minX * sideOffset.x + aabb.maxX * (1 - sideOffset.x);
|
||||
double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y);
|
||||
double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z);
|
||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified entity is able to reach the specified block with
|
||||
* 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 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, 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) {
|
||||
if (result.getBlockPos().equals(pos)) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
if (entity.world.getBlockState(pos).getBlock() instanceof BlockFire && result.getBlockPos().equals(pos.down())) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance);
|
||||
}
|
||||
}
|
||||
|
||||
162
src/api/java/baritone/api/utils/SettingsUtil.java
Normal file
162
src/api/java/baritone/api/utils/SettingsUtil.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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.Settings;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
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 Path SETTINGS_PATH = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt");
|
||||
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>[^ ]+)"); // 2 words separated by spaces
|
||||
|
||||
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 {
|
||||
forEachLine(SETTINGS_PATH, line -> {
|
||||
Matcher matcher = SETTING_PATTERN.matcher(line);
|
||||
if (!matcher.matches()) {
|
||||
System.out.println("Invalid syntax in setting file: " + line);
|
||||
return;
|
||||
}
|
||||
|
||||
String settingName = matcher.group("setting").toLowerCase();
|
||||
String settingValue = matcher.group("value");
|
||||
try {
|
||||
parseAndApply(settings, settingName, settingValue);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Unable to parse line " + line);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
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 (BufferedWriter out = Files.newBufferedWriter(SETTINGS_PATH)) {
|
||||
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");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Exception thrown while saving Baritone settings!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private 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);
|
||||
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 {
|
||||
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),
|
||||
|
||||
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());
|
||||
|
||||
|
||||
Class<?> klass;
|
||||
Function<String, Object> parser;
|
||||
Function<Object, String> toString;
|
||||
|
||||
<T> SettingsIO(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) {
|
||||
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);
|
||||
}
|
||||
map = Collections.unmodifiableMap(tempMap);
|
||||
}
|
||||
}
|
||||
116
src/api/java/baritone/api/utils/VecUtils.java
Normal file
116
src/api/java/baritone/api/utils/VecUtils.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.BlockFire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/13/2018
|
||||
*/
|
||||
public final class VecUtils {
|
||||
|
||||
private VecUtils() {}
|
||||
|
||||
/**
|
||||
* Calculates the center of the block at the specified position's bounding box
|
||||
*
|
||||
* @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)
|
||||
*/
|
||||
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
||||
IBlockState b = world.getBlockState(pos);
|
||||
AxisAlignedBB bbox = b.getBoundingBox(world, pos);
|
||||
double xDiff = (bbox.minX + bbox.maxX) / 2;
|
||||
double yDiff = (bbox.minY + bbox.maxY) / 2;
|
||||
double zDiff = (bbox.minZ + bbox.maxZ) / 2;
|
||||
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
|
||||
yDiff = 0;
|
||||
}
|
||||
return new Vec3d(
|
||||
pos.getX() + xDiff,
|
||||
pos.getY() + yDiff,
|
||||
pos.getZ() + zDiff
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the assumed center position of the given block position.
|
||||
* This is done by adding 0.5 to the X, Y, and Z axes.
|
||||
* <p>
|
||||
* TODO: We may want to consider replacing many usages of this method with #calculateBlockCenter(BlockPos)
|
||||
*
|
||||
* @param pos The block position
|
||||
* @return The assumed center of the position
|
||||
* @see #calculateBlockCenter(World, BlockPos)
|
||||
*/
|
||||
public static Vec3d getBlockPosCenter(BlockPos pos) {
|
||||
return new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distance from the specified position to the assumed center of the specified block position.
|
||||
*
|
||||
* @param pos The block position
|
||||
* @param x The x pos
|
||||
* @param y The y pos
|
||||
* @param z The z pos
|
||||
* @return The distance from the assumed block center to the position
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double distanceToCenter(BlockPos pos, double x, double y, double 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distance from the specified entity's position to the assumed
|
||||
* center of the specified block position.
|
||||
*
|
||||
* @param entity The entity
|
||||
* @param pos The block position
|
||||
* @return The distance from the entity to the block's assumed center
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
|
||||
return distanceToCenter(pos, entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distance from the specified entity's position to the assumed
|
||||
* center of the specified block position, ignoring the Y axis.
|
||||
*
|
||||
* @param entity The entity
|
||||
* @param pos The block position
|
||||
* @return The horizontal distance from the entity to the block's assumed center
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
|
||||
return distanceToCenter(pos, entity.posX, pos.getY() + 0.5, entity.posZ);
|
||||
}
|
||||
}
|
||||
119
src/api/java/baritone/api/utils/input/Input.java
Normal file
119
src/api/java/baritone/api/utils/input/Input.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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.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,
|
||||
* sneaking, and sprinting.
|
||||
*/
|
||||
public enum Input {
|
||||
|
||||
/**
|
||||
* The move forward input
|
||||
*/
|
||||
MOVE_FORWARD(s -> s.keyBindForward),
|
||||
|
||||
/**
|
||||
* The move back input
|
||||
*/
|
||||
MOVE_BACK(s -> s.keyBindBack),
|
||||
|
||||
/**
|
||||
* The move left input
|
||||
*/
|
||||
MOVE_LEFT(s -> s.keyBindLeft),
|
||||
|
||||
/**
|
||||
* The move right input
|
||||
*/
|
||||
MOVE_RIGHT(s -> s.keyBindRight),
|
||||
|
||||
/**
|
||||
* The attack input
|
||||
*/
|
||||
CLICK_LEFT(s -> s.keyBindAttack),
|
||||
|
||||
/**
|
||||
* The use item input
|
||||
*/
|
||||
CLICK_RIGHT(s -> s.keyBindUseItem),
|
||||
|
||||
/**
|
||||
* The jump input
|
||||
*/
|
||||
JUMP(s -> s.keyBindJump),
|
||||
|
||||
/**
|
||||
* The sneak input
|
||||
*/
|
||||
SNEAK(s -> s.keyBindSneak),
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
}
|
||||
@@ -17,61 +17,39 @@
|
||||
|
||||
package baritone.launch;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import io.github.impactdevelopment.simpletweaker.SimpleTweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 9:59 PM
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
public class BaritoneTweaker implements ITweaker {
|
||||
|
||||
List<String> args;
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
this.args = new ArrayList<>(args);
|
||||
if (gameDir != null) {
|
||||
addArg("gameDir", gameDir.getAbsolutePath());
|
||||
}
|
||||
if (assetsDir != null) {
|
||||
addArg("assetsDir", assetsDir.getAbsolutePath());
|
||||
}
|
||||
if (profile != null) {
|
||||
addArg("version", profile);
|
||||
}
|
||||
}
|
||||
public class BaritoneTweaker extends SimpleTweaker {
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
super.injectIntoClassLoader(classLoader);
|
||||
|
||||
MixinBootstrap.init();
|
||||
|
||||
// noinspection unchecked
|
||||
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
||||
|
||||
String obfuscation = ObfuscationServiceMCP.NOTCH;
|
||||
if (tweakClasses.stream().anyMatch(s -> s.contains("net.minecraftforge.fml.common.launcher"))) {
|
||||
obfuscation = ObfuscationServiceMCP.SEARGE;
|
||||
}
|
||||
|
||||
MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
|
||||
MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH);
|
||||
MixinEnvironment.getDefaultEnvironment().setObfuscationContext(obfuscation);
|
||||
|
||||
Mixins.addConfiguration("mixins.baritone.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getLaunchTarget() {
|
||||
return "net.minecraft.client.main.Main";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] getLaunchArguments() {
|
||||
return this.args.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void addArg(String label, String value) {
|
||||
if (!args.contains("--" + label) && value != null) {
|
||||
this.args.add("--" + label);
|
||||
this.args.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ import java.io.File;
|
||||
@Mixin(AnvilChunkLoader.class)
|
||||
public class MixinAnvilChunkLoader implements IAnvilChunkLoader {
|
||||
|
||||
@Shadow @Final private File chunkSaveLocation;
|
||||
@Shadow
|
||||
@Final
|
||||
private File chunkSaveLocation;
|
||||
|
||||
@Override
|
||||
public File getChunkSaveLocation() {
|
||||
|
||||
@@ -35,6 +35,12 @@ public class MixinBlockPos extends Vec3i {
|
||||
super(xIn, yIn, zIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of this was to ensure a friendly name for when we print raw
|
||||
* block positions to chat in the context of an obfuscated environment.
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String toString() {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.utils.accessor.IChunkProviderClient;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ChunkProviderClient.class)
|
||||
public class MixinChunkProviderClient implements IChunkProviderClient {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Long2ObjectMap<Chunk> loadedChunks;
|
||||
|
||||
@Override
|
||||
public Long2ObjectMap<Chunk> loadedChunks() {
|
||||
return this.loadedChunks;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,9 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Mixin(ChunkProviderServer.class)
|
||||
public class MixinChunkProviderServer implements IChunkProviderServer {
|
||||
|
||||
@Shadow @Final private IChunkLoader chunkLoader;
|
||||
@Shadow
|
||||
@Final
|
||||
private IChunkLoader chunkLoader;
|
||||
|
||||
@Override
|
||||
public IChunkLoader getChunkLoader() {
|
||||
|
||||
@@ -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.get() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.get());
|
||||
GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
return renderChunkIn.getPosition();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.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.get()) {
|
||||
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,56 +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.Baritone;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/21/2018
|
||||
*/
|
||||
@Mixin(Entity.class)
|
||||
public class MixinEntity {
|
||||
|
||||
@Inject(
|
||||
method = "moveRelative",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||
Entity _this = (Entity) (Object) this;
|
||||
if (_this == Minecraft.getMinecraft().player)
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.MOTION_UPDATE));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "moveRelative",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||
Entity _this = (Entity) (Object) this;
|
||||
if (_this == Minecraft.getMinecraft().player)
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.MOTION_UPDATE));
|
||||
}
|
||||
}
|
||||
@@ -17,41 +17,82 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static org.spongepowered.asm.lib.Opcodes.GETFIELD;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/10/2018
|
||||
*/
|
||||
@Mixin(EntityLivingBase.class)
|
||||
public class MixinEntityLivingBase {
|
||||
public abstract class MixinEntityLivingBase extends Entity {
|
||||
|
||||
/**
|
||||
* Event called to override the movement direction when jumping
|
||||
*/
|
||||
private RotationMoveEvent jumpRotationEvent;
|
||||
|
||||
public MixinEntityLivingBase(World worldIn, RotationMoveEvent jumpRotationEvent) {
|
||||
super(worldIn);
|
||||
this.jumpRotationEvent = jumpRotationEvent;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "jump",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preJump(CallbackInfo ci) {
|
||||
Entity _this = (Entity) (Object) this;
|
||||
if (_this == Minecraft.getMinecraft().player)
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.JUMP));
|
||||
private void preMoveRelative(CallbackInfo ci) {
|
||||
// noinspection ConstantConditions
|
||||
if (EntityPlayerSP.class.isInstance(this)) {
|
||||
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@Redirect(
|
||||
method = "jump",
|
||||
at = @At("RETURN")
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = GETFIELD,
|
||||
target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F"
|
||||
)
|
||||
)
|
||||
private void postJump(CallbackInfo ci) {
|
||||
Entity _this = (Entity) (Object) this;
|
||||
if (_this == Minecraft.getMinecraft().player)
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.JUMP));
|
||||
private float overrideYaw(EntityLivingBase self) {
|
||||
if (self instanceof EntityPlayerSP) {
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,26 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018 5:06 PM
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
@Mixin(EntityPlayerSP.class)
|
||||
public class MixinEntityPlayerSP {
|
||||
@@ -41,7 +48,7 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(msg);
|
||||
Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -57,7 +64,7 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private void onPreUpdate(CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -70,6 +77,49 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private void onPostUpdate(CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onLivingUpdate",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/entity/player/PlayerCapabilities.allowFlying:Z"
|
||||
)
|
||||
)
|
||||
private boolean isAllowFlying(PlayerCapabilities capabilities) {
|
||||
IPathingBehavior pathingBehavior = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getPathingBehavior();
|
||||
return !pathingBehavior.isPathing() && capabilities.allowFlying;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "onLivingUpdate",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z"
|
||||
)
|
||||
)
|
||||
private boolean isKeyDown(KeyBinding keyBinding) {
|
||||
SprintStateEvent event = new SprintStateEvent();
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
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) {
|
||||
((LookBehavior) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getLookBehavior()).pig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -33,10 +34,12 @@ public class MixinEntityRenderer {
|
||||
at = @At(
|
||||
value = "INVOKE_STRING",
|
||||
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
|
||||
args = { "ldc=hand" }
|
||||
args = {"ldc=hand"}
|
||||
)
|
||||
)
|
||||
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,62 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.utils.Helper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 11:44 PM
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
@Mixin(KeyBinding.class)
|
||||
public class MixinKeyBinding {
|
||||
|
||||
@Shadow
|
||||
private int pressTime;
|
||||
|
||||
@Inject(
|
||||
method = "isKeyDown",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void isKeyDown(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) {
|
||||
cir.setReturnValue(true);
|
||||
// only the primary baritone forces keys
|
||||
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
||||
if (force != null) {
|
||||
if (!force && !Baritone.settings().suppressClicks.get()) {
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(force); // :sunglasses:
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "isPressed",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void isPressed(CallbackInfoReturnable<Boolean> cir) {
|
||||
// only the primary baritone forces keys
|
||||
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
||||
if (pressTime > 0 && (KeyBinding) (Object) this == Minecraft.getMinecraft().gameSettings.keyBindAttack && Baritone.settings().clickCancel.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing()) {
|
||||
Helper.HELPER.logDirect("Cancelling path on left click since the clickCancel setting is enabled!");
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
|
||||
return;
|
||||
}
|
||||
if (force != null && !force && Baritone.settings().suppressClicks.get()) { // <-- cursed
|
||||
if (pressTime > 0) {
|
||||
Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you.");
|
||||
Helper.HELPER.logDirect("Turn off the suppressClicks setting to allow clicking while pathing.");
|
||||
pressTime--;
|
||||
}
|
||||
cir.setReturnValue(force); // :sunglasses:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.BlockInteractEvent;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.events.WorldEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.utils.ExampleBaritoneControl;
|
||||
import baritone.utils.BaritoneAutoTest;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -43,13 +44,11 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 10:51 PM
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft {
|
||||
|
||||
@Shadow
|
||||
private int leftClickCounter;
|
||||
@Shadow
|
||||
public EntityPlayerSP player;
|
||||
@Shadow
|
||||
@@ -59,9 +58,19 @@ public class MixinMinecraft {
|
||||
method = "init",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void init(CallbackInfo ci) {
|
||||
Baritone.INSTANCE.init();
|
||||
ExampleBaritoneControl.INSTANCE.initAndRegister();
|
||||
private void postInit(CallbackInfo ci) {
|
||||
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).init();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "init",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/Minecraft.startTimerHackThread()V"
|
||||
)
|
||||
)
|
||||
private void preInit(CallbackInfo ci) {
|
||||
BaritoneAutoTest.INSTANCE.onPreInit();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -76,21 +85,15 @@ public class MixinMinecraft {
|
||||
)
|
||||
)
|
||||
private void runTick(CallbackInfo ci) {
|
||||
Minecraft mc = (Minecraft) (Object) this;
|
||||
Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent(
|
||||
EventState.PRE,
|
||||
(mc.player != null && mc.world != null)
|
||||
? TickEvent.Type.IN
|
||||
: TickEvent.Type.OUT
|
||||
));
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
|
||||
TickEvent.Type type = ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().world() != null
|
||||
? TickEvent.Type.IN
|
||||
: TickEvent.Type.OUT;
|
||||
|
||||
ibaritone.getGameEventHandler().onTick(new TickEvent(EventState.PRE, type));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "processKeyBinds",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void runTickKeyboard(CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -103,7 +106,9 @@ public class MixinMinecraft {
|
||||
return;
|
||||
}
|
||||
|
||||
Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
|
||||
// mc.world changing is only the primary baritone
|
||||
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onWorldEvent(
|
||||
new WorldEvent(
|
||||
world,
|
||||
EventState.PRE
|
||||
@@ -118,7 +123,8 @@ public class MixinMinecraft {
|
||||
private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
|
||||
// still fire event for both null, as that means we've just finished exiting a world
|
||||
|
||||
Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
|
||||
// mc.world changing is only the primary baritone
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onWorldEvent(
|
||||
new WorldEvent(
|
||||
world,
|
||||
EventState.POST
|
||||
@@ -135,7 +141,8 @@ public class MixinMinecraft {
|
||||
)
|
||||
)
|
||||
private boolean isAllowUserInput(GuiScreen screen) {
|
||||
return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput;
|
||||
// allow user input is only the primary baritone
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -147,7 +154,8 @@ public class MixinMinecraft {
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK));
|
||||
// clickMouse is only for the main player
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.START_BREAK));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -159,6 +167,7 @@ public class MixinMinecraft {
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
|
||||
// rightClickMouse is only for the main player
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
@@ -30,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/3/2018 12:54 AM
|
||||
* @since 8/3/2018
|
||||
*/
|
||||
@Mixin(NetHandlerPlayClient.class)
|
||||
public class MixinNetHandlerPlayClient {
|
||||
@@ -43,14 +44,18 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
)
|
||||
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
ChunkEvent.Type.POPULATE,
|
||||
packetIn.getChunkX(),
|
||||
packetIn.getChunkZ()
|
||||
)
|
||||
);
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
|
||||
packetIn.getChunkX(),
|
||||
packetIn.getChunkZ()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -58,14 +63,18 @@ public class MixinNetHandlerPlayClient {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
ChunkEvent.Type.POPULATE,
|
||||
packetIn.getChunkX(),
|
||||
packetIn.getChunkZ()
|
||||
)
|
||||
);
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
|
||||
packetIn.getChunkX(),
|
||||
packetIn.getChunkZ()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -76,6 +85,10 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
)
|
||||
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onPlayerDeath();
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onPlayerDeath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.PacketEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -36,7 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/6/2018 9:30 PM
|
||||
* @since 8/6/2018
|
||||
*/
|
||||
@Mixin(NetworkManager.class)
|
||||
public class MixinNetworkManager {
|
||||
@@ -53,8 +54,14 @@ public class MixinNetworkManager {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket));
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +70,14 @@ public class MixinNetworkManager {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket));
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +89,14 @@ public class MixinNetworkManager {
|
||||
)
|
||||
)
|
||||
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.PRE, packet));}
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -85,8 +104,13 @@ public class MixinNetworkManager {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||
if (this.channel.isOpen() && this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet));
|
||||
if (!this.channel.isOpen() || this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
88
src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
Normal file
88
src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.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.get()) {
|
||||
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.get()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
46
src/launch/java/baritone/launch/mixins/MixinRenderList.java
Normal file
46
src/launch/java/baritone/launch/mixins/MixinRenderList.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.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.get()) {
|
||||
// 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,46 @@
|
||||
/*
|
||||
* 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.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.get()) {
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
@@ -28,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/2/2018 12:41 AM
|
||||
* @since 8/2/2018
|
||||
*/
|
||||
@Mixin(WorldClient.class)
|
||||
public class MixinWorldClient {
|
||||
@@ -38,14 +39,19 @@ public class MixinWorldClient {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||
chunkX,
|
||||
chunkZ
|
||||
)
|
||||
);
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||
chunkX,
|
||||
chunkZ
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -53,13 +59,17 @@ public class MixinWorldClient {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||
chunkX,
|
||||
chunkZ
|
||||
)
|
||||
);
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||
chunkX,
|
||||
chunkZ
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
"client": [
|
||||
"MixinAnvilChunkLoader",
|
||||
"MixinBlockPos",
|
||||
"MixinChunkProviderClient",
|
||||
"MixinChunkProviderServer",
|
||||
"MixinEntity",
|
||||
"MixinChunkRenderContainer",
|
||||
"MixinChunkRenderWorker",
|
||||
"MixinEntityLivingBase",
|
||||
"MixinEntityPlayerSP",
|
||||
"MixinEntityRenderer",
|
||||
@@ -19,6 +21,9 @@
|
||||
"MixinMinecraft",
|
||||
"MixinNetHandlerPlayClient",
|
||||
"MixinNetworkManager",
|
||||
"MixinRenderChunk",
|
||||
"MixinRenderList",
|
||||
"MixinVboRenderList",
|
||||
"MixinWorldClient"
|
||||
]
|
||||
}
|
||||
@@ -18,13 +18,19 @@
|
||||
package baritone;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.listener.IGameEventListener;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.utils.BaritoneAutoTest;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.process.CustomGoalProcess;
|
||||
import baritone.process.FollowProcess;
|
||||
import baritone.process.GetToBlockProcess;
|
||||
import baritone.process.MineProcess;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
@@ -36,18 +42,26 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 10:50 PM
|
||||
* @since 7/31/2018
|
||||
*/
|
||||
public enum Baritone {
|
||||
public class Baritone implements IBaritone {
|
||||
|
||||
/**
|
||||
* Singleton instance of this class
|
||||
*/
|
||||
INSTANCE;
|
||||
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
|
||||
@@ -55,122 +69,142 @@ public enum Baritone {
|
||||
private boolean initialized;
|
||||
|
||||
private GameEventHandler gameEventHandler;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
private Settings settings;
|
||||
|
||||
private List<Behavior> behaviors;
|
||||
private File dir;
|
||||
private ThreadPoolExecutor threadPool;
|
||||
private PathingBehavior pathingBehavior;
|
||||
private LookBehavior lookBehavior;
|
||||
private MemoryBehavior memoryBehavior;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
|
||||
private FollowProcess followProcess;
|
||||
private MineProcess mineProcess;
|
||||
private GetToBlockProcess getToBlockProcess;
|
||||
private CustomGoalProcess customGoalProcess;
|
||||
|
||||
/**
|
||||
* List of consumers to be called after Baritone has initialized
|
||||
*/
|
||||
private List<Consumer<Baritone>> onInitConsumers;
|
||||
private PathingControlManager pathingControlManager;
|
||||
|
||||
/**
|
||||
* Whether or not Baritone is active
|
||||
*/
|
||||
private boolean active;
|
||||
private IPlayerContext playerContext;
|
||||
private WorldProvider worldProvider;
|
||||
|
||||
public BlockStateInterface bsi;
|
||||
|
||||
Baritone() {
|
||||
this.onInitConsumers = new ArrayList<>();
|
||||
this.gameEventHandler = new GameEventHandler(this);
|
||||
}
|
||||
|
||||
public synchronized void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
this.threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
this.gameEventHandler = new GameEventHandler();
|
||||
this.inputOverrideHandler = new InputOverrideHandler();
|
||||
|
||||
// Acquire the "singleton" instance of the settings directly from the API
|
||||
// We might want to change this...
|
||||
this.settings = BaritoneAPI.getSettings();
|
||||
|
||||
BaritoneAPI.registerProviders(WorldProvider.INSTANCE);
|
||||
// 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<>();
|
||||
{
|
||||
registerBehavior(PathingBehavior.INSTANCE);
|
||||
registerBehavior(LookBehavior.INSTANCE);
|
||||
registerBehavior(MemoryBehavior.INSTANCE);
|
||||
registerBehavior(LocationTrackingBehavior.INSTANCE);
|
||||
registerBehavior(FollowBehavior.INSTANCE);
|
||||
registerBehavior(MineBehavior.INSTANCE);
|
||||
|
||||
// TODO: Clean this up
|
||||
// Maybe combine this call in someway with the registerBehavior calls?
|
||||
BaritoneAPI.registerDefaultBehaviors(
|
||||
FollowBehavior.INSTANCE,
|
||||
LookBehavior.INSTANCE,
|
||||
MemoryBehavior.INSTANCE,
|
||||
MineBehavior.INSTANCE,
|
||||
PathingBehavior.INSTANCE
|
||||
);
|
||||
}
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST && "true".equals(System.getenv("BARITONE_AUTO_TEST"))) {
|
||||
registerEventListener(new BaritoneAutoTest());
|
||||
}
|
||||
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||
if (!Files.exists(dir.toPath())) {
|
||||
try {
|
||||
Files.createDirectories(dir.toPath());
|
||||
} catch (IOException ignored) {}
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
||||
this.worldProvider = new WorldProvider();
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||
}
|
||||
|
||||
this.active = true;
|
||||
this.initialized = true;
|
||||
|
||||
this.onInitConsumers.forEach(consumer -> consumer.accept(this));
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return this.initialized;
|
||||
}
|
||||
|
||||
public IGameEventListener getGameEventHandler() {
|
||||
return this.gameEventHandler;
|
||||
}
|
||||
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
@Override
|
||||
public PathingControlManager getPathingControlManager() {
|
||||
return this.pathingControlManager;
|
||||
}
|
||||
|
||||
public List<Behavior> getBehaviors() {
|
||||
return this.behaviors;
|
||||
}
|
||||
|
||||
public Executor getExecutor() {
|
||||
return threadPool;
|
||||
}
|
||||
|
||||
public void registerBehavior(Behavior behavior) {
|
||||
this.behaviors.add(behavior);
|
||||
this.registerEventListener(behavior);
|
||||
this.gameEventHandler.registerEventListener(behavior);
|
||||
}
|
||||
|
||||
public void registerEventListener(IGameEventListener listener) {
|
||||
this.gameEventHandler.registerEventListener(listener);
|
||||
@Override
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
@Override
|
||||
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
||||
return this.customGoalProcess;
|
||||
}
|
||||
|
||||
public Settings getSettings() {
|
||||
return this.settings;
|
||||
@Override
|
||||
public GetToBlockProcess getGetToBlockProcess() { // Iffy
|
||||
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 LookBehavior getLookBehavior() {
|
||||
return this.lookBehavior;
|
||||
}
|
||||
|
||||
@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 Baritone.INSTANCE.settings; // yolo
|
||||
return BaritoneAPI.getSettings();
|
||||
}
|
||||
|
||||
public File getDir() {
|
||||
return this.dir;
|
||||
public static File getDir() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public void registerInitListener(Consumer<Baritone> runnable) {
|
||||
this.onInitConsumers.add(runnable);
|
||||
public static Executor getExecutor() {
|
||||
return threadPool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,30 +15,37 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch;
|
||||
package baritone;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.IBaritoneProvider;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 7/31/2018 10:09 PM
|
||||
* @since 9/29/2018
|
||||
*/
|
||||
public class BaritoneTweakerForge extends BaritoneTweaker {
|
||||
public final class BaritoneProvider implements IBaritoneProvider {
|
||||
|
||||
private final Baritone primary = new Baritone();
|
||||
|
||||
@Override
|
||||
public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
this.args = new ArrayList<>();
|
||||
public IBaritone getPrimaryBaritone() {
|
||||
return primary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
super.injectIntoClassLoader(classLoader);
|
||||
MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE);
|
||||
public List<IBaritone> getAllBaritones() {
|
||||
// TODO return a CopyOnWriteArrayList
|
||||
return Collections.singletonList(primary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldScanner getWorldScanner() {
|
||||
return WorldScanner.INSTANCE;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user