Compare commits
373 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a48ae2a9a8 | ||
|
|
476b724471 | ||
|
|
98da144691 | ||
|
|
7320c3fd7e | ||
|
|
c37cdf78e4 | ||
|
|
6a1f716dc8 | ||
|
|
a9d90786ff | ||
|
|
484c606dc1 | ||
|
|
331a7f3842 | ||
|
|
637c182114 | ||
|
|
25de16e051 | ||
|
|
a732e766f4 | ||
|
|
2377694a6b | ||
|
|
1b3799d4d7 | ||
|
|
81fadde388 | ||
|
|
a61eabd60c | ||
|
|
bb75e68b0a | ||
|
|
e9b9977674 | ||
|
|
91854f97ad | ||
|
|
825bad47ef | ||
|
|
78acd2f945 | ||
|
|
1183196e0d | ||
|
|
e4947ec071 | ||
|
|
5262f68215 | ||
|
|
4b45cc6f0b | ||
|
|
a3da25ca27 | ||
|
|
eae6e4d804 | ||
|
|
37cd50d435 | ||
|
|
3f65d46e12 | ||
|
|
15fd313757 | ||
|
|
835fb3471f | ||
|
|
ca870af20e | ||
|
|
c98c54c985 | ||
|
|
4c9689fe19 | ||
|
|
f41c873852 | ||
|
|
eb8a673165 | ||
|
|
a9f497981f | ||
|
|
74dd88d123 | ||
|
|
9a7b07befc | ||
|
|
b94494d386 | ||
|
|
974b19fcc7 | ||
|
|
364b7b5438 | ||
|
|
2c3f352d0d | ||
|
|
7fbe9c062e | ||
|
|
c1d7683896 | ||
|
|
b493c2ce89 | ||
|
|
82436f30e1 | ||
|
|
f549e0e2d4 | ||
|
|
5494c43290 | ||
|
|
f5d5457100 | ||
|
|
d6cbb58e7e | ||
|
|
0222c47113 | ||
|
|
33d007eea5 | ||
|
|
79e0f4ba23 | ||
|
|
72cf9392b1 | ||
|
|
b6265036d4 | ||
|
|
dc70d810c9 | ||
|
|
dbb0f599fc | ||
|
|
dcc0b82210 | ||
|
|
16cfcb36a3 | ||
|
|
6bec994a57 | ||
|
|
a99206b6c2 | ||
|
|
c491d67925 | ||
|
|
853b5ca771 | ||
|
|
f4706fff18 | ||
|
|
7218a46211 | ||
|
|
320a5d64a3 | ||
|
|
b16a8ecf21 | ||
|
|
73265ef944 | ||
|
|
3bbc141e9a | ||
|
|
9ca95e8e14 | ||
|
|
6d51e10090 | ||
|
|
14b75973b0 | ||
|
|
0bfd0bca0c | ||
|
|
cafb810a1f | ||
|
|
07704b3ec7 | ||
|
|
7032efcc05 | ||
|
|
65a5677b33 | ||
|
|
5d3522ca0a | ||
|
|
bfb530e02b | ||
|
|
5a5d11922f | ||
|
|
39cfebeb34 | ||
|
|
950f47ccae | ||
|
|
d2c625e1c9 | ||
|
|
3f207b7041 | ||
|
|
8deb9e5a35 | ||
|
|
5eeb33a6f5 | ||
|
|
918f009e8a | ||
|
|
d6665f1cd5 | ||
|
|
af29ed7146 | ||
|
|
8ddc795158 | ||
|
|
8a572516fc | ||
|
|
508dacac63 | ||
|
|
13ca691f5d | ||
|
|
7e4d2c9b28 | ||
|
|
500c34c330 | ||
|
|
234fd3f75e | ||
|
|
32ef30686b | ||
|
|
175df6ce7a | ||
|
|
96b874c099 | ||
|
|
612510550f | ||
|
|
80e4852f90 | ||
|
|
071243b99a | ||
|
|
547db3a6b4 | ||
|
|
063f698bd2 | ||
|
|
bcbfca100f | ||
|
|
a92675e125 | ||
|
|
8206b1673c | ||
|
|
d7088c8eea | ||
|
|
bf723deced | ||
|
|
9636e69a6b | ||
|
|
ed91e2aa7b | ||
|
|
7cbe5bfd2f | ||
|
|
69c4c7a3b8 | ||
|
|
3c691bb498 | ||
|
|
ea35a3478f | ||
|
|
b7d1ba1fa5 | ||
|
|
5f686c1c12 | ||
|
|
4eea8308d7 | ||
|
|
7f9704592e | ||
|
|
523f13c430 | ||
|
|
3b32c72d63 | ||
|
|
0102ce8fad | ||
|
|
0b9bb9df2b | ||
|
|
78dd64c73d | ||
|
|
750cc619fb | ||
|
|
1c8079c051 | ||
|
|
2abd024b3c | ||
|
|
7992b63aae | ||
|
|
836ef3328c | ||
|
|
c470dc1a17 | ||
|
|
97a1029a72 | ||
|
|
5f9602796a | ||
|
|
6eaa3a27f2 | ||
|
|
02e7886e77 | ||
|
|
9851623557 | ||
|
|
f0d2bae3d1 | ||
|
|
f3561cab47 | ||
|
|
38d047dbd1 | ||
|
|
e6ba4ef309 | ||
|
|
460833f7d6 | ||
|
|
2eba22031a | ||
|
|
ac55de63e9 | ||
|
|
88e2fba447 | ||
|
|
94ac15a8fc | ||
|
|
19355cb4f2 | ||
|
|
e0ff16e2dd | ||
|
|
49db52673a | ||
|
|
f8872e1cd4 | ||
|
|
2ed3e10833 | ||
|
|
2b6fe188ed | ||
|
|
2ddc2c3660 | ||
|
|
17e16498b6 | ||
|
|
3f3358d0b1 | ||
|
|
c006005cc7 | ||
|
|
b187d86074 | ||
|
|
727694fdd5 | ||
|
|
7081cf7172 | ||
|
|
a25afd5c13 | ||
|
|
c180eb9975 | ||
|
|
9e45998a65 | ||
|
|
6cd12bf84d | ||
|
|
a09f5d41f6 | ||
|
|
8aaa49c80d | ||
|
|
4f1db04224 | ||
|
|
dbeee33657 | ||
|
|
cd245f7f59 | ||
|
|
246dd2b0ad | ||
|
|
2acf64a0d0 | ||
|
|
9d41367eff | ||
|
|
20fa2c6f3d | ||
|
|
9cb021ffa0 | ||
|
|
2acb8f2a37 | ||
|
|
b044d244d0 | ||
|
|
807b1b5eb0 | ||
|
|
819178b280 | ||
|
|
039898c654 | ||
|
|
854985e5b5 | ||
|
|
b64dd8f25f | ||
|
|
cbb3483456 | ||
|
|
6603e8b11e | ||
|
|
d522f9dfa3 | ||
|
|
f02476ff3a | ||
|
|
eafca1e1fe | ||
|
|
0055a059f7 | ||
|
|
8262909063 | ||
|
|
e42c19bfec | ||
|
|
c41eb4afa0 | ||
|
|
80c8294f5f | ||
|
|
fc58673abd | ||
|
|
ca831bc734 | ||
|
|
a76cf0fe9a | ||
|
|
6e78384bcf | ||
|
|
47501ab8e1 | ||
|
|
682de71ab7 | ||
|
|
410ea059fc | ||
|
|
688853c523 | ||
|
|
806dc8f017 | ||
|
|
89ab78a329 | ||
|
|
3a7cb5e020 | ||
|
|
d0f594065d | ||
|
|
10677040e0 | ||
|
|
c2624bbaaf | ||
|
|
b7870d059c | ||
|
|
06865f1561 | ||
|
|
fe0b54cfb4 | ||
|
|
0bf7bb4b39 | ||
|
|
2a830b6b68 | ||
|
|
fc620f8ba8 | ||
|
|
33d4dd47bb | ||
|
|
ec92ab8b39 | ||
|
|
ff3234fcdd | ||
|
|
c32652394e | ||
|
|
580ba60762 | ||
|
|
0e7bf25de7 | ||
|
|
315977e1f2 | ||
|
|
e7658b75ef | ||
|
|
e218ced2c7 | ||
|
|
3cc4c0ea98 | ||
|
|
ac2a88d186 | ||
|
|
8c3fac977e | ||
|
|
be2ee1a07c | ||
|
|
a4f7207089 | ||
|
|
aead997b13 | ||
|
|
2d421e66dc | ||
|
|
e8370f1348 | ||
|
|
16f6baf216 | ||
|
|
89ab959fb4 | ||
|
|
b13b86b67a | ||
|
|
b9a7efc25b | ||
|
|
3b7f13babd | ||
|
|
6cc31a9422 | ||
|
|
dff92beea1 | ||
|
|
592a01f3e4 | ||
|
|
db718a1781 | ||
|
|
261bf005f6 | ||
|
|
62b808ad48 | ||
|
|
e926ff2a16 | ||
|
|
8794bfd79a | ||
|
|
500643aec7 | ||
|
|
58bb6c4357 | ||
|
|
520142427d | ||
|
|
69e871eaad | ||
|
|
d759c676f7 | ||
|
|
12481cc491 | ||
|
|
43f11aaf0c | ||
|
|
f4842aa512 | ||
|
|
bcd3fd3266 | ||
|
|
67256c17cf | ||
|
|
d6106a44f7 | ||
|
|
369d726a96 | ||
|
|
e0beba38af | ||
|
|
ebe3f457c6 | ||
|
|
6289e540b8 | ||
|
|
eda1820773 | ||
|
|
c8856cfea4 | ||
|
|
e0bd82d7ff | ||
|
|
217e0da4a6 | ||
|
|
96a8bb90c9 | ||
|
|
0ca3c496de | ||
|
|
0434e1c5d3 | ||
|
|
4c79701d22 | ||
|
|
5f49bedc42 | ||
|
|
d9fc825b0f | ||
|
|
17c691b1cf | ||
|
|
9fb46946b5 | ||
|
|
220fa79057 | ||
|
|
f1f4adf8a6 | ||
|
|
448dd979a2 | ||
|
|
3386947522 | ||
|
|
628ec0f2b5 | ||
|
|
e3b91c884a | ||
|
|
10bb935a42 | ||
|
|
6f136a90a2 | ||
|
|
acd9bcceeb | ||
|
|
3c2838df9e | ||
|
|
4b526f7242 | ||
|
|
5ec4b89caa | ||
|
|
5fd3e236e2 | ||
|
|
399037b866 | ||
|
|
61563c9359 | ||
|
|
2d941f6264 | ||
|
|
1a8d93b946 | ||
|
|
50783e65a9 | ||
|
|
e854bf59f8 | ||
|
|
393a3a87b6 | ||
|
|
888b2723e0 | ||
|
|
6ed03d0858 | ||
|
|
ee33666b38 | ||
|
|
07c406aa16 | ||
|
|
c578d5c1a3 | ||
|
|
2ea66ea8fc | ||
|
|
27440fc147 | ||
|
|
b1f5429db9 | ||
|
|
042b1ed6d7 | ||
|
|
a8645afbdb | ||
|
|
25b85f17a3 | ||
|
|
cf691118b9 | ||
|
|
0dcb9d4b69 | ||
|
|
2d2571cff5 | ||
|
|
ec8d5c0f4d | ||
|
|
85d63c9d7f | ||
|
|
19f70f5a79 | ||
|
|
80955cad8b | ||
|
|
606e9bf97c | ||
|
|
47ae75a9d6 | ||
|
|
25587e317a | ||
|
|
01ba712d33 | ||
|
|
e0985d3b68 | ||
|
|
b3ba129fc5 | ||
|
|
746b7b5c88 | ||
|
|
db2f6ec78d | ||
|
|
96bcabff8b | ||
|
|
0a1fe857dc | ||
|
|
7181d2c91a | ||
|
|
e66d8616ce | ||
|
|
656dd91004 | ||
|
|
d88b3a7799 | ||
|
|
7cdbc4acca | ||
|
|
de68e6630e | ||
|
|
de89da20b2 | ||
|
|
49aaa55172 | ||
|
|
e03e251541 | ||
|
|
f5380881f4 | ||
|
|
a022778fb6 | ||
|
|
8543a99fba | ||
|
|
17a06621f5 | ||
|
|
b3de840e04 | ||
|
|
539b8ef973 | ||
|
|
997888fe85 | ||
|
|
94a2e13561 | ||
|
|
f7041022d0 | ||
|
|
710170ef2d | ||
|
|
2d2030ecdf | ||
|
|
a3dec3a47e | ||
|
|
eb348120d9 | ||
|
|
27cb708d40 | ||
|
|
36bbe430d4 | ||
|
|
80952e091d | ||
|
|
760ac5dd8f | ||
|
|
fb22cf05eb | ||
|
|
92966dc57c | ||
|
|
0fba32853b | ||
|
|
9f5d9bceaa | ||
|
|
214225c08d | ||
|
|
05b5894348 | ||
|
|
c528dba0ea | ||
|
|
2b3a302a5f | ||
|
|
bd345ae041 | ||
|
|
84a257faf4 | ||
|
|
34620a448e | ||
|
|
e54d63576f | ||
|
|
02419f8b07 | ||
|
|
ddeb2a5c14 | ||
|
|
8973b73bfa | ||
|
|
4557bab3c4 | ||
|
|
6e185b580c | ||
|
|
4e73880d4a | ||
|
|
0bb148844d | ||
|
|
e53b207148 | ||
|
|
afc639ab4b | ||
|
|
afebdce1f8 | ||
|
|
2ca4c3042a | ||
|
|
6bee5828a0 | ||
|
|
8a5cc5b17d | ||
|
|
4e563c6130 | ||
|
|
01cf3c67a6 | ||
|
|
36315c5151 | ||
|
|
9f951f261d | ||
|
|
4c8907c629 | ||
|
|
223791cea7 | ||
|
|
8758c77ac0 | ||
|
|
dba496471e |
14
.github/ISSUE_TEMPLATE/bug.md
vendored
14
.github/ISSUE_TEMPLATE/bug.md
vendored
@@ -14,12 +14,22 @@ Baritone version:
|
||||
Forge mods (if used):
|
||||
|
||||
## Exception, error or logs
|
||||
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
|
||||
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue
|
||||
|
||||
Linux: `~/.minecraft/logs/`
|
||||
|
||||
Windows: `%appdata%/.minecraft/logs/`
|
||||
|
||||
Mac: `/Library/Application\ Support/minecraft/logs/`
|
||||
|
||||
## How to reproduce
|
||||
Add your steps to reproduce the issue/bug experienced here.
|
||||
|
||||
## Modified settings
|
||||
To get the modified settings run `#modified` in game
|
||||
|
||||
## Final checklist
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
|
||||
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
||||
3
.github/ISSUE_TEMPLATE/question.md
vendored
3
.github/ISSUE_TEMPLATE/question.md
vendored
@@ -10,4 +10,5 @@ assignees: ''
|
||||
With as much detail as possible, describe your question and what you may need help with.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
||||
3
.github/ISSUE_TEMPLATE/suggestion.md
vendored
3
.github/ISSUE_TEMPLATE/suggestion.md
vendored
@@ -16,4 +16,5 @@ If applicable, what settings/customizability should be offered to tweak the func
|
||||
Describe how your suggestion would improve Baritone, or the reason behind it being added.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
||||
run/
|
||||
autotest/
|
||||
dist/
|
||||
volderyarn/
|
||||
|
||||
# Gradle
|
||||
build/
|
||||
|
||||
14
.gitlab-ci.yml
Normal file
14
.gitlab-ci.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
image: java:8
|
||||
|
||||
before_script:
|
||||
- which java
|
||||
- which javac
|
||||
|
||||
build:
|
||||
script:
|
||||
- ./gradlew build
|
||||
- ./gradlew build -Pbaritone.forge_build
|
||||
artifacts:
|
||||
paths:
|
||||
- dist/*
|
||||
expire_in: 1 week
|
||||
31
.gitmessage
Normal file
31
.gitmessage
Normal file
@@ -0,0 +1,31 @@
|
||||
<emoji> <title> (<ticket>)
|
||||
|
||||
# 📝 Update README.md (WD-1234)
|
||||
# ✅ Add unit test for inputs (WD-1234)
|
||||
|
||||
# <emoji> can be:
|
||||
# 🎨 :art: when improving structure of the code
|
||||
# ⚡️ :zap: when improving performance
|
||||
# 🔥 :fire: when removing code or files
|
||||
# ✨ :sparkles: when introducing new features
|
||||
# 🚧 :construction: when work in progress
|
||||
# 🔨 :hammer: when refactoring code
|
||||
# 📝 :memo: when writing docs
|
||||
# 💄 :lipstick: when updating the UI and style files
|
||||
# 📈 :chart_with_upwards_trend: when adding analytics or tracking code
|
||||
# 🌐 :globe_with_meridians: when adding internationalization and localization
|
||||
# ✏️ :pencil2: when fixing typos
|
||||
# 🚚 :truck: when moving or renaming files
|
||||
# ✅ :white_check_mark: when adding tests
|
||||
|
||||
# 👌 :ok_hand: when updating code due to code review changes
|
||||
# 🐛 :bug: when fixing a bug
|
||||
# 🚑 :ambulance: when doing a critical hotfix
|
||||
# 🚨 :rotating_light: when removing linter warnings
|
||||
|
||||
# 🔀 :twisted_rightwards_arrows: when merging branches
|
||||
# ⬆️ :arrow_up: when upgrading dependencies
|
||||
# ⬇️ :arrow_down: when downgrading dependencies
|
||||
# 🔧 :wrench: when changing configuration files
|
||||
# 🔖 :bookmark: when releasing / version tagging
|
||||
# 💚 :green_heart: when fixing the CI build
|
||||
@@ -9,8 +9,7 @@ install:
|
||||
- travis_retry docker build -t cabaletta/baritone .
|
||||
|
||||
script:
|
||||
- docker run --rm cabaletta/baritone ./gradlew javadoc
|
||||
- docker run --name baritone cabaletta/baritone /bin/sh -c "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runAutoTest; cat /code/autotest/success"
|
||||
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
|
||||
- docker cp baritone:/code/dist dist
|
||||
- ls dist
|
||||
- cat dist/checksums.txt
|
||||
|
||||
10
Dockerfile
10
Dockerfile
@@ -1,7 +1,5 @@
|
||||
FROM debian:stretch
|
||||
|
||||
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update -y
|
||||
@@ -10,14 +8,10 @@ RUN apt install \
|
||||
openjdk-8-jdk \
|
||||
--assume-yes
|
||||
|
||||
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
|
||||
COPY . /code
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# this .deb is specially patched to support lwjgl
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build -Pbaritone.forge_build
|
||||
RUN ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
47
README.md
47
README.md
@@ -1,13 +1,16 @@
|
||||
# Baritone
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
|
||||
[](https://travis-ci.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.15.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.16.4/)
|
||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
@@ -19,26 +22,30 @@
|
||||

|
||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||
[](https://github.com/cabaletta/baritone/commit/)
|
||||
[](https://impactclient.net/)
|
||||
[](https://impactclient.net/)
|
||||
[](https://github.com/kami-blue/client)
|
||||
[](https://github.com/fr1kin/ForgeHax/)
|
||||
[](https://gitlab.com/emc-mods-indrit/baritone_api)
|
||||
[](https://wweclient.com/)
|
||||
[](https://futureclient.net/)
|
||||
[](https://rootnet.dev/)
|
||||
[](https://futureclient.net/)
|
||||
[](https://rusherhack.org/)
|
||||
[](http://forthebadge.com/)
|
||||
[](http://forthebadge.com/)
|
||||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
|
||||
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)
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
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.14/baritone-api-forge-1.2.14.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
|
||||
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.
|
||||
|
||||
For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.16.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` 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 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.4. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
|
||||
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
|
||||
|
||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||
|
||||
@@ -56,13 +63,17 @@ Here are some links to help to get started:
|
||||
|
||||
- [Usage (chat control)](USAGE.md)
|
||||
|
||||
## Stars over time
|
||||
|
||||
[](https://starchart.cc/cabaletta/baritone)
|
||||
|
||||
# API
|
||||
|
||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
||||
jar.
|
||||
|
||||
Below is an example of basic usage for changing some settings, and then pathing to a X/Z goal.
|
||||
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
|
||||
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
@@ -75,12 +86,22 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd
|
||||
|
||||
## Can I use Baritone as a library in my custom utility client?
|
||||
|
||||
That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License)
|
||||
That's what it's for, sure! (As long as usage complies with the LGPL 3.0 License)
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||
|
||||
### Additional Special Thanks To:
|
||||
|
||||

|
||||
|
||||
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications.
|
||||
|
||||
YourKit is the creator of the [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/), and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||
|
||||
We thank them for granting Baritone an OSS license so that we can make our software the best it can be.
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
It's named for FitMC's deep sultry voice.
|
||||
It's named for FitMC's deep sultry voice.
|
||||
|
||||
47
SETUP.md
47
SETUP.md
@@ -2,7 +2,7 @@
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||
You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version
|
||||
|
||||
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
@@ -47,6 +47,29 @@ You can verify whether or not it worked by running `.b version` in chat (only va
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
Open JDK 8 download: https://openjdk.java.net/install/
|
||||
#### macOS guide
|
||||
In order to get JDK 8, Try running the following command:
|
||||
`% /usr/libexec/java_home -V`
|
||||
If it doesn't work try this guide: https://stackoverflow.com/questions/46513639/how-to-downgrade-java-from-9-to-8-on-a-macos-eclipse-is-not-running-with-java-9
|
||||
|
||||
If you see something like
|
||||
|
||||
`% 1.8.0_VERSION, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_VERSION.jdk/Contents/Home`
|
||||
|
||||
in the list then you've got JDK 8 installed.
|
||||
In order to get JDK 8 running in the **current terminal window** you will have to run this command:
|
||||
|
||||
`% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)`
|
||||
|
||||
To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc
|
||||
|
||||
Setting up the Environment:
|
||||
|
||||
```
|
||||
@@ -54,6 +77,18 @@ $ gradlew setupDecompWorkspace
|
||||
$ gradlew --refresh-dependencies
|
||||
```
|
||||
|
||||
Building Baritone:
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
For minecraft 1.15.2+, run the following instead to include the Forge jars:
|
||||
|
||||
```
|
||||
$ gradlew build -Pbaritone.forge_build
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
@@ -87,16 +122,6 @@ For information on how to build baritone, see [Building Baritone](#building-bari
|
||||
|
||||

|
||||
|
||||
# Building
|
||||
|
||||
Make sure that you have properly [setup](#setup) the environment before trying to build it.
|
||||
|
||||
## Command Line
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
## IntelliJ
|
||||
|
||||
- Navigate to the gradle tasks on the right tab as follows
|
||||
|
||||
24
USAGE.md
24
USAGE.md
@@ -16,12 +16,16 @@ Try `#help` I promise it won't just send you back here =)
|
||||
|
||||
"wtf where is cleararea" -> look at `#help sel`
|
||||
|
||||
"wtf where is goto death, goto waypoint" -> look at `#help wp` (a "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually)). So you might want `#wp save user coolbiome` then, to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` (remember stuff is clickable!).
|
||||
"wtf where is goto death, goto waypoint" -> look at `#help wp`
|
||||
|
||||
just look at `#help` lmao
|
||||
|
||||
Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
|
||||
|
||||
# Commands
|
||||
|
||||
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
|
||||
**All** of these commands may need a prefix before them, as above ^.
|
||||
|
||||
`help`
|
||||
@@ -36,13 +40,13 @@ Some common examples:
|
||||
- `goal clear` to clear the goal
|
||||
- `cancel` or `stop` to stop everything
|
||||
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
||||
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
|
||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
|
||||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `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).
|
||||
- `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type.
|
||||
- `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)
|
||||
- `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `schematica` to build the schematic that is currently open in schematica
|
||||
- `tunnel` to dig just straight ahead and make a tunnel
|
||||
- `tunnel` to dig and make a tunnel, 1x2. It will only deviate from the straight line if necessary such as to avoid lava. For a dumber tunnel that is really just cleararea, you can `tunnel 3 2 100`, to clear an area 3 high, 2 wide, and 100 deep.
|
||||
- `farm` to automatically harvest, replant, or bone meal crops
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
|
||||
@@ -50,7 +54,7 @@ Some common examples:
|
||||
- `version` to get the version of Baritone you're running
|
||||
- `damn` daniel
|
||||
|
||||
For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java).
|
||||
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>.
|
||||
|
||||
@@ -71,6 +75,8 @@ There are about a hundred settings, but here are some fun / interesting / import
|
||||
- `worldExploringChunkOffset`
|
||||
- `acceptableThrowawayItems`
|
||||
- `blocksToAvoidBreaking`
|
||||
- `mineScanDroppedItems`
|
||||
- `allowDiagonalAscend`
|
||||
|
||||
|
||||
|
||||
@@ -90,4 +96,4 @@ So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Min
|
||||
|
||||
## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?
|
||||
These are custom commands that they added; those aren't from Baritone.
|
||||
The equivalent you're looking for is `goal x z` then `path`.
|
||||
The equivalent you're looking for is `goto x z`.
|
||||
|
||||
263
build.gradle
263
build.gradle
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.3.6'
|
||||
version '1.6.3'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
@@ -28,22 +28,45 @@ buildscript {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://www.dogforce-games.com/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://libraries.minecraft.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
|
||||
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
|
||||
classpath group: 'net.fabricmc', name: 'fabric-loom', version: '0.5-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import baritone.gradle.fabric.CreateVolderYarn
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
def mcpVersion = [channel: 'snapshot', version: '20201028-1.16.3']
|
||||
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
CreateVolderYarn.genMappings("1.16.5", mcpVersion)
|
||||
apply plugin: 'fabric-loom'
|
||||
} else {
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
}
|
||||
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
@@ -51,6 +74,7 @@ compileJava {
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
api {
|
||||
compileClasspath += main.compileClasspath
|
||||
@@ -80,88 +104,112 @@ task sourceJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.api.allSource
|
||||
}
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
minecraft.refmapName = "mixins.baritone.refmap.json"
|
||||
} else {
|
||||
minecraft {
|
||||
mappings mcpVersion
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20190307-1.13.1'
|
||||
reobfMappings 'notch'
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
source sourceSets.launch
|
||||
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
}
|
||||
if (getProject().hasProperty("baritone.forge_build")) {
|
||||
reobfMappings 'searge'
|
||||
} else {
|
||||
reobfMappings 'notch'
|
||||
}
|
||||
|
||||
autoTest {
|
||||
workingDirectory project.file('autotest')
|
||||
source sourceSets.launch
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
source sourceSets.launch
|
||||
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
environment 'BARITONE_AUTO_TEST', 'true'
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
}
|
||||
}
|
||||
|
||||
autoTest {
|
||||
workingDirectory project.file('autotest')
|
||||
source sourceSets.launch
|
||||
|
||||
main 'baritone.launch.LaunchTesting'
|
||||
|
||||
environment 'assetIndex', '{asset_index}'
|
||||
environment 'assetDirectory', downloadAssets.output
|
||||
environment 'nativesDirectory', extractNatives.output
|
||||
|
||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
environment 'BARITONE_AUTO_TEST', 'true'
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
jvmArgs "-XstartOnFirstThread"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv searge
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
name = 'SpongePowered'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://www.dogforce-games.com/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.13.2'
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
minecraft "com.mojang:minecraft:1.16.5"
|
||||
mappings fileTree(dir: "./build/volderyarn", include: "**.jar")
|
||||
modImplementation "net.fabricmc:fabric-loader:0.9.1+build.205"
|
||||
|
||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
}
|
||||
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
// 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'
|
||||
}
|
||||
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
} else {
|
||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.5'
|
||||
|
||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
}
|
||||
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.8.+') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
}
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv searge
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
|
||||
options.linkSource true
|
||||
@@ -170,26 +218,121 @@ javadoc {
|
||||
classpath += sourceSets.api.compileClasspath
|
||||
}
|
||||
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
// 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 = 8
|
||||
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
|
||||
'Implementation-Version': version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
// skidded from ProguardTask
|
||||
File getClientJar() {
|
||||
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter({ f -> f.toString().endsWith("client-extra.jar") })
|
||||
.map({ f -> new File(f.getParentFile(), "client.jar") })
|
||||
.findFirst()
|
||||
.get()
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
File getClientJarFabric() {
|
||||
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter({ f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") })
|
||||
.map({ f -> new File(f.getParentFile().getParentFile(), f.getName().toString().replace("mapped", "intermediary")) })
|
||||
.findFirst()
|
||||
.get()
|
||||
}
|
||||
|
||||
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
task copyMcJar(type: Copy) {
|
||||
def mcJar = { getClientJarFabric() }
|
||||
|
||||
from mcJar
|
||||
into 'build/createMcIntermediaryJar/'
|
||||
rename { 'client.jar' }
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask, dependsOn: copyMcJar) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
} else {
|
||||
task copyMcJar(type: Copy) {
|
||||
def mcJar = { getClientJar() }
|
||||
|
||||
from mcJar
|
||||
into 'build/createMcSrgJar/'
|
||||
rename { 'client-srg.jar' }
|
||||
}
|
||||
|
||||
task createSrgMc(type: RenameJarInPlace) {
|
||||
setInput(new File(copyMcJar.getOutputs().getFiles().getSingleFile(), "client-srg.jar"))
|
||||
setClasspath(files({ getClientJar() }))
|
||||
|
||||
// fork
|
||||
setMappingType(net.minecraftforge.gradle.common.util.MappingFile.Mapping.SEARGE)
|
||||
setJarTask('trans alaska pipeline')
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
createSrgMc.dependsOn(extractSrg, copyMcJar)
|
||||
createSrgMc.setMappings(extractSrg.getOutput())
|
||||
}
|
||||
|
||||
|
||||
task proguard(type: ProguardTask, dependsOn: createSrgMc) { // TODO: dont need to create srg mc if doing notch build
|
||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||
extract 'proguard6.0.3/lib/proguard.jar'
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
}
|
||||
build.finalizedBy(createDist)
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.gradle.fabric;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @Author Wagyourtail
|
||||
*/
|
||||
public class CreateVolderYarn {
|
||||
public static String VOLDERYARNFOLDER = "./build/volderyarn/";
|
||||
public static String VOLDERYARN = "volderyarn-%s-%s-%s.jar";
|
||||
|
||||
public static void genMappings(String mcVersion, Map<String, String> mcpVersion) throws IOException {
|
||||
//download yarn intermediary
|
||||
URL intURL = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%s/intermediary-%s-v2.jar", mcVersion, mcVersion));
|
||||
String intermediary = readZipContentFromURL(intURL, "mappings/mappings.tiny").get("mappings/mappings.tiny");
|
||||
Map<String, ClassData> mappings = parseTinyMap(intermediary);
|
||||
|
||||
//download srg
|
||||
URL srgURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_config/%s/mcp_config-%s.zip", mcVersion, mcVersion));
|
||||
String tsrg = readZipContentFromURL(srgURL, "config/joined.tsrg").get("config/joined.tsrg");
|
||||
MCPData mcpData = addTSRGData(mappings, tsrg);
|
||||
|
||||
//download mcp
|
||||
URL mcpURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_%s/%s/mcp_%s-%s.zip", mcpVersion.get("channel"), mcpVersion.get("version"), mcpVersion.get("channel"), mcpVersion.get("version")));
|
||||
Map<String, String> mcpfiles = readZipContentFromURL(mcpURL, "fields.csv", "methods.csv");
|
||||
addMCPData(mcpData, mcpfiles.get("fields.csv"), mcpfiles.get("methods.csv"));
|
||||
|
||||
StringBuilder builder = new StringBuilder("tiny\t2\t0\tintermediary\tnamed");
|
||||
for (ClassData clazz : mappings.values()) {
|
||||
builder.append("\n").append(clazz.getIntToMCP());
|
||||
}
|
||||
|
||||
File outputFolder = new File(VOLDERYARNFOLDER);
|
||||
if (!outputFolder.exists() && !outputFolder.mkdirs())
|
||||
throw new RuntimeException("Failed to create dir for volderyarn mappings.");
|
||||
|
||||
for (File f : outputFolder.listFiles()) {
|
||||
if (!f.isDirectory()) f.delete();
|
||||
}
|
||||
|
||||
File outputFile = new File(outputFolder, String.format(VOLDERYARN, mcVersion, mcpVersion.get("channel"), mcpVersion.get("version")));
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdir())
|
||||
throw new FileNotFoundException("Failed to create folder for volderyarn!");
|
||||
}
|
||||
|
||||
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outputFile))) {
|
||||
output.putNextEntry(new ZipEntry("mappings/mappings.tiny"));
|
||||
byte[] outData = builder.toString().getBytes(StandardCharsets.UTF_8);
|
||||
output.write(outData, 0, outData.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, ClassData> parseTinyMap(String map) {
|
||||
Map<String, ClassData> mappings = new LinkedHashMap<>();
|
||||
ClassData clazzdata = null;
|
||||
for (String line : map.split("\n")) {
|
||||
String[] parts = line.trim().split("\t");
|
||||
switch (parts[0]) {
|
||||
case "c":
|
||||
mappings.put(parts[1], clazzdata = new ClassData(mappings, parts[1], parts[2]));
|
||||
break;
|
||||
case "m":
|
||||
assert clazzdata != null;
|
||||
clazzdata.addMethod(parts[2], parts[1], parts[3]);
|
||||
break;
|
||||
case "f":
|
||||
assert clazzdata != null;
|
||||
clazzdata.addField(parts[2], parts[1], parts[3]);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
private static MCPData addTSRGData(Map<String, ClassData> mappings, String tsrg) {
|
||||
MCPData mcpData = new MCPData();
|
||||
String[] classes = String.join("\t", tsrg.split("\n\t")).split("\n");
|
||||
for (String c : classes) {
|
||||
String[] lines = c.split("\t");
|
||||
String[] classData = lines[0].split("\\s+");
|
||||
ClassData clazz = mappings.get(classData[0]);
|
||||
if (clazz == null) continue;
|
||||
clazz.mcpName = classData[1];
|
||||
for (int i = 1; i < lines.length; ++i) {
|
||||
String[] lineData = lines[i].split("\\s+");
|
||||
//method
|
||||
if (lineData.length == 3) {
|
||||
if (!mcpData.methods.containsKey(lineData[2])) mcpData.methods.put(lineData[2], new LinkedList<>());
|
||||
MethodData d = clazz.methods.get(lineData[0] + lineData[1]);
|
||||
if (d == null) continue;
|
||||
d.mcpName = lineData[2];
|
||||
mcpData.methods.get(lineData[2]).add(d);
|
||||
//field
|
||||
} else {
|
||||
if (!mcpData.fields.containsKey(lineData[1])) mcpData.fields.put(lineData[1], new LinkedList<>());
|
||||
FieldData d = clazz.fields.get(lineData[0]);
|
||||
if (d == null) continue;
|
||||
d.mcpName = lineData[1];
|
||||
mcpData.fields.get(lineData[1]).add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mcpData;
|
||||
}
|
||||
|
||||
private static void addMCPData(MCPData mcpData, String fields, String methods) {
|
||||
for (String field : fields.split("\n")) {
|
||||
String[] fieldData = field.split(",");
|
||||
mcpData.fields.getOrDefault(fieldData[0].trim(), new LinkedList<>()).forEach(f -> f.mcpName = fieldData[1].trim());
|
||||
}
|
||||
|
||||
for (String method : methods.split("\n")) {
|
||||
String[] methodData = method.split(",");
|
||||
mcpData.methods.getOrDefault(methodData[0].trim(), new LinkedList<>()).forEach(m -> m.mcpName = methodData[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, String> readZipContentFromURL(URL remote, String... files) throws IOException {
|
||||
try (ZipInputStream is = new ZipInputStream(new BufferedInputStream(remote.openStream(), 1024))) {
|
||||
byte[] buff = new byte[1024];
|
||||
ZipEntry entry;
|
||||
Set<String> fileList = new HashSet<>(Arrays.asList(files));
|
||||
Map<String, String> fileContents = new HashMap<>();
|
||||
while ((entry = is.getNextEntry()) != null) {
|
||||
if (fileList.contains(entry.getName())) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int read;
|
||||
while ((read = is.read(buff, 0, 1024)) > 0) {
|
||||
builder.append(new String(buff, 0, read));
|
||||
}
|
||||
fileContents.put(entry.getName(), builder.toString());
|
||||
}
|
||||
}
|
||||
return fileContents;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClassData {
|
||||
final Map<String, ClassData> classMap;
|
||||
final String obf;
|
||||
final String intermediary;
|
||||
String mcpName;
|
||||
|
||||
final Map<String, MethodData> methods = new LinkedHashMap<>();
|
||||
final Map<String, FieldData> fields = new LinkedHashMap<>();
|
||||
|
||||
public ClassData(Map<String, ClassData> classMap, String obf, String intermediary) {
|
||||
this.classMap = classMap;
|
||||
this.obf = obf;
|
||||
this.intermediary = intermediary;
|
||||
}
|
||||
|
||||
public void addMethod(String obf, String obfSig, String intermediary) {
|
||||
methods.put(obf + obfSig, new MethodData(classMap, obf, obfSig, intermediary));
|
||||
}
|
||||
|
||||
public void addField(String obf, String obfSig, String intermediary) {
|
||||
fields.put(obf, new FieldData(classMap, obf, obfSig, intermediary));
|
||||
}
|
||||
|
||||
public String getIntToMCP() {
|
||||
StringBuilder builder = new StringBuilder("c\t").append(intermediary).append("\t").append(mcpName);
|
||||
for (MethodData method : methods.values()) {
|
||||
builder.append("\n\tm\t").append(method.getIntermediarySig()).append("\t").append(method.intermediary).append("\t").append(method.mcpName);
|
||||
}
|
||||
for (FieldData field : fields.values()) {
|
||||
builder.append("\n\tf\t").append(field.getIntermediarySig()).append("\t").append(field.intermediary).append("\t").append(field.mcpName);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MethodData {
|
||||
final Map<String, ClassData> classMap;
|
||||
final String obf;
|
||||
final String intermediary;
|
||||
String mcpName;
|
||||
|
||||
final String obfSig;
|
||||
|
||||
public MethodData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
|
||||
this.classMap = classMap;
|
||||
this.obf = obf;
|
||||
this.obfSig = obfSig;
|
||||
this.intermediary = intermediary;
|
||||
}
|
||||
|
||||
public String getIntermediarySig() {
|
||||
int offset = 0;
|
||||
Matcher m = Pattern.compile("L(.+?);").matcher(obfSig);
|
||||
String intSig = obfSig;
|
||||
while (m.find()) {
|
||||
if (!classMap.containsKey(m.group(1))) continue;
|
||||
String intName = classMap.get(m.group(1)).intermediary;
|
||||
intSig = intSig.substring(0, m.start(1) + offset) + intName + intSig.substring(m.end(1) + offset);
|
||||
offset += intName.length() - m.group(1).length();
|
||||
}
|
||||
return intSig;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FieldData {
|
||||
final Map<String, ClassData> classMap;
|
||||
final String obf;
|
||||
final String intermediary;
|
||||
String mcpName;
|
||||
|
||||
final String obfSig;
|
||||
|
||||
public FieldData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
|
||||
this.classMap = classMap;
|
||||
this.obf = obf;
|
||||
this.obfSig = obfSig;
|
||||
this.intermediary = intermediary;
|
||||
}
|
||||
|
||||
public String getIntermediarySig() {
|
||||
Matcher m = Pattern.compile("(\\[*)L(.+?);").matcher(obfSig);
|
||||
if (m.find()) {
|
||||
if (!classMap.containsKey(m.group(2))) return obfSig;
|
||||
return m.group(1) + "L" + classMap.get(m.group(2)).intermediary + ";";
|
||||
} else {
|
||||
return obfSig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MCPData {
|
||||
final Map<String, List<MethodData>> methods = new HashMap<>();
|
||||
final Map<String, List<FieldData>> fields = new HashMap<>();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package baritone.gradle.task;
|
||||
import org.gradle.api.DefaultTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -40,31 +41,53 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||
ARTIFACT_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";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, proguardOut;
|
||||
protected final Path
|
||||
artifactPath,
|
||||
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
|
||||
proguardOut;
|
||||
|
||||
protected void verifyArtifacts() throws IllegalStateException {
|
||||
public BaritoneGradleTask() {
|
||||
this.artifactName = getProject().getName();
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
|
||||
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.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!");
|
||||
}
|
||||
}
|
||||
|
||||
protected void write(InputStream stream, Path file) throws Exception {
|
||||
protected void write(InputStream stream, Path file) throws IOException {
|
||||
if (Files.exists(file)) {
|
||||
Files.delete(file);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
|
||||
@@ -42,9 +42,9 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
super.verifyArtifacts();
|
||||
|
||||
// Define the distribution file paths
|
||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||
|
||||
// NIO will not automatically create directories
|
||||
Path dir = getRelativeFile("dist/");
|
||||
@@ -53,12 +53,14 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
}
|
||||
|
||||
// Copy build jars to dist/
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
// TODO: dont copy files that dont exist
|
||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||
|
||||
// Calculate all checksums and format them like "shasum"
|
||||
List<String> shasum = Stream.of(api, standalone, unoptimized)
|
||||
List<String> shasum = getAllDistJars().stream()
|
||||
.filter(Files::exists)
|
||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -68,6 +70,24 @@ public class CreateDistTask extends BaritoneGradleTask {
|
||||
Files.write(getRelativeFile("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) {
|
||||
|
||||
@@ -22,6 +22,21 @@ import org.apache.commons.io.IOUtils;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.internal.file.IdentityFileResolver;
|
||||
import org.gradle.api.internal.plugins.DefaultConvention;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.TaskCollection;
|
||||
import org.gradle.api.tasks.compile.ForkOptions;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.internal.Pair;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
|
||||
import org.gradle.process.internal.DefaultExecActionFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
@@ -86,6 +101,101 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
}
|
||||
}
|
||||
|
||||
private String getJavaBinPathForProguard() throws Exception {
|
||||
String path;
|
||||
try {
|
||||
path = findJavaPathByGradleConfig();
|
||||
if (path != null) return path;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Unable to find java by javaCompile options");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
path = findJavaByJavaHome();
|
||||
if (path != null) return path;
|
||||
}
|
||||
catch(Exception ex) {
|
||||
System.err.println("Unable to find java by JAVA_HOME");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
path = findJavaByGradleCurrentRuntime();
|
||||
if (path != null) return path;
|
||||
|
||||
throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," +
|
||||
" JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)");
|
||||
}
|
||||
|
||||
private String findJavaByGradleCurrentRuntime() {
|
||||
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
|
||||
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Using Gradle's runtime Java for ProGuard");
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String findJavaByJavaHome() {
|
||||
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
||||
if (javaHomeEnv != null) {
|
||||
|
||||
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Detected Java path by JAVA_HOME");
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String findJavaPathByGradleConfig() {
|
||||
final TaskCollection<JavaCompile> javaCompiles = super.getProject().getTasks().withType(JavaCompile.class);
|
||||
|
||||
final JavaCompile compileTask = javaCompiles.iterator().next();
|
||||
final ForkOptions forkOptions = compileTask.getOptions().getForkOptions();
|
||||
|
||||
if (forkOptions != null) {
|
||||
String javacPath = forkOptions.getExecutable();
|
||||
if (javacPath != null) {
|
||||
File javacFile = new File(javacPath);
|
||||
if (javacFile.exists()) {
|
||||
File[] maybeJava = javacFile.getParentFile().listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.equals("java");
|
||||
}
|
||||
});
|
||||
|
||||
if (maybeJava != null && maybeJava.length > 0) {
|
||||
String path = maybeJava[0].getAbsolutePath();
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Detected Java path by forkOptions");
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean validateJavaVersion(String java) {
|
||||
final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
|
||||
|
||||
if (!javaVersion.getMajorVersion().equals("8")) {
|
||||
System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
||||
// throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generateConfigs() throws Exception {
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
|
||||
@@ -95,22 +205,34 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
|
||||
|
||||
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
|
||||
Process p = new ProcessBuilder("java", "-verbose").start();
|
||||
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
|
||||
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
||||
template.add(2, "-libraryjars '" + out + "'");
|
||||
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
acquireDependencies().forEach(f -> {
|
||||
if (f.toString().endsWith("-recomp.jar")) {
|
||||
// remove MCP mapped jar
|
||||
return;
|
||||
{
|
||||
final Stream<File> libraries;
|
||||
{
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
final Stream<File> dependencies = acquireDependencies()
|
||||
// remove MCP mapped jar
|
||||
.filter(f -> !f.toString().endsWith("-recomp.jar"))
|
||||
// go from the extra to the original downloaded client
|
||||
.map(f -> f.toString().endsWith("client-extra.jar") ? new File(f.getParentFile(), "client.jar") : f);
|
||||
|
||||
if (getProject().hasProperty("baritone.forge_build")) {
|
||||
libraries = dependencies
|
||||
.map(f -> f.toString().endsWith("client.jar") ? getSrgMcJar() : f);
|
||||
} else if (getProject().hasProperty("baritone.fabric_build")) {
|
||||
libraries = dependencies
|
||||
.map(f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") ? getSrgMcJar() : f);
|
||||
} else {
|
||||
libraries = dependencies;
|
||||
}
|
||||
}
|
||||
if (f.toString().endsWith("client-extra.jar")) {
|
||||
// go from the extra to the original downloaded client
|
||||
f = new File(f.getParentFile(), "client.jar");
|
||||
}
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
libraries.forEach(f -> {
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
}
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||
@@ -121,8 +243,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||
}
|
||||
|
||||
private File getSrgMcJar() {
|
||||
return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
|
||||
}
|
||||
|
||||
private Stream<File> acquireDependencies() {
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles().stream().filter(File::isFile);
|
||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(File::isFile);
|
||||
}
|
||||
|
||||
private void proguardApi() throws Exception {
|
||||
|
||||
58
scripts/proguard.pro
vendored
58
scripts/proguard.pro
vendored
@@ -16,7 +16,10 @@
|
||||
-dontwarn org.lwjgl.**
|
||||
# also lwjgl lol
|
||||
-dontwarn module-info
|
||||
# we dont have forge
|
||||
-dontwarn baritone.launch.BaritoneForgeModXD
|
||||
|
||||
# please do not change the comment below
|
||||
-keep class baritone.api.** { *; } # this is the keep api
|
||||
|
||||
# service provider needs these class names
|
||||
@@ -25,6 +28,13 @@
|
||||
|
||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||
|
||||
# Keep any class or member annotated with @KeepName so we dont have to put everything in the script
|
||||
-keep,allowobfuscation @interface baritone.KeepName
|
||||
-keep @baritone.KeepName class *
|
||||
-keepclassmembers class * {
|
||||
@baritone.KeepName *;
|
||||
}
|
||||
|
||||
# setting names are reflected from field names, so keep field names
|
||||
-keepclassmembers class baritone.api.Settings {
|
||||
public <fields>;
|
||||
@@ -134,19 +144,19 @@
|
||||
-assumenosideeffects public class java.lang.* extends java.lang.Number {
|
||||
public static java.lang.String toString(byte);
|
||||
public static java.lang.Byte valueOf(byte);
|
||||
public static byte parseByte(java.lang.String);
|
||||
public static byte parseByte(java.lang.String,int);
|
||||
public static java.lang.Byte valueOf(java.lang.String,int);
|
||||
public static java.lang.Byte valueOf(java.lang.String);
|
||||
public static java.lang.Byte decode(java.lang.String);
|
||||
# public static byte parseByte(java.lang.String);
|
||||
# public static byte parseByte(java.lang.String,int);
|
||||
# public static java.lang.Byte valueOf(java.lang.String,int);
|
||||
# public static java.lang.Byte valueOf(java.lang.String);
|
||||
# public static java.lang.Byte decode(java.lang.String);
|
||||
public int compareTo(java.lang.Byte);
|
||||
public static java.lang.String toString(short);
|
||||
public static short parseShort(java.lang.String);
|
||||
public static short parseShort(java.lang.String,int);
|
||||
public static java.lang.Short valueOf(java.lang.String,int);
|
||||
public static java.lang.Short valueOf(java.lang.String);
|
||||
# public static short parseShort(java.lang.String);
|
||||
# public static short parseShort(java.lang.String,int);
|
||||
# public static java.lang.Short valueOf(java.lang.String,int);
|
||||
# public static java.lang.Short valueOf(java.lang.String);
|
||||
public static java.lang.Short valueOf(short);
|
||||
public static java.lang.Short decode(java.lang.String);
|
||||
# public static java.lang.Short decode(java.lang.String);
|
||||
public static short reverseBytes(short);
|
||||
public int compareTo(java.lang.Short);
|
||||
public static java.lang.String toString(int,int);
|
||||
@@ -154,10 +164,10 @@
|
||||
public static java.lang.String toOctalString(int);
|
||||
public static java.lang.String toBinaryString(int);
|
||||
public static java.lang.String toString(int);
|
||||
public static int parseInt(java.lang.String,int);
|
||||
public static int parseInt(java.lang.String);
|
||||
public static java.lang.Integer valueOf(java.lang.String,int);
|
||||
public static java.lang.Integer valueOf(java.lang.String);
|
||||
# public static int parseInt(java.lang.String,int);
|
||||
# public static int parseInt(java.lang.String);
|
||||
# public static java.lang.Integer valueOf(java.lang.String,int);
|
||||
# public static java.lang.Integer valueOf(java.lang.String);
|
||||
public static java.lang.Integer valueOf(int);
|
||||
public static java.lang.Integer getInteger(java.lang.String);
|
||||
public static java.lang.Integer getInteger(java.lang.String,int);
|
||||
@@ -179,12 +189,12 @@
|
||||
public static java.lang.String toOctalString(long);
|
||||
public static java.lang.String toBinaryString(long);
|
||||
public static java.lang.String toString(long);
|
||||
public static long parseLong(java.lang.String,int);
|
||||
public static long parseLong(java.lang.String);
|
||||
public static java.lang.Long valueOf(java.lang.String,int);
|
||||
public static java.lang.Long valueOf(java.lang.String);
|
||||
# public static long parseLong(java.lang.String,int);
|
||||
# public static long parseLong(java.lang.String);
|
||||
# public static java.lang.Long valueOf(java.lang.String,int);
|
||||
# public static java.lang.Long valueOf(java.lang.String);
|
||||
public static java.lang.Long valueOf(long);
|
||||
public static java.lang.Long decode(java.lang.String);
|
||||
# public static java.lang.Long decode(java.lang.String);
|
||||
public static java.lang.Long getLong(java.lang.String);
|
||||
public static java.lang.Long getLong(java.lang.String,long);
|
||||
public static java.lang.Long getLong(java.lang.String,java.lang.Long);
|
||||
@@ -201,9 +211,9 @@
|
||||
public int compareTo(java.lang.Long);
|
||||
public static java.lang.String toString(float);
|
||||
public static java.lang.String toHexString(float);
|
||||
public static java.lang.Float valueOf(java.lang.String);
|
||||
# public static java.lang.Float valueOf(java.lang.String);
|
||||
public static java.lang.Float valueOf(float);
|
||||
public static float parseFloat(java.lang.String);
|
||||
# public static float parseFloat(java.lang.String);
|
||||
public static boolean isNaN(float);
|
||||
public static boolean isInfinite(float);
|
||||
public static int floatToIntBits(float);
|
||||
@@ -215,9 +225,9 @@
|
||||
public int compareTo(java.lang.Float);
|
||||
public static java.lang.String toString(double);
|
||||
public static java.lang.String toHexString(double);
|
||||
public static java.lang.Double valueOf(java.lang.String);
|
||||
public static java.lang.Double valueOf(double);
|
||||
public static double parseDouble(java.lang.String);
|
||||
# public static java.lang.Double valueOf(java.lang.String);
|
||||
# public static java.lang.Double valueOf(double);
|
||||
# public static double parseDouble(java.lang.String);
|
||||
public static boolean isNaN(double);
|
||||
public static boolean isInfinite(double);
|
||||
public static long doubleToLongBits(double);
|
||||
|
||||
Binary file not shown.
@@ -19,9 +19,6 @@ package baritone.api;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
|
||||
*
|
||||
@@ -37,9 +34,11 @@ public final class BaritoneAPI {
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings);
|
||||
|
||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||
provider = instances.next();
|
||||
try {
|
||||
provider = (IBaritoneProvider) Class.forName("baritone.BaritoneProvider").newInstance();
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static IBaritoneProvider getProvider() {
|
||||
|
||||
@@ -20,13 +20,13 @@ package baritone.api;
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.*;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
|
||||
@@ -21,7 +21,7 @@ import baritone.api.cache.IWorldScanner;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.api.schematic.ISchematicSystem;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -47,19 +47,19 @@ public interface IBaritoneProvider {
|
||||
* returned by {@link #getPrimaryBaritone()}.
|
||||
*
|
||||
* @return All active {@link IBaritone} instances.
|
||||
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
||||
* @see #getBaritoneForPlayer(ClientPlayerEntity)
|
||||
*/
|
||||
List<IBaritone> getAllBaritones();
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
||||
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}. This will likely be
|
||||
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
||||
* {@code bot-system} is merged into {@code master}.
|
||||
*
|
||||
* @param player The player
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
|
||||
for (IBaritone baritone : getAllBaritones()) {
|
||||
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
||||
return baritone;
|
||||
|
||||
@@ -20,18 +20,18 @@ package baritone.api;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.TypeUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -61,6 +61,19 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> allowInventory = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
|
||||
* <p>
|
||||
* Specifically, path calculation will still assume that an auto tool will run at execution time, even though
|
||||
* Baritone itself will not do that.
|
||||
*/
|
||||
public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* If this setting is on, no auto tool will occur at all, not at calculation time nor execution time
|
||||
*/
|
||||
public final Setting<Boolean> disableAutoTool = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* It doesn't actually take twenty ticks to place a block, this cost is so high
|
||||
* because we want to generally conserve blocks which might be limited.
|
||||
@@ -178,9 +191,7 @@ public final class Settings {
|
||||
Blocks.CRAFTING_TABLE,
|
||||
Blocks.FURNACE,
|
||||
Blocks.CHEST,
|
||||
Blocks.TRAPPED_CHEST,
|
||||
Blocks.SIGN,
|
||||
Blocks.WALL_SIGN
|
||||
Blocks.TRAPPED_CHEST
|
||||
)));
|
||||
|
||||
/**
|
||||
@@ -192,6 +203,15 @@ public final class Settings {
|
||||
|
||||
)));
|
||||
|
||||
/**
|
||||
* A list of blocks to become air
|
||||
* <p>
|
||||
* If a schematic asks for a block on this list, only air will be accepted at that location (and nothing on buildIgnoreBlocks)
|
||||
*/
|
||||
public final Setting<List<Block>> okIfAir = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
|
||||
)));
|
||||
|
||||
/**
|
||||
* If this is true, the builder will treat all non-air blocks as correct. It will only place new blocks.
|
||||
*/
|
||||
@@ -434,6 +454,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> simplifyUnloadedYCoord = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Whenever a block changes, repack the whole chunk that it's in
|
||||
*/
|
||||
public final Setting<Boolean> repackOnAnyBlockChange = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* If a movement takes this many ticks more than its initial cost estimate, cancel it
|
||||
*/
|
||||
@@ -506,6 +531,18 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> backfill = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Shows popup message in the upper right corner, similarly to when you make an advancement
|
||||
*/
|
||||
public final Setting<Boolean> logAsToast = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* The time of how long the message in the pop-up will display
|
||||
* <p>
|
||||
* If below 1000L (1sec), it's better to disable this
|
||||
*/
|
||||
public final Setting<Long> toastTimer = new Setting<>(5000L);
|
||||
|
||||
/**
|
||||
* Print all the debug messages to chat
|
||||
*/
|
||||
@@ -703,6 +740,23 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
|
||||
|
||||
/**
|
||||
* Sets the minimum y level whilst mining - set to 0 to turn off.
|
||||
*/
|
||||
public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
|
||||
|
||||
/**
|
||||
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
|
||||
*/
|
||||
public final Setting<Boolean> allowOnlyExposedOres = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When allowOnlyExposedOres is enabled this is the distance around to search.
|
||||
* <p>
|
||||
* It is recommended to keep this value low, as it dramatically increases calculation times.
|
||||
*/
|
||||
public final Setting<Integer> allowOnlyExposedOresDistance = new Setting<>(1);
|
||||
|
||||
/**
|
||||
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
|
||||
*/
|
||||
@@ -756,10 +810,21 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> layerOrder = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Start building the schematic at a specific layer.
|
||||
* Can help on larger builds when schematic wants to break things its already built
|
||||
*/
|
||||
public final Setting<Integer> startAtLayer = new Setting<>(0);
|
||||
|
||||
/**
|
||||
* If a layer is unable to be constructed, just skip it.
|
||||
*/
|
||||
public final Setting<Boolean> skipFailedLayers = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
|
||||
*/
|
||||
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
|
||||
public final Setting<Vector3i> buildRepeat = new Setting<>(new Vector3i(0, 0, 0));
|
||||
|
||||
/**
|
||||
* How many times to buildrepeat. -1 for infinite.
|
||||
@@ -960,6 +1025,11 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
||||
|
||||
/**
|
||||
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors
|
||||
*/
|
||||
public final Setting<Boolean> verboseCommandExceptions = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||
*/
|
||||
@@ -1050,6 +1120,35 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notifications
|
||||
*/
|
||||
public final Setting<Boolean> desktopNotifications = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Desktop notification on path complete
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnPathComplete = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notification on farm fail
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnFarmFail = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notification on build finished
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnBuildFinished = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notification on explore finished
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnExploreFinished = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notification on mine fail
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public interface IBlockTypeAccess {
|
||||
|
||||
IBlockState getBlock(int x, int y, int z);
|
||||
BlockState getBlock(int x, int y, int z);
|
||||
|
||||
default IBlockState getBlock(BlockPos pos) {
|
||||
default BlockState getBlock(BlockPos pos) {
|
||||
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public interface IWorldScanner {
|
||||
* Queues the chunks in a square formation around the specified player, using the specified
|
||||
* range, which represents 1/2 the square's dimensions, where the player is in the center.
|
||||
*
|
||||
* @param ctx The player, describing the origin
|
||||
* @param ctx The player, describing the origin
|
||||
* @param range The range to repack
|
||||
* @return The amount of chunks successfully queued for repacking
|
||||
*/
|
||||
|
||||
@@ -34,9 +34,8 @@ import java.util.stream.Stream;
|
||||
* So basically, you should use it because it provides a small amount of boilerplate,
|
||||
* but you're not forced to use it.
|
||||
*
|
||||
* @see ICommand
|
||||
*
|
||||
* @author LoganDark
|
||||
* @see ICommand
|
||||
*/
|
||||
public abstract class Command implements ICommand {
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public interface IArgParserManager {
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
@@ -27,7 +25,9 @@ import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
@@ -223,7 +223,7 @@ public interface IArgConsumer {
|
||||
* @param type The type to peek as
|
||||
* @param index The index to peek
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
@@ -240,7 +240,7 @@ public interface IArgConsumer {
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #peekAsOrDefault(Class, Object)
|
||||
@@ -404,8 +404,8 @@ public interface IArgConsumer {
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
||||
* {@link EnumFacing#UP}
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as the next argument's value
|
||||
@@ -419,8 +419,8 @@ public interface IArgConsumer {
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
||||
* {@link EnumFacing#UP}
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @param def The default value
|
||||
@@ -436,8 +436,8 @@ public interface IArgConsumer {
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
||||
* {@link EnumFacing#UP}
|
||||
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||
* {@link Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it
|
||||
@@ -458,7 +458,7 @@ public interface IArgConsumer {
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #get()
|
||||
* @see #getAsOrDefault(Class, Object)
|
||||
|
||||
@@ -19,7 +19,7 @@ package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
|
||||
@@ -50,8 +50,8 @@ public interface ICommandArgument {
|
||||
/**
|
||||
* Gets an enum value from the enum class with the same name as this argument's value
|
||||
* <p>
|
||||
* For example if you getEnum as an {@link EnumFacing}, and this argument's value is "up", it will return {@link
|
||||
* EnumFacing#UP}
|
||||
* For example if you getEnum as an {@link Direction}, and this argument's value is "up", it will return {@link
|
||||
* Direction#UP}
|
||||
*
|
||||
* @param enumClass The enum class to search
|
||||
* @return An enum constant of that class with the same name as this argument's value
|
||||
@@ -87,7 +87,7 @@ public interface ICommandArgument {
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T, S> T getAs(Class<T> type, Class<S> stateType, S state) throws CommandInvalidTypeException;
|
||||
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -33,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 = IRegistry.BLOCK.get(id)) == Blocks.AIR) {
|
||||
if ((block = Registry.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
}
|
||||
return block;
|
||||
@@ -43,7 +42,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
IRegistry.BLOCK.keySet()
|
||||
Registry.BLOCK.keySet()
|
||||
.stream()
|
||||
.map(Object::toString)
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@ import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -32,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 = IRegistry.ENTITY_TYPE.get(id)) == null) {
|
||||
if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
}
|
||||
return entity;
|
||||
@@ -41,7 +41,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(IRegistry.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
@@ -17,26 +17,26 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForEnumFacing implements IDatatypeFor<EnumFacing> {
|
||||
public enum ForDirection implements IDatatypeFor<Direction> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public EnumFacing get(IDatatypeContext ctx) throws CommandException {
|
||||
return EnumFacing.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
||||
public Direction get(IDatatypeContext ctx) throws CommandException {
|
||||
return Direction.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Stream.of(EnumFacing.values())
|
||||
.map(EnumFacing::getName).map(String::toLowerCase))
|
||||
.append(Stream.of(Direction.values())
|
||||
.map(Direction::getName2).map(String::toLowerCase))
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.stream();
|
||||
}
|
||||
@@ -20,8 +20,8 @@ package baritone.api.command.datatypes;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -24,9 +24,8 @@ import baritone.api.command.argument.IArgConsumer;
|
||||
* Provides an {@link IDatatype} with contextual information so
|
||||
* that it can perform the desired operation on the target level.
|
||||
*
|
||||
* @see IDatatype
|
||||
*
|
||||
* @author Brady
|
||||
* @see IDatatype
|
||||
* @since 9/26/2019
|
||||
*/
|
||||
public interface IDatatypeContext {
|
||||
|
||||
@@ -34,11 +34,10 @@ public interface IDatatypeFor<T> extends IDatatype {
|
||||
* if the expected input does not conform to a parseable value. As far as a {@link CommandException} being
|
||||
* thrown is concerned, see the note below for specifics.
|
||||
*
|
||||
* @see IDatatypeContext
|
||||
*
|
||||
* @param ctx The context
|
||||
* @return The parsed data-type
|
||||
* @throws CommandException If there was an issue parsing using another type or arguments could not be polled.
|
||||
* @see IDatatypeContext
|
||||
*/
|
||||
T get(IDatatypeContext ctx) throws CommandException;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package baritone.api.command.datatypes;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,11 +30,11 @@ import java.util.stream.Stream;
|
||||
* An {@link IDatatype} used to resolve nearby players, those within
|
||||
* render distance of the target {@link IBaritone} instance.
|
||||
*/
|
||||
public enum NearbyPlayer implements IDatatypeFor<EntityPlayer> {
|
||||
public enum NearbyPlayer implements IDatatypeFor<PlayerEntity> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public EntityPlayer get(IDatatypeContext ctx) throws CommandException {
|
||||
public PlayerEntity get(IDatatypeContext ctx) throws CommandException {
|
||||
final String username = ctx.getConsumer().getString();
|
||||
return getPlayers(ctx).stream()
|
||||
.filter(s -> s.getName().getString().equalsIgnoreCase(username))
|
||||
@@ -44,13 +44,13 @@ public enum NearbyPlayer implements IDatatypeFor<EntityPlayer> {
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(getPlayers(ctx).stream().map(EntityPlayer::getName).map(ITextComponent::getString))
|
||||
.append(getPlayers(ctx).stream().map(PlayerEntity::getName).map(ITextComponent::getString))
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
|
||||
private static List<EntityPlayer> getPlayers(IDatatypeContext ctx) {
|
||||
return ctx.getBaritone().getPlayerContext().world().playerEntities;
|
||||
private static List<? extends PlayerEntity> getPlayers(IDatatypeContext ctx) {
|
||||
return ctx.getBaritone().getPlayerContext().world().getPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
@@ -18,16 +18,13 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
@@ -37,7 +37,7 @@ public enum RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
|
||||
final IArgConsumer consumer = ctx.getConsumer();
|
||||
return new GoalXZ(
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y))
|
||||
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CommandUnhandledException extends RuntimeException implements IComm
|
||||
@Override
|
||||
public void handle(ICommand command, List<ICommandArgument> args) {
|
||||
HELPER.logDirect("An unhandled exception occurred. " +
|
||||
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
|
||||
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
|
||||
TextFormatting.RED);
|
||||
|
||||
this.printStackTrace();
|
||||
|
||||
@@ -38,8 +38,8 @@ import static baritone.api.utils.Helper.HELPER;
|
||||
public interface ICommandException {
|
||||
|
||||
/**
|
||||
* @see Exception#getMessage()
|
||||
* @return The exception details
|
||||
* @see Exception#getMessage()
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
|
||||
package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.utils.Helper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -74,40 +75,40 @@ public class Paginator<E> implements Helper {
|
||||
}
|
||||
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||
ITextComponent prevPageComponent = new TextComponentString("<<");
|
||||
TextComponent prevPageComponent = new StringTextComponent("<<");
|
||||
if (hasPrevPage) {
|
||||
prevPageComponent.getStyle()
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle()
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page - 1)
|
||||
))
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to view previous page")
|
||||
));
|
||||
new StringTextComponent("Click to view previous page")
|
||||
)));
|
||||
} else {
|
||||
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY));
|
||||
}
|
||||
ITextComponent nextPageComponent = new TextComponentString(">>");
|
||||
TextComponent nextPageComponent = new StringTextComponent(">>");
|
||||
if (hasNextPage) {
|
||||
nextPageComponent.getStyle()
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle()
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format("%s %d", commandPrefix, page + 1)
|
||||
))
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to view next page")
|
||||
));
|
||||
new StringTextComponent("Click to view next page")
|
||||
)));
|
||||
} else {
|
||||
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY));
|
||||
}
|
||||
ITextComponent pagerComponent = new TextComponentString("");
|
||||
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
pagerComponent.appendSibling(prevPageComponent);
|
||||
pagerComponent.appendText(" | ");
|
||||
pagerComponent.appendSibling(nextPageComponent);
|
||||
pagerComponent.appendText(String.format(" %d/%d", page, getMaxPage()));
|
||||
TextComponent pagerComponent = new StringTextComponent("");
|
||||
pagerComponent.setStyle(pagerComponent.getStyle().setFormatting(TextFormatting.GRAY));
|
||||
pagerComponent.append(prevPageComponent);
|
||||
pagerComponent.appendString(" | ");
|
||||
pagerComponent.append(nextPageComponent);
|
||||
pagerComponent.appendString(String.format(" %d/%d", page, getMaxPage()));
|
||||
logDirect(pagerComponent);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -236,7 +236,6 @@ public class TabCompleteHelper {
|
||||
* Appends every command in the specified {@link ICommandManager} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @param manager A command manager
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addCommands(ICommandManager manager) {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -31,9 +31,9 @@ public final class PacketEvent {
|
||||
|
||||
private final EventState state;
|
||||
|
||||
private final Packet<?> packet;
|
||||
private final IPacket<?> packet;
|
||||
|
||||
public PacketEvent(NetworkManager networkManager, EventState state, Packet<?> packet) {
|
||||
public PacketEvent(NetworkManager networkManager, EventState state, IPacket<?> packet) {
|
||||
this.networkManager = networkManager;
|
||||
this.state = state;
|
||||
this.packet = packet;
|
||||
@@ -47,12 +47,12 @@ public final class PacketEvent {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public final Packet<?> getPacket() {
|
||||
public final IPacket<?> getPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends Packet<?>> T cast() {
|
||||
public final <T extends IPacket<?>> T cast() {
|
||||
return (T) this.packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/5/2018
|
||||
@@ -28,8 +31,13 @@ public final class RenderEvent {
|
||||
*/
|
||||
private final float partialTicks;
|
||||
|
||||
public RenderEvent(float partialTicks) {
|
||||
private final Matrix4f projectionMatrix;
|
||||
private final MatrixStack modelViewStack;
|
||||
|
||||
public RenderEvent(float partialTicks, MatrixStack modelViewStack, Matrix4f projectionMatrix) {
|
||||
this.partialTicks = partialTicks;
|
||||
this.modelViewStack = modelViewStack;
|
||||
this.projectionMatrix = projectionMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,4 +46,12 @@ public final class RenderEvent {
|
||||
public final float getPartialTicks() {
|
||||
return this.partialTicks;
|
||||
}
|
||||
|
||||
public MatrixStack getModelViewStack() {
|
||||
return this.modelViewStack;
|
||||
}
|
||||
|
||||
public Matrix4f getProjectionMatrix() {
|
||||
return this.projectionMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -69,14 +70,14 @@ public final class RotationMoveEvent {
|
||||
/**
|
||||
* Called when the player's motion is updated.
|
||||
*
|
||||
* @see Entity#moveRelative(float, float, float, float)
|
||||
* @see Entity#moveRelative(float, Vector3d)
|
||||
*/
|
||||
MOTION_UPDATE,
|
||||
|
||||
/**
|
||||
* Called when the player jumps.
|
||||
*
|
||||
* @see EntityLivingBase#jump
|
||||
* @see LivingEntity
|
||||
*/
|
||||
JUMP
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
import baritone.api.event.events.type.Overrideable;
|
||||
|
||||
/**
|
||||
* @author LoganDark
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -29,14 +29,14 @@ public final class WorldEvent {
|
||||
/**
|
||||
* The new world that is being loaded. {@code null} if being unloaded.
|
||||
*/
|
||||
private final WorldClient world;
|
||||
private final ClientWorld world;
|
||||
|
||||
/**
|
||||
* The state of the event
|
||||
*/
|
||||
private final EventState state;
|
||||
|
||||
public WorldEvent(WorldClient world, EventState state) {
|
||||
public WorldEvent(ClientWorld world, EventState state) {
|
||||
this.world = world;
|
||||
this.state = state;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public final class WorldEvent {
|
||||
/**
|
||||
* @return The new world that is being loaded. {@code null} if being unloaded.
|
||||
*/
|
||||
public final WorldClient getWorld() {
|
||||
public final ClientWorld getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ package baritone.api.event.listener;
|
||||
|
||||
import baritone.api.event.events.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiGameOver;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.DeathScreen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -44,7 +44,7 @@ public interface IGameEventListener {
|
||||
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#tick()
|
||||
* @see ClientPlayerEntity#tick()
|
||||
*/
|
||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface IGameEventListener {
|
||||
* Runs whenever the client player sends a message to the server.
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#sendChatMessage(String)
|
||||
* @see ClientPlayerEntity#sendChatMessage(String)
|
||||
*/
|
||||
void onSendChatMessage(ChatEvent event);
|
||||
|
||||
@@ -81,7 +81,7 @@ public interface IGameEventListener {
|
||||
* Runs before and after whenever a new world is loaded
|
||||
*
|
||||
* @param event The event
|
||||
* @see Minecraft#loadWorld(WorldClient, GuiScreen)
|
||||
* @see Minecraft#loadWorld(ClientWorld)
|
||||
*/
|
||||
void onWorldEvent(WorldEvent event);
|
||||
|
||||
@@ -89,7 +89,7 @@ public interface IGameEventListener {
|
||||
* Runs before a outbound packet is sent
|
||||
*
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see IPacket
|
||||
*/
|
||||
void onSendPacket(PacketEvent event);
|
||||
|
||||
@@ -97,7 +97,7 @@ public interface IGameEventListener {
|
||||
* Runs before an inbound packet is processed
|
||||
*
|
||||
* @param event The event
|
||||
* @see Packet
|
||||
* @see IPacket
|
||||
*/
|
||||
void onReceivePacket(PacketEvent event);
|
||||
|
||||
@@ -106,15 +106,15 @@ public interface IGameEventListener {
|
||||
* and before and after the player jumps.
|
||||
*
|
||||
* @param event The event
|
||||
* @see Entity#moveRelative(float, float, float, float)
|
||||
* @see Entity#moveRelative(float, Vector3d)
|
||||
*/
|
||||
void onPlayerRotationMove(RotationMoveEvent event);
|
||||
|
||||
/**
|
||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#livingTick}
|
||||
* Called whenever the sprint keybind state is checked in {@link ClientPlayerEntity#livingTick}
|
||||
*
|
||||
* @param event The event
|
||||
* @see EntityPlayerSP#livingTick()
|
||||
* @see ClientPlayerEntity#livingTick()
|
||||
*/
|
||||
void onPlayerSprintState(SprintStateEvent event);
|
||||
|
||||
@@ -126,9 +126,9 @@ public interface IGameEventListener {
|
||||
void onBlockInteract(BlockInteractEvent event);
|
||||
|
||||
/**
|
||||
* Called when the local player dies, as indicated by the creation of the {@link GuiGameOver} screen.
|
||||
* Called when the local player dies, as indicated by the creation of the {@link DeathScreen} screen.
|
||||
*
|
||||
* @see GuiGameOver
|
||||
* @see DeathScreen
|
||||
*/
|
||||
void onPlayerDeath();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GoalRunAway implements Goal {
|
||||
|
||||
private final BlockPos[] from;
|
||||
|
||||
private final double distanceSq;
|
||||
private final int distanceSq;
|
||||
|
||||
private final Integer maintainY;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GoalRunAway implements Goal {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.from = from;
|
||||
this.distanceSq = distance * distance;
|
||||
this.distanceSq = (int) (distance * distance);
|
||||
this.maintainY = maintainY;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GoalRunAway implements Goal {
|
||||
for (BlockPos p : from) {
|
||||
int diffX = x - p.getX();
|
||||
int diffZ = z - p.getZ();
|
||||
double distSq = diffX * diffX + diffZ * diffZ;
|
||||
int distSq = diffX * diffX + diffZ * diffZ;
|
||||
if (distSq < distanceSq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ public class GoalStrictDirection implements Goal {
|
||||
public final int dx;
|
||||
public final int dz;
|
||||
|
||||
public GoalStrictDirection(BlockPos origin, EnumFacing direction) {
|
||||
public GoalStrictDirection(BlockPos origin, Direction direction) {
|
||||
x = origin.getX();
|
||||
y = origin.getY();
|
||||
z = origin.getZ();
|
||||
|
||||
@@ -21,7 +21,7 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
/**
|
||||
* Useful for long-range goals that don't have a specific Y level.
|
||||
@@ -94,7 +94,7 @@ public class GoalXZ implements Goal {
|
||||
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune
|
||||
}
|
||||
|
||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||
public static GoalXZ fromDirection(Vector3d origin, float yaw, double distance) {
|
||||
float theta = (float) Math.toRadians(yaw);
|
||||
double x = origin.x - MathHelper.sin(theta) * distance;
|
||||
double z = origin.z + MathHelper.cos(theta) * distance;
|
||||
|
||||
@@ -75,7 +75,7 @@ public interface IBaritoneProcess {
|
||||
* to start eating this tick. {@code PauseForAutoEatProcess} should only actually right click once onTick is called with
|
||||
* {@code isSafeToCancel} true though.
|
||||
*
|
||||
* @return Whethor or not if this control is temporary
|
||||
* @return Whether or not if this control is temporary
|
||||
*/
|
||||
boolean isTemporary();
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -39,7 +39,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
* @param schematic The object representation of the schematic
|
||||
* @param origin The origin position of the schematic being built
|
||||
*/
|
||||
void build(String name, ISchematic schematic, Vec3i origin);
|
||||
void build(String name, ISchematic schematic, Vector3i origin);
|
||||
|
||||
/**
|
||||
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
|
||||
@@ -49,7 +49,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
* @param origin The origin position of the schematic being built
|
||||
* @return Whether or not the schematic was able to load from file
|
||||
*/
|
||||
boolean build(String name, File schematic, Vec3i origin);
|
||||
boolean build(String name, File schematic, Vector3i origin);
|
||||
|
||||
default boolean build(String schematicFile, BlockPos origin) {
|
||||
File file = new File(new File(Minecraft.getInstance().gameDir, "schematics"), schematicFile);
|
||||
@@ -71,5 +71,5 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
* schematics, for example, to pick a state that the builder process will be happy with, because any variation will
|
||||
* cause it to give up. This is updated every tick, but only while the builder process is active.
|
||||
*/
|
||||
List<IBlockState> getApproxPlaceable();
|
||||
List<BlockState> getApproxPlaceable();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,29 @@
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IFarmProcess extends IBaritoneProcess {
|
||||
|
||||
void farm();
|
||||
/**
|
||||
* Begin to search for crops to farm with in specified aria
|
||||
* from specified location.
|
||||
*
|
||||
* @param range The distance from center to farm from
|
||||
* @param pos The center position to base the range from
|
||||
*/
|
||||
void farm(int range, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Begin to search for nearby crops to farm.
|
||||
*/
|
||||
default void farm() {farm(0, null);}
|
||||
|
||||
/**
|
||||
* Begin to search for crops to farm with in specified aria
|
||||
* from the position the command was executed.
|
||||
*
|
||||
* @param range The distance to search for crops to farm
|
||||
*/
|
||||
default void farm(int range) {farm(range, null);}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -47,7 +47,7 @@ public class CompositeSchematic extends AbstractSchematic {
|
||||
recalcArr();
|
||||
}
|
||||
|
||||
private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) {
|
||||
private CompositeSchematicEntry getSchematic(int x, int y, int z, BlockState currentState) {
|
||||
for (CompositeSchematicEntry entry : schematicArr) {
|
||||
if (x >= entry.x && y >= entry.y && z >= entry.z &&
|
||||
entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
|
||||
@@ -58,13 +58,13 @@ public class CompositeSchematic extends AbstractSchematic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
||||
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||
CompositeSchematicEntry entry = getSchematic(x, y, z, currentState);
|
||||
return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||
CompositeSchematicEntry entry = getSchematic(x, y, z, current);
|
||||
if (entry == null) {
|
||||
throw new IllegalStateException("couldn't find schematic for this position");
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.schematic;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FillSchematic extends AbstractSchematic {
|
||||
this.bom = bom;
|
||||
}
|
||||
|
||||
public FillSchematic(int x, int y, int z, IBlockState state) {
|
||||
public FillSchematic(int x, int y, int z, BlockState state) {
|
||||
this(x, y, z, new BlockOptionalMeta(state.getBlock()));
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ public class FillSchematic extends AbstractSchematic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||
if (bom.matches(current)) {
|
||||
return current;
|
||||
} else if (current.getBlock() != Blocks.AIR) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
for (IBlockState placeable : approxPlaceable) {
|
||||
for (BlockState placeable : approxPlaceable) {
|
||||
if (bom.matches(placeable)) {
|
||||
return placeable;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,11 +44,11 @@ public interface ISchematic {
|
||||
* @param currentState The current state of that block in the world, or null
|
||||
* @return Whether or not the specified position is within the bounds of this schematic
|
||||
*/
|
||||
default boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
||||
default boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
||||
}
|
||||
|
||||
default int size(EnumFacing.Axis axis) {
|
||||
default int size(Direction.Axis axis) {
|
||||
switch (axis) {
|
||||
case X:
|
||||
return widthX();
|
||||
@@ -71,7 +71,7 @@ public interface ISchematic {
|
||||
* @param approxPlaceable The list of blockstates estimated to be placeable
|
||||
* @return The desired block state at the specified position
|
||||
*/
|
||||
IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable);
|
||||
BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable);
|
||||
|
||||
/**
|
||||
* @return The width (X axis length) of this schematic
|
||||
|
||||
@@ -17,21 +17,20 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
/**
|
||||
* A static schematic is capable of providing the desired state at a given position without
|
||||
* additional context. Schematics of this type are expected to have non-varying contents.
|
||||
*
|
||||
* @see #getDirect(int, int, int)
|
||||
*
|
||||
* @author Brady
|
||||
* @see #getDirect(int, int, int)
|
||||
* @since 12/24/2019
|
||||
*/
|
||||
public interface IStaticSchematic extends ISchematic {
|
||||
|
||||
/**
|
||||
* Gets the {@link IBlockState} for a given position in this schematic. It should be guaranteed
|
||||
* Gets the {@link BlockState} for a given position in this schematic. It should be guaranteed
|
||||
* that the return value of this method will not change given that the parameters are the same.
|
||||
*
|
||||
* @param x The X block position
|
||||
@@ -39,19 +38,19 @@ public interface IStaticSchematic extends ISchematic {
|
||||
* @param z The Z block position
|
||||
* @return The desired state at the specified position.
|
||||
*/
|
||||
IBlockState getDirect(int x, int y, int z);
|
||||
BlockState getDirect(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Returns an {@link IBlockState} array of size {@link #heightY()} which contains all
|
||||
* desired block states in the specified vertical column. The index of {@link IBlockState}s
|
||||
* Returns an {@link BlockState} array of size {@link #heightY()} which contains all
|
||||
* desired block states in the specified vertical column. The index of {@link BlockState}s
|
||||
* in the array are equivalent to their Y position in the schematic.
|
||||
*
|
||||
* @param x The X column position
|
||||
* @param z The Z column position
|
||||
* @return An {@link IBlockState} array
|
||||
* @return An {@link BlockState} array
|
||||
*/
|
||||
default IBlockState[] getColumn(int x, int z) {
|
||||
IBlockState[] column = new IBlockState[this.heightY()];
|
||||
default BlockState[] getColumn(int x, int z) {
|
||||
BlockState[] column = new BlockState[this.heightY()];
|
||||
for (int i = 0; i < this.heightY(); i++) {
|
||||
column[i] = getDirect(x, i, z);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,15 +30,15 @@ public abstract class MaskSchematic extends AbstractSchematic {
|
||||
this.schematic = schematic;
|
||||
}
|
||||
|
||||
protected abstract boolean partOfMask(int x, int y, int z, IBlockState currentState);
|
||||
protected abstract boolean partOfMask(int x, int y, int z, BlockState currentState);
|
||||
|
||||
@Override
|
||||
public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
||||
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||
return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||
return schematic.desiredState(x, y, z, current, approxPlaceable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.schematic;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
public class ReplaceSchematic extends MaskSchematic {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ReplaceSchematic extends MaskSchematic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||
if (cache[x][y][z] == null) {
|
||||
cache[x][y][z] = filter.has(currentState);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
public class ShellSchematic extends MaskSchematic {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ShellSchematic extends MaskSchematic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||
return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
public class WallsSchematic extends MaskSchematic {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class WallsSchematic extends MaskSchematic {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||
return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.selection;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
/**
|
||||
* A selection is an immutable object representing the current selection. The selection is commonly used for certain
|
||||
@@ -51,7 +51,7 @@ public interface ISelection {
|
||||
/**
|
||||
* @return The size of this ISelection.
|
||||
*/
|
||||
Vec3i size();
|
||||
Vector3i size();
|
||||
|
||||
/**
|
||||
* @return An {@link AxisAlignedBB} encompassing all blocks in this selection.
|
||||
@@ -65,7 +65,7 @@ public interface ISelection {
|
||||
* @param blocks How many blocks to expand it.
|
||||
* @return A new selection, expanded as specified.
|
||||
*/
|
||||
ISelection expand(EnumFacing direction, int blocks);
|
||||
ISelection expand(Direction direction, int blocks);
|
||||
|
||||
/**
|
||||
* Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
|
||||
@@ -77,7 +77,7 @@ public interface ISelection {
|
||||
* @param blocks How many blocks to contract it.
|
||||
* @return A new selection, contracted as specified.
|
||||
*/
|
||||
ISelection contract(EnumFacing direction, int blocks);
|
||||
ISelection contract(Direction direction, int blocks);
|
||||
|
||||
/**
|
||||
* Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves
|
||||
@@ -87,5 +87,5 @@ public interface ISelection {
|
||||
* @param blocks How many blocks to shift it.
|
||||
* @return A new selection, shifted as specified.
|
||||
*/
|
||||
ISelection shift(EnumFacing direction, int blocks);
|
||||
ISelection shift(Direction direction, int blocks);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.selection;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving
|
||||
@@ -87,7 +87,7 @@ public interface ISelectionManager {
|
||||
* @param blocks How many blocks to expand it.
|
||||
* @return The new selection, expanded as specified.
|
||||
*/
|
||||
ISelection expand(ISelection selection, EnumFacing direction, int blocks);
|
||||
ISelection expand(ISelection selection, Direction direction, int blocks);
|
||||
|
||||
/**
|
||||
* Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
|
||||
@@ -101,7 +101,7 @@ public interface ISelectionManager {
|
||||
* @param blocks How many blocks to contract it.
|
||||
* @return The new selection, contracted as specified.
|
||||
*/
|
||||
ISelection contract(ISelection selection, EnumFacing direction, int blocks);
|
||||
ISelection contract(ISelection selection, Direction direction, int blocks);
|
||||
|
||||
/**
|
||||
* Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of
|
||||
@@ -112,5 +112,5 @@ public interface ISelectionManager {
|
||||
* @param blocks How many blocks to shift it.
|
||||
* @return The new selection, shifted as specified.
|
||||
*/
|
||||
ISelection shift(ISelection selection, EnumFacing direction, int blocks);
|
||||
ISelection shift(ISelection selection, Direction direction, int blocks);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -120,10 +120,10 @@ public final class BetterBlockPos extends BlockPos {
|
||||
// this is unimaginably faster than blockpos.up
|
||||
// that literally calls
|
||||
// this.up(1)
|
||||
// which calls this.offset(EnumFacing.UP, 1)
|
||||
// which calls this.offset(Direction.UP, 1)
|
||||
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
|
||||
|
||||
// how many function calls is that? up(), up(int), offset(EnumFacing, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
||||
// how many function calls is that? up(), up(int), offset(Direction, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
||||
// that's ten.
|
||||
// this is one function call.
|
||||
return new BetterBlockPos(x, y + 1, z);
|
||||
@@ -148,17 +148,17 @@ public final class BetterBlockPos extends BlockPos {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos offset(EnumFacing dir) {
|
||||
Vec3i vec = dir.getDirectionVec();
|
||||
public BetterBlockPos offset(Direction dir) {
|
||||
Vector3i vec = dir.getDirectionVec();
|
||||
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BetterBlockPos offset(EnumFacing dir, int dist) {
|
||||
public BetterBlockPos offset(Direction dir, int dist) {
|
||||
if (dist == 0) {
|
||||
return this;
|
||||
}
|
||||
Vec3i vec = dir.getDirectionVec();
|
||||
Vector3i vec = dir.getDirectionVec();
|
||||
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,21 @@ package baritone.api.utils;
|
||||
|
||||
import baritone.api.utils.accessor.IItemStack;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.properties.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.loot.*;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -38,10 +41,13 @@ import java.util.regex.Pattern;
|
||||
public final class BlockOptionalMeta {
|
||||
|
||||
private final Block block;
|
||||
private final Set<IBlockState> blockstates;
|
||||
private final Set<BlockState> blockstates;
|
||||
private final ImmutableSet<Integer> stateHashes;
|
||||
private final ImmutableSet<Integer> stackHashes;
|
||||
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||
private static LootTableManager manager;
|
||||
private static LootPredicateManager predicate = new LootPredicateManager();
|
||||
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||
|
||||
public BlockOptionalMeta(@Nonnull Block block) {
|
||||
this.block = block;
|
||||
@@ -59,38 +65,32 @@ public final class BlockOptionalMeta {
|
||||
|
||||
MatchResult matchResult = matcher.toMatchResult();
|
||||
|
||||
ResourceLocation id = new ResourceLocation(matchResult.group(1));
|
||||
|
||||
if (!IRegistry.BLOCK.containsKey(id)) {
|
||||
throw new IllegalArgumentException("Invalid block ID");
|
||||
}
|
||||
|
||||
block = IRegistry.BLOCK.get(id);
|
||||
block = BlockUtils.stringToBlockRequired(matchResult.group(1));
|
||||
blockstates = getStates(block);
|
||||
stateHashes = getStateHashes(blockstates);
|
||||
stackHashes = getStackHashes(blockstates);
|
||||
}
|
||||
|
||||
private static Set<IBlockState> getStates(@Nonnull Block block) {
|
||||
private static Set<BlockState> getStates(@Nonnull Block block) {
|
||||
return new HashSet<>(block.getStateContainer().getValidStates());
|
||||
}
|
||||
|
||||
private static ImmutableSet<Integer> getStateHashes(Set<IBlockState> blockstates) {
|
||||
private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
|
||||
return ImmutableSet.copyOf(
|
||||
blockstates.stream()
|
||||
.map(IBlockState::hashCode)
|
||||
.map(BlockState::hashCode)
|
||||
.toArray(Integer[]::new)
|
||||
);
|
||||
}
|
||||
|
||||
private static ImmutableSet<Integer> getStackHashes(Set<IBlockState> blockstates) {
|
||||
private static ImmutableSet<Integer> getStackHashes(Set<BlockState> blockstates) {
|
||||
//noinspection ConstantConditions
|
||||
return ImmutableSet.copyOf(
|
||||
blockstates.stream()
|
||||
.map(state -> new ItemStack(
|
||||
state.getBlock().getItemDropped(state, null, null, 0).asItem(),
|
||||
1
|
||||
))
|
||||
.flatMap(state -> drops(state.getBlock())
|
||||
.stream()
|
||||
.map(item -> new ItemStack(item, 1))
|
||||
)
|
||||
.map(stack -> ((IItemStack) (Object) stack).getBaritoneHash())
|
||||
.toArray(Integer[]::new)
|
||||
);
|
||||
@@ -104,7 +104,7 @@ public final class BlockOptionalMeta {
|
||||
return block == this.block;
|
||||
}
|
||||
|
||||
public boolean matches(@Nonnull IBlockState blockstate) {
|
||||
public boolean matches(@Nonnull BlockState blockstate) {
|
||||
Block block = blockstate.getBlock();
|
||||
return block == this.block && stateHashes.contains(blockstate.hashCode());
|
||||
}
|
||||
@@ -123,11 +123,56 @@ public final class BlockOptionalMeta {
|
||||
return String.format("BlockOptionalMeta{block=%s}", block);
|
||||
}
|
||||
|
||||
public IBlockState getAnyBlockState() {
|
||||
public BlockState getAnyBlockState() {
|
||||
if (blockstates.size() > 0) {
|
||||
return blockstates.iterator().next();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LootTableManager getManager() {
|
||||
if (manager == null) {
|
||||
ResourcePackList rpl = new ResourcePackList(ResourcePackInfo::new, new ServerPackFinder());
|
||||
rpl.reloadPacksFromFinders();
|
||||
IResourcePack thePack = rpl.getAllPacks().iterator().next().getResourcePack();
|
||||
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
|
||||
manager = new LootTableManager(predicate);
|
||||
resourceManager.addReloadListener(manager);
|
||||
try {
|
||||
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static LootPredicateManager getPredicateManager() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
private static synchronized List<Item> drops(Block b) {
|
||||
return drops.computeIfAbsent(b, block -> {
|
||||
ResourceLocation lootTableLocation = block.getLootTable();
|
||||
if (lootTableLocation == LootTables.EMPTY) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
|
||||
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
|
||||
getManager().getLootTableFromLocation(lootTableLocation).generate(
|
||||
new LootContext.Builder(null)
|
||||
.withRandom(new Random())
|
||||
.withParameter(LootParameters.field_237457_g_, Vector3d.copy(BlockPos.NULL_VECTOR))
|
||||
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
|
||||
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
|
||||
.withParameter(LootParameters.BLOCK_STATE, block.getDefaultState())
|
||||
.build(LootParameterSets.BLOCK),
|
||||
stack -> items.add(stack.getItem())
|
||||
);
|
||||
return items;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -61,7 +61,7 @@ public class BlockOptionalMetaLookup {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean has(IBlockState state) {
|
||||
public boolean has(BlockState state) {
|
||||
for (BlockOptionalMeta bom : boms) {
|
||||
if (bom.matches(state)) {
|
||||
return true;
|
||||
|
||||
@@ -19,7 +19,7 @@ package baritone.api.utils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -29,7 +29,7 @@ public class BlockUtils {
|
||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||
|
||||
public static String blockToString(Block block) {
|
||||
ResourceLocation loc = IRegistry.BLOCK.getKey(block);
|
||||
ResourceLocation loc = Registry.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?
|
||||
@@ -57,7 +57,7 @@ public class BlockUtils {
|
||||
if (resourceCache.containsKey(name)) {
|
||||
return null; // cached as null
|
||||
}
|
||||
block = IRegistry.BLOCK.get(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name));
|
||||
block = Registry.BLOCK.getOptional(ResourceLocation.tryCreate(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;
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -47,19 +50,50 @@ public interface Helper {
|
||||
|
||||
static ITextComponent getPrefix() {
|
||||
// Inner text component
|
||||
ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE);
|
||||
final Calendar now = Calendar.getInstance();
|
||||
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
|
||||
TextComponent baritone = new StringTextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
baritone.setStyle(baritone.getStyle().setFormatting(TextFormatting.LIGHT_PURPLE));
|
||||
|
||||
// Outer brackets
|
||||
ITextComponent prefix = new TextComponentString("");
|
||||
prefix.getStyle().setColor(TextFormatting.DARK_PURPLE);
|
||||
prefix.appendText("[");
|
||||
prefix.appendSibling(baritone);
|
||||
prefix.appendText("]");
|
||||
TextComponent prefix = new StringTextComponent("");
|
||||
prefix.setStyle(baritone.getStyle().setFormatting(TextFormatting.DARK_PURPLE));
|
||||
prefix.appendString("[");
|
||||
prefix.append(baritone);
|
||||
prefix.appendString("]");
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to display as a toast popup
|
||||
*
|
||||
* @param title The title to display in the popup
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(ITextComponent title, ITextComponent message) {
|
||||
mc.execute(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to display as a toast popup
|
||||
*
|
||||
* @param title The title to display in the popup
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String title, String message) {
|
||||
logToast(new StringTextComponent(title), new StringTextComponent(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to display as a toast popup
|
||||
*
|
||||
* @param message The message to display in the popup
|
||||
*/
|
||||
default void logToast(String message) {
|
||||
logToast(Helper.getPrefix(), new StringTextComponent(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to chat only if chatDebug is on
|
||||
*
|
||||
@@ -71,7 +105,27 @@ public interface Helper {
|
||||
//System.out.println(message);
|
||||
return;
|
||||
}
|
||||
logDirect(message);
|
||||
// We won't log debug chat into toasts
|
||||
// Because only a madman would want that extreme spam -_-
|
||||
logDirect(message, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send components to chat with the [Baritone] prefix
|
||||
*
|
||||
* @param logAsToast Whether to log as a toast notification
|
||||
* @param components The components to send
|
||||
*/
|
||||
default void logDirect(boolean logAsToast, ITextComponent... components) {
|
||||
TextComponent component = new StringTextComponent("");
|
||||
component.append(getPrefix());
|
||||
component.append(new StringTextComponent(" "));
|
||||
Arrays.asList(components).forEach(component::append);
|
||||
if (logAsToast) {
|
||||
logToast(getPrefix(), component);
|
||||
} else {
|
||||
mc.execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,11 +134,23 @@ public interface Helper {
|
||||
* @param components The components to send
|
||||
*/
|
||||
default void logDirect(ITextComponent... components) {
|
||||
ITextComponent component = new TextComponentString("");
|
||||
component.appendSibling(getPrefix());
|
||||
component.appendSibling(new TextComponentString(" "));
|
||||
Arrays.asList(components).forEach(component::appendSibling);
|
||||
mc.addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
||||
logDirect(BaritoneAPI.getSettings().logAsToast.value, components);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a
|
||||
* direct response to a chat command)
|
||||
*
|
||||
* @param message The message to display in chat
|
||||
* @param color The color to print that message in
|
||||
* @param logAsToast Whether to log as a toast notification
|
||||
*/
|
||||
default void logDirect(String message, TextFormatting color, boolean logAsToast) {
|
||||
Stream.of(message.split("\n")).forEach(line -> {
|
||||
TextComponent component = new StringTextComponent(line.replace("\t", " "));
|
||||
component.setStyle(component.getStyle().setFormatting(color));
|
||||
logDirect(logAsToast, component);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,11 +161,18 @@ public interface Helper {
|
||||
* @param color The color to print that message in
|
||||
*/
|
||||
default void logDirect(String message, TextFormatting color) {
|
||||
Stream.of(message.split("\n")).forEach(line -> {
|
||||
ITextComponent component = new TextComponentString(line.replace("\t", " "));
|
||||
component.getStyle().setColor(color);
|
||||
logDirect(component);
|
||||
});
|
||||
logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a
|
||||
* direct response to a chat command)
|
||||
*
|
||||
* @param message The message to display in chat
|
||||
* @param logAsToast Whether to log as a toast notification
|
||||
*/
|
||||
default void logDirect(String message, boolean logAsToast) {
|
||||
logDirect(message, TextFormatting.GRAY, logAsToast);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +182,6 @@ public interface Helper {
|
||||
* @param message The message to display in chat
|
||||
*/
|
||||
default void logDirect(String message) {
|
||||
logDirect(message, TextFormatting.GRAY);
|
||||
logDirect(message, BaritoneAPI.getSettings().logAsToast.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,19 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.cache.IWorldData;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -34,19 +38,28 @@ import java.util.Optional;
|
||||
*/
|
||||
public interface IPlayerContext {
|
||||
|
||||
EntityPlayerSP player();
|
||||
ClientPlayerEntity player();
|
||||
|
||||
IPlayerController playerController();
|
||||
|
||||
World world();
|
||||
|
||||
default Iterable<Entity> entities() {
|
||||
return ((ClientWorld) world()).getAllEntities();
|
||||
}
|
||||
|
||||
default Stream<Entity> entitiesStream() {
|
||||
return StreamSupport.stream(entities().spliterator(), false);
|
||||
}
|
||||
|
||||
|
||||
IWorldData worldData();
|
||||
|
||||
RayTraceResult objectMouseOver();
|
||||
|
||||
default BetterBlockPos playerFeet() {
|
||||
// TODO find a better way to deal with soul sand!!!!!
|
||||
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
BetterBlockPos feet = new BetterBlockPos(player().getPositionVec().x, player().getPositionVec().y + 0.1251, player().getPositionVec().z);
|
||||
|
||||
// sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException
|
||||
// that causes the game to immediately crash
|
||||
@@ -57,7 +70,7 @@ public interface IPlayerContext {
|
||||
// this does not impact performance at all since we're not null checking constantly
|
||||
// if there is an exception, the only overhead is Java generating the exception object... so we can ignore it
|
||||
try {
|
||||
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) {
|
||||
if (world().getBlockState(feet).getBlock() instanceof SlabBlock) {
|
||||
return feet.up();
|
||||
}
|
||||
} catch (NullPointerException ignored) {}
|
||||
@@ -65,18 +78,22 @@ public interface IPlayerContext {
|
||||
return feet;
|
||||
}
|
||||
|
||||
default Vec3d playerFeetAsVec() {
|
||||
return new Vec3d(player().posX, player().posY, player().posZ);
|
||||
default Vector3d playerFeetAsVec() {
|
||||
return new Vector3d(player().getPositionVec().x, player().getPositionVec().y, player().getPositionVec().z);
|
||||
}
|
||||
|
||||
default Vec3d playerHead() {
|
||||
return new Vec3d(player().posX, player().posY + player().getEyeHeight(), player().posZ);
|
||||
default Vector3d playerHead() {
|
||||
return new Vector3d(player().getPositionVec().x, player().getPositionVec().y + player().getEyeHeight(), player().getPositionVec().z);
|
||||
}
|
||||
|
||||
default Rotation playerRotations() {
|
||||
return new Rotation(player().rotationYaw, player().rotationPitch);
|
||||
}
|
||||
|
||||
static double eyeHeight(boolean ifSneaking) {
|
||||
return ifSneaking ? 1.27 : 1.62;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block that the crosshair is currently placed over. Updated once per tick.
|
||||
*
|
||||
@@ -84,8 +101,8 @@ public interface IPlayerContext {
|
||||
*/
|
||||
default Optional<BlockPos> getSelectedBlock() {
|
||||
RayTraceResult result = objectMouseOver();
|
||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
||||
return Optional.of(result.getBlockPos());
|
||||
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||
return Optional.of(((BlockRayTraceResult) result).getPos());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -93,17 +110,4 @@ public interface IPlayerContext {
|
||||
default boolean isLookingAt(BlockPos pos) {
|
||||
return getSelectedBlock().equals(Optional.of(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity that the crosshair is currently placed over. Updated once per tick.
|
||||
*
|
||||
* @return The entity
|
||||
*/
|
||||
default Optional<Entity> getSelectedEntity() {
|
||||
RayTraceResult result = objectMouseOver();
|
||||
if (result != null && result.type == RayTraceResult.Type.ENTITY) {
|
||||
return Optional.of(result.entity);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -40,19 +40,19 @@ public interface IPlayerController {
|
||||
|
||||
boolean hasBrokenBlock();
|
||||
|
||||
boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side);
|
||||
boolean onPlayerDamageBlock(BlockPos pos, Direction side);
|
||||
|
||||
void resetBlockRemoving();
|
||||
|
||||
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player);
|
||||
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player);
|
||||
|
||||
GameType getGameType();
|
||||
|
||||
EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand);
|
||||
ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, Hand hand, BlockRayTraceResult result);
|
||||
|
||||
EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand);
|
||||
ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand);
|
||||
|
||||
boolean clickBlock(BlockPos loc, EnumFacing face);
|
||||
boolean clickBlock(BlockPos loc, Direction face);
|
||||
|
||||
void setHittingBlock(boolean hittingBlock);
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -41,13 +41,26 @@ public final class RayTraceUtils {
|
||||
* @return The calculated raytrace result
|
||||
*/
|
||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
|
||||
Vec3d start = entity.getEyePosition(1.0F);
|
||||
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
||||
Vec3d end = start.add(
|
||||
return rayTraceTowards(entity, rotation, blockReachDistance, false);
|
||||
}
|
||||
|
||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) {
|
||||
Vector3d start;
|
||||
if (wouldSneak) {
|
||||
start = inferSneakingEyePosition(entity);
|
||||
} else {
|
||||
start = entity.getEyePosition(1.0F); // do whatever is correct
|
||||
}
|
||||
Vector3d direction = RotationUtils.calcVector3dFromRotation(rotation);
|
||||
Vector3d end = start.add(
|
||||
direction.x * blockReachDistance,
|
||||
direction.y * blockReachDistance,
|
||||
direction.z * blockReachDistance
|
||||
);
|
||||
return entity.world.rayTraceBlocks(start, end, RayTraceFluidMode.NEVER, false, true);
|
||||
return entity.world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
|
||||
}
|
||||
|
||||
public static Vector3d inferSneakingEyePosition(Entity entity) {
|
||||
return new Vector3d(entity.getPosX(), entity.getPosY() + IPlayerContext.eyeHeight(true), entity.getPosZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,18 @@ package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import net.minecraft.block.BlockFire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -52,13 +53,13 @@ public final class RotationUtils {
|
||||
/**
|
||||
* Offsets from the root block position to the center of each side.
|
||||
*/
|
||||
private static final Vec3d[] BLOCK_SIDE_MULTIPLIERS = new Vec3d[]{
|
||||
new Vec3d(0.5, 0, 0.5), // Down
|
||||
new Vec3d(0.5, 1, 0.5), // Up
|
||||
new Vec3d(0.5, 0.5, 0), // North
|
||||
new Vec3d(0.5, 0.5, 1), // South
|
||||
new Vec3d(0, 0.5, 0.5), // West
|
||||
new Vec3d(1, 0.5, 0.5) // East
|
||||
private static final Vector3d[] BLOCK_SIDE_MULTIPLIERS = new Vector3d[]{
|
||||
new Vector3d(0.5, 0, 0.5), // Down
|
||||
new Vector3d(0.5, 1, 0.5), // Up
|
||||
new Vector3d(0.5, 0.5, 0), // North
|
||||
new Vector3d(0.5, 0.5, 1), // South
|
||||
new Vector3d(0, 0.5, 0.5), // West
|
||||
new Vector3d(1, 0.5, 0.5) // East
|
||||
};
|
||||
|
||||
private RotationUtils() {}
|
||||
@@ -71,7 +72,7 @@ public final class RotationUtils {
|
||||
* @return The rotation from the origin to the destination
|
||||
*/
|
||||
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
|
||||
return calcRotationFromVec3d(new Vec3d(orig), new Vec3d(dest));
|
||||
return calcRotationFromVec3d(new Vector3d(orig.getX(), orig.getY(), orig.getZ()), new Vector3d(dest.getX(), dest.getY(), dest.getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +101,7 @@ public final class RotationUtils {
|
||||
* @return The rotation from the origin to the destination
|
||||
* @see #wrapAnglesToRelative(Rotation, Rotation)
|
||||
*/
|
||||
public static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest, Rotation current) {
|
||||
public static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest, Rotation current) {
|
||||
return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest));
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ public final class RotationUtils {
|
||||
* @param dest The destination position
|
||||
* @return The rotation from the origin to the destination
|
||||
*/
|
||||
private static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest) {
|
||||
private static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest) {
|
||||
double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z};
|
||||
double yaw = MathHelper.atan2(delta[0], -delta[2]);
|
||||
double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
|
||||
@@ -128,24 +129,28 @@ public final class RotationUtils {
|
||||
* @param rotation The input rotation
|
||||
* @return Look vector for the rotation
|
||||
*/
|
||||
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
|
||||
public static Vector3d calcVector3dFromRotation(Rotation rotation) {
|
||||
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||
return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||
return new Vector3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx Context for the viewing entity
|
||||
* @param pos The target block position
|
||||
* @return The optional rotation
|
||||
* @see #reachable(EntityPlayerSP, BlockPos, double)
|
||||
* @see #reachable(ClientPlayerEntity, BlockPos, double)
|
||||
*/
|
||||
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
|
||||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||
}
|
||||
|
||||
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, boolean wouldSneak) {
|
||||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance(), wouldSneak);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified entity is able to reach the center of any of the sides
|
||||
* of the specified block. It first checks if the block center is reachable, and if so,
|
||||
@@ -158,7 +163,11 @@ public final class RotationUtils {
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) {
|
||||
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance) {
|
||||
return reachable(entity, pos, blockReachDistance, false);
|
||||
}
|
||||
|
||||
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
|
||||
if (baritone.getPlayerContext().isLookingAt(pos)) {
|
||||
/*
|
||||
@@ -171,24 +180,33 @@ public final class RotationUtils {
|
||||
*
|
||||
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
|
||||
*/
|
||||
return Optional.of(new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F));
|
||||
Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F);
|
||||
if (wouldSneak) {
|
||||
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
|
||||
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(pos)) {
|
||||
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
|
||||
}
|
||||
} else {
|
||||
return Optional.of(hypothetical);
|
||||
}
|
||||
}
|
||||
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance);
|
||||
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance, wouldSneak);
|
||||
//System.out.println("center: " + possibleRotation);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
}
|
||||
|
||||
IBlockState state = entity.world.getBlockState(pos);
|
||||
BlockState state = entity.world.getBlockState(pos);
|
||||
VoxelShape shape = state.getShape(entity.world, pos);
|
||||
if (shape.isEmpty()) {
|
||||
shape = VoxelShapes.fullCube();
|
||||
}
|
||||
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
||||
double xDiff = shape.getStart(EnumFacing.Axis.X) * sideOffset.x + shape.getEnd(EnumFacing.Axis.X) * (1 - sideOffset.x);
|
||||
double yDiff = shape.getStart(EnumFacing.Axis.Y) * sideOffset.y + shape.getEnd(EnumFacing.Axis.Y) * (1 - sideOffset.y);
|
||||
double zDiff = shape.getStart(EnumFacing.Axis.Z) * sideOffset.z + shape.getEnd(EnumFacing.Axis.Z) * (1 - sideOffset.z);
|
||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
||||
for (Vector3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
||||
double xDiff = shape.getStart(Direction.Axis.X) * sideOffset.x + shape.getEnd(Direction.Axis.X) * (1 - sideOffset.x);
|
||||
double yDiff = shape.getStart(Direction.Axis.Y) * sideOffset.y + shape.getEnd(Direction.Axis.Y) * (1 - sideOffset.y);
|
||||
double zDiff = shape.getStart(Direction.Axis.Z) * sideOffset.z + shape.getEnd(Direction.Axis.Z) * (1 - sideOffset.z);
|
||||
possibleRotation = reachableOffset(entity, pos, new Vector3d(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
}
|
||||
@@ -207,15 +225,16 @@ public final class RotationUtils {
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
|
||||
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vector3d offsetPos, double blockReachDistance, boolean wouldSneak) {
|
||||
Vector3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
|
||||
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
|
||||
//System.out.println(result);
|
||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
||||
if (result.getBlockPos().equals(pos)) {
|
||||
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
|
||||
if (((BlockRayTraceResult) result).getPos().equals(pos)) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
if (entity.world.getBlockState(pos).getBlock() instanceof BlockFire && result.getBlockPos().equals(pos.down())) {
|
||||
if (entity.world.getBlockState(pos).getBlock() instanceof FireBlock && ((BlockRayTraceResult) result).getPos().equals(pos.down())) {
|
||||
return Optional.of(rotation);
|
||||
}
|
||||
}
|
||||
@@ -231,7 +250,7 @@ public final class RotationUtils {
|
||||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance);
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import baritone.api.Settings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.BufferedReader;
|
||||
@@ -218,15 +218,15 @@ public class SettingsUtil {
|
||||
FLOAT(Float.class, Float::parseFloat),
|
||||
LONG(Long.class, Long::parseLong),
|
||||
STRING(String.class, String::new),
|
||||
ENUMFACING(EnumFacing.class, EnumFacing::byName),
|
||||
DIRECTION(Direction.class, Direction::byName),
|
||||
COLOR(
|
||||
Color.class,
|
||||
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||
),
|
||||
VEC3I(
|
||||
Vec3i.class,
|
||||
str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||
Vector3i.class,
|
||||
str -> new Vector3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||
vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ()
|
||||
),
|
||||
BLOCK(
|
||||
@@ -236,8 +236,8 @@ public class SettingsUtil {
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> IRegistry.ITEM.get(new ResourceLocation(str.trim())),
|
||||
item -> IRegistry.ITEM.getKey(item).toString()
|
||||
str -> Registry.ITEM.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> Registry.ITEM.getKey(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
@Override
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
import net.minecraft.block.BlockFire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@@ -42,22 +42,22 @@ public final class VecUtils {
|
||||
* @return The center of the block's bounding box
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
||||
IBlockState b = world.getBlockState(pos);
|
||||
public static Vector3d calculateBlockCenter(World world, BlockPos pos) {
|
||||
BlockState b = world.getBlockState(pos);
|
||||
VoxelShape shape = b.getCollisionShape(world, pos);
|
||||
if (shape.isEmpty()) {
|
||||
return getBlockPosCenter(pos);
|
||||
}
|
||||
double xDiff = (shape.getStart(EnumFacing.Axis.X) + shape.getEnd(EnumFacing.Axis.X)) / 2;
|
||||
double yDiff = (shape.getStart(EnumFacing.Axis.Y) + shape.getEnd(EnumFacing.Axis.Y)) / 2;
|
||||
double zDiff = (shape.getStart(EnumFacing.Axis.Z) + shape.getEnd(EnumFacing.Axis.Z)) / 2;
|
||||
double xDiff = (shape.getStart(Direction.Axis.X) + shape.getEnd(Direction.Axis.X)) / 2;
|
||||
double yDiff = (shape.getStart(Direction.Axis.Y) + shape.getEnd(Direction.Axis.Y)) / 2;
|
||||
double zDiff = (shape.getStart(Direction.Axis.Z) + shape.getEnd(Direction.Axis.Z)) / 2;
|
||||
if (Double.isNaN(xDiff) || Double.isNaN(yDiff) || Double.isNaN(zDiff)) {
|
||||
throw new IllegalStateException(b + " " + pos + " " + shape);
|
||||
}
|
||||
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
|
||||
if (b.getBlock() instanceof FireBlock) {//look at bottom of fire when putting it out
|
||||
yDiff = 0;
|
||||
}
|
||||
return new Vec3d(
|
||||
return new Vector3d(
|
||||
pos.getX() + xDiff,
|
||||
pos.getY() + yDiff,
|
||||
pos.getZ() + zDiff
|
||||
@@ -74,8 +74,8 @@ public final class VecUtils {
|
||||
* @return The assumed center of the position
|
||||
* @see #calculateBlockCenter(World, BlockPos)
|
||||
*/
|
||||
public static Vec3d getBlockPosCenter(BlockPos pos) {
|
||||
return new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
public static Vector3d getBlockPosCenter(BlockPos pos) {
|
||||
return new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ public final class VecUtils {
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
|
||||
return distanceToCenter(pos, entity.posX, entity.posY, entity.posZ);
|
||||
return distanceToCenter(pos, entity.getPositionVec().x, entity.getPositionVec().y, entity.getPositionVec().z);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,6 +118,6 @@ public final class VecUtils {
|
||||
* @see #getBlockPosCenter(BlockPos)
|
||||
*/
|
||||
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
|
||||
return distanceToCenter(pos, entity.posX, pos.getY() + 0.5, entity.posZ);
|
||||
return distanceToCenter(pos, entity.getPositionVec().x, pos.getY() + 0.5, entity.getPositionVec().z);
|
||||
}
|
||||
}
|
||||
|
||||
75
src/api/java/baritone/api/utils/gui/BaritoneToast.java
Normal file
75
src/api/java/baritone/api/utils/gui/BaritoneToast.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.gui.toasts.IToast;
|
||||
import net.minecraft.client.gui.toasts.ToastGui;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class BaritoneToast implements IToast {
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private long firstDrawTime;
|
||||
private boolean newDisplay;
|
||||
private long totalShowTime;
|
||||
|
||||
public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) {
|
||||
this.title = titleComponent.getString();
|
||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
|
||||
this.totalShowTime = totalShowTime;
|
||||
}
|
||||
|
||||
public Visibility func_230444_a_(MatrixStack matrixStack, ToastGui toastGui, long delta) {
|
||||
if (this.newDisplay) {
|
||||
this.firstDrawTime = delta;
|
||||
this.newDisplay = false;
|
||||
}
|
||||
|
||||
toastGui.getMinecraft().getTextureManager().bindTexture(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);
|
||||
|
||||
if (this.subtitle == null) {
|
||||
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.title, 18, 12, -11534256);
|
||||
} else {
|
||||
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.title, 18, 7, -11534256);
|
||||
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.subtitle, 18, 18, -16777216);
|
||||
}
|
||||
|
||||
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
|
||||
}
|
||||
|
||||
public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) {
|
||||
this.title = titleComponent.getString();
|
||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
|
||||
this.newDisplay = true;
|
||||
}
|
||||
|
||||
public static void addOrUpdate(ToastGui toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) {
|
||||
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
|
||||
|
||||
if (baritonetoast == null) {
|
||||
toast.add(new BaritoneToast(title, subtitle, totalShowTime));
|
||||
} else {
|
||||
baritonetoast.setDisplayedText(title, subtitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/launch/java/baritone/launch/BaritoneMixinConnector.java
Normal file
29
src/launch/java/baritone/launch/BaritoneMixinConnector.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
import org.spongepowered.asm.mixin.connect.IMixinConnector;
|
||||
|
||||
public class BaritoneMixinConnector implements IMixinConnector {
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
Mixins.addConfiguration("mixins.baritone.json");
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IBitArray;
|
||||
import net.minecraft.util.BitArray;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(BitArray.class)
|
||||
public abstract class MixinBitArray implements IBitArray {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private long[] longArray;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private int bitsPerEntry;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private long maxEntryValue;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private int arraySize;
|
||||
|
||||
@Override
|
||||
@Unique
|
||||
public int[] toArray() {
|
||||
int[] out = new int[arraySize];
|
||||
|
||||
for (int idx = 0, kl = bitsPerEntry - 1; idx < arraySize; idx++, kl += bitsPerEntry) {
|
||||
final int i = idx * bitsPerEntry;
|
||||
final int j = i >> 6;
|
||||
final int l = i & 63;
|
||||
final int k = kl >> 6;
|
||||
final long jl = longArray[j] >>> l;
|
||||
|
||||
if (j == k) {
|
||||
out[idx] = (int) (jl & maxEntryValue);
|
||||
} else {
|
||||
out[idx] = (int) ((jl | longArray[k] << (64 - l)) & maxEntryValue);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IBitArray;
|
||||
import baritone.utils.accessor.IBlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BitArray;
|
||||
import net.minecraft.world.chunk.BlockStateContainer;
|
||||
import net.minecraft.world.chunk.IBlockStatePalette;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(BlockStateContainer.class)
|
||||
public abstract class MixinBlockStateContainer implements IBlockStateContainer {
|
||||
|
||||
@Shadow
|
||||
protected BitArray storage;
|
||||
|
||||
@Shadow
|
||||
protected IBlockStatePalette<IBlockState> palette;
|
||||
|
||||
@Override
|
||||
public IBlockState getAtPalette(int index) {
|
||||
return palette.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] storageArray() {
|
||||
return ((IBitArray) storage).toArray();
|
||||
}
|
||||
}
|
||||
92
src/launch/java/baritone/launch/mixins/MixinChunkArray.java
Normal file
92
src/launch/java/baritone/launch/mixins/MixinChunkArray.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IChunkArray;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkProvider$ChunkArray")
|
||||
public abstract class MixinChunkArray implements IChunkArray {
|
||||
@Shadow
|
||||
private AtomicReferenceArray<Chunk> chunks;
|
||||
@Shadow
|
||||
private int viewDistance;
|
||||
@Shadow
|
||||
private int sideLength;
|
||||
@Shadow
|
||||
private int centerX;
|
||||
@Shadow
|
||||
private int centerZ;
|
||||
@Shadow
|
||||
private int loaded;
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean inView(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract int getIndex(int x, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract void replace(int index, Chunk chunk);
|
||||
|
||||
@Override
|
||||
public int centerX() {
|
||||
return centerX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int centerZ() {
|
||||
return centerZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int viewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AtomicReferenceArray<Chunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(IChunkArray other) {
|
||||
centerX = other.centerX();
|
||||
centerZ = other.centerZ();
|
||||
|
||||
AtomicReferenceArray<Chunk> copyingFrom = other.getChunks();
|
||||
for (int k = 0; k < copyingFrom.length(); ++k) {
|
||||
Chunk chunk = copyingFrom.get(k);
|
||||
if (chunk != null) {
|
||||
ChunkPos chunkpos = chunk.getPos();
|
||||
if (inView(chunkpos.x, chunkpos.z)) {
|
||||
int index = getIndex(chunkpos.x, chunkpos.z);
|
||||
if (chunks.get(index) != null) {
|
||||
throw new IllegalStateException("Doing this would mutate the client's REAL loaded chunks?!");
|
||||
}
|
||||
replace(index, chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IChunkProviderServer;
|
||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/4/2018
|
||||
*/
|
||||
@Mixin(ChunkProviderServer.class)
|
||||
public class MixinChunkProviderServer implements IChunkProviderServer {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private IChunkLoader chunkLoader;
|
||||
|
||||
@Override
|
||||
public IChunkLoader getChunkLoader() {
|
||||
return this.chunkLoader;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ChunkRenderContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
||||
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
||||
import static org.lwjgl.opengl.GL14.GL_CONSTANT_ALPHA;
|
||||
import static org.lwjgl.opengl.GL14.GL_ONE_MINUS_CONSTANT_ALPHA;
|
||||
|
||||
@Mixin(ChunkRenderContainer.class)
|
||||
public class MixinChunkRenderContainer {
|
||||
|
||||
@Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
|
||||
method = "preRenderChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/chunk/RenderChunk.getPosition()Lnet/minecraft/util/math/BlockPos;"
|
||||
)
|
||||
)
|
||||
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer() && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
||||
GlStateManager.blendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
return renderChunkIn.getPosition();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ChunkRenderWorker.class)
|
||||
public abstract class MixinChunkRenderWorker {
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean isChunkExisting(BlockPos pos, World worldIn);
|
||||
|
||||
@Redirect(
|
||||
method = "processTask",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z"
|
||||
)
|
||||
)
|
||||
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||
return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world);
|
||||
}
|
||||
}
|
||||
|
||||
return this.isChunkExisting(pos, world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IChunkArray;
|
||||
import baritone.utils.accessor.IClientChunkProvider;
|
||||
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mixin(ClientChunkProvider.class)
|
||||
public class MixinClientChunkProvider implements IClientChunkProvider {
|
||||
|
||||
@Shadow
|
||||
private ClientWorld world;
|
||||
|
||||
@Override
|
||||
public ClientChunkProvider createThreadSafeCopy() {
|
||||
IChunkArray arr = extractReferenceArray();
|
||||
ClientChunkProvider result = new ClientChunkProvider(world, arr.viewDistance() - 3); // -3 because its adds 3 for no reason lmao
|
||||
IChunkArray copyArr = ((IClientChunkProvider) result).extractReferenceArray();
|
||||
copyArr.copyFrom(arr);
|
||||
if (copyArr.viewDistance() != arr.viewDistance()) {
|
||||
throw new IllegalStateException(copyArr.viewDistance() + " " + arr.viewDistance());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkArray extractReferenceArray() {
|
||||
for (Field f : ClientChunkProvider.class.getDeclaredFields()) {
|
||||
if (IChunkArray.class.isAssignableFrom(f.getType())) {
|
||||
try {
|
||||
return (IChunkArray) f.get(this);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(Arrays.toString(ClientChunkProvider.class.getDeclaredFields()));
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,16 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketCombatEvent;
|
||||
import net.minecraft.network.play.server.SPacketUnloadChunk;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -34,10 +36,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* @author Brady
|
||||
* @since 8/3/2018
|
||||
*/
|
||||
@Mixin(NetHandlerPlayClient.class)
|
||||
public class MixinNetHandlerPlayClient {
|
||||
@Mixin(ClientPlayNetHandler.class)
|
||||
public class MixinClientPlayNetHandler {
|
||||
|
||||
@Inject(
|
||||
// unused lol
|
||||
/*@Inject(
|
||||
method = "handleChunkData",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
@@ -46,7 +49,8 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
@@ -57,15 +61,16 @@ public class MixinNetHandlerPlayClient {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(
|
||||
method = "handleChunkData",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
@@ -82,9 +87,10 @@ public class MixinNetHandlerPlayClient {
|
||||
method = "processChunkUnload",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) {
|
||||
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
||||
);
|
||||
@@ -96,9 +102,10 @@ public class MixinNetHandlerPlayClient {
|
||||
method = "processChunkUnload",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) {
|
||||
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
||||
);
|
||||
@@ -106,16 +113,75 @@ public class MixinNetHandlerPlayClient {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "handleBlockChange",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postHandleBlockChange(SChangeBlockPacket packetIn, CallbackInfo ci) {
|
||||
if (!Baritone.settings().repackOnAnyBlockChange.value) {
|
||||
return;
|
||||
}
|
||||
if (!CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(packetIn.getState().getBlock())) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
ChunkEvent.Type.POPULATE_FULL,
|
||||
packetIn.getPos().getX() >> 4,
|
||||
packetIn.getPos().getZ() >> 4
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "handleMultiBlockChange",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postHandleMultiBlockChange(SMultiBlockChangePacket packetIn, CallbackInfo ci) {
|
||||
if (!Baritone.settings().repackOnAnyBlockChange.value) {
|
||||
return;
|
||||
}
|
||||
ChunkPos[] chunkPos = new ChunkPos[1];
|
||||
packetIn.func_244310_a((pos, state) -> {
|
||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(state.getBlock())) {
|
||||
chunkPos[0] = new ChunkPos(pos);
|
||||
}
|
||||
});
|
||||
if (chunkPos[0] == null) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
ChunkEvent.Type.POPULATE_FULL,
|
||||
chunkPos[0].x,
|
||||
chunkPos[0].z
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "handleCombatEvent",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"
|
||||
target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/screen/Screen;)V"
|
||||
)
|
||||
)
|
||||
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
|
||||
private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onPlayerDeath();
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import baritone.api.event.events.PlayerUpdateEvent;
|
||||
import baritone.api.event.events.SprintStateEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.PlayerCapabilities;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -37,8 +37,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* @author Brady
|
||||
* @since 8/1/2018
|
||||
*/
|
||||
@Mixin(EntityPlayerSP.class)
|
||||
public class MixinEntityPlayerSP {
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class MixinClientPlayerEntity {
|
||||
|
||||
@Inject(
|
||||
method = "sendChatMessage",
|
||||
@@ -47,7 +47,7 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
private void sendChatMessage(String msg, CallbackInfo ci) {
|
||||
ChatEvent event = new ChatEvent(msg);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
@@ -61,13 +61,13 @@ public class MixinEntityPlayerSP {
|
||||
method = "tick",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/entity/EntityPlayerSP.isPassenger()Z",
|
||||
target = "net/minecraft/client/entity/player/ClientPlayerEntity.isPassenger()Z",
|
||||
shift = At.Shift.BY,
|
||||
by = -3
|
||||
)
|
||||
)
|
||||
private void onPreUpdate(CallbackInfo ci) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
|
||||
}
|
||||
@@ -77,13 +77,13 @@ public class MixinEntityPlayerSP {
|
||||
method = "tick",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/entity/EntityPlayerSP.onUpdateWalkingPlayer()V",
|
||||
target = "net/minecraft/client/entity/player/ClientPlayerEntity.onUpdateWalkingPlayer()V",
|
||||
shift = At.Shift.BY,
|
||||
by = 2
|
||||
)
|
||||
)
|
||||
private void onPostUpdate(CallbackInfo ci) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
|
||||
}
|
||||
@@ -93,11 +93,11 @@ public class MixinEntityPlayerSP {
|
||||
method = "livingTick",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/entity/player/PlayerCapabilities.allowFlying:Z"
|
||||
target = "net/minecraft/entity/player/PlayerAbilities.allowFlying:Z"
|
||||
)
|
||||
)
|
||||
private boolean isAllowFlying(PlayerCapabilities capabilities) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
private boolean isAllowFlying(PlayerAbilities capabilities) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone == null) {
|
||||
return capabilities.allowFlying;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private boolean isKeyDown(KeyBinding keyBinding) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone == null) {
|
||||
return keyBinding.isKeyDown();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class MixinEntityPlayerSP {
|
||||
)
|
||||
)
|
||||
private void updateRidden(CallbackInfo cb) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone != null) {
|
||||
((LookBehavior) baritone.getLookBehavior()).pig();
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import baritone.api.event.events.TabCompleteEvent;
|
||||
import com.mojang.brigadier.context.StringRange;
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import net.minecraft.client.gui.GuiChat;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.CommandSuggestionHelper;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -40,21 +40,22 @@ import java.util.stream.Stream;
|
||||
* @author Brady
|
||||
* @since 10/9/2019
|
||||
*/
|
||||
@Mixin(GuiChat.class)
|
||||
public class MixinGuiChat {
|
||||
|
||||
@Shadow
|
||||
protected GuiTextField inputField;
|
||||
@Mixin(CommandSuggestionHelper.class)
|
||||
public class MixinCommandSuggestionHelper {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected List<String> commandUsage;
|
||||
private TextFieldWidget inputField;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<Suggestions> pendingSuggestions;
|
||||
@Final
|
||||
private List<String> exceptionList;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<Suggestions> suggestionsFuture;
|
||||
|
||||
@Inject(
|
||||
method = "updateSuggestion",
|
||||
method = "init",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
@@ -74,10 +75,10 @@ public class MixinGuiChat {
|
||||
ci.cancel();
|
||||
|
||||
// TODO: Support populating the command usage
|
||||
this.commandUsage.clear();
|
||||
this.exceptionList.clear();
|
||||
|
||||
if (event.completions.length == 0) {
|
||||
this.pendingSuggestions = Suggestions.empty();
|
||||
this.suggestionsFuture = Suggestions.empty();
|
||||
} else {
|
||||
int offset = this.inputField.getText().endsWith(" ")
|
||||
? this.inputField.getCursorPosition()
|
||||
@@ -91,8 +92,8 @@ public class MixinGuiChat {
|
||||
StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)),
|
||||
suggestionList);
|
||||
|
||||
this.pendingSuggestions = new CompletableFuture<>();
|
||||
this.pendingSuggestions.complete(suggestions);
|
||||
this.suggestionsFuture = new CompletableFuture<>();
|
||||
this.suggestionsFuture.complete(suggestions);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
src/launch/java/baritone/launch/mixins/MixinEntity.java
Normal file
60
src/launch/java/baritone/launch/mixins/MixinEntity.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class MixinEntity {
|
||||
|
||||
@Shadow
|
||||
private float rotationYaw;
|
||||
|
||||
float yawRestore;
|
||||
|
||||
@Inject(
|
||||
method = "moveRelative",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void moveRelativeHead(CallbackInfo info) {
|
||||
this.yawRestore = this.rotationYaw;
|
||||
// noinspection ConstantConditions
|
||||
if (!ClientPlayerEntity.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) == null) {
|
||||
return;
|
||||
}
|
||||
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
||||
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "moveRelative",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void moveRelativeReturn(CallbackInfo info) {
|
||||
this.rotationYaw = this.yawRestore;
|
||||
}
|
||||
}
|
||||
@@ -17,27 +17,26 @@
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IAnvilChunkLoader;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import baritone.utils.accessor.IEntityRenderManager;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.io.File;
|
||||
@Mixin(EntityRendererManager.class)
|
||||
public class MixinEntityRenderManager implements IEntityRenderManager {
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/4/2018
|
||||
*/
|
||||
@Mixin(AnvilChunkLoader.class)
|
||||
public class MixinAnvilChunkLoader implements IAnvilChunkLoader {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private File chunkSaveLocation;
|
||||
|
||||
@Override
|
||||
public File getChunkSaveLocation() {
|
||||
return this.chunkSaveLocation;
|
||||
public double renderPosX() {
|
||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double renderPosY() {
|
||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double renderPosZ() {
|
||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().z;
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ package baritone.launch.mixins;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -31,21 +31,21 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static org.spongepowered.asm.lib.Opcodes.GETFIELD;
|
||||
import static org.objectweb.asm.Opcodes.GETFIELD;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/10/2018
|
||||
*/
|
||||
@Mixin(EntityLivingBase.class)
|
||||
public abstract class MixinEntityLivingBase extends Entity {
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
/**
|
||||
* Event called to override the movement direction when jumping
|
||||
*/
|
||||
private RotationMoveEvent jumpRotationEvent;
|
||||
|
||||
public MixinEntityLivingBase(EntityType<?> entityTypeIn, World worldIn) {
|
||||
public MixinLivingEntity(EntityType<?> entityTypeIn, World worldIn) {
|
||||
super(entityTypeIn, worldIn);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public abstract class MixinEntityLivingBase extends Entity {
|
||||
)
|
||||
private void preMoveRelative(CallbackInfo ci) {
|
||||
// noinspection ConstantConditions
|
||||
if (EntityPlayerSP.class.isInstance(this)) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
||||
if (ClientPlayerEntity.class.isInstance(this)) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
|
||||
if (baritone != null) {
|
||||
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
|
||||
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
|
||||
@@ -69,34 +69,15 @@ public abstract class MixinEntityLivingBase extends Entity {
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = GETFIELD,
|
||||
target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F"
|
||||
target = "net/minecraft/entity/LivingEntity.rotationYaw:F"
|
||||
)
|
||||
)
|
||||
private float overrideYaw(EntityLivingBase self) {
|
||||
if (self instanceof EntityPlayerSP && BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) != null) {
|
||||
private float overrideYaw(LivingEntity self) {
|
||||
if (self instanceof ClientPlayerEntity && BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) != null) {
|
||||
return this.jumpRotationEvent.getYaw();
|
||||
}
|
||||
return self.rotationYaw;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "travel",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/entity/EntityLivingBase.moveRelative(FFFF)V"
|
||||
)
|
||||
)
|
||||
private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) {
|
||||
// noinspection ConstantConditions
|
||||
if (!EntityPlayerSP.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this) == null) {
|
||||
moveRelative(strafe, up, forward, friction);
|
||||
return;
|
||||
}
|
||||
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
||||
float originalYaw = this.rotationYaw;
|
||||
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
||||
this.moveRelative(strafe, up, forward, friction);
|
||||
this.rotationYaw = originalYaw;
|
||||
}
|
||||
|
||||
}
|
||||
74
src/launch/java/baritone/launch/mixins/MixinLootContext.java
Normal file
74
src/launch/java/baritone/launch/mixins/MixinLootContext.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootPredicateManager;
|
||||
import net.minecraft.loot.LootTableManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(LootContext.Builder.class)
|
||||
public class MixinLootContext {
|
||||
|
||||
@Redirect(
|
||||
method = "build",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/world/server/ServerWorld.getServer()Lnet/minecraft/server/MinecraftServer;"
|
||||
)
|
||||
)
|
||||
private MinecraftServer getServer(ServerWorld world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
return world.getServer();
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "build",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/server/MinecraftServer.getLootTableManager()Lnet/minecraft/loot/LootTableManager;"
|
||||
)
|
||||
)
|
||||
private LootTableManager getLootTableManager(MinecraftServer server) {
|
||||
if (server == null) {
|
||||
return BlockOptionalMeta.getManager();
|
||||
}
|
||||
return server.getLootTableManager();
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "build",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/server/MinecraftServer.func_229736_aP_()Lnet/minecraft/loot/LootPredicateManager;"
|
||||
)
|
||||
)
|
||||
private LootPredicateManager getLootPredicateManager(MinecraftServer server) {
|
||||
if (server == null) {
|
||||
return BlockOptionalMeta.getPredicateManager();
|
||||
}
|
||||
return server.func_229736_aP_();
|
||||
}
|
||||
}
|
||||
@@ -19,27 +19,20 @@ package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.BlockInteractEvent;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.events.WorldEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.utils.BaritoneAutoTest;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@@ -51,35 +44,25 @@ import java.util.function.BiFunction;
|
||||
public class MixinMinecraft {
|
||||
|
||||
@Shadow
|
||||
public EntityPlayerSP player;
|
||||
public ClientPlayerEntity player;
|
||||
@Shadow
|
||||
public WorldClient world;
|
||||
public ClientWorld world;
|
||||
|
||||
@Inject(
|
||||
method = "init",
|
||||
method = "<init>",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postInit(CallbackInfo ci) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "init",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/Minecraft.startTimerHackThread()V"
|
||||
)
|
||||
)
|
||||
private void preInit(CallbackInfo ci) {
|
||||
BaritoneAutoTest.INSTANCE.onPreInit();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "runTick",
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;",
|
||||
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
ordinal = 5,
|
||||
shift = At.Shift.BY,
|
||||
by = -3
|
||||
@@ -100,10 +83,10 @@ public class MixinMinecraft {
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
||||
method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
||||
private void preLoadWorld(ClientWorld world, CallbackInfo ci) {
|
||||
// If we're unloading the world but one doesn't exist, ignore it
|
||||
if (this.world == null && world == null) {
|
||||
return;
|
||||
@@ -120,10 +103,10 @@ public class MixinMinecraft {
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
||||
method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
||||
private void postLoadWorld(ClientWorld world, CallbackInfo ci) {
|
||||
// still fire event for both null, as that means we've just finished exiting a world
|
||||
|
||||
// mc.world changing is only the primary baritone
|
||||
@@ -140,37 +123,32 @@ public class MixinMinecraft {
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z"
|
||||
target = "net/minecraft/client/gui/screen/Screen.passEvents:Z"
|
||||
)
|
||||
)
|
||||
private boolean isAllowUserInput(GuiScreen screen) {
|
||||
private boolean passEvents(Screen screen) {
|
||||
// allow user input is only the primary baritone
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput;
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "clickMouse",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z"
|
||||
),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
|
||||
// clickMouse is only for the main player
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.START_BREAK));
|
||||
}
|
||||
|
||||
@Inject(
|
||||
// TODO
|
||||
// FIXME
|
||||
// bradyfix
|
||||
// i cant mixin
|
||||
// lol
|
||||
// https://discordapp.com/channels/208753003996512258/503692253881958400/674760939681349652
|
||||
// https://discordapp.com/channels/208753003996512258/503692253881958400/674756457966862376
|
||||
/*@Inject(
|
||||
method = "rightClickMouse",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V"
|
||||
target = "net/minecraft/client/entity/player/ClientPlayerEntity.swingArm(Lnet/minecraft/util/Hand;)V",
|
||||
ordinal = 1
|
||||
),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) {
|
||||
private void onBlockUse(CallbackInfo ci, Hand var1[], int var2, int var3, Hand enumhand, ItemStack itemstack, EntityRayTraceResult rt, Entity ent, ActionResultType art, BlockRayTraceResult raytrace, int i, ActionResultType enumactionresult) {
|
||||
// rightClickMouse is only for the main player
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
|
||||
}
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(raytrace.getPos(), BlockInteractEvent.Type.USE));
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketDirection;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -47,14 +47,14 @@ public class MixinNetworkManager {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private EnumPacketDirection direction;
|
||||
private PacketDirection direction;
|
||||
|
||||
@Inject(
|
||||
method = "dispatchPacket",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
private void preDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
if (this.direction != PacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class MixinNetworkManager {
|
||||
method = "dispatchPacket",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
private void postDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
||||
if (this.direction != PacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ public class MixinNetworkManager {
|
||||
method = "channelRead0",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;)V"
|
||||
target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;)V"
|
||||
)
|
||||
)
|
||||
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
private void preProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
|
||||
if (this.direction != PacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
@@ -103,8 +103,8 @@ public class MixinNetworkManager {
|
||||
method = "channelRead0",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||
if (!this.channel.isOpen() || this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||
private void postProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
|
||||
if (!this.channel.isOpen() || this.direction != PacketDirection.CLIENTBOUND) {
|
||||
return;
|
||||
}
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IPlayerControllerMP;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.multiplayer.PlayerController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP implements IPlayerControllerMP {
|
||||
@Mixin(PlayerController.class)
|
||||
public abstract class MixinPlayerController implements IPlayerControllerMP {
|
||||
|
||||
@Accessor
|
||||
@Override
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 1/29/2019
|
||||
*/
|
||||
@Mixin(RenderChunk.class)
|
||||
public class MixinRenderChunk {
|
||||
|
||||
@Redirect(
|
||||
method = "rebuildChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/chunk/RenderChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"
|
||||
)
|
||||
)
|
||||
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||
return baritone.bsi.get0(pos);
|
||||
}
|
||||
}
|
||||
|
||||
return chunkCache.getBlockState(pos);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(RenderChunkCache.class)
|
||||
public class MixinRenderChunkCache {
|
||||
|
||||
@Redirect(
|
||||
method = "generateCache",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/world/chunk/Chunk.isEmptyBetween(II)Z"
|
||||
)
|
||||
)
|
||||
private static boolean isEmpty(Chunk chunk, int yStart, int yEnd) {
|
||||
if (!chunk.isEmptyBetween(yStart, yEnd)) {
|
||||
return false;
|
||||
}
|
||||
if (chunk.isEmpty() && Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@Mixin(RenderList.class)
|
||||
public class MixinRenderList {
|
||||
|
||||
@Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
|
||||
method = "renderChunkLayer",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
|
||||
)
|
||||
)
|
||||
private void popMatrix() {
|
||||
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||
// reset the blend func to normal (not dependent on constant alpha)
|
||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user