Compare commits
364 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7487b90d50 | ||
|
|
09554ab39d | ||
|
|
2ae7bc6a64 | ||
|
|
6979bd6971 | ||
|
|
b2bd025896 | ||
|
|
666a890088 | ||
|
|
b389b573e5 | ||
|
|
eb28298983 | ||
|
|
336b2c2798 | ||
|
|
63d0064d69 | ||
|
|
43eb4e3581 | ||
|
|
7bb311687b | ||
|
|
d1a55c43e1 | ||
|
|
63e3dfc9b8 | ||
|
|
6db376c02e | ||
|
|
a1e797ab53 | ||
|
|
fe64f1fd8a | ||
|
|
7a5c4f1f03 | ||
|
|
787644181a | ||
|
|
7b60943714 | ||
|
|
7879b6909a | ||
|
|
9898e0da26 | ||
|
|
5841bd4e36 | ||
|
|
81e9865067 | ||
|
|
f9d563b9e6 | ||
|
|
3e3312f009 | ||
|
|
327fbc868e | ||
|
|
6d5cfe4187 | ||
|
|
d3e0da7c5e | ||
|
|
38fbc127e6 | ||
|
|
25ef38aaf2 | ||
|
|
d05d5fd98e | ||
|
|
698d40d797 | ||
|
|
2b6c59fa8a | ||
|
|
21bc830143 | ||
|
|
432d42ade8 | ||
|
|
aa9206381d | ||
|
|
d6d9af65fb | ||
|
|
a3f70e7977 | ||
|
|
0057f093db | ||
|
|
6bbdba7a21 | ||
|
|
6a175379fb | ||
|
|
7677ed8240 | ||
|
|
85c21fa8e3 | ||
|
|
bc8c823045 | ||
|
|
9935da8a6f | ||
|
|
c39b6c3fe7 | ||
|
|
c47a6f92c5 | ||
|
|
778628da30 | ||
|
|
ba0ca0cc65 | ||
|
|
fba3828479 | ||
|
|
c8dd4f26f7 | ||
|
|
16a62625b3 | ||
|
|
de5f6d5fce | ||
|
|
98a87d099b | ||
|
|
a6f3c95684 | ||
|
|
75e39e7ef5 | ||
|
|
77b2b26a7a | ||
|
|
1680eeb80d | ||
|
|
9a9b4a1874 | ||
|
|
0e1fee352f | ||
|
|
1136494fc6 | ||
|
|
9b3e5cb444 | ||
|
|
f13dc16af5 | ||
|
|
145a944860 | ||
|
|
dd127ff3e7 | ||
|
|
b0fb474e1d | ||
|
|
a1a94ec0d1 | ||
|
|
678f8bc77f | ||
|
|
41968546d1 | ||
|
|
b51b78f4e4 | ||
|
|
f76283ebfe | ||
|
|
7ad1a2dac7 | ||
|
|
e59bf9ab97 | ||
|
|
b2f66241d5 | ||
|
|
fd55e455a1 | ||
|
|
e7e25abc0b | ||
|
|
cfdbc851a0 | ||
|
|
6ccebdc978 | ||
|
|
4bc9884a95 | ||
|
|
df53040339 | ||
|
|
42dc5b14b0 | ||
|
|
e2538abcb1 | ||
|
|
1697293f12 | ||
|
|
0e35a3e62b | ||
|
|
d60e1e8a05 | ||
|
|
1112feff5b | ||
|
|
967dc6cbd6 | ||
|
|
2ce60fbb79 | ||
|
|
35b7c48430 | ||
|
|
d157756d94 | ||
|
|
ea1914a248 | ||
|
|
85087ce04a | ||
|
|
e09127eadf | ||
|
|
db842445f6 | ||
|
|
3a8d438d7c | ||
|
|
386caf5d1e | ||
|
|
f7f0c84407 | ||
|
|
75cd4600a0 | ||
|
|
e6642a2122 | ||
|
|
e7252f5b3f | ||
|
|
4168401aa1 | ||
|
|
3e082b21d5 | ||
|
|
85790c0b2f | ||
|
|
e1095962a1 | ||
|
|
eabd1150b0 | ||
|
|
c20d40f8dd | ||
|
|
4fa43ce201 | ||
|
|
f51f835b11 | ||
|
|
93501248cd | ||
|
|
3a945c8c10 | ||
|
|
54f6851dd9 | ||
|
|
3cef7a7911 | ||
|
|
1cd2fb5b18 | ||
|
|
ba3ca47f8c | ||
|
|
98763271a4 | ||
|
|
063842edc4 | ||
|
|
2453a4a4f1 | ||
|
|
5a8adc5344 | ||
|
|
8b94ac8fca | ||
|
|
c1e12b8746 | ||
|
|
44c1438541 | ||
|
|
c2a857f4d6 | ||
|
|
9d620f8137 | ||
|
|
7c2327b743 | ||
|
|
d91abd5e45 | ||
|
|
4699b46744 | ||
|
|
8f514bd782 | ||
|
|
69ffdb7665 | ||
|
|
f9c5386e7a | ||
|
|
ec2941bede | ||
|
|
55273b5340 | ||
|
|
5b37b68363 | ||
|
|
04f5ca2647 | ||
|
|
5cd1c9d15d | ||
|
|
b461b2af2f | ||
|
|
3a5608566e | ||
|
|
fc65f22feb | ||
|
|
f53bfa89a9 | ||
|
|
fdfeeb2ffa | ||
|
|
3e75cc7408 | ||
|
|
d1930e03e1 | ||
|
|
144a534bb3 | ||
|
|
de1256cc80 | ||
|
|
76404c8af6 | ||
|
|
fb814e912d | ||
|
|
43ee86b4fe | ||
|
|
eb697b7a17 | ||
|
|
3da5bbd267 | ||
|
|
c14be17e53 | ||
|
|
45c0b38156 | ||
|
|
025f6235f9 | ||
|
|
4ba3c883e6 | ||
|
|
3a4168a661 | ||
|
|
484b3326c7 | ||
|
|
e99fcbbe36 | ||
|
|
7ba3de57d0 | ||
|
|
5ff274f040 | ||
|
|
293f5db172 | ||
|
|
d928e705b9 | ||
|
|
7a48824ced | ||
|
|
8aa8918124 | ||
|
|
a091c17b83 | ||
|
|
52aa0d9b8a | ||
|
|
3d8eddc4e1 | ||
|
|
295265c261 | ||
|
|
376d6422ec | ||
|
|
113e340474 | ||
|
|
c89d8b69e5 | ||
|
|
70303634f5 | ||
|
|
325aa7201b | ||
|
|
75a3fc699e | ||
|
|
3cd8ce8323 | ||
|
|
240e81a9e0 | ||
|
|
40449400d3 | ||
|
|
bf43fd1274 | ||
|
|
cd7c504c76 | ||
|
|
96ba589d4d | ||
|
|
9ffe4f2c25 | ||
|
|
af95f77134 | ||
|
|
8803c618b1 | ||
|
|
78f1c45e13 | ||
|
|
287addb9fd | ||
|
|
cf47573298 | ||
|
|
96ba96ca69 | ||
|
|
da998eb469 | ||
|
|
e75a4b95cc | ||
|
|
d1a0f1e3ca | ||
|
|
344085f4ef | ||
|
|
52d077de49 | ||
|
|
b1f35e93dc | ||
|
|
076326dcc3 | ||
|
|
b1b8288d05 | ||
|
|
df62427fee | ||
|
|
61b9762a22 | ||
|
|
d37a6a0b2d | ||
|
|
d7fc916d20 | ||
|
|
06be5f5372 | ||
|
|
80a4757242 | ||
|
|
658048ff2d | ||
|
|
0587223da8 | ||
|
|
2d1b81dc20 | ||
|
|
0bd16fb81a | ||
|
|
0c1fec5d1e | ||
|
|
ee16eb7fde | ||
|
|
5c9aeab6b4 | ||
|
|
5c7cae9ab0 | ||
|
|
93fa6cf875 | ||
|
|
5b7bee977b | ||
|
|
8018dac396 | ||
|
|
85ab317c6c | ||
|
|
6b0fb1721b | ||
|
|
fdcdcbb85f | ||
|
|
4e2095d251 | ||
|
|
51275b3a65 | ||
|
|
8d480cefb9 | ||
|
|
3e7f9039c4 | ||
|
|
49828baae3 | ||
|
|
348b02e4f8 | ||
|
|
a73e1185dc | ||
|
|
441dceb731 | ||
|
|
57c4f9e103 | ||
|
|
2741fc2683 | ||
|
|
fcd20b10f1 | ||
|
|
82f184c848 | ||
|
|
fd43dace70 | ||
|
|
a475f522ef | ||
|
|
e6cc9b1131 | ||
|
|
347027a8e0 | ||
|
|
868c023dbd | ||
|
|
e7c357ab7f | ||
|
|
f204fbb08e | ||
|
|
9e1a5008ed | ||
|
|
606f9c55a8 | ||
|
|
f2a11df616 | ||
|
|
5773da36bd | ||
|
|
86303ed495 | ||
|
|
2b4da2a46c | ||
|
|
f699be7973 | ||
|
|
ed381d6b33 | ||
|
|
1caa99fee3 | ||
|
|
4a042510d8 | ||
|
|
ffbe683e86 | ||
|
|
4dba5a4399 | ||
|
|
8cfdcbdc9e | ||
|
|
59b3fe7c3a | ||
|
|
6e37221b3c | ||
|
|
b54ddeadf4 | ||
|
|
caa88c5b60 | ||
|
|
1b3139c99a | ||
|
|
3d95f0ad65 | ||
|
|
0df45a89be | ||
|
|
b0266cd14b | ||
|
|
9bf40dd60b | ||
|
|
a6557121a0 | ||
|
|
2dad6262cf | ||
|
|
af1eb58bb8 | ||
|
|
56b44496bf | ||
|
|
3df451677c | ||
|
|
9e021d2875 | ||
|
|
db9ee98762 | ||
|
|
4e0a507ba0 | ||
|
|
7d39aacd72 | ||
|
|
a8ae8a6171 | ||
|
|
9c99333759 | ||
|
|
17a2aa42e9 | ||
|
|
231f671400 | ||
|
|
ec6ffb0f53 | ||
|
|
221eba11dd | ||
|
|
ad40a9225e | ||
|
|
1544b09c82 | ||
|
|
1d08b3e729 | ||
|
|
8a150568ec | ||
|
|
00b20b2158 | ||
|
|
25e8e1b5fe | ||
|
|
bf7c840ea3 | ||
|
|
78a5838aa1 | ||
|
|
cbef05838d | ||
|
|
d0d74b1591 | ||
|
|
056107a356 | ||
|
|
93a16f356d | ||
|
|
070083dc9b | ||
|
|
4dcf260059 | ||
|
|
2cf973809a | ||
|
|
65974e15ba | ||
|
|
e885d2c221 | ||
|
|
fe61a404d6 | ||
|
|
97ac4bbd4f | ||
|
|
dd29b72295 | ||
|
|
23fa65cee0 | ||
|
|
af646bd313 | ||
|
|
c3c88c50d1 | ||
|
|
16f93ce769 | ||
|
|
3cee66229a | ||
|
|
88c00f2fec | ||
|
|
394b4fd5b8 | ||
|
|
48b34bfbb8 | ||
|
|
4b2d1fe6b0 | ||
|
|
01c75db38a | ||
|
|
adc88d1fb9 | ||
|
|
2908c7499c | ||
|
|
ef4c2bbc98 | ||
|
|
dc6b32a154 | ||
|
|
76f593e4bb | ||
|
|
15b991a48e | ||
|
|
f3c93855bb | ||
|
|
f033230548 | ||
|
|
702d0790bc | ||
|
|
599aa42cd8 | ||
|
|
95afaf3eac | ||
|
|
2953e2c522 | ||
|
|
bf450b7d68 | ||
|
|
4e6b6d97ce | ||
|
|
17b2245033 | ||
|
|
7b7c49d7ad | ||
|
|
1522d11df0 | ||
|
|
7eecf69178 | ||
|
|
6aadd00e72 | ||
|
|
e036f5360c | ||
|
|
384dfb5f46 | ||
|
|
8c2aae2ddc | ||
|
|
89bd2a4a07 | ||
|
|
511941c714 | ||
|
|
e58220e2c4 | ||
|
|
477e3a706b | ||
|
|
9ba8949a2e | ||
|
|
9b7d3af03d | ||
|
|
02711a73ed | ||
|
|
25d418e96b | ||
|
|
10430f8142 | ||
|
|
8aba97b577 | ||
|
|
8a0771e5f4 | ||
|
|
9c6c977314 | ||
|
|
8fe5b2369a | ||
|
|
dc6c87b58d | ||
|
|
ef4e19002b | ||
|
|
e6ee5fc6b8 | ||
|
|
38c5388e00 | ||
|
|
519a76a171 | ||
|
|
eefc98a68e | ||
|
|
d0dc8cf726 | ||
|
|
b19c935da1 | ||
|
|
0ade37f14f | ||
|
|
91be4c4643 | ||
|
|
d2b62e2d21 | ||
|
|
267961434c | ||
|
|
0bfe98d306 | ||
|
|
bfa644e7a7 | ||
|
|
0ef1558803 | ||
|
|
9dad1af960 | ||
|
|
407f4dbbae | ||
|
|
7052fe6225 | ||
|
|
49357790f1 | ||
|
|
694219e497 | ||
|
|
af240d38e0 | ||
|
|
9b70ace180 | ||
|
|
a3dbec62dc | ||
|
|
e0a53144db | ||
|
|
fe26168a07 | ||
|
|
25de332492 | ||
|
|
2d0f10c79f | ||
|
|
74ea803651 | ||
|
|
21534d1c0b | ||
|
|
bb91dc98de |
26
.github/workflows/gradle_build.yml
vendored
26
.github/workflows/gradle_build.yml
vendored
@@ -13,33 +13,31 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)"
|
||||
|
||||
- name: Build (fabric) with Gradle
|
||||
run: ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
- name: Build (forge) with Gradle
|
||||
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: dist/
|
||||
|
||||
- name: Archive mapping.txt
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Mappings
|
||||
path: build/tmp/proguard/mapping.txt
|
||||
path: mapping/
|
||||
|
||||
8
.github/workflows/run_tests.yml
vendored
8
.github/workflows/run_tests.yml
vendored
@@ -11,16 +11,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Executing tests
|
||||
run: ./gradlew test
|
||||
|
||||
|
||||
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -21,6 +21,9 @@ classes/
|
||||
*.iws
|
||||
/logs/
|
||||
|
||||
tweaker/logs/
|
||||
common/logs/
|
||||
|
||||
# Eclipse Files
|
||||
.classpath
|
||||
.project
|
||||
@@ -32,3 +35,6 @@ baritone_Client.launch
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
|
||||
.vscode/launch.json
|
||||
.architectury-transformer
|
||||
|
||||
mapping
|
||||
@@ -13,5 +13,3 @@ COPY . /code
|
||||
WORKDIR /code
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
RUN ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
30
README.md
30
README.md
@@ -4,20 +4,20 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.13.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.14.4-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.15.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.18.1-brightgreen.svg" alt="Minecraft"/>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/master"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.13.2"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.14.4"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.15.2"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.16.5"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.17.1"><img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/tree/1.18.2"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
|
||||
<a href="https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400" alt="Codacy Badge"/></a>
|
||||
<a href="https://www.codacy.com/gh/cabaletta/baritone/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/cadab857dab049438b6e28b3cfc5570e" alt="Codacy Badge"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat" alt="Code of Conduct"/></a>
|
||||
<a href="https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle"><img src="https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle" alt="Known Vulnerabilities"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="Contributions welcome"/></a>
|
||||
@@ -50,17 +50,19 @@ A Minecraft pathfinder bot.
|
||||
|
||||
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) 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.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
|
||||
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar.
|
||||
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.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click
|
||||
[here](https://github.com/cabaletta/baritone/releases/download/v1.2.17/baritone-api-forge-1.2.17.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
|
||||
|
||||
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**.
|
||||
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.2/baritone-api-fabric-1.7.2.jar)**.
|
||||
|
||||
If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**.
|
||||
If you need Forge or Fabric 1.18.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.3) and get the `api-forge` or `api-fabric` jar. **For 1.18.2 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-fabric-1.8.3.jar)**. **For 1.18.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-forge-1.8.3.jar)**.
|
||||
|
||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. 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).
|
||||
@@ -95,7 +97,7 @@ jar.
|
||||
|
||||
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
|
||||
|
||||
```
|
||||
```java
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
||||
|
||||
|
||||
21
SETUP.md
21
SETUP.md
@@ -11,7 +11,7 @@ These releases are not always completely up to date with latest features, and ar
|
||||
|
||||
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, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL)
|
||||
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.5, v1.7.* is for 1.17.1, v1.8.* is for 1.18.1
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.
|
||||
|
||||
@@ -22,15 +22,16 @@ The build is fully deterministic and reproducible, and you can verify Travis did
|
||||
|
||||
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.**
|
||||
**The Forge and Fabric releases can simply be added as a Forge/Fabric mods.**
|
||||
|
||||
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.
|
||||
- **Forge/Fabric API**: Same as API, but packaged for Forge/Fabric. 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.
|
||||
- **Forge/Fabric Standalone**: Same as Standalone, but packaged for Forge/Fabric. This should be used when Baritone is your only Forge/Fabric mod, or none of your other Forge/Fabric mods integrate with Baritone.
|
||||
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
||||
- **Forge/Fabric Unoptimized**: Same as Unoptimized, but packaged for Forge/Fabric.
|
||||
|
||||
## Build it yourself
|
||||
- Clone or download Baritone
|
||||
@@ -42,13 +43,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone
|
||||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
|
||||
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8.
|
||||
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16 for 1.17.1, and JDK 17 for 1.18.1.
|
||||
|
||||
To check which java you are using do
|
||||
`java -version` in a command prompt or terminal.
|
||||
If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
|
||||
If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
|
||||
|
||||
Open JDK 8 download: https://openjdk.java.net/install/
|
||||
Open JDK download: https://openjdk.java.net/install/
|
||||
#### macOS guide
|
||||
In order to get JDK 8, Try running the following command:
|
||||
`% /usr/libexec/java_home -V`
|
||||
@@ -84,6 +85,12 @@ For minecraft 1.15.2+, run the following instead to include the Forge jars:
|
||||
$ gradlew build -Pbaritone.forge_build
|
||||
```
|
||||
|
||||
Do this instead for Fabric jars:
|
||||
|
||||
```
|
||||
$ gradlew build -Pbaritone.fabric_build
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
|
||||
16
USAGE.md
16
USAGE.md
@@ -32,13 +32,13 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
|
||||
|
||||
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:
|
||||
Commands in Baritone:
|
||||
- `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
|
||||
- `cancel` or `stop` to stop everything, `forcecancel` is also an option
|
||||
- `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 64 diamond_ore`.
|
||||
- `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 select an area (`#help sel` to see what you can do with that selection).
|
||||
@@ -51,11 +51,19 @@ Some common examples:
|
||||
- `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.
|
||||
- `come` tells Baritone to head towards your camera, useful when freecam doesn't move your player position.
|
||||
- `blacklist` will stop baritone from going to the closest block so it won't attempt to get to it.
|
||||
- `eta` to get information about the estimated time until the next segment and the goal, be aware that the ETA to your goal is really unprecise.
|
||||
- `proc` to view miscellaneous information about the process currently controlling Baritone.
|
||||
- `repack` to re-cache the chunks around you.
|
||||
- `gc` to call `System.gc()` which may free up some memory.
|
||||
- `render` to fix glitched chunk rendering without having to reload all of them.
|
||||
- `reloadall` to reload Baritone's world cache or `saveall` to save Baritone's world cache.
|
||||
- `find` to search through Baritone's cache and attempt to find the location of the block.
|
||||
- `surface` or `top` to tell Baritone to head towards the closest surface-like area, this can be the surface or highest available air space.
|
||||
- `version` to get the version of Baritone you're running
|
||||
- `damn` daniel
|
||||
|
||||
For the rest of the commands, you can take a look at the code [here](https://baritone.leijurv.com/baritone/api/Settings.html).
|
||||
|
||||
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.
|
||||
|
||||
218
build.gradle
218
build.gradle
@@ -15,34 +15,89 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
allprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: "xyz.wagyourtail.unimined"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
|
||||
if (!vers.startsWith("v")) {
|
||||
println "git doesn't appear to be installed!"
|
||||
println "using version number: " + rootProject.mod_version
|
||||
version = rootProject.mod_version
|
||||
} else {
|
||||
version = vers.substring(1)
|
||||
}
|
||||
group = rootProject.maven_group
|
||||
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
name = 'fabric-maven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
name = "ldtteam"
|
||||
url = "https://maven.parchmentmc.net/"
|
||||
}
|
||||
// for the newer version of launchwrapper
|
||||
maven {
|
||||
name = "multimc-maven"
|
||||
url = "https://files.multimc.org/maven/"
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraft:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings, you may use other mappings as well
|
||||
mappings "net.fabricmc:intermediary:${rootProject.minecraft_version}:v2"
|
||||
mappings "net.minecraft:minecraft:${rootProject.minecraft_version}:client-mappings"
|
||||
mappings "org.parchmentmc.data:parchment-1.19.2:2022.11.27@zip"
|
||||
|
||||
implementation "org.spongepowered:mixin:0.8.5"
|
||||
implementation "org.ow2.asm:asm:9.3"
|
||||
// The following line declares the yarn mappings you may select this one as well.
|
||||
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
def targetVersion = 17
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
|
||||
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
minecraft {
|
||||
runs.off = true
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-common"
|
||||
|
||||
sourceSets {
|
||||
api {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += api.output
|
||||
runtimeClasspath += api.output
|
||||
}
|
||||
test {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
@@ -54,63 +109,24 @@ sourceSets {
|
||||
}
|
||||
schematica_api {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += schematica_api.output
|
||||
runtimeClasspath += schematica_api.output
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
if (compileType.equals("FORGE")) {
|
||||
forge {
|
||||
mixinConfig 'mixins.baritone.json'
|
||||
}
|
||||
}
|
||||
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
|
||||
|
||||
runs {
|
||||
client {
|
||||
source = sourceSets.launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
name = "ldtteam"
|
||||
url = "https://maven.parchmentmc.net/"
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if (compileType.equals("FORGE")) {
|
||||
forge "net.minecraftforge:forge:${project.forge_version}"
|
||||
}
|
||||
mappings loom.layered() {
|
||||
officialMojangMappings()
|
||||
//technically optional, but really helpful in dev:
|
||||
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
|
||||
}
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
if (!compileType.equals("FORGE")) {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
|
||||
}
|
||||
// this makes it compile with the forge tweak stuff
|
||||
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||
implementation('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
exclude module: 'asm-debug-all'
|
||||
}
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
jar {
|
||||
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
|
||||
}
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
remapJar {
|
||||
target = "mojmap"
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -119,72 +135,4 @@ javadoc {
|
||||
options.encoding "UTF-8" // allow emoji in comments :^)
|
||||
source = sourceSets.api.allJava
|
||||
classpath += sourceSets.api.compileClasspath
|
||||
}
|
||||
|
||||
// skidded from fabric-example-mod (comments and all)
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||
def targetVersion = 16
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jar {
|
||||
from sourceSets.launch.output, sourceSets.api.output
|
||||
|
||||
if (!getProject().hasProperty("baritone.forge_build")) {
|
||||
exclude "**/BaritoneForgeModXD.class"
|
||||
exclude "**/mods.toml"
|
||||
}
|
||||
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": version
|
||||
}
|
||||
} else {
|
||||
exclude("fabric.mod.json")
|
||||
}
|
||||
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (compileType.equals("OFFICIAL")) {
|
||||
remapJar {
|
||||
toM.set "official"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
|
||||
extract 'proguard-7.2.0-beta2/lib/proguard.jar'
|
||||
compType compileType
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
}
|
||||
@@ -16,10 +16,25 @@
|
||||
*/
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = 'WagYourMaven'
|
||||
url = 'https://maven.wagyourtail.xyz/releases'
|
||||
}
|
||||
maven {
|
||||
name = 'ForgeMaven'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'FabricMaven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
|
||||
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||
|
||||
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '0.4.10'
|
||||
}
|
||||
@@ -18,6 +18,9 @@
|
||||
package baritone.gradle.task;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -40,50 +43,56 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
PROGUARD_MAPPING_DIR = "mapping",
|
||||
|
||||
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_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
|
||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
|
||||
ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
|
||||
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
|
||||
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
protected final Path
|
||||
protected Path
|
||||
artifactPath,
|
||||
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
|
||||
proguardOut;
|
||||
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
protected String compType = null;
|
||||
|
||||
public String getCompType() {
|
||||
return compType;
|
||||
}
|
||||
|
||||
public void setCompType(String compType) {
|
||||
this.compType = compType;
|
||||
}
|
||||
|
||||
|
||||
public BaritoneGradleTask() {
|
||||
this.artifactName = getProject().getName();
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
this.artifactName = getProject().getRootProject().getProperties().get("archives_base_name").toString();
|
||||
}
|
||||
|
||||
public void doFirst() {
|
||||
if (compType != null) {
|
||||
this.artifactVersion = compType + "-" + getProject().getVersion();
|
||||
} else {
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
}
|
||||
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
|
||||
if (getProject().hasProperty("baritone.forge_build")) {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
} else if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
|
||||
} else {
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
protected void verifyArtifacts() throws IllegalStateException {
|
||||
if (!Files.exists(this.artifactPath)) {
|
||||
throw new IllegalStateException("Artifact not found! Run build first!");
|
||||
throw new IllegalStateException("Artifact not found! Run build first! Missing file: " + this.artifactPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +108,11 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
}
|
||||
|
||||
protected Path getRelativeFile(String file) {
|
||||
return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath());
|
||||
return Paths.get(new File(getProject().getBuildDir(), file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getRootRelativeFile(String file) {
|
||||
return Paths.get(new File(getProject().getRootDir(), file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getTemporaryFile(String file) {
|
||||
@@ -107,6 +120,10 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
}
|
||||
|
||||
protected Path getBuildFile(String file) {
|
||||
return getRelativeFile("build/libs/" + file);
|
||||
return getRelativeFile("libs/" + file);
|
||||
}
|
||||
|
||||
protected String addCompTypeFirst(String string) {
|
||||
return compType == null ? string : compType + "-" + string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -39,15 +41,16 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.doFirst();
|
||||
super.verifyArtifacts();
|
||||
|
||||
// Define the distribution file paths
|
||||
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||
Path api = getRootRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||
Path standalone = getRootRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||
Path unoptimized = getRootRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||
|
||||
// NIO will not automatically create directories
|
||||
Path dir = getRelativeFile("dist/");
|
||||
Path dir = getRootRelativeFile("dist/");
|
||||
if (!Files.exists(dir)) {
|
||||
Files.createDirectory(dir);
|
||||
}
|
||||
@@ -59,35 +62,21 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
|
||||
// Calculate all checksums and format them like "shasum"
|
||||
List<String> shasum = getAllDistJars().stream()
|
||||
.filter(Files::exists)
|
||||
List<String> shasum = Files.list(getRootRelativeFile("dist/"))
|
||||
.filter(e -> e.getFileName().toString().endsWith(".jar"))
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
shasum.forEach(System.out::println);
|
||||
|
||||
// Write the checksums to a file
|
||||
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
|
||||
Files.write(getRootRelativeFile("dist/checksums.txt"), shasum);
|
||||
}
|
||||
|
||||
private static String getFileName(Path p) {
|
||||
return p.getFileName().toString();
|
||||
}
|
||||
|
||||
private List<Path> getAllDistJars() {
|
||||
return Arrays.asList(
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
|
||||
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
|
||||
);
|
||||
}
|
||||
|
||||
private static synchronized String sha1(Path path) {
|
||||
try {
|
||||
if (SHA1_DIGEST == null) {
|
||||
|
||||
@@ -26,8 +26,12 @@ import org.gradle.api.tasks.TaskCollection;
|
||||
import org.gradle.api.tasks.compile.ForkOptions;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
import xyz.wagyourtail.unimined.api.Constants;
|
||||
import xyz.wagyourtail.unimined.api.minecraft.EnvType;
|
||||
import xyz.wagyourtail.unimined.api.minecraft.MinecraftProvider;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -59,22 +63,11 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
return extract;
|
||||
}
|
||||
|
||||
@Input
|
||||
private String compType;
|
||||
|
||||
public String getCompType() {
|
||||
return compType;
|
||||
}
|
||||
|
||||
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
|
||||
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.doFirst();
|
||||
super.verifyArtifacts();
|
||||
|
||||
copyMcJar();
|
||||
|
||||
// "Haha brady why don't you make separate tasks"
|
||||
processArtifact();
|
||||
downloadProguard();
|
||||
@@ -85,30 +78,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private boolean isMcJar(File f) {
|
||||
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-mapped");
|
||||
MinecraftProvider<?, ?> provider = this.getProject().getExtensions().getByType(MinecraftProvider.class);
|
||||
|
||||
private File getMcJar() {
|
||||
return provider.getMinecraftWithMapping(EnvType.COMBINED, provider.getMcPatcher().getProdNamespace(), provider.getMcPatcher().getProdNamespace()).toFile();
|
||||
}
|
||||
|
||||
private void copyMcJar() throws IOException {
|
||||
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(this::isMcJar)
|
||||
.map(f -> {
|
||||
switch (compType) {
|
||||
case "OFFICIAL":
|
||||
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
|
||||
case "FABRIC":
|
||||
return new File(f.getParentFile(), "minecraft-intermediary.jar");
|
||||
case "FORGE":
|
||||
return new File(f.getParentFile(), "minecraft-srg.jar");
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.findFirst()
|
||||
.get();
|
||||
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
|
||||
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
|
||||
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
|
||||
private boolean isMcJar(File f) {
|
||||
return this.getProject().getConfigurations().getByName(Constants.MINECRAFT_COMBINED_PROVIDER).getFiles().contains(f);
|
||||
}
|
||||
|
||||
private void processArtifact() throws Exception {
|
||||
@@ -233,18 +210,26 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
}
|
||||
|
||||
private void generateConfigs() throws Exception {
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
Files.copy(getRootRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
|
||||
// Setup the template that will be used to derive the API and Standalone configs
|
||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||
template.add(0, "-injars " + this.artifactPath.toString());
|
||||
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
|
||||
template.add(0, "-injars '" + this.artifactPath.toString() + "'");
|
||||
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
|
||||
|
||||
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
|
||||
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
|
||||
template.add(4, "-libraryjars <java.home>/jmods/jdk.unsupported.jmod(!**.jar;!module-info.class)");
|
||||
|
||||
{
|
||||
final Stream<File> libraries;
|
||||
File mcJar;
|
||||
try {
|
||||
mcJar = getMcJar();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to find Minecraft jar", e);
|
||||
}
|
||||
|
||||
{
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
final Stream<File> dependencies = acquireDependencies()
|
||||
@@ -252,39 +237,41 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
|
||||
|
||||
libraries = dependencies
|
||||
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
|
||||
.map(f -> isMcJar(f) ? mcJar : f);
|
||||
}
|
||||
libraries.forEach(f -> {
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
}
|
||||
|
||||
Files.createDirectories(this.getRootRelativeFile(PROGUARD_MAPPING_DIR));
|
||||
|
||||
List<String> api = new ArrayList<>(template);
|
||||
api.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("api.txt")));
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||
Files.write(getTemporaryFile(compType+PROGUARD_API_CONFIG), api);
|
||||
|
||||
// For the Standalone config, don't keep the API package
|
||||
List<String> standalone = new ArrayList<>(template);
|
||||
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
}
|
||||
|
||||
private File getSrgMcJar() {
|
||||
return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
|
||||
standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("standalone.txt")));
|
||||
Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
}
|
||||
|
||||
private Stream<File> acquireDependencies() {
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(File::isFile);
|
||||
}
|
||||
|
||||
private void proguardApi() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||
runProguard(getTemporaryFile(compType+PROGUARD_API_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
|
||||
}
|
||||
|
||||
private void proguardStandalone() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||
runProguard(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||
}
|
||||
|
||||
@@ -301,20 +288,21 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
public void setExtract(String extract) {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
public void setCompType(String compType) {
|
||||
this.compType = compType;
|
||||
}
|
||||
|
||||
private void runProguard(Path config) throws Exception {
|
||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||
if (Files.exists(this.proguardOut)) {
|
||||
Files.delete(this.proguardOut);
|
||||
}
|
||||
|
||||
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
|
||||
// Make paths relative to work directory; fixes spaces in path to config, @"" doesn't work
|
||||
Path workingDirectory = getTemporaryFile("");
|
||||
Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR));
|
||||
config = workingDirectory.relativize(config);
|
||||
|
||||
// Honestly, if you still have spaces in your path at this point, you're SOL.
|
||||
|
||||
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
|
||||
.directory(getTemporaryFile("").toFile()) // Set the working directory to the temporary folder]
|
||||
.directory(workingDirectory.toFile()) // Set the working directory to the temporary folder]
|
||||
.start();
|
||||
|
||||
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
|
||||
|
||||
103
fabric/build.gradle
Normal file
103
fabric/build.gradle
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/>.
|
||||
*/
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-fabric"
|
||||
|
||||
minecraft {
|
||||
fabric()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
fabric "net.fabricmc:fabric-loader:${project.fabric_version}"
|
||||
|
||||
// because of multiple sourcesets `common project(":")` doesn't work
|
||||
for (sourceSet in rootProject.sourceSets) {
|
||||
if (sourceSet == rootProject.sourceSets.test) continue
|
||||
if (sourceSet == rootProject.sourceSets.schematica_api) continue
|
||||
common sourceSet.output
|
||||
shadowCommon sourceSet.output
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "fabric"
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard) {
|
||||
compType "fabric"
|
||||
}
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,11 @@
|
||||
"entrypoints": {
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.baritone.json"
|
||||
"mixins.baritone.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.0",
|
||||
"minecraft": "1.18.x"
|
||||
"minecraft": ">=1.20 <=1.20.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
122
forge/build.gradle
Normal file
122
forge/build.gradle
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
}
|
||||
|
||||
archivesBaseName = archivesBaseName + "-forge"
|
||||
|
||||
minecraft {
|
||||
forge {
|
||||
devFallbackNamespace = "intermediary"
|
||||
mixinConfig = ["mixins.baritone.json"]
|
||||
}
|
||||
}
|
||||
|
||||
//loom {
|
||||
// forge {
|
||||
// mixinConfig 'mixins.baritone.json'
|
||||
// }
|
||||
//}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
|
||||
// because of multiple sourcesets `common project(":")` doesn't work
|
||||
for (sourceSet in rootProject.sourceSets) {
|
||||
if (sourceSet == rootProject.sourceSets.test) continue
|
||||
if (sourceSet == rootProject.sourceSets.schematica_api) continue
|
||||
common sourceSet.output
|
||||
shadowCommon sourceSet.output
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "forge"
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard) {
|
||||
compType "forge"
|
||||
}
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
18
forge/gradle.properties
Normal file
18
forge/gradle.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
loom.platform=forge
|
||||
22
forge/src/main/java/baritone/launch/BaritoneForgeModXD.java
Normal file
22
forge/src/main/java/baritone/launch/BaritoneForgeModXD.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch;import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("baritoe")
|
||||
public class BaritoneForgeModXD {
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="[33,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
license="https://raw.githubusercontent.com/cabaletta/baritone/1.16.2/LICENSE"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
|
||||
@@ -15,7 +15,7 @@ issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
|
||||
# The modid of the mod
|
||||
modId="baritoe" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version="${file.jarVersion}" #mandatory
|
||||
version="${version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="Baritone" #mandatory
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
@@ -31,3 +31,10 @@ description='''
|
||||
A Minecraft pathfinder bot.
|
||||
'''
|
||||
|
||||
[[dependencies.baritoe]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.20,1.20.1]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
6
forge/src/main/resources/pack.mcmeta
Normal file
6
forge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "null",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
|
||||
mod_version=1.8.2
|
||||
available_loaders=fabric,forge,tweaker
|
||||
|
||||
mod_version=1.10.1
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
minecraft_version=1.18
|
||||
forge_version=1.18-38.0.10
|
||||
fabric_version=0.12.5
|
||||
|
||||
# # un comment for forge debugging default (as opposed to fabric)
|
||||
# baritone.forge_build=true
|
||||
# loom.platform=forge
|
||||
minecraft_version=1.20.1
|
||||
forge_version=1.20.1-47.0.1
|
||||
fabric_version=0.14.18
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
4
jitpack.yml
Normal file
4
jitpack.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
before_install:
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- sdk install java 17.0.5-tem
|
||||
- sdk use java 17.0.5-tem
|
||||
9
scripts/proguard.pro
vendored
9
scripts/proguard.pro
vendored
@@ -1,5 +1,6 @@
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes InnerClasses
|
||||
|
||||
-optimizationpasses 5
|
||||
-verbose
|
||||
@@ -27,6 +28,7 @@
|
||||
-keep class baritone.api.IBaritoneProvider
|
||||
|
||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||
-keepname class baritone.api.utils.BlockOptionalMeta # this name is exposed to the user, so we need to keep it in all builds
|
||||
|
||||
# Keep any class or member annotated with @KeepName so we dont have to put everything in the script
|
||||
-keep,allowobfuscation @interface baritone.KeepName
|
||||
@@ -45,9 +47,10 @@
|
||||
|
||||
#try to keep usage of schematica in separate classes
|
||||
-keep class baritone.utils.schematic.schematica.**
|
||||
-keep class baritone.utils.schematic.litematica.**
|
||||
#proguard doesnt like it when it cant find our fake schematica classes
|
||||
-dontwarn baritone.utils.schematic.schematica.**
|
||||
|
||||
-dontwarn baritone.utils.schematic.litematica.**
|
||||
|
||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||
# methods.
|
||||
@@ -336,6 +339,4 @@
|
||||
public int length();
|
||||
public java.lang.String substring(int);
|
||||
public java.lang.String substring(int,int);
|
||||
}
|
||||
|
||||
-printmapping mapping.txt
|
||||
}
|
||||
@@ -17,24 +17,31 @@
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = 'WagYourMaven'
|
||||
url = 'https://maven.wagyourtail.xyz/snapshots'
|
||||
}
|
||||
maven {
|
||||
name = 'ForgeMaven'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'FabricMaven'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'https://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://www.dogforce-games.com/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://libraries.minecraft.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal() {
|
||||
content {
|
||||
excludeGroup "org.apache.logging.log4j"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
|
||||
include("tweaker")
|
||||
for (platform in available_loaders.split(",")) {
|
||||
include(platform)
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import baritone.api.utils.TypeUtils;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -35,8 +33,8 @@ import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Baritone's settings. Settings apply to all Baritone instances.
|
||||
@@ -50,6 +48,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> allowBreak = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Blocks that baritone will be allowed to break even with allowBreak set to false
|
||||
*/
|
||||
public final Setting<List<Block>> allowBreakAnyway = new Setting<>(new ArrayList<>());
|
||||
|
||||
/**
|
||||
* Allow Baritone to sprint
|
||||
*/
|
||||
@@ -103,6 +106,13 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(3D);
|
||||
|
||||
/**
|
||||
* Don't allow breaking blocks next to liquids.
|
||||
* <p>
|
||||
* Enable if you have mods adding custom fluid physics.
|
||||
*/
|
||||
public final Setting<Boolean> strictLiquidCheck = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
|
||||
* Reliability: questionable.
|
||||
@@ -112,6 +122,8 @@ public final class Settings {
|
||||
/**
|
||||
* Allow Baritone to assume it can walk on still water just like any other block.
|
||||
* This functionality is assumed to be provided by a separate library that might have imported Baritone.
|
||||
* <p>
|
||||
* Note: This will prevent some usage of the frostwalker enchantment, like pillaring up from water.
|
||||
*/
|
||||
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||
|
||||
@@ -192,7 +204,7 @@ public final class Settings {
|
||||
* Blocks that Baritone is not allowed to break
|
||||
*/
|
||||
public final Setting<List<Block>> blocksToDisallowBreaking = new Setting<>(new ArrayList<>(
|
||||
// Leave Empty by Default
|
||||
// Leave Empty by Default
|
||||
));
|
||||
|
||||
/**
|
||||
@@ -232,6 +244,8 @@ public final class Settings {
|
||||
* A mapping of blocks to blocks treated as correct in their position
|
||||
* <p>
|
||||
* If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well
|
||||
* <p>
|
||||
* Syntax same as <a href="https://baritone.leijurv.com/baritone/api/Settings.html#buildSubstitutes">buildSubstitutes</a>
|
||||
*/
|
||||
public final Setting<Map<Block, List<Block>>> buildValidSubstitutes = new Setting<>(new HashMap<>());
|
||||
|
||||
@@ -239,6 +253,15 @@ public final class Settings {
|
||||
* A mapping of blocks to blocks to be built instead
|
||||
* <p>
|
||||
* If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list
|
||||
* <p>
|
||||
* Usage Syntax:
|
||||
* <pre>
|
||||
* sourceblockA->blockToSubstituteA1,blockToSubstituteA2,...blockToSubstituteAN,sourceBlockB->blockToSubstituteB1,blockToSubstituteB2,...blockToSubstituteBN,...sourceBlockX->blockToSubstituteX1,blockToSubstituteX2...blockToSubstituteXN
|
||||
* </pre>
|
||||
* Example:
|
||||
* <pre>
|
||||
* stone->cobblestone,andesite,oak_planks->birch_planks,acacia_planks,glass
|
||||
* </pre>
|
||||
*/
|
||||
public final Setting<Map<Block, List<Block>>> buildSubstitutes = new Setting<>(new HashMap<>());
|
||||
|
||||
@@ -261,6 +284,12 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* A list of names of block properties the builder will ignore.
|
||||
*/
|
||||
public final Setting<List<String>> buildIgnoreProperties = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
)));
|
||||
|
||||
/**
|
||||
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
||||
* <p>
|
||||
@@ -388,6 +417,9 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
|
||||
|
||||
/**
|
||||
* Distance to avoid mob spawners.
|
||||
*/
|
||||
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
|
||||
|
||||
/**
|
||||
@@ -397,6 +429,9 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
|
||||
|
||||
/**
|
||||
* Distance to avoid mobs.
|
||||
*/
|
||||
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
||||
|
||||
/**
|
||||
@@ -547,6 +582,17 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||
|
||||
|
||||
/**
|
||||
* allows baritone to save bed waypoints when interacting with beds
|
||||
*/
|
||||
public final Setting<Boolean> doBedWaypoints = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* allows baritone to save death waypoints
|
||||
*/
|
||||
public final Setting<Boolean> doDeathWaypoints = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||
*/
|
||||
@@ -883,7 +929,7 @@ public final class Settings {
|
||||
/**
|
||||
* Only build the selected part of schematics
|
||||
*/
|
||||
public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
|
||||
public final Setting<Boolean> buildOnlySelection = 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
|
||||
@@ -1017,7 +1063,7 @@ public final class Settings {
|
||||
/**
|
||||
* What Y level to go to for legit strip mining
|
||||
*/
|
||||
public final Setting<Integer> legitMineYLevel = new Setting<>(11);
|
||||
public final Setting<Integer> legitMineYLevel = new Setting<>(-59);
|
||||
|
||||
/**
|
||||
* Magically see ores that are separated diagonally from existing ores. Basically like mining around the ores that it finds
|
||||
@@ -1095,7 +1141,7 @@ public final class Settings {
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>(Minecraft.getInstance().gui.getChat()::addMessage);
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will send a desktop notification. This function can be added to
|
||||
|
||||
@@ -19,11 +19,12 @@ package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum BlockById implements IDatatypeFor<Block> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -31,7 +32,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = Registry.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
}
|
||||
return block;
|
||||
@@ -41,7 +42,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
Registry.BLOCK.keySet()
|
||||
BuiltInRegistries.BLOCK.keySet()
|
||||
.stream()
|
||||
.map(Object::toString)
|
||||
)
|
||||
|
||||
@@ -19,11 +19,12 @@ package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -31,7 +32,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
EntityType entity;
|
||||
if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
}
|
||||
return entity;
|
||||
@@ -40,7 +41,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.append(BuiltInRegistries.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
|
||||
@@ -26,7 +26,8 @@ import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
INSTANCE;
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
|
||||
private static String ScalesAliasRegex = "[kKmM]";
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + ScalesAliasRegex + "?)|)$");
|
||||
|
||||
@Override
|
||||
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
|
||||
@@ -41,11 +42,15 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
|
||||
boolean isRelative = !matcher.group(1).isEmpty();
|
||||
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, ""));
|
||||
|
||||
if (matcher.group(2).contains("k")) {
|
||||
if (matcher.group(2).toLowerCase().contains("k")) {
|
||||
offset *= 1000;
|
||||
}
|
||||
if (matcher.group(2).toLowerCase().contains("m")) {
|
||||
offset *= 1000000;
|
||||
}
|
||||
|
||||
|
||||
if (isRelative) {
|
||||
return origin + offset;
|
||||
|
||||
@@ -83,10 +83,10 @@ public enum RelativeFile implements IDatatypePost<File, File> {
|
||||
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()))
|
||||
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)))
|
||||
|
||||
@@ -21,15 +21,16 @@ import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.Helper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
public class Paginator<E> implements Helper {
|
||||
|
||||
@@ -74,7 +75,7 @@ public class Paginator<E> implements Helper {
|
||||
}
|
||||
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||
BaseComponent prevPageComponent = new TextComponent("<<");
|
||||
MutableComponent prevPageComponent = Component.literal("<<");
|
||||
if (hasPrevPage) {
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
@@ -83,26 +84,23 @@ public class Paginator<E> implements Helper {
|
||||
))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to view previous page")
|
||||
Component.literal("Click to view previous page")
|
||||
)));
|
||||
} else {
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
BaseComponent nextPageComponent = new TextComponent(">>");
|
||||
MutableComponent nextPageComponent = Component.literal(">>");
|
||||
if (hasNextPage) {
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page + 1)
|
||||
))
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", commandPrefix, page + 1)))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to view next page")
|
||||
Component.literal("Click to view next page")
|
||||
)));
|
||||
} else {
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
BaseComponent pagerComponent = new TextComponent("");
|
||||
MutableComponent pagerComponent = Component.literal("");
|
||||
pagerComponent.setStyle(pagerComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
pagerComponent.append(prevPageComponent);
|
||||
pagerComponent.append(" | ");
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Registry<V> {
|
||||
* @param entry The entry to unregister.
|
||||
*/
|
||||
public void unregister(V entry) {
|
||||
if (registered(entry)) {
|
||||
if (!registered(entry)) {
|
||||
return;
|
||||
}
|
||||
_entries.remove(entry);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
|
||||
@@ -19,8 +19,8 @@ package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import java.util.Arrays;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Useful for automated combat (retreating specifically)
|
||||
*
|
||||
|
||||
@@ -65,8 +65,8 @@ public interface ActionCosts {
|
||||
|
||||
|
||||
static double[] generateFallNBlocksCost() {
|
||||
double[] costs = new double[257];
|
||||
for (int i = 0; i < 257; i++) {
|
||||
double[] costs = new double[4097];
|
||||
for (int i = 0; i < 4097; i++) {
|
||||
costs[i] = distanceToTicks(i);
|
||||
}
|
||||
return costs;
|
||||
|
||||
@@ -57,6 +57,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void buildOpenLitematic(int i);
|
||||
|
||||
void pause();
|
||||
|
||||
boolean isPaused();
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
package baritone.api.schematic;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FillSchematic extends AbstractSchematic {
|
||||
|
||||
private final BlockOptionalMeta bom;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
private final Map<Block, List<Block>> substitutions;
|
||||
private final Map<BlockState, Map<Block, BlockState>> blockStateCache = new HashMap<>();
|
||||
|
||||
public SubstituteSchematic(ISchematic schematic, Map<Block,List<Block>> substitutions) {
|
||||
public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
|
||||
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
|
||||
this.schematic = schematic;
|
||||
this.substitutions = substitutions;
|
||||
@@ -81,9 +81,10 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
} catch (IllegalArgumentException e) { //property does not exist for target block
|
||||
}
|
||||
}
|
||||
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block,BlockState>()).put(block, newState);
|
||||
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, BlockState>()).put(block, newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
|
||||
return toState.setValue(prop, fromState.getValue(prop));
|
||||
}
|
||||
|
||||
@@ -20,31 +20,46 @@ package baritone.api.utils;
|
||||
import baritone.api.utils.accessor.IItemStack;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.packs.PackResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.server.packs.*;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.RandomSequences;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.level.storage.loot.PredicateManager;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -56,8 +71,7 @@ public final class BlockOptionalMeta {
|
||||
private final ImmutableSet<Integer> stateHashes;
|
||||
private final ImmutableSet<Integer> stackHashes;
|
||||
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||
private static LootTables manager;
|
||||
private static PredicateManager predicate = new PredicateManager();
|
||||
private static LootDataManager lootTables;
|
||||
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||
|
||||
public BlockOptionalMeta(@Nonnull Block block) {
|
||||
@@ -142,25 +156,37 @@ public final class BlockOptionalMeta {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LootTables getManager() {
|
||||
if (manager == null) {
|
||||
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
|
||||
rpl.reload();
|
||||
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
|
||||
ReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(PackType.SERVER_DATA);
|
||||
manager = new LootTables(predicate);
|
||||
resourceManager.registerReloadListener(manager);
|
||||
private static Method getVanillaServerPack;
|
||||
|
||||
private static VanillaPackResources getVanillaServerPack() {
|
||||
if (getVanillaServerPack == null) {
|
||||
getVanillaServerPack = Arrays.stream(ServerPacksSource.class.getDeclaredMethods()).filter(field -> field.getReturnType() == VanillaPackResources.class).findFirst().orElseThrow();
|
||||
getVanillaServerPack.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
return (VanillaPackResources) getVanillaServerPack.invoke(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LootDataManager getManager() {
|
||||
if (lootTables == null) {
|
||||
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
|
||||
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
|
||||
lootTables = new LootDataManager();
|
||||
resourceManager.registerReloadListener(lootTables);
|
||||
try {
|
||||
resourceManager.reload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
||||
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static PredicateManager getPredicateManager() {
|
||||
return predicate;
|
||||
}
|
||||
return lootTables;
|
||||
}
|
||||
|
||||
private static synchronized List<Item> drops(Block b) {
|
||||
@@ -170,20 +196,59 @@ public final class BlockOptionalMeta {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
try {
|
||||
|
||||
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
|
||||
getManager().get(lootTableLocation).getRandomItems(
|
||||
new LootContext.Builder((ServerLevel) null)
|
||||
.withRandom(new Random())
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
|
||||
.create(LootContextParamSets.BLOCK),
|
||||
getManager().getLootTable(lootTableLocation).getRandomItemsRaw(
|
||||
new LootContext.Builder(
|
||||
new LootParams.Builder(ServerLevelStub.fastCreate())
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
|
||||
.create(LootContextParamSets.BLOCK)
|
||||
).withOptionalRandomSeed(1L)
|
||||
.create(null),
|
||||
stack -> items.add(stack.getItem())
|
||||
);
|
||||
);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ServerLevelStub extends ServerLevel {
|
||||
private static Minecraft client = Minecraft.getInstance();
|
||||
private static Unsafe unsafe = getUnsafe();
|
||||
|
||||
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10, @Nullable RandomSequences $$11) {
|
||||
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureFlagSet enabledFeatures() {
|
||||
assert client.level != null;
|
||||
return client.level.enabledFeatures();
|
||||
}
|
||||
|
||||
public static ServerLevelStub fastCreate() {
|
||||
try {
|
||||
return (ServerLevelStub) unsafe.allocateInstance(ServerLevelStub.class);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Unsafe getUnsafe() {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
return (Unsafe) theUnsafe.get(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.api.utils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class BlockUtils {
|
||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||
|
||||
public static String blockToString(Block block) {
|
||||
ResourceLocation loc = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation loc = BuiltInRegistries.BLOCK.getKey(block);
|
||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||
if (!loc.getNamespace().equals("minecraft")) {
|
||||
// Baritone is running on top of forge with mods installed, perhaps?
|
||||
@@ -56,7 +57,7 @@ public class BlockUtils {
|
||||
if (resourceCache.containsKey(name)) {
|
||||
return null; // cached as null
|
||||
}
|
||||
block = Registry.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
|
||||
block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
|
||||
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||
copy.put(name, block);
|
||||
resourceCache = copy;
|
||||
|
||||
@@ -21,9 +21,10 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.stream.Stream;
|
||||
@@ -51,11 +52,11 @@ public interface Helper {
|
||||
// Inner text component
|
||||
final Calendar now = Calendar.getInstance();
|
||||
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
|
||||
BaseComponent baritone = new TextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
MutableComponent baritone = Component.literal(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
|
||||
|
||||
// Outer brackets
|
||||
BaseComponent prefix = new TextComponent("");
|
||||
MutableComponent prefix = Component.literal("");
|
||||
prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
|
||||
prefix.append("[");
|
||||
prefix.append(baritone);
|
||||
@@ -81,7 +82,7 @@ public interface Helper {
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String title, String message) {
|
||||
logToast(new TextComponent(title), new TextComponent(message));
|
||||
logToast(Component.literal(title), Component.literal(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +91,7 @@ public interface Helper {
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String message) {
|
||||
logToast(Helper.getPrefix(), new TextComponent(message));
|
||||
logToast(Helper.getPrefix(), Component.literal(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,9 +159,9 @@ public interface Helper {
|
||||
* @param components The components to send
|
||||
*/
|
||||
default void logDirect(boolean logAsToast, Component... components) {
|
||||
BaseComponent component = new TextComponent("");
|
||||
MutableComponent component = Component.literal("");
|
||||
component.append(getPrefix());
|
||||
component.append(new TextComponent(" "));
|
||||
component.append(Component.literal(" "));
|
||||
Arrays.asList(components).forEach(component::append);
|
||||
if (logAsToast) {
|
||||
logToast(getPrefix(), component);
|
||||
@@ -188,7 +189,7 @@ public interface Helper {
|
||||
*/
|
||||
default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
|
||||
Stream.of(message.split("\n")).forEach(line -> {
|
||||
BaseComponent component = new TextComponent(line.replace("\t", " "));
|
||||
MutableComponent component = Component.literal(line.replace("\t", " "));
|
||||
component.setStyle(component.getStyle().withColor(color));
|
||||
logDirect(logAsToast, component);
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class RayTraceUtils {
|
||||
direction.y * blockReachDistance,
|
||||
direction.z * blockReachDistance
|
||||
);
|
||||
return entity.level.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
|
||||
return entity.level().clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
|
||||
}
|
||||
|
||||
public static Vec3 inferSneakingEyePosition(Entity entity) {
|
||||
|
||||
@@ -196,8 +196,8 @@ public final class RotationUtils {
|
||||
return possibleRotation;
|
||||
}
|
||||
|
||||
BlockState state = entity.level.getBlockState(pos);
|
||||
VoxelShape shape = state.getShape(entity.level, pos);
|
||||
BlockState state = entity.level().getBlockState(pos);
|
||||
VoxelShape shape = state.getShape(entity.level(), pos);
|
||||
if (shape.isEmpty()) {
|
||||
shape = Shapes.block();
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public final class RotationUtils {
|
||||
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
|
||||
if (entity.level().getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
}
|
||||
@@ -250,6 +250,6 @@ public final class RotationUtils {
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level(), pos), blockReachDistance, wouldSneak);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -178,7 +179,7 @@ public class SettingsUtil {
|
||||
/**
|
||||
* This should always be the same as whether the setting can be parsed from or serialized to a string
|
||||
*
|
||||
* @param the setting
|
||||
* @param setting The Setting
|
||||
* @return true if the setting can not be set or read by the user
|
||||
*/
|
||||
public static boolean javaOnlySetting(Settings.Setting setting) {
|
||||
@@ -252,8 +253,8 @@ public class SettingsUtil {
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> Registry.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> Registry.ITEM.getKey(item).toString()
|
||||
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> BuiltInRegistries.ITEM.getKey(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
@Override
|
||||
@@ -300,7 +301,7 @@ public class SettingsUtil {
|
||||
Parser keyParser = Parser.getParser(keyType);
|
||||
Parser valueParser = Parser.getParser(valueType);
|
||||
|
||||
return ((Map<?,?>) value).entrySet().stream()
|
||||
return ((Map<?, ?>) value).entrySet().stream()
|
||||
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.api.utils.gui;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraft.client.gui.components.toasts.ToastComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -38,7 +39,7 @@ public class BaritoneToast implements Toast {
|
||||
this.totalShowTime = totalShowTime;
|
||||
}
|
||||
|
||||
public Visibility render(PoseStack matrixStack, ToastComponent toastGui, long delta) {
|
||||
public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) {
|
||||
if (this.newDisplay) {
|
||||
this.firstDrawTime = delta;
|
||||
this.newDisplay = false;
|
||||
@@ -46,15 +47,13 @@ public class BaritoneToast implements Toast {
|
||||
|
||||
|
||||
//TODO: check
|
||||
toastGui.getMinecraft().getTextureManager().bindForSetup(new ResourceLocation("textures/gui/toasts.png"));
|
||||
//GlStateManager._color4f(1.0F, 1.0F, 1.0F, 255.0F);
|
||||
toastGui.blit(matrixStack, 0, 0, 0, 32, 160, 32);
|
||||
gui.blit(new ResourceLocation("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
|
||||
|
||||
if (this.subtitle == null) {
|
||||
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 12, -11534256);
|
||||
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);
|
||||
} else {
|
||||
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 7, -11534256);
|
||||
toastGui.getMinecraft().font.draw(matrixStack, this.subtitle, 18, 18, -16777216);
|
||||
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 7, -11534256);
|
||||
gui.drawString(toastGui.getMinecraft().font, this.subtitle, 18, 18, -16777216);
|
||||
}
|
||||
|
||||
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IChunkArray;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -27,24 +28,28 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkCache$Storage")
|
||||
public abstract class MixinChunkArray implements IChunkArray {
|
||||
@Final
|
||||
@Shadow
|
||||
private AtomicReferenceArray<LevelChunk> chunks;
|
||||
AtomicReferenceArray<LevelChunk> chunks;
|
||||
@Final
|
||||
@Shadow
|
||||
private int chunkRadius;
|
||||
int chunkRadius;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private int viewRange;
|
||||
@Shadow
|
||||
private int viewCenterX;
|
||||
int viewCenterX;
|
||||
@Shadow
|
||||
private int viewCenterZ;
|
||||
int viewCenterZ;
|
||||
@Shadow
|
||||
private int chunkCount;
|
||||
int chunkCount;
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean inRange(int x, int z);
|
||||
abstract boolean inRange(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract int getIndex(int x, int z);
|
||||
abstract int getIndex(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract void replace(int index, LevelChunk chunk);
|
||||
|
||||
@@ -20,14 +20,19 @@ package baritone.launch.mixins;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -63,6 +68,25 @@ public class MixinClientPlayNetHandler {
|
||||
}
|
||||
}*/
|
||||
|
||||
@Shadow @Final private Minecraft minecraft;
|
||||
|
||||
@Inject(
|
||||
method = "sendChat(Ljava/lang/String;)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void sendChatMessage(String string, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(string);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(this.minecraft.player);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
baritone.getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "handleLevelChunkWithLight",
|
||||
at = @At("RETURN")
|
||||
@@ -175,7 +199,7 @@ public class MixinClientPlayNetHandler {
|
||||
method = "handlePlayerCombatKill",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"
|
||||
target = "Lnet/minecraft/client/player/LocalPlayer;shouldShowDeathScreen()Z"
|
||||
)
|
||||
)
|
||||
private void onPlayerDeath(ClientboundPlayerCombatKillPacket packetIn, CallbackInfo ci) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -40,23 +41,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(LocalPlayer.class)
|
||||
public class MixinClientPlayerEntity {
|
||||
|
||||
@Inject(
|
||||
method = "chat",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(msg);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
baritone.getGameEventHandler().onSendChatMessage(event);
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tick",
|
||||
at = @At(
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class MixinItemStack implements IItemStack {
|
||||
private int baritoneHash;
|
||||
|
||||
@Shadow
|
||||
protected abstract int getDamageValue();
|
||||
public abstract int getDamageValue();
|
||||
|
||||
private void recalculateHash() {
|
||||
baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue();
|
||||
|
||||
@@ -21,8 +21,7 @@ import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.level.storage.loot.PredicateManager;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -48,27 +47,13 @@ public class MixinLootContext {
|
||||
method = "create",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getLootTables()Lnet/minecraft/world/level/storage/loot/LootTables;"
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getLootData()Lnet/minecraft/world/level/storage/loot/LootDataManager;"
|
||||
)
|
||||
)
|
||||
private LootTables getLootTableManager(MinecraftServer server) {
|
||||
private LootDataManager getLootTableManager(MinecraftServer server) {
|
||||
if (server == null) {
|
||||
return BlockOptionalMeta.getManager();
|
||||
}
|
||||
return server.getLootTables();
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "create",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getPredicateManager()Lnet/minecraft/world/level/storage/loot/PredicateManager;"
|
||||
)
|
||||
)
|
||||
private PredicateManager getLootPredicateManager(MinecraftServer server) {
|
||||
if (server == null) {
|
||||
return BlockOptionalMeta.getPredicateManager();
|
||||
}
|
||||
return server.getPredicateManager();
|
||||
return server.getLootData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
@@ -123,12 +124,26 @@ public class MixinMinecraft {
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/client/gui/screens/Screen;passEvents:Z"
|
||||
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;"
|
||||
),
|
||||
slice = @Slice(
|
||||
from = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/client/Options;renderDebug:Z"
|
||||
),
|
||||
to = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=Keybindings"
|
||||
)
|
||||
)
|
||||
)
|
||||
private boolean passEvents(Screen screen) {
|
||||
private Screen passEvents(Minecraft instance) {
|
||||
// allow user input is only the primary baritone
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
|
||||
if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) {
|
||||
return null;
|
||||
}
|
||||
return instance.screen;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.PacketSendListener;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -53,14 +54,14 @@ public class MixinNetworkManager {
|
||||
method = "sendPacket",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
|
||||
if (this.receiving != PacketFlow.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, inPacket));
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,14 +70,14 @@ public class MixinNetworkManager {
|
||||
method = "sendPacket",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
|
||||
if (this.receiving != PacketFlow.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, inPacket));
|
||||
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,20 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.net.URI;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen implements IGuiScreen {
|
||||
@@ -30,4 +38,20 @@ public abstract class MixinScreen implements IGuiScreen {
|
||||
@Override
|
||||
@Invoker("openLink")
|
||||
public abstract void openLinkInvoker(URI url);
|
||||
|
||||
|
||||
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
|
||||
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {
|
||||
ClickEvent clickEvent = style.getClickEvent();
|
||||
if (clickEvent == null) {
|
||||
return;
|
||||
}
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onSendChatMessage(new ChatEvent(clickEvent.getValue()));
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "baritone.launch.mixins",
|
||||
"refmap": "mixins.baritone.refmap.json",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"verbose": false,
|
||||
"injectors": {
|
||||
"maxShiftBy": 2
|
||||
"maxShiftBy": 2,
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"client": [
|
||||
"MixinChunkArray",
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "baritoe",
|
||||
"pack_format": 5
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ public class Baritone implements IBaritone {
|
||||
private PathingBehavior pathingBehavior;
|
||||
private LookBehavior lookBehavior;
|
||||
private InventoryBehavior inventoryBehavior;
|
||||
private WaypointBehavior waypointBehavior;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
|
||||
private FollowProcess followProcess;
|
||||
@@ -101,6 +102,7 @@ public class Baritone implements IBaritone {
|
||||
lookBehavior = new LookBehavior(this);
|
||||
inventoryBehavior = new InventoryBehavior(this);
|
||||
inputOverrideHandler = new InputOverrideHandler(this);
|
||||
waypointBehavior = new WaypointBehavior(this);
|
||||
}
|
||||
|
||||
this.pathingControlManager = new PathingControlManager(this);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package baritone.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
||||
@@ -98,6 +98,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
baritone.getPathingControlManager().cancelEverything();
|
||||
return;
|
||||
}
|
||||
|
||||
expectedSegmentStart = pathStart();
|
||||
baritone.getPathingControlManager().preTick();
|
||||
tickPath();
|
||||
@@ -237,11 +238,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
if (current != null) {
|
||||
switch (event.getState()) {
|
||||
case PRE:
|
||||
lastAutoJump = mc.options.autoJump;
|
||||
mc.options.autoJump = false;
|
||||
lastAutoJump = mc.options.autoJump().get();
|
||||
mc.options.autoJump().set(false);
|
||||
break;
|
||||
case POST:
|
||||
mc.options.autoJump = lastAutoJump;
|
||||
mc.options.autoJump().set(lastAutoJump);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -418,7 +419,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
public BetterBlockPos pathStart() { // TODO move to a helper or util class
|
||||
BetterBlockPos feet = ctx.playerFeet();
|
||||
if (!MovementHelper.canWalkOn(ctx, feet.below())) {
|
||||
if (ctx.player().isOnGround()) {
|
||||
if (ctx.player().onGround()) {
|
||||
double playerX = ctx.player().position().x;
|
||||
double playerZ = ctx.player().position().z;
|
||||
ArrayList<BetterBlockPos> closest = new ArrayList<>();
|
||||
|
||||
93
src/main/java/baritone/behavior/WaypointBehavior.java
Normal file
93
src/main/java/baritone/behavior/WaypointBehavior.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.event.events.BlockInteractEvent;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.level.block.BedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BedPart;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class WaypointBehavior extends Behavior {
|
||||
|
||||
|
||||
public WaypointBehavior(Baritone baritone) {
|
||||
super(baritone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockInteract(BlockInteractEvent event) {
|
||||
if (!Baritone.settings().doBedWaypoints.value)
|
||||
return;
|
||||
if (event.getType() == BlockInteractEvent.Type.USE) {
|
||||
BetterBlockPos pos = BetterBlockPos.from(event.getPos());
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
if (state.getBlock() instanceof BedBlock) {
|
||||
if (state.getValue(BedBlock.PART) == BedPart.FOOT) {
|
||||
pos = pos.relative(state.getValue(BedBlock.FACING));
|
||||
}
|
||||
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED);
|
||||
boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent();
|
||||
if (!exists) {
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDeath() {
|
||||
if (!Baritone.settings().doDeathWaypoints.value)
|
||||
return;
|
||||
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
|
||||
MutableComponent component = Component.literal("Death position saved.");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
Component.literal("Click to goto death")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goto %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
"wp",
|
||||
deathWaypoint.getTag().getName(),
|
||||
deathWaypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
Helper.HELPER.logDirect(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public final class CachedRegion implements ICachedRegion {
|
||||
/**
|
||||
* Magic value to detect invalid cache files, or incompatible cache files saved in an old version of Baritone
|
||||
*/
|
||||
private static final int CACHED_REGION_MAGIC = 456022910;
|
||||
private static final int CACHED_REGION_MAGIC = 456022911;
|
||||
|
||||
/**
|
||||
* All of the chunks in this region: A 32x32 array of them.
|
||||
@@ -166,7 +166,7 @@ public final class CachedRegion implements ICachedRegion {
|
||||
out.writeShort(entry.getValue().size());
|
||||
for (BlockPos pos : entry.getValue()) {
|
||||
out.writeByte((byte) (pos.getZ() << 4 | pos.getX()));
|
||||
out.writeByte((byte) (pos.getY()));
|
||||
out.writeInt(pos.getY()-dimension.minY());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,8 +270,8 @@ public final class CachedRegion implements ICachedRegion {
|
||||
byte xz = in.readByte();
|
||||
int X = xz & 0x0f;
|
||||
int Z = (xz >>> 4) & 0x0f;
|
||||
int Y = in.readByte() & 0xff;
|
||||
locs.add(new BlockPos(X, Y, Z));
|
||||
int Y = in.readInt();
|
||||
locs.add(new BlockPos(X, Y+dimension.minY(), Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
||||
private BlockPos guessPosition() {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
IWorldData data = ibaritone.getWorldProvider().getCurrentWorld();
|
||||
if (data != null && data.getCachedWorld() == this) {
|
||||
if (data != null && data.getCachedWorld() == this && ibaritone.getPlayerContext().player() != null) {
|
||||
return ibaritone.getPlayerContext().playerFeet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import java.util.*;
|
||||
@@ -82,7 +83,7 @@ public final class ChunkPacker {
|
||||
Block block = state.getBlock();
|
||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
|
||||
String name = BlockUtils.blockToString(block);
|
||||
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +133,7 @@ public final class ChunkPacker {
|
||||
return PathingBlockType.AVOID;
|
||||
}
|
||||
if (x == 0 || x == 15 || z == 0 || z == 15) {
|
||||
Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + chunk.getPos().x << 4, y, z + chunk.getPos().z << 4));
|
||||
Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + (chunk.getPos().x << 4), y, z + (chunk.getPos().z << 4)));
|
||||
if (flow.x != 0.0 || flow.z != 0.0) {
|
||||
return PathingBlockType.WATER;
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public final class ChunkPacker {
|
||||
if (dimension.ultraWarm()) {
|
||||
return Blocks.NETHERRACK.defaultBlockState();
|
||||
}
|
||||
if (dimension.createDragonFight()) {
|
||||
if (dimension.effectsLocation().equals(BuiltinDimensionTypes.END_EFFECTS)) {
|
||||
return Blocks.END_STONE.defaultBlockState();
|
||||
}
|
||||
default:
|
||||
|
||||
6
src/main/java/baritone/cache/WorldData.java
vendored
6
src/main/java/baritone/cache/WorldData.java
vendored
@@ -21,12 +21,10 @@ import baritone.Baritone;
|
||||
import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Data about a world, from baritone's point of view. Includes cached chunks, waypoints, and map data.
|
||||
*
|
||||
|
||||
37
src/main/java/baritone/cache/WorldProvider.java
vendored
37
src/main/java/baritone/cache/WorldProvider.java
vendored
@@ -45,9 +45,11 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
private static final Map<Path, WorldData> worldCache = new HashMap<>(); // this is how the bots have the same cached world
|
||||
|
||||
private WorldData currentWorld;
|
||||
private Level mcWorld; // this let's us detect a broken load/unload hook
|
||||
|
||||
@Override
|
||||
public final WorldData getCurrentWorld() {
|
||||
detectAndHandleBrokenLoading();
|
||||
return this.currentWorld;
|
||||
}
|
||||
|
||||
@@ -76,16 +78,14 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
readme = directory;
|
||||
} else { // Otherwise, the server must be remote...
|
||||
String folderName;
|
||||
if (mc.isConnectedToRealms()) {
|
||||
folderName = "realms";
|
||||
if (mc.getCurrentServer() != null) {
|
||||
folderName = mc.isConnectedToRealms() ? "realms" : mc.getCurrentServer().ip;
|
||||
} else {
|
||||
if (mc.getCurrentServer() != null) {
|
||||
folderName = mc.getCurrentServer().ip;
|
||||
} else {
|
||||
//replaymod causes null currentServerData and false singleplayer.
|
||||
currentWorld = null;
|
||||
return;
|
||||
}
|
||||
//replaymod causes null currentServer and false singleplayer.
|
||||
System.out.println("World seems to be a replay. Not loading Baritone cache.");
|
||||
currentWorld = null;
|
||||
mcWorld = mc.level;
|
||||
return;
|
||||
}
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
folderName = folderName.replace(":", "_");
|
||||
@@ -112,6 +112,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
synchronized (worldCache) {
|
||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, world));
|
||||
}
|
||||
this.mcWorld = mc.level;
|
||||
}
|
||||
|
||||
public final Path getDimDir(ResourceKey<Level> level, int height, Path directory) {
|
||||
@@ -121,6 +122,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
public final void closeWorld() {
|
||||
WorldData world = this.currentWorld;
|
||||
this.currentWorld = null;
|
||||
this.mcWorld = null;
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
@@ -128,8 +130,25 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
}
|
||||
|
||||
public final void ifWorldLoaded(Consumer<WorldData> currentWorldConsumer) {
|
||||
detectAndHandleBrokenLoading();
|
||||
if (this.currentWorld != null) {
|
||||
currentWorldConsumer.accept(this.currentWorld);
|
||||
}
|
||||
}
|
||||
|
||||
private final void detectAndHandleBrokenLoading() {
|
||||
if (this.mcWorld != mc.level) {
|
||||
if (this.currentWorld != null) {
|
||||
System.out.println("mc.world unloaded unnoticed! Unloading Baritone cache now.");
|
||||
closeWorld();
|
||||
}
|
||||
if (mc.level != null) {
|
||||
System.out.println("mc.world loaded unnoticed! Loading Baritone cache now.");
|
||||
initWorld(mc.level.dimension(), mc.level.dimensionType());
|
||||
}
|
||||
} else if (currentWorld == null && mc.level != null && (mc.hasSingleplayerServer() || mc.getCurrentServer() != null)) {
|
||||
System.out.println("Retrying to load Baritone cache");
|
||||
initWorld(mc.level.dimension(), mc.level.dimensionType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,8 @@ import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -78,12 +76,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
||||
if (settings.echoCommands.value) {
|
||||
String msg = command + rest;
|
||||
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
|
||||
BaseComponent component = new TextComponent(String.format("> %s", toDisplay));
|
||||
MutableComponent component = Component.literal(String.format("> %s", toDisplay));
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to rerun command")
|
||||
Component.literal("Click to rerun command")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
|
||||
@@ -42,7 +42,8 @@ public final class DefaultCommands {
|
||||
new VersionCommand(baritone),
|
||||
new RepackCommand(baritone),
|
||||
new BuildCommand(baritone),
|
||||
new SchematicaCommand(baritone),
|
||||
//new SchematicaCommand(baritone),
|
||||
new LitematicaCommand(baritone),
|
||||
new ComeCommand(baritone),
|
||||
new AxisCommand(baritone),
|
||||
new ForceCancelCommand(baritone),
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -45,11 +45,17 @@ public class ETACommand extends Command {
|
||||
throw new CommandInvalidStateException("No process in control");
|
||||
}
|
||||
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||
|
||||
double ticksRemainingInSegment = pathingBehavior.ticksRemainingInSegment().orElse(Double.NaN);
|
||||
double ticksRemainingInGoal = pathingBehavior.estimatedTicksToGoal().orElse(Double.NaN);
|
||||
|
||||
logDirect(String.format(
|
||||
"Next segment: %.2f\n" +
|
||||
"Goal: %.2f",
|
||||
pathingBehavior.ticksRemainingInSegment().orElse(-1.0),
|
||||
pathingBehavior.estimatedTicksToGoal().orElse(-1.0)
|
||||
"Next segment: %.1fs (%.0f ticks)\n" +
|
||||
"Goal: %.1fs (%.0f ticks)",
|
||||
ticksRemainingInSegment / 20, // we just assume tps is 20, it isn't worth the effort that is needed to calculate it exactly
|
||||
ticksRemainingInSegment,
|
||||
ticksRemainingInGoal / 20,
|
||||
ticksRemainingInGoal
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ public class ExecutionControlCommands {
|
||||
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ public class ExecutionControlCommands {
|
||||
}
|
||||
}
|
||||
);
|
||||
pauseCommand = new Command(baritone, "pause", "p") {
|
||||
pauseCommand = new Command(baritone, "pause", "p", "paws") {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
@@ -112,7 +113,7 @@ public class ExecutionControlCommands {
|
||||
);
|
||||
}
|
||||
};
|
||||
resumeCommand = new Command(baritone, "resume", "r", "unpause") {
|
||||
resumeCommand = new Command(baritone, "resume", "r", "unpause", "unpaws") {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
|
||||
@@ -22,13 +22,24 @@ import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.BlockById;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class FindCommand extends Command {
|
||||
|
||||
@@ -38,15 +49,16 @@ public class FindCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMin(1);
|
||||
List<Block> toFind = new ArrayList<>();
|
||||
while (args.hasAny()) {
|
||||
toFind.add(args.getDatatypeFor(BlockById.INSTANCE));
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
toFind.stream()
|
||||
Component[] components = toFind.stream()
|
||||
.flatMap(block ->
|
||||
ctx.worldData().getCachedWorld().getLocationsOf(
|
||||
Registry.BLOCK.getKey(block).getPath(),
|
||||
BuiltInRegistries.BLOCK.getKey(block).getPath(),
|
||||
Integer.MAX_VALUE,
|
||||
origin.x,
|
||||
origin.y,
|
||||
@@ -54,13 +66,39 @@ public class FindCommand extends Command {
|
||||
).stream()
|
||||
)
|
||||
.map(BetterBlockPos::new)
|
||||
.map(BetterBlockPos::toString)
|
||||
.forEach(this::logDirect);
|
||||
.map(this::positionToComponent)
|
||||
.toArray(Component[]::new);
|
||||
if (components.length > 0) {
|
||||
Arrays.asList(components).forEach(this::logDirect);
|
||||
} else {
|
||||
logDirect("No positions known, are you sure the blocks are cached?");
|
||||
}
|
||||
}
|
||||
|
||||
private Component positionToComponent(BetterBlockPos pos) {
|
||||
String positionText = String.format("%s %s %s", pos.x, pos.y, pos.z);
|
||||
String command = String.format("%sgoal %s", FORCE_COMMAND_PREFIX, positionText);
|
||||
MutableComponent baseComponent = Component.literal(pos.toString());
|
||||
MutableComponent hoverComponent = Component.literal("Click to set goal to this position");
|
||||
baseComponent.setStyle(baseComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withInsertion(positionText)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)));
|
||||
return baseComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
||||
return args.tabCompleteDatatype(BlockById.INSTANCE);
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
|
||||
.map(BuiltInRegistries.BLOCK::getKey)
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(args.getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,10 +109,11 @@ public class FindCommand extends Command {
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"",
|
||||
"The find command searches through Baritone's cache and attempts to find the location of the block.",
|
||||
"Tab completion will suggest only cached blocks and uncached blocks can not be found.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> "
|
||||
"> find <block> [...] - Try finding the listed blocks"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -84,7 +85,7 @@ public class FollowCommand extends Command {
|
||||
} else {
|
||||
logDirect("Following these types of entities:");
|
||||
classes.stream()
|
||||
.map(Registry.ENTITY_TYPE::getKey)
|
||||
.map(BuiltInRegistries.ENTITY_TYPE::getKey)
|
||||
.map(Objects::requireNonNull)
|
||||
.map(ResourceLocation::toString)
|
||||
.forEach(this::logDirect);
|
||||
|
||||
@@ -25,16 +25,18 @@ import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
@@ -58,17 +60,17 @@ public class HelpCommand extends Command {
|
||||
command -> {
|
||||
String names = String.join("/", command.getNames());
|
||||
String name = command.getNames().get(0);
|
||||
TextComponent shortDescComponent = new TextComponent(" - " + command.getShortDesc());
|
||||
MutableComponent shortDescComponent = Component.literal(" - " + command.getShortDesc());
|
||||
shortDescComponent.setStyle(shortDescComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
TextComponent namesComponent = new TextComponent(names);
|
||||
MutableComponent namesComponent = Component.literal(names);
|
||||
namesComponent.setStyle(namesComponent.getStyle().withColor(ChatFormatting.WHITE));
|
||||
TextComponent hoverComponent = new TextComponent("");
|
||||
MutableComponent hoverComponent = Component.literal("");
|
||||
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
hoverComponent.append(namesComponent);
|
||||
hoverComponent.append("\n" + command.getShortDesc());
|
||||
hoverComponent.append("\n\nClick to view full help");
|
||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
|
||||
TextComponent component = new TextComponent(name);
|
||||
MutableComponent component = Component.literal(name);
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(shortDescComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
@@ -88,7 +90,7 @@ public class HelpCommand extends Command {
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
BaseComponent returnComponent = new TextComponent("Click to return to the help menu");
|
||||
MutableComponent returnComponent = Component.literal("Click to return to the help menu");
|
||||
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class LitematicaCommand extends Command {
|
||||
|
||||
public LitematicaCommand(IBaritone baritone) {
|
||||
super(baritone, "litematica");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
int schematic = 0;
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(1);
|
||||
if (args.is(Integer.class)) {
|
||||
schematic = args.getAs(Integer.class) - 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
baritone.getBuilderProcess().buildOpenLitematic(schematic);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logDirect("Pleas provide a valid index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Builds the loaded schematic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"Build a schematic currently open in Litematica.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> litematica",
|
||||
"> litematica <#>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,12 @@ public class MineCommand extends Command {
|
||||
return Arrays.asList(
|
||||
"The mine command allows you to tell Baritone to search for and mine individual blocks.",
|
||||
"",
|
||||
"The specified blocks can be ores (which are commonly cached), or any other block.",
|
||||
"The specified blocks can be ores, or any other block.",
|
||||
"",
|
||||
"Also see the legitMine settings (see #set l legitMine).",
|
||||
"",
|
||||
"Usage:",
|
||||
"> mine diamond_ore - Mines all diamonds it can find.",
|
||||
"> mine redstone_ore lit_redstone_ore - Mines redstone ore.",
|
||||
"> mine log:0 - Mines only oak logs."
|
||||
"> mine diamond_ore - Mines all diamonds it can find."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RenderCommand extends Command {
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
int renderDistance = (mc.options.renderDistance + 1) * 16;
|
||||
int renderDistance = (mc.options.renderDistance().get() + 1) * 16;
|
||||
mc.levelRenderer.setBlocksDirty(
|
||||
origin.x - renderDistance,
|
||||
0,
|
||||
|
||||
@@ -36,15 +36,9 @@ import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -52,6 +46,12 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SelCommand extends Command {
|
||||
|
||||
private ISelectionManager manager = baritone.getSelectionManager();
|
||||
@@ -193,7 +193,7 @@ public class SelCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
ISchematic schematic = new StaticSchematic(){{
|
||||
ISchematic schematic = new StaticSchematic() {{
|
||||
states = blockstates;
|
||||
x = size.getX();
|
||||
y = size.getY();
|
||||
|
||||
@@ -28,16 +28,17 @@ import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.utils.SettingsUtil.*;
|
||||
@@ -77,19 +78,19 @@ public class SetCommand extends Command {
|
||||
: String.format("All %ssettings:", viewModified ? "modified " : "")
|
||||
),
|
||||
setting -> {
|
||||
TextComponent typeComponent = new TextComponent(String.format(
|
||||
MutableComponent typeComponent = Component.literal(String.format(
|
||||
" (%s)",
|
||||
settingTypeToString(setting)
|
||||
));
|
||||
typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY);
|
||||
TextComponent hoverComponent = new TextComponent("");
|
||||
hoverComponent.getStyle().withColor(ChatFormatting.GRAY);
|
||||
typeComponent.setStyle(typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
MutableComponent hoverComponent = Component.literal("");
|
||||
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
hoverComponent.append(setting.getName());
|
||||
hoverComponent.append(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
hoverComponent.append(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
hoverComponent.append(String.format("\n\nDefault Value:\n%s", settingDefaultToString(setting)));
|
||||
String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName());
|
||||
TextComponent component = new TextComponent(setting.getName());
|
||||
MutableComponent component = Component.literal(setting.getName());
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(typeComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
@@ -146,7 +147,8 @@ public class SetCommand extends Command {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a toggleable setting", "some other setting");
|
||||
}
|
||||
//noinspection unchecked
|
||||
((Settings.Setting<Boolean>) setting).value ^= true;
|
||||
Settings.Setting<Boolean> asBoolSetting = (Settings.Setting<Boolean>) setting;
|
||||
asBoolSetting.value ^= true;
|
||||
logDirect(String.format(
|
||||
"Toggled setting %s to %s",
|
||||
setting.getName(),
|
||||
@@ -169,12 +171,12 @@ public class SetCommand extends Command {
|
||||
settingValueToString(setting)
|
||||
));
|
||||
}
|
||||
BaseComponent oldValueComponent = new TextComponent(String.format("Old value: %s", oldValue));
|
||||
MutableComponent oldValueComponent = Component.literal(String.format("Old value: %s", oldValue));
|
||||
oldValueComponent.setStyle(oldValueComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to set the setting back to this value")
|
||||
Component.literal("Click to set the setting back to this value")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
|
||||
@@ -20,8 +20,8 @@ package baritone.command.defaults;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.ForWaypoints;
|
||||
@@ -40,17 +40,17 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class WaypointsCommand extends Command {
|
||||
|
||||
private Map<IWorldData,List<IWaypoint>> deletedWaypoints = new HashMap<>();
|
||||
private Map<IWorldData, List<IWaypoint>> deletedWaypoints = new HashMap<>();
|
||||
|
||||
public WaypointsCommand(IBaritone baritone) {
|
||||
super(baritone, "waypoints", "waypoint", "wp");
|
||||
@@ -63,13 +63,13 @@ public class WaypointsCommand extends Command {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
BiFunction<IWaypoint, Action, Component> toComponent = (waypoint, _action) -> {
|
||||
BaseComponent component = new TextComponent("");
|
||||
BaseComponent tagComponent = new TextComponent(waypoint.getTag().name() + " ");
|
||||
MutableComponent component = Component.literal("");
|
||||
MutableComponent tagComponent = Component.literal(waypoint.getTag().name() + " ");
|
||||
tagComponent.setStyle(tagComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
String name = waypoint.getName();
|
||||
BaseComponent nameComponent = new TextComponent(!name.isEmpty() ? name : "<empty>");
|
||||
MutableComponent nameComponent = Component.literal(!name.isEmpty() ? name : "<empty>");
|
||||
nameComponent.setStyle(nameComponent.getStyle().withColor(!name.isEmpty() ? ChatFormatting.GRAY : ChatFormatting.DARK_GRAY));
|
||||
BaseComponent timestamp = new TextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
MutableComponent timestamp = Component.literal(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
timestamp.setStyle(timestamp.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
component.append(tagComponent);
|
||||
component.append(nameComponent);
|
||||
@@ -77,7 +77,7 @@ public class WaypointsCommand extends Command {
|
||||
component.setStyle(component.getStyle()
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to select")
|
||||
Component.literal("Click to select")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
@@ -143,7 +143,7 @@ public class WaypointsCommand extends Command {
|
||||
args.requireMax(0);
|
||||
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
||||
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);
|
||||
BaseComponent component = new TextComponent("Waypoint added: ");
|
||||
MutableComponent component = Component.literal("Waypoint added: ");
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(toComponent.apply(waypoint, Action.INFO));
|
||||
logDirect(component);
|
||||
@@ -155,8 +155,8 @@ public class WaypointsCommand extends Command {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
}
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
|
||||
TextComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
MutableComponent textComponent = Component.literal(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
@@ -164,7 +164,7 @@ public class WaypointsCommand extends Command {
|
||||
label,
|
||||
Stream.of(waypoints).map(wp -> Long.toString(wp.getCreationTimestamp())).collect(Collectors.joining(" "))
|
||||
)
|
||||
));
|
||||
)));
|
||||
logDirect(textComponent);
|
||||
} else if (action == Action.RESTORE) {
|
||||
List<IWaypoint> waypoints = new ArrayList<>();
|
||||
@@ -236,7 +236,7 @@ public class WaypointsCommand extends Command {
|
||||
if (action == Action.INFO) {
|
||||
logDirect(transform.apply(waypoint));
|
||||
logDirect(String.format("Position: %s", waypoint.getLocation()));
|
||||
BaseComponent deleteComponent = new TextComponent("Click to delete this waypoint");
|
||||
MutableComponent deleteComponent = Component.literal("Click to delete this waypoint");
|
||||
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -247,7 +247,7 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
BaseComponent goalComponent = new TextComponent("Click to set goal to this waypoint");
|
||||
MutableComponent goalComponent = Component.literal("Click to set goal to this waypoint");
|
||||
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
@@ -258,8 +258,8 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
BaseComponent recreateComponent = new TextComponent("Click to show a command to recreate this waypoint");
|
||||
recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
MutableComponent recreateComponent = Component.literal("Click to show a command to recreate this waypoint");
|
||||
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
String.format(
|
||||
"%s%s save %s %s %s %s %s",
|
||||
@@ -271,16 +271,16 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getLocation().y,
|
||||
waypoint.getLocation().z
|
||||
)
|
||||
));
|
||||
BaseComponent backComponent = new TextComponent("Click to return to the waypoints list");
|
||||
backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
)));
|
||||
MutableComponent backComponent = Component.literal("Click to return to the waypoints list");
|
||||
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s list",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label
|
||||
)
|
||||
));
|
||||
)));
|
||||
logDirect(deleteComponent);
|
||||
logDirect(goalComponent);
|
||||
logDirect(recreateComponent);
|
||||
@@ -288,8 +288,8 @@ public class WaypointsCommand extends Command {
|
||||
} else if (action == Action.DELETE) {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
|
||||
TextComponent textComponent = new TextComponent("That waypoint has successfully been deleted, click to restore it");
|
||||
textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
MutableComponent textComponent = Component.literal("That waypoint has successfully been deleted, click to restore it");
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
@@ -297,7 +297,7 @@ public class WaypointsCommand extends Command {
|
||||
label,
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
)));
|
||||
logDirect(textComponent);
|
||||
} else if (action == Action.GOAL) {
|
||||
Goal goal = new GoalBlock(waypoint.getLocation());
|
||||
|
||||
@@ -21,19 +21,24 @@ import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.cache.WorldData;
|
||||
import baritone.pathing.precompute.PrecomputedData;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
|
||||
/**
|
||||
@@ -55,11 +60,13 @@ public class CalculationContext {
|
||||
public final boolean canSprint;
|
||||
protected final double placeBlockCost; // protected because you should call the function instead
|
||||
public final boolean allowBreak;
|
||||
public final List<Block> allowBreakAnyway;
|
||||
public final boolean allowParkour;
|
||||
public final boolean allowParkourPlace;
|
||||
public final boolean allowJumpAt256;
|
||||
public final boolean allowParkourAscend;
|
||||
public final boolean assumeWalkOnWater;
|
||||
public final int frostWalker;
|
||||
public final boolean allowDiagonalDescend;
|
||||
public final boolean allowDiagonalAscend;
|
||||
public final boolean allowDownward;
|
||||
@@ -72,11 +79,14 @@ public class CalculationContext {
|
||||
public final double walkOnWaterOnePenalty;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
public final PrecomputedData precomputedData;
|
||||
|
||||
public CalculationContext(IBaritone baritone) {
|
||||
this(baritone, false);
|
||||
}
|
||||
|
||||
public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
|
||||
this.precomputedData = new PrecomputedData();
|
||||
this.safeForThreadedUse = forUseOnAnotherThread;
|
||||
this.baritone = baritone;
|
||||
LocalPlayer player = baritone.getPlayerContext().player();
|
||||
@@ -89,11 +99,13 @@ public class CalculationContext {
|
||||
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodData().getFoodLevel() > 6;
|
||||
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
|
||||
this.allowBreak = Baritone.settings().allowBreak.value;
|
||||
this.allowBreakAnyway = new ArrayList<>(Baritone.settings().allowBreakAnyway.value);
|
||||
this.allowParkour = Baritone.settings().allowParkour.value;
|
||||
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
|
||||
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
|
||||
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
||||
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
||||
this.frostWalker = EnchantmentHelper.getEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
|
||||
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
||||
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
||||
this.allowDownward = Baritone.settings().allowDownward.value;
|
||||
@@ -143,14 +155,13 @@ public class CalculationContext {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!worldBorder.canPlaceAt(x, z)) {
|
||||
// TODO perhaps MovementHelper.canPlaceAgainst could also use this?
|
||||
return COST_INF;
|
||||
}
|
||||
return placeBlockCost;
|
||||
}
|
||||
|
||||
public double breakCostMultiplierAt(int x, int y, int z, BlockState current) {
|
||||
if (!allowBreak) {
|
||||
if (!allowBreak && !allowBreakAnyway.contains(current.getBlock())) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (isPossiblyProtected(x, y, z)) {
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
||||
public MovementStatus update() {
|
||||
ctx.player().getAbilities().flying = false;
|
||||
currentState = updateState(currentState);
|
||||
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
||||
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && ctx.player().position().y < dest.y + 0.6) {
|
||||
currentState.setInput(Input.JUMP, true);
|
||||
}
|
||||
if (ctx.player().isInWall()) {
|
||||
|
||||
@@ -26,29 +26,34 @@ import baritone.api.utils.*;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||
import baritone.pathing.precompute.Ternary;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.piston.MovingPistonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP;
|
||||
import static baritone.pathing.precompute.Ternary.*;
|
||||
|
||||
/**
|
||||
* Static helpers for cost calculation
|
||||
@@ -58,6 +63,9 @@ import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____S
|
||||
public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, z)) {
|
||||
return true;
|
||||
}
|
||||
Block b = state.getBlock();
|
||||
return Baritone.settings().blocksToDisallowBreaking.value.contains(b)
|
||||
|| b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||
@@ -83,6 +91,19 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
&& FallingBlock.isFree(bsi.get0(x, y - 1, z))) { // and if it would fall (i.e. it's unsupported)
|
||||
return true; // dont break a block that is adjacent to unsupported gravel because it can cause really weird stuff
|
||||
}
|
||||
// only pure liquids for now
|
||||
// waterlogged blocks can have closed bottom sides and such
|
||||
if (block instanceof LiquidBlock) {
|
||||
if (directlyAbove || Baritone.settings().strictLiquidCheck.value) {
|
||||
return true;
|
||||
}
|
||||
int level = state.getValue(LiquidBlock.LEVEL);
|
||||
if (level == 0) {
|
||||
return true; // source blocks like to flow horizontally
|
||||
}
|
||||
// everything else will prefer flowing down
|
||||
return !(bsi.get0(x, y - 1, z).getBlock() instanceof LiquidBlock); // assume everything is in a static state
|
||||
}
|
||||
return !state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@@ -94,32 +115,88 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkThrough(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.canWalkThrough(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z) {
|
||||
return context.precomputedData.canWalkThrough(context.bsi, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) { // early return for most common case
|
||||
Ternary canWalkThrough = canWalkThroughBlockState(state);
|
||||
if (canWalkThrough == YES) {
|
||||
return true;
|
||||
}
|
||||
if (block instanceof BaseFireBlock || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK || block == Blocks.END_ROD || block == Blocks.POINTED_DRIPSTONE || block == Blocks.AMETHYST_CLUSTER || block instanceof AzaleaBlock) {
|
||||
if (canWalkThrough == NO) {
|
||||
return false;
|
||||
}
|
||||
return canWalkThroughPosition(bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static Ternary canWalkThroughBlockState(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof BaseFireBlock || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK || block == Blocks.END_ROD || block == Blocks.SWEET_BERRY_BUSH || block == Blocks.POINTED_DRIPSTONE || block instanceof AmethystClusterBlock || block instanceof AzaleaBlock) {
|
||||
return NO;
|
||||
}
|
||||
if (block == Blocks.BIG_DRIPLEAF) {
|
||||
return false;
|
||||
return NO;
|
||||
}
|
||||
if (block == Blocks.POWDER_SNOW) {
|
||||
return NO;
|
||||
}
|
||||
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||
return false;
|
||||
return NO;
|
||||
}
|
||||
if (block instanceof DoorBlock || block instanceof FenceGateBlock) {
|
||||
// Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume
|
||||
// that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't
|
||||
// be opened by just interacting.
|
||||
return block != Blocks.IRON_DOOR;
|
||||
// TODO this assumes that all doors in all mods are openable
|
||||
if (block == Blocks.IRON_DOOR) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof WoolCarpetBlock) {
|
||||
return canWalkOn(bsi, x, y - 1, z);
|
||||
if (block instanceof CarpetBlock) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (block instanceof SnowLayerBlock) {
|
||||
// we've already checked doors and fence gates
|
||||
// so the only remaining dynamic isPassables are snow and trapdoor
|
||||
// snow layers cached as the top layer of a packed chunk have no metadata, we can't make a decision based on their depth here
|
||||
// it would otherwise make long distance pathing through snowy biomes impossible
|
||||
return MAYBE;
|
||||
}
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (!fluidState.isEmpty()) {
|
||||
if (fluidState.getType().getAmount(fluidState) != 8) {
|
||||
return NO;
|
||||
} else {
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
if (block instanceof CauldronBlock) {
|
||||
return NO;
|
||||
}
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean canWalkThroughPosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block instanceof CarpetBlock) {
|
||||
return canWalkOn(bsi, x, y - 1, z);
|
||||
}
|
||||
|
||||
if (block instanceof SnowLayerBlock) {
|
||||
// if they're cached as a top block, we don't know their metadata
|
||||
// default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
||||
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
||||
@@ -134,52 +211,33 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkOn(bsi, x, y - 1, z);
|
||||
}
|
||||
|
||||
if (isFlowing(x, y, z, state, bsi)) {
|
||||
return false; // Don't walk through flowing liquids
|
||||
}
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (fluidState.getType() instanceof WaterFluid) {
|
||||
if (!fluidState.isEmpty()) {
|
||||
if (isFlowing(x, y, z, state, bsi)) {
|
||||
return false;
|
||||
}
|
||||
// Everything after this point has to be a special case as it relies on the water not being flowing, which means a special case is needed.
|
||||
if (Baritone.settings().assumeWalkOnWater.value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState up = bsi.get0(x, y + 1, z);
|
||||
if (!up.getFluidState().isEmpty() || up.getBlock() instanceof WaterlilyBlock) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return fluidState.getType() instanceof WaterFluid;
|
||||
}
|
||||
|
||||
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
||||
// has already been accounted for above
|
||||
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
||||
return state.isPathfindable(bsi.access, BlockPos.ZERO, PathComputationType.LAND); // workaround for future compatibility =P
|
||||
}
|
||||
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*
|
||||
* @param context Calculation context to provide block state lookup
|
||||
* @param x The block's x position
|
||||
* @param y The block's y position
|
||||
* @param z The block's z position
|
||||
* @return Whether or not the block at the specified position
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(
|
||||
context.bsi.access,
|
||||
context.bsi.isPassableBlockPos.set(x, y, z),
|
||||
context.bsi.get0(x, y, z)
|
||||
);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
return fullyPassable(ctx.world(), pos, ctx.world().getBlockState(pos));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(BlockGetter access, BlockPos pos, BlockState state) {
|
||||
static Ternary fullyPassableBlockState(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) { // early return for most common case
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
// exceptions - blocks that are isPassable true, but we can't actually jump through
|
||||
if (block instanceof BaseFireBlock
|
||||
@@ -197,10 +255,49 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|| block instanceof EndPortalBlock
|
||||
|| block instanceof SkullBlock
|
||||
|| block instanceof ShulkerBoxBlock) {
|
||||
return false;
|
||||
return NO;
|
||||
}
|
||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||
return state.isPathfindable(access, pos, PathComputationType.LAND);
|
||||
// at least in 1.12.2 vanilla, that is.....
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
// see PR #1087 for why
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(context, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.fullyPassable(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
BlockState state = ctx.world().getBlockState(pos);
|
||||
Ternary fullyPassable = fullyPassableBlockState(state);
|
||||
if (fullyPassable == YES) {
|
||||
return true;
|
||||
}
|
||||
if (fullyPassable == NO) {
|
||||
return false;
|
||||
}
|
||||
return fullyPassablePosition(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), state); // meh
|
||||
}
|
||||
|
||||
static boolean fullyPassablePosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
return state.isPathfindable(bsi.access, bsi.isPassableBlockPos.set(x, y, z), PathComputationType.LAND);
|
||||
}
|
||||
|
||||
static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||
@@ -229,7 +326,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
return state.canBeReplaced();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -288,6 +385,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return !state.getFluidState().isEmpty()
|
||||
|| block == Blocks.MAGMA_BLOCK
|
||||
|| block == Blocks.CACTUS
|
||||
|| block == Blocks.SWEET_BERRY_BUSH
|
||||
|| block instanceof BaseFireBlock
|
||||
|| block == Blocks.END_PORTAL
|
||||
|| block == Blocks.COBWEB
|
||||
@@ -298,6 +396,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
* Can I walk on this block without anything weird happening like me falling
|
||||
* through? Includes water because we know that we automatically jump on
|
||||
* water
|
||||
* <p>
|
||||
* If changing something in this function remember to also change it in precomputed data
|
||||
*
|
||||
* @param bsi Block state provider
|
||||
* @param x The block's x position
|
||||
@@ -307,36 +407,68 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
* @return Whether or not the specified block can be walked on
|
||||
*/
|
||||
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN || block == Blocks.HONEY_BLOCK) {
|
||||
// early return for most common case (air)
|
||||
// plus magma, which is a normal cube but it hurts you
|
||||
Ternary canWalkOn = canWalkOnBlockState(state);
|
||||
if (canWalkOn == YES) {
|
||||
return true;
|
||||
}
|
||||
if (canWalkOn == NO) {
|
||||
return false;
|
||||
}
|
||||
if (isBlockNormalCube(state)) {
|
||||
return true;
|
||||
return canWalkOnPosition(bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static Ternary canWalkOnBlockState(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (isBlockNormalCube(state) && block != Blocks.MAGMA_BLOCK && block != Blocks.BUBBLE_COLUMN && block != Blocks.HONEY_BLOCK) {
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof AzaleaBlock) {
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
if (block == Blocks.FARMLAND || block == Blocks.DIRT_PATH) {
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
|
||||
return true;
|
||||
return YES;
|
||||
}
|
||||
if (block == Blocks.GLASS || block instanceof StainedGlassBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof StairBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (isWater(state)) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (MovementHelper.isLava(state) && Baritone.settings().assumeWalkOnLava.value) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (block instanceof SlabBlock) {
|
||||
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
static boolean canWalkOnPosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (isWater(state)) {
|
||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||
BlockState upState = bsi.get0(x, y + 1, z);
|
||||
Block up = upState.getBlock();
|
||||
if (up == Blocks.LILY_PAD || up instanceof WoolCarpetBlock) {
|
||||
if (up == Blocks.LILY_PAD || up instanceof CarpetBlock) {
|
||||
return true;
|
||||
}
|
||||
if (isFlowing(x, y, z, state, bsi) || upState.getFluidState().getType() == Fluids.FLOWING_WATER) {
|
||||
if (MovementHelper.isFlowing(x, y, z, state, bsi) || upState.getFluidState().getType() == Fluids.FLOWING_WATER) {
|
||||
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
||||
return isWater(upState) && !Baritone.settings().assumeWalkOnWater.value;
|
||||
}
|
||||
@@ -344,19 +476,20 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
||||
return isWater(upState) ^ Baritone.settings().assumeWalkOnWater.value;
|
||||
}
|
||||
if (Baritone.settings().assumeWalkOnLava.value && isLava(state) && !isFlowing(x, y, z, state, bsi)) {
|
||||
|
||||
if (MovementHelper.isLava(state) && !MovementHelper.isFlowing(x, y, z, state, bsi) && Baritone.settings().assumeWalkOnLava.value) { // if we get here it means that assumeWalkOnLava must be true, so put it last
|
||||
return true;
|
||||
}
|
||||
if (block == Blocks.GLASS || block instanceof StainedGlassBlock) {
|
||||
return true;
|
||||
}
|
||||
if (block instanceof SlabBlock) {
|
||||
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
||||
return state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return block instanceof StairBlock;
|
||||
|
||||
return false; // If we don't recognise it then we want to just return false to be safe.
|
||||
}
|
||||
|
||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.canWalkOn(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z) {
|
||||
return canWalkOn(context, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, BlockState state) {
|
||||
@@ -375,6 +508,61 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkOn(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
|
||||
return context.frostWalker != 0
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
return EnchantmentHelper.hasFrostWalker(ctx.player())
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If movements make us stand/walk on this block, will it have a top to walk on?
|
||||
*/
|
||||
static boolean mustBeSolidToWalkOn(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
||||
return false;
|
||||
}
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
// used for frostwalker so only includes blocks where we are still on ground when leaving them to any side
|
||||
if (block instanceof SlabBlock) {
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM) {
|
||||
return true;
|
||||
}
|
||||
} else if (block instanceof StairBlock) {
|
||||
if (state.getValue(StairBlock.HALF) == Half.TOP) {
|
||||
return true;
|
||||
}
|
||||
StairsShape shape = state.getValue(StairBlock.SHAPE);
|
||||
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT) {
|
||||
return true;
|
||||
}
|
||||
} else if (block instanceof TrapDoorBlock) {
|
||||
if (!state.getValue(TrapDoorBlock.OPEN) && state.getValue(TrapDoorBlock.HALF) == Half.TOP) {
|
||||
return true;
|
||||
}
|
||||
} else if (block == Blocks.SCAFFOLDING) {
|
||||
return true;
|
||||
} else if (block instanceof LeavesBlock) {
|
||||
return true;
|
||||
}
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false;
|
||||
}
|
||||
Block blockAbove = context.getBlock(x, y + 1, z);
|
||||
if (blockAbove instanceof LiquidBlock) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
||||
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
@@ -388,6 +576,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, z)) {
|
||||
return false;
|
||||
}
|
||||
// can we look at the center of a side face of this block and likely be able to place?
|
||||
// (thats how this check is used)
|
||||
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
||||
@@ -400,7 +591,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, BlockState state, boolean includeFalling) {
|
||||
Block block = state.getBlock();
|
||||
if (!canWalkThrough(context.bsi, x, y, z, state)) {
|
||||
if (!canWalkThrough(context, x, y, z, state)) {
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
return COST_INF;
|
||||
}
|
||||
@@ -532,7 +723,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean isBlockNormalCube(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BambooBlock
|
||||
if (block instanceof BambooStalkBlock
|
||||
|| block instanceof MovingPistonBlock
|
||||
|| block instanceof ScaffoldingBlock
|
||||
|| block instanceof ShulkerBoxBlock
|
||||
@@ -609,7 +800,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean isTransparent(Block b) {
|
||||
|
||||
return b == Blocks.AIR ||
|
||||
return b instanceof AirBlock ||
|
||||
b == Blocks.LAVA ||
|
||||
b == Blocks.WATER;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MovementAscend extends Movement {
|
||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||
BlockState toPlace = context.get(destX, y, destZ);
|
||||
double additionalPlacementCost = 0;
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
||||
if (!MovementHelper.canWalkOn(context, destX, y, destZ, toPlace)) {
|
||||
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ, toPlace);
|
||||
if (additionalPlacementCost >= COST_INF) {
|
||||
return COST_INF;
|
||||
@@ -93,7 +93,7 @@ public class MovementAscend extends Movement {
|
||||
}
|
||||
}
|
||||
BlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway
|
||||
if (context.get(x, y + 3, z).getBlock() instanceof FallingBlock && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof FallingBlock))) {//it would fall on us and possibly suffocate us
|
||||
if (context.get(x, y + 3, z).getBlock() instanceof FallingBlock && (MovementHelper.canWalkThrough(context, x, y + 1, z) || !(srcUp2.getBlock() instanceof FallingBlock))) {//it would fall on us and possibly suffocate us
|
||||
// HOWEVER, we assume that we're standing in the start position
|
||||
// that means that src and src.up(1) are both air
|
||||
// maybe they aren't now, but they will be by the time this starts
|
||||
|
||||
@@ -42,6 +42,7 @@ import net.minecraft.world.phys.Vec3;
|
||||
public class MovementDescend extends Movement {
|
||||
|
||||
private int numTicks = 0;
|
||||
public boolean forceSafeMode = false;
|
||||
|
||||
public MovementDescend(IBaritone baritone, BetterBlockPos start, BetterBlockPos end) {
|
||||
super(baritone, start, end, new BetterBlockPos[]{end.above(2), end.above(), end}, end.below());
|
||||
@@ -51,6 +52,14 @@ public class MovementDescend extends Movement {
|
||||
public void reset() {
|
||||
super.reset();
|
||||
numTicks = 0;
|
||||
forceSafeMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by PathExecutor if needing safeMode can only be detected with knowledge about the next movement
|
||||
*/
|
||||
public void forceSafeMode() {
|
||||
forceSafeMode = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +109,7 @@ public class MovementDescend extends Movement {
|
||||
//C, D, etc determine the length of the fall
|
||||
|
||||
BlockState below = context.get(destX, y - 2, destZ);
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ, below)) {
|
||||
if (!MovementHelper.canWalkOn(context, destX, y - 2, destZ, below)) {
|
||||
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
||||
return;
|
||||
}
|
||||
@@ -108,6 +117,9 @@ public class MovementDescend extends Movement {
|
||||
if (destDown.getBlock() == Blocks.LADDER || destDown.getBlock() == Blocks.VINE) {
|
||||
return;
|
||||
}
|
||||
if (MovementHelper.canUseFrostWalker(context, destDown)) { // no need to check assumeWalkOnWater
|
||||
return; // the water will freeze when we try to walk into it
|
||||
}
|
||||
|
||||
// we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel)
|
||||
double walk = WALK_OFF_BLOCK_COST;
|
||||
@@ -129,7 +141,7 @@ public class MovementDescend extends Movement {
|
||||
// and potentially replace the water we're going to fall into
|
||||
return false;
|
||||
}
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y - 2, destZ, below)) {
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y - 2, destZ, below)) {
|
||||
return false;
|
||||
}
|
||||
double costSoFar = 0;
|
||||
@@ -145,7 +157,7 @@ public class MovementDescend extends Movement {
|
||||
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
||||
if (MovementHelper.isWater(ontoBlock)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
if (!MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
||||
return false;
|
||||
}
|
||||
if (context.assumeWalkOnWater) {
|
||||
@@ -154,7 +166,7 @@ public class MovementDescend extends Movement {
|
||||
if (MovementHelper.isFlowing(destX, newY, destZ, ontoBlock, context.bsi)) {
|
||||
return false; // TODO flowing check required here?
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY - 1, destZ)) {
|
||||
if (!MovementHelper.canWalkOn(context, destX, newY - 1, destZ)) {
|
||||
// we could punch right through the water into something else
|
||||
return false;
|
||||
}
|
||||
@@ -173,10 +185,10 @@ public class MovementDescend extends Movement {
|
||||
effectiveStartHeight = newY;
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
if (MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
if (!MovementHelper.canWalkOn(context, destX, newY, destZ, ontoBlock)) {
|
||||
return false;
|
||||
}
|
||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||
@@ -247,6 +259,9 @@ public class MovementDescend extends Movement {
|
||||
}
|
||||
|
||||
public boolean safeMode() {
|
||||
if (forceSafeMode) {
|
||||
return true;
|
||||
}
|
||||
// (dest - src) + dest is offset 1 more in the same direction
|
||||
// so it's the block we'd need to worry about running into if we decide to sprint straight through this descend
|
||||
BlockPos into = dest.subtract(src.below()).offset(dest);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MovementDiagonal extends Movement {
|
||||
@Override
|
||||
protected boolean safeToCancel(MovementState state) {
|
||||
//too simple. backfill does not work after cornering with this
|
||||
//return MovementHelper.canWalkOn(ctx, ctx.playerFeet().down());
|
||||
//return context.precomputedData.canWalkOn(ctx, ctx.playerFeet().down());
|
||||
LocalPlayer player = ctx.player();
|
||||
double offset = 0.25;
|
||||
double x = player.position().x;
|
||||
@@ -109,40 +109,49 @@ public class MovementDiagonal extends Movement {
|
||||
}
|
||||
|
||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y + 1, destZ)) {
|
||||
return;
|
||||
}
|
||||
BlockState destInto = context.get(destX, y, destZ);
|
||||
BlockState fromDown;
|
||||
boolean ascend = false;
|
||||
BlockState destWalkOn;
|
||||
boolean descend = false;
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto)) {
|
||||
boolean frostWalker = false;
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y, destZ, destInto)) {
|
||||
ascend = true;
|
||||
if (!context.allowDiagonalAscend || !MovementHelper.canWalkThrough(context.bsi, x, y + 2, z) || !MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 2, destZ)) {
|
||||
if (!context.allowDiagonalAscend || !MovementHelper.canWalkThrough(context, x, y + 2, z) || !MovementHelper.canWalkOn(context, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context, destX, y + 2, destZ)) {
|
||||
return;
|
||||
}
|
||||
destWalkOn = destInto;
|
||||
fromDown = context.get(x, y - 1, z);
|
||||
} else {
|
||||
destWalkOn = context.get(destX, y - 1, destZ);
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
fromDown = context.get(x, y - 1, z);
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, fromDown);
|
||||
frostWalker = standingOnABlock && MovementHelper.canUseFrostWalker(context, destWalkOn);
|
||||
if (!frostWalker && !MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn)) {
|
||||
descend = true;
|
||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context, destX, y - 1, destZ, destWalkOn)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
frostWalker &= !context.assumeWalkOnWater; // do this after checking for descends because jesus can't prevent the water from freezing, it just prevents us from relying on the water freezing
|
||||
}
|
||||
double multiplier = WALK_ONE_BLOCK_COST;
|
||||
// For either possible soul sand, that affects half of our walking
|
||||
if (destWalkOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (frostWalker) {
|
||||
// frostwalker lets us walk on water without the penalty
|
||||
} else if (destWalkOn.getBlock() == Blocks.WATER) {
|
||||
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
|
||||
}
|
||||
Block fromDown = context.get(x, y - 1, z).getBlock();
|
||||
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
||||
Block fromDownBlock = fromDown.getBlock();
|
||||
if (fromDownBlock == Blocks.LADDER || fromDownBlock == Blocks.VINE) {
|
||||
return;
|
||||
}
|
||||
if (fromDown == Blocks.SOUL_SAND) {
|
||||
if (fromDownBlock == Blocks.SOUL_SAND) {
|
||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
}
|
||||
BlockState cuttingOver1 = context.get(x, y - 1, destZ);
|
||||
@@ -169,17 +178,17 @@ public class MovementDiagonal extends Movement {
|
||||
BlockState pb0 = context.get(x, y, destZ);
|
||||
BlockState pb2 = context.get(destX, y, z);
|
||||
if (ascend) {
|
||||
boolean ATop = MovementHelper.canWalkThrough(context.bsi, x, y + 2, destZ);
|
||||
boolean AMid = MovementHelper.canWalkThrough(context.bsi, x, y + 1, destZ);
|
||||
boolean ALow = MovementHelper.canWalkThrough(context.bsi, x, y, destZ, pb0);
|
||||
boolean BTop = MovementHelper.canWalkThrough(context.bsi, destX, y + 2, z);
|
||||
boolean BMid = MovementHelper.canWalkThrough(context.bsi, destX, y + 1, z);
|
||||
boolean BLow = MovementHelper.canWalkThrough(context.bsi, destX, y, z, pb2);
|
||||
boolean ATop = MovementHelper.canWalkThrough(context, x, y + 2, destZ);
|
||||
boolean AMid = MovementHelper.canWalkThrough(context, x, y + 1, destZ);
|
||||
boolean ALow = MovementHelper.canWalkThrough(context, x, y, destZ, pb0);
|
||||
boolean BTop = MovementHelper.canWalkThrough(context, destX, y + 2, z);
|
||||
boolean BMid = MovementHelper.canWalkThrough(context, destX, y + 1, z);
|
||||
boolean BLow = MovementHelper.canWalkThrough(context, destX, y, z, pb2);
|
||||
if ((!(ATop && AMid && ALow) && !(BTop && BMid && BLow)) // no option
|
||||
|| MovementHelper.avoidWalkingInto(pb0) // bad
|
||||
|| MovementHelper.avoidWalkingInto(pb2) // bad
|
||||
|| (ATop && AMid && MovementHelper.canWalkOn(context.bsi, x, y, destZ, pb0)) // we could just ascend
|
||||
|| (BTop && BMid && MovementHelper.canWalkOn(context.bsi, destX, y, z, pb2)) // we could just ascend
|
||||
|| (ATop && AMid && MovementHelper.canWalkOn(context, x, y, destZ, pb0)) // we could just ascend
|
||||
|| (BTop && BMid && MovementHelper.canWalkOn(context, destX, y, z, pb2)) // we could just ascend
|
||||
|| (!ATop && AMid && ALow) // head bonk A
|
||||
|| (!BTop && BMid && BLow)) { // head bonk B
|
||||
return;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MovementDownward extends Movement {
|
||||
if (!context.allowDownward) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context.bsi, x, y - 2, z)) {
|
||||
if (!MovementHelper.canWalkOn(context, x, y - 2, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
BlockState down = context.get(x, y - 1, z);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MovementFall extends Movement {
|
||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||
}
|
||||
|
||||
if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().isOnGround()) {
|
||||
if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround()) {
|
||||
ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER);
|
||||
|
||||
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
||||
@@ -135,7 +135,7 @@ public class MovementFall extends Movement {
|
||||
}
|
||||
Vec3 destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder)
|
||||
if (Math.abs(ctx.player().position().x + ctx.player().getDeltaMovement().x - destCenter.x) > 0.1 || Math.abs(ctx.player().position().z + ctx.player().getDeltaMovement().z - destCenter.z) > 0.1) {
|
||||
if (!ctx.player().isOnGround() && Math.abs(ctx.player().getDeltaMovement().y) > 0.4) {
|
||||
if (!ctx.player().onGround() && Math.abs(ctx.player().getDeltaMovement().y) > 0.4) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
state.setInput(Input.MOVE_FORWARD, true);
|
||||
@@ -147,7 +147,7 @@ public class MovementFall extends Movement {
|
||||
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().position().x)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().position().z));
|
||||
if (dist < 0.6) {
|
||||
state.setInput(Input.MOVE_FORWARD, true);
|
||||
} else if (!ctx.player().isOnGround()) {
|
||||
} else if (!ctx.player().onGround()) {
|
||||
state.setInput(Input.SNEAK, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.pathing.movement.movements;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.movement.MovementStatus;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
@@ -27,16 +28,16 @@ import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.movement.MovementState;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.pathing.MutableMoveResult;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementParkour extends Movement {
|
||||
|
||||
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
||||
@@ -74,7 +75,7 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
BlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
||||
if (MovementHelper.canWalkOn(context.bsi, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||
if (MovementHelper.canWalkOn(context, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||
// second most common case -- we could just traverse not parkour
|
||||
return;
|
||||
}
|
||||
@@ -91,9 +92,16 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
BlockState standingOn = context.get(x, y - 1, z);
|
||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof StairBlock || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getType() != Fluids.EMPTY) {
|
||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof StairBlock || MovementHelper.isBottomSlab(standingOn)) {
|
||||
return;
|
||||
}
|
||||
// we can't jump from (frozen) water with assumeWalkOnWater because we can't be sure it will be frozen
|
||||
if (context.assumeWalkOnWater && !standingOn.getFluidState().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!context.get(x, y, z).getFluidState().isEmpty()) {
|
||||
return; // can't jump out of water
|
||||
}
|
||||
int maxJump;
|
||||
if (standingOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
maxJump = 2; // 1 block gap
|
||||
@@ -104,13 +112,13 @@ public class MovementParkour extends Movement {
|
||||
maxJump = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check parkour jumps from smallest to largest for obstacles/walls and landing positions
|
||||
int verifiedMaxJump = 1; // i - 1 (when i = 2)
|
||||
for (int i = 2; i <= maxJump; i++) {
|
||||
int destX = x + xDiff * i;
|
||||
int destZ = z + zDiff * i;
|
||||
|
||||
|
||||
// check head/feet
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) {
|
||||
break;
|
||||
@@ -118,11 +126,11 @@ public class MovementParkour extends Movement {
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for ascend landing position
|
||||
BlockState destInto = context.bsi.get0(destX, y, destZ);
|
||||
if (!MovementHelper.fullyPassable(context.bsi.access, context.bsi.isPassableBlockPos.set(destX, y, destZ), destInto)) {
|
||||
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
|
||||
if (!MovementHelper.fullyPassable(context, destX, y, destZ, destInto)) {
|
||||
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
|
||||
res.x = destX;
|
||||
res.y = y + 1;
|
||||
res.z = destZ;
|
||||
@@ -131,11 +139,14 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for flat landing position
|
||||
BlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
|
||||
// farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
|
||||
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) {
|
||||
// frostwalker works here because we can't jump from possibly unfrozen water
|
||||
if ((landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context, destX, y - 1, destZ, landingOn))
|
||||
|| (Math.min(16, context.frostWalker + 2) >= i && MovementHelper.canUseFrostWalker(context, landingOn))
|
||||
) {
|
||||
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
|
||||
res.x = destX;
|
||||
res.y = y;
|
||||
@@ -145,14 +156,14 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
verifiedMaxJump = i;
|
||||
}
|
||||
|
||||
|
||||
// parkour place starts here
|
||||
if (!context.allowParkourPlace) {
|
||||
return;
|
||||
@@ -265,7 +276,12 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
} else if (!ctx.playerFeet().equals(src)) {
|
||||
if (ctx.playerFeet().equals(src.relative(direction)) || ctx.player().position().y - src.y > 0.0001) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.below()) && !ctx.player().isOnGround() && MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), true, false) == PlaceResult.READY_TO_PLACE) {
|
||||
if (Baritone.settings().allowPlace.value // see PR #3775
|
||||
&& ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway()
|
||||
&& !MovementHelper.canWalkOn(ctx, dest.below())
|
||||
&& !ctx.player().onGround()
|
||||
&& MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), true, false) == PlaceResult.READY_TO_PLACE
|
||||
) {
|
||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||
state.setInput(Input.CLICK_RIGHT, true);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CarpetBlock;
|
||||
import net.minecraft.world.level.block.FallingBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.LadderBlock;
|
||||
@@ -42,6 +43,7 @@ import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementPillar extends Movement {
|
||||
@@ -105,6 +107,10 @@ public class MovementPillar extends Movement {
|
||||
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
|
||||
return COST_INF;
|
||||
}
|
||||
if ((from == Blocks.LILY_PAD || from instanceof CarpetBlock) && !fromDown.getFluidState().isEmpty()) {
|
||||
// to ascend here we'd have to break the block we are standing on
|
||||
return COST_INF;
|
||||
}
|
||||
double hardness = MovementHelper.getMiningDurationTicks(context, x, y + 2, z, toBreak, true);
|
||||
if (hardness >= COST_INF) {
|
||||
return COST_INF;
|
||||
@@ -124,7 +130,7 @@ public class MovementPillar extends Movement {
|
||||
}
|
||||
}
|
||||
// this is commented because it may have had a purpose, but it's very unclear what it was. it's from the minebot era.
|
||||
//if (!MovementHelper.canWalkOn(chkPos, check) || MovementHelper.canWalkThrough(chkPos, check)) {//if the block above where we want to break is not a full block, don't do it
|
||||
//if (!MovementHelper.canWalkOn(context, chkPos, check) || MovementHelper.canWalkThrough(context, chkPos, check)) {//if the block above where we want to break is not a full block, don't do it
|
||||
// TODO why does canWalkThrough mean this action is COST_INF?
|
||||
// FallingBlock makes sense, and !canWalkOn deals with weird cases like if it were lava
|
||||
// but I don't understand why canWalkThrough makes it impossible
|
||||
@@ -250,7 +256,7 @@ public class MovementPillar extends Movement {
|
||||
BlockState frState = BlockStateInterface.get(ctx, src);
|
||||
Block fr = frState.getBlock();
|
||||
// TODO: Evaluate usage of getMaterial().isReplaceable()
|
||||
if (!(fr instanceof AirBlock || frState.getMaterial().isReplaceable())) {
|
||||
if (!(fr instanceof AirBlock || frState.canBeReplaced())) {
|
||||
RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance())
|
||||
.map(rot -> new MovementState.MovementTarget(rot, true))
|
||||
.ifPresent(state::setTarget);
|
||||
|
||||
@@ -35,14 +35,15 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CarpetBlock;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.LadderBlock;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -70,16 +71,18 @@ public class MovementTraverse extends Movement {
|
||||
|
||||
@Override
|
||||
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||
return ImmutableSet.of(src, dest);
|
||||
return ImmutableSet.of(src, dest); // src.above means that we don't get caught in an infinite loop in water
|
||||
}
|
||||
|
||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||
BlockState pb0 = context.get(destX, y + 1, destZ);
|
||||
BlockState pb1 = context.get(destX, y, destZ);
|
||||
BlockState destOn = context.get(destX, y - 1, destZ);
|
||||
BlockState down = context.get(x, y - 1, z);
|
||||
Block srcDown = down.getBlock();
|
||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||
BlockState srcDown = context.get(x, y - 1, z);
|
||||
Block srcDownBlock = srcDown.getBlock();
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, srcDown);
|
||||
boolean frostWalker = standingOnABlock && !context.assumeWalkOnWater && MovementHelper.canUseFrostWalker(context, destOn);
|
||||
if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge
|
||||
double WC = WALK_ONE_BLOCK_COST;
|
||||
boolean water = false;
|
||||
if (MovementHelper.isWater(pb0) || MovementHelper.isWater(pb1)) {
|
||||
@@ -88,10 +91,12 @@ public class MovementTraverse extends Movement {
|
||||
} else {
|
||||
if (destOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (frostWalker) {
|
||||
// with frostwalker we can walk on water without the penalty, if we are sure we won't be using jesus
|
||||
} else if (destOn.getBlock() == Blocks.WATER) {
|
||||
WC += context.walkOnWaterOnePenalty;
|
||||
}
|
||||
if (srcDown == Blocks.SOUL_SAND) {
|
||||
if (srcDownBlock == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
}
|
||||
}
|
||||
@@ -109,13 +114,13 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
return WC;
|
||||
}
|
||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
|
||||
hardness1 *= 5;
|
||||
hardness2 *= 5;
|
||||
}
|
||||
return WC + hardness1 + hardness2;
|
||||
} else {//this is a bridge, so we need to place a block
|
||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (MovementHelper.isReplaceable(destX, y - 1, destZ, destOn, context.bsi)) {
|
||||
@@ -146,12 +151,16 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
}
|
||||
// now that we've checked all possible directions to side place, we actually need to backplace
|
||||
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof SlabBlock && down.getValue(SlabBlock.TYPE) != SlabType.DOUBLE)) {
|
||||
if (srcDownBlock == Blocks.SOUL_SAND || (srcDownBlock instanceof SlabBlock && srcDown.getValue(SlabBlock.TYPE) != SlabType.DOUBLE)) {
|
||||
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
|
||||
}
|
||||
if (down.getFluidState().getType() instanceof WaterFluid) {
|
||||
if (!standingOnABlock) { // standing on water / swimming
|
||||
return COST_INF; // this is obviously impossible
|
||||
}
|
||||
Block blockSrc = context.getBlock(x, y, z);
|
||||
if ((blockSrc == Blocks.LILY_PAD || blockSrc instanceof CarpetBlock) && !srcDown.getFluidState().isEmpty()) {
|
||||
return COST_INF; // we can stand on these but can't place against them
|
||||
}
|
||||
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol
|
||||
return WC + placeCost + hardness1 + hardness2;
|
||||
}
|
||||
@@ -232,11 +241,12 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder || MovementHelper.canUseFrostWalker(ctx, positionToPlace);
|
||||
BlockPos feet = ctx.playerFeet();
|
||||
if (feet.getY() != dest.getY() && !ladder) {
|
||||
logDebug("Wrong Y coordinate");
|
||||
if (feet.getY() < dest.getY()) {
|
||||
System.out.println("In movement traverse");
|
||||
return state.setInput(Input.JUMP, true);
|
||||
}
|
||||
return state;
|
||||
@@ -251,7 +261,7 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
||||
Block high = BlockStateInterface.get(ctx, src.above()).getBlock();
|
||||
if (ctx.player().position().y > src.y + 0.1D && !ctx.player().isOnGround() && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
if (ctx.player().position().y > src.y + 0.1D && !ctx.player().onGround() && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
// hitting W could cause us to climb the ladder instead of going forward
|
||||
// wait until we're on the ground
|
||||
return state;
|
||||
|
||||
@@ -71,8 +71,8 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
private HashSet<BlockPos> toPlace = new HashSet<>();
|
||||
private HashSet<BlockPos> toWalkInto = new HashSet<>();
|
||||
|
||||
private PathingBehavior behavior;
|
||||
private IPlayerContext ctx;
|
||||
private final PathingBehavior behavior;
|
||||
private final IPlayerContext ctx;
|
||||
|
||||
private boolean sprintNextTick;
|
||||
|
||||
@@ -272,7 +272,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
if (!current.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
if (!ctx.player().isOnGround()) {
|
||||
if (!ctx.player().onGround()) {
|
||||
return false;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().below())) {
|
||||
@@ -321,7 +321,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
* @return Whether or not it was possible to snap to the current player feet
|
||||
*/
|
||||
public boolean snipsnapifpossible() {
|
||||
if (!ctx.player().isOnGround() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
|
||||
if (!ctx.player().onGround() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
|
||||
// if we're falling in the air, and not in water, don't splice
|
||||
return false;
|
||||
} else {
|
||||
@@ -348,7 +348,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||
|
||||
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint
|
||||
if (!new CalculationContext(behavior.baritone).canSprint) {
|
||||
if (!new CalculationContext(behavior.baritone, false).canSprint) {
|
||||
return false;
|
||||
}
|
||||
IMovement current = path.movements().get(pathPosition);
|
||||
@@ -378,6 +378,26 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
// however, descend and ascend don't request sprinting, because they don't know the context of what movement comes after it
|
||||
if (current instanceof MovementDescend) {
|
||||
|
||||
if (pathPosition < path.length() - 2) {
|
||||
// keep this out of onTick, even if that means a tick of delay before it has an effect
|
||||
IMovement next = path.movements().get(pathPosition + 1);
|
||||
if (MovementHelper.canUseFrostWalker(ctx, next.getDest().below())) {
|
||||
// frostwalker only works if you cross the edge of the block on ground so in some cases we may not overshoot
|
||||
// Since MovementDescend can't know the next movement we have to tell it
|
||||
if (next instanceof MovementTraverse || next instanceof MovementParkour) {
|
||||
boolean couldPlaceInstead = Baritone.settings().allowPlace.value && behavior.baritone.getInventoryBehavior().hasGenericThrowaway() && next instanceof MovementParkour; // traverse doesn't react fast enough
|
||||
// this is true if the next movement does not ascend or descends and goes into the same cardinal direction (N-NE-E-SE-S-SW-W-NW) as the descend
|
||||
// in that case current.getDirection() is e.g. (0, -1, 1) and next.getDirection() is e.g. (0, 0, 3) so the cross product of (0, 0, 1) and (0, 0, 3) is taken, which is (0, 0, 0) because the vectors are colinear (don't form a plane)
|
||||
// since movements in exactly the opposite direction (e.g. descend (0, -1, 1) and traverse (0, 0, -1)) would also pass this check we also have to rule out that case
|
||||
// we can do that by adding the directions because traverse is always 1 long like descend and parkour can't jump through current.getSrc().down()
|
||||
boolean sameFlatDirection = !current.getDirection().above().offset(next.getDirection()).equals(BlockPos.ZERO)
|
||||
&& current.getDirection().above().cross(next.getDirection()).equals(BlockPos.ZERO); // here's why you learn maths in school
|
||||
if (sameFlatDirection && !couldPlaceInstead) {
|
||||
((MovementDescend) current).forceSafeMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((MovementDescend) current).safeMode() && !((MovementDescend) current).skipToAscend()) {
|
||||
logDebug("Sprinting would be unsafe");
|
||||
return false;
|
||||
@@ -395,11 +415,20 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
return true;
|
||||
}
|
||||
if (canSprintFromDescendInto(ctx, current, next)) {
|
||||
|
||||
if (next instanceof MovementDescend && pathPosition < path.length() - 3) {
|
||||
IMovement next_next = path.movements().get(pathPosition + 2);
|
||||
if (next_next instanceof MovementDescend && !canSprintFromDescendInto(ctx, next, next_next)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if (ctx.playerFeet().equals(current.getDest())) {
|
||||
pathPosition++;
|
||||
onChangeInPathPosition();
|
||||
onTick();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
||||
|
||||
117
src/main/java/baritone/pathing/precompute/PrecomputedData.java
Normal file
117
src/main/java/baritone/pathing/precompute/PrecomputedData.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.pathing.precompute;
|
||||
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import static baritone.pathing.precompute.Ternary.MAYBE;
|
||||
import static baritone.pathing.precompute.Ternary.YES;
|
||||
|
||||
public class PrecomputedData {
|
||||
|
||||
private final int[] data = new int[Block.BLOCK_STATE_REGISTRY.size()];
|
||||
|
||||
private static final int COMPLETED_MASK = 1 << 0;
|
||||
private static final int CAN_WALK_ON_MASK = 1 << 1;
|
||||
private static final int CAN_WALK_ON_SPECIAL_MASK = 1 << 2;
|
||||
private static final int CAN_WALK_THROUGH_MASK = 1 << 3;
|
||||
private static final int CAN_WALK_THROUGH_SPECIAL_MASK = 1 << 4;
|
||||
private static final int FULLY_PASSABLE_MASK = 1 << 5;
|
||||
private static final int FULLY_PASSABLE_SPECIAL_MASK = 1 << 6;
|
||||
|
||||
private int fillData(int id, BlockState state) {
|
||||
int blockData = 0;
|
||||
|
||||
Ternary canWalkOnState = MovementHelper.canWalkOnBlockState(state);
|
||||
if (canWalkOnState == YES) {
|
||||
blockData |= CAN_WALK_ON_MASK;
|
||||
}
|
||||
if (canWalkOnState == MAYBE) {
|
||||
blockData |= CAN_WALK_ON_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary canWalkThroughState = MovementHelper.canWalkThroughBlockState(state);
|
||||
if (canWalkThroughState == YES) {
|
||||
blockData |= CAN_WALK_THROUGH_MASK;
|
||||
}
|
||||
if (canWalkThroughState == MAYBE) {
|
||||
blockData |= CAN_WALK_THROUGH_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary fullyPassableState = MovementHelper.fullyPassableBlockState(state);
|
||||
if (fullyPassableState == YES) {
|
||||
blockData |= FULLY_PASSABLE_MASK;
|
||||
}
|
||||
if (fullyPassableState == MAYBE) {
|
||||
blockData |= FULLY_PASSABLE_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
blockData |= COMPLETED_MASK;
|
||||
|
||||
data[id] = blockData; // in theory, this is thread "safe" because every thread should compute the exact same int to write?
|
||||
return blockData;
|
||||
}
|
||||
|
||||
public boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & CAN_WALK_ON_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkOnPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & CAN_WALK_ON_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & CAN_WALK_THROUGH_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkThroughPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & CAN_WALK_THROUGH_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean fullyPassable(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & FULLY_PASSABLE_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.fullyPassablePosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & FULLY_PASSABLE_MASK) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/main/java/baritone/pathing/precompute/Ternary.java
Normal file
22
src/main/java/baritone/pathing/precompute/Ternary.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.pathing.precompute;
|
||||
|
||||
public enum Ternary {
|
||||
YES, MAYBE, NO
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||
Baritone.settings().backfill.value = false;
|
||||
return false;
|
||||
}
|
||||
amIBreakingABlockHMMMMMMM();
|
||||
for (BlockPos pos : new ArrayList<>(blocksToReplace.keySet())) {
|
||||
if (ctx.world().getChunk(pos) instanceof EmptyLevelChunk) {
|
||||
if (ctx.world().getChunk(pos) instanceof EmptyLevelChunk || ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||
blocksToReplace.remove(pos);
|
||||
}
|
||||
}
|
||||
amIBreakingABlockHMMMMMMM();
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
|
||||
return !toFillIn().isEmpty();
|
||||
@@ -91,7 +91,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||
}
|
||||
|
||||
private void amIBreakingABlockHMMMMMMM() {
|
||||
if (!ctx.getSelectedBlock().isPresent()) {
|
||||
if (!ctx.getSelectedBlock().isPresent() || !baritone.getPathingBehavior().isPathing()) {
|
||||
return;
|
||||
}
|
||||
blocksToReplace.put(ctx.getSelectedBlock().get(), ctx.world().getBlockState(ctx.getSelectedBlock().get()));
|
||||
|
||||
@@ -26,9 +26,9 @@ import baritone.api.process.IBuilderProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.schematic.FillSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.RayTraceUtils;
|
||||
@@ -44,6 +44,8 @@ import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.schematic.MapArtSchematic;
|
||||
import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import baritone.utils.schematic.litematica.LitematicaHelper;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -51,6 +53,7 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
@@ -65,10 +68,13 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
|
||||
@@ -85,6 +91,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
private int layer;
|
||||
private int numRepeats;
|
||||
private List<BlockState> approxPlaceable;
|
||||
public int stopAtHeight = 0;
|
||||
|
||||
public BuilderProcess(Baritone baritone) {
|
||||
super(baritone);
|
||||
@@ -95,6 +102,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.name = name;
|
||||
this.schematic = schematic;
|
||||
this.realSchematic = null;
|
||||
boolean buildingSelectionSchematic = schematic instanceof SelectionSchematic;
|
||||
if (!Baritone.settings().buildSubstitutes.value.isEmpty()) {
|
||||
this.schematic = new SubstituteSchematic(this.schematic, Baritone.settings().buildSubstitutes.value);
|
||||
}
|
||||
@@ -113,8 +121,28 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.origin = new Vec3i(x, y, z);
|
||||
this.paused = false;
|
||||
this.layer = Baritone.settings().startAtLayer.value;
|
||||
this.stopAtHeight = schematic.heightY();
|
||||
if (Baritone.settings().buildOnlySelection.value && buildingSelectionSchematic) { // currently redundant but safer maybe
|
||||
if (baritone.getSelectionManager().getSelections().length == 0) {
|
||||
logDirect("Poor little kitten forgot to set a selection while BuildOnlySelection is true");
|
||||
this.stopAtHeight = 0;
|
||||
} else if (Baritone.settings().buildInLayers.value) {
|
||||
OptionalInt minim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.min().y).min();
|
||||
OptionalInt maxim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.max().y).max();
|
||||
if (minim.isPresent() && maxim.isPresent()) {
|
||||
int startAtHeight = Baritone.settings().layerOrder.value ? y + schematic.heightY() - maxim.getAsInt() : minim.getAsInt() - y;
|
||||
this.stopAtHeight = (Baritone.settings().layerOrder.value ? y + schematic.heightY() - minim.getAsInt() : maxim.getAsInt() - y) + 1;
|
||||
this.layer = Math.max(this.layer, startAtHeight / Baritone.settings().layerHeight.value); // startAtLayer or startAtHeight, whichever is highest
|
||||
logDebug(String.format("Schematic starts at y=%s with height %s", y, schematic.heightY()));
|
||||
logDebug(String.format("Selection starts at y=%s and ends at y=%s", minim.getAsInt(), maxim.getAsInt()));
|
||||
logDebug(String.format("Considering relevant height %s - %s", startAtHeight, this.stopAtHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.numRepeats = 0;
|
||||
this.observedCompleted = new LongOpenHashSet();
|
||||
this.incorrectPositions = null;
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
@@ -182,6 +210,28 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpenLitematic(int i) {
|
||||
if (LitematicaHelper.isLitematicaPresent()) {
|
||||
//if java.lang.NoSuchMethodError is thrown see comment in SchematicPlacementManager
|
||||
if (LitematicaHelper.hasLoadedSchematic()) {
|
||||
String name = LitematicaHelper.getName(i);
|
||||
try {
|
||||
LitematicaSchematic schematic1 = new LitematicaSchematic(NbtIo.readCompressed(Files.newInputStream(LitematicaHelper.getSchematicFile(i).toPath())), false);
|
||||
Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic1, i);
|
||||
LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i);
|
||||
build(name, schematic2, correctedOrigin);
|
||||
} catch (Exception e) {
|
||||
logDirect("Schematic File could not be loaded.");
|
||||
}
|
||||
} else {
|
||||
logDirect("No schematic currently loaded");
|
||||
}
|
||||
} else {
|
||||
logDirect("Litematica is not present");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearArea(BlockPos corner1, BlockPos corner2) {
|
||||
BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ()));
|
||||
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
|
||||
@@ -445,7 +495,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
BuilderCalculationContext bcc = new BuilderCalculationContext();
|
||||
if (!recalc(bcc)) {
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) {
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < stopAtHeight) {
|
||||
logDirect("Starting layer " + layer);
|
||||
layer++;
|
||||
return onTick(calcFailed, isSafeToCancel, recursions + 1);
|
||||
@@ -475,7 +525,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
|
||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().isOnGround()) {
|
||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround()) {
|
||||
// we'd like to pause to break this block
|
||||
// only change look direction if it's safe (don't want to fuck up an in progress parkour for example
|
||||
Rotation rot = toBreak.get().getB();
|
||||
@@ -495,7 +545,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
List<BlockState> desirableOnHotbar = new ArrayList<>();
|
||||
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().isOnGround() && ticks <= 0) {
|
||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround() && ticks <= 0) {
|
||||
Rotation rot = toPlace.get().rot;
|
||||
baritone.getLookBehavior().updateTarget(rot, true);
|
||||
ctx.player().getInventory().selected = toPlace.get().hotbarSelection;
|
||||
@@ -624,7 +674,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
// this is not in render distance
|
||||
if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))
|
||||
&& !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) {
|
||||
&& !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) {
|
||||
// and we've never seen this position be correct
|
||||
// therefore mark as incorrect
|
||||
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
||||
@@ -847,7 +897,18 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue;
|
||||
}
|
||||
// <toxic cloud>
|
||||
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {})));
|
||||
BlockState itemState = ((BlockItem) stack.getItem())
|
||||
.getBlock()
|
||||
.getStateForPlacement(
|
||||
new BlockPlaceContext(
|
||||
new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}
|
||||
)
|
||||
);
|
||||
if (itemState != null) {
|
||||
result.add(itemState);
|
||||
} else {
|
||||
result.add(Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
// </toxic cloud>
|
||||
}
|
||||
return result;
|
||||
@@ -861,14 +922,21 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
TrapDoorBlock.OPEN, TrapDoorBlock.HALF
|
||||
);
|
||||
|
||||
private boolean sameWithoutOrientation(BlockState first, BlockState second) {
|
||||
private boolean sameBlockstate(BlockState first, BlockState second) {
|
||||
if (first.getBlock() != second.getBlock()) {
|
||||
return false;
|
||||
}
|
||||
boolean ignoreDirection = Baritone.settings().buildIgnoreDirection.value;
|
||||
List<String> ignoredProps = Baritone.settings().buildIgnoreProperties.value;
|
||||
if (!ignoreDirection && ignoredProps.isEmpty()) {
|
||||
return first.equals(second); // early return if no properties are being ignored
|
||||
}
|
||||
ImmutableMap<Property<?>, Comparable<?>> map1 = first.getValues();
|
||||
ImmutableMap<Property<?>, Comparable<?>> map2 = second.getValues();
|
||||
for (Property<?> prop : map1.keySet()) {
|
||||
if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) {
|
||||
if (map1.get(prop) != map2.get(prop)
|
||||
&& !(ignoreDirection && orientationProps.contains(prop))
|
||||
&& !ignoredProps.contains(prop.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -900,7 +968,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (current.equals(desired)) {
|
||||
return true;
|
||||
}
|
||||
return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired);
|
||||
return sameBlockstate(current, desired);
|
||||
}
|
||||
|
||||
public class BuilderCalculationContext extends CalculationContext {
|
||||
@@ -967,12 +1035,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
|
||||
@Override
|
||||
public double breakCostMultiplierAt(int x, int y, int z, BlockState current) {
|
||||
if (!allowBreak || isPossiblyProtected(x, y, z)) {
|
||||
if ((!allowBreak && !allowBreakAnyway.contains(current.getBlock())) || isPossiblyProtected(x, y, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
BlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
|
||||
if (sch.getBlock() == Blocks.AIR) {
|
||||
if (sch.getBlock() instanceof AirBlock) {
|
||||
// it should be air
|
||||
// regardless of current contents, we can break it
|
||||
return 1;
|
||||
|
||||
@@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalComposite;
|
||||
import baritone.api.process.IFarmProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.RayTraceUtils;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.RotationUtils;
|
||||
@@ -302,11 +303,11 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
||||
}
|
||||
}
|
||||
for (Entity entity : ctx.entities()) {
|
||||
if (entity instanceof ItemEntity && entity.isOnGround()) {
|
||||
if (entity instanceof ItemEntity && entity.onGround()) {
|
||||
ItemEntity ei = (ItemEntity) entity;
|
||||
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
|
||||
// +0.1 because of farmland's 0.9375 dummy height lol
|
||||
goalz.add(new GoalBlock(new BlockPos(entity.position().x, entity.position().y + 0.1, entity.position().z)));
|
||||
goalz.add(new GoalBlock(new BetterBlockPos(entity.position().x, entity.position().y + 0.1, entity.position().z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.process.IFollowProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
@@ -59,7 +60,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
pos = following.blockPosition();
|
||||
} else {
|
||||
GoalXZ g = GoalXZ.fromDirection(following.position(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
||||
pos = new BlockPos(g.getX(), following.position().y, g.getZ());
|
||||
pos = new BetterBlockPos(g.getX(), following.position().y, g.getZ());
|
||||
}
|
||||
return new GoalNear(pos, Baritone.settings().followRadius.value);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,14 @@ import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
import java.util.*;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
||||
|
||||
private BlockOptionalMeta gettingTo;
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.FallingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -102,11 +103,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
|
||||
updateLoucaSystem();
|
||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||
@@ -115,7 +112,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
||||
}
|
||||
if (Baritone.settings().legitMine.value) {
|
||||
addNearby();
|
||||
if (!addNearby()) {
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Optional<BlockPos> shaft = curr.stream()
|
||||
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
|
||||
@@ -123,7 +123,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
||||
.min(Comparator.comparingDouble(ctx.playerFeet()::distSqr));
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
if (shaft.isPresent() && ctx.player().isOnGround()) {
|
||||
if (shaft.isPresent() && ctx.player().onGround()) {
|
||||
BlockPos pos = shaft.get();
|
||||
BlockState state = baritone.bsi.get0(pos);
|
||||
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||
@@ -177,6 +177,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
|
||||
private PathingCommand updateGoal() {
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean legit = Baritone.settings().legitMine.value;
|
||||
List<BlockPos> locs = knownOreLocations;
|
||||
if (!locs.isEmpty()) {
|
||||
@@ -211,6 +216,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
@@ -221,6 +227,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
|
||||
private void rescan(List<BlockPos> already, CalculationContext context) {
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return;
|
||||
}
|
||||
@@ -370,11 +377,18 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return prune(ctx, locs, filter, max, blacklist, dropped);
|
||||
}
|
||||
|
||||
private void addNearby() {
|
||||
private boolean addNearby() {
|
||||
List<BlockPos> dropped = droppedItemsScan();
|
||||
knownOreLocations.addAll(dropped);
|
||||
BlockPos playerFeet = ctx.playerFeet();
|
||||
BlockStateInterface bsi = new BlockStateInterface(ctx);
|
||||
|
||||
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int searchDist = 10;
|
||||
double fakedBlockReachDistance = 20; // at least 10 * sqrt(3) with some extra space to account for positioning within the block
|
||||
for (int x = playerFeet.getX() - searchDist; x <= playerFeet.getX() + searchDist; x++) {
|
||||
@@ -392,6 +406,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, ORE_LOCATIONS_COUNT, blacklist, dropped);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped) {
|
||||
@@ -467,10 +482,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
@Override
|
||||
public void mine(int quantity, BlockOptionalMetaLookup filter) {
|
||||
this.filter = filter;
|
||||
if (filter != null && !Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
this.mine(quantity, (BlockOptionalMetaLookup) null);
|
||||
return;
|
||||
if (this.filterFilter() == null) {
|
||||
this.filter = null;
|
||||
}
|
||||
this.desiredQuantity = quantity;
|
||||
this.knownOreLocations = new ArrayList<>();
|
||||
@@ -482,4 +495,22 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
||||
}
|
||||
}
|
||||
|
||||
private BlockOptionalMetaLookup filterFilter() {
|
||||
if (this.filter == null) {
|
||||
return null;
|
||||
}
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
BlockOptionalMetaLookup f = new BlockOptionalMetaLookup(this.filter.blocks()
|
||||
.stream()
|
||||
.filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock()))
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
if (f.blocks().isEmpty()) {
|
||||
logDirect("Unable to mine when allowBreak is false and target block is not in allowBreakAnyway!");
|
||||
return null;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.utils.IPlayerContext;
|
||||
import baritone.cache.CachedRegion;
|
||||
import baritone.cache.WorldData;
|
||||
import baritone.utils.accessor.IClientChunkProvider;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -43,9 +44,10 @@ public class BlockStateInterface {
|
||||
|
||||
private final ClientChunkCache provider;
|
||||
private final WorldData worldData;
|
||||
protected final BlockGetter world;
|
||||
protected final Level world;
|
||||
public final BlockPos.MutableBlockPos isPassableBlockPos;
|
||||
public final BlockGetter access;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
private LevelChunk prev = null;
|
||||
private CachedRegion prevCached = null;
|
||||
@@ -64,6 +66,7 @@ public class BlockStateInterface {
|
||||
|
||||
public BlockStateInterface(Level world, WorldData worldData, boolean copyLoadedChunks) {
|
||||
this.world = world;
|
||||
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
||||
this.worldData = worldData;
|
||||
if (copyLoadedChunks) {
|
||||
this.provider = ((IClientChunkProvider) world.getChunkSource()).createThreadSafeCopy();
|
||||
@@ -97,9 +100,9 @@ public class BlockStateInterface {
|
||||
}
|
||||
|
||||
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
||||
y -= worldData.dimension.minY();
|
||||
y -= world.dimensionType().minY();
|
||||
// Invalid vertical position
|
||||
if (y < 0 || y >= worldData.dimension.height()) {
|
||||
if (y < 0 || y >= world.dimensionType().height()) {
|
||||
return AIR;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user