Compare commits
800 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c528dba0ea | ||
|
|
2b3a302a5f | ||
|
|
1c00e167ca | ||
|
|
861ee5049a | ||
|
|
2f9efae457 | ||
|
|
c1fe588de4 | ||
|
|
8fa2dac261 | ||
|
|
5e9b439591 | ||
|
|
f0ae31f455 | ||
|
|
dc7d64fb88 | ||
|
|
42306055ee | ||
|
|
62df244db7 | ||
|
|
ce2fc6f251 | ||
|
|
0b2bab6549 | ||
|
|
eb619adf4a | ||
|
|
4d05b152f0 | ||
|
|
c908552174 | ||
|
|
f1bbdc177f | ||
|
|
9591b6fdef | ||
|
|
84a257faf4 | ||
|
|
34620a448e | ||
|
|
2b4d6f4aa0 | ||
|
|
8f0a8b6f56 | ||
|
|
e54d63576f | ||
|
|
7e505fc68f | ||
|
|
9c323aba91 | ||
|
|
d1c2a0491c | ||
|
|
d19039e3e5 | ||
|
|
22d5cb8068 | ||
|
|
5f0d3a4018 | ||
|
|
889e288524 | ||
|
|
06805057d4 | ||
|
|
6e1e355a61 | ||
|
|
9843e8048d | ||
|
|
29d8ab43f2 | ||
|
|
1440e81ea4 | ||
|
|
bfd8773efa | ||
|
|
3a3d880d81 | ||
|
|
089c5fb095 | ||
|
|
f1fb109d40 | ||
|
|
ae9671bff0 | ||
|
|
d256f05787 | ||
|
|
47e6a039ef | ||
|
|
b8c8b1eb69 | ||
|
|
8a396db80e | ||
|
|
6a90b57ced | ||
|
|
a75b90fcef | ||
|
|
9981af67d5 | ||
|
|
cf60a5f3bd | ||
|
|
a04742085e | ||
|
|
b75a78f3d3 | ||
|
|
45bea50c91 | ||
|
|
5ba1e67ea0 | ||
|
|
1064a79e1d | ||
|
|
3803bc631b | ||
|
|
0b39b3e7b4 | ||
|
|
2f480fcec2 | ||
|
|
a8b1badd8a | ||
|
|
f8f214ca90 | ||
|
|
595f5a35e0 | ||
|
|
9f271b1f44 | ||
|
|
7292245b55 | ||
|
|
9ffca6ad66 | ||
|
|
376c93bd3b | ||
|
|
204f9d2e31 | ||
|
|
e4353e489f | ||
|
|
b88af1d682 | ||
|
|
9d2f83d8d6 | ||
|
|
ea4f34cb0f | ||
|
|
b7eaae88a8 | ||
|
|
e70d18f046 | ||
|
|
5a83b791bb | ||
|
|
eaa426dd66 | ||
|
|
fc43ef9308 | ||
|
|
8b4ac3893e | ||
|
|
a0f412f255 | ||
|
|
0a2e3f98f9 | ||
|
|
6cc29712e2 | ||
|
|
fae24beaed | ||
|
|
394775fb9a | ||
|
|
5d9209ce80 | ||
|
|
aff3103f36 | ||
|
|
6f2529c243 | ||
|
|
e976224258 | ||
|
|
050b6046d7 | ||
|
|
f0c78751bf | ||
|
|
2870d2d69e | ||
|
|
fbabbe69c0 | ||
|
|
b63c54b657 | ||
|
|
3c914de690 | ||
|
|
307d6a0628 | ||
|
|
61d4f102ba | ||
|
|
0a38e6f690 | ||
|
|
23a592ec01 | ||
|
|
396a96d604 | ||
|
|
0504a1d4bf | ||
|
|
fa905b8844 | ||
|
|
7f58847f88 | ||
|
|
5f674b86f8 | ||
|
|
cccd61e050 | ||
|
|
bf03a000d1 | ||
|
|
fc63c16ee0 | ||
|
|
1bb4e44b71 | ||
|
|
147884f76d | ||
|
|
240af75ff7 | ||
|
|
c54dcdba24 | ||
|
|
9db07faf49 | ||
|
|
aefc82e47c | ||
|
|
957f62ffbb | ||
|
|
8a001a2438 | ||
|
|
f8d4e22b13 | ||
|
|
243e6e3b99 | ||
|
|
69e3481a32 | ||
|
|
daa0d0c859 | ||
|
|
72402052ae | ||
|
|
5ee1e738f4 | ||
|
|
382ad0079c | ||
|
|
8dc4ff26d6 | ||
|
|
755a3f0154 | ||
|
|
b51dccc737 | ||
|
|
620fc9af64 | ||
|
|
991283182c | ||
|
|
1413bd2f05 | ||
|
|
faa8c727c3 | ||
|
|
65d2bdaf2b | ||
|
|
17ca9ec43d | ||
|
|
289971557a | ||
|
|
d1a0b735d9 | ||
|
|
bc0f2b59da | ||
|
|
98bb3fba9c | ||
|
|
b405a610bb | ||
|
|
3e3df0b493 | ||
|
|
c1749057d9 | ||
|
|
150f7a9fd9 | ||
|
|
6411fd80aa | ||
|
|
0b953a237d | ||
|
|
48f6d338a6 | ||
|
|
afc575d080 | ||
|
|
384b9b4704 | ||
|
|
ce329d7fb3 | ||
|
|
287615b0a1 | ||
|
|
b96692f2d9 | ||
|
|
1b8aea2e6d | ||
|
|
97ce377b9c | ||
|
|
f1973b14c7 | ||
|
|
73bd2cdcc3 | ||
|
|
9038310150 | ||
|
|
07fb09b4cc | ||
|
|
ef38051826 | ||
|
|
445037b614 | ||
|
|
44ec969203 | ||
|
|
444cde1ee9 | ||
|
|
cf12cbbcf4 | ||
|
|
bb2f4da6b6 | ||
|
|
4bca6cc1a5 | ||
|
|
544ae24b64 | ||
|
|
8fc80a285c | ||
|
|
6ed86cb3c7 | ||
|
|
84f45ebb48 | ||
|
|
90fb17b89f | ||
|
|
d54e846f91 | ||
|
|
ee71819bb2 | ||
|
|
2ee313a795 | ||
|
|
b924e8511b | ||
|
|
15e9d756b7 | ||
|
|
8be879465a | ||
|
|
5e0b333cfd | ||
|
|
efa243386c | ||
|
|
ae6ee5688c | ||
|
|
9f3eaac3df | ||
|
|
c938983ff5 | ||
|
|
172ce3a054 | ||
|
|
69ca48287e | ||
|
|
a6726f4e96 | ||
|
|
b6c91b5062 | ||
|
|
fe47245b73 | ||
|
|
d687e1203a | ||
|
|
0280fcb2da | ||
|
|
4354d09c20 | ||
|
|
e3c4d06b2b | ||
|
|
6327c8492f | ||
|
|
e7412d0d46 | ||
|
|
6a181abdcb | ||
|
|
65a9b1a78a | ||
|
|
5ce644718e | ||
|
|
a7add6bc13 | ||
|
|
d2a046c8b4 | ||
|
|
33080a4e1c | ||
|
|
dae6cc8e20 | ||
|
|
a2159d62e5 | ||
|
|
a092a0ba94 | ||
|
|
33faf5c9b0 | ||
|
|
d927207b67 | ||
|
|
02419f8b07 | ||
|
|
ddeb2a5c14 | ||
|
|
8973b73bfa | ||
|
|
4557bab3c4 | ||
|
|
6e185b580c | ||
|
|
a9ba05bf5e | ||
|
|
b9f0da7d27 | ||
|
|
1c36bf3300 | ||
|
|
cca137d526 | ||
|
|
4e73880d4a | ||
|
|
24da012903 | ||
|
|
0bb148844d | ||
|
|
e53b207148 | ||
|
|
7c9b812a5b | ||
|
|
0eb7a5aed6 | ||
|
|
5cbf1eef5f | ||
|
|
ed4fba330d | ||
|
|
9046eb500b | ||
|
|
011b7427e2 | ||
|
|
13caaf6fa7 | ||
|
|
a98677dbda | ||
|
|
afc639ab4b | ||
|
|
6c1f0d3711 | ||
|
|
e1e6a08eb2 | ||
|
|
7b21b0401d | ||
|
|
4c935fc447 | ||
|
|
3d221dcda4 | ||
|
|
ac6c413fb8 | ||
|
|
17a07ba85e | ||
|
|
ca6f7003a5 | ||
|
|
d402ba61cc | ||
|
|
081fae98c4 | ||
|
|
014d3b3a99 | ||
|
|
19fe29ad1e | ||
|
|
8bcbd0231e | ||
|
|
01c0e321b5 | ||
|
|
5f721b544e | ||
|
|
57d4a79496 | ||
|
|
9541a45451 | ||
|
|
bba4c09195 | ||
|
|
06c62029c5 | ||
|
|
6f251b64f1 | ||
|
|
551b6b88d2 | ||
|
|
07cbc47fb2 | ||
|
|
fe6ca97f21 | ||
|
|
1b481c6765 | ||
|
|
1c5e0b4d68 | ||
|
|
afebdce1f8 | ||
|
|
2ca4c3042a | ||
|
|
a8226ba4c8 | ||
|
|
bc849daccb | ||
|
|
e34b2d1392 | ||
|
|
f5b4de023f | ||
|
|
6dc7a7788e | ||
|
|
6bee5828a0 | ||
|
|
8a5cc5b17d | ||
|
|
4e563c6130 | ||
|
|
01cf3c67a6 | ||
|
|
36315c5151 | ||
|
|
9f951f261d | ||
|
|
4c8907c629 | ||
|
|
223791cea7 | ||
|
|
de6e96b952 | ||
|
|
0e51a73149 | ||
|
|
44a092cd94 | ||
|
|
7000b6cda2 | ||
|
|
7a17f7d253 | ||
|
|
821e73c1d3 | ||
|
|
784bc52d6d | ||
|
|
4338e34734 | ||
|
|
61147536e5 | ||
|
|
6b9737eb3f | ||
|
|
fe54372a53 | ||
|
|
21e9c0b7c1 | ||
|
|
8bf977060e | ||
|
|
074ec333cf | ||
|
|
d505ec4f9f | ||
|
|
9dd6856872 | ||
|
|
4d127acb9a | ||
|
|
ed4753e968 | ||
|
|
df900c9e64 | ||
|
|
93a090c56e | ||
|
|
8b43d93259 | ||
|
|
053662d0af | ||
|
|
af943a8253 | ||
|
|
8151444671 | ||
|
|
f32147d9d5 | ||
|
|
515e0364f7 | ||
|
|
09239f8180 | ||
|
|
0d9f233e33 | ||
|
|
e034437c63 | ||
|
|
72be046f34 | ||
|
|
3ba8824eb0 | ||
|
|
b51a261bd1 | ||
|
|
38602dd141 | ||
|
|
cdbec60da0 | ||
|
|
2b41012c5b | ||
|
|
6bb87d0a64 | ||
|
|
b16f9edd2c | ||
|
|
ce4b1e09ed | ||
|
|
1a4635df16 | ||
|
|
1390af20b6 | ||
|
|
1427cf57a8 | ||
|
|
d70243b4c0 | ||
|
|
8f63dd4ba6 | ||
|
|
01658286af | ||
|
|
aa90c8b7cd | ||
|
|
eba1011fd6 | ||
|
|
96a424c25a | ||
|
|
f4dd100345 | ||
|
|
c7e1c917c3 | ||
|
|
cd4205c361 | ||
|
|
b81bcf8c6d | ||
|
|
4259764b70 | ||
|
|
8f761f7dff | ||
|
|
cbbaf2aa2f | ||
|
|
dd9b84646a | ||
|
|
94131fd705 | ||
|
|
6d8914e6c9 | ||
|
|
63ee687cee | ||
|
|
ab779dc850 | ||
|
|
c2f35ae46f | ||
|
|
199e0e5ed3 | ||
|
|
a8155b4b0b | ||
|
|
fdd78cf110 | ||
|
|
afff6395d1 | ||
|
|
4d3d48e962 | ||
|
|
36290e4e53 | ||
|
|
fd6923dd28 | ||
|
|
9c64067d49 | ||
|
|
f4d2ea7923 | ||
|
|
ce3d3bb244 | ||
|
|
fa71e7d84f | ||
|
|
b0115b8b4c | ||
|
|
3902b2db3b | ||
|
|
4ff61f96df | ||
|
|
f998dce614 | ||
|
|
2b9084d2f3 | ||
|
|
b3605546ac | ||
|
|
96097ab726 | ||
|
|
be142d79bc | ||
|
|
0fd241a9ba | ||
|
|
7b192f17e8 | ||
|
|
cc015846d2 | ||
|
|
e785bd13f5 | ||
|
|
eb6c0a39ea | ||
|
|
86525f98ec | ||
|
|
8758c77ac0 | ||
|
|
dba496471e | ||
|
|
125facfbb6 | ||
|
|
94bf703dde | ||
|
|
14bb0a0a80 | ||
|
|
1ee6e04f00 | ||
|
|
ee6796d5e2 | ||
|
|
81d7f3c319 | ||
|
|
9822962d98 | ||
|
|
ce606f826b | ||
|
|
4c4bc8058b | ||
|
|
f0210f7c5f | ||
|
|
aef84eceb8 | ||
|
|
a6ea9ed3a6 | ||
|
|
0815e3c195 | ||
|
|
a1c03eb601 | ||
|
|
1e43563cc3 | ||
|
|
63f3f9123a | ||
|
|
4860d3bd18 | ||
|
|
7fa6593bdc | ||
|
|
e1dd580df8 | ||
|
|
f19e63d6e9 | ||
|
|
130873d91d | ||
|
|
9611cb9057 | ||
|
|
023aa78d8b | ||
|
|
39a231eae0 | ||
|
|
aca6922be0 | ||
|
|
1a52537d0c | ||
|
|
479b4e3349 | ||
|
|
a1e2b018a2 | ||
|
|
aa0f664cda | ||
|
|
2e2f4aee1b | ||
|
|
18474d872c | ||
|
|
44327c009a | ||
|
|
de554655a5 | ||
|
|
bd0c7b9391 | ||
|
|
8d32db5206 | ||
|
|
a6954aa719 | ||
|
|
b4d203ab99 | ||
|
|
bb924ad83f | ||
|
|
79da32cc60 | ||
|
|
c7fe9c3171 | ||
|
|
d70da4f37d | ||
|
|
ccc1b04e81 | ||
|
|
352e428890 | ||
|
|
4679e12588 | ||
|
|
16b74ff53c | ||
|
|
9297e98ac3 | ||
|
|
6861bfd4e6 | ||
|
|
0dd4834e18 | ||
|
|
da58988f01 | ||
|
|
b2f3880722 | ||
|
|
0293a76702 | ||
|
|
6a13e94c4f | ||
|
|
79d448e5f4 | ||
|
|
264b3db63c | ||
|
|
c8cd4b5f28 | ||
|
|
c9e81897a5 | ||
|
|
c738007538 | ||
|
|
da8bf6b1b3 | ||
|
|
1501d721e7 | ||
|
|
482d874af2 | ||
|
|
7dcd7384f1 | ||
|
|
2a5ef35794 | ||
|
|
0f09a46540 | ||
|
|
a6d4708ccf | ||
|
|
77303b4a62 | ||
|
|
0ffbb0c151 | ||
|
|
b521d7bee1 | ||
|
|
4e96c5e5ee | ||
|
|
e05010c9d2 | ||
|
|
d0a1c241a4 | ||
|
|
4ea8f23fc7 | ||
|
|
ec819220b7 | ||
|
|
54da0d24a3 | ||
|
|
58ebd5f9a6 | ||
|
|
d60a0bee9e | ||
|
|
e9e26c981a | ||
|
|
5f12f04e87 | ||
|
|
7b7be32ca7 | ||
|
|
a14166b1e2 | ||
|
|
166eb97c3f | ||
|
|
920ce745c2 | ||
|
|
c931cde3ae | ||
|
|
f7a577e163 | ||
|
|
9bf3a041d4 | ||
|
|
85eb7d8043 | ||
|
|
b338dcc9de | ||
|
|
7d9b8ee4f3 | ||
|
|
0f61aaafb8 | ||
|
|
0927e0e017 | ||
|
|
783a7cedc3 | ||
|
|
b1ee23ad50 | ||
|
|
9118e0b368 | ||
|
|
5a0ccac0a1 | ||
|
|
c8419dc362 | ||
|
|
9127ba2fce | ||
|
|
36858ca219 | ||
|
|
30469e2de2 | ||
|
|
79c433b14d | ||
|
|
bc419cfd1a | ||
|
|
09fbf675ec | ||
|
|
2ee119fc64 | ||
|
|
83265fcb54 | ||
|
|
e8b4f4d2b6 | ||
|
|
714c6773c3 | ||
|
|
2fac594315 | ||
|
|
4bec49de5b | ||
|
|
4eaa6e20c3 | ||
|
|
315cc26525 | ||
|
|
794a761243 | ||
|
|
5da14fcb3f | ||
|
|
1047d4ade9 | ||
|
|
0b8fa3ffe3 | ||
|
|
498e4e2d6c | ||
|
|
850c414e8f | ||
|
|
d5a8ed5cb1 | ||
|
|
dd8406c39a | ||
|
|
13469053b9 | ||
|
|
c4c85b4f49 | ||
|
|
af0c3bbd5c | ||
|
|
2fcf9ace64 | ||
|
|
47e1c67bd8 | ||
|
|
7e3aa6efdd | ||
|
|
7a2f26ef62 | ||
|
|
b64154e3b3 | ||
|
|
26256e7155 | ||
|
|
6599736e00 | ||
|
|
343bb20bd8 | ||
|
|
518fa1c74d | ||
|
|
0b72a8b4b3 | ||
|
|
c013d1e0d9 | ||
|
|
fe51220e3c | ||
|
|
44d757347b | ||
|
|
3d3a5f420e | ||
|
|
c136182e17 | ||
|
|
a1a9b4e6b9 | ||
|
|
f49df63183 | ||
|
|
96414b37f3 | ||
|
|
544168ff45 | ||
|
|
e0a618a791 | ||
|
|
3333797144 | ||
|
|
9c9c9d4387 | ||
|
|
82d09a536d | ||
|
|
6e49adea33 | ||
|
|
f7f003c0f9 | ||
|
|
236d02cb47 | ||
|
|
f85afdbc70 | ||
|
|
6e97fe2210 | ||
|
|
6741666c24 | ||
|
|
fcadf68c90 | ||
|
|
65cd6a92d3 | ||
|
|
a09bb0d538 | ||
|
|
2bf475d840 | ||
|
|
76cdaaace6 | ||
|
|
ce59ef559f | ||
|
|
563028a5b3 | ||
|
|
d5c317b88b | ||
|
|
fc3f183dce | ||
|
|
6b6eea2d8c | ||
|
|
e54652941b | ||
|
|
867c01ff86 | ||
|
|
87a9e67ba8 | ||
|
|
bf076f6246 | ||
|
|
75b54dfaec | ||
|
|
71a2219b07 | ||
|
|
ccc3de2d7c | ||
|
|
af11e64cec | ||
|
|
2c3dc5d6b1 | ||
|
|
71482cc984 | ||
|
|
3329db1dae | ||
|
|
926e2d5620 | ||
|
|
d2de8828e7 | ||
|
|
9fcae6560e | ||
|
|
2e8fdd43ee | ||
|
|
27e39c8083 | ||
|
|
a8f373d568 | ||
|
|
c59ec9da10 | ||
|
|
71491a7922 | ||
|
|
3a675836da | ||
|
|
7e0fc81246 | ||
|
|
f970f932c7 | ||
|
|
52d2741f52 | ||
|
|
7bc6765cac | ||
|
|
85b2aea6e9 | ||
|
|
c6ba5481d9 | ||
|
|
81f47d5632 | ||
|
|
9b1440ed2c | ||
|
|
2a8dcee028 | ||
|
|
277ba3643c | ||
|
|
170c2d35c2 | ||
|
|
e5fbaf60f3 | ||
|
|
bc49b2d5ba | ||
|
|
f58b6b41cb | ||
|
|
ac1ac50158 | ||
|
|
d4103a924d | ||
|
|
0deb854e1b | ||
|
|
8268e3ec1b | ||
|
|
bd64f73842 | ||
|
|
cac653ddd9 | ||
|
|
04ff365890 | ||
|
|
54ed6ce5a5 | ||
|
|
32ac46c8a9 | ||
|
|
7ab2cd2a45 | ||
|
|
a07fae6cdd | ||
|
|
3f6af51713 | ||
|
|
8c4e778506 | ||
|
|
65902d556e | ||
|
|
af91da6a28 | ||
|
|
aada9731a6 | ||
|
|
9a15a65ad5 | ||
|
|
49658078b9 | ||
|
|
bcd097c6cb | ||
|
|
cfec67f1f9 | ||
|
|
0cbe9f81c8 | ||
|
|
42afd2dd54 | ||
|
|
aaaf0f8839 | ||
|
|
315929f31c | ||
|
|
358aa80280 | ||
|
|
1dd9e11994 | ||
|
|
5a8f02c944 | ||
|
|
f248a5b677 | ||
|
|
ee83471bf6 | ||
|
|
610fe6439f | ||
|
|
e4a49c5529 | ||
|
|
449b44ba50 | ||
|
|
a00eec402e | ||
|
|
717779f742 | ||
|
|
bd1dcff385 | ||
|
|
6f843bd24d | ||
|
|
226ede7ba2 | ||
|
|
89fb5cecd5 | ||
|
|
d79fbea433 | ||
|
|
a75317cc2c | ||
|
|
ee6df270ce | ||
|
|
e09541151f | ||
|
|
74e0552be0 | ||
|
|
4d22c10ddb | ||
|
|
1ea92a6092 | ||
|
|
909ab553eb | ||
|
|
866408aece | ||
|
|
2215f170df | ||
|
|
a5601fd89a | ||
|
|
fa8f2632f5 | ||
|
|
66eba84d06 | ||
|
|
92e39b5d1d | ||
|
|
0ddc47f473 | ||
|
|
ddfeca6947 | ||
|
|
6bd2e90cfd | ||
|
|
82505ddb01 | ||
|
|
2790d1d308 | ||
|
|
52d8d271f1 | ||
|
|
11e503a022 | ||
|
|
b240e8420a | ||
|
|
25024b58de | ||
|
|
6fe49380ba | ||
|
|
1f2e267e3d | ||
|
|
4cf6783622 | ||
|
|
82d77a7bac | ||
|
|
ba31d209c9 | ||
|
|
7974d9135b | ||
|
|
841a927033 | ||
|
|
5a16561954 | ||
|
|
a5a795a22c | ||
|
|
416b5b66d2 | ||
|
|
88e41f37b1 | ||
|
|
7cfa837604 | ||
|
|
6b7aca3081 | ||
|
|
580af2ab06 | ||
|
|
d144d30890 | ||
|
|
ecac546c6d | ||
|
|
e2cc51908b | ||
|
|
1390e04435 | ||
|
|
84d961cbab | ||
|
|
87b9d3915c | ||
|
|
c38d17563d | ||
|
|
0c2af85ac0 | ||
|
|
76297e8176 | ||
|
|
d90f391b5e | ||
|
|
d80ae57964 | ||
|
|
74d7483b3c | ||
|
|
b3c580e657 | ||
|
|
8050b69f2f | ||
|
|
459720c348 | ||
|
|
a73f5c1359 | ||
|
|
71cb0f6d36 | ||
|
|
0d15225b1d | ||
|
|
826f3788d0 | ||
|
|
2133ab39b7 | ||
|
|
558c14a375 | ||
|
|
882ac41291 | ||
|
|
66c7a3f513 | ||
|
|
5904441a7e | ||
|
|
c465228531 | ||
|
|
81b22019dd | ||
|
|
3e47d485f9 | ||
|
|
701bc772a8 | ||
|
|
3ae05b7348 | ||
|
|
2e186019f5 | ||
|
|
4c6f321cff | ||
|
|
c72eb3e195 | ||
|
|
a4237bf1f9 | ||
|
|
e767e34b92 | ||
|
|
8ac82ebe2a | ||
|
|
0ed6ccab71 | ||
|
|
bf25d7328e | ||
|
|
a47b0c0581 | ||
|
|
596849c7e6 | ||
|
|
76914b7859 | ||
|
|
3dbbe053d7 | ||
|
|
c474cdb1f8 | ||
|
|
3de02cbf21 | ||
|
|
26fefc70f0 | ||
|
|
4086c9f4b5 | ||
|
|
c947c77853 | ||
|
|
9be44c0371 | ||
|
|
5412fa6cfd | ||
|
|
6e7320b954 | ||
|
|
fbb2d37634 | ||
|
|
7afe16fc10 | ||
|
|
b19f241d81 | ||
|
|
583ce80003 | ||
|
|
195c33407e | ||
|
|
600c5b77ad | ||
|
|
f1084fab76 | ||
|
|
bd65e32407 | ||
|
|
e4416f424a | ||
|
|
73ec110b22 | ||
|
|
0bce801a3f | ||
|
|
e8e00e8dfb | ||
|
|
cc4335e48e | ||
|
|
5427911da3 | ||
|
|
c808d5a42d | ||
|
|
3b46dbd6a1 | ||
|
|
e63b2f1bf1 | ||
|
|
d32e822057 | ||
|
|
2b672998e1 | ||
|
|
e18dc7c7e7 | ||
|
|
16dcd2f44d | ||
|
|
eb9f755b54 | ||
|
|
29a9e6e1d1 | ||
|
|
1f52f706ed | ||
|
|
bf12763a10 | ||
|
|
963641a818 | ||
|
|
3e94d92fbd | ||
|
|
a72040f83d | ||
|
|
84d8f826ff | ||
|
|
70d216b29f | ||
|
|
66356d5334 | ||
|
|
d9625dfe78 | ||
|
|
6d847577d8 | ||
|
|
8fd687f9d7 | ||
|
|
f7a9380b9d | ||
|
|
5617c595b2 | ||
|
|
8770524679 | ||
|
|
a8ddb2fcf1 | ||
|
|
76c4ca9ba6 | ||
|
|
ed2b0f0bb9 | ||
|
|
6702b44b3e | ||
|
|
c486d8241e | ||
|
|
d2bb8c374e | ||
|
|
530cecea5b | ||
|
|
266e2dada9 | ||
|
|
ce73d34627 | ||
|
|
11af0a7aac | ||
|
|
46c2d8f7c7 | ||
|
|
38127011fb | ||
|
|
89b5ce4b63 | ||
|
|
4fe9c180d5 | ||
|
|
f094e83e4d | ||
|
|
5b6c9fc348 | ||
|
|
3f1ee100bf | ||
|
|
41b1106c72 | ||
|
|
b27d95a615 | ||
|
|
5b8a83853d | ||
|
|
d0548b2715 | ||
|
|
bffeb9c862 | ||
|
|
dbd760fbcb | ||
|
|
a84b3bfc7a | ||
|
|
e8d3bf509c | ||
|
|
b2583773d5 | ||
|
|
9ecd24c755 | ||
|
|
f1bacd6210 | ||
|
|
a21ec54d4f | ||
|
|
0b4efb24ae | ||
|
|
c473914d05 | ||
|
|
90a1fa8337 | ||
|
|
99cb7f5142 | ||
|
|
4026b850f8 | ||
|
|
aac7ebf6dd | ||
|
|
8d481ba394 | ||
|
|
24fa75c24e | ||
|
|
cf38d593b8 | ||
|
|
36f608c63c | ||
|
|
1d88564a72 | ||
|
|
503f2fb197 | ||
|
|
bb000c4e3f | ||
|
|
4868ed7560 | ||
|
|
7017e9e2ea | ||
|
|
a18eb90702 | ||
|
|
9d1d4fe0d9 | ||
|
|
1a430dc2cf | ||
|
|
e37a09a1c8 | ||
|
|
d0d8b12fb8 | ||
|
|
9a29f9ce57 | ||
|
|
42513e4b56 | ||
|
|
67fa91abe8 | ||
|
|
d8348ad292 | ||
|
|
6faa7344aa | ||
|
|
299540725e | ||
|
|
0ef08142fd | ||
|
|
c0761c0eef | ||
|
|
8694d926c4 | ||
|
|
46f8829951 | ||
|
|
4c4bce3561 | ||
|
|
68e8717b5c | ||
|
|
b484e6fa3f | ||
|
|
aa8773a67e | ||
|
|
a822d3ef05 | ||
|
|
311cf81e8a | ||
|
|
bf9ee918f3 | ||
|
|
92ba76e7a1 | ||
|
|
3326339263 | ||
|
|
52cafbc7aa | ||
|
|
efb316de14 | ||
|
|
3cf944398f | ||
|
|
d2bfd47039 | ||
|
|
920cb6556b | ||
|
|
cd3ae2a7f5 | ||
|
|
b12fedb2d9 | ||
|
|
1cae7ad6b1 | ||
|
|
7dd881aa9a | ||
|
|
5fb8a1d3d1 | ||
|
|
306bd18a40 | ||
|
|
847181ada4 | ||
|
|
1c1fbe83ec | ||
|
|
ccd56e0368 | ||
|
|
cef88cde20 | ||
|
|
aa3833915b | ||
|
|
0c0bbeff27 | ||
|
|
ceda14096c | ||
|
|
d5b393d6bd | ||
|
|
e2cdd6a7f9 | ||
|
|
261d02e67b | ||
|
|
a6ce4694fc | ||
|
|
14bc65468a | ||
|
|
56d109bf0a | ||
|
|
a965859095 | ||
|
|
863ae447b9 | ||
|
|
4dd922f1b5 | ||
|
|
f95dc40f4c | ||
|
|
81786f7a7c | ||
|
|
1381d8d94c | ||
|
|
1dca02517e | ||
|
|
b109fc7420 | ||
|
|
c74c01271d | ||
|
|
702b916948 | ||
|
|
8ed2431f37 | ||
|
|
c45cbebcce | ||
|
|
251110c4f8 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
25
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Please file a separate report for each issue
|
||||
title: Please add a brief but descriptive title
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Some information
|
||||
Operating system:
|
||||
Java version:
|
||||
Minecraft version:
|
||||
Baritone version:
|
||||
Forge mods (if used):
|
||||
|
||||
## Exception, error or logs
|
||||
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
|
||||
|
||||
## How to reproduce
|
||||
Add your steps to reproduce the issue/bug experienced here.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
|
||||
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
name: Question
|
||||
about: Please file a separate report for each question
|
||||
title: Please add a brief but descriptive title
|
||||
labels: question
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## What do you need help with?
|
||||
With as much detail as possible, describe your question and what you may need help with.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/suggestion.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Suggestion
|
||||
about: Please file a separate report for each suggestion
|
||||
title: Please add a brief but descriptive title
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Describe your suggestion
|
||||
With as much detail as possible, describe what your suggestion would do for Baritone.
|
||||
|
||||
## Settings
|
||||
If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.
|
||||
|
||||
## Context
|
||||
Describe how your suggestion would improve Baritone, or the reason behind it being added.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<!-- No UwU's or OwO's allowed -->
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -11,11 +11,15 @@ build/
|
||||
classes/
|
||||
*.class
|
||||
|
||||
/out
|
||||
|
||||
# IntelliJ Files
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
/logs/
|
||||
|
||||
# Copyright Files
|
||||
!/.idea/copyright/Baritone.xml
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
|
||||
@@ -10,7 +10,7 @@ install:
|
||||
|
||||
script:
|
||||
- docker run --rm cabaletta/baritone ./gradlew javadoc
|
||||
- docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||
- docker run --name baritone cabaletta/baritone /bin/sh -c "/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 runAutoTest; cat /code/autotest/success"
|
||||
- docker cp baritone:/code/dist dist
|
||||
- ls dist
|
||||
- cat dist/checksums.txt
|
||||
|
||||
83
CODE_OF_CONDUCT.md
Normal file
83
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* No Anime (including uwu's or owo's)
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Giving and gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* Anime
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* ~~Trolling, insulting/derogatory comments, and personal or political attacks~~
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission or consent
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
Project maintainers have the right and responsibility to immediately remove
|
||||
without any sort of dispute any issues or pull requests that do not align
|
||||
with their corresponding templates. Absolutely no leniancy shall be accepted
|
||||
with these terms.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at complaints@leijurv.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
11
Dockerfile
11
Dockerfile
@@ -1,17 +1,16 @@
|
||||
FROM debian:jessie
|
||||
FROM debian:stretch
|
||||
|
||||
RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list
|
||||
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update -y
|
||||
|
||||
RUN apt install --target-release jessie-backports \
|
||||
RUN apt install \
|
||||
openjdk-8-jdk \
|
||||
ca-certificates-java \
|
||||
--assume-yes
|
||||
|
||||
RUN apt install -qq --force-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
|
||||
COPY . /code
|
||||
|
||||
@@ -21,4 +20,4 @@ WORKDIR /code
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
- **Block breaking** Baritone considers breaking blocks as part of its path. It also takes into account your current tool set and hot bar. For example, if you have a Eff V diamond pick, it may choose to mine through a stone barrier, while if you only had a wood pick it might be faster to climb over it.
|
||||
- **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. <a href="https://www.youtube.com/watch?v=F6FbI1L9UmU">Example</a>
|
||||
- **Falling** Baritone will fall up to 3 blocks onto solid ground (configurable, if you have Feather Falling and/or don't mind taking a little damage). If you have a water bucket on your hotbar, it will fall up to 23 blocks and place the bucket beneath it. It will fall an unlimited distance into existing still water.
|
||||
- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`).
|
||||
- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). Baritone can break its fall by grabbing ladders / vines midair, and understands when that is and isn't possible.
|
||||
- **Opening fence gates and doors**
|
||||
- **Slabs and stairs**
|
||||
- **Falling blocks** Baritone understands the costs of breaking blocks with falling blocks on top, and includes all of their break costs. Additionally, since it avoids breaking any blocks touching a liquid, it won't break the bottom of a gravel stack below a lava lake (anymore).
|
||||
@@ -22,9 +22,9 @@ Baritone uses A*, with some modifications:
|
||||
- **Backtrack cost favoring** While calculating the next segment, Baritone favors backtracking its current segment. The cost is decreased heavily, but is still positive (this won't cause it to backtrack if it doesn't need to). This allows it to splice and jump onto the next segment as early as possible, if the next segment begins with a backtrack of the current one. <a href="https://www.youtube.com/watch?v=CGiMcb8-99Y">Example</a>
|
||||
- **Backtrack detection and pausing** While path calculation happens on a separate thread, the main game thread has access to the latest node considered, and the best path so far (those are rendered light blue and dark blue respectively). When the current best path (rendered dark blue) passes through the player's current position on the current path segment, path execution is paused (if it's safe to do so), because there's no point continuing forward if we're about to turn around and go back that same way. Note that the current best path as reported by the path calculation thread takes into account the incremental cost backoff system, so it's accurate to what the path calculation thread will actually pick once it finishes.
|
||||
|
||||
# Configuring Baritone
|
||||
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>.
|
||||
To change a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `pathTimeoutMS 250`). It's case insensitive.
|
||||
# Chat control
|
||||
|
||||
- [Baritone chat control usage](USAGE.md)
|
||||
|
||||
# Goals
|
||||
The pathing goal can be set to any of these options:
|
||||
|
||||
88
INSTALL.md
88
INSTALL.md
@@ -1,88 +0,0 @@
|
||||
# Integration between Baritone and Impact
|
||||
Impact 4.4 has Baritone included.
|
||||
|
||||
These instructions apply to Impact 4.3 (and potentially other "hacked clients").
|
||||
|
||||
To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`).
|
||||
|
||||
## An Introduction
|
||||
There are some basic steps to getting Baritone setup with Impact.
|
||||
- Acquiring a build of Baritone
|
||||
- Placing Baritone in the libraries directory
|
||||
- Modifying the Impact Profile JSON to run baritone
|
||||
- How to use Baritone
|
||||
|
||||
## Acquiring a build of Baritone
|
||||
There are two methods of acquiring a build of Baritone
|
||||
|
||||
### Official Release (Not always up to date)
|
||||
https://github.com/cabaletta/baritone/releases
|
||||
|
||||
For Impact 4.3, there is no Baritone integration yet, so you will want `baritone-standalone-X.Y.Z.jar`.
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
|
||||
|
||||
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone . && docker run --rm cabaletta/baritone cat /code/dist/checksums.txt` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
|
||||
|
||||
### Building Baritone yourself
|
||||
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>
|
||||
that contains all of the dependencies that are required from the game and some mods. This is where we will be
|
||||
putting baritone.
|
||||
- Locate the ``libraries`` folder, it should be in the Minecraft Installation Directory
|
||||
- Create 3 new subdirectories starting from ``libraries``
|
||||
- ``cabaletta``
|
||||
- ``baritone``
|
||||
- ``X.Y.Z``
|
||||
- Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder
|
||||
- The full path should look like ``<Minecraft>/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar``
|
||||
|
||||
## Modifying the Impact Profile JSON to run baritone
|
||||
The final step is "registering" the Baritone library with Impact, so that it loads on launch.
|
||||
- Ensure your Minecraft launcher is closed
|
||||
- Navigate back to the Minecraft Installation Directory
|
||||
- Find the ``versions`` directory, and open in
|
||||
- In here there should be a ``1.12.2-Impact_4.3`` folder.
|
||||
- If you don't have any Impact folder or have a version older than 4.3, you can download Impact <a href="https://impactdevelopment.github.io">here</a>.
|
||||
- Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json``
|
||||
- Open the JSON file with a text editor that supports your system's line endings
|
||||
- For example, Notepad on Windows likely will NOT work for this. You should instead use a Text Editor like
|
||||
<a href="https://notepad-plus-plus.org/">Notepad++</a> if you're on Windows. (For other systems, I'm not sure
|
||||
what would work the best so you may have to do some research.)
|
||||
- Find the ``libraries`` array in the JSON. It should look something like this.
|
||||
```
|
||||
"libraries": [
|
||||
{
|
||||
"name": "net.minecraft:launchwrapper:1.12"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDevelopment:Impact:4.3-1.12.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDeveloment:ClientAPI:3.0.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
...
|
||||
```
|
||||
- Create two new objects in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably.
|
||||
```
|
||||
{
|
||||
"name": "cabaletta:baritone:X.Y.Z"
|
||||
},
|
||||
{
|
||||
"name": "com.github.ImpactDevelopment:SimpleTweaker:1.2",
|
||||
"url": "https://impactdevelopment.github.io/maven/"
|
||||
},
|
||||
```
|
||||
- Now find the ``"minecraftArguments": "..."`` text near the top.
|
||||
- At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like:
|
||||
- ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"``
|
||||
- If you didn't close your launcher for this step, restart it now.
|
||||
- You can now launch Impact 4.3 as normal, and Baritone should start up
|
||||
|
||||
## How to use Baritone
|
||||
Instructions on how to use Baritone are limited, and you may have to read a little bit of code (Really nothing much
|
||||
just plain English), you can view that <a href="https://github.com/cabaletta/baritone#chat-control">here</a>.
|
||||
BIN
LICENSE-Part-2.jpg
Normal file
BIN
LICENSE-Part-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
67
README.md
67
README.md
@@ -1,57 +1,68 @@
|
||||
# Baritone
|
||||
[](https://travis-ci.com/cabaletta/baritone)
|
||||
[](https://github.com/cabaletta/baritone/releases)
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[](https://github.com/cabaletta/baritone/issues)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](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://impactclient.net/)
|
||||
[](https://github.com/fr1kin/ForgeHax/)
|
||||
[](https://gitlab.com/emc-mods-indrit/baritone_api)
|
||||
[](https://wweclient.com/)
|
||||
[](https://futureclient.net/)
|
||||
[](https://github.com/fr1kin/ForgeHax)
|
||||
[](http://forthebadge.com/)
|
||||
[](http://forthebadge.com/)
|
||||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
|
||||
|
||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day for the last 6 months =D 🦀
|
||||
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
|
||||
|
||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||
|
||||
# Getting Started
|
||||
|
||||
Here are some links to help to get started:
|
||||
|
||||
- [Features](FEATURES.md)
|
||||
|
||||
- [Setup](SETUP.md)
|
||||
- [Installation & setup](SETUP.md)
|
||||
|
||||
- [Installation](INSTALL.md)
|
||||
- [API Javadocs](https://baritone.leijurv.com/)
|
||||
|
||||
- [Javadocs](https://baritone.leijurv.com/)
|
||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
||||
|
||||
# Chat control
|
||||
[Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java)
|
||||
- [Usage (chat control)](USAGE.md)
|
||||
|
||||
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
||||
# API
|
||||
|
||||
On v1.1.0 and newer: Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent).
|
||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
||||
jar.
|
||||
|
||||
For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting.
|
||||
|
||||
**Only** in Impact is `.b` also a valid prefix
|
||||
|
||||
# API example
|
||||
Below is an example of basic usage for changing some settings, and then pathing to a X/Z goal.
|
||||
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
@@ -64,11 +75,11 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd
|
||||
|
||||
## Can I use Baritone as a library in my custom utility client?
|
||||
|
||||
Sure! (As long as usage is in compliance with the LGPL 3 License)
|
||||
That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License)
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pain)
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
|
||||
52
SETUP.md
52
SETUP.md
@@ -1,11 +1,41 @@
|
||||
# Setup
|
||||
# Installation
|
||||
|
||||
## Prebuilt
|
||||
[Releases](https://github.com/cabaletta/baritone/releases)
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
|
||||
|
||||
Not always completely up to date with latest features.
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||
|
||||
The forge release (currently `baritone-forge-1.1.0.jar`) can simply be added as a Forge mod. However, it is not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. You should use Forge 14.23.4.2743 or **older** with Baritone. Newer versions of Forge "work", sort of, but Baritone's movement becomes unreliable and `freeLook` must be off.
|
||||
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
## Prebuilt official releases
|
||||
These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself)
|
||||
|
||||
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
|
||||
|
||||
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
|
||||
|
||||
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
|
||||
|
||||
|
||||
## Artifacts
|
||||
|
||||
Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
|
||||
|
||||
**The Forge release can simply be added as a Forge mod.**
|
||||
|
||||
If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar`
|
||||
|
||||
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
||||
- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration.
|
||||
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
|
||||
- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone.
|
||||
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
||||
|
||||
## More Info
|
||||
To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal.
|
||||
|
||||
You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`.
|
||||
|
||||
## Build it yourself
|
||||
- Clone or download Baritone
|
||||
@@ -74,15 +104,3 @@ $ gradlew build
|
||||

|
||||
|
||||
- Double click on **build** to run it
|
||||
|
||||
## Artifacts
|
||||
|
||||
Building Baritone will result in 4 artifacts created in the ``dist`` directory.
|
||||
|
||||
- **Forge**: Forge mod
|
||||
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
||||
- **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.
|
||||
- **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"`).
|
||||
|
||||
87
USAGE.md
Normal file
87
USAGE.md
Normal file
@@ -0,0 +1,87 @@
|
||||
(assuming you already have Baritone [set up](SETUP.md))
|
||||
|
||||
# Prefix
|
||||
|
||||
Baritone's chat control prefix is `#` by default. In Impact, you can also use `.b` as a prefix. (for example, `.b click` instead of `#click`)
|
||||
|
||||
Baritone commands can also by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of "goal" it goes into public chat, which is bad, so using `#` is suggested.
|
||||
|
||||
To disable direct chat control (with no prefix), turn off the `chatControl` setting. To disable chat control with the `#` prefix, turn off the `prefixControl` setting. In Impact, `.b` cannot be disabled. Be careful that you don't leave yourself with all control methods disabled (if you do, reset your settings by deleting the file `minecraft/baritone/settings.txt` and relaunching).
|
||||
|
||||
# Commands
|
||||
|
||||
**All** of these commands may need a prefix before them, as above ^.
|
||||
|
||||
`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java#L47).
|
||||
|
||||
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
|
||||
|
||||
Some common examples:
|
||||
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
|
||||
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
|
||||
- `goal` to set the goal to your player's feet
|
||||
- `goal clear` to clear the goal
|
||||
- `cancel` or `stop` to stop everything
|
||||
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
||||
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
|
||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
|
||||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `schematica` to build the schematic that is currently open in schematica
|
||||
- `tunnel` to dig just straight ahead and make a tunnel
|
||||
- `farm` to automatically harvest, replant, or bone meal crops
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
|
||||
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.
|
||||
- `version` to get the version of Baritone you're running
|
||||
- `damn` daniel
|
||||
|
||||
|
||||
New commands:
|
||||
- `sel` to manage selections
|
||||
- some others
|
||||
|
||||
|
||||
For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java).
|
||||
|
||||
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>. If you find HTML easier to read than Javadoc, you can look <a href="https://baritone.leijurv.com/baritone/api/Settings.html#field.detail">here</a>.
|
||||
|
||||
There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links.
|
||||
- `allowBreak`
|
||||
- `allowSprint`
|
||||
- `allowPlace`
|
||||
- `allowParkour`
|
||||
- `allowParkourPlace`
|
||||
- `blockPlacementPenalty`
|
||||
- `renderCachedChunks` (and `cachedChunksOpacity`) <-- very fun but you need a beefy computer
|
||||
- `avoidance` (avoidance of mobs / mob spawners)
|
||||
- `legitMine`
|
||||
- `followRadius`
|
||||
- `backfill` (fill in tunnels behind you)
|
||||
- `buildInLayers`
|
||||
- `buildRepeatDistance` and `buildRepeatDirection`
|
||||
- `worldExploringChunkOffset`
|
||||
- `acceptableThrowawayItems`
|
||||
- `blocksToAvoidBreaking`
|
||||
|
||||
|
||||
|
||||
|
||||
# Troubleshooting / common issues
|
||||
|
||||
## Why doesn't Baritone respond to any of my chat commands?
|
||||
This could be one of many things.
|
||||
|
||||
First, make sure it's actually installed. An easy way to check is seeing if it created the folder `baritone` in your Minecraft folder.
|
||||
|
||||
Second, make sure that you're using the prefix properly, and that chat control is enabled in the way you expect.
|
||||
|
||||
For example, Impact disables direct chat control. (i.e. anything typed in chat without a prefix will be ignored and sent publicly). **This is a saved setting**, so if you run Impact once, `chatControl` will be off from then on, **even in other clients**.
|
||||
So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Minecraft folder to undo that (specifically, remove the line `chatControl false` then restart your client).
|
||||
|
||||
|
||||
## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?
|
||||
These are custom commands that they added; those aren't from Baritone.
|
||||
The equivalent you're looking for is `goal x z` then `path`.
|
||||
326
build.gradle
326
build.gradle
@@ -1,131 +1,195 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.1.2'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'SpongePowered'
|
||||
url = 'http://repo.spongepowered.org/maven'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = '1.12.2'
|
||||
mappings = 'stable_39'
|
||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||
runDir = 'run'
|
||||
|
||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||
makeObfSourceJar = true
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv 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'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.4.2'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
|
||||
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
|
||||
}
|
||||
}
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += api.output
|
||||
}
|
||||
test {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
task sourceJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.api.allSource
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20190814-1.14.3'
|
||||
reobfMappings 'notch'
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
source sourceSets.launch
|
||||
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
}
|
||||
}
|
||||
|
||||
autoTest {
|
||||
workingDirectory project.file('autotest')
|
||||
source sourceSets.launch
|
||||
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
environment 'BARITONE_AUTO_TEST', 'true'
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.14.4'
|
||||
|
||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
}
|
||||
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv searge
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
|
||||
options.linkSource true
|
||||
options.encoding "UTF-8" // allow emoji in comments :^)
|
||||
source = sourceSets.api.allJava
|
||||
classpath += sourceSets.api.compileClasspath
|
||||
}
|
||||
|
||||
jar {
|
||||
from sourceSets.launch.output, sourceSets.api.output
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.gradle.task;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.gradle.api.DefaultTask;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,7 +24,6 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -34,8 +31,6 @@ import java.util.List;
|
||||
*/
|
||||
class BaritoneGradleTask extends DefaultTask {
|
||||
|
||||
protected static final JsonParser PARSER = new JsonParser();
|
||||
|
||||
protected static final String
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
@@ -45,28 +40,22 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
|
||||
VERSION_MANIFEST = "version_manifest.json",
|
||||
|
||||
TEMP_LIBRARY_DIR = "tempLibraries/",
|
||||
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||
ARTIFACT_FORGE = "%s-forge-%s.jar";
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgePath, proguardOut;
|
||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, 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.artifactForgePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE));
|
||||
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.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||
|
||||
@@ -97,8 +86,4 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
protected Path getBuildFile(String file) {
|
||||
return getRelativeFile("build/libs/" + file);
|
||||
}
|
||||
|
||||
protected JsonElement readJson(List<String> lines) {
|
||||
return PARSER.parse(String.join("\n", lines));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,9 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
super.verifyArtifacts();
|
||||
|
||||
// Define the distribution file paths
|
||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
Path forge = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE));
|
||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
|
||||
// NIO will not automatically create directories
|
||||
Path dir = getRelativeFile("dist/");
|
||||
@@ -54,13 +53,12 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
}
|
||||
|
||||
// Copy build jars to dist/
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactForgePath, forge, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
|
||||
// Calculate all checksums and format them like "shasum"
|
||||
List<String> shasum = Stream.of(api, standalone, unoptimized, forge)
|
||||
List<String> shasum = Stream.of(api, standalone, unoptimized)
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -18,26 +18,18 @@
|
||||
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.plugins.JavaPluginConvention;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -49,18 +41,12 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
*/
|
||||
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();
|
||||
@@ -70,10 +56,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
downloadProguard();
|
||||
extractProguard();
|
||||
generateConfigs();
|
||||
acquireDependencies();
|
||||
proguardApi();
|
||||
proguardStandalone();
|
||||
createForge();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
@@ -82,7 +66,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Files.delete(this.artifactUnoptimizedPath);
|
||||
}
|
||||
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
|
||||
}
|
||||
|
||||
private void downloadProguard() throws Exception {
|
||||
@@ -115,6 +99,19 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
||||
template.add(2, "-libraryjars '" + out + "'");
|
||||
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
acquireDependencies().forEach(f -> {
|
||||
if (f.toString().endsWith("-recomp.jar")) {
|
||||
// remove MCP mapped jar
|
||||
return;
|
||||
}
|
||||
if (f.toString().endsWith("client-extra.jar")) {
|
||||
// go from the extra to the original downloaded client
|
||||
f = new File(f.getParentFile(), "client.jar");
|
||||
}
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||
|
||||
@@ -122,167 +119,20 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
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 Stream<File> acquireDependencies() {
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles().stream().filter(File::isFile);
|
||||
}
|
||||
|
||||
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.artifactApiPath.toString());
|
||||
}
|
||||
|
||||
private void proguardStandalone() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Optional.empty());
|
||||
}
|
||||
|
||||
private void createForge() throws Exception {
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgePath.toString(), Optional.of(mixin));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
|
||||
@@ -22,7 +22,10 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@@ -36,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class Determinizer {
|
||||
|
||||
public static void determinize(String inputPath, String outputPath, Optional<File> toInclude) throws IOException {
|
||||
public static void determinize(String inputPath, String outputPath) throws IOException {
|
||||
System.out.println("Running Determinizer");
|
||||
System.out.println(" Input path: " + inputPath);
|
||||
System.out.println(" Output path: " + outputPath);
|
||||
@@ -63,30 +66,10 @@ public class Determinizer {
|
||||
if (entry.getName().endsWith(".refmap.json")) {
|
||||
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
||||
jos.write(writeSorted(object).getBytes());
|
||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && toInclude.isPresent()) { // only replace for forge jar
|
||||
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
|
||||
copy(jarFile.getInputStream(entry), cancer);
|
||||
String manifest = new String(cancer.toByteArray());
|
||||
if (!manifest.contains("baritone.launch.BaritoneTweaker")) {
|
||||
throw new IllegalStateException("unable to replace");
|
||||
}
|
||||
manifest = manifest.replace("baritone.launch.BaritoneTweaker", "org.spongepowered.asm.launch.MixinTweaker");
|
||||
jos.write(manifest.getBytes());
|
||||
} else {
|
||||
copy(jarFile.getInputStream(entry), jos);
|
||||
}
|
||||
}
|
||||
if (toInclude.isPresent()) {
|
||||
try (JarFile mixin = new JarFile(toInclude.get())) {
|
||||
for (JarEntry entry : mixin.stream().sorted(Comparator.comparing(JarEntry::getName)).collect(Collectors.toList())) {
|
||||
if (entry.getName().startsWith("META-INF") && !entry.getName().startsWith("META-INF/services")) {
|
||||
continue;
|
||||
}
|
||||
jos.putNextEntry(entry);
|
||||
copy(mixin.getInputStream(entry), jos);
|
||||
}
|
||||
}
|
||||
}
|
||||
jos.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +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.gradle.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* All credits go to AsmLibGradle and its contributors.
|
||||
*
|
||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/ReobfWrapper.java">Original Source</a>
|
||||
*/
|
||||
public class ReobfWrapper {
|
||||
|
||||
private final Object instance;
|
||||
private final Class<?> type;
|
||||
|
||||
public ReobfWrapper(Object instance) {
|
||||
this.instance = instance;
|
||||
Objects.requireNonNull(instance);
|
||||
this.type = instance.getClass();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
try {
|
||||
Field nameField = type.getDeclaredField("name");
|
||||
nameField.setAccessible(true);
|
||||
return (String) nameField.get(this.instance);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public MappingType getMappingType() {
|
||||
try {
|
||||
Field enumField = type.getDeclaredField("mappingType");
|
||||
enumField.setAccessible(true);
|
||||
Enum<?> aEnum = (Enum<?>) enumField.get(this.instance);
|
||||
MappingType mappingType = MappingType.values()[aEnum.ordinal()];
|
||||
if (!aEnum.name().equals(mappingType.name())) {
|
||||
throw new IllegalStateException("ForgeGradle ReobfMappingType is not equivalent to MappingType (version error?)");
|
||||
}
|
||||
return mappingType;
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
gradle/wrapper/gradle-wrapper.properties
vendored
12
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Tue Jul 31 21:56:56 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
#Tue Jul 31 21:56:56 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
|
||||
168
gradlew.bat
vendored
168
gradlew.bat
vendored
@@ -1,84 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
59
scripts/proguard.pro
vendored
59
scripts/proguard.pro
vendored
@@ -13,7 +13,9 @@
|
||||
-repackageclasses 'baritone'
|
||||
|
||||
# lwjgl is weird
|
||||
-dontwarn org.lwjgl.opengl.GL14
|
||||
-dontwarn org.lwjgl.**
|
||||
# also lwjgl lol
|
||||
-dontwarn module-info
|
||||
|
||||
-keep class baritone.api.** { *; } # this is the keep api
|
||||
|
||||
@@ -21,8 +23,7 @@
|
||||
-keep class baritone.BaritoneProvider
|
||||
-keep class baritone.api.IBaritoneProvider
|
||||
|
||||
# hack
|
||||
-keep class baritone.utils.ExampleBaritoneControl { *; } # have to include this string to remove this keep in the standalone build: # this is the keep api
|
||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||
|
||||
# setting names are reflected from field names, so keep field names
|
||||
-keepclassmembers class baritone.api.Settings {
|
||||
@@ -32,54 +33,10 @@
|
||||
# need to keep mixin names
|
||||
-keep class baritone.launch.** { *; }
|
||||
|
||||
# copy all necessary libraries into tempLibraries to build
|
||||
|
||||
# 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'
|
||||
-libraryjars 'tempLibraries/codecwav-20101023.jar'
|
||||
-libraryjars 'tempLibraries/commons-codec-1.10.jar'
|
||||
-libraryjars 'tempLibraries/commons-compress-1.8.1.jar'
|
||||
-libraryjars 'tempLibraries/commons-io-2.5.jar'
|
||||
-libraryjars 'tempLibraries/commons-lang3-3.5.jar'
|
||||
-libraryjars 'tempLibraries/commons-logging-1.1.3.jar'
|
||||
-libraryjars 'tempLibraries/fastutil-7.1.0.jar'
|
||||
-libraryjars 'tempLibraries/gson-2.8.0.jar'
|
||||
-libraryjars 'tempLibraries/guava-21.0.jar'
|
||||
-libraryjars 'tempLibraries/httpclient-4.3.3.jar'
|
||||
-libraryjars 'tempLibraries/httpcore-4.3.2.jar'
|
||||
-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar'
|
||||
-libraryjars 'tempLibraries/jinput-2.0.5.jar'
|
||||
-libraryjars 'tempLibraries/jna-4.4.0.jar'
|
||||
-libraryjars 'tempLibraries/jopt-simple-5.0.3.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'
|
||||
|
||||
# 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'
|
||||
-libraryjars 'tempLibraries/platform-3.4.0.jar'
|
||||
-libraryjars 'tempLibraries/realms-1.10.22.jar'
|
||||
-libraryjars 'tempLibraries/soundsystem-20120107.jar'
|
||||
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
||||
|
||||
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
||||
-libraryjars 'tempLibraries/launchwrapper-1.11.jar' # TODO why does only 1.11.jar exist?
|
||||
|
||||
|
||||
#try to keep usage of schematica in separate classes
|
||||
-keep class baritone.utils.schematic.schematica.**
|
||||
#proguard doesnt like it when it cant find our fake schematica classes
|
||||
-dontwarn baritone.utils.schematic.schematica.**
|
||||
|
||||
|
||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
|
||||
@@ -23,9 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* API exposure for various things implemented in Baritone.
|
||||
* <p>
|
||||
* W.I.P
|
||||
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
@@ -36,12 +34,12 @@ public final class BaritoneAPI {
|
||||
private static final Settings settings;
|
||||
|
||||
static {
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings);
|
||||
|
||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||
provider = instances.next();
|
||||
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings);
|
||||
}
|
||||
|
||||
public static IBaritoneProvider getProvider() {
|
||||
|
||||
@@ -22,12 +22,11 @@ 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.process.*;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -36,10 +35,10 @@ import baritone.api.utils.IPlayerContext;
|
||||
public interface IBaritone {
|
||||
|
||||
/**
|
||||
* @return The {@link IFollowProcess} instance
|
||||
* @see IFollowProcess
|
||||
* @return The {@link IPathingBehavior} instance
|
||||
* @see IPathingBehavior
|
||||
*/
|
||||
IFollowProcess getFollowProcess();
|
||||
IPathingBehavior getPathingBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link ILookBehavior} instance
|
||||
@@ -47,6 +46,12 @@ public interface IBaritone {
|
||||
*/
|
||||
ILookBehavior getLookBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IFollowProcess} instance
|
||||
* @see IFollowProcess
|
||||
*/
|
||||
IFollowProcess getFollowProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IMineProcess} instance
|
||||
* @see IMineProcess
|
||||
@@ -54,10 +59,34 @@ public interface IBaritone {
|
||||
IMineProcess getMineProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IPathingBehavior} instance
|
||||
* @see IPathingBehavior
|
||||
* @return The {@link IBuilderProcess} instance
|
||||
* @see IBuilderProcess
|
||||
*/
|
||||
IPathingBehavior getPathingBehavior();
|
||||
IBuilderProcess getBuilderProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IExploreProcess} instance
|
||||
* @see IExploreProcess
|
||||
*/
|
||||
IExploreProcess getExploreProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IFarmProcess} instance
|
||||
* @see IFarmProcess
|
||||
*/
|
||||
IFarmProcess getFarmProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link ICustomGoalProcess} instance
|
||||
* @see ICustomGoalProcess
|
||||
*/
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IGetToBlockProcess} instance
|
||||
* @see IGetToBlockProcess
|
||||
*/
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IWorldProvider} instance
|
||||
@@ -65,15 +94,47 @@ public interface IBaritone {
|
||||
*/
|
||||
IWorldProvider getWorldProvider();
|
||||
|
||||
/**
|
||||
* Returns the {@link IPathingControlManager} for this {@link IBaritone} instance, which is responsible
|
||||
* for managing the {@link IBaritoneProcess}es which control the {@link IPathingBehavior} state.
|
||||
*
|
||||
* @return The {@link IPathingControlManager} instance
|
||||
* @see IPathingControlManager
|
||||
*/
|
||||
IPathingControlManager getPathingControlManager();
|
||||
|
||||
/**
|
||||
* @return The {@link IInputOverrideHandler} instance
|
||||
* @see IInputOverrideHandler
|
||||
*/
|
||||
IInputOverrideHandler getInputOverrideHandler();
|
||||
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
||||
IGetToBlockProcess getGetToBlockProcess();
|
||||
|
||||
/**
|
||||
* @return The {@link IPlayerContext} instance
|
||||
* @see IPlayerContext
|
||||
*/
|
||||
IPlayerContext getPlayerContext();
|
||||
|
||||
/**
|
||||
* @return The {@link IEventBus} instance
|
||||
* @see IEventBus
|
||||
*/
|
||||
IEventBus getGameEventHandler();
|
||||
|
||||
/**
|
||||
* @return The {@link ISelectionManager} instance
|
||||
* @see ISelectionManager
|
||||
*/
|
||||
ISelectionManager getSelectionManager();
|
||||
|
||||
/**
|
||||
* @return The {@link ICommandManager} instance
|
||||
* @see ICommandManager
|
||||
*/
|
||||
ICommandManager getCommandManager();
|
||||
|
||||
/**
|
||||
* Open click
|
||||
*/
|
||||
void openClick();
|
||||
}
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Leijurv
|
||||
* Provides the present {@link IBaritone} instances, as well as non-baritone instance related APIs.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public interface IBaritoneProvider {
|
||||
|
||||
@@ -41,24 +46,25 @@ public interface IBaritoneProvider {
|
||||
* returned by {@link #getPrimaryBaritone()}.
|
||||
*
|
||||
* @return All active {@link IBaritone} instances.
|
||||
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
||||
* @see #getBaritoneForPlayer(ClientPlayerEntity)
|
||||
*/
|
||||
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.
|
||||
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}. This will likely be
|
||||
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
||||
* {@code bot-system} is merged into {@code master}.
|
||||
*
|
||||
* @param player The player
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
|
||||
for (IBaritone baritone : getAllBaritones()) {
|
||||
if (player.equals(baritone.getPlayerContext().player())) {
|
||||
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No baritone for player " + player);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,4 +74,12 @@ public interface IBaritoneProvider {
|
||||
* @return The {@link IWorldScanner} instance.
|
||||
*/
|
||||
IWorldScanner getWorldScanner();
|
||||
|
||||
/**
|
||||
* Returns the {@link ICommandSystem} instance. This is not bound to a specific {@link IBaritone}
|
||||
* instance because {@link ICommandSystem} itself controls global behavior for {@link ICommand}s.
|
||||
*
|
||||
* @return The {@link ICommandSystem} instance.
|
||||
*/
|
||||
ICommandSystem getCommandSystem();
|
||||
}
|
||||
|
||||
@@ -17,19 +17,25 @@
|
||||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.TypeUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Baritone's settings
|
||||
* Baritone's settings. Settings apply to all Baritone instances.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
@@ -57,7 +63,9 @@ public final class Settings {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* because we want to generally conserve blocks which might be limited.
|
||||
* <p>
|
||||
* Decrease to make Baritone more often consider paths that would require placing blocks
|
||||
*/
|
||||
public final Setting<Double> blockPlacementPenalty = new Setting<>(20D);
|
||||
|
||||
@@ -76,7 +84,7 @@ public final class Settings {
|
||||
/**
|
||||
* Walking on water uses up hunger really quick, so penalize it
|
||||
*/
|
||||
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(5D);
|
||||
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(3D);
|
||||
|
||||
/**
|
||||
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
|
||||
@@ -90,6 +98,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* If you have Fire Resistance and Jesus then I guess you could turn this on lol
|
||||
*/
|
||||
public final Setting<Boolean> assumeWalkOnLava = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Assume step functionality; don't jump on an Ascend.
|
||||
*/
|
||||
@@ -107,10 +120,17 @@ public final class Settings {
|
||||
/**
|
||||
* 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
|
||||
* Defaults to false because this fails on constantiam. Please let me know if this is ever disabled. Please.
|
||||
*/
|
||||
public final Setting<Boolean> allowJumpAt256 = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* This should be monetized it's so good
|
||||
* <p>
|
||||
* Defaults to true, but only actually takes effect if allowParkour is also true
|
||||
*/
|
||||
public final Setting<Boolean> allowParkourAscend = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow descending diagonally
|
||||
* <p>
|
||||
@@ -120,20 +140,59 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> allowDiagonalDescend = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow diagonal ascending
|
||||
* <p>
|
||||
* Actually pretty safe, much safer than diagonal descend tbh
|
||||
*/
|
||||
public final Setting<Boolean> allowDiagonalAscend = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow mining the block directly beneath its feet
|
||||
* <p>
|
||||
* Turn this off to force it to make more staircases and less shafts
|
||||
*/
|
||||
public final Setting<Boolean> allowDownward = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
||||
*/
|
||||
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
Item.getItemFromBlock(Blocks.DIRT),
|
||||
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
||||
Item.getItemFromBlock(Blocks.NETHERRACK)
|
||||
Blocks.DIRT.asItem(),
|
||||
Blocks.COBBLESTONE.asItem(),
|
||||
Blocks.NETHERRACK.asItem(),
|
||||
Blocks.STONE.asItem()
|
||||
)));
|
||||
|
||||
/**
|
||||
* Blocks that Baritone will attempt to avoid (Used in avoidance)
|
||||
*/
|
||||
public final Setting<List<Block>> blocksToAvoid = new Setting<>(new ArrayList<>(
|
||||
// Leave Empty by Default
|
||||
));
|
||||
|
||||
/**
|
||||
* Blocks that Baritone is not allowed to break
|
||||
*/
|
||||
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
|
||||
Blocks.CRAFTING_TABLE,
|
||||
Blocks.FURNACE,
|
||||
Blocks.CHEST,
|
||||
Blocks.TRAPPED_CHEST
|
||||
)));
|
||||
|
||||
/**
|
||||
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
||||
* <p>
|
||||
* I.E. it will never trigger cascading sand / gravel falls
|
||||
*/
|
||||
public final Setting<Boolean> avoidUpdatingFallingBlocks = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Almost never turn this on lol
|
||||
*/
|
||||
public final Setting<Boolean> allowVines = new Setting<>(false);
|
||||
|
||||
@@ -164,6 +223,38 @@ public final class Settings {
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* If we overshoot a traverse and end up one block beyond the destination, mark it as successful anyway.
|
||||
* <p>
|
||||
* This helps with speed at >=20m/s
|
||||
*/
|
||||
public final Setting<Boolean> overshootTraverse = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When breaking blocks for a movement, wait until all falling blocks have settled before continuing
|
||||
*/
|
||||
public final Setting<Boolean> pauseMiningForFallingBlocks = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* How many ticks between right clicks are allowed. Default in game is 4
|
||||
*/
|
||||
public final Setting<Integer> rightClickSpeed = new Setting<>(4);
|
||||
|
||||
/**
|
||||
* How many degrees to randomize the yaw every tick. Set to 0 to disable
|
||||
*/
|
||||
public final Setting<Double> randomLooking113 = new Setting<>(2d);
|
||||
|
||||
/**
|
||||
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
|
||||
*/
|
||||
public final Setting<Double> randomLooking = new Setting<>(0.01d);
|
||||
|
||||
/**
|
||||
* This is the big A* setting.
|
||||
* As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path.
|
||||
@@ -277,7 +368,7 @@ public final class Settings {
|
||||
/**
|
||||
* Start planning the next path once the remaining movements tick estimates sum up to less than this value
|
||||
*/
|
||||
public final Setting<Integer> planningTickLookAhead = new Setting<>(150);
|
||||
public final Setting<Integer> planningTickLookahead = new Setting<>(150);
|
||||
|
||||
/**
|
||||
* Default size of the Long2ObjectOpenHashMap used in pathing
|
||||
@@ -308,6 +399,8 @@ public final class Settings {
|
||||
* 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 final Setting<Boolean> allowOvershootDiagonalDescend = new Setting<>(true);
|
||||
|
||||
@@ -373,15 +466,29 @@ public final class Settings {
|
||||
* On save, delete from RAM any cached regions that are more than 1024 blocks away from the player
|
||||
* <p>
|
||||
* Temporarily disabled
|
||||
* <p>
|
||||
* Temporarily reenabled
|
||||
*
|
||||
* @see <a href="https://github.com/cabaletta/baritone/issues/248">Issue #248</a>
|
||||
*/
|
||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(false);
|
||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Fill in blocks behind you
|
||||
*/
|
||||
public final Setting<Boolean> backfill = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Print all the debug messages to chat
|
||||
*/
|
||||
public final 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
|
||||
@@ -390,20 +497,30 @@ public final class Settings {
|
||||
public final Setting<Boolean> chatControl = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* A second override over chatControl to force it on
|
||||
* Some clients like Impact try to force chatControl to off, so here's a second setting to do it anyway
|
||||
*/
|
||||
public final Setting<Boolean> removePrefix = new Setting<>(false);
|
||||
public final Setting<Boolean> chatControlAnyway = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Render the path
|
||||
*/
|
||||
public final Setting<Boolean> renderPath = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render the path as a line instead of a frickin thingy
|
||||
*/
|
||||
public final Setting<Boolean> renderPathAsLine = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Render the goal
|
||||
*/
|
||||
public final Setting<Boolean> renderGoal = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render selection boxes
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionBoxes = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Ignore depth when rendering the goal
|
||||
*/
|
||||
@@ -456,11 +573,26 @@ public final class Settings {
|
||||
|
||||
/**
|
||||
* Exclusively use cached chunks for pathing
|
||||
* <p>
|
||||
* Never turn this on
|
||||
*/
|
||||
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* 😎 Render cached chunks as semitransparent.
|
||||
* Continue sprinting while in water
|
||||
*/
|
||||
public final Setting<Boolean> sprintInWater = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
|
||||
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not.
|
||||
* This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break)
|
||||
* Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
|
||||
*/
|
||||
public final Setting<Boolean> blacklistClosestOnFailure = 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
|
||||
@@ -470,29 +602,65 @@ public final class Settings {
|
||||
* <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);
|
||||
public final Setting<Boolean> renderCachedChunks = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* 0.0f = not visible, fully transparent
|
||||
* 0.0f = not visible, fully transparent (instead of setting this to 0, turn off renderCachedChunks)
|
||||
* 1.0f = fully opaque
|
||||
*/
|
||||
public Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
|
||||
public final 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
|
||||
* Whether or not to allow you to run Baritone commands with the prefix
|
||||
*/
|
||||
public final Setting<Boolean> prefixControl = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The command prefix for chat control
|
||||
*/
|
||||
public final Setting<String> prefix = new Setting<>("#");
|
||||
|
||||
/**
|
||||
* Use a short Baritone prefix [B] instead of [Baritone] when logging to chat
|
||||
*/
|
||||
public final Setting<Boolean> shortBaritonePrefix = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Echo commands to chat when they are run
|
||||
*/
|
||||
public final Setting<Boolean> echoCommands = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Censor coordinates in goals and block positions
|
||||
*/
|
||||
public final Setting<Boolean> censorCoordinates = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Censor arguments to ran commands, to hide, for example, coordinates to #goal
|
||||
*/
|
||||
public final Setting<Boolean> censorRanCommands = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk
|
||||
* touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
|
||||
*/
|
||||
public final Setting<Boolean> preferSilkTouch = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Don't stop walking forward when you need to break blocks in your way
|
||||
*/
|
||||
public final Setting<Boolean> walkWhileBreaking = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When a new segment is calculated that doesn't overlap with the current one, but simply begins where the current segment ends,
|
||||
* splice it on and make a longer combined path. If this setting is off, any planned segment will not be spliced and will instead
|
||||
* be the "next path" in PathingBehavior, and will only start after this one ends. Turning this off hurts planning ahead,
|
||||
* because the next segment will exist even if it's very short.
|
||||
*
|
||||
* @see #planningTickLookahead
|
||||
*/
|
||||
public final Setting<Boolean> splicePath = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* If we are more than 300 movements into the current path, discard the oldest segments, as they are no longer useful
|
||||
*/
|
||||
@@ -509,16 +677,142 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* After finding this many instances of the target block in the cache, it will stop expanding outward the chunk search.
|
||||
*/
|
||||
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
|
||||
|
||||
/**
|
||||
* 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 exploring the world, offset the closest unloaded chunk by this much in both axes.
|
||||
* <p>
|
||||
* This can result in more efficient loading, if you set this to the render distance.
|
||||
*/
|
||||
public final Setting<Integer> worldExploringChunkOffset = new Setting<>(0);
|
||||
|
||||
/**
|
||||
* Take the 10 closest chunks, even if they aren't strictly tied for distance metric from origin.
|
||||
*/
|
||||
public final Setting<Integer> exploreChunkSetMinimumSize = new Setting<>(10);
|
||||
|
||||
/**
|
||||
* Attempt to maintain Y coordinate while exploring
|
||||
* <p>
|
||||
* -1 to disable
|
||||
*/
|
||||
public final Setting<Integer> exploreMaintainY = new Setting<>(64);
|
||||
|
||||
/**
|
||||
* Replant normal Crops while farming and leave cactus and sugarcane to regrow
|
||||
*/
|
||||
public final Setting<Boolean> replantCrops = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Replant nether wart while farming. This setting only has an effect when replantCrops is also enabled
|
||||
*/
|
||||
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When the cache scan gives less blocks than the maximum threshold (but still above zero), scan the main world too.
|
||||
* <p>
|
||||
* Only if you have a beefy CPU and automatically mine blocks that are in cache
|
||||
*/
|
||||
public final Setting<Boolean> extendCacheOnThreshold = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Don't consider the next layer in builder until the current one is done
|
||||
*/
|
||||
public final Setting<Boolean> buildInLayers = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* false = build from bottom to top
|
||||
* <p>
|
||||
* true = build from top to bottom
|
||||
*/
|
||||
public final Setting<Boolean> layerOrder = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
|
||||
*/
|
||||
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
|
||||
|
||||
/**
|
||||
* Allow standing above a block while mining it, in BuilderProcess
|
||||
* <p>
|
||||
* Experimental
|
||||
*/
|
||||
public final Setting<Boolean> breakFromAbove = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* As well as breaking from above, set a goal to up and to the side of all blocks to break.
|
||||
* <p>
|
||||
* Never turn this on without also turning on breakFromAbove.
|
||||
*/
|
||||
public final Setting<Boolean> goalBreakFromAbove = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Build in map art mode, which makes baritone only care about the top block in each column
|
||||
*/
|
||||
public final Setting<Boolean> mapArtMode = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Override builder's behavior to not attempt to correct blocks that are currently water
|
||||
*/
|
||||
public final Setting<Boolean> okIfWater = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* The set of incorrect blocks can never grow beyond this size
|
||||
*/
|
||||
public final Setting<Integer> incorrectSize = new Setting<>(100);
|
||||
|
||||
/**
|
||||
* Multiply the cost of breaking a block that's correct in the builder's schematic by this coefficient
|
||||
*/
|
||||
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
|
||||
|
||||
/**
|
||||
* When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
|
||||
*/
|
||||
public final Setting<Boolean> schematicOrientationX = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When this setting is true, build a schematic with the highest Y coordinate being the origin, instead of the lowest
|
||||
*/
|
||||
public final Setting<Boolean> schematicOrientationY = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When this setting is true, build a schematic with the highest Z coordinate being the origin, instead of the lowest
|
||||
*/
|
||||
public final Setting<Boolean> schematicOrientationZ = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Distance to scan every tick for updates. Expanding this beyond player reach distance (i.e. setting it to 6 or above)
|
||||
* is only necessary in very large schematics where rescanning the whole thing is costly.
|
||||
*/
|
||||
public final Setting<Integer> builderTickScanRadius = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* While mining, wait this number of milliseconds after mining an ore to see if it will drop an item
|
||||
* instead of immediately going onto the next one
|
||||
* <p>
|
||||
* Thanks Louca
|
||||
*/
|
||||
public final Setting<Long> mineDropLoiterDurationMSThanksLouca = new Setting<>(250L);
|
||||
|
||||
/**
|
||||
* Trim incorrect positions too far away, helps performance but hurts reliability in very large schematics
|
||||
*/
|
||||
public final Setting<Boolean> distanceTrim = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
|
||||
* <p>
|
||||
@@ -539,6 +833,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> axisHeight = new Setting<>(120);
|
||||
|
||||
/**
|
||||
* Disconnect from the server upon arriving at your goal
|
||||
*/
|
||||
public final Setting<Boolean> disconnectOnArrival = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -551,6 +850,19 @@ public final class Settings {
|
||||
*/
|
||||
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
|
||||
@@ -581,6 +893,12 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> followRadius = new Setting<>(3);
|
||||
|
||||
/**
|
||||
* Turn this on if your exploration filter is enormous, you don't want it to check if it's done,
|
||||
* and you are just fine with it just hanging on completion
|
||||
*/
|
||||
public final Setting<Boolean> disableCompletionCheck = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -608,7 +926,12 @@ public final class Settings {
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
||||
|
||||
/**
|
||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||
*/
|
||||
public final Setting<Double> yLevelBoxSize = new Setting<>(15D);
|
||||
|
||||
/**
|
||||
* The color of the current path
|
||||
@@ -650,6 +973,51 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Color> colorGoalBox = new Setting<>(Color.GREEN);
|
||||
|
||||
/**
|
||||
* The color of the goal box when it's inverted
|
||||
*/
|
||||
public final Setting<Color> colorInvertedGoalBox = new Setting<>(Color.RED);
|
||||
|
||||
/**
|
||||
* The color of all selections
|
||||
*/
|
||||
public final Setting<Color> colorSelection = new Setting<>(Color.CYAN);
|
||||
|
||||
/**
|
||||
* The color of the selection pos 1
|
||||
*/
|
||||
public final Setting<Color> colorSelectionPos1 = new Setting<>(Color.BLACK);
|
||||
|
||||
/**
|
||||
* The color of the selection pos 2
|
||||
*/
|
||||
public final Setting<Color> colorSelectionPos2 = new Setting<>(Color.ORANGE);
|
||||
|
||||
/**
|
||||
* The opacity of the selection. 0 is completely transparent, 1 is completely opaque
|
||||
*/
|
||||
public final Setting<Float> selectionOpacity = new Setting<>(.5f);
|
||||
|
||||
/**
|
||||
* Line width of the goal when rendered, in pixels
|
||||
*/
|
||||
public final Setting<Float> selectionLineWidth = new Setting<>(2F);
|
||||
|
||||
/**
|
||||
* Render selections
|
||||
*/
|
||||
public final Setting<Boolean> renderSelection = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Ignore depth when rendering selections
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionIgnoreDepth = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render selection corners
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
||||
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
@@ -661,17 +1029,13 @@ public final class Settings {
|
||||
*/
|
||||
public final List<Setting<?>> allSettings;
|
||||
|
||||
public void reset() {
|
||||
for (Setting setting : allSettings) {
|
||||
setting.value = setting.defaultValue;
|
||||
}
|
||||
}
|
||||
public final Map<Setting<?>, Type> settingTypes;
|
||||
|
||||
public final class Setting<T> {
|
||||
|
||||
public class Setting<T> {
|
||||
public T value;
|
||||
public final T defaultValue;
|
||||
private String name;
|
||||
private final Class<T> klass;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Setting(T value) {
|
||||
@@ -680,12 +1044,16 @@ public final class Settings {
|
||||
}
|
||||
this.value = value;
|
||||
this.defaultValue = value;
|
||||
this.klass = (Class<T>) value.getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <K extends T> K get() {
|
||||
return (K) value;
|
||||
/**
|
||||
* Deprecated! Please use .value directly instead
|
||||
*
|
||||
* @return the current setting value
|
||||
*/
|
||||
@Deprecated
|
||||
public final T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
@@ -693,11 +1061,24 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public Class<T> getValueClass() {
|
||||
return klass;
|
||||
// noinspection unchecked
|
||||
return (Class<T>) TypeUtils.resolveBaseClass(getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + ": " + value;
|
||||
return SettingsUtil.settingToString(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset this setting to its default value
|
||||
*/
|
||||
public void reset() {
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return settingTypes.get(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,8 +1086,11 @@ public final class Settings {
|
||||
|
||||
Settings() {
|
||||
Field[] temp = getClass().getFields();
|
||||
HashMap<String, Setting<?>> tmpByName = new HashMap<>();
|
||||
|
||||
Map<String, Setting<?>> tmpByName = new HashMap<>();
|
||||
List<Setting<?>> tmpAll = new ArrayList<>();
|
||||
Map<Setting<?>, Type> tmpSettingTypes = new HashMap<>();
|
||||
|
||||
try {
|
||||
for (Field field : temp) {
|
||||
if (field.getType().equals(Setting.class)) {
|
||||
@@ -719,6 +1103,7 @@ public final class Settings {
|
||||
}
|
||||
tmpByName.put(name, setting);
|
||||
tmpAll.add(setting);
|
||||
tmpSettingTypes.put(setting, ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]);
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -726,13 +1111,14 @@ public final class Settings {
|
||||
}
|
||||
byLowerName = Collections.unmodifiableMap(tmpByName);
|
||||
allSettings = Collections.unmodifiableList(tmpAll);
|
||||
settingTypes = Collections.unmodifiableMap(tmpSettingTypes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<Setting<T>> getAllValuesByType(Class<T> klass) {
|
||||
public <T> List<Setting<T>> getAllValuesByType(Class<T> cla$$) {
|
||||
List<Setting<T>> result = new ArrayList<>();
|
||||
for (Setting<?> setting : allSettings) {
|
||||
if (setting.getValueClass().equals(klass)) {
|
||||
if (setting.getValueClass().equals(cla$$)) {
|
||||
result.add((Setting<T>) setting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,13 @@
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.event.listener.IGameEventListener;
|
||||
|
||||
/**
|
||||
* A behavior is simply a type that is able to listen to events.
|
||||
*
|
||||
* @author Brady
|
||||
* @see IGameEventListener
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IBehavior extends AbstractGameEventListener {}
|
||||
|
||||
@@ -64,9 +64,17 @@ public interface IPathingBehavior extends IBehavior {
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* @return Whether or not a path is currently being executed.
|
||||
* @return Whether or not a path is currently being executed. This will be false if there's currently a pause.
|
||||
* @see #hasPath()
|
||||
*/
|
||||
default boolean isPathing() {
|
||||
boolean isPathing();
|
||||
|
||||
/**
|
||||
* @return If there is a current path. Note that the path is not necessarily being executed, for example when there
|
||||
* is a pause in effect.
|
||||
* @see #isPathing()
|
||||
*/
|
||||
default boolean hasPath() {
|
||||
return getCurrent() != null;
|
||||
}
|
||||
|
||||
@@ -80,6 +88,13 @@ public interface IPathingBehavior extends IBehavior {
|
||||
*/
|
||||
boolean cancelEverything();
|
||||
|
||||
/**
|
||||
* PLEASE never call this
|
||||
* <p>
|
||||
* If cancelEverything was like "kill" this is "sudo kill -9". Or shutting off your computer.
|
||||
*/
|
||||
void forceCancel();
|
||||
|
||||
/**
|
||||
* Returns the current path, from the current path executor, if there is one.
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public interface IBlockTypeAccess {
|
||||
|
||||
IBlockState getBlock(int x, int y, int z);
|
||||
BlockState getBlock(int x, int y, int z);
|
||||
|
||||
default IBlockState getBlock(BlockPos pos) {
|
||||
default BlockState getBlock(BlockPos pos) {
|
||||
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package baritone.api.cache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -68,7 +68,7 @@ public interface ICachedWorld {
|
||||
* @param maxRegionDistanceSq The maximum region distance, squared
|
||||
* @return The locations found that match the special block
|
||||
*/
|
||||
LinkedList<BlockPos> getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq);
|
||||
ArrayList<BlockPos> getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq);
|
||||
|
||||
/**
|
||||
* Reloads all of the cached regions in this world from disk. Anything that is not saved
|
||||
@@ -81,4 +81,6 @@ public interface ICachedWorld {
|
||||
* in a new thread by default.
|
||||
*/
|
||||
void save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
51
src/api/java/baritone/api/cache/IWaypoint.java
vendored
51
src/api/java/baritone/api/cache/IWaypoint.java
vendored
@@ -17,12 +17,9 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A marker for a position in the world.
|
||||
@@ -60,7 +57,7 @@ public interface IWaypoint {
|
||||
*
|
||||
* @return The block position of this waypoint
|
||||
*/
|
||||
BlockPos getLocation();
|
||||
BetterBlockPos getLocation();
|
||||
|
||||
enum Tag {
|
||||
|
||||
@@ -92,20 +89,48 @@ public interface IWaypoint {
|
||||
/**
|
||||
* The names for the tag, anything that the tag can be referred to as.
|
||||
*/
|
||||
private final String[] names;
|
||||
public final String[] names;
|
||||
|
||||
Tag(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a tag from one of the names that could be used to identify said tag.
|
||||
*
|
||||
* @param name The name of the tag
|
||||
* @return The tag, if one is found, otherwise, {@code null}
|
||||
* @return A name that can be passed to {@link #getByName(String)} to retrieve this tag
|
||||
*/
|
||||
public static Tag fromString(String name) {
|
||||
return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null);
|
||||
public String getName() {
|
||||
return names[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a tag by one of its names.
|
||||
*
|
||||
* @param name The name to search for.
|
||||
* @return The tag, if found, or null.
|
||||
*/
|
||||
public static Tag getByName(String name) {
|
||||
for (Tag action : Tag.values()) {
|
||||
for (String alias : action.names) {
|
||||
if (alias.equalsIgnoreCase(name)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All tag names.
|
||||
*/
|
||||
public static String[] getAllNames() {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
for (Tag tag : Tag.values()) {
|
||||
names.addAll(Arrays.asList(tag.names));
|
||||
}
|
||||
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -33,28 +34,53 @@ 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 ctx The {@link IPlayerContext} containing player and world info that the scan is based upon
|
||||
* @param filter 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 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);
|
||||
List<BlockPos> scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius);
|
||||
|
||||
default List<BlockPos> scanChunkRadius(IPlayerContext ctx, List<Block> filter, int max, int yLevelThreshold, int maxSearchRadius) {
|
||||
return scanChunkRadius(ctx, new BlockOptionalMetaLookup(filter.toArray(new Block[0])), max, yLevelThreshold, 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 ctx The {@link IPlayerContext} containing player and world info that the scan is based upon
|
||||
* @param filter 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, BlockOptionalMetaLookup filter, ChunkPos pos, int max, int yLevelThreshold);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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);
|
||||
default List<BlockPos> scanChunk(IPlayerContext ctx, List<Block> blocks, ChunkPos pos, int max, int yLevelThreshold) {
|
||||
return scanChunk(ctx, new BlockOptionalMetaLookup(blocks), pos, max, yLevelThreshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Repacks 40 chunks around the player.
|
||||
*
|
||||
* @param ctx The player context for that player.
|
||||
* @return The number of chunks queued for repacking.
|
||||
*/
|
||||
int repack(IPlayerContext ctx);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.cache;
|
||||
package baritone.api.cache;
|
||||
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -32,9 +31,9 @@ public class Waypoint implements IWaypoint {
|
||||
private final String name;
|
||||
private final Tag tag;
|
||||
private final long creationTimestamp;
|
||||
private final BlockPos location;
|
||||
private final BetterBlockPos location;
|
||||
|
||||
public Waypoint(String name, Tag tag, BlockPos location) {
|
||||
public Waypoint(String name, Tag tag, BetterBlockPos location) {
|
||||
this(name, tag, location, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ public class Waypoint implements IWaypoint {
|
||||
* @param location The waypoint location
|
||||
* @param creationTimestamp When the waypoint was created
|
||||
*/
|
||||
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
||||
public Waypoint(String name, Tag tag, BetterBlockPos location, long creationTimestamp) {
|
||||
this.name = name;
|
||||
this.tag = tag;
|
||||
this.location = location;
|
||||
@@ -56,7 +55,7 @@ public class Waypoint implements IWaypoint {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
|
||||
return name.hashCode() ^ tag.hashCode() ^ location.hashCode() ^ Long.hashCode(creationTimestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,13 +74,18 @@ public class Waypoint implements IWaypoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getLocation() {
|
||||
public BetterBlockPos getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " " + location.toString() + " " + new Date(creationTimestamp).toString();
|
||||
return String.format(
|
||||
"%s %s %s",
|
||||
name,
|
||||
BetterBlockPos.from(location).toString(),
|
||||
new Date(creationTimestamp).toString()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
68
src/api/java/baritone/api/command/Command.java
Normal file
68
src/api/java/baritone/api/command/Command.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A default implementation of {@link ICommand} which provides easy access to the
|
||||
* command's bound {@link IBaritone} instance, {@link IPlayerContext} and an easy
|
||||
* way to provide multiple valid command execution names through the default constructor.
|
||||
* <p>
|
||||
* So basically, you should use it because it provides a small amount of boilerplate,
|
||||
* but you're not forced to use it.
|
||||
*
|
||||
* @see ICommand
|
||||
*
|
||||
* @author LoganDark
|
||||
*/
|
||||
public abstract class Command implements ICommand {
|
||||
|
||||
protected IBaritone baritone;
|
||||
protected IPlayerContext ctx;
|
||||
|
||||
/**
|
||||
* The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
protected final List<String> names;
|
||||
|
||||
/**
|
||||
* Creates a new Baritone control command.
|
||||
*
|
||||
* @param names The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
protected Command(IBaritone baritone, String... names) {
|
||||
this.names = Collections.unmodifiableList(Stream.of(names)
|
||||
.map(s -> s.toLowerCase(Locale.US))
|
||||
.collect(Collectors.toList()));
|
||||
this.baritone = baritone;
|
||||
this.ctx = baritone.getPlayerContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<String> getNames() {
|
||||
return this.names;
|
||||
}
|
||||
}
|
||||
42
src/api/java/baritone/api/command/IBaritoneChatControl.java
Normal file
42
src/api/java/baritone/api/command/IBaritoneChatControl.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import baritone.api.Settings;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/26/2019
|
||||
*/
|
||||
public interface IBaritoneChatControl {
|
||||
|
||||
/**
|
||||
* In certain cases chat components need to execute commands for you. For example, the paginator automatically runs
|
||||
* commands when you click the forward and back arrows to show you the previous/next page.
|
||||
* <p>
|
||||
* If the prefix is changed in the meantime, then the command will go to chat. That's no good. So here's a permanent
|
||||
* prefix that forces a command to run, regardless of the current prefix, chat/prefix control being enabled, etc.
|
||||
* <p>
|
||||
* If used right (by both developers and users), it should be impossible to expose a command accidentally to the
|
||||
* server. As a rule of thumb, if you have a clickable chat component, always use this prefix. If you're suggesting
|
||||
* a command (a component that puts text into your text box, or something else), use {@link Settings#prefix}.
|
||||
*/
|
||||
String FORCE_COMMAND_PREFIX = String.format("<<%s>>", UUID.randomUUID().toString());
|
||||
}
|
||||
67
src/api/java/baritone/api/command/ICommand.java
Normal file
67
src/api/java/baritone/api/command/ICommand.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.command;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.Helper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* The base for a command.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 10/7/2019
|
||||
*/
|
||||
public interface ICommand extends Helper {
|
||||
|
||||
/**
|
||||
* Called when this command is executed.
|
||||
*/
|
||||
void execute(String label, IArgConsumer args) throws CommandException;
|
||||
|
||||
/**
|
||||
* Called when the command needs to tab complete. Return a Stream representing the entries to put in the completions
|
||||
* list.
|
||||
*/
|
||||
Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException;
|
||||
|
||||
/**
|
||||
* @return A <b>single-line</b> string containing a short description of this command's purpose.
|
||||
*/
|
||||
String getShortDesc();
|
||||
|
||||
/**
|
||||
* @return A list of lines that will be printed by the help command when the user wishes to view them.
|
||||
*/
|
||||
List<String> getLongDesc();
|
||||
|
||||
/**
|
||||
* @return A list of the names that can be accepted to have arguments passed to this command
|
||||
*/
|
||||
List<String> getNames();
|
||||
|
||||
/**
|
||||
* @return {@code true} if this command should be hidden from the help menu
|
||||
*/
|
||||
default boolean hiddenFromHelp() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.gradle.util;
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.command.argparser.IArgParserManager;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* @author Brady
|
||||
* @since 10/4/2019
|
||||
*/
|
||||
public enum MappingType {
|
||||
SEARGE,
|
||||
NOTCH,
|
||||
CUSTOM // forgegradle
|
||||
public interface ICommandSystem {
|
||||
|
||||
IArgParserManager getParserManager();
|
||||
}
|
||||
60
src/api/java/baritone/api/command/argparser/IArgParser.java
Normal file
60
src/api/java/baritone/api/command/argparser/IArgParser.java
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.command.argparser;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public interface IArgParser<T> {
|
||||
|
||||
/**
|
||||
* @return the class of this parser.
|
||||
*/
|
||||
Class<T> getTarget();
|
||||
|
||||
/**
|
||||
* A stateless argument parser is just that. It takes a {@link ICommandArgument} and outputs its type.
|
||||
*/
|
||||
interface Stateless<T> extends IArgParser<T> {
|
||||
|
||||
/**
|
||||
* @param arg The argument to parse.
|
||||
* @return What it was parsed into.
|
||||
* @throws RuntimeException if you want the parsing to fail. The exception will be caught and turned into an
|
||||
* appropriate error.
|
||||
*/
|
||||
T parseArg(ICommandArgument arg) throws Exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* A stated argument parser is similar to a stateless one. It also takes a {@link ICommandArgument}, but it also
|
||||
* takes a second argument that can be any type, referred to as the state.
|
||||
*/
|
||||
interface Stated<T, S> extends IArgParser<T> {
|
||||
|
||||
Class<S> getStateType();
|
||||
|
||||
/**
|
||||
* @param arg The argument to parse.
|
||||
* @param state Can be anything.
|
||||
* @return What it was parsed into.
|
||||
* @throws RuntimeException if you want the parsing to fail. The exception will be caught and turned into an
|
||||
* appropriate error.
|
||||
*/
|
||||
T parseArg(ICommandArgument arg, S state) throws Exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.command.argparser;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.registry.Registry;
|
||||
|
||||
/**
|
||||
* Used to retrieve {@link IArgParser} instances from the registry, by their target class.
|
||||
* It can be assumed that a {@link IArgParser} exists for {@link Integer}, {@link Long},
|
||||
* {@link Float}, {@link Double} and {@link Boolean}.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 10/4/2019
|
||||
*/
|
||||
public interface IArgParserManager {
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
<T> IArgParser.Stateless<T> getParserStateless(Class<T> type);
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
<T, S> IArgParser.Stated<T, S> getParserStated(Class<T> type, Class<S> stateKlass);
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T> T parseStateless(Class<T> type, ICommandArgument arg) throws CommandInvalidTypeException;
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stated {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @param state The state to pass to the {@link IArgParser.Stated}.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser.Stated
|
||||
*/
|
||||
<T, S> T parseStated(Class<T> type, Class<S> stateKlass, ICommandArgument arg, S state) throws CommandInvalidTypeException;
|
||||
|
||||
Registry<IArgParser> getRegistry();
|
||||
}
|
||||
594
src/api/java/baritone/api/command/argument/IArgConsumer.java
Normal file
594
src/api/java/baritone/api/command/argument/IArgConsumer.java
Normal file
@@ -0,0 +1,594 @@
|
||||
/*
|
||||
* 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.command.argument;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* The {@link IArgConsumer} is how {@link ICommand}s read the arguments passed to them. This class has many benefits:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Mutability. The whole concept of the {@link IArgConsumer}} is to let you gradually consume arguments in any way
|
||||
* you'd like. You can change your consumption based on earlier arguments, for subcommands for example.</li>
|
||||
* <li>You don't need to keep track of your consumption. The {@link IArgConsumer}} keeps track of the arguments you
|
||||
* consume so that it can throw detailed exceptions whenever something is out of the ordinary. Additionally, if you
|
||||
* need to retrieve an argument after you've already consumed it - look no further than {@link #consumed()}!</li>
|
||||
* <li>Easy retrieval of many different types. If you need to retrieve an instance of an int or float for example,
|
||||
* look no further than {@link #getAs(Class)}. If you need a more powerful way of retrieving data, try out the many
|
||||
* {@code getDatatype...} methods.</li>
|
||||
* <li>It's very easy to throw detailed exceptions. The {@link IArgConsumer}} has many different methods that can
|
||||
* enforce the number of arguments, the type of arguments, and more, throwing different types of
|
||||
* {@link CommandException}s if something seems off. You're recommended to do all validation and store all needed
|
||||
* data in variables BEFORE logging any data to chat via {@link Helper#logDirect(String)}, so that the error
|
||||
* handlers can do their job and log the error to chat.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public interface IArgConsumer {
|
||||
|
||||
LinkedList<ICommandArgument> getArgs();
|
||||
|
||||
Deque<ICommandArgument> getConsumed();
|
||||
|
||||
/**
|
||||
* @param num The number of arguments to check for
|
||||
* @return {@code true} if there are <i>at least</i> {@code num} arguments left in this {@link IArgConsumer}}
|
||||
* @see #hasAny()
|
||||
* @see #hasAtMost(int)
|
||||
* @see #hasExactly(int)
|
||||
*/
|
||||
boolean has(int num);
|
||||
|
||||
/**
|
||||
* @return {@code true} if there is <i>at least</i> 1 argument left in this {@link IArgConsumer}}
|
||||
* @see #has(int)
|
||||
* @see #hasAtMostOne()
|
||||
* @see #hasExactlyOne()
|
||||
*/
|
||||
boolean hasAny();
|
||||
|
||||
/**
|
||||
* @param num The number of arguments to check for
|
||||
* @return {@code true} if there are <i>at most</i> {@code num} arguments left in this {@link IArgConsumer}}
|
||||
* @see #has(int)
|
||||
* @see #hasAtMost(int)
|
||||
* @see #hasExactly(int)
|
||||
*/
|
||||
boolean hasAtMost(int num);
|
||||
|
||||
/**
|
||||
* @return {@code true} if there is <i>at most</i> 1 argument left in this {@link IArgConsumer}}
|
||||
* @see #hasAny()
|
||||
* @see #hasAtMostOne()
|
||||
* @see #hasExactlyOne()
|
||||
*/
|
||||
boolean hasAtMostOne();
|
||||
|
||||
/**
|
||||
* @param num The number of arguments to check for
|
||||
* @return {@code true} if there are <i>exactly</i> {@code num} arguments left in this {@link IArgConsumer}}
|
||||
* @see #has(int)
|
||||
* @see #hasAtMost(int)
|
||||
*/
|
||||
boolean hasExactly(int num);
|
||||
|
||||
/**
|
||||
* @return {@code true} if there is <i>exactly</i> 1 argument left in this {@link IArgConsumer}}
|
||||
* @see #hasAny()
|
||||
* @see #hasAtMostOne()
|
||||
*/
|
||||
boolean hasExactlyOne();
|
||||
|
||||
/**
|
||||
* @param index The index to peek
|
||||
* @return The argument at index {@code index} in this {@link IArgConsumer}}, with 0 being the next one. This does not
|
||||
* mutate the {@link IArgConsumer}}
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
|
||||
* @see #peek()
|
||||
* @see #peekString(int)
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #get()
|
||||
*/
|
||||
ICommandArgument peek(int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @return The next argument in this {@link IArgConsumer}}. This does not mutate the {@link IArgConsumer}}
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than one argument left
|
||||
* @see #peek(int)
|
||||
* @see #peekString()
|
||||
* @see #peekAs(Class)
|
||||
* @see #get()
|
||||
*/
|
||||
ICommandArgument peek() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param index The index to peek
|
||||
* @param type The type to check for
|
||||
* @return If an ArgParser.Stateless for the specified {@code type} would succeed in parsing the next
|
||||
* argument
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
|
||||
* @see #peek()
|
||||
* @see #getAs(Class)
|
||||
*/
|
||||
boolean is(Class<?> type, int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param type The type to check for
|
||||
* @return If an ArgParser.Stateless for the specified {@code type} would succeed in parsing the next
|
||||
* argument
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than one argument left
|
||||
* @see #peek()
|
||||
* @see #getAs(Class)
|
||||
*/
|
||||
boolean is(Class<?> type) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param index The index to peek
|
||||
* @return The value of the argument at index {@code index} in this {@link IArgConsumer}}, with 0 being the next one
|
||||
* This does not mutate the {@link IArgConsumer}}
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
|
||||
* @see #peek()
|
||||
* @see #peekString()
|
||||
*/
|
||||
String peekString(int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @return The value of the next argument in this {@link IArgConsumer}}. This does not mutate the {@link IArgConsumer}}
|
||||
* @throws CommandNotEnoughArgumentsException If there is less than one argument left
|
||||
* @see #peekString(int)
|
||||
* @see #getString()
|
||||
*/
|
||||
String peekString() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param index The index to peek
|
||||
* @param enumClass The class to search
|
||||
* @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
|
||||
* next argument's value
|
||||
* @throws java.util.NoSuchElementException If the constant couldn't be found
|
||||
* @see #peekEnumOrNull(Class)
|
||||
* @see #getEnum(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E peekEnum(Class<E> enumClass, int index) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param enumClass The class to search
|
||||
* @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
|
||||
* next argument's value
|
||||
* @throws CommandInvalidTypeException If the constant couldn't be found
|
||||
* @see #peekEnumOrNull(Class)
|
||||
* @see #getEnum(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E peekEnum(Class<E> enumClass) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param index The index to peek
|
||||
* @param enumClass The class to search
|
||||
* @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
|
||||
* next argument's value. If no constant could be found, null
|
||||
* @see #peekEnum(Class)
|
||||
* @see #getEnumOrNull(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E peekEnumOrNull(Class<E> enumClass, int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param enumClass The class to search
|
||||
* @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
|
||||
* next argument's value. If no constant could be found, null
|
||||
* @see #peekEnum(Class)
|
||||
* @see #getEnumOrNull(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E peekEnumOrNull(Class<E> enumClass) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
|
||||
* class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @param index The index to peek
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
*/
|
||||
<T> T peekAs(Class<T> type, int index) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #peekAsOrDefault(Class, Object)
|
||||
* @see #peekAsOrNull(Class)
|
||||
*/
|
||||
<T> T peekAs(Class<T> type) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
|
||||
* class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @param def The value to return if the argument can't be parsed
|
||||
* @param index The index to peek
|
||||
* @return An instance of the specified type, or {@code def} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #peekAsOrDefault(Class, Object)
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
*/
|
||||
<T> T peekAsOrDefault(Class<T> type, T def, int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @param def The value to return if the argument can't be parsed
|
||||
* @return An instance of the specified type, or {@code def} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrNull(Class)
|
||||
*/
|
||||
<T> T peekAsOrDefault(Class<T> type, T def) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
|
||||
* class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @param index The index to peek
|
||||
* @return An instance of the specified type, or {@code null} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #peekAsOrNull(Class)
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
*/
|
||||
<T> T peekAsOrNull(Class<T> type, int index) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type, or {@code null} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object)
|
||||
*/
|
||||
<T> T peekAsOrNull(Class<T> type) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
<T> T peekDatatype(IDatatypeFor<T> datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, O> T peekDatatype(IDatatypePost<T, O> datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, O> T peekDatatype(IDatatypePost<T, O> datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T> T peekDatatypeOrNull(IDatatypeFor<T> datatype);
|
||||
|
||||
<T, O> T peekDatatypeOrNull(IDatatypePost<T, O> datatype);
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T peekDatatypePost(D datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T peekDatatypePostOrDefault(D datatype, O original, T def);
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T peekDatatypePostOrNull(D datatype, O original);
|
||||
|
||||
/**
|
||||
* Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
* <p>
|
||||
* Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
|
||||
*
|
||||
* @param datatype The datatype to get
|
||||
* @return The datatype instance
|
||||
* @see IDatatype
|
||||
* @see IDatatypeFor
|
||||
*/
|
||||
<T, D extends IDatatypeFor<T>> T peekDatatypeFor(Class<D> datatype);
|
||||
|
||||
/**
|
||||
* Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
* <p>
|
||||
* Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
|
||||
*
|
||||
* @param datatype The datatype to get
|
||||
* @param def The default value
|
||||
* @return The datatype instance, or {@code def} if it throws an exception
|
||||
* @see IDatatype
|
||||
* @see IDatatypeFor
|
||||
*/
|
||||
<T, D extends IDatatypeFor<T>> T peekDatatypeForOrDefault(Class<D> datatype, T def);
|
||||
|
||||
/**
|
||||
* Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
* <p>
|
||||
* Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
|
||||
*
|
||||
* @param datatype The datatype to get
|
||||
* @return The datatype instance, or {@code null} if it throws an exception
|
||||
* @see IDatatype
|
||||
* @see IDatatypeFor
|
||||
*/
|
||||
<T, D extends IDatatypeFor<T>> T peekDatatypeForOrNull(Class<D> datatype);
|
||||
|
||||
/**
|
||||
* Gets the next argument and returns it. This consumes the first argument so that subsequent calls will return
|
||||
* later arguments
|
||||
*
|
||||
* @return The next argument
|
||||
* @throws CommandNotEnoughArgumentsException If there's less than one argument left
|
||||
*/
|
||||
ICommandArgument get() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Gets the value of the next argument and returns it. This consumes the first argument so that subsequent calls
|
||||
* will return later arguments
|
||||
*
|
||||
* @return The value of the next argument
|
||||
* @throws CommandNotEnoughArgumentsException If there's less than one argument left
|
||||
*/
|
||||
String getString() throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as the next argument's value
|
||||
* @throws CommandInvalidTypeException If the constant couldn't be found
|
||||
* @see #peekEnum(Class)
|
||||
* @see #getEnumOrNull(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E getEnum(Class<E> enumClass) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @param def The default value
|
||||
* @return An enum constant of that class with the same name as the next argument's value, or {@code def} if it
|
||||
* couldn't be found
|
||||
* @see #getEnum(Class)
|
||||
* @see #getEnumOrNull(Class)
|
||||
* @see #peekEnumOrNull(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E getEnumOrDefault(Class<E> enumClass, E def) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it
|
||||
* couldn't be found
|
||||
* @see #getEnum(Class)
|
||||
* @see #getEnumOrDefault(Class, Enum)
|
||||
* @see #peekEnumOrNull(Class)
|
||||
* @see ICommandArgument#getEnum(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E getEnumOrNull(Class<E> enumClass) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #get()
|
||||
* @see #getAsOrDefault(Class, Object)
|
||||
* @see #getAsOrNull(Class)
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
*/
|
||||
<T> T getAs(Class<T> type) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @param def The default value
|
||||
* @return An instance of the specified type, or {@code def} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #get()
|
||||
* @see #getAs(Class)
|
||||
* @see #getAsOrNull(Class)
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
*/
|
||||
<T> T getAsOrDefault(Class<T> type, T def) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
|
||||
* <p>
|
||||
* A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
|
||||
* While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
|
||||
* {@link IArgConsumer}}.
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type, or {@code null} if it couldn't be parsed
|
||||
* @see IArgParser
|
||||
* @see #get()
|
||||
* @see #getAs(Class)
|
||||
* @see #getAsOrDefault(Class, Object)
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
* @see #peekAsOrNull(Class, int)
|
||||
*/
|
||||
<T> T getAsOrNull(Class<T> type) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T getDatatypePost(D datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrDefault(D datatype, O original, T _default);
|
||||
|
||||
<T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrNull(D datatype, O original);
|
||||
|
||||
<T, D extends IDatatypeFor<T>> T getDatatypeFor(D datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
|
||||
|
||||
<T, D extends IDatatypeFor<T>> T getDatatypeForOrDefault(D datatype, T def);
|
||||
|
||||
<T, D extends IDatatypeFor<T>> T getDatatypeForOrNull(D datatype);
|
||||
|
||||
<T extends IDatatype> Stream<String> tabCompleteDatatype(T datatype);
|
||||
|
||||
/**
|
||||
* Returns the "raw rest" of the string. For example, from a string <code>arg1 arg2 arg3</code>, split
|
||||
* into three {@link ICommandArgument}s {@code "arg1"}, {@code "arg2"}, and {@code "arg3"}:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code rawRest()} would return <code>arg1 arg2 arg3</code></li>
|
||||
* <li>After calling {@link #get()}, {@code rawRest()} would return <code>arg2 arg3</code> (note the
|
||||
* double space - it is preserved!)</li>
|
||||
* <li>After calling {@link #get()} again, {@code rawRest()} would return {@code "arg3"}</li>
|
||||
* <li>After calling {@link #get()} one last time, {@code rawRest()} would return {@code ""}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return The "raw rest" of the string.
|
||||
*/
|
||||
String rawRest();
|
||||
|
||||
/**
|
||||
* @param min The minimum amount of arguments to require.
|
||||
* @throws CommandNotEnoughArgumentsException If there are less than {@code min} arguments left.
|
||||
* @see #requireMax(int)
|
||||
* @see #requireExactly(int)
|
||||
*/
|
||||
void requireMin(int min) throws CommandNotEnoughArgumentsException;
|
||||
|
||||
/**
|
||||
* @param max The maximum amount of arguments allowed.
|
||||
* @throws CommandTooManyArgumentsException If there are more than {@code max} arguments left.
|
||||
* @see #requireMin(int)
|
||||
* @see #requireExactly(int)
|
||||
*/
|
||||
void requireMax(int max) throws CommandTooManyArgumentsException;
|
||||
|
||||
/**
|
||||
* @param args The exact amount of arguments to require.
|
||||
* @throws CommandNotEnoughArgumentsException If there are less than {@code args} arguments left.
|
||||
* @throws CommandTooManyArgumentsException If there are more than {@code args} arguments left.
|
||||
* @see #requireMin(int)
|
||||
* @see #requireMax(int)
|
||||
*/
|
||||
void requireExactly(int args) throws CommandException;
|
||||
|
||||
/**
|
||||
* @return If this {@link IArgConsumer}} has consumed at least one argument.
|
||||
* @see #consumed()
|
||||
* @see #consumedString()
|
||||
*/
|
||||
boolean hasConsumed();
|
||||
|
||||
/**
|
||||
* @return The last argument this {@link IArgConsumer}} has consumed, or an "unknown" argument, indicated by a
|
||||
* comamnd argument index that has a value of {@code -1}, if no arguments have been consumed yet.
|
||||
* @see #consumedString()
|
||||
* @see #hasConsumed()
|
||||
*/
|
||||
ICommandArgument consumed();
|
||||
|
||||
/**
|
||||
* @return The value of thelast argument this {@link IArgConsumer}} has consumed, or an empty string if no arguments
|
||||
* have been consumed yet
|
||||
* @see #consumed()
|
||||
* @see #hasConsumed()
|
||||
*/
|
||||
String consumedString();
|
||||
|
||||
/**
|
||||
* @return A copy of this {@link IArgConsumer}}. It has the same arguments (both consumed and not), but does not
|
||||
* affect or mutate this instance. Useful for the various {@code peek} functions
|
||||
*/
|
||||
IArgConsumer copy();
|
||||
}
|
||||
101
src/api/java/baritone/api/command/argument/ICommandArgument.java
Normal file
101
src/api/java/baritone/api/command/argument/ICommandArgument.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.command.argument;
|
||||
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
|
||||
* that argument, its value, and the rest of the string that argument was found in
|
||||
* <p>
|
||||
* You're recommended to use {@link IArgConsumer}}s to handle these.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 10/2/2019
|
||||
*/
|
||||
public interface ICommandArgument {
|
||||
|
||||
/**
|
||||
* @return The index of this command argument in the list of command arguments generated
|
||||
*/
|
||||
int getIndex();
|
||||
|
||||
/**
|
||||
* @return The raw value of just this argument
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* @return The raw value of the remaining arguments after this one was captured
|
||||
*/
|
||||
String getRawRest();
|
||||
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as this argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link Direction}, and this argument's value is "up", it will return {@link
|
||||
* Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as this argument's value
|
||||
* @throws CommandInvalidTypeException If the constant couldn't be found
|
||||
* @see IArgConsumer#peekEnum(Class)
|
||||
* @see IArgConsumer#peekEnum(Class, int)
|
||||
* @see IArgConsumer#peekEnumOrNull(Class)
|
||||
* @see IArgConsumer#peekEnumOrNull(Class, int)
|
||||
* @see IArgConsumer#getEnum(Class)
|
||||
* @see IArgConsumer#getEnumOrNull(Class)
|
||||
*/
|
||||
<E extends Enum<?>> E getEnum(Class<E> enumClass) throws CommandInvalidTypeException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse this argument into the specified class
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T> T getAs(Class<T> type) throws CommandInvalidTypeException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stateless</b> {@link IArgParser} to parse this argument into the specified class
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return If the parser succeeded
|
||||
*/
|
||||
<T> boolean is(Class<T> type);
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stated</b> {@link IArgParser} to parse this argument into the specified class
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T, S> T getAs(Class<T> type, Class<S> stateType, S state) throws CommandInvalidTypeException;
|
||||
|
||||
/**
|
||||
* Tries to use a <b>stated</b> {@link IArgParser} to parse this argument into the specified class
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return If the parser succeeded
|
||||
*/
|
||||
<T, S> boolean is(Class<T> type, Class<S> stateType, S state);
|
||||
}
|
||||
53
src/api/java/baritone/api/command/datatypes/BlockById.java
Normal file
53
src/api/java/baritone/api/command/datatypes/BlockById.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum BlockById implements IDatatypeFor<Block> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = Registry.BLOCK.getValue(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
Registry.BLOCK.keySet()
|
||||
.stream()
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
EntityType entity;
|
||||
if ((entity = Registry.ENTITY_TYPE.getValue(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
@@ -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.command.datatypes;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
|
||||
return new BlockOptionalMeta(ctx.getConsumer().getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForDirection implements IDatatypeFor<Direction> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Direction get(IDatatypeContext ctx) throws CommandException {
|
||||
return Direction.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Stream.of(Direction.values())
|
||||
.map(Direction::getName).map(String::toLowerCase))
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForWaypoints implements IDatatypeFor<IWaypoint[]> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public IWaypoint[] get(IDatatypeContext ctx) throws CommandException {
|
||||
final String input = ctx.getConsumer().getString();
|
||||
final IWaypoint.Tag tag = IWaypoint.Tag.getByName(input);
|
||||
|
||||
// If the input doesn't resolve to a valid tag, resolve by name
|
||||
return tag == null
|
||||
? getWaypointsByName(ctx.getBaritone(), input)
|
||||
: getWaypointsByTag(ctx.getBaritone(), tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(getWaypointNames(ctx.getBaritone()))
|
||||
.sortAlphabetically()
|
||||
.prepend(IWaypoint.Tag.getAllNames())
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.stream();
|
||||
}
|
||||
|
||||
public static IWaypointCollection waypoints(IBaritone baritone) {
|
||||
return baritone.getWorldProvider().getCurrentWorld().getWaypoints();
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypoints(IBaritone baritone) {
|
||||
return waypoints(baritone).getAllWaypoints().stream()
|
||||
.sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed())
|
||||
.toArray(IWaypoint[]::new);
|
||||
}
|
||||
|
||||
public static String[] getWaypointNames(IBaritone baritone) {
|
||||
return Stream.of(getWaypoints(baritone))
|
||||
.map(IWaypoint::getName)
|
||||
.filter(name -> !name.isEmpty())
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypointsByTag(IBaritone baritone, IWaypoint.Tag tag) {
|
||||
return waypoints(baritone).getByTag(tag).stream()
|
||||
.sorted(Comparator.comparingLong(IWaypoint::getCreationTimestamp).reversed())
|
||||
.toArray(IWaypoint[]::new);
|
||||
}
|
||||
|
||||
public static IWaypoint[] getWaypointsByName(IBaritone baritone, String name) {
|
||||
return Stream.of(getWaypoints(baritone))
|
||||
.filter(waypoint -> waypoint.getName().equalsIgnoreCase(name))
|
||||
.toArray(IWaypoint[]::new);
|
||||
}
|
||||
}
|
||||
56
src/api/java/baritone/api/command/datatypes/IDatatype.java
Normal file
56
src/api/java/baritone/api/command/datatypes/IDatatype.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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An {@link IDatatype} is similar to an {@link IArgParser} in the sense that it is capable of consuming an argument
|
||||
* to transform it into a usable form as the code desires.
|
||||
* <p>
|
||||
* A fundamental difference is that an {@link IDatatype} is capable of consuming multiple arguments. For example,
|
||||
* {@link RelativeBlockPos} is an {@link IDatatypePost} which requires at least 3 {@link RelativeCoordinate} arguments
|
||||
* to be specified.
|
||||
* <p>
|
||||
* Another difference is that an {@link IDatatype} can be tab-completed, providing comprehensive auto completion
|
||||
* that can substitute based on existing input or provide possibilities for the next piece of input.
|
||||
*
|
||||
* @see IDatatypeContext
|
||||
* @see IDatatypeFor
|
||||
* @see IDatatypePost
|
||||
*/
|
||||
public interface IDatatype {
|
||||
|
||||
/**
|
||||
* Attempts to complete missing or partial input provided through the {@link IArgConsumer}} provided by
|
||||
* {@link IDatatypeContext#getConsumer()} in order to aide the user in executing commands.
|
||||
* <p>
|
||||
* One benefit over datatypes over {@link IArgParser}s is that instead of each command trying to guess what values
|
||||
* the datatype will accept, or simply not tab completing at all, datatypes that support tab completion can provide
|
||||
* accurate information using the same methods used to parse arguments in the first place.
|
||||
*
|
||||
* @param ctx The argument consumer to tab complete
|
||||
* @return A stream representing the strings that can be tab completed. DO NOT INCLUDE SPACES IN ANY STRINGS.
|
||||
* @see IArgConsumer#tabCompleteDatatype(IDatatype)
|
||||
*/
|
||||
Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException;
|
||||
}
|
||||
@@ -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.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
|
||||
/**
|
||||
* Provides an {@link IDatatype} with contextual information so
|
||||
* that it can perform the desired operation on the target level.
|
||||
*
|
||||
* @see IDatatype
|
||||
*
|
||||
* @author Brady
|
||||
* @since 9/26/2019
|
||||
*/
|
||||
public interface IDatatypeContext {
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance that is associated with the action relating to datatype handling.
|
||||
*
|
||||
* @return The context {@link IBaritone} instance.
|
||||
*/
|
||||
IBaritone getBaritone();
|
||||
|
||||
/**
|
||||
* Provides the {@link IArgConsumer}} to fetch input information from.
|
||||
*
|
||||
* @return The context {@link IArgConsumer}}.
|
||||
*/
|
||||
IArgConsumer getConsumer();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An {@link IDatatype} which acts as a {@link Supplier}, in essence. The only difference
|
||||
* is that it requires an {@link IDatatypeContext} to be provided due to the expectation that
|
||||
* implementations of {@link IDatatype} are singletons.
|
||||
*/
|
||||
public interface IDatatypeFor<T> extends IDatatype {
|
||||
|
||||
/**
|
||||
* Consumes the desired amount of arguments from the specified {@link IDatatypeContext}, and
|
||||
* then returns the parsed value. This method will more than likely return a {@link IllegalArgumentException}
|
||||
* if the expected input does not conform to a parseable value. As far as a {@link CommandException} being
|
||||
* thrown is concerned, see the note below for specifics.
|
||||
*
|
||||
* @see IDatatypeContext
|
||||
*
|
||||
* @param ctx The context
|
||||
* @return The parsed data-type
|
||||
* @throws CommandException If there was an issue parsing using another type or arguments could not be polled.
|
||||
*/
|
||||
T get(IDatatypeContext ctx) throws CommandException;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* An {@link IDatatype} which acts as a {@link Function}, in essence. The only difference
|
||||
* is that it requires an {@link IDatatypeContext} to be provided due to the expectation that
|
||||
* implementations of {@link IDatatype} are singletons.
|
||||
*/
|
||||
public interface IDatatypePost<T, O> extends IDatatype {
|
||||
|
||||
/**
|
||||
* Takes the expected input and transforms it based on the value held by {@code original}. If {@code original}
|
||||
* is null, it is expected that the implementation of this method has a case to handle it, such that a
|
||||
* {@link NullPointerException} will never be thrown as a result.
|
||||
*
|
||||
* @param ctx The datatype context
|
||||
* @param original The transformable value
|
||||
* @return The transformed value
|
||||
*/
|
||||
T apply(IDatatypeContext ctx, O original) throws CommandException;
|
||||
}
|
||||
@@ -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.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/26/2019
|
||||
*/
|
||||
public interface IDatatypePostFunction<T, O> {
|
||||
|
||||
T apply(O original) throws CommandException;
|
||||
}
|
||||
@@ -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.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An {@link IDatatype} used to resolve nearby players, those within
|
||||
* render distance of the target {@link IBaritone} instance.
|
||||
*/
|
||||
public enum NearbyPlayer implements IDatatypeFor<PlayerEntity> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public PlayerEntity get(IDatatypeContext ctx) throws CommandException {
|
||||
final String username = ctx.getConsumer().getString();
|
||||
return getPlayers(ctx).stream()
|
||||
.filter(s -> s.getName().getString().equalsIgnoreCase(username))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(getPlayers(ctx).stream().map(PlayerEntity::getName).map(ITextComponent::getString))
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
|
||||
private static List<? extends PlayerEntity> getPlayers(IDatatypeContext ctx) {
|
||||
return ctx.getBaritone().getPlayerContext().world().getPlayers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeBlockPos implements IDatatypePost<BetterBlockPos, BetterBlockPos> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public BetterBlockPos apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = BetterBlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
return new BetterBlockPos(
|
||||
consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x),
|
||||
consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y),
|
||||
consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
if (consumer.hasAny() && !consumer.has(4)) {
|
||||
while (consumer.has(2)) {
|
||||
if (consumer.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) == null) {
|
||||
break;
|
||||
}
|
||||
consumer.get();
|
||||
}
|
||||
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
INSTANCE;
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
|
||||
|
||||
@Override
|
||||
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = 0.0D;
|
||||
}
|
||||
|
||||
Matcher matcher = PATTERN.matcher(ctx.getConsumer().getString());
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException("pattern doesn't match");
|
||||
}
|
||||
|
||||
boolean isRelative = !matcher.group(1).isEmpty();
|
||||
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
|
||||
|
||||
if (matcher.group(2).contains("k")) {
|
||||
offset *= 1000;
|
||||
}
|
||||
|
||||
if (isRelative) {
|
||||
return origin + offset;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
if (!consumer.has(2) && consumer.getString().matches("^(~|$)")) {
|
||||
return Stream.of("~");
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
103
src/api/java/baritone/api/command/datatypes/RelativeFile.java
Normal file
103
src/api/java/baritone/api/command/datatypes/RelativeFile.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.Helper.HELPER;
|
||||
|
||||
public enum RelativeFile implements IDatatypePost<File, File> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public File apply(IDatatypeContext ctx, File original) throws CommandException {
|
||||
if (original == null) {
|
||||
original = new File("./");
|
||||
}
|
||||
|
||||
Path path;
|
||||
try {
|
||||
path = FileSystems.getDefault().getPath(ctx.getConsumer().getString());
|
||||
} catch (InvalidPathException e) {
|
||||
throw new IllegalArgumentException("invalid path");
|
||||
}
|
||||
return getCanonicalFileUnchecked(original.toPath().resolve(path).toFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Seriously
|
||||
*
|
||||
* @param file File
|
||||
* @return Canonical file of file
|
||||
* @author LoganDark
|
||||
*/
|
||||
private static File getCanonicalFileUnchecked(File file) {
|
||||
try {
|
||||
return file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Stream<String> tabComplete(IArgConsumer consumer, File base0) throws CommandException {
|
||||
// I will not make the caller deal with this, seriously
|
||||
// Tab complete code is beautiful and I'm not going to bloat it with dumb ass checked exception bullshit -LoganDark
|
||||
|
||||
// lol owned -Brady
|
||||
|
||||
File base = getCanonicalFileUnchecked(base0);
|
||||
String currentPathStringThing = consumer.getString();
|
||||
Path currentPath = FileSystems.getDefault().getPath(currentPathStringThing);
|
||||
Path basePath = currentPath.isAbsolute() ? currentPath.getRoot() : base.toPath();
|
||||
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
||||
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
||||
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
|
||||
useParent
|
||||
? currentFile.getParentFile()
|
||||
: currentFile
|
||||
).listFiles()))
|
||||
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
|
||||
(f.isDirectory() ? File.separator : ""))
|
||||
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
|
||||
.filter(s -> !s.contains(" "));
|
||||
}
|
||||
|
||||
public static File gameDir() {
|
||||
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
|
||||
if (gameDir.getName().equals(".")) {
|
||||
return gameDir.getParentFile();
|
||||
}
|
||||
return gameDir;
|
||||
}
|
||||
}
|
||||
@@ -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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Goal apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = BetterBlockPos.ORIGIN;
|
||||
}
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
|
||||
List<IDatatypePostFunction<Double, Double>> coords = new ArrayList<>();
|
||||
final IArgConsumer copy = consumer.copy(); // This is a hack and should be fixed in the future probably
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (copy.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) {
|
||||
coords.add(o -> consumer.getDatatypePost(RelativeCoordinate.INSTANCE, o));
|
||||
copy.get(); // Consume so we actually decrement the remaining arguments
|
||||
}
|
||||
}
|
||||
|
||||
switch (coords.size()) {
|
||||
case 0:
|
||||
return new GoalBlock(origin);
|
||||
case 1:
|
||||
return new GoalYLevel(
|
||||
MathHelper.floor(coords.get(0).apply((double) origin.y))
|
||||
);
|
||||
case 2:
|
||||
return new GoalXZ(
|
||||
MathHelper.floor(coords.get(0).apply((double) origin.x)),
|
||||
MathHelper.floor(coords.get(1).apply((double) origin.z))
|
||||
);
|
||||
case 3:
|
||||
return new GoalBlock(
|
||||
MathHelper.floor(coords.get(0).apply((double) origin.x)),
|
||||
MathHelper.floor(coords.get(1).apply((double) origin.y)),
|
||||
MathHelper.floor(coords.get(2).apply((double) origin.z))
|
||||
);
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected coords size: " + coords.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
return ctx.getConsumer().tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPos> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public GoalBlock apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = BetterBlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
return new GoalBlock(
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y)),
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
if (consumer.hasAtMost(3)) {
|
||||
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public GoalXZ apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = BetterBlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
return new GoalXZ(
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
if (consumer.hasAtMost(2)) {
|
||||
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public GoalYLevel apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException {
|
||||
if (origin == null) {
|
||||
origin = BetterBlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
return new GoalYLevel(
|
||||
MathHelper.floor(ctx.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
if (consumer.hasAtMost(1)) {
|
||||
return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE);
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandErrorMessageException extends CommandException {
|
||||
|
||||
protected CommandErrorMessageException(String reason) {
|
||||
super(reason);
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandException extends Exception implements ICommandException {
|
||||
|
||||
protected CommandException(String reason) {
|
||||
super(reason);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.command.exception;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
|
||||
|
||||
public final ICommandArgument arg;
|
||||
|
||||
protected CommandInvalidArgumentException(ICommandArgument arg, String reason) {
|
||||
super(String.format(
|
||||
"Error at argument #%s: %s",
|
||||
arg.getIndex() == -1 ? "<unknown>" : Integer.toString(arg.getIndex() + 1),
|
||||
reason
|
||||
));
|
||||
this.arg = arg;
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandInvalidStateException extends CommandErrorMessageException {
|
||||
|
||||
public CommandInvalidStateException(String reason) {
|
||||
super(reason);
|
||||
}
|
||||
}
|
||||
@@ -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.api.command.exception;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument arg, String expected) {
|
||||
super(arg, String.format("Expected %s", expected));
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument arg, String expected, Throwable cause) {
|
||||
super(arg, String.format("Expected %s.\nMore details: %s", expected, cause.getMessage()));
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument arg, String expected, String got) {
|
||||
super(arg, String.format("Expected %s, but got %s instead", expected, got));
|
||||
}
|
||||
|
||||
public CommandInvalidTypeException(ICommandArgument arg, String expected, String got, Throwable cause) {
|
||||
super(arg, String.format("Expected %s, but got %s instead.\nMore details: %s", expected, got, cause.getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandNoParserForTypeException extends CommandUnhandledException {
|
||||
|
||||
public CommandNoParserForTypeException(Class<?> klass) {
|
||||
super(String.format("Could not find a handler for type %s", klass.getSimpleName()));
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
|
||||
|
||||
public CommandNotEnoughArgumentsException(int minArgs) {
|
||||
super(String.format("Not enough arguments (expected at least %d)", minArgs));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.utils.Helper.HELPER;
|
||||
|
||||
public class CommandNotFoundException extends CommandException {
|
||||
|
||||
public final String command;
|
||||
|
||||
public CommandNotFoundException(String command) {
|
||||
super(String.format("Command not found: %s", command));
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ICommand command, List<ICommandArgument> args) {
|
||||
HELPER.logDirect(getMessage());
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
|
||||
|
||||
public CommandTooManyArgumentsException(int maxArgs) {
|
||||
super(String.format("Too many arguments (expected at most %d)", maxArgs));
|
||||
}
|
||||
}
|
||||
@@ -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.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.utils.Helper.HELPER;
|
||||
|
||||
public class CommandUnhandledException extends RuntimeException implements ICommandException {
|
||||
|
||||
public CommandUnhandledException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CommandUnhandledException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ICommand command, List<ICommandArgument> args) {
|
||||
HELPER.logDirect("An unhandled exception occurred." +
|
||||
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
|
||||
TextFormatting.RED);
|
||||
|
||||
this.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -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.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.utils.Helper.HELPER;
|
||||
|
||||
/**
|
||||
* The base for a Baritone Command Exception, checked or unchecked. Provides a
|
||||
* {@link #handle(ICommand, List)} method that is used to provide useful output
|
||||
* to the user for diagnosing issues that may have occurred during execution.
|
||||
* <p>
|
||||
* Anything implementing this interface should be assignable to {@link Exception}.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 9/20/2019
|
||||
*/
|
||||
public interface ICommandException {
|
||||
|
||||
/**
|
||||
* @see Exception#getMessage()
|
||||
* @return The exception details
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
* Called when this exception is thrown, to handle the exception.
|
||||
*
|
||||
* @param command The command that threw it.
|
||||
* @param args The arguments the command was called with.
|
||||
*/
|
||||
default void handle(ICommand command, List<ICommandArgument> args) {
|
||||
HELPER.logDirect(this.getMessage(), TextFormatting.RED);
|
||||
}
|
||||
}
|
||||
184
src/api/java/baritone/api/command/helpers/Paginator.java
Normal file
184
src/api/java/baritone/api/command/helpers/Paginator.java
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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.command.helpers;
|
||||
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Paginator<E> implements Helper {
|
||||
|
||||
public final List<E> entries;
|
||||
public int pageSize = 8;
|
||||
public int page = 1;
|
||||
|
||||
public Paginator(List<E> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public Paginator(E... entries) {
|
||||
this.entries = Arrays.asList(entries);
|
||||
}
|
||||
|
||||
public Paginator<E> setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMaxPage() {
|
||||
return (entries.size() - 1) / pageSize + 1;
|
||||
}
|
||||
|
||||
public boolean validPage(int page) {
|
||||
return page > 0 && page <= getMaxPage();
|
||||
}
|
||||
|
||||
public Paginator<E> skipPages(int pages) {
|
||||
page += pages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void display(Function<E, ITextComponent> transform, String commandPrefix) {
|
||||
int offset = (page - 1) * pageSize;
|
||||
for (int i = offset; i < offset + pageSize; i++) {
|
||||
if (i < entries.size()) {
|
||||
logDirect(transform.apply(entries.get(i)));
|
||||
} else {
|
||||
logDirect("--", TextFormatting.DARK_GRAY);
|
||||
}
|
||||
}
|
||||
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||
ITextComponent prevPageComponent = new StringTextComponent("<<");
|
||||
if (hasPrevPage) {
|
||||
prevPageComponent.getStyle()
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page - 1)
|
||||
))
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new StringTextComponent("Click to view previous page")
|
||||
));
|
||||
} else {
|
||||
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
}
|
||||
ITextComponent nextPageComponent = new StringTextComponent(">>");
|
||||
if (hasNextPage) {
|
||||
nextPageComponent.getStyle()
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page + 1)
|
||||
))
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new StringTextComponent("Click to view next page")
|
||||
));
|
||||
} else {
|
||||
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
}
|
||||
ITextComponent pagerComponent = new StringTextComponent("");
|
||||
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
pagerComponent.appendSibling(prevPageComponent);
|
||||
pagerComponent.appendText(" | ");
|
||||
pagerComponent.appendSibling(nextPageComponent);
|
||||
pagerComponent.appendText(String.format(" %d/%d", page, getMaxPage()));
|
||||
logDirect(pagerComponent);
|
||||
}
|
||||
|
||||
public void display(Function<E, ITextComponent> transform) {
|
||||
display(transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
int page = 1;
|
||||
consumer.requireMax(1);
|
||||
if (consumer.hasAny()) {
|
||||
page = consumer.getAs(Integer.class);
|
||||
if (!pagi.validPage(page)) {
|
||||
throw new CommandInvalidTypeException(
|
||||
consumer.consumed(),
|
||||
String.format(
|
||||
"a valid page (1-%d)",
|
||||
pagi.getMaxPage()
|
||||
),
|
||||
consumer.consumed().getValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
pagi.skipPages(page - pagi.page);
|
||||
if (pre != null) {
|
||||
pre.run();
|
||||
}
|
||||
pagi.display(transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
paginate(consumer, new Paginator<>(elems), pre, transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
paginate(consumer, Arrays.asList(elems), pre, transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
paginate(consumer, pagi, null, transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
paginate(consumer, new Paginator<>(elems), null, transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
|
||||
paginate(consumer, Arrays.asList(elems), null, transform, commandPrefix);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, pagi, pre, transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, new Paginator<>(elems), pre, transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, Arrays.asList(elems), pre, transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, pagi, null, transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, new Paginator<>(elems), null, transform, null);
|
||||
}
|
||||
|
||||
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, ITextComponent> transform) throws CommandException {
|
||||
paginate(consumer, Arrays.asList(elems), null, transform, null);
|
||||
}
|
||||
}
|
||||
288
src/api/java/baritone/api/command/helpers/TabCompleteHelper.java
Normal file
288
src/api/java/baritone/api/command/helpers/TabCompleteHelper.java
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* 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.command.helpers;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper
|
||||
* methods for appending and prepending streams, sorting, filtering by prefix, and so on.
|
||||
* <p>
|
||||
* The recommended way to use this class is:
|
||||
* <ul>
|
||||
* <li>Create a new instance with the empty constructor</li>
|
||||
* <li>Use {@code append}, {@code prepend} or {@code add<something>} methods to add completions</li>
|
||||
* <li>Sort using {@link #sort(Comparator)} or {@link #sortAlphabetically()} and then filter by prefix using
|
||||
* {@link #filterPrefix(String)}</li>
|
||||
* <li>Get the stream using {@link #stream()}</li>
|
||||
* <li>Pass it up to whatever's calling your tab complete function (i.e.
|
||||
* {@link ICommandManager#tabComplete(String)} or {@link IArgConsumer}#tabCompleteDatatype(IDatatype)})</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* For advanced users: if you're intercepting {@link TabCompleteEvent}s directly, use {@link #build()} instead for an
|
||||
* array.
|
||||
*/
|
||||
public class TabCompleteHelper {
|
||||
|
||||
private Stream<String> stream;
|
||||
|
||||
public TabCompleteHelper(String[] base) {
|
||||
stream = Stream.of(base);
|
||||
}
|
||||
|
||||
public TabCompleteHelper(List<String> base) {
|
||||
stream = base.stream();
|
||||
}
|
||||
|
||||
public TabCompleteHelper() {
|
||||
stream = Stream.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the specified stream to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param source The stream to append
|
||||
* @return This {@link TabCompleteHelper} after having appended the stream
|
||||
* @see #append(String...)
|
||||
* @see #append(Class)
|
||||
*/
|
||||
public TabCompleteHelper append(Stream<String> source) {
|
||||
stream = Stream.concat(stream, source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the specified strings to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param source The stream to append
|
||||
* @return This {@link TabCompleteHelper} after having appended the strings
|
||||
* @see #append(Stream)
|
||||
* @see #append(Class)
|
||||
*/
|
||||
public TabCompleteHelper append(String... source) {
|
||||
return append(Stream.of(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all values of the specified enum to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param num The enum to append the values of
|
||||
* @return This {@link TabCompleteHelper} after having appended the values
|
||||
* @see #append(Stream)
|
||||
* @see #append(String...)
|
||||
*/
|
||||
public TabCompleteHelper append(Class<? extends Enum<?>> num) {
|
||||
return append(
|
||||
Stream.of(num.getEnumConstants())
|
||||
.map(Enum::name)
|
||||
.map(String::toLowerCase)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends the specified stream to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param source The stream to prepend
|
||||
* @return This {@link TabCompleteHelper} after having prepended the stream
|
||||
* @see #prepend(String...)
|
||||
* @see #prepend(Class)
|
||||
*/
|
||||
public TabCompleteHelper prepend(Stream<String> source) {
|
||||
stream = Stream.concat(source, stream);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends the specified strings to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param source The stream to prepend
|
||||
* @return This {@link TabCompleteHelper} after having prepended the strings
|
||||
* @see #prepend(Stream)
|
||||
* @see #prepend(Class)
|
||||
*/
|
||||
public TabCompleteHelper prepend(String... source) {
|
||||
return prepend(Stream.of(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends all values of the specified enum to this {@link TabCompleteHelper} and returns it for chaining
|
||||
*
|
||||
* @param num The enum to prepend the values of
|
||||
* @return This {@link TabCompleteHelper} after having prepended the values
|
||||
* @see #prepend(Stream)
|
||||
* @see #prepend(String...)
|
||||
*/
|
||||
public TabCompleteHelper prepend(Class<? extends Enum<?>> num) {
|
||||
return prepend(
|
||||
Stream.of(num.getEnumConstants())
|
||||
.map(Enum::name)
|
||||
.map(String::toLowerCase)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the specified {@code transform} to every element <b>currently</b> in this {@link TabCompleteHelper} and
|
||||
* return this object for chaining
|
||||
*
|
||||
* @param transform The transform to apply
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper map(Function<String, String> transform) {
|
||||
stream = stream.map(transform);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the specified {@code filter} to every element <b>currently</b> in this {@link TabCompleteHelper} and return
|
||||
* this object for chaining
|
||||
*
|
||||
* @param filter The filter to apply
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper filter(Predicate<String> filter) {
|
||||
stream = stream.filter(filter);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the specified {@code sort} to every element <b>currently</b> in this {@link TabCompleteHelper} and return
|
||||
* this object for chaining
|
||||
*
|
||||
* @param comparator The comparator to use
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper sort(Comparator<String> comparator) {
|
||||
stream = stream.sorted(comparator);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort every element <b>currently</b> in this {@link TabCompleteHelper} alphabetically and return this object for
|
||||
* chaining
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper sortAlphabetically() {
|
||||
return sort(String.CASE_INSENSITIVE_ORDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out any element that doesn't start with {@code prefix} and return this object for chaining
|
||||
*
|
||||
* @param prefix The prefix to filter for
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper filterPrefix(String prefix) {
|
||||
return filter(x -> x.toLowerCase(Locale.US).startsWith(prefix.toLowerCase(Locale.US)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out any element that doesn't start with {@code prefix} and return this object for chaining
|
||||
* <p>
|
||||
* Assumes every element in this {@link TabCompleteHelper} is a {@link ResourceLocation}
|
||||
*
|
||||
* @param prefix The prefix to filter for
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper filterPrefixNamespaced(String prefix) {
|
||||
return filterPrefix(new ResourceLocation(prefix).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An array containing every element in this {@link TabCompleteHelper}
|
||||
* @see #stream()
|
||||
*/
|
||||
public String[] build() {
|
||||
return stream.toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A stream containing every element in this {@link TabCompleteHelper}
|
||||
* @see #build()
|
||||
*/
|
||||
public Stream<String> stream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends every command in the specified {@link ICommandManager} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @param manager A command manager
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addCommands(ICommandManager manager) {
|
||||
return append(manager.getRegistry().descendingStream()
|
||||
.flatMap(command -> command.getNames().stream())
|
||||
.distinct()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends every setting in the {@link Settings} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addSettings() {
|
||||
return append(
|
||||
BaritoneAPI.getSettings().allSettings.stream()
|
||||
.map(Settings.Setting::getName)
|
||||
.filter(s -> !s.equalsIgnoreCase("logger"))
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends every modified setting in the {@link Settings} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addModifiedSettings() {
|
||||
return append(
|
||||
SettingsUtil.modifiedSettings(BaritoneAPI.getSettings()).stream()
|
||||
.map(Settings.Setting::getName)
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends every {@link Boolean} setting in the {@link Settings} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addToggleableSettings() {
|
||||
return append(
|
||||
BaritoneAPI.getSettings().getAllValuesByType(Boolean.class).stream()
|
||||
.map(Settings.Setting::getName)
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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.command.manager;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.registry.Registry;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/21/2019
|
||||
*/
|
||||
public interface ICommandManager {
|
||||
|
||||
IBaritone getBaritone();
|
||||
|
||||
Registry<ICommand> getRegistry();
|
||||
|
||||
/**
|
||||
* @param name The command name to search for.
|
||||
* @return The command, if found.
|
||||
*/
|
||||
ICommand getCommand(String name);
|
||||
|
||||
boolean execute(String string);
|
||||
|
||||
boolean execute(Tuple<String, List<ICommandArgument>> expanded);
|
||||
|
||||
Stream<String> tabComplete(Tuple<String, List<ICommandArgument>> expanded);
|
||||
|
||||
Stream<String> tabComplete(String prefix);
|
||||
}
|
||||
135
src/api/java/baritone/api/command/registry/Registry.java
Normal file
135
src/api/java/baritone/api/command/registry/Registry.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.command.registry;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* This registry class allows for registration and unregistration of a certain type. This is mainly designed for use by
|
||||
* event handlers where newly registered ones are encountered first during iteration and can therefore override older
|
||||
* ones. In Baritone, this is used for commands and argument parsers so that mods and addons can extend Baritone's
|
||||
* functionality without resorting to hacks, wrappers, or mixins.
|
||||
*
|
||||
* @param <V> The entry type that will be stored in this registry. This can be anything, really - preferably anything
|
||||
* that works as a HashMap key, as that's what's used to keep track of which entries are registered or not.
|
||||
*/
|
||||
public class Registry<V> {
|
||||
|
||||
/**
|
||||
* An internal linked list of all the entries that are currently registered. This is a linked list so that entries
|
||||
* can be inserted at the beginning, which means that newer entries are encountered first during iteration. This is
|
||||
* an important property of the registry that makes it more useful than a simple list, and also the reason it does
|
||||
* not just use a map.
|
||||
*/
|
||||
private final Deque<V> _entries = new LinkedList<>();
|
||||
/**
|
||||
* A HashSet containing every entry currently registered. Entries are added to this set when something is registered
|
||||
* and removed from the set when they are unregistered. An entry being present in this set indicates that it is
|
||||
* currently registered, can be removed, and should not be reregistered until it is removed.
|
||||
*/
|
||||
private final Set<V> registered = new HashSet<>();
|
||||
/**
|
||||
* The collection of entries that are currently in this registry. This is a collection (and not a list) because,
|
||||
* internally, entries are stored in a linked list, which is not the same as a normal list.
|
||||
*/
|
||||
public final Collection<V> entries = Collections.unmodifiableCollection(_entries);
|
||||
|
||||
/**
|
||||
* @param entry The entry to check.
|
||||
* @return If this entry is currently registered in this registry.
|
||||
*/
|
||||
public boolean registered(V entry) {
|
||||
return registered.contains(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the entry {@code entry} is registered.
|
||||
*
|
||||
* @param entry The entry to register.
|
||||
* @return A boolean indicating whether or not this is a new registration. No matter the value of this boolean, the
|
||||
* entry is always guaranteed to now be in this registry. This boolean simply indicates if the entry was <i>not</i>
|
||||
* in the map prior to this method call.
|
||||
*/
|
||||
public boolean register(V entry) {
|
||||
if (!registered(entry)) {
|
||||
_entries.addFirst(entry);
|
||||
registered.add(entry);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this entry from this registry. After this method call, the entry is guaranteed to be removed from the
|
||||
* registry, since each entry only ever appears once.
|
||||
*
|
||||
* @param entry The entry to unregister.
|
||||
*/
|
||||
public void unregister(V entry) {
|
||||
if (registered(entry)) {
|
||||
return;
|
||||
}
|
||||
_entries.remove(entry);
|
||||
registered.remove(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator that iterates over each entry in this registry, with the newest elements iterated over first.
|
||||
* Internally, as new elements are prepended to the registry rather than appended to the end, this order is the best
|
||||
* way to search through the registry if you want to discover newer items first.
|
||||
*/
|
||||
public Iterator<V> iterator() {
|
||||
return _entries.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator that iterates over each entry in this registry, in the order they were added. Internally,
|
||||
* this iterates through the registry backwards, as new elements are prepended to the registry rather than appended
|
||||
* to the end. You should only do this when you need to, for example, list elements in order - it is almost always
|
||||
* fine to simply use {@link Iterable#forEach(Consumer) forEach} on the {@link #entries} collection instead.
|
||||
*/
|
||||
public Iterator<V> descendingIterator() {
|
||||
return _entries.descendingIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream that contains each entry in this registry, with the newest elements ordered first. Internally,
|
||||
* as new elements are prepended to the registry rather than appended to the end, this order is the best way to
|
||||
* search through the registry if you want to discover newer items first.
|
||||
*/
|
||||
public Stream<V> stream() {
|
||||
return _entries.stream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream that returns each entry in this registry, in the order they were added. Internally, this orders
|
||||
* the registry backwards, as new elements are prepended to the registry rather than appended to the end. You should
|
||||
* only use this when you need to, for example, list elements in order - it is almost always fine to simply use the
|
||||
* regular {@link #stream()} method instead.
|
||||
*/
|
||||
public Stream<V> descendingStream() {
|
||||
return StreamSupport.stream(Spliterators.spliterator(
|
||||
descendingIterator(),
|
||||
_entries.size(),
|
||||
Spliterator.SIZED | Spliterator.SUBSIZED
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.IPacket;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -31,9 +31,9 @@ public final class PacketEvent {
|
||||
|
||||
private final EventState state;
|
||||
|
||||
private final Packet<?> packet;
|
||||
private final IPacket<?> packet;
|
||||
|
||||
public PacketEvent(NetworkManager networkManager, EventState state, Packet<?> packet) {
|
||||
public PacketEvent(NetworkManager networkManager, EventState state, IPacket<?> packet) {
|
||||
this.networkManager = networkManager;
|
||||
this.state = state;
|
||||
this.packet = packet;
|
||||
@@ -47,12 +47,12 @@ public final class PacketEvent {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public final Packet<?> getPacket() {
|
||||
public final IPacket<?> getPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends Packet<?>> T cast() {
|
||||
public final <T extends IPacket<?>> T cast() {
|
||||
return (T) this.packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -76,7 +75,7 @@ public final class RotationMoveEvent {
|
||||
/**
|
||||
* Called when the player jumps.
|
||||
*
|
||||
* @see EntityLivingBase#jump
|
||||
* @see LivingEntity#jump
|
||||
*/
|
||||
JUMP
|
||||
}
|
||||
|
||||
35
src/api/java/baritone/api/event/events/TabCompleteEvent.java
Normal file
35
src/api/java/baritone/api/event/events/TabCompleteEvent.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
import baritone.api.event.events.type.Overrideable;
|
||||
|
||||
/**
|
||||
* @author LoganDark
|
||||
*/
|
||||
public final class TabCompleteEvent extends Cancellable {
|
||||
|
||||
public final String prefix;
|
||||
public String[] completions;
|
||||
|
||||
public TabCompleteEvent(String prefix) {
|
||||
this.prefix = prefix;
|
||||
this.completions = null;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -29,14 +29,14 @@ public final class WorldEvent {
|
||||
/**
|
||||
* The new world that is being loaded. {@code null} if being unloaded.
|
||||
*/
|
||||
private final WorldClient world;
|
||||
private final ClientWorld world;
|
||||
|
||||
/**
|
||||
* The state of the event
|
||||
*/
|
||||
private final EventState state;
|
||||
|
||||
public WorldEvent(WorldClient world, EventState state) {
|
||||
public WorldEvent(ClientWorld world, EventState state) {
|
||||
this.world = world;
|
||||
this.state = state;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public final class WorldEvent {
|
||||
/**
|
||||
* @return The new world that is being loaded. {@code null} if being unloaded.
|
||||
*/
|
||||
public final WorldClient getWorld() {
|
||||
public final ClientWorld getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.event.events.type;
|
||||
|
||||
/**
|
||||
* @author LoganDark
|
||||
*/
|
||||
public class Overrideable<T> {
|
||||
|
||||
private T value;
|
||||
private boolean modified;
|
||||
|
||||
public Overrideable(T current) {
|
||||
value = current;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void set(T newValue) {
|
||||
value = newValue;
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public boolean wasModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"Overrideable{modified=%b,value=%s}",
|
||||
modified,
|
||||
value.toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,9 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
||||
@Override
|
||||
default void onSendChatMessage(ChatEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onPreTabComplete(TabCompleteEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onChunkEvent(ChunkEvent event) {}
|
||||
|
||||
|
||||
@@ -18,14 +18,12 @@
|
||||
package baritone.api.event.listener;
|
||||
|
||||
import baritone.api.event.events.*;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
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.settings.GameSettings;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.DeathScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -45,7 +43,7 @@ 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()
|
||||
* @see ClientPlayerEntity#tick()
|
||||
*/
|
||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||
|
||||
@@ -53,22 +51,26 @@ public interface IGameEventListener {
|
||||
* Runs whenever the client player sends a message to the server.
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#sendChatMessage(String)
|
||||
* @see ClientPlayerEntity#sendChatMessage(String)
|
||||
*/
|
||||
void onSendChatMessage(ChatEvent event);
|
||||
|
||||
/**
|
||||
* Runs whenever the client player tries to tab complete in chat.
|
||||
*
|
||||
* @param event The event
|
||||
*/
|
||||
void onPreTabComplete(TabCompleteEvent event);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Runs once per world render pass. Two passes are made when {@link GameSettings#anaglyph} is on.
|
||||
* <p>
|
||||
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
|
||||
* Runs once per world render pass.
|
||||
*
|
||||
* @param event The event
|
||||
*/
|
||||
@@ -78,7 +80,7 @@ public interface IGameEventListener {
|
||||
* Runs before and after whenever a new world is loaded
|
||||
*
|
||||
* @param event The event
|
||||
* @see Minecraft#loadWorld(WorldClient, String)
|
||||
* @see Minecraft#loadWorld(ClientWorld, Screen)
|
||||
*/
|
||||
void onWorldEvent(WorldEvent event);
|
||||
|
||||
@@ -87,7 +89,6 @@ public interface IGameEventListener {
|
||||
*
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see GenericFutureListener
|
||||
*/
|
||||
void onSendPacket(PacketEvent event);
|
||||
|
||||
@@ -96,7 +97,6 @@ public interface IGameEventListener {
|
||||
*
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see GenericFutureListener
|
||||
*/
|
||||
void onReceivePacket(PacketEvent event);
|
||||
|
||||
@@ -110,10 +110,10 @@ public interface IGameEventListener {
|
||||
void onPlayerRotationMove(RotationMoveEvent event);
|
||||
|
||||
/**
|
||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate}
|
||||
* Called whenever the sprint keybind state is checked in {@link ClientPlayerEntity#livingTick}
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#onLivingUpdate()
|
||||
* @see ClientPlayerEntity#livingTick()
|
||||
*/
|
||||
void onPlayerSprintState(SprintStateEvent event);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GoalAxis implements Goal {
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
|
||||
return y == BaritoneAPI.getSettings().axisHeight.value && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +39,7 @@ public class GoalAxis implements Goal {
|
||||
|
||||
double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2));
|
||||
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y);
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -30,17 +31,17 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
/**
|
||||
* The X block position of this goal
|
||||
*/
|
||||
private final int x;
|
||||
public final int x;
|
||||
|
||||
/**
|
||||
* The Y block position of this goal
|
||||
*/
|
||||
private final int y;
|
||||
public final int y;
|
||||
|
||||
/**
|
||||
* The Z block position of this goal
|
||||
*/
|
||||
private final int z;
|
||||
public final int z;
|
||||
|
||||
public GoalBlock(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
@@ -67,7 +68,12 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalBlock{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -28,9 +29,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public GoalGetToBlock(BlockPos pos) {
|
||||
this.x = pos.getX();
|
||||
@@ -61,6 +62,11 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalGetToBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalGetToBlock{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
52
src/api/java/baritone/api/pathing/goals/GoalInverted.java
Normal file
52
src/api/java/baritone/api/pathing/goals/GoalInverted.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.pathing.goals;
|
||||
|
||||
/**
|
||||
* Invert any goal.
|
||||
* <p>
|
||||
* In the old chat control system, #invert just tried to pick a {@link GoalRunAway} that <i>effectively</i> inverted the
|
||||
* current goal. This goal just reverses the heuristic to act as a TRUE invert. Inverting a Y level? Baritone tries to
|
||||
* get away from that Y level. Inverting a GoalBlock? Baritone will try to make distance whether it's in the X, Y or Z
|
||||
* directions. And of course, you can always invert a GoalXZ.
|
||||
*
|
||||
* @author LoganDark
|
||||
*/
|
||||
public class GoalInverted implements Goal {
|
||||
|
||||
public final Goal origin;
|
||||
|
||||
public GoalInverted(Goal origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {
|
||||
return -origin.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("GoalInverted{%s}", origin.toString());
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,12 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
@@ -56,11 +58,12 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalNear{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", rangeSq=" + rangeSq +
|
||||
'}';
|
||||
return String.format(
|
||||
"GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z),
|
||||
rangeSq
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -82,7 +83,11 @@ public class GoalRunAway implements Goal {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (maintainY != null) {
|
||||
return "GoalRunAwayFromMaintainY y=" + maintainY + ", " + Arrays.asList(from);
|
||||
return String.format(
|
||||
"GoalRunAwayFromMaintainY y=%s, %s",
|
||||
SettingsUtil.maybeCensor(maintainY),
|
||||
Arrays.asList(from)
|
||||
);
|
||||
} else {
|
||||
return "GoalRunAwayFrom" + Arrays.asList(from);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
|
||||
*/
|
||||
public class GoalStrictDirection implements Goal {
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final int dx;
|
||||
public final int dz;
|
||||
|
||||
public GoalStrictDirection(BlockPos origin, Direction direction) {
|
||||
x = origin.getX();
|
||||
y = origin.getY();
|
||||
z = origin.getZ();
|
||||
dx = direction.getXOffset();
|
||||
dz = direction.getZOffset();
|
||||
if (dx == 0 && dz == 0) {
|
||||
throw new IllegalArgumentException(direction + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {
|
||||
int distanceFromStartInDesiredDirection = (x - this.x) * dx + (z - this.z) * dz;
|
||||
|
||||
int distanceFromStartInIncorrectDirection = Math.abs((x - this.x) * dz) + Math.abs((z - this.z) * dx);
|
||||
|
||||
int verticalDistanceFromStart = Math.abs(y - this.y);
|
||||
|
||||
// we want heuristic to decrease as desiredDirection increases
|
||||
double heuristic = -distanceFromStartInDesiredDirection * 100;
|
||||
|
||||
heuristic += distanceFromStartInIncorrectDirection * 1000;
|
||||
heuristic += verticalDistanceFromStart * 1000;
|
||||
return heuristic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z),
|
||||
SettingsUtil.maybeCensor(dx),
|
||||
SettingsUtil.maybeCensor(dz)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -31,17 +32,17 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
/**
|
||||
* The X block position of this goal
|
||||
*/
|
||||
private final int x;
|
||||
protected final int x;
|
||||
|
||||
/**
|
||||
* The Y block position of this goal
|
||||
*/
|
||||
private final int y;
|
||||
protected final int y;
|
||||
|
||||
/**
|
||||
* The Z block position of this goal
|
||||
*/
|
||||
private final int z;
|
||||
protected final int z;
|
||||
|
||||
public GoalTwoBlocks(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
@@ -73,6 +74,11 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalTwoBlocks{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalTwoBlocks{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -45,6 +47,11 @@ public class GoalXZ implements Goal {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public GoalXZ(BetterBlockPos pos) {
|
||||
this.x = pos.x;
|
||||
this.z = pos.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return x == this.x && z == this.z;
|
||||
@@ -59,7 +66,11 @@ public class GoalXZ implements Goal {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalXZ{x=" + x + ",z=" + z + "}";
|
||||
return String.format(
|
||||
"GoalXZ{x=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
|
||||
public static double calculate(double xDiff, double zDiff) {
|
||||
@@ -80,14 +91,14 @@ public class GoalXZ implements Goal {
|
||||
diagonal = z;
|
||||
}
|
||||
diagonal *= SQRT_2;
|
||||
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune
|
||||
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune
|
||||
}
|
||||
|
||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||
float theta = (float) Math.toRadians(yaw);
|
||||
double x = origin.x - MathHelper.sin(theta) * distance;
|
||||
double z = origin.z + MathHelper.cos(theta) * distance;
|
||||
return new GoalXZ((int) x, (int) z);
|
||||
return new GoalXZ(MathHelper.floor(x), MathHelper.floor(z));
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
/**
|
||||
* Useful for mining (getting to diamond / iron level)
|
||||
@@ -29,7 +30,7 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
/**
|
||||
* The target Y level
|
||||
*/
|
||||
private final int level;
|
||||
public final int level;
|
||||
|
||||
public GoalYLevel(int level) {
|
||||
this.level = level;
|
||||
@@ -59,6 +60,9 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalYLevel{y=" + level + "}";
|
||||
return String.format(
|
||||
"GoalYLevel{y=%s}",
|
||||
SettingsUtil.maybeCensor(level)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,6 @@ public interface IMovement {
|
||||
*/
|
||||
boolean safeToCancel();
|
||||
|
||||
double recalculateCost();
|
||||
|
||||
double calculateCostWithoutCaching();
|
||||
|
||||
boolean calculatedWhileLoaded();
|
||||
|
||||
BetterBlockPos getSrc();
|
||||
|
||||
@@ -35,6 +35,16 @@ import baritone.api.event.events.PathEvent;
|
||||
*/
|
||||
public interface IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Default priority. Most normal processes should have this value.
|
||||
* <p>
|
||||
* Some examples of processes that should have different values might include some kind of automated mob avoidance
|
||||
* that would be temporary and would forcefully take control. Same for something that pauses pathing for auto eat, etc.
|
||||
* <p>
|
||||
* The value is -1 beacuse that's what Impact 4.5's beta auto walk returns and I want to tie with it.
|
||||
*/
|
||||
double DEFAULT_PRIORITY = -1;
|
||||
|
||||
/**
|
||||
* Would this process like to be in control?
|
||||
*
|
||||
@@ -82,12 +92,23 @@ public interface IBaritoneProcess {
|
||||
*
|
||||
* @return A double representing the priority
|
||||
*/
|
||||
double priority();
|
||||
default double priority() {
|
||||
return DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user-friendly name for this process. Suitable for a HUD.
|
||||
*
|
||||
* @return A display name that's suitable for a HUD
|
||||
*/
|
||||
String displayName();
|
||||
default String displayName() {
|
||||
if (!isActive()) {
|
||||
// i love it when impcat's scuffed HUD calls displayName for inactive processes for 1 tick too long
|
||||
// causing NPEs when the displayname relies on fields that become null when inactive
|
||||
return "INACTIVE";
|
||||
}
|
||||
return displayName0();
|
||||
}
|
||||
|
||||
String displayName0();
|
||||
}
|
||||
|
||||
75
src/api/java/baritone/api/process/IBuilderProcess.java
Normal file
75
src/api/java/baritone/api/process/IBuilderProcess.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 1/15/2019
|
||||
*/
|
||||
public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
|
||||
*
|
||||
* @param name A user-friendly name for the schematic
|
||||
* @param schematic The object representation of the schematic
|
||||
* @param origin The origin position of the schematic being built
|
||||
*/
|
||||
void build(String name, ISchematic schematic, Vec3i origin);
|
||||
|
||||
/**
|
||||
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
|
||||
*
|
||||
* @param name A user-friendly name for the schematic
|
||||
* @param schematic The file path of the schematic
|
||||
* @param origin The origin position of the schematic being built
|
||||
* @return Whether or not the schematic was able to load from file
|
||||
*/
|
||||
boolean build(String name, File schematic, Vec3i origin);
|
||||
|
||||
default boolean build(String schematicFile, BlockPos origin) {
|
||||
File file = new File(new File(Minecraft.getInstance().gameDir, "schematics"), schematicFile);
|
||||
return build(schematicFile, file, origin);
|
||||
}
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void pause();
|
||||
|
||||
boolean isPaused();
|
||||
|
||||
void resume();
|
||||
|
||||
void clearArea(BlockPos corner1, BlockPos corner2);
|
||||
|
||||
/**
|
||||
* @return A list of block states that are estimated to be placeable by this builder process. You can use this in
|
||||
* schematics, for example, to pick a state that the builder process will be happy with, because any variation will
|
||||
* cause it to give up. This is updated every tick, but only while the builder process is active.
|
||||
*/
|
||||
List<BlockState> getApproxPlaceable();
|
||||
}
|
||||
27
src/api/java/baritone/api/process/IExploreProcess.java
Normal file
27
src/api/java/baritone/api/process/IExploreProcess.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IExploreProcess extends IBaritoneProcess {
|
||||
|
||||
void explore(int centerX, int centerZ);
|
||||
|
||||
void applyJsonFilter(Path path, boolean invert) throws Exception;
|
||||
}
|
||||
23
src/api/java/baritone/api/process/IFarmProcess.java
Normal file
23
src/api/java/baritone/api/process/IFarmProcess.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
public interface IFarmProcess extends IBaritoneProcess {
|
||||
|
||||
void farm();
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
@@ -24,5 +25,11 @@ import net.minecraft.block.Block;
|
||||
*/
|
||||
public interface IGetToBlockProcess extends IBaritoneProcess {
|
||||
|
||||
void getToBlock(Block block);
|
||||
void getToBlock(BlockOptionalMeta block);
|
||||
|
||||
default void getToBlock(Block block) {
|
||||
getToBlock(new BlockOptionalMeta(block));
|
||||
}
|
||||
|
||||
boolean blacklistClosest();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user