Compare commits
280 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3e12d299f | |||
| 3556a22818 | |||
| 9abc34ca4c | |||
| f561ff84fa | |||
| cd9f7637b4 | |||
| c9b57e8052 | |||
| cf43a410c3 | |||
| 00658dcaba | |||
| 9624e343af | |||
| eb78a1f49b | |||
| b056f18444 | |||
| a3f42e2292 | |||
| ce55cc56c1 | |||
| 7db973017a | |||
| 6b810c570b | |||
| 353f2c7d9f | |||
| 5a82b2b322 | |||
| 1b1670427b | |||
| c165070c5e | |||
| 35710103cd | |||
| 3e606e83b5 | |||
| 09f0eca7cb | |||
| c94ac6e26c | |||
| 9d3392c25c | |||
| 50ea3d7b93 | |||
| 17591736c4 | |||
| bb5b1a7a91 | |||
| 7632f0184c | |||
| 0a451dc15e | |||
| 56717b83a8 | |||
| cd379c1852 | |||
| a74c1531db | |||
| 67f0a3d73f | |||
| 780d967d41 | |||
| 61cf103df4 | |||
| 80a734141c | |||
| 40bea503c3 | |||
| 0f7743263e | |||
| 1b74c8c8be | |||
| 8c397d1454 | |||
| b9cba93d33 | |||
| 34e5811613 | |||
| ce39183482 | |||
| 529f8dae47 | |||
| b575f54977 | |||
| 6ec6ff4596 | |||
| 30b63abb73 | |||
| 2a8575caa8 | |||
| 6829bc920e | |||
| 8ee7446517 | |||
| 559f575db5 | |||
| 750da2f1a6 | |||
| 7d27509e63 | |||
| 76f287582e | |||
| 239a95961e | |||
| 3e189510d4 | |||
| cef4fb0f50 | |||
| da3f5251b5 | |||
| fc591eafd3 | |||
| 5087e65c61 | |||
| 1553f99129 | |||
| 2c4384970c | |||
| 65672b5564 | |||
| 758e9c511a | |||
| 812c23e1ca | |||
| 9e27a59d7f | |||
| 787665ae08 | |||
| 35c8b03122 | |||
| 1cf4c9419f | |||
| 111e03c5b8 | |||
| 0ed6bc966e | |||
| ba7e9a56e3 | |||
| df88b02ed5 | |||
| d6c2c053db | |||
| 5650c86a7d | |||
| 4ec9a4fc5b | |||
| 7b0f14a0e5 | |||
| c3a21b928e | |||
| 89ad673ae3 | |||
| fa7a0b3c45 | |||
| 23e1ea0020 | |||
| 5edd4e06bb | |||
| aa6bdd7f33 | |||
| 4d5446ddbd | |||
| e3b777d2ef | |||
| eeea07ed2b | |||
| 4ac2ade7c6 | |||
| 62b8bc0f47 | |||
| 7edf581c6a | |||
| e99fc5d9b7 | |||
| a6aa659629 | |||
| 182c1e6ff5 | |||
| 6770985b3a | |||
| 943794726a | |||
| 59b4e1a993 | |||
| a05d3269a3 | |||
| 5ca5fdf777 | |||
| 53590a96b9 | |||
| 1a6b7d184a | |||
| c623250387 | |||
| 289637a370 | |||
| b20f148fa6 | |||
| cc01c88dbd | |||
| 23c11a5170 | |||
| 7fa6e001e6 | |||
| 65a59cb739 | |||
| b2cbce28b3 | |||
| 0d0eefec9c | |||
| 1b576eca28 | |||
| 2d3cdddc51 | |||
| 3c4708fef7 | |||
| eaa44c90f3 | |||
| e33564f1eb | |||
| 7888dd24e5 | |||
| f07c02ff41 | |||
| c64785f0ce | |||
| d471bfa948 | |||
| c508fb2cb7 | |||
| 15fa12fe08 | |||
| e16bc5eca4 | |||
| 8b307f296a | |||
| 9661ab3b42 | |||
| ae59e94a6c | |||
| 21568f593a | |||
| 2cac115211 | |||
| 4513a537db | |||
| e3434115ac | |||
| ddf7b3739a | |||
| 1c2e47c39a | |||
| 0575e2d667 | |||
| 37f00f3e14 | |||
| d0fd370d53 | |||
| 454bc9c628 | |||
| 5bd4dcadf8 | |||
| 01b88caa93 | |||
| 8a03428635 | |||
| d3c194c746 | |||
| 28a8e7ea63 | |||
| d4f1a127d7 | |||
| ecd8da553b | |||
| caccc3001e | |||
| 139d05d93f | |||
| 2e63ac41d9 | |||
| 1790534421 | |||
| 2375f1a408 | |||
| ef55d86913 | |||
| 28ebf065ee | |||
| b47b813462 | |||
| f13bcbd49f | |||
| dc5514b5b7 | |||
| 66e6216b71 | |||
| 63a1083e19 | |||
| 6b61a00bed | |||
| bfdf8d6c87 | |||
| 71952410eb | |||
| 42e179c4ce | |||
| e981bfa346 | |||
| 043dd80e28 | |||
| b3654492be | |||
| 583a5046ef | |||
| d2be54f138 | |||
| f36b11016e | |||
| a589cb0d9e | |||
| 74dc8d4118 | |||
| 0b640199ef | |||
| 3011b85aee | |||
| f25f264fd3 | |||
| 71473ab17d | |||
| eac5184d4d | |||
| 5f0009a060 | |||
| b4ddd98bcb | |||
| aa2caf63d3 | |||
| bc82276e62 | |||
| b7cc707737 | |||
| 543c0d0a33 | |||
| af58304b38 | |||
| e75d0ff102 | |||
| dbd1fb2aa2 | |||
| fb7d729b11 | |||
| 51f1cadbb8 | |||
| 7fd0d2d038 | |||
| a92465a5f9 | |||
| 8dac838fe0 | |||
| 23779329a9 | |||
| 3f15451e88 | |||
| 0ce68ee21f | |||
| 30fc72a34c | |||
| 5492dc59e2 | |||
| 9937739518 | |||
| eca41a046a | |||
| e54ea6c571 | |||
| 43cf2062bc | |||
| 27b9324cf1 | |||
| a978ddec08 | |||
| b5a512963d | |||
| 67c5a9caa0 | |||
| 20ecab7d53 | |||
| 0b30e822c2 | |||
| 19b47d77e5 | |||
| 9b375e1f5f | |||
| 1745ce6a62 | |||
| 5513d0669f | |||
| 12b64ead5c | |||
| 13cfb8e369 | |||
| 29391af5ad | |||
| 7d94cb259f | |||
| 1bd15e5d5b | |||
| 001070d406 | |||
| a38da64c49 | |||
| d7a646789e | |||
| 6b45b84784 | |||
| 853cbf3554 | |||
| 5f9b6683ac | |||
| 7d0914bd43 | |||
| e3830643f6 | |||
| 924cea342b | |||
| 33a0a2a7f9 | |||
| 13628789c8 | |||
| 380f21bb38 | |||
| 651bfac786 | |||
| d536d311d6 | |||
| d07eb3f486 | |||
| 530bdfae0f | |||
| 4c5c35069d | |||
| df765a14b0 | |||
| 315c1bf63c | |||
| 796be3da79 | |||
| ef396829f0 | |||
| 0a0209d2e1 | |||
| fb8ee44447 | |||
| 2fd888b9ee | |||
| a7504caa67 | |||
| 39a3c1cd4a | |||
| 7f983c92f4 | |||
| e82f6b8e35 | |||
| 5669204b4a | |||
| 3afc77bc9a | |||
| 0412298555 | |||
| 9334cf1dd4 | |||
| acd9cecd66 | |||
| 1bf34d42e2 | |||
| e6c574063e | |||
| ff2714b15f | |||
| bafc938424 | |||
| ab1037bcfd | |||
| 3dfde818d3 | |||
| 35ed0f6821 | |||
| a0a480e2cc | |||
| 9daf46e30c | |||
| a67e6fd163 | |||
| d8790e1dc6 | |||
| fb07e47141 | |||
| a59d30d11e | |||
| 72eec135d0 | |||
| 075ad3f244 | |||
| ecbb34366f | |||
| 8fa0d63ae5 | |||
| 5cbc9d2d74 | |||
| 3d63abe950 | |||
| 805b870d7d | |||
| d7cf6b1438 | |||
| 56762780e3 | |||
| 50cc05a680 | |||
| ca91d09fbf | |||
| 7333f9dc9a | |||
| 685cc4d06e | |||
| 230cca391a | |||
| 7f8747afc7 | |||
| b2aced82ee | |||
| 4363cb20f3 | |||
| 4c864a433f | |||
| c05b02484a | |||
| e456040661 | |||
| 8c03a75cb7 | |||
| 1d89370edc | |||
| 4f76607233 | |||
| 22926289fc | |||
| 581ef474ad | |||
| 8544917c34 | |||
| 3c28d07cb6 |
Generated
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<copyright>
|
<copyright>
|
||||||
<option name="notice" value="This file is part of Baritone. Baritone is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Baritone. If not, see <https://www.gnu.org/licenses/>." />
|
<option name="keyword" value="This file is part of Baritone" />
|
||||||
|
<option name="notice" value="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/>." />
|
||||||
<option name="myName" value="Baritone" />
|
<option name="myName" value="Baritone" />
|
||||||
</copyright>
|
</copyright>
|
||||||
</component>
|
</component>
|
||||||
+29
@@ -1 +1,30 @@
|
|||||||
language: java
|
language: java
|
||||||
|
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get update
|
||||||
|
- sudo apt-get install jshon
|
||||||
|
- docker build -t cabaletta/baritone .
|
||||||
|
|
||||||
|
script:
|
||||||
|
- docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; sh scripts/build.sh; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||||
|
- docker cp baritone:/code/dist dist
|
||||||
|
- ls dist
|
||||||
|
- cat dist/checksums.txt
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key:
|
||||||
|
secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s=
|
||||||
|
all_branches: true
|
||||||
|
file_glob: true
|
||||||
|
file:
|
||||||
|
- dist/*
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
repo: cabaletta/baritone
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
FROM debian:jessie
|
||||||
|
|
||||||
|
RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
|
RUN apt update -y
|
||||||
|
|
||||||
|
RUN apt install --target-release jessie-backports \
|
||||||
|
openjdk-8-jdk \
|
||||||
|
ca-certificates-java \
|
||||||
|
--assume-yes
|
||||||
|
|
||||||
|
RUN apt install -qq --force-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||||
|
|
||||||
|
RUN apt install -qq --force-yes unzip wget
|
||||||
|
|
||||||
|
ADD . /code
|
||||||
|
|
||||||
|
RUN echo "\nrunClient {\nargs \"--width\",\"128\",\"--height\",\"128\"\n}" >> /code/build.gradle
|
||||||
|
|
||||||
|
RUN dpkg -i /code/scripts/xvfb_1.16.4-1_amd64.deb
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
RUN ./gradlew build
|
||||||
@@ -1,16 +1,86 @@
|
|||||||
# Integration between Baritone and Impact
|
# Integration between Baritone and Impact
|
||||||
|
Impact 4.4 will have Baritone included on release, however, if you're impatient, you can install Baritone into Impact 4.3 right now!
|
||||||
|
|
||||||
Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now.
|
## An Introduction
|
||||||
|
There are some basic steps to getting Baritone setup with Impact.
|
||||||
|
- Acquiring a build of Baritone
|
||||||
|
- Placing Baritone in the libraries directory
|
||||||
|
- Modifying the Impact Profile JSON to run baritone
|
||||||
|
- How to use Baritone
|
||||||
|
|
||||||
You can either build Baritone yourself, or download the jar from September 4 from <a href="https://www.dropbox.com/s/imc6xwwpwsh3i0y/baritone-1.0.0.jar?dl=0">here</a>
|
## Acquiring a build of Baritone
|
||||||
|
There are 3 methods of acquiring a build of Baritone (While it is still in development)
|
||||||
|
|
||||||
To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu.
|
### Official Build (Not always up to date)
|
||||||
|
Download the "official" jar (as of commit <a href="https://github.com/cabaletta/baritone/commit/61cf103df451a5aafa6bfbe5ed089043212f0b42">61cf103</a>,
|
||||||
|
built on September 24) from <a href="https://www.dropbox.com/s/imc6xwwpwsh3i0y/baritone-1.0.0.jar?dl=0">here</a>.
|
||||||
|
|
||||||
Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0.0` in libraries first.
|
### Building Baritone yourself
|
||||||
|
There are a few steps to this
|
||||||
|
- Clone this repository
|
||||||
|
- Setup the project as instructed in the README
|
||||||
|
- Run the ``build`` gradle task. You can either do this using IntelliJ's gradle UI or through a
|
||||||
|
command line
|
||||||
|
- Windows: ``gradlew build``
|
||||||
|
- Mac/Linux: ``./gradlew build``
|
||||||
|
- The build should be exported into ``/build/libs/baritone-X.Y.Z.jar``
|
||||||
|
|
||||||
Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json` or copy your existing installation and rename the version folder, json, and id in the json.
|
### Cutting Edge Release
|
||||||
|
If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit
|
||||||
|
from his Jenkins server, found <a href="https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/">here</a>.
|
||||||
|
|
||||||
- Add the Baritone tweak class to line 7 "minecraftArguments" like so: `"minecraftArguments": " ... --tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine",`. You need the Optifine tweaker even though there is no Optifine involved, for reasons I don't quite understand.
|
## Placing Baritone in the libraries directory
|
||||||
- Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0.0" },` between Impact and ClientAPI, which should be between lines 15 and 16.
|
``/libraries`` is a neat directory in your <a href="https://minecraft.gamepedia.com/.minecraft">Minecraft Installation Directory</a>
|
||||||
|
that contains all of the dependencies that are required from the game and some mods. This is where we will be
|
||||||
|
putting baritone.
|
||||||
|
- Locate the ``libraries`` folder, it should be in the Minecraft Installation Directory
|
||||||
|
- Create 3 new subdirectories starting from ``libraries``
|
||||||
|
- ``cabaletta``
|
||||||
|
- ``baritone``
|
||||||
|
- ``X.Y.Z``
|
||||||
|
- Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder
|
||||||
|
- The full path should look like ``<Minecraft>/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar``
|
||||||
|
|
||||||
Restart the Minecraft launcher, then load Impact 4.3 as normal, and it should now include Baritone.
|
## Modifying the Impact Profile JSON to run baritone
|
||||||
|
The final step is "registering" the Baritone library with Impact, so that it loads on launch.
|
||||||
|
- Ensure your Minecraft launcher is closed
|
||||||
|
- Navigate back to the Minecraft Installation Directory
|
||||||
|
- Find the ``versions`` directory, and open in
|
||||||
|
- In here there should be a ``1.12.2-Impact_4.3`` folder.
|
||||||
|
- If you don't have any Impact folder or have a version older than 4.3, you can download Impact <a href="https://impactdevelopment.github.io">here</a>.
|
||||||
|
- Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json``
|
||||||
|
- Open the JSON file with a text editor that supports your system's line endings
|
||||||
|
- For example, Notepad on Windows likely will NOT work for this. You should instead use a Text Editor like
|
||||||
|
<a href="https://notepad-plus-plus.org/">Notepad++</a> if you're on Windows. (For other systems, I'm not sure
|
||||||
|
what would work the best so you may have to do some research.)
|
||||||
|
- Find the ``libraries`` array in the JSON. It should look something like this.
|
||||||
|
```
|
||||||
|
"libraries": [
|
||||||
|
{
|
||||||
|
"name": "net.minecraft:launchwrapper:1.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.github.ImpactDevelopment:Impact:4.3-1.12.2",
|
||||||
|
"url": "https://impactdevelopment.github.io/maven/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.github.ImpactDeveloment:ClientAPI:3.0.2",
|
||||||
|
"url": "https://impactdevelopment.github.io/maven/"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
- Create a new object in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"name": "cabaletta:baritone:X.Y.Z"
|
||||||
|
},
|
||||||
|
```
|
||||||
|
- Now find the ``"minecraftArguments": "..."`` text near the top.
|
||||||
|
- At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like:
|
||||||
|
- ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"``
|
||||||
|
- If you didn't close your launcher for this step, restart it now.
|
||||||
|
- You can now launch Impact 4.3 as normal, and Baritone should start up
|
||||||
|
|
||||||
|
## How to use Baritone
|
||||||
|
Instructions on how to use Baritone are limited, and you may have to read a little bit of code (Really nothing much
|
||||||
|
just plain English), you can view that <a href="https://github.com/cabaletta/baritone#chat-control">here</a>.
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
||||||
-674
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program 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 General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Baritone Copyright (C) 2018 Cabaletta
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
@@ -1,14 +1,29 @@
|
|||||||
# Baritone
|
# Baritone
|
||||||
[](https://travis-ci.com/cabaletta/baritone)
|
[](https://travis-ci.com/cabaletta/baritone)
|
||||||
|
[](LICENSE)
|
||||||
|
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||||
|
|
||||||
A Minecraft bot. This project is an updated version of [Minebot](https://github.com/leijurv/MineBot/),
|
<!---
|
||||||
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2.
|
Plutie's jenkins is dead right now, so here's the old badge that was used:
|
||||||
|
[](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/)
|
||||||
|
--->
|
||||||
|
|
||||||
<a href="https://github.com/cabaletta/baritone/blob/master/FEATURES.md">Features</a>
|
Unofficial Jenkins: []()
|
||||||
|
|
||||||
<a href="https://github.com/cabaletta/baritone/blob/master/IMPACT.md">Baritone + Impact</a>
|
A Minecraft pathfinder bot. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||||
|
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||||
|
|
||||||
|
Here are some links to help to get started:
|
||||||
|
|
||||||
|
- [Features](FEATURES.md)
|
||||||
|
|
||||||
|
- [Baritone + Impact](IMPACT.md)
|
||||||
|
|
||||||
|
There's also some useful information down below
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
|
## IntelliJ's Gradle UI
|
||||||
- Open the project in IntelliJ as a Gradle project
|
- Open the project in IntelliJ as a Gradle project
|
||||||
- Run the Gradle task `setupDecompWorkspace`
|
- Run the Gradle task `setupDecompWorkspace`
|
||||||
- Run the Gradle task `genIntellijRuns`
|
- Run the Gradle task `genIntellijRuns`
|
||||||
@@ -32,26 +47,30 @@ $ gradlew genIntellijRuns
|
|||||||
```
|
```
|
||||||
|
|
||||||
# Chat control
|
# Chat control
|
||||||
<a href="https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java">Defined here</a>
|
[Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java)
|
||||||
|
|
||||||
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
||||||
|
|
||||||
# API example
|
# API example
|
||||||
|
|
||||||
```
|
```
|
||||||
Baritone.settings().allowSprint.value = true;
|
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||||
Baritone.settings().pathTimeoutMS.value = 2000L;
|
BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L;
|
||||||
|
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalXZ(10000, 20000));
|
BaritoneAPI.getPathingBehavior().setGoal(new GoalXZ(10000, 20000));
|
||||||
PathingBehavior.INSTANCE.path();
|
BaritoneAPI.getPathingBehavior().path();
|
||||||
```
|
```
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
|
||||||
## Can I use Baritone as a library in my hacked client?
|
## Can I use Baritone as a library in my hacked client?
|
||||||
|
|
||||||
Sure! (As long as usage is in compliance with the GPL 3 License)
|
Sure! (As long as usage is in compliance with the LGPL 3 License)
|
||||||
|
|
||||||
## How is it so fast?
|
## How is it so fast?
|
||||||
|
|
||||||
Magic
|
Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pain)
|
||||||
|
|
||||||
|
## Why is it called Baritone?
|
||||||
|
|
||||||
|
It's named for FitMC's deep sultry voice.
|
||||||
+5
-5
@@ -2,21 +2,21 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.0.0'
|
version '0.0.3'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -87,5 +87,5 @@ mixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from sourceSets.launch.output
|
from sourceSets.launch.output, sourceSets.api.output
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
set -e # this makes the whole script fail immediately if any one of these commands fails
|
||||||
|
./gradlew build
|
||||||
|
export VERSION=$(cat build.gradle | grep "version '" | cut -d "'" -f 2-2)
|
||||||
|
|
||||||
|
wget -nv https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip
|
||||||
|
unzip proguard6.0.3.zip 2>&1 > /dev/null
|
||||||
|
cd build/libs
|
||||||
|
echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version
|
||||||
|
cat ../../scripts/proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" >> api.pro # remove default rt jar and injar lines
|
||||||
|
echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location
|
||||||
|
tail api.pro # debug, print out what the previous two commands generated
|
||||||
|
cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api
|
||||||
|
wget -nv https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry
|
||||||
|
mv tempLibraries.zip?dl=1 tempLibraries.zip
|
||||||
|
unzip tempLibraries.zip
|
||||||
|
mkdir ../../dist
|
||||||
|
java -jar ../../proguard6.0.3/lib/proguard.jar @api.pro
|
||||||
|
mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-api-$VERSION.jar
|
||||||
|
java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro
|
||||||
|
mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar
|
||||||
|
mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar
|
||||||
|
cd ../../dist
|
||||||
|
shasum * | tee checksums.txt
|
||||||
|
cd ..
|
||||||
Vendored
+6
-7
@@ -1,29 +1,28 @@
|
|||||||
-injars baritone-1.0.0.jar
|
-injars baritone-0.0.2.jar
|
||||||
-outjars Obfuscated
|
-outjars Obfuscated
|
||||||
|
|
||||||
|
|
||||||
-keepattributes Signature
|
-keepattributes Signature
|
||||||
-keepattributes *Annotation*
|
-keepattributes *Annotation*
|
||||||
|
|
||||||
-optimizationpasses 20
|
-optimizationpasses 5
|
||||||
-verbose
|
-verbose
|
||||||
|
|
||||||
-allowaccessmodification # anything not kept can be changed from public to private and inlined etc
|
-allowaccessmodification # anything not kept can be changed from public to private and inlined etc
|
||||||
-mergeinterfacesaggressively
|
|
||||||
-overloadaggressively
|
-overloadaggressively
|
||||||
-dontusemixedcaseclassnames
|
-dontusemixedcaseclassnames
|
||||||
|
|
||||||
# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with mcp
|
# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with minecraft's obfd classes
|
||||||
-flattenpackagehierarchy
|
-flattenpackagehierarchy
|
||||||
-repackageclasses 'baritone'
|
-repackageclasses 'baritone'
|
||||||
|
|
||||||
#-keep class baritone.behavior.** { *; }
|
#-keep class baritone.behavior.** { *; }
|
||||||
#-keep class baritone.api.** { *; }
|
-keep class baritone.api.** { *; }
|
||||||
#-keep class baritone.* { *; }
|
#-keep class baritone.* { *; }
|
||||||
#-keep class baritone.pathing.goals.** { *; }
|
#-keep class baritone.pathing.goals.** { *; }
|
||||||
|
|
||||||
# setting names are reflected from field names, so keep field names
|
# setting names are reflected from field names, so keep field names
|
||||||
-keepclassmembers class baritone.Settings {
|
-keepclassmembers class baritone.api.Settings {
|
||||||
public <fields>;
|
public <fields>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@
|
|||||||
-keep class baritone.launch.** { *; }
|
-keep class baritone.launch.** { *; }
|
||||||
|
|
||||||
# copy all necessary libraries into tempLibraries to build
|
# copy all necessary libraries into tempLibraries to build
|
||||||
-libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar'
|
-libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' # this is the rt jar
|
||||||
|
|
||||||
-libraryjars 'tempLibraries/1.12.2.jar'
|
-libraryjars 'tempLibraries/1.12.2.jar'
|
||||||
|
|
||||||
Binary file not shown.
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api;
|
||||||
|
|
||||||
|
import baritone.api.behavior.*;
|
||||||
|
import baritone.api.cache.IWorldProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API exposure for various things implemented in Baritone.
|
||||||
|
* <p>
|
||||||
|
* W.I.P
|
||||||
|
*
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public class BaritoneAPI {
|
||||||
|
|
||||||
|
// General
|
||||||
|
private static final Settings settings = new Settings();
|
||||||
|
private static IWorldProvider worldProvider;
|
||||||
|
|
||||||
|
// Behaviors
|
||||||
|
private static IFollowBehavior followBehavior;
|
||||||
|
private static ILookBehavior lookBehavior;
|
||||||
|
private static IMemoryBehavior memoryBehavior;
|
||||||
|
private static IMineBehavior mineBehavior;
|
||||||
|
private static IPathingBehavior pathingBehavior;
|
||||||
|
|
||||||
|
public static IFollowBehavior getFollowBehavior() {
|
||||||
|
return followBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ILookBehavior getLookBehavior() {
|
||||||
|
return lookBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMemoryBehavior getMemoryBehavior() {
|
||||||
|
return memoryBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMineBehavior getMineBehavior() {
|
||||||
|
return mineBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IPathingBehavior getPathingBehavior() {
|
||||||
|
return pathingBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Settings getSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IWorldProvider getWorldProvider() {
|
||||||
|
return worldProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FOR INTERNAL USE ONLY
|
||||||
|
*/
|
||||||
|
public static void registerProviders(
|
||||||
|
IWorldProvider worldProvider
|
||||||
|
) {
|
||||||
|
BaritoneAPI.worldProvider = worldProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FOR INTERNAL USE ONLY
|
||||||
|
*/
|
||||||
|
// @formatter:off
|
||||||
|
public static void registerDefaultBehaviors(
|
||||||
|
IFollowBehavior followBehavior,
|
||||||
|
ILookBehavior lookBehavior,
|
||||||
|
IMemoryBehavior memoryBehavior,
|
||||||
|
IMineBehavior mineBehavior,
|
||||||
|
IPathingBehavior pathingBehavior
|
||||||
|
) {
|
||||||
|
BaritoneAPI.followBehavior = followBehavior;
|
||||||
|
BaritoneAPI.lookBehavior = lookBehavior;
|
||||||
|
BaritoneAPI.memoryBehavior = memoryBehavior;
|
||||||
|
BaritoneAPI.mineBehavior = mineBehavior;
|
||||||
|
BaritoneAPI.pathingBehavior = pathingBehavior;
|
||||||
|
}
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
@@ -2,26 +2,31 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone;
|
package baritone.api;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Baritone's settings
|
* Baritone's settings
|
||||||
@@ -29,6 +34,7 @@ import java.util.*;
|
|||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow Baritone to break blocks
|
* Allow Baritone to break blocks
|
||||||
*/
|
*/
|
||||||
@@ -62,6 +68,20 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
public Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assume step functionality; don't jump on an Ascend.
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> assumeStep = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assume safe walk functionality; don't sneak on a backplace traverse.
|
||||||
|
* <p>
|
||||||
|
* Warning: if you do something janky like sneak-backplace from an ender chest, if this is true
|
||||||
|
* it won't sneak right click, it'll just right click, which means it'll open the chest instead of placing
|
||||||
|
* against it. That's why this defaults to off.
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> assumeSafeWalk = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
||||||
*/
|
*/
|
||||||
@@ -90,6 +110,11 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public Setting<Boolean> allowParkour = new Setting<>(false);
|
public Setting<Boolean> allowParkour = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like parkour, but even more unreliable!
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> allowParkourPlace = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
|
* For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
|
||||||
*/
|
*/
|
||||||
@@ -110,7 +135,7 @@ public class Settings {
|
|||||||
* <p>
|
* <p>
|
||||||
* Finding the optimal path is worth it, so it's the default.
|
* Finding the optimal path is worth it, so it's the default.
|
||||||
*/
|
*/
|
||||||
public Setting<Double> costHeuristic = this.new <Double>Setting<Double>(3.5D);
|
public Setting<Double> costHeuristic = new Setting<>(3.5D);
|
||||||
|
|
||||||
// a bunch of obscure internal A* settings that you probably don't want to change
|
// a bunch of obscure internal A* settings that you probably don't want to change
|
||||||
/**
|
/**
|
||||||
@@ -120,8 +145,9 @@ public class Settings {
|
|||||||
public Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
|
public Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See issue #18
|
|
||||||
* Set to 1.0 to effectively disable this feature
|
* Set to 1.0 to effectively disable this feature
|
||||||
|
*
|
||||||
|
* @see <a href="https://github.com/cabaletta/baritone/issues/18">Issue #18</a>
|
||||||
*/
|
*/
|
||||||
public Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.9);
|
public Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.9);
|
||||||
|
|
||||||
@@ -131,19 +157,20 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
|
public Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
|
||||||
* Use a pythagorean metric (as opposed to the more accurate hybrid diagonal / traverse).
|
|
||||||
* You probably don't want this. It roughly triples nodes considered for no real advantage.
|
|
||||||
*/
|
|
||||||
public Setting<Boolean> pythagoreanMetric = new Setting<>(false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is
|
* After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is
|
||||||
* entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified.
|
* entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified.
|
||||||
* See issue #114 for why this is disabled.
|
*
|
||||||
|
* @see <a href="https://github.com/cabaletta/baritone/issues/144">Issue #144</a>
|
||||||
*/
|
*/
|
||||||
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
|
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a movement's cost increases by more than this amount between calculation and execution (due to changes
|
||||||
|
* in the environment / world), cancel and recalculate
|
||||||
|
*/
|
||||||
|
public Setting<Double> maxCostIncrease = new Setting<>(10D);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop 5 movements before anything that made the path COST_INF.
|
* Stop 5 movements before anything that made the path COST_INF.
|
||||||
* For example, if lava has spread across the path, don't walk right up to it then recalculate, it might
|
* For example, if lava has spread across the path, don't walk right up to it then recalculate, it might
|
||||||
@@ -203,12 +230,12 @@ public class Settings {
|
|||||||
/**
|
/**
|
||||||
* Pathing can never take longer than this
|
* Pathing can never take longer than this
|
||||||
*/
|
*/
|
||||||
public Setting<Number> pathTimeoutMS = new Setting<>(2000L);
|
public Setting<Long> pathTimeoutMS = new Setting<>(2000L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Planning ahead while executing a segment can never take longer than this
|
* Planning ahead while executing a segment can never take longer than this
|
||||||
*/
|
*/
|
||||||
public Setting<Number> planAheadTimeoutMS = new Setting<>(4000L);
|
public Setting<Long> planAheadTimeoutMS = new Setting<>(4000L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For debugging, consider nodes much much slower
|
* For debugging, consider nodes much much slower
|
||||||
@@ -218,12 +245,12 @@ public class Settings {
|
|||||||
/**
|
/**
|
||||||
* Milliseconds between each node
|
* Milliseconds between each node
|
||||||
*/
|
*/
|
||||||
public Setting<Number> slowPathTimeDelayMS = new Setting<>(100L);
|
public Setting<Long> slowPathTimeDelayMS = new Setting<>(100L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The alternative timeout number when slowPath is on
|
* The alternative timeout number when slowPath is on
|
||||||
*/
|
*/
|
||||||
public Setting<Number> slowPathTimeoutMS = new Setting<>(40000L);
|
public Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||||
@@ -295,6 +322,123 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public Setting<Boolean> prefix = new Setting<>(false);
|
public Setting<Boolean> prefix = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code true}: can mine blocks when in inventory, chat, or tabbed away in ESC menu
|
||||||
|
* <p>
|
||||||
|
* {@code false}: works on cosmic prisons
|
||||||
|
* <p>
|
||||||
|
* LOL
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> leftClickWorkaround = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't stop walking forward when you need to break blocks in your way
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> walkWhileBreaking = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rescan for the goal once every 5 ticks.
|
||||||
|
* Set to 0 to disable.
|
||||||
|
*/
|
||||||
|
public Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
|
||||||
|
* <p>
|
||||||
|
* Currently only runs when either MineBehavior or FollowBehavior is active.
|
||||||
|
* <p>
|
||||||
|
* For example, if Baritone is doing "mine iron_ore", the instant it breaks the ore (and it becomes air), that location
|
||||||
|
* is no longer a goal. This means that if this setting is true, it will stop there. If this setting were off, it would
|
||||||
|
* continue with its path, and walk into that location. The tradeoff is if this setting is true, it mines ores much faster
|
||||||
|
* since it doesn't waste any time getting into locations that no longer contain ores, but on the other hand, it misses
|
||||||
|
* some drops, and continues on without ever picking them up.
|
||||||
|
* <p>
|
||||||
|
* Also on cosmic prisons this should be set to true since you don't actually mine the ore it just gets replaced with stone.
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> cancelOnGoalInvalidation = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "axis" command (aka GoalAxis) will go to a axis, or diagonal axis, at this Y level.
|
||||||
|
*/
|
||||||
|
public Setting<Integer> axisHeight = new Setting<>(120);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When mining block of a certain type, try to mine two at once instead of one.
|
||||||
|
* If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks
|
||||||
|
* If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> forceInternalMining = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modification to the previous setting, only has effect if forceInternalMining is true
|
||||||
|
* If true, only apply the previous setting if the block adjacent to the goal isn't air.
|
||||||
|
*/
|
||||||
|
public Setting<Boolean> internalMiningAirException = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual GoalNear is set this distance away from the entity you're following
|
||||||
|
* <p>
|
||||||
|
* For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target.
|
||||||
|
*/
|
||||||
|
public Setting<Double> followOffsetDistance = new Setting<>(0D);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual GoalNear is set in this direction from the entity you're following
|
||||||
|
*/
|
||||||
|
public Setting<Float> followOffsetDirection = new Setting<>(0F);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The radius (for the GoalNear) of how close to your target position you actually have to be
|
||||||
|
*/
|
||||||
|
public Setting<Integer> followRadius = new Setting<>(3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function that is called when Baritone will log to chat. This function can be added to
|
||||||
|
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||||
|
* {@link Setting#value};
|
||||||
|
*/
|
||||||
|
public Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the current path
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorCurrentPath = new Setting<>(Color.RED);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the next path
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorNextPath = new Setting<>(Color.MAGENTA);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the blocks to break
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorBlocksToBreak = new Setting<>(Color.RED);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the blocks to place
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorBlocksToPlace = new Setting<>(Color.GREEN);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the blocks to walk into
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorBlocksToWalkInto = new Setting<>(Color.MAGENTA);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the best path so far
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorBestPathSoFar = new Setting<>(Color.BLUE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the path to the most recent considered node
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorMostRecentConsidered = new Setting<>(Color.CYAN);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the goal box
|
||||||
|
*/
|
||||||
|
public Setting<Color> colorGoalBox = new Setting<>(Color.GREEN);
|
||||||
|
|
||||||
public final Map<String, Setting<?>> byLowerName;
|
public final Map<String, Setting<?>> byLowerName;
|
||||||
public final List<Setting<?>> allSettings;
|
public final List<Setting<?>> allSettings;
|
||||||
|
|
||||||
@@ -351,7 +495,7 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
byLowerName = Collections.unmodifiableMap(tmpByName);
|
byLowerName = Collections.unmodifiableMap(tmpByName);
|
||||||
allSettings = Collections.unmodifiableList(tmpAll);
|
allSettings = Collections.unmodifiableList(tmpAll);
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior;
|
||||||
|
|
||||||
|
import baritone.api.event.listener.AbstractGameEventListener;
|
||||||
|
import baritone.api.utils.interfaces.Toggleable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IBehavior extends AbstractGameEventListener, Toggleable {}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IFollowBehavior extends IBehavior {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the follow target to the specified entity;
|
||||||
|
*
|
||||||
|
* @param entity The entity to follow
|
||||||
|
*/
|
||||||
|
void follow(Entity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The entity that is currently being followed
|
||||||
|
*/
|
||||||
|
Entity following();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the follow behavior, this will clear the current follow target.
|
||||||
|
*/
|
||||||
|
void cancel();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior;
|
||||||
|
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface ILookBehavior extends IBehavior {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the current {@link ILookBehavior} target to target
|
||||||
|
* the specified rotations on the next tick. If force is {@code true},
|
||||||
|
* then freeLook will be overriden and angles will be set regardless.
|
||||||
|
* If any sort of block interaction is required, force should be {@code true},
|
||||||
|
* otherwise, it should be {@code false};
|
||||||
|
*
|
||||||
|
* @param rotation The target rotations
|
||||||
|
* @param force Whether or not to "force" the rotations
|
||||||
|
*/
|
||||||
|
void updateTarget(Rotation rotation, boolean force);
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior;
|
||||||
|
|
||||||
|
import baritone.api.behavior.memory.IRememberedInventory;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IMemoryBehavior extends IBehavior {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a remembered inventory by its block position.
|
||||||
|
*
|
||||||
|
* @param pos The position of the container block
|
||||||
|
* @return The remembered inventory
|
||||||
|
*/
|
||||||
|
IRememberedInventory getInventoryByPos(BlockPos pos);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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.behavior;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IMineBehavior extends IBehavior {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin to search for and mine the specified blocks until
|
||||||
|
* the number of specified items to get from the blocks that
|
||||||
|
* are mined. This is based on the first target block to mine.
|
||||||
|
*
|
||||||
|
* @param quantity The number of items to get from blocks mined
|
||||||
|
* @param blocks The blocks to mine
|
||||||
|
*/
|
||||||
|
void mine(int quantity, String... blocks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin to search for and mine the specified blocks until
|
||||||
|
* the number of specified items to get from the blocks that
|
||||||
|
* are mined. This is based on the first target block to mine.
|
||||||
|
*
|
||||||
|
* @param quantity The number of items to get from blocks mined
|
||||||
|
* @param blocks The blocks to mine
|
||||||
|
*/
|
||||||
|
void mine(int quantity, Block... blocks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin to search for and mine the specified blocks.
|
||||||
|
*
|
||||||
|
* @param blocks The blocks to mine
|
||||||
|
*/
|
||||||
|
default void mine(String... blocks) {
|
||||||
|
this.mine(0, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin to search for and mine the specified blocks.
|
||||||
|
*
|
||||||
|
* @param blocks The blocks to mine
|
||||||
|
*/
|
||||||
|
default void mine(Block... blocks) {
|
||||||
|
this.mine(0, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the current mining task
|
||||||
|
*/
|
||||||
|
void cancel();
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior;
|
||||||
|
|
||||||
|
import baritone.api.pathing.goals.Goal;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IPathingBehavior extends IBehavior {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the estimated remaining ticks in the current pathing
|
||||||
|
* segment. Given that the return type is an optional, {@link Optional#empty()}
|
||||||
|
* will be returned in the case that there is no current segment being pathed.
|
||||||
|
*
|
||||||
|
* @return The estimated remaining ticks in the current segment.
|
||||||
|
*/
|
||||||
|
Optional<Double> ticksRemainingInSegment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pathing goal.
|
||||||
|
*
|
||||||
|
* @param goal The pathing goal
|
||||||
|
*/
|
||||||
|
void setGoal(Goal goal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The current pathing goal
|
||||||
|
*/
|
||||||
|
Goal getGoal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begins pathing. Calculation will start in a new thread, and once completed,
|
||||||
|
* movement will commence. Returns whether or not the operation was successful.
|
||||||
|
*
|
||||||
|
* @return Whether or not the operation was successful
|
||||||
|
*/
|
||||||
|
boolean path();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not a path is currently being executed.
|
||||||
|
*/
|
||||||
|
boolean isPathing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the pathing behavior or the current path calculation.
|
||||||
|
*/
|
||||||
|
void cancel();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.behavior.memory;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public interface IRememberedInventory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The contents of this inventory
|
||||||
|
*/
|
||||||
|
List<ItemStack> getContents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of slots in this inventory
|
||||||
|
*/
|
||||||
|
int getSize();
|
||||||
|
}
|
||||||
+5
-6
@@ -2,22 +2,21 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils.pathing;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import baritone.utils.Helper;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 2:01 AM
|
* @since 8/4/2018 2:01 AM
|
||||||
*/
|
*/
|
||||||
public interface IBlockTypeAccess extends Helper {
|
public interface IBlockTypeAccess {
|
||||||
|
|
||||||
IBlockState getBlock(int x, int y, int z);
|
IBlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface ICachedRegion extends IBlockTypeAccess {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the block at the specified X and Z coordinates
|
||||||
|
* is cached in this world. Similar to {@link ICachedWorld#isCached(int, int)},
|
||||||
|
* however, the block coordinates should in on a scale from 0 to 511 (inclusive)
|
||||||
|
* because region sizes are 512x512 blocks.
|
||||||
|
*
|
||||||
|
* @see ICachedWorld#isCached(int, int)
|
||||||
|
*
|
||||||
|
* @param blockX The block X coordinate
|
||||||
|
* @param blockZ The block Z coordinate
|
||||||
|
* @return Whether or not the specified XZ location is cached
|
||||||
|
*/
|
||||||
|
boolean isCached(int blockX, int blockZ);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The X coordinate of this region
|
||||||
|
*/
|
||||||
|
int getX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Z coordinate of this region
|
||||||
|
*/
|
||||||
|
int getZ();
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface ICachedWorld {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the region at the specified region coordinates
|
||||||
|
*
|
||||||
|
* @param regionX The region X coordinate
|
||||||
|
* @param regionZ The region Z coordinate
|
||||||
|
* @return The region located at the specified coordinates
|
||||||
|
*/
|
||||||
|
ICachedRegion getRegion(int regionX, int regionZ);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queues the specified chunk for packing. This entails reading the contents
|
||||||
|
* of the chunk, then packing the data into the 2-bit format, and storing that
|
||||||
|
* in this cached world.
|
||||||
|
*
|
||||||
|
* @param chunk The chunk to pack and store
|
||||||
|
*/
|
||||||
|
void queueForPacking(Chunk chunk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the block at the specified X and Z coordinates
|
||||||
|
* is cached in this world.
|
||||||
|
*
|
||||||
|
* @param blockX The block X coordinate
|
||||||
|
* @param blockZ The block Z coordinate
|
||||||
|
* @return Whether or not the specified XZ location is cached
|
||||||
|
*/
|
||||||
|
boolean isCached(int blockX, int blockZ);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scans the cached chunks for location of the specified special block. The
|
||||||
|
* information that is returned by this method may not be up to date, because
|
||||||
|
* older cached chunks can contain data that is much more likely to have changed.
|
||||||
|
*
|
||||||
|
* @param block The special block to search for
|
||||||
|
* @param maximum The maximum number of position results to receive
|
||||||
|
* @param maxRegionDistanceSq The maximum region distance, squared
|
||||||
|
* @return The locations found that match the special block
|
||||||
|
*/
|
||||||
|
LinkedList<BlockPos> getLocationsOf(String block, int maximum, int maxRegionDistanceSq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads all of the cached regions in this world from disk. Anything that is not saved
|
||||||
|
* will be lost. This operation does not execute in a new thread by default.
|
||||||
|
*/
|
||||||
|
void reloadAllFromDisk();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves all of the cached regions in this world to disk. This operation does not execute
|
||||||
|
* in a new thread by default.
|
||||||
|
*/
|
||||||
|
void save();
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A marker for a position in the world.
|
||||||
|
*
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface IWaypoint {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The label for this waypoint
|
||||||
|
*/
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tag for this waypoint. The tag is a category
|
||||||
|
* for the waypoint in a sense, it describes the source of
|
||||||
|
* the waypoint.
|
||||||
|
*
|
||||||
|
* @return The waypoint tag
|
||||||
|
*/
|
||||||
|
Tag getTag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unix epoch time in milliseconds that this waypoint
|
||||||
|
* was created. This value should only be set once, when the waypoint
|
||||||
|
* is initially created, and not when it is being loaded from file.
|
||||||
|
*
|
||||||
|
* @return The unix epoch milliseconds that this waypoint was created
|
||||||
|
*/
|
||||||
|
long getCreationTimestamp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the actual block position of this waypoint.
|
||||||
|
*
|
||||||
|
* @return The block position of this waypoint
|
||||||
|
*/
|
||||||
|
BlockPos getLocation();
|
||||||
|
|
||||||
|
enum Tag {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag indicating a position explictly marked as a home base
|
||||||
|
*/
|
||||||
|
HOME("home", "base"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag indicating a position that the local player has died at
|
||||||
|
*/
|
||||||
|
DEATH("death"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag indicating a bed position
|
||||||
|
*/
|
||||||
|
BED("bed", "spawn"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag indicating that the waypoint was user-created
|
||||||
|
*/
|
||||||
|
USER("user");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of all of the
|
||||||
|
*/
|
||||||
|
private static final List<Tag> TAG_LIST = Collections.unmodifiableList(Arrays.asList(Tag.values()));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The names for the tag, anything that the tag can be referred to as.
|
||||||
|
*/
|
||||||
|
private final String[] names;
|
||||||
|
|
||||||
|
Tag(String... names) {
|
||||||
|
this.names = names;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a tag from one of the names that could be used to identify said tag.
|
||||||
|
*
|
||||||
|
* @param name The name of the tag
|
||||||
|
* @return The tag, if one is found, otherwise, {@code null}
|
||||||
|
*/
|
||||||
|
public static Tag fromString(String name) {
|
||||||
|
return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface IWaypointCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a waypoint to this collection
|
||||||
|
*
|
||||||
|
* @param waypoint The waypoint
|
||||||
|
*/
|
||||||
|
void addWaypoint(IWaypoint waypoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a waypoint from this collection
|
||||||
|
*
|
||||||
|
* @param waypoint The waypoint
|
||||||
|
*/
|
||||||
|
void removeWaypoint(IWaypoint waypoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the most recently created waypoint by the specified {@link IWaypoint.Tag}
|
||||||
|
*
|
||||||
|
* @param tag The tag
|
||||||
|
* @return The most recently created waypoint with the specified tag
|
||||||
|
*/
|
||||||
|
IWaypoint getMostRecentByTag(IWaypoint.Tag tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all of the waypoints that have the specified tag
|
||||||
|
*
|
||||||
|
* @see IWaypointCollection#getAllWaypoints()
|
||||||
|
*
|
||||||
|
* @param tag The tag
|
||||||
|
* @return All of the waypoints with the specified tag
|
||||||
|
*/
|
||||||
|
Set<IWaypoint> getByTag(IWaypoint.Tag tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all of the waypoints in this collection, regardless of the tag.
|
||||||
|
*
|
||||||
|
* @see IWaypointCollection#getByTag(IWaypoint.Tag)
|
||||||
|
*
|
||||||
|
* @return All of the waypoints in this collection
|
||||||
|
*/
|
||||||
|
Set<IWaypoint> getAllWaypoints();
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface IWorldData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the cached world for this world. A cached world is a simplified format
|
||||||
|
* of a regular world, intended for use on multiplayer servers where chunks are not
|
||||||
|
* traditionally stored to disk, allowing for long distance pathing with minimal disk usage.
|
||||||
|
*/
|
||||||
|
ICachedWorld getCachedWorld();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the waypoint collection for this world.
|
||||||
|
*
|
||||||
|
* @return The waypoint collection for this world
|
||||||
|
*/
|
||||||
|
IWaypointCollection getWaypoints();
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/24/2018
|
||||||
|
*/
|
||||||
|
public interface IWorldProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the data of the currently loaded world
|
||||||
|
*
|
||||||
|
* @return The current world data
|
||||||
|
*/
|
||||||
|
IWorldData getCurrentWorld();
|
||||||
|
}
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+5
-4
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -28,5 +28,6 @@ public enum PathEvent {
|
|||||||
AT_GOAL,
|
AT_GOAL,
|
||||||
PATH_FINISHED_NEXT_STILL_CALCULATING,
|
PATH_FINISHED_NEXT_STILL_CALCULATING,
|
||||||
NEXT_CALC_FAILED,
|
NEXT_CALC_FAILED,
|
||||||
DISCARD_NEXT
|
DISCARD_NEXT,
|
||||||
|
CANCELED;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -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.event.events;
|
||||||
|
|
||||||
|
import baritone.api.event.events.type.EventState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 8/21/2018
|
||||||
|
*/
|
||||||
|
public final class RotationMoveEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of event
|
||||||
|
*/
|
||||||
|
private final Type type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of the event
|
||||||
|
*/
|
||||||
|
private final EventState state;
|
||||||
|
|
||||||
|
public RotationMoveEvent(EventState state, Type type) {
|
||||||
|
this.state = state;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The state of the event
|
||||||
|
*/
|
||||||
|
public final EventState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The type of the event
|
||||||
|
*/
|
||||||
|
public final Type getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the player's motion is updated.
|
||||||
|
*
|
||||||
|
* @see Entity#moveRelative(float, float, float, float)
|
||||||
|
*/
|
||||||
|
MOTION_UPDATE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the player jumps.
|
||||||
|
*
|
||||||
|
* @see EntityLivingBase#jump
|
||||||
|
*/
|
||||||
|
JUMP
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,10 +23,22 @@ public final class TickEvent {
|
|||||||
|
|
||||||
private final EventState state;
|
private final EventState state;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
private final int count;
|
||||||
|
|
||||||
|
private static int overallTickCount;
|
||||||
|
|
||||||
public TickEvent(EventState state, Type type) {
|
public TickEvent(EventState state, Type type) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.count = incrementCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static synchronized int incrementCount() {
|
||||||
|
return overallTickCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+3
-3
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+4
-4
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public enum EventState {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that whatever movement the event is being
|
* Indicates that whatever movement the event is being
|
||||||
* dispatched as a result of has already occured.
|
* dispatched as a result of has already occurred.
|
||||||
*/
|
*/
|
||||||
POST
|
POST
|
||||||
}
|
}
|
||||||
+4
-21
@@ -2,33 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,7 +58,7 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
|||||||
default void onReceivePacket(PacketEvent event) {}
|
default void onReceivePacket(PacketEvent event) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onPlayerRelativeMove(RelativeMoveEvent event) {}
|
default void onPlayerRotationMove(RotationMoveEvent event) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onBlockInteract(BlockInteractEvent event) {}
|
default void onBlockInteract(BlockInteractEvent event) {}
|
||||||
+12
-21
@@ -2,33 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -43,6 +26,7 @@ import net.minecraft.client.multiplayer.WorldClient;
|
|||||||
import net.minecraft.client.renderer.EntityRenderer;
|
import net.minecraft.client.renderer.EntityRenderer;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
@@ -108,6 +92,8 @@ public interface IGameEventListener {
|
|||||||
* Runs before a outbound packet is sent
|
* Runs before a outbound packet is sent
|
||||||
*
|
*
|
||||||
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
||||||
|
* @see Packet
|
||||||
|
* @see GenericFutureListener
|
||||||
*/
|
*/
|
||||||
void onSendPacket(PacketEvent event);
|
void onSendPacket(PacketEvent event);
|
||||||
|
|
||||||
@@ -115,15 +101,19 @@ public interface IGameEventListener {
|
|||||||
* Runs before an inbound packet is processed
|
* Runs before an inbound packet is processed
|
||||||
*
|
*
|
||||||
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
||||||
|
* @see Packet
|
||||||
|
* @see GenericFutureListener
|
||||||
*/
|
*/
|
||||||
void onReceivePacket(PacketEvent event);
|
void onReceivePacket(PacketEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run once per game tick from before and after the player's moveRelative method is called
|
* Run once per game tick from before and after the player's moveRelative method is called
|
||||||
|
* and before and after the player jumps.
|
||||||
*
|
*
|
||||||
* @see Entity#moveRelative(float, float, float, float)
|
* @see Entity#moveRelative(float, float, float, float)
|
||||||
|
* @see EntityLivingBase#jump()
|
||||||
*/
|
*/
|
||||||
void onPlayerRelativeMove(RelativeMoveEvent event);
|
void onPlayerRotationMove(RotationMoveEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the local player interacts with a block, whether it is breaking or opening/placing.
|
* Called when the local player interacts with a block, whether it is breaking or opening/placing.
|
||||||
@@ -137,6 +127,7 @@ public interface IGameEventListener {
|
|||||||
* 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 GuiGameOver} screen.
|
||||||
*
|
*
|
||||||
* @see GuiGameOver(ITextComponent)
|
* @see GuiGameOver(ITextComponent)
|
||||||
|
* @see ITextComponent
|
||||||
*/
|
*/
|
||||||
void onPlayerDeath();
|
void onPlayerDeath();
|
||||||
|
|
||||||
+15
-10
@@ -2,22 +2,21 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.pathing.movement.ActionCosts;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,22 +24,28 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public interface Goal extends ActionCosts {
|
public interface Goal {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the specified position
|
* Returns whether or not the specified position
|
||||||
* meets the requirement for this goal based.
|
* meets the requirement for this goal based.
|
||||||
*
|
*
|
||||||
* @param pos The position
|
|
||||||
* @return Whether or not it satisfies this goal
|
* @return Whether or not it satisfies this goal
|
||||||
*/
|
*/
|
||||||
boolean isInGoal(BlockPos pos);
|
boolean isInGoal(int x, int y, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate the number of ticks it will take to get to the goal
|
* Estimate the number of ticks it will take to get to the goal
|
||||||
*
|
*
|
||||||
* @param pos The
|
|
||||||
* @return The estimate number of ticks to satisfy the goal
|
* @return The estimate number of ticks to satisfy the goal
|
||||||
*/
|
*/
|
||||||
double heuristic(BlockPos pos);
|
double heuristic(int x, int y, int z);
|
||||||
|
|
||||||
|
default boolean isInGoal(BlockPos pos) {
|
||||||
|
return isInGoal(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
default double heuristic(BlockPos pos) {
|
||||||
|
return heuristic(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
|
import baritone.api.BaritoneAPI;
|
||||||
|
|
||||||
|
public class GoalAxis implements Goal {
|
||||||
|
|
||||||
|
private static final double SQRT_2_OVER_2 = Math.sqrt(2) / 2;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
|
return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double heuristic(int x0, int y, int z0) {
|
||||||
|
int x = Math.abs(x0);
|
||||||
|
int z = Math.abs(z0);
|
||||||
|
|
||||||
|
int shrt = Math.min(x, z);
|
||||||
|
int lng = Math.max(x, z);
|
||||||
|
int diff = lng - shrt;
|
||||||
|
|
||||||
|
double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2));
|
||||||
|
|
||||||
|
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GoalAxis";
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-23
@@ -2,22 +2,22 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,36 +53,27 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z;
|
return x == this.x && y == this.y && z == this.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The min range value over which to begin considering Y coordinate in the heuristic
|
|
||||||
*/
|
|
||||||
private static final double MIN = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The max range value over which to begin considering Y coordinate in the heuristic
|
|
||||||
*/
|
|
||||||
private static final double MAX = 150;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
int xDiff = pos.getX() - this.x;
|
int xDiff = x - this.x;
|
||||||
int yDiff = pos.getY() - this.y;
|
int yDiff = y - this.y;
|
||||||
int zDiff = pos.getZ() - this.z;
|
int zDiff = z - this.z;
|
||||||
return calculate(xDiff, yDiff, zDiff);
|
return calculate(xDiff, yDiff, zDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
|
return "GoalBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The position of this goal as a {@link BlockPos}
|
* @return The position of this goal as a {@link BlockPos}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public BlockPos getGoalPos() {
|
public BlockPos getGoalPos() {
|
||||||
return new BlockPos(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
@@ -92,7 +83,7 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
|||||||
|
|
||||||
// if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be
|
// if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be
|
||||||
// therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
|
// therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
|
||||||
heuristic += new GoalYLevel(yDiff).heuristic(new BlockPos(0, 0, 0));
|
heuristic += GoalYLevel.calculate(yDiff, 0);
|
||||||
|
|
||||||
//use the pythagorean and manhattan mixture from GoalXZ
|
//use the pythagorean and manhattan mixture from GoalXZ
|
||||||
heuristic += GoalXZ.calculate(xDiff, zDiff);
|
heuristic += GoalXZ.calculate(xDiff, zDiff);
|
||||||
+17
-10
@@ -2,24 +2,25 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A composite of many goals, any one of which satisfies the composite.
|
* A composite of many goals, any one of which satisfies the composite.
|
||||||
@@ -33,7 +34,7 @@ public class GoalComposite implements Goal {
|
|||||||
/**
|
/**
|
||||||
* An array of goals that any one of must be satisfied
|
* An array of goals that any one of must be satisfied
|
||||||
*/
|
*/
|
||||||
public final Goal[] goals;
|
private final Goal[] goals;
|
||||||
|
|
||||||
public GoalComposite(Goal... goals) {
|
public GoalComposite(Goal... goals) {
|
||||||
this.goals = goals;
|
this.goals = goals;
|
||||||
@@ -48,15 +49,21 @@ public class GoalComposite implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
return Arrays.stream(this.goals).anyMatch(goal -> goal.isInGoal(pos));
|
for (Goal goal : goals) {
|
||||||
|
if (goal.isInGoal(x, y, z)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
double min = Double.MAX_VALUE;
|
double min = Double.MAX_VALUE;
|
||||||
for (Goal g : goals) {
|
for (Goal g : goals) {
|
||||||
min = Math.min(min, g.heuristic(pos)); // whichever is closest
|
// TODO technically this isn't admissible...?
|
||||||
|
min = Math.min(min, g.heuristic(x, y, z)); // whichever is closest
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
+20
-15
@@ -2,23 +2,22 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import baritone.utils.pathing.BetterBlockPos;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
|
||||||
@@ -39,15 +38,16 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
|||||||
this.z = pos.getZ();
|
this.z = pos.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockPos getGoalPos() {
|
public BlockPos getGoalPos() {
|
||||||
return new BetterBlockPos(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
int xDiff = pos.getX() - this.x;
|
int xDiff = x - this.x;
|
||||||
int yDiff = pos.getY() - this.y;
|
int yDiff = y - this.y;
|
||||||
int zDiff = pos.getZ() - this.z;
|
int zDiff = z - this.z;
|
||||||
if (yDiff < 0) {
|
if (yDiff < 0) {
|
||||||
yDiff++;
|
yDiff++;
|
||||||
}
|
}
|
||||||
@@ -55,10 +55,15 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
int xDiff = pos.getX() - this.x;
|
int xDiff = x - this.x;
|
||||||
int yDiff = pos.getY() - this.y;
|
int yDiff = y - this.y;
|
||||||
int zDiff = pos.getZ() - this.z;
|
int zDiff = z - this.z;
|
||||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GoalGetToBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+20
-19
@@ -2,29 +2,29 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class GoalNear implements Goal, IGoalRenderPos {
|
public class GoalNear implements Goal, IGoalRenderPos {
|
||||||
final int x;
|
private final int x;
|
||||||
final int y;
|
private final int y;
|
||||||
final int z;
|
private final int z;
|
||||||
final int rangeSq;
|
private final int rangeSq;
|
||||||
|
|
||||||
public GoalNear(BlockPos pos, int range) {
|
public GoalNear(BlockPos pos, int range) {
|
||||||
this.x = pos.getX();
|
this.x = pos.getX();
|
||||||
@@ -34,21 +34,22 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
int diffX = x - pos.getX();
|
int xDiff = x - this.x;
|
||||||
int diffY = y - pos.getY();
|
int yDiff = y - this.y;
|
||||||
int diffZ = z - pos.getZ();
|
int zDiff = z - this.z;
|
||||||
return diffX * diffX + diffY * diffY + diffZ * diffZ <= rangeSq;
|
return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff <= rangeSq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
int diffX = x - pos.getX();
|
int xDiff = x - this.x;
|
||||||
int diffY = y - pos.getY();
|
int yDiff = y - this.y;
|
||||||
int diffZ = z - pos.getZ();
|
int zDiff = z - this.z;
|
||||||
return GoalBlock.calculate(diffX, diffY, diffZ);
|
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockPos getGoalPos() {
|
public BlockPos getGoalPos() {
|
||||||
return new BlockPos(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
+15
-13
@@ -2,33 +2,35 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Useful for automated combat (retreating specifically)
|
* Useful for automated combat (retreating specifically)
|
||||||
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class GoalRunAway implements Goal {
|
public class GoalRunAway implements Goal {
|
||||||
|
|
||||||
public final BlockPos[] from;
|
private final BlockPos[] from;
|
||||||
|
|
||||||
final double distanceSq;
|
private final double distanceSq;
|
||||||
|
|
||||||
public GoalRunAway(double distance, BlockPos... from) {
|
public GoalRunAway(double distance, BlockPos... from) {
|
||||||
if (from.length == 0) {
|
if (from.length == 0) {
|
||||||
@@ -39,10 +41,10 @@ public class GoalRunAway implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
for (BlockPos p : from) {
|
for (BlockPos p : from) {
|
||||||
int diffX = pos.getX() - p.getX();
|
int diffX = x - p.getX();
|
||||||
int diffZ = pos.getZ() - p.getZ();
|
int diffZ = z - p.getZ();
|
||||||
double distSq = diffX * diffX + diffZ * diffZ;
|
double distSq = diffX * diffX + diffZ * diffZ;
|
||||||
if (distSq < distanceSq) {
|
if (distSq < distanceSq) {
|
||||||
return false;
|
return false;
|
||||||
@@ -52,10 +54,10 @@ public class GoalRunAway implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {//mostly copied from GoalBlock
|
public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock
|
||||||
double min = Double.MAX_VALUE;
|
double min = Double.MAX_VALUE;
|
||||||
for (BlockPos p : from) {
|
for (BlockPos p : from) {
|
||||||
double h = GoalXZ.calculate(p.getX() - pos.getX(), p.getZ() - pos.getZ());
|
double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
|
||||||
if (h < min) {
|
if (h < min) {
|
||||||
min = h;
|
min = h;
|
||||||
}
|
}
|
||||||
@@ -65,6 +67,6 @@ public class GoalRunAway implements Goal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GoalRunAwayFrom[" + Arrays.asList(from) + "]";
|
return "GoalRunAwayFrom" + Arrays.asList(from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-11
@@ -2,22 +2,22 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,21 +54,22 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
return pos.getX() == this.x && (pos.getY() == this.y || pos.getY() == this.y - 1) && pos.getZ() == this.z;
|
return x == this.x && (y == this.y || y == this.y - 1) && z == this.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
double xDiff = pos.getX() - this.x;
|
int xDiff = x - this.x;
|
||||||
int yDiff = pos.getY() - this.y;
|
int yDiff = y - this.y;
|
||||||
|
int zDiff = z - this.z;
|
||||||
if (yDiff < 0) {
|
if (yDiff < 0) {
|
||||||
yDiff++;
|
yDiff++;
|
||||||
}
|
}
|
||||||
double zDiff = pos.getZ() - this.z;
|
|
||||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockPos getGoalPos() {
|
public BlockPos getGoalPos() {
|
||||||
return new BlockPos(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
+13
-18
@@ -2,24 +2,22 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.utils.Utils;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
@@ -48,26 +46,23 @@ public class GoalXZ implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
return pos.getX() == x && pos.getZ() == z;
|
return x == this.x && z == this.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {//mostly copied from GoalBlock
|
public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock
|
||||||
double xDiff = pos.getX() - this.x;
|
int xDiff = x - this.x;
|
||||||
double zDiff = pos.getZ() - this.z;
|
int zDiff = z - this.z;
|
||||||
return calculate(xDiff, zDiff);
|
return calculate(xDiff, zDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Goal{x=" + x + ",z=" + z + "}";
|
return "GoalXZ{x=" + x + ",z=" + z + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double calculate(double xDiff, double zDiff) {
|
public static double calculate(double xDiff, double zDiff) {
|
||||||
if (Baritone.settings().pythagoreanMetric.get()) {
|
|
||||||
return Math.sqrt(xDiff * xDiff + zDiff * zDiff) * Baritone.settings().costHeuristic.get();
|
|
||||||
}
|
|
||||||
//This is a combination of pythagorean and manhattan distance
|
//This is a combination of pythagorean and manhattan distance
|
||||||
//It takes into account the fact that pathing can either walk diagonally or forwards
|
//It takes into account the fact that pathing can either walk diagonally or forwards
|
||||||
|
|
||||||
@@ -85,11 +80,11 @@ public class GoalXZ implements Goal {
|
|||||||
diagonal = z;
|
diagonal = z;
|
||||||
}
|
}
|
||||||
diagonal *= SQRT_2;
|
diagonal *= SQRT_2;
|
||||||
return (diagonal + straight) * Baritone.settings().costHeuristic.get(); // big TODO tune
|
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||||
float theta = (float) Utils.degToRad(yaw);
|
float theta = (float) Math.toRadians(yaw);
|
||||||
double x = origin.x - MathHelper.sin(theta) * distance;
|
double x = origin.x - MathHelper.sin(theta) * distance;
|
||||||
double z = origin.z + MathHelper.cos(theta) * distance;
|
double z = origin.z + MathHelper.cos(theta) * distance;
|
||||||
return new GoalXZ((int) x, (int) z);
|
return new GoalXZ((int) x, (int) z);
|
||||||
+18
-14
@@ -2,29 +2,29 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Useful for mining (getting to diamond / iron level)
|
* Useful for mining (getting to diamond / iron level)
|
||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class GoalYLevel implements Goal {
|
public class GoalYLevel implements Goal, ActionCosts {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target Y level
|
* The target Y level
|
||||||
@@ -36,25 +36,29 @@ public class GoalYLevel implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInGoal(BlockPos pos) {
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
return pos.getY() == level;
|
return y == level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic(BlockPos pos) {
|
public double heuristic(int x, int y, int z) {
|
||||||
if (pos.getY() > level) {
|
return calculate(level, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculate(int goalY, int currentY) {
|
||||||
|
if (currentY > goalY) {
|
||||||
// need to descend
|
// need to descend
|
||||||
return FALL_N_BLOCKS_COST[2] / 2 * (pos.getY() - level);
|
return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY);
|
||||||
}
|
}
|
||||||
if (pos.getY() < level) {
|
if (currentY < goalY) {
|
||||||
// need to ascend
|
// need to ascend
|
||||||
return (level - pos.getY()) * JUMP_ONE_BLOCK_COST;
|
return (goalY - currentY) * JUMP_ONE_BLOCK_COST;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Goal{y=" + level + "}";
|
return "GoalYLevel{y=" + level + "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+36
-10
@@ -2,22 +2,49 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.pathing.movement;
|
package baritone.api.pathing.movement;
|
||||||
|
|
||||||
|
public interface ActionCosts {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These costs are measured roughly in ticks btw
|
||||||
|
*/
|
||||||
|
double WALK_ONE_BLOCK_COST = 20 / 4.317; // 4.633
|
||||||
|
double WALK_ONE_IN_WATER_COST = 20 / 2.2;
|
||||||
|
double WALK_ONE_OVER_SOUL_SAND_COST = WALK_ONE_BLOCK_COST * 2; // 0.4 in BlockSoulSand but effectively about half
|
||||||
|
double SPRINT_ONE_OVER_SOUL_SAND_COST = WALK_ONE_OVER_SOUL_SAND_COST * 0.75;
|
||||||
|
double LADDER_UP_ONE_COST = 20 / 2.35;
|
||||||
|
double LADDER_DOWN_ONE_COST = 20 / 3.0;
|
||||||
|
double SNEAK_ONE_BLOCK_COST = 20 / 1.3;
|
||||||
|
double SPRINT_ONE_BLOCK_COST = 20 / 5.612; // 3.564
|
||||||
|
/**
|
||||||
|
* To walk off an edge you need to walk 0.5 to the edge then 0.3 to start falling off
|
||||||
|
*/
|
||||||
|
double WALK_OFF_BLOCK_COST = WALK_ONE_BLOCK_COST * 0.8;
|
||||||
|
/**
|
||||||
|
* To walk the rest of the way to be centered on the new block
|
||||||
|
*/
|
||||||
|
double CENTER_AFTER_FALL_COST = WALK_ONE_BLOCK_COST - WALK_OFF_BLOCK_COST;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* don't make this Double.MAX_VALUE because it's added to other things, maybe other COST_INFs,
|
||||||
|
* and that would make it overflow to negative
|
||||||
|
*/
|
||||||
|
double COST_INF = 1000000;
|
||||||
|
|
||||||
public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside {
|
|
||||||
double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost();
|
double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost();
|
||||||
|
|
||||||
double FALL_1_25_BLOCKS_COST = distanceToTicks(1.25);
|
double FALL_1_25_BLOCKS_COST = distanceToTicks(1.25);
|
||||||
@@ -57,16 +84,15 @@ public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside {
|
|||||||
if (distance == 0) {
|
if (distance == 0) {
|
||||||
return 0; // Avoid 0/0 NaN
|
return 0; // Avoid 0/0 NaN
|
||||||
}
|
}
|
||||||
|
double tmpDistance = distance;
|
||||||
int tickCount = 0;
|
int tickCount = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
double fallDistance = velocity(tickCount);
|
double fallDistance = velocity(tickCount);
|
||||||
if (distance <= fallDistance) {
|
if (tmpDistance <= fallDistance) {
|
||||||
return tickCount + distance / fallDistance;
|
return tickCount + tmpDistance / fallDistance;
|
||||||
}
|
}
|
||||||
distance -= fallDistance;
|
tmpDistance -= fallDistance;
|
||||||
tickCount++;
|
tickCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+9
-9
@@ -2,26 +2,26 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.util.Tuple;
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/23/2018
|
||||||
|
*/
|
||||||
|
public class Logger {
|
||||||
|
|
||||||
public class Rotation extends Tuple<Float, Float> {
|
|
||||||
|
|
||||||
public Rotation(Float yaw, Float pitch) {
|
|
||||||
super(yaw, pitch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/25/2018
|
||||||
|
*/
|
||||||
|
public class Rotation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The yaw angle of this Rotation
|
||||||
|
*/
|
||||||
|
private float yaw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pitch angle of this Rotation
|
||||||
|
*/
|
||||||
|
private float pitch;
|
||||||
|
|
||||||
|
public Rotation(float yaw, float pitch) {
|
||||||
|
this.yaw = yaw;
|
||||||
|
this.pitch = pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The yaw of this rotation
|
||||||
|
*/
|
||||||
|
public float getYaw() {
|
||||||
|
return this.yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The pitch of this rotation
|
||||||
|
*/
|
||||||
|
public float getPitch() {
|
||||||
|
return this.pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the yaw/pitch of the specified rotations to this
|
||||||
|
* rotation's yaw/pitch, and returns the result.
|
||||||
|
*
|
||||||
|
* @param other Another rotation
|
||||||
|
* @return The result from adding the other rotation to this rotation
|
||||||
|
*/
|
||||||
|
public Rotation add(Rotation other) {
|
||||||
|
return new Rotation(
|
||||||
|
this.yaw + other.yaw,
|
||||||
|
this.pitch + other.pitch
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtracts the yaw/pitch of the specified rotations from this
|
||||||
|
* rotation's yaw/pitch, and returns the result.
|
||||||
|
*
|
||||||
|
* @param other Another rotation
|
||||||
|
* @return The result from subtracting the other rotation from this rotation
|
||||||
|
*/
|
||||||
|
public Rotation subtract(Rotation other) {
|
||||||
|
return new Rotation(
|
||||||
|
this.yaw - other.yaw,
|
||||||
|
this.pitch - other.pitch
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A copy of this rotation with the pitch clamped
|
||||||
|
*/
|
||||||
|
public Rotation clamp() {
|
||||||
|
return new Rotation(
|
||||||
|
this.yaw,
|
||||||
|
RotationUtils.clampPitch(this.pitch)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A copy of this rotation with the yaw normalized
|
||||||
|
*/
|
||||||
|
public Rotation normalize() {
|
||||||
|
return new Rotation(
|
||||||
|
RotationUtils.normalizeYaw(this.yaw),
|
||||||
|
this.pitch
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A copy of this rotation with the pitch clamped and the yaw normalized
|
||||||
|
*/
|
||||||
|
public Rotation normalizeAndClamp() {
|
||||||
|
return new Rotation(
|
||||||
|
RotationUtils.normalizeYaw(this.yaw),
|
||||||
|
RotationUtils.clampPitch(this.pitch)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/25/2018
|
||||||
|
*/
|
||||||
|
public final class RotationUtils {
|
||||||
|
|
||||||
|
private RotationUtils() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamps the specified pitch value between -90 and 90.
|
||||||
|
*
|
||||||
|
* @param pitch The input pitch
|
||||||
|
* @return The clamped pitch
|
||||||
|
*/
|
||||||
|
public static float clampPitch(float pitch) {
|
||||||
|
return Math.max(-90, Math.min(90, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes the specified yaw value between -180 and 180.
|
||||||
|
*
|
||||||
|
* @param yaw The input yaw
|
||||||
|
* @return The normalized yaw
|
||||||
|
*/
|
||||||
|
public static float normalizeYaw(float yaw) {
|
||||||
|
float newYaw = yaw % 360F;
|
||||||
|
if (newYaw < -180F) {
|
||||||
|
newYaw += 360F;
|
||||||
|
}
|
||||||
|
if (newYaw >= 180F) {
|
||||||
|
newYaw -= 360F;
|
||||||
|
}
|
||||||
|
return newYaw;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -2,20 +2,20 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils.interfaces;
|
package baritone.api.utils.interfaces;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
+14
-4
@@ -2,20 +2,20 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils.interfaces;
|
package baritone.api.utils.interfaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -41,4 +41,14 @@ public interface Toggleable {
|
|||||||
* @return Whether or not this {@link Toggleable} object is enabled
|
* @return Whether or not this {@link Toggleable} object is enabled
|
||||||
*/
|
*/
|
||||||
boolean isEnabled();
|
boolean isEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the state changes from disabled to enabled
|
||||||
|
*/
|
||||||
|
default void onEnable() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the state changes from enabled to disabled
|
||||||
|
*/
|
||||||
|
default void onDisable() {}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,33 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,33 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,23 +2,23 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.event.events.RelativeMoveEvent;
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -41,7 +41,7 @@ public class MixinEntity {
|
|||||||
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||||
Entity _this = (Entity) (Object) this;
|
Entity _this = (Entity) (Object) this;
|
||||||
if (_this == Minecraft.getMinecraft().player)
|
if (_this == Minecraft.getMinecraft().player)
|
||||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRelativeMove(new RelativeMoveEvent(EventState.PRE));
|
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.MOTION_UPDATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
@@ -51,6 +51,6 @@ public class MixinEntity {
|
|||||||
private void postMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
private void postMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||||
Entity _this = (Entity) (Object) this;
|
Entity _this = (Entity) (Object) this;
|
||||||
if (_this == Minecraft.getMinecraft().player)
|
if (_this == Minecraft.getMinecraft().player)
|
||||||
Baritone.INSTANCE.getGameEventHandler().onPlayerRelativeMove(new RelativeMoveEvent(EventState.POST));
|
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.MOTION_UPDATE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
|
import baritone.api.event.events.type.EventState;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 9/10/2018
|
||||||
|
*/
|
||||||
|
@Mixin(EntityLivingBase.class)
|
||||||
|
public class MixinEntityLivingBase {
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "jump",
|
||||||
|
at = @At("HEAD")
|
||||||
|
)
|
||||||
|
private void preJump(CallbackInfo ci) {
|
||||||
|
Entity _this = (Entity) (Object) this;
|
||||||
|
if (_this == Minecraft.getMinecraft().player)
|
||||||
|
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.JUMP));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "jump",
|
||||||
|
at = @At("RETURN")
|
||||||
|
)
|
||||||
|
private void postJump(CallbackInfo ci) {
|
||||||
|
Entity _this = (Entity) (Object) this;
|
||||||
|
if (_this == Minecraft.getMinecraft().player)
|
||||||
|
Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.JUMP));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU 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.settings.GameSettings;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
* @since 8/1/2018 12:28 AM
|
|
||||||
*/
|
|
||||||
@Mixin(GameSettings.class)
|
|
||||||
public class MixinGameSettings {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "isKeyDown",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private static boolean isKeyDown(int keyCode) {
|
|
||||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU 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.gui.inventory.GuiContainer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
* @since 7/31/2018 10:47 PM
|
|
||||||
*/
|
|
||||||
@Mixin(GuiContainer.class)
|
|
||||||
public class MixinGuiContainer {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = {
|
|
||||||
"mouseClicked",
|
|
||||||
"mouseReleased"
|
|
||||||
},
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private boolean isKeyDown(int keyCode) {
|
|
||||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU 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.gui.GuiScreen;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
* @since 7/31/2018 10:38 PM
|
|
||||||
*/
|
|
||||||
@Mixin(GuiScreen.class)
|
|
||||||
public class MixinGuiScreen {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = {
|
|
||||||
"isCtrlKeyDown",
|
|
||||||
"isShiftKeyDown",
|
|
||||||
"isAltKeyDown"
|
|
||||||
},
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private static boolean isKeyDown(int keyCode) {
|
|
||||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import baritone.api.event.events.BlockInteractEvent;
|
|||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.api.event.events.WorldEvent;
|
import baritone.api.event.events.WorldEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.behavior.impl.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.utils.ExampleBaritoneControl;
|
import baritone.utils.ExampleBaritoneControl;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
@@ -85,18 +85,6 @@ public class MixinMinecraft {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "runTickKeyboard",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
|
|
||||||
remap = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private boolean Keyboard$isKeyDown(int keyCode) {
|
|
||||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "processKeyBinds",
|
method = "processKeyBinds",
|
||||||
at = @At("HEAD")
|
at = @At("HEAD")
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -24,8 +24,10 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.util.concurrent.Future;
|
import io.netty.util.concurrent.Future;
|
||||||
import io.netty.util.concurrent.GenericFutureListener;
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -42,12 +44,18 @@ public class MixinNetworkManager {
|
|||||||
@Shadow
|
@Shadow
|
||||||
private Channel channel;
|
private Channel channel;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
private EnumPacketDirection direction;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "dispatchPacket",
|
method = "dispatchPacket",
|
||||||
at = @At("HEAD")
|
at = @At("HEAD")
|
||||||
)
|
)
|
||||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||||
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket));
|
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||||
|
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
@@ -55,7 +63,9 @@ public class MixinNetworkManager {
|
|||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||||
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket));
|
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||||
|
Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
@@ -66,7 +76,8 @@ public class MixinNetworkManager {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||||
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.PRE, packet));
|
if (this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||||
|
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.PRE, packet));}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
@@ -74,7 +85,7 @@ public class MixinNetworkManager {
|
|||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
private void postProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||||
if (this.channel.isOpen()) {
|
if (this.channel.isOpen() && this.direction == EnumPacketDirection.CLIENTBOUND) {
|
||||||
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet));
|
Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,9 @@
|
|||||||
"MixinBlockPos",
|
"MixinBlockPos",
|
||||||
"MixinChunkProviderServer",
|
"MixinChunkProviderServer",
|
||||||
"MixinEntity",
|
"MixinEntity",
|
||||||
|
"MixinEntityLivingBase",
|
||||||
"MixinEntityPlayerSP",
|
"MixinEntityPlayerSP",
|
||||||
"MixinEntityRenderer",
|
"MixinEntityRenderer",
|
||||||
"MixinGameSettings",
|
|
||||||
"MixinGuiContainer",
|
|
||||||
"MixinGuiScreen",
|
|
||||||
"MixinKeyBinding",
|
"MixinKeyBinding",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
|
|||||||
@@ -2,24 +2,28 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone;
|
package baritone;
|
||||||
|
|
||||||
import baritone.api.event.GameEventHandler;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.api.Settings;
|
||||||
import baritone.behavior.impl.*;
|
import baritone.api.event.listener.IGameEventListener;
|
||||||
|
import baritone.behavior.*;
|
||||||
|
import baritone.cache.WorldProvider;
|
||||||
|
import baritone.event.GameEventHandler;
|
||||||
|
import baritone.utils.BaritoneAutoTest;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
@@ -28,6 +32,10 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.SynchronousQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +59,8 @@ public enum Baritone {
|
|||||||
private Settings settings;
|
private Settings settings;
|
||||||
private List<Behavior> behaviors;
|
private List<Behavior> behaviors;
|
||||||
private File dir;
|
private File dir;
|
||||||
|
private ThreadPoolExecutor threadPool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of consumers to be called after Baritone has initialized
|
* List of consumers to be called after Baritone has initialized
|
||||||
@@ -70,9 +80,16 @@ public enum Baritone {
|
|||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||||
this.gameEventHandler = new GameEventHandler();
|
this.gameEventHandler = new GameEventHandler();
|
||||||
this.inputOverrideHandler = new InputOverrideHandler();
|
this.inputOverrideHandler = new InputOverrideHandler();
|
||||||
this.settings = new Settings();
|
|
||||||
|
// Acquire the "singleton" instance of the settings directly from the API
|
||||||
|
// We might want to change this...
|
||||||
|
this.settings = BaritoneAPI.getSettings();
|
||||||
|
|
||||||
|
BaritoneAPI.registerProviders(WorldProvider.INSTANCE);
|
||||||
|
|
||||||
this.behaviors = new ArrayList<>();
|
this.behaviors = new ArrayList<>();
|
||||||
{
|
{
|
||||||
registerBehavior(PathingBehavior.INSTANCE);
|
registerBehavior(PathingBehavior.INSTANCE);
|
||||||
@@ -81,6 +98,19 @@ public enum Baritone {
|
|||||||
registerBehavior(LocationTrackingBehavior.INSTANCE);
|
registerBehavior(LocationTrackingBehavior.INSTANCE);
|
||||||
registerBehavior(FollowBehavior.INSTANCE);
|
registerBehavior(FollowBehavior.INSTANCE);
|
||||||
registerBehavior(MineBehavior.INSTANCE);
|
registerBehavior(MineBehavior.INSTANCE);
|
||||||
|
|
||||||
|
// TODO: Clean this up
|
||||||
|
// Maybe combine this call in someway with the registerBehavior calls?
|
||||||
|
BaritoneAPI.registerDefaultBehaviors(
|
||||||
|
FollowBehavior.INSTANCE,
|
||||||
|
LookBehavior.INSTANCE,
|
||||||
|
MemoryBehavior.INSTANCE,
|
||||||
|
MineBehavior.INSTANCE,
|
||||||
|
PathingBehavior.INSTANCE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (BaritoneAutoTest.ENABLE_AUTO_TEST && "true".equals(System.getenv("BARITONE_AUTO_TEST"))) {
|
||||||
|
registerEventListener(new BaritoneAutoTest());
|
||||||
}
|
}
|
||||||
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||||
if (!Files.exists(dir.toPath())) {
|
if (!Files.exists(dir.toPath())) {
|
||||||
@@ -95,32 +125,40 @@ public enum Baritone {
|
|||||||
this.onInitConsumers.forEach(consumer -> consumer.accept(this));
|
this.onInitConsumers.forEach(consumer -> consumer.accept(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return this.initialized;
|
return this.initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final GameEventHandler getGameEventHandler() {
|
public IGameEventListener getGameEventHandler() {
|
||||||
return this.gameEventHandler;
|
return this.gameEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final InputOverrideHandler getInputOverrideHandler() {
|
public InputOverrideHandler getInputOverrideHandler() {
|
||||||
return this.inputOverrideHandler;
|
return this.inputOverrideHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<Behavior> getBehaviors() {
|
public List<Behavior> getBehaviors() {
|
||||||
return this.behaviors;
|
return this.behaviors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Executor getExecutor() {
|
||||||
|
return threadPool;
|
||||||
|
}
|
||||||
|
|
||||||
public void registerBehavior(Behavior behavior) {
|
public void registerBehavior(Behavior behavior) {
|
||||||
this.behaviors.add(behavior);
|
this.behaviors.add(behavior);
|
||||||
this.gameEventHandler.registerEventListener(behavior);
|
this.registerEventListener(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isActive() {
|
public void registerEventListener(IGameEventListener listener) {
|
||||||
|
this.gameEventHandler.registerEventListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
return this.active;
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Settings getSettings() {
|
public Settings getSettings() {
|
||||||
return this.settings;
|
return this.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,11 +166,11 @@ public enum Baritone {
|
|||||||
return Baritone.INSTANCE.settings; // yolo
|
return Baritone.INSTANCE.settings; // yolo
|
||||||
}
|
}
|
||||||
|
|
||||||
public final File getDir() {
|
public File getDir() {
|
||||||
return this.dir;
|
return this.dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void registerInitListener(Consumer<Baritone> runnable) {
|
public void registerInitListener(Consumer<Baritone> runnable) {
|
||||||
this.onInitConsumers.add(runnable);
|
this.onInitConsumers.add(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.api.event.events;
|
|
||||||
|
|
||||||
import baritone.api.event.listener.IGameEventListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called in some cases where a player's inventory has it's current slot queried.
|
|
||||||
* <p>
|
|
||||||
* @see IGameEventListener#onQueryItemSlotForBlocks()
|
|
||||||
*
|
|
||||||
* @author Brady
|
|
||||||
* @since 8/20/2018
|
|
||||||
*/
|
|
||||||
public final class ItemSlotEvent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current slot index
|
|
||||||
*/
|
|
||||||
private int slot;
|
|
||||||
|
|
||||||
public ItemSlotEvent(int slot) {
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the new slot index that will be used
|
|
||||||
*
|
|
||||||
* @param slot The slot index
|
|
||||||
*/
|
|
||||||
public final void setSlot(int slot) {
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The current slot index
|
|
||||||
*/
|
|
||||||
public final int getSlot() {
|
|
||||||
return this.slot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.api.event.events;
|
|
||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
* @since 8/21/2018
|
|
||||||
*/
|
|
||||||
public final class RelativeMoveEvent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The state of the event
|
|
||||||
*/
|
|
||||||
private final EventState state;
|
|
||||||
|
|
||||||
public RelativeMoveEvent(EventState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The state of the event
|
|
||||||
*/
|
|
||||||
public final EventState getState() {
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,32 +2,30 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.behavior;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.api.event.listener.AbstractGameEventListener;
|
import baritone.api.behavior.IBehavior;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.interfaces.Toggleable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic bot behavior.
|
* A type of game event listener that can be toggled.
|
||||||
*
|
*
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/1/2018 6:29 PM
|
* @since 8/1/2018 6:29 PM
|
||||||
*/
|
*/
|
||||||
public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
|
public class Behavior implements IBehavior {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this behavior is enabled
|
* Whether or not this behavior is enabled
|
||||||
@@ -41,7 +39,7 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean toggle() {
|
public final boolean toggle() {
|
||||||
return this.setEnabled(!this.enabled);
|
return this.setEnabled(!this.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,35 +49,17 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean setEnabled(boolean enabled) {
|
public final boolean setEnabled(boolean enabled) {
|
||||||
boolean newState = getNewState(this.enabled, enabled);
|
if (enabled == this.enabled) {
|
||||||
if (newState == this.enabled) {
|
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
if (this.enabled = enabled) {
|
||||||
if (this.enabled = newState) {
|
this.onEnable();
|
||||||
onStart();
|
|
||||||
} else {
|
} else {
|
||||||
onCancel();
|
this.onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to determine what the new enabled state of this
|
|
||||||
* {@link Behavior} should be given the old state, and the
|
|
||||||
* proposed state. Intended to be overridden by behaviors
|
|
||||||
* that should always be active, given that the bot itself is
|
|
||||||
* active.
|
|
||||||
*
|
|
||||||
* @param oldState The old state
|
|
||||||
* @param proposedState The proposed state
|
|
||||||
* @return The new state
|
|
||||||
*/
|
|
||||||
public boolean getNewState(boolean oldState, boolean proposedState) {
|
|
||||||
return proposedState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Whether or not this {@link Behavior} is active.
|
* @return Whether or not this {@link Behavior} is active.
|
||||||
*/
|
*/
|
||||||
@@ -87,14 +67,4 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
|
|||||||
public final boolean isEnabled() {
|
public final boolean isEnabled() {
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the state changes from disabled to enabled
|
|
||||||
*/
|
|
||||||
public void onStart() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the state changes from enabled to disabled
|
|
||||||
*/
|
|
||||||
public void onCancel() {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.behavior;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.behavior.IFollowBehavior;
|
||||||
|
import baritone.api.event.events.TickEvent;
|
||||||
|
import baritone.api.pathing.goals.GoalNear;
|
||||||
|
import baritone.api.pathing.goals.GoalXZ;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Follow an entity
|
||||||
|
*
|
||||||
|
* @author leijurv
|
||||||
|
*/
|
||||||
|
public final class FollowBehavior extends Behavior implements IFollowBehavior, Helper {
|
||||||
|
|
||||||
|
public static final FollowBehavior INSTANCE = new FollowBehavior();
|
||||||
|
|
||||||
|
private Entity following;
|
||||||
|
|
||||||
|
private FollowBehavior() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTick(TickEvent event) {
|
||||||
|
if (event.getType() == TickEvent.Type.OUT) {
|
||||||
|
following = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (following == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// lol this is trashy but it works
|
||||||
|
BlockPos pos;
|
||||||
|
if (Baritone.settings().followOffsetDistance.get() == 0) {
|
||||||
|
pos = following.getPosition();
|
||||||
|
} else {
|
||||||
|
GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get());
|
||||||
|
pos = new BlockPos(g.getX(), following.posY, g.getZ());
|
||||||
|
}
|
||||||
|
PathingBehavior.INSTANCE.setGoal(new GoalNear(pos, Baritone.settings().followRadius.get()));
|
||||||
|
PathingBehavior.INSTANCE.revalidateGoal();
|
||||||
|
PathingBehavior.INSTANCE.path();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void follow(Entity entity) {
|
||||||
|
this.following = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity following() {
|
||||||
|
return this.following;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
PathingBehavior.INSTANCE.cancel();
|
||||||
|
follow(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-10
@@ -2,26 +2,26 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.behavior.Behavior;
|
|
||||||
import baritone.chunk.Waypoint;
|
|
||||||
import baritone.chunk.WorldProvider;
|
|
||||||
import baritone.api.event.events.BlockInteractEvent;
|
import baritone.api.event.events.BlockInteractEvent;
|
||||||
|
import baritone.cache.Waypoint;
|
||||||
|
import baritone.cache.WorldProvider;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.block.BlockBed;
|
import net.minecraft.block.BlockBed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +33,7 @@ import net.minecraft.block.BlockBed;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/22/2018
|
* @since 8/22/2018
|
||||||
*/
|
*/
|
||||||
public final class LocationTrackingBehavior extends Behavior {
|
public final class LocationTrackingBehavior extends Behavior implements Helper {
|
||||||
|
|
||||||
public static final LocationTrackingBehavior INSTANCE = new LocationTrackingBehavior();
|
public static final LocationTrackingBehavior INSTANCE = new LocationTrackingBehavior();
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ public final class LocationTrackingBehavior extends Behavior {
|
|||||||
@Override
|
@Override
|
||||||
public void onBlockInteract(BlockInteractEvent event) {
|
public void onBlockInteract(BlockInteractEvent event) {
|
||||||
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
|
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerDeath() {
|
public void onPlayerDeath() {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
|
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+24
-17
@@ -2,34 +2,33 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.Settings;
|
import baritone.api.Settings;
|
||||||
|
import baritone.api.behavior.ILookBehavior;
|
||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.RelativeMoveEvent;
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.utils.Rotation;
|
import baritone.utils.Helper;
|
||||||
|
|
||||||
public class LookBehavior extends Behavior {
|
public final class LookBehavior extends Behavior implements ILookBehavior, Helper {
|
||||||
|
|
||||||
public static final LookBehavior INSTANCE = new LookBehavior();
|
public static final LookBehavior INSTANCE = new LookBehavior();
|
||||||
|
|
||||||
private LookBehavior() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target's values are as follows:
|
* Target's values are as follows:
|
||||||
* <p>
|
* <p>
|
||||||
@@ -50,6 +49,9 @@ public class LookBehavior extends Behavior {
|
|||||||
*/
|
*/
|
||||||
private float lastYaw;
|
private float lastYaw;
|
||||||
|
|
||||||
|
private LookBehavior() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateTarget(Rotation target, boolean force) {
|
public void updateTarget(Rotation target, boolean force) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.force = force || !Baritone.settings().freeLook.get();
|
this.force = force || !Baritone.settings().freeLook.get();
|
||||||
@@ -67,9 +69,9 @@ public class LookBehavior extends Behavior {
|
|||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case PRE: {
|
case PRE: {
|
||||||
if (this.force) {
|
if (this.force) {
|
||||||
player().rotationYaw = this.target.getFirst();
|
player().rotationYaw = this.target.getYaw();
|
||||||
float oldPitch = player().rotationPitch;
|
float oldPitch = player().rotationPitch;
|
||||||
float desiredPitch = this.target.getSecond();
|
float desiredPitch = this.target.getPitch();
|
||||||
player().rotationPitch = desiredPitch;
|
player().rotationPitch = desiredPitch;
|
||||||
if (desiredPitch == oldPitch) {
|
if (desiredPitch == oldPitch) {
|
||||||
nudgeToLevel();
|
nudgeToLevel();
|
||||||
@@ -77,7 +79,7 @@ public class LookBehavior extends Behavior {
|
|||||||
this.target = null;
|
this.target = null;
|
||||||
} else if (silent) {
|
} else if (silent) {
|
||||||
this.lastYaw = player().rotationYaw;
|
this.lastYaw = player().rotationYaw;
|
||||||
player().rotationYaw = this.target.getFirst();
|
player().rotationYaw = this.target.getYaw();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -88,25 +90,30 @@ public class LookBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerRelativeMove(RelativeMoveEvent event) {
|
public void onPlayerRotationMove(RotationMoveEvent event) {
|
||||||
if (this.target != null && !this.force) {
|
if (this.target != null && !this.force) {
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case PRE:
|
case PRE:
|
||||||
this.lastYaw = player().rotationYaw;
|
this.lastYaw = player().rotationYaw;
|
||||||
player().rotationYaw = this.target.getFirst();
|
player().rotationYaw = this.target.getYaw();
|
||||||
break;
|
break;
|
||||||
case POST:
|
case POST:
|
||||||
player().rotationYaw = this.lastYaw;
|
player().rotationYaw = this.lastYaw;
|
||||||
|
|
||||||
// If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate()
|
// If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate()
|
||||||
if (!Baritone.settings().antiCheatCompatibility.get()) {
|
// Also the type has to be MOTION_UPDATE because that is called after JUMP
|
||||||
|
if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE) {
|
||||||
this.target = null;
|
this.target = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-9
@@ -2,22 +2,26 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.utils.*;
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
import baritone.utils.RayTraceUtils;
|
||||||
|
import baritone.utils.Utils;
|
||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockFire;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
@@ -47,10 +51,10 @@ public final class LookBehaviorUtils implements Helper {
|
|||||||
* @return vector of the rotation
|
* @return vector of the rotation
|
||||||
*/
|
*/
|
||||||
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
|
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
|
||||||
float f = MathHelper.cos(-rotation.getFirst() * (float) DEG_TO_RAD - (float) Math.PI);
|
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
|
||||||
float f1 = MathHelper.sin(-rotation.getFirst() * (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.getSecond() * (float) DEG_TO_RAD);
|
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
|
||||||
float f3 = MathHelper.sin(-rotation.getSecond() * (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 Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||||
}
|
}
|
||||||
|
|
||||||
+63
-46
@@ -1,9 +1,28 @@
|
|||||||
package baritone.behavior.impl;
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.behavior;
|
||||||
|
|
||||||
|
import baritone.api.behavior.IMemoryBehavior;
|
||||||
|
import baritone.api.behavior.memory.IRememberedInventory;
|
||||||
import baritone.api.event.events.PacketEvent;
|
import baritone.api.event.events.PacketEvent;
|
||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.play.client.CPacketCloseWindow;
|
import net.minecraft.network.play.client.CPacketCloseWindow;
|
||||||
@@ -20,12 +39,10 @@ import java.util.*;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/6/2018 9:47 PM
|
* @since 8/6/2018 9:47 PM
|
||||||
*/
|
*/
|
||||||
public class MemoryBehavior extends Behavior {
|
public final class MemoryBehavior extends Behavior implements IMemoryBehavior, Helper {
|
||||||
|
|
||||||
public static MemoryBehavior INSTANCE = new MemoryBehavior();
|
public static MemoryBehavior INSTANCE = new MemoryBehavior();
|
||||||
|
|
||||||
private MemoryBehavior() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible future inventories that we will be able to remember
|
* Possible future inventories that we will be able to remember
|
||||||
*/
|
*/
|
||||||
@@ -36,6 +53,8 @@ public class MemoryBehavior extends Behavior {
|
|||||||
*/
|
*/
|
||||||
private final Map<BlockPos, RememberedInventory> rememberedInventories = new HashMap<>();
|
private final Map<BlockPos, RememberedInventory> rememberedInventories = new HashMap<>();
|
||||||
|
|
||||||
|
private MemoryBehavior() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
||||||
if (event.getState() == EventState.PRE) {
|
if (event.getState() == EventState.PRE) {
|
||||||
@@ -47,27 +66,24 @@ public class MemoryBehavior extends Behavior {
|
|||||||
public void onSendPacket(PacketEvent event) {
|
public void onSendPacket(PacketEvent event) {
|
||||||
Packet p = event.getPacket();
|
Packet p = event.getPacket();
|
||||||
|
|
||||||
switch (event.getState()) {
|
if (event.getState() == EventState.PRE) {
|
||||||
case PRE: {
|
if (p instanceof CPacketPlayerTryUseItemOnBlock) {
|
||||||
if (p instanceof CPacketPlayerTryUseItemOnBlock) {
|
CPacketPlayerTryUseItemOnBlock packet = event.cast();
|
||||||
CPacketPlayerTryUseItemOnBlock packet = event.cast();
|
|
||||||
|
|
||||||
TileEntity tileEntity = world().getTileEntity(packet.getPos());
|
TileEntity tileEntity = world().getTileEntity(packet.getPos());
|
||||||
|
|
||||||
// Ensure the TileEntity is a container of some sort
|
// Ensure the TileEntity is a container of some sort
|
||||||
if (tileEntity instanceof TileEntityLockable) {
|
if (tileEntity instanceof TileEntityLockable) {
|
||||||
|
|
||||||
TileEntityLockable lockable = (TileEntityLockable) tileEntity;
|
TileEntityLockable lockable = (TileEntityLockable) tileEntity;
|
||||||
int size = lockable.getSizeInventory();
|
int size = lockable.getSizeInventory();
|
||||||
|
|
||||||
this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), tileEntity.getPos()));
|
this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), tileEntity.getPos()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p instanceof CPacketCloseWindow) {
|
if (p instanceof CPacketCloseWindow) {
|
||||||
updateInventory();
|
updateInventory();
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,31 +92,28 @@ public class MemoryBehavior extends Behavior {
|
|||||||
public void onReceivePacket(PacketEvent event) {
|
public void onReceivePacket(PacketEvent event) {
|
||||||
Packet p = event.getPacket();
|
Packet p = event.getPacket();
|
||||||
|
|
||||||
switch (event.getState()) {
|
if (event.getState() == EventState.PRE) {
|
||||||
case PRE: {
|
if (p instanceof SPacketOpenWindow) {
|
||||||
if (p instanceof SPacketOpenWindow) {
|
SPacketOpenWindow packet = event.cast();
|
||||||
SPacketOpenWindow packet = event.cast();
|
|
||||||
|
|
||||||
// Remove any entries that were created over a second ago, this should make up for INSANE latency
|
// Remove any entries that were created over a second ago, this should make up for INSANE latency
|
||||||
this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000);
|
this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000);
|
||||||
|
|
||||||
this.futureInventories.stream()
|
this.futureInventories.stream()
|
||||||
.filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
|
.filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
|
||||||
.findFirst().ifPresent(matched -> {
|
.findFirst().ifPresent(matched -> {
|
||||||
// Remove the future inventory
|
// Remove the future inventory
|
||||||
this.futureInventories.remove(matched);
|
this.futureInventories.remove(matched);
|
||||||
|
|
||||||
// Setup the remembered inventory
|
// Setup the remembered inventory
|
||||||
RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory());
|
RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory());
|
||||||
inventory.windowId = packet.getWindowId();
|
inventory.windowId = packet.getWindowId();
|
||||||
inventory.size = packet.getSlotCount();
|
inventory.size = packet.getSlotCount();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof SPacketCloseWindow) {
|
if (p instanceof SPacketCloseWindow) {
|
||||||
updateInventory();
|
updateInventory();
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,6 +129,7 @@ public class MemoryBehavior extends Behavior {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final RememberedInventory getInventoryByPos(BlockPos pos) {
|
public final RememberedInventory getInventoryByPos(BlockPos pos) {
|
||||||
return this.rememberedInventories.get(pos);
|
return this.rememberedInventories.get(pos);
|
||||||
}
|
}
|
||||||
@@ -158,7 +172,7 @@ public class MemoryBehavior extends Behavior {
|
|||||||
* <p>
|
* <p>
|
||||||
* Associated with a {@link BlockPos} in {@link MemoryBehavior#rememberedInventories}.
|
* Associated with a {@link BlockPos} in {@link MemoryBehavior#rememberedInventories}.
|
||||||
*/
|
*/
|
||||||
public static class RememberedInventory {
|
public static class RememberedInventory implements IRememberedInventory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of items in the inventory
|
* The list of items in the inventory
|
||||||
@@ -179,11 +193,14 @@ public class MemoryBehavior extends Behavior {
|
|||||||
this.items = new ArrayList<>();
|
this.items = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return The list of items in the inventory
|
public final List<ItemStack> getContents() {
|
||||||
*/
|
|
||||||
public final List<ItemStack> getItems() {
|
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getSize() {
|
||||||
|
return this.size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.behavior;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.behavior.IMineBehavior;
|
||||||
|
import baritone.api.event.events.PathEvent;
|
||||||
|
import baritone.api.event.events.TickEvent;
|
||||||
|
import baritone.api.pathing.goals.Goal;
|
||||||
|
import baritone.cache.CachedChunk;
|
||||||
|
import baritone.cache.ChunkPacker;
|
||||||
|
import baritone.cache.WorldProvider;
|
||||||
|
import baritone.cache.WorldScanner;
|
||||||
|
import baritone.api.pathing.goals.GoalBlock;
|
||||||
|
import baritone.api.pathing.goals.GoalComposite;
|
||||||
|
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||||
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.EmptyChunk;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mine blocks of a certain type
|
||||||
|
*
|
||||||
|
* @author leijurv
|
||||||
|
*/
|
||||||
|
public final class MineBehavior extends Behavior implements IMineBehavior, Helper {
|
||||||
|
|
||||||
|
public static final MineBehavior INSTANCE = new MineBehavior();
|
||||||
|
|
||||||
|
private List<Block> mining;
|
||||||
|
private List<BlockPos> locationsCache;
|
||||||
|
private int quantity;
|
||||||
|
|
||||||
|
private MineBehavior() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTick(TickEvent event) {
|
||||||
|
if (event.getType() == TickEvent.Type.OUT) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mining == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (quantity > 0) {
|
||||||
|
Item item = mining.get(0).getItemDropped(mining.get(0).getDefaultState(), new Random(), 0);
|
||||||
|
int curr = player().inventory.mainInventory.stream().filter(stack -> item.equals(stack.getItem())).mapToInt(ItemStack::getCount).sum();
|
||||||
|
System.out.println("Currently have " + curr + " " + item);
|
||||||
|
if (curr >= quantity) {
|
||||||
|
logDirect("Have " + curr + " " + item.getItemStackDisplayName(new ItemStack(item, 1)));
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get();
|
||||||
|
if (mineGoalUpdateInterval != 0) {
|
||||||
|
if (event.getCount() % mineGoalUpdateInterval == 0) {
|
||||||
|
Baritone.INSTANCE.getExecutor().execute(this::updateGoal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PathingBehavior.INSTANCE.revalidateGoal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPathEvent(PathEvent event) {
|
||||||
|
updateGoal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGoal() {
|
||||||
|
if (mining == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!locationsCache.isEmpty()) {
|
||||||
|
locationsCache = prune(new ArrayList<>(locationsCache), mining, 64);
|
||||||
|
PathingBehavior.INSTANCE.setGoal(coalesce(locationsCache));
|
||||||
|
PathingBehavior.INSTANCE.path();
|
||||||
|
}
|
||||||
|
List<BlockPos> locs = scanFor(mining, 64);
|
||||||
|
if (locs.isEmpty()) {
|
||||||
|
logDebug("No locations for " + mining + " known, cancelling");
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
locationsCache = locs;
|
||||||
|
PathingBehavior.INSTANCE.setGoal(coalesce(locs));
|
||||||
|
PathingBehavior.INSTANCE.path();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GoalComposite coalesce(List<BlockPos> locs) {
|
||||||
|
return new GoalComposite(locs.stream().map(loc -> {
|
||||||
|
if (!Baritone.settings().forceInternalMining.get()) {
|
||||||
|
return new GoalTwoBlocks(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR);
|
||||||
|
boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR);
|
||||||
|
if (upwardGoal) {
|
||||||
|
if (downwardGoal) {
|
||||||
|
return new GoalTwoBlocks(loc);
|
||||||
|
} else {
|
||||||
|
return new GoalBlock(loc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (downwardGoal) {
|
||||||
|
return new GoalBlock(loc.down());
|
||||||
|
} else {
|
||||||
|
return new GoalTwoBlocks(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).toArray(Goal[]::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockPos> scanFor(List<Block> mining, int max) {
|
||||||
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
|
List<Block> uninteresting = new ArrayList<>();
|
||||||
|
//long b = System.currentTimeMillis();
|
||||||
|
for (Block m : mining) {
|
||||||
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||||
|
locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, 1));
|
||||||
|
} else {
|
||||||
|
uninteresting.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms");
|
||||||
|
if (locs.isEmpty()) {
|
||||||
|
uninteresting = mining;
|
||||||
|
}
|
||||||
|
if (!uninteresting.isEmpty()) {
|
||||||
|
//long before = System.currentTimeMillis();
|
||||||
|
locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max, 10, 26));
|
||||||
|
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
||||||
|
}
|
||||||
|
return prune(locs, mining, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockPos> prune(List<BlockPos> locs, List<Block> mining, int max) {
|
||||||
|
BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet();
|
||||||
|
locs.sort(Comparator.comparingDouble(playerFeet::distanceSq));
|
||||||
|
|
||||||
|
// remove any that are within loaded chunks that aren't actually what we want
|
||||||
|
locs.removeAll(locs.stream()
|
||||||
|
.filter(pos -> !(MineBehavior.INSTANCE.world().getChunk(pos) instanceof EmptyChunk))
|
||||||
|
.filter(pos -> !mining.contains(BlockStateInterface.get(pos).getBlock()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
if (locs.size() > max) {
|
||||||
|
return locs.subList(0, max);
|
||||||
|
}
|
||||||
|
return locs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mine(int quantity, String... blocks) {
|
||||||
|
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList());
|
||||||
|
this.quantity = quantity;
|
||||||
|
this.locationsCache = new ArrayList<>();
|
||||||
|
updateGoal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mine(int quantity, Block... blocks) {
|
||||||
|
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
||||||
|
this.quantity = quantity;
|
||||||
|
this.locationsCache = new ArrayList<>();
|
||||||
|
updateGoal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
mine(0, (String[]) null);
|
||||||
|
PathingBehavior.INSTANCE.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
+95
-51
@@ -2,51 +2,55 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.behavior.IPathingBehavior;
|
||||||
import baritone.api.event.events.PathEvent;
|
import baritone.api.event.events.PathEvent;
|
||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.RenderEvent;
|
import baritone.api.event.events.RenderEvent;
|
||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.api.pathing.goals.Goal;
|
||||||
import baritone.pathing.calc.AStarPathFinder;
|
import baritone.pathing.calc.AStarPathFinder;
|
||||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||||
import baritone.pathing.calc.IPathFinder;
|
import baritone.pathing.calc.IPathFinder;
|
||||||
import baritone.pathing.goals.*;
|
import baritone.api.pathing.goals.GoalXZ;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.path.IPath;
|
import baritone.pathing.path.IPath;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
|
import baritone.utils.BlockBreakHelper;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.PathRenderer;
|
import baritone.utils.PathRenderer;
|
||||||
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
|
import baritone.utils.pathing.BetterBlockPos;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.EmptyChunk;
|
import net.minecraft.world.chunk.EmptyChunk;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PathingBehavior extends Behavior {
|
public final class PathingBehavior extends Behavior implements IPathingBehavior, Helper {
|
||||||
|
|
||||||
public static final PathingBehavior INSTANCE = new PathingBehavior();
|
public static final PathingBehavior INSTANCE = new PathingBehavior();
|
||||||
|
|
||||||
private PathingBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private PathExecutor current;
|
private PathExecutor current;
|
||||||
private PathExecutor next;
|
private PathExecutor next;
|
||||||
|
|
||||||
@@ -59,8 +63,10 @@ public class PathingBehavior extends Behavior {
|
|||||||
|
|
||||||
private boolean lastAutoJump;
|
private boolean lastAutoJump;
|
||||||
|
|
||||||
|
private PathingBehavior() {}
|
||||||
|
|
||||||
private void dispatchPathEvent(PathEvent event) {
|
private void dispatchPathEvent(PathEvent event) {
|
||||||
new Thread(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event)).start();
|
Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,6 +75,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mc.playerController.setPlayerCapabilities(mc.player);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -77,14 +84,14 @@ public class PathingBehavior extends Behavior {
|
|||||||
if (current.failed() || current.finished()) {
|
if (current.failed() || current.finished()) {
|
||||||
current = null;
|
current = null;
|
||||||
if (goal == null || goal.isInGoal(playerFeet())) {
|
if (goal == null || goal.isInGoal(playerFeet())) {
|
||||||
displayChatMessageRaw("All done. At " + goal);
|
logDebug("All done. At " + goal);
|
||||||
dispatchPathEvent(PathEvent.AT_GOAL);
|
dispatchPathEvent(PathEvent.AT_GOAL);
|
||||||
next = null;
|
next = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (next != null && !next.getPath().positions().contains(playerFeet())) {
|
if (next != null && !next.getPath().positions().contains(playerFeet())) {
|
||||||
// if the current path failed, we may not actually be on the next one, so make sure
|
// if the current path failed, we may not actually be on the next one, so make sure
|
||||||
displayChatMessageRaw("Discarding next path as it does not contain current position");
|
logDebug("Discarding next path as it does not contain current position");
|
||||||
// for example if we had a nicely planned ahead path that starts where current ends
|
// for example if we had a nicely planned ahead path that starts where current ends
|
||||||
// that's all fine and good
|
// that's all fine and good
|
||||||
// but if we fail in the middle of current
|
// but if we fail in the middle of current
|
||||||
@@ -94,7 +101,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
displayChatMessageRaw("Continuing on to planned next path");
|
logDebug("Continuing on to planned next path");
|
||||||
dispatchPathEvent(PathEvent.CONTINUING_ONTO_PLANNED_NEXT);
|
dispatchPathEvent(PathEvent.CONTINUING_ONTO_PLANNED_NEXT);
|
||||||
current = next;
|
current = next;
|
||||||
next = null;
|
next = null;
|
||||||
@@ -118,7 +125,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
if (next != null) {
|
if (next != null) {
|
||||||
if (next.getPath().positions().contains(playerFeet())) {
|
if (next.getPath().positions().contains(playerFeet())) {
|
||||||
// jump directly onto the next path
|
// jump directly onto the next path
|
||||||
displayChatMessageRaw("Splicing into planned next path early...");
|
logDebug("Splicing into planned next path early...");
|
||||||
dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
|
dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
|
||||||
current = next;
|
current = next;
|
||||||
next = null;
|
next = null;
|
||||||
@@ -141,7 +148,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) {
|
if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) {
|
||||||
// and this path has 5 seconds or less left
|
// and this path has 5 seconds or less left
|
||||||
displayChatMessageRaw("Path almost over. Planning ahead...");
|
logDebug("Path almost over. Planning ahead...");
|
||||||
dispatchPathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
dispatchPathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
||||||
findPathInNewThread(current.getPath().getDest(), false, Optional.of(current.getPath()));
|
findPathInNewThread(current.getPath().getDest(), false, Optional.of(current.getPath()));
|
||||||
}
|
}
|
||||||
@@ -160,10 +167,13 @@ public class PathingBehavior extends Behavior {
|
|||||||
case POST:
|
case POST:
|
||||||
mc.gameSettings.autoJump = lastAutoJump;
|
mc.gameSettings.autoJump = lastAutoJump;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Optional<Double> ticksRemainingInSegment() {
|
public Optional<Double> ticksRemainingInSegment() {
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -171,10 +181,12 @@ public class PathingBehavior extends Behavior {
|
|||||||
return Optional.of(current.getPath().ticksRemainingFrom(current.getPosition()));
|
return Optional.of(current.getPath().ticksRemainingFrom(current.getPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setGoal(Goal goal) {
|
public void setGoal(Goal goal) {
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Goal getGoal() {
|
public Goal getGoal() {
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
@@ -187,15 +199,30 @@ public class PathingBehavior extends Behavior {
|
|||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Expose this method in the API?
|
||||||
|
// In order to do so, we'd need to move over IPath which has a whole lot of references to other
|
||||||
|
// things that may not need to be exposed necessarily, so we'll need to figure that out.
|
||||||
public Optional<IPath> getPath() {
|
public Optional<IPath> getPath() {
|
||||||
return Optional.ofNullable(current).map(PathExecutor::getPath);
|
return Optional.ofNullable(current).map(PathExecutor::getPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPathing() {
|
||||||
|
return this.current != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
dispatchPathEvent(PathEvent.CANCELED);
|
||||||
current = null;
|
current = null;
|
||||||
next = null;
|
next = null;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel);
|
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel);
|
||||||
|
BlockBreakHelper.stopBreakingBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceCancel() { // NOT exposed on public api
|
||||||
|
isPathCalcInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,6 +230,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
*
|
*
|
||||||
* @return true if this call started path calculation, false if it was already calculating or executing a path
|
* @return true if this call started path calculation, false if it was already calculating or executing a path
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean path() {
|
public boolean path() {
|
||||||
if (goal == null) {
|
if (goal == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -225,8 +253,11 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos pathStart() {
|
/**
|
||||||
BlockPos feet = playerFeet();
|
* @return The starting {@link BlockPos} for a new path
|
||||||
|
*/
|
||||||
|
private BlockPos pathStart() {
|
||||||
|
BetterBlockPos feet = playerFeet();
|
||||||
if (BlockStateInterface.get(feet.down()).getBlock().equals(Blocks.AIR) && MovementHelper.canWalkOn(feet.down().down())) {
|
if (BlockStateInterface.get(feet.down()).getBlock().equals(Blocks.AIR) && MovementHelper.canWalkOn(feet.down().down())) {
|
||||||
return feet.down();
|
return feet.down();
|
||||||
}
|
}
|
||||||
@@ -246,9 +277,9 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
isPathCalcInProgress = true;
|
isPathCalcInProgress = true;
|
||||||
}
|
}
|
||||||
new Thread(() -> {
|
Baritone.INSTANCE.getExecutor().execute(() -> {
|
||||||
if (talkAboutIt) {
|
if (talkAboutIt) {
|
||||||
displayChatMessageRaw("Starting to search for path from " + start + " to " + goal);
|
logDebug("Starting to search for path from " + start + " to " + goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<IPath> path = findPath(start, previous);
|
Optional<IPath> path = findPath(start, previous);
|
||||||
@@ -280,16 +311,16 @@ public class PathingBehavior extends Behavior {
|
|||||||
|
|
||||||
if (talkAboutIt && current != null && current.getPath() != null) {
|
if (talkAboutIt && current != null && current.getPath() != null) {
|
||||||
if (goal == null || goal.isInGoal(current.getPath().getDest())) {
|
if (goal == null || goal.isInGoal(current.getPath().getDest())) {
|
||||||
displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
logDebug("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
||||||
} else {
|
} else {
|
||||||
displayChatMessageRaw("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
logDebug("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized (pathCalcLock) {
|
synchronized (pathCalcLock) {
|
||||||
isPathCalcInProgress = false;
|
isPathCalcInProgress = false;
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,26 +332,18 @@ public class PathingBehavior extends Behavior {
|
|||||||
private Optional<IPath> findPath(BlockPos start, Optional<IPath> previous) {
|
private Optional<IPath> findPath(BlockPos start, Optional<IPath> previous) {
|
||||||
Goal goal = this.goal;
|
Goal goal = this.goal;
|
||||||
if (goal == null) {
|
if (goal == null) {
|
||||||
displayChatMessageRaw("no goal");
|
logDebug("no goal");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
if (Baritone.settings().simplifyUnloadedYCoord.get()) {
|
if (Baritone.settings().simplifyUnloadedYCoord.get()) {
|
||||||
BlockPos pos = null;
|
BlockPos pos = null;
|
||||||
if (goal instanceof GoalBlock) {
|
if (goal instanceof IGoalRenderPos) {
|
||||||
pos = ((GoalBlock) goal).getGoalPos();
|
pos = ((IGoalRenderPos) goal).getGoalPos();
|
||||||
}
|
|
||||||
if (goal instanceof GoalTwoBlocks) {
|
|
||||||
pos = ((GoalTwoBlocks) goal).getGoalPos();
|
|
||||||
}
|
|
||||||
if (goal instanceof GoalNear) {
|
|
||||||
pos = ((GoalNear) goal).getGoalPos();
|
|
||||||
}
|
|
||||||
if (goal instanceof GoalGetToBlock) {
|
|
||||||
pos = ((GoalGetToBlock) goal).getGoalPos();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO simplify each individual goal in a GoalComposite
|
// TODO simplify each individual goal in a GoalComposite
|
||||||
if (pos != null && world().getChunk(pos) instanceof EmptyChunk) {
|
if (pos != null && world().getChunk(pos) instanceof EmptyChunk) {
|
||||||
displayChatMessageRaw("Simplifying " + goal.getClass() + " to GoalXZ due to distance");
|
logDebug("Simplifying " + goal.getClass() + " to GoalXZ due to distance");
|
||||||
goal = new GoalXZ(pos.getX(), pos.getZ());
|
goal = new GoalXZ(pos.getX(), pos.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,29 +353,46 @@ public class PathingBehavior extends Behavior {
|
|||||||
} else {
|
} else {
|
||||||
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
|
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
|
||||||
}
|
}
|
||||||
|
Optional<HashSet<Long>> favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC
|
||||||
try {
|
try {
|
||||||
IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions));
|
IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions);
|
||||||
return pf.calculate(timeout);
|
return pf.calculate(timeout);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
displayChatMessageRaw("Pathing exception: " + e);
|
logDebug("Pathing exception: " + e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void revalidateGoal() {
|
||||||
|
if (!Baritone.settings().cancelOnGoalInvalidation.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (current == null || goal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Goal intended = current.getPath().getGoal();
|
||||||
|
BlockPos end = current.getPath().getDest();
|
||||||
|
if (intended.isInGoal(end) && !goal.isInGoal(end)) {
|
||||||
|
// this path used to end in the goal
|
||||||
|
// but the goal has changed, so there's no reason to continue...
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderPass(RenderEvent event) {
|
public void onRenderPass(RenderEvent event) {
|
||||||
// System.out.println("Render passing");
|
// System.out.println("Render passing");
|
||||||
// System.out.println(event.getPartialTicks());
|
// System.out.println(event.getPartialTicks());
|
||||||
float partialTicks = event.getPartialTicks();
|
float partialTicks = event.getPartialTicks();
|
||||||
if (goal != null && Baritone.settings().renderGoal.value) {
|
if (goal != null && Baritone.settings().renderGoal.value) {
|
||||||
PathRenderer.drawLitDankGoalBox(player(), goal, partialTicks, Color.GREEN);
|
PathRenderer.drawLitDankGoalBox(player(), goal, partialTicks, Baritone.settings().colorGoalBox.get());
|
||||||
}
|
}
|
||||||
if (!Baritone.settings().renderPath.get()) {
|
if (!Baritone.settings().renderPath.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long start = System.nanoTime();
|
//long start = System.nanoTime();
|
||||||
|
|
||||||
|
|
||||||
PathExecutor current = this.current; // this should prevent most race conditions?
|
PathExecutor current = this.current; // this should prevent most race conditions?
|
||||||
@@ -363,35 +403,39 @@ public class PathingBehavior extends Behavior {
|
|||||||
// Render the current path, if there is one
|
// Render the current path, if there is one
|
||||||
if (current != null && current.getPath() != null) {
|
if (current != null && current.getPath() != null) {
|
||||||
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
||||||
PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Color.RED, Baritone.settings().fadePath.get(), 10, 20);
|
PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Baritone.settings().colorCurrentPath.get(), Baritone.settings().fadePath.get(), 10, 20);
|
||||||
}
|
}
|
||||||
if (next != null && next.getPath() != null) {
|
if (next != null && next.getPath() != null) {
|
||||||
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.MAGENTA, Baritone.settings().fadePath.get(), 10, 20);
|
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Baritone.settings().colorNextPath.get(), Baritone.settings().fadePath.get(), 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
long split = System.nanoTime();
|
//long split = System.nanoTime();
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
PathRenderer.drawManySelectionBoxes(player(), current.toBreak(), partialTicks, Color.RED);
|
PathRenderer.drawManySelectionBoxes(player(), current.toBreak(), partialTicks, Baritone.settings().colorBlocksToBreak.get());
|
||||||
PathRenderer.drawManySelectionBoxes(player(), current.toPlace(), partialTicks, Color.GREEN);
|
PathRenderer.drawManySelectionBoxes(player(), current.toPlace(), partialTicks, Baritone.settings().colorBlocksToPlace.get());
|
||||||
PathRenderer.drawManySelectionBoxes(player(), current.toWalkInto(), partialTicks, Color.MAGENTA);
|
PathRenderer.drawManySelectionBoxes(player(), current.toWalkInto(), partialTicks, Baritone.settings().colorBlocksToWalkInto.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a path calculation currently running, render the path calculation process
|
// If there is a path calculation currently running, render the path calculation process
|
||||||
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(currentlyRunning -> {
|
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(currentlyRunning -> {
|
||||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||||
PathRenderer.drawPath(p, 0, player(), partialTicks, Color.BLUE, Baritone.settings().fadePath.get(), 10, 20);
|
PathRenderer.drawPath(p, 0, player(), partialTicks, Baritone.settings().colorBestPathSoFar.get(), Baritone.settings().fadePath.get(), 10, 20);
|
||||||
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
||||||
|
|
||||||
PathRenderer.drawPath(mr, 0, player(), partialTicks, Color.CYAN, Baritone.settings().fadePath.get(), 10, 20);
|
PathRenderer.drawPath(mr, 0, player(), partialTicks, Baritone.settings().colorMostRecentConsidered.get(), Baritone.settings().fadePath.get(), 10, 20);
|
||||||
PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Color.CYAN);
|
PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Baritone.settings().colorMostRecentConsidered.get());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
long end = System.nanoTime();
|
//long end = System.nanoTime();
|
||||||
//System.out.println((end - split) + " " + (split - start));
|
//System.out.println((end - split) + " " + (split - start));
|
||||||
// if (end - start > 0) {
|
// if (end - start > 0) {
|
||||||
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
||||||
//}
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,60 +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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
|
||||||
|
|
||||||
import baritone.api.event.events.TickEvent;
|
|
||||||
import baritone.behavior.Behavior;
|
|
||||||
import baritone.pathing.goals.GoalNear;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Follow an entity
|
|
||||||
*
|
|
||||||
* @author leijurv
|
|
||||||
*/
|
|
||||||
public class FollowBehavior extends Behavior {
|
|
||||||
public static final FollowBehavior INSTANCE = new FollowBehavior();
|
|
||||||
|
|
||||||
private FollowBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity following;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTick(TickEvent event) {
|
|
||||||
if (event.getType() == TickEvent.Type.OUT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (following == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// lol this is trashy but it works
|
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(following), 3));
|
|
||||||
PathingBehavior.INSTANCE.path();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void follow(Entity follow) {
|
|
||||||
this.following = follow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancel() {
|
|
||||||
PathingBehavior.INSTANCE.cancel();
|
|
||||||
follow(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,111 +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 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.behavior.impl;
|
|
||||||
|
|
||||||
import baritone.api.event.events.PathEvent;
|
|
||||||
import baritone.behavior.Behavior;
|
|
||||||
import baritone.chunk.CachedChunk;
|
|
||||||
import baritone.chunk.ChunkPacker;
|
|
||||||
import baritone.chunk.WorldProvider;
|
|
||||||
import baritone.chunk.WorldScanner;
|
|
||||||
import baritone.pathing.goals.Goal;
|
|
||||||
import baritone.pathing.goals.GoalComposite;
|
|
||||||
import baritone.pathing.goals.GoalTwoBlocks;
|
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.chunk.EmptyChunk;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mine blocks of a certain type
|
|
||||||
*
|
|
||||||
* @author leijurv
|
|
||||||
*/
|
|
||||||
public class MineBehavior extends Behavior {
|
|
||||||
public static final MineBehavior INSTANCE = new MineBehavior();
|
|
||||||
|
|
||||||
private MineBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> mining;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPathEvent(PathEvent event) {
|
|
||||||
updateGoal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateGoal() {
|
|
||||||
if (mining == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<BlockPos> locs = scanFor(mining, 64);
|
|
||||||
if (locs.isEmpty()) {
|
|
||||||
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
|
|
||||||
cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new)));
|
|
||||||
PathingBehavior.INSTANCE.path();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BlockPos> scanFor(List<String> mining, int max) {
|
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
|
||||||
List<String> uninteresting = new ArrayList<>();
|
|
||||||
//long b = System.currentTimeMillis();
|
|
||||||
for (String m : mining) {
|
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(ChunkPacker.stringToBlock(m))) {
|
|
||||||
locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1));
|
|
||||||
} else {
|
|
||||||
uninteresting.add(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms");
|
|
||||||
if (!uninteresting.isEmpty()) {
|
|
||||||
//long before = System.currentTimeMillis();
|
|
||||||
locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max));
|
|
||||||
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
|
||||||
}
|
|
||||||
BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet();
|
|
||||||
locs.sort(Comparator.comparingDouble(playerFeet::distanceSq));
|
|
||||||
|
|
||||||
// remove any that are within loaded chunks that aren't actually what we want
|
|
||||||
locs.removeAll(locs.stream()
|
|
||||||
.filter(pos -> !(MineBehavior.INSTANCE.world().getChunk(pos) instanceof EmptyChunk))
|
|
||||||
.filter(pos -> !mining.contains(ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).toLowerCase()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
if (locs.size() > max) {
|
|
||||||
locs = locs.subList(0, max);
|
|
||||||
}
|
|
||||||
return locs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mine(String... mining) {
|
|
||||||
this.mining = mining == null || mining.length == 0 ? null : new ArrayList<>(Arrays.asList(mining));
|
|
||||||
updateGoal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancel() {
|
|
||||||
PathingBehavior.INSTANCE.cancel();
|
|
||||||
mine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
+16
-11
@@ -2,22 +2,23 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.utils.pathing.IBlockTypeAccess;
|
import baritone.api.cache.IBlockTypeAccess;
|
||||||
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@@ -30,7 +31,7 @@ import java.util.*;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/3/2018 1:04 AM
|
* @since 8/3/2018 1:04 AM
|
||||||
*/
|
*/
|
||||||
public final class CachedChunk implements IBlockTypeAccess {
|
public final class CachedChunk implements IBlockTypeAccess, Helper {
|
||||||
|
|
||||||
public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(new HashSet<Block>() {{
|
public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(new HashSet<Block>() {{
|
||||||
add(Blocks.DIAMOND_ORE);
|
add(Blocks.DIAMOND_ORE);
|
||||||
@@ -63,6 +64,8 @@ public final class CachedChunk implements IBlockTypeAccess {
|
|||||||
add(Blocks.DRAGON_EGG);
|
add(Blocks.DRAGON_EGG);
|
||||||
add(Blocks.JUKEBOX);
|
add(Blocks.JUKEBOX);
|
||||||
add(Blocks.END_GATEWAY);
|
add(Blocks.END_GATEWAY);
|
||||||
|
add(Blocks.WEB);
|
||||||
|
add(Blocks.NETHER_WART);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,13 +100,13 @@ public final class CachedChunk implements IBlockTypeAccess {
|
|||||||
/**
|
/**
|
||||||
* The block names of each surface level block for generating an overview
|
* The block names of each surface level block for generating an overview
|
||||||
*/
|
*/
|
||||||
private final String[] overview;
|
private final IBlockState[] overview;
|
||||||
|
|
||||||
private final int[] heightMap;
|
private final int[] heightMap;
|
||||||
|
|
||||||
private final Map<String, List<BlockPos>> specialBlockLocations;
|
private final Map<String, List<BlockPos>> specialBlockLocations;
|
||||||
|
|
||||||
CachedChunk(int x, int z, BitSet data, String[] overview, Map<String, List<BlockPos>> specialBlockLocations) {
|
CachedChunk(int x, int z, BitSet data, IBlockState[] overview, Map<String, List<BlockPos>> specialBlockLocations) {
|
||||||
validateSize(data);
|
validateSize(data);
|
||||||
|
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -120,14 +123,16 @@ public final class CachedChunk implements IBlockTypeAccess {
|
|||||||
int internalPos = z << 4 | x;
|
int internalPos = z << 4 | x;
|
||||||
if (heightMap[internalPos] == y) {
|
if (heightMap[internalPos] == y) {
|
||||||
// we have this exact block, it's a surface block
|
// we have this exact block, it's a surface block
|
||||||
IBlockState state = ChunkPacker.stringToBlock(overview[internalPos]).getDefaultState();
|
|
||||||
/*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state);
|
/*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state);
|
||||||
if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) {
|
if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) {
|
||||||
throw new IllegalStateException("failed " + Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16));
|
throw new IllegalStateException("failed " + Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16));
|
||||||
}*/
|
}*/
|
||||||
return state;
|
return overview[internalPos];
|
||||||
}
|
}
|
||||||
PathingBlockType type = getType(x, y, z);
|
PathingBlockType type = getType(x, y, z);
|
||||||
|
if (type == PathingBlockType.SOLID && y == 127 && mc.player.dimension == -1) {
|
||||||
|
return Blocks.BEDROCK.getDefaultState();
|
||||||
|
}
|
||||||
return ChunkPacker.pathingTypeToBlock(type);
|
return ChunkPacker.pathingTypeToBlock(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +157,7 @@ public final class CachedChunk implements IBlockTypeAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String[] getOverview() {
|
public final IBlockState[] getOverview() {
|
||||||
return overview;
|
return overview;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vendored
+14
-10
@@ -2,22 +2,22 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.utils.pathing.IBlockTypeAccess;
|
import baritone.api.cache.ICachedRegion;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -33,7 +33,8 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/3/2018 9:35 PM
|
* @since 8/3/2018 9:35 PM
|
||||||
*/
|
*/
|
||||||
public final class CachedRegion implements IBlockTypeAccess {
|
public final class CachedRegion implements ICachedRegion {
|
||||||
|
|
||||||
private static final byte CHUNK_NOT_PRESENT = 0;
|
private static final byte CHUNK_NOT_PRESENT = 0;
|
||||||
private static final byte CHUNK_PRESENT = 1;
|
private static final byte CHUNK_PRESENT = 1;
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean isCached(int x, int z) {
|
public final boolean isCached(int x, int z) {
|
||||||
return chunks[x >> 4][z >> 4] != null;
|
return chunks[x >> 4][z >> 4] != null;
|
||||||
}
|
}
|
||||||
@@ -100,7 +102,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
final synchronized void updateCachedChunk(int chunkX, int chunkZ, CachedChunk chunk) {
|
public final synchronized void updateCachedChunk(int chunkX, int chunkZ, CachedChunk chunk) {
|
||||||
this.chunks[chunkX][chunkZ] = chunk;
|
this.chunks[chunkX][chunkZ] = chunk;
|
||||||
hasUnsavedChanges = true;
|
hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
@@ -145,7 +147,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
for (int x = 0; x < 32; x++) {
|
for (int x = 0; x < 32; x++) {
|
||||||
if (chunks[x][z] != null) {
|
if (chunks[x][z] != null) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
out.writeUTF(chunks[x][z].getOverview()[i]);
|
out.writeUTF(ChunkPacker.blockToString(chunks[x][z].getOverview()[i].getBlock()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,7 +217,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
int regionZ = this.z;
|
int regionZ = this.z;
|
||||||
int chunkX = x + 32 * regionX;
|
int chunkX = x + 32 * regionX;
|
||||||
int chunkZ = z + 32 * regionZ;
|
int chunkZ = z + 32 * regionZ;
|
||||||
tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new String[256], location[x][z]);
|
tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new IBlockState[256], location[x][z]);
|
||||||
break;
|
break;
|
||||||
case CHUNK_NOT_PRESENT:
|
case CHUNK_NOT_PRESENT:
|
||||||
tmpCached[x][z] = null;
|
tmpCached[x][z] = null;
|
||||||
@@ -229,7 +231,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
for (int x = 0; x < 32; x++) {
|
for (int x = 0; x < 32; x++) {
|
||||||
if (tmpCached[x][z] != null) {
|
if (tmpCached[x][z] != null) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
tmpCached[x][z].getOverview()[i] = in.readUTF();
|
tmpCached[x][z].getOverview()[i] = ChunkPacker.stringToBlock(in.readUTF()).getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,6 +282,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
/**
|
/**
|
||||||
* @return The region x coordinate
|
* @return The region x coordinate
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getX() {
|
public final int getX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
@@ -287,6 +290,7 @@ public final class CachedRegion implements IBlockTypeAccess {
|
|||||||
/**
|
/**
|
||||||
* @return The region z coordinate
|
* @return The region z coordinate
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getZ() {
|
public final int getZ() {
|
||||||
return this.z;
|
return this.z;
|
||||||
}
|
}
|
||||||
Vendored
+24
-38
@@ -2,26 +2,26 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.utils.pathing.IBlockTypeAccess;
|
import baritone.api.cache.ICachedWorld;
|
||||||
|
import baritone.utils.Helper;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 12:02 AM
|
* @since 8/4/2018 12:02 AM
|
||||||
*/
|
*/
|
||||||
public final class CachedWorld implements IBlockTypeAccess {
|
public final class CachedWorld implements ICachedWorld, Helper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of regions in any direction from (0,0)
|
* The maximum number of regions in any direction from (0,0)
|
||||||
@@ -67,8 +67,8 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
System.out.println("Cached world directory: " + directory);
|
System.out.println("Cached world directory: " + directory);
|
||||||
// Insert an invalid region element
|
// Insert an invalid region element
|
||||||
cachedRegions.put(0, null);
|
cachedRegions.put(0, null);
|
||||||
new PackerThread().start();
|
Baritone.INSTANCE.getExecutor().execute(new PackerThread());
|
||||||
new Thread(() -> {
|
Baritone.INSTANCE.getExecutor().execute(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -81,9 +81,10 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void queueForPacking(Chunk chunk) {
|
public final void queueForPacking(Chunk chunk) {
|
||||||
try {
|
try {
|
||||||
toPack.put(chunk);
|
toPack.put(chunk);
|
||||||
@@ -93,27 +94,16 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final IBlockState getBlock(int x, int y, int z) {
|
public final boolean isCached(int blockX, int blockZ) {
|
||||||
// no point in doing getOrCreate region, if we don't have it we don't have it
|
CachedRegion region = getRegion(blockX >> 9, blockZ >> 9);
|
||||||
CachedRegion region = getRegion(x >> 9, z >> 9);
|
|
||||||
if (region == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return region.getBlock(x & 511, y, z & 511);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isCached(BlockPos pos) {
|
|
||||||
int x = pos.getX();
|
|
||||||
int z = pos.getZ();
|
|
||||||
CachedRegion region = getRegion(x >> 9, z >> 9);
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return region.isCached(x & 511, z & 511);
|
return region.isCached(blockX & 511, blockZ & 511);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final LinkedList<BlockPos> getLocationsOf(String block, int minimum, int maxRegionDistanceSq) {
|
public final LinkedList<BlockPos> getLocationsOf(String block, int maximum, int maxRegionDistanceSq) {
|
||||||
LinkedList<BlockPos> res = new LinkedList<>();
|
LinkedList<BlockPos> res = new LinkedList<>();
|
||||||
int playerRegionX = playerFeet().getX() >> 9;
|
int playerRegionX = playerFeet().getX() >> 9;
|
||||||
int playerRegionZ = playerFeet().getZ() >> 9;
|
int playerRegionZ = playerFeet().getZ() >> 9;
|
||||||
@@ -130,13 +120,12 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
int regionZ = zoff + playerRegionZ;
|
int regionZ = zoff + playerRegionZ;
|
||||||
CachedRegion region = getOrCreateRegion(regionX, regionZ);
|
CachedRegion region = getOrCreateRegion(regionX, regionZ);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
for (BlockPos pos : region.getLocationsOf(block)) {
|
// TODO: 100% verify if this or addAll is faster.
|
||||||
res.add(pos);
|
region.getLocationsOf(block).forEach(res::add);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.size() >= minimum) {
|
if (res.size() >= maximum) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
searchRadius++;
|
searchRadius++;
|
||||||
@@ -149,6 +138,7 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
region.updateCachedChunk(chunk.x & 31, chunk.z & 31, chunk);
|
region.updateCachedChunk(chunk.x & 31, chunk.z & 31, chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void save() {
|
public final void save() {
|
||||||
if (!Baritone.settings().chunkCaching.get()) {
|
if (!Baritone.settings().chunkCaching.get()) {
|
||||||
System.out.println("Not saving to disk; chunk caching is disabled.");
|
System.out.println("Not saving to disk; chunk caching is disabled.");
|
||||||
@@ -168,6 +158,7 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
return new ArrayList<>(this.cachedRegions.values());
|
return new ArrayList<>(this.cachedRegions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void reloadAllFromDisk() {
|
public final void reloadAllFromDisk() {
|
||||||
long start = System.nanoTime() / 1000000L;
|
long start = System.nanoTime() / 1000000L;
|
||||||
allRegions().forEach(region -> {
|
allRegions().forEach(region -> {
|
||||||
@@ -179,13 +170,7 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
System.out.println("World load took " + (now - start) + "ms");
|
System.out.println("World load took " + (now - start) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns the region at the specified region coordinates
|
|
||||||
*
|
|
||||||
* @param regionX The region X coordinate
|
|
||||||
* @param regionZ The region Z coordinate
|
|
||||||
* @return The region located at the specified coordinates
|
|
||||||
*/
|
|
||||||
public final synchronized CachedRegion getRegion(int regionX, int regionZ) {
|
public final synchronized CachedRegion getRegion(int regionX, int regionZ) {
|
||||||
return cachedRegions.get(getRegionID(regionX, regionZ));
|
return cachedRegions.get(getRegionID(regionX, regionZ));
|
||||||
}
|
}
|
||||||
@@ -233,9 +218,10 @@ public final class CachedWorld implements IBlockTypeAccess {
|
|||||||
return regionX <= REGION_MAX && regionX >= -REGION_MAX && regionZ <= REGION_MAX && regionZ >= -REGION_MAX;
|
return regionX <= REGION_MAX && regionX >= -REGION_MAX && regionZ <= REGION_MAX && regionZ >= -REGION_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PackerThread extends Thread {
|
private class PackerThread implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
// TODO: Add CachedWorld unloading to remove the redundancy of having this
|
||||||
LinkedBlockingQueue<Chunk> queue = toPack;
|
LinkedBlockingQueue<Chunk> queue = toPack;
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
break;
|
break;
|
||||||
Vendored
+38
-63
@@ -2,20 +2,20 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
@@ -42,24 +42,8 @@ public final class ChunkPacker implements Helper {
|
|||||||
|
|
||||||
private ChunkPacker() {}
|
private ChunkPacker() {}
|
||||||
|
|
||||||
private static BitSet originalPacker(Chunk chunk) {
|
|
||||||
BitSet bitSet = new BitSet(CachedChunk.SIZE);
|
|
||||||
for (int y = 0; y < 256; y++) {
|
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
int index = CachedChunk.getPositionIndex(x, y, z);
|
|
||||||
IBlockState state = chunk.getBlockState(x, y, z);
|
|
||||||
boolean[] bits = getPathingBlockType(state).getBits();
|
|
||||||
bitSet.set(index, bits[0]);
|
|
||||||
bitSet.set(index + 1, bits[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bitSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CachedChunk pack(Chunk chunk) {
|
public static CachedChunk pack(Chunk chunk) {
|
||||||
long start = System.nanoTime() / 1000000L;
|
//long start = System.nanoTime() / 1000000L;
|
||||||
|
|
||||||
Map<String, List<BlockPos>> specialBlocks = new HashMap<>();
|
Map<String, List<BlockPos>> specialBlocks = new HashMap<>();
|
||||||
BitSet bitSet = new BitSet(CachedChunk.SIZE);
|
BitSet bitSet = new BitSet(CachedChunk.SIZE);
|
||||||
@@ -100,32 +84,29 @@ public final class ChunkPacker implements Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if (!bitSet.equals(originalPacker(chunk))) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}*/
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//System.out.println("Packed special blocks: " + specialBlocks);
|
//long end = System.nanoTime() / 1000000L;
|
||||||
long end = System.nanoTime() / 1000000L;
|
|
||||||
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
|
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
|
||||||
String[] blockNames = new String[256];
|
IBlockState[] blocks = new IBlockState[256];
|
||||||
|
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
outerLoop:
|
// @formatter:off
|
||||||
|
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
||||||
|
// @formatter:on
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int y = 255; y >= 0; y--) {
|
for (int y = 255; y >= 0; y--) {
|
||||||
int index = CachedChunk.getPositionIndex(x, y, z);
|
int index = CachedChunk.getPositionIndex(x, y, z);
|
||||||
if (bitSet.get(index) || bitSet.get(index + 1)) {
|
if (bitSet.get(index) || bitSet.get(index + 1)) {
|
||||||
String name = blockToString(chunk.getBlockState(x, y, z).getBlock());
|
blocks[z << 4 | x] = chunk.getBlockState(x, y, z);
|
||||||
blockNames[z << 4 | x] = name;
|
continue https;
|
||||||
continue outerLoop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockNames[z << 4 | x] = "air";
|
blocks[z << 4 | x] = Blocks.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CachedChunk cached = new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks);
|
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks);
|
||||||
return cached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blockToString(Block block) {
|
public static String blockToString(Block block) {
|
||||||
@@ -139,10 +120,7 @@ public final class ChunkPacker implements Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Block stringToBlock(String name) {
|
public static Block stringToBlock(String name) {
|
||||||
if (!name.contains(":")) {
|
return Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
|
||||||
name = "minecraft:" + name;
|
|
||||||
}
|
|
||||||
return Block.getBlockFromName(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PathingBlockType getPathingBlockType(IBlockState state) {
|
private static PathingBlockType getPathingBlockType(IBlockState state) {
|
||||||
@@ -152,7 +130,7 @@ public final class ChunkPacker implements Helper {
|
|||||||
return PathingBlockType.WATER;
|
return PathingBlockType.WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || MovementHelper.isBottomSlab(state)) {
|
if (MovementHelper.avoidWalkingInto(block) || block == Blocks.FLOWING_WATER || MovementHelper.isBottomSlab(state)) {
|
||||||
return PathingBlockType.AVOID;
|
return PathingBlockType.AVOID;
|
||||||
}
|
}
|
||||||
// We used to do an AABB check here
|
// We used to do an AABB check here
|
||||||
@@ -166,30 +144,27 @@ public final class ChunkPacker implements Helper {
|
|||||||
return PathingBlockType.SOLID;
|
return PathingBlockType.SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IBlockState pathingTypeToBlock(PathingBlockType type) {
|
public static IBlockState pathingTypeToBlock(PathingBlockType type) {
|
||||||
if (type != null) {
|
switch (type) {
|
||||||
switch (type) {
|
case AIR:
|
||||||
case AIR:
|
return Blocks.AIR.getDefaultState();
|
||||||
return Blocks.AIR.getDefaultState();
|
case WATER:
|
||||||
case WATER:
|
return Blocks.WATER.getDefaultState();
|
||||||
return Blocks.WATER.getDefaultState();
|
case AVOID:
|
||||||
case AVOID:
|
return Blocks.LAVA.getDefaultState();
|
||||||
return Blocks.LAVA.getDefaultState();
|
case SOLID:
|
||||||
case SOLID:
|
// Dimension solid types
|
||||||
// Dimension solid types
|
switch (mc.player.dimension) {
|
||||||
switch (mc.player.dimension) {
|
case -1:
|
||||||
case -1:
|
return Blocks.NETHERRACK.getDefaultState();
|
||||||
return Blocks.NETHERRACK.getDefaultState();
|
case 0:
|
||||||
case 0:
|
default: // The fallback solid type
|
||||||
return Blocks.STONE.getDefaultState();
|
return Blocks.STONE.getDefaultState();
|
||||||
case 1:
|
case 1:
|
||||||
return Blocks.END_STONE.getDefaultState();
|
return Blocks.END_STONE.getDefaultState();
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
// The fallback solid type
|
return null;
|
||||||
return Blocks.STONE.getDefaultState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+48
-42
@@ -2,91 +2,97 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import baritone.api.cache.IWaypoint;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single waypoint
|
* Basic implementation of {@link IWaypoint}
|
||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class Waypoint {
|
public class Waypoint implements IWaypoint {
|
||||||
|
|
||||||
public final String name;
|
private final String name;
|
||||||
public final Tag tag;
|
private final Tag tag;
|
||||||
private final long creationTimestamp;
|
private final long creationTimestamp;
|
||||||
public final BlockPos location;
|
private final BlockPos location;
|
||||||
|
|
||||||
public Waypoint(String name, Tag tag, BlockPos location) {
|
public Waypoint(String name, Tag tag, BlockPos location) {
|
||||||
this(name, tag, location, System.currentTimeMillis());
|
this(name, tag, location, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) { // read from disk
|
/**
|
||||||
|
* Constructor called when a Waypoint is read from disk, adds the creationTimestamp
|
||||||
|
* as a parameter so that it is reserved after a waypoint is wrote to the disk.
|
||||||
|
*
|
||||||
|
* @param name The waypoint name
|
||||||
|
* @param tag The waypoint tag
|
||||||
|
* @param location The waypoint location
|
||||||
|
* @param creationTimestamp When the waypoint was created
|
||||||
|
*/
|
||||||
|
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.creationTimestamp = creationTimestamp;
|
this.creationTimestamp = creationTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!(o instanceof Waypoint)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Waypoint w = (Waypoint) o;
|
|
||||||
return name.equals(w.name) && tag == w.tag && location.equals(w.location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
|
return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
|
||||||
}
|
}
|
||||||
|
|
||||||
public long creationTimestamp() {
|
@Override
|
||||||
return creationTimestamp;
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tag getTag() {
|
||||||
|
return this.tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCreationTimestamp() {
|
||||||
|
return this.creationTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos getLocation() {
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + " " + location.toString() + " " + new Date(creationTimestamp).toString();
|
return name + " " + location.toString() + " " + new Date(creationTimestamp).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Tag {
|
@Override
|
||||||
HOME("home", "base"),
|
public boolean equals(Object o) {
|
||||||
DEATH("death"),
|
if (o == null) {
|
||||||
BED("bed", "spawn"),
|
return false;
|
||||||
USER();
|
|
||||||
|
|
||||||
private static final List<Tag> TAG_LIST = ImmutableList.<Tag>builder().add(Tag.values()).build();
|
|
||||||
|
|
||||||
private final String[] names;
|
|
||||||
|
|
||||||
Tag(String... names) {
|
|
||||||
this.names = names;
|
|
||||||
}
|
}
|
||||||
|
if (!(o instanceof IWaypoint)) {
|
||||||
public static Tag fromString(String name) {
|
return false;
|
||||||
return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null);
|
|
||||||
}
|
}
|
||||||
|
IWaypoint w = (IWaypoint) o;
|
||||||
|
return name.equals(w.getName()) && tag == w.getTag() && location.equals(w.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+48
-29
@@ -2,34 +2,37 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
|
import baritone.api.cache.IWaypoint;
|
||||||
|
import baritone.api.cache.IWaypointCollection;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waypoints for a world
|
* Waypoints for a world
|
||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class Waypoints {
|
public class Waypoints implements IWaypointCollection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic value to detect invalid waypoint files
|
* Magic value to detect invalid waypoint files
|
||||||
@@ -37,7 +40,7 @@ public class Waypoints {
|
|||||||
private static final long WAYPOINT_MAGIC_VALUE = 121977993584L; // good value
|
private static final long WAYPOINT_MAGIC_VALUE = 121977993584L; // good value
|
||||||
|
|
||||||
private final Path directory;
|
private final Path directory;
|
||||||
private final Map<Waypoint.Tag, Set<Waypoint>> waypoints;
|
private final Map<IWaypoint.Tag, Set<IWaypoint>> waypoints;
|
||||||
|
|
||||||
Waypoints(Path directory) {
|
Waypoints(Path directory) {
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
@@ -58,9 +61,9 @@ public class Waypoints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void load(Waypoint.Tag tag) {
|
private synchronized void load(Waypoint.Tag tag) {
|
||||||
waypoints.put(tag, new HashSet<>());
|
this.waypoints.put(tag, new HashSet<>());
|
||||||
|
|
||||||
Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4");
|
Path fileName = this.directory.resolve(tag.name().toLowerCase() + ".mp4");
|
||||||
if (!Files.exists(fileName)) {
|
if (!Files.exists(fileName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -82,44 +85,60 @@ public class Waypoints {
|
|||||||
int x = in.readInt();
|
int x = in.readInt();
|
||||||
int y = in.readInt();
|
int y = in.readInt();
|
||||||
int z = in.readInt();
|
int z = in.readInt();
|
||||||
waypoints.get(tag).add(new Waypoint(name, tag, new BlockPos(x, y, z), creationTimestamp));
|
this.waypoints.get(tag).add(new Waypoint(name, tag, new BlockPos(x, y, z), creationTimestamp));
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void save(Waypoint.Tag tag) {
|
private synchronized void save(Waypoint.Tag tag) {
|
||||||
Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4");
|
Path fileName = this.directory.resolve(tag.name().toLowerCase() + ".mp4");
|
||||||
try (
|
try (
|
||||||
FileOutputStream fileOut = new FileOutputStream(fileName.toFile());
|
FileOutputStream fileOut = new FileOutputStream(fileName.toFile());
|
||||||
BufferedOutputStream bufOut = new BufferedOutputStream(fileOut);
|
BufferedOutputStream bufOut = new BufferedOutputStream(fileOut);
|
||||||
DataOutputStream out = new DataOutputStream(bufOut)
|
DataOutputStream out = new DataOutputStream(bufOut)
|
||||||
) {
|
) {
|
||||||
out.writeLong(WAYPOINT_MAGIC_VALUE);
|
out.writeLong(WAYPOINT_MAGIC_VALUE);
|
||||||
out.writeLong(waypoints.get(tag).size());
|
out.writeLong(this.waypoints.get(tag).size());
|
||||||
for (Waypoint waypoint : waypoints.get(tag)) {
|
for (IWaypoint waypoint : this.waypoints.get(tag)) {
|
||||||
out.writeUTF(waypoint.name);
|
out.writeUTF(waypoint.getName());
|
||||||
out.writeLong(waypoint.creationTimestamp());
|
out.writeLong(waypoint.getCreationTimestamp());
|
||||||
out.writeInt(waypoint.location.getX());
|
out.writeInt(waypoint.getLocation().getX());
|
||||||
out.writeInt(waypoint.location.getY());
|
out.writeInt(waypoint.getLocation().getY());
|
||||||
out.writeInt(waypoint.location.getZ());
|
out.writeInt(waypoint.getLocation().getZ());
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Waypoint> getByTag(Waypoint.Tag tag) {
|
@Override
|
||||||
return Collections.unmodifiableSet(waypoints.get(tag));
|
public void addWaypoint(IWaypoint waypoint) {
|
||||||
}
|
|
||||||
|
|
||||||
public Waypoint getMostRecentByTag(Waypoint.Tag tag) {
|
|
||||||
// Find a waypoint of the given tag which has the greatest timestamp value, indicating the most recent
|
|
||||||
return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.creationTimestamp())).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addWaypoint(Waypoint waypoint) {
|
|
||||||
// no need to check for duplicate, because it's a Set not a List
|
// no need to check for duplicate, because it's a Set not a List
|
||||||
waypoints.get(waypoint.tag).add(waypoint);
|
if (waypoints.get(waypoint.getTag()).add(waypoint)) {
|
||||||
save(waypoint.tag);
|
save(waypoint.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeWaypoint(IWaypoint waypoint) {
|
||||||
|
if (waypoints.get(waypoint.getTag()).remove(waypoint)) {
|
||||||
|
save(waypoint.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWaypoint getMostRecentByTag(IWaypoint.Tag tag) {
|
||||||
|
// Find a waypoint of the given tag which has the greatest timestamp value, indicating the most recent
|
||||||
|
return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.getCreationTimestamp())).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<IWaypoint> getByTag(IWaypoint.Tag tag) {
|
||||||
|
return Collections.unmodifiableSet(this.waypoints.get(tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<IWaypoint> getAllWaypoints() {
|
||||||
|
return this.waypoints.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+26
-12
@@ -2,20 +2,25 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.cache.ICachedWorld;
|
||||||
|
import baritone.api.cache.IWaypointCollection;
|
||||||
|
import baritone.api.cache.IWorldData;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
@@ -24,9 +29,10 @@ import java.nio.file.Path;
|
|||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class WorldData {
|
public class WorldData implements IWorldData {
|
||||||
|
|
||||||
public final CachedWorld cache;
|
public final CachedWorld cache;
|
||||||
public final Waypoints waypoints;
|
private final Waypoints waypoints;
|
||||||
//public final MapData map;
|
//public final MapData map;
|
||||||
public final Path directory;
|
public final Path directory;
|
||||||
|
|
||||||
@@ -37,11 +43,19 @@ public class WorldData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onClose() {
|
void onClose() {
|
||||||
new Thread() {
|
Baritone.INSTANCE.getExecutor().execute(() -> {
|
||||||
public void run() {
|
System.out.println("Started saving the world in a new thread");
|
||||||
System.out.println("Started saving the world in a new thread");
|
cache.save();
|
||||||
cache.save();
|
});
|
||||||
}
|
}
|
||||||
}.start();
|
|
||||||
|
@Override
|
||||||
|
public ICachedWorld getCachedWorld() {
|
||||||
|
return this.cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWaypointCollection getWaypoints() {
|
||||||
|
return this.waypoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+7
-5
@@ -2,22 +2,23 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.cache.IWorldProvider;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.accessor.IAnvilChunkLoader;
|
import baritone.utils.accessor.IAnvilChunkLoader;
|
||||||
import baritone.utils.accessor.IChunkProviderServer;
|
import baritone.utils.accessor.IChunkProviderServer;
|
||||||
@@ -38,7 +39,7 @@ import java.util.function.Consumer;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 11:06 AM
|
* @since 8/4/2018 11:06 AM
|
||||||
*/
|
*/
|
||||||
public enum WorldProvider implements Helper {
|
public enum WorldProvider implements IWorldProvider, Helper {
|
||||||
|
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ public enum WorldProvider implements Helper {
|
|||||||
|
|
||||||
private WorldData currentWorld;
|
private WorldData currentWorld;
|
||||||
|
|
||||||
|
@Override
|
||||||
public final WorldData getCurrentWorld() {
|
public final WorldData getCurrentWorld() {
|
||||||
return this.currentWorld;
|
return this.currentWorld;
|
||||||
}
|
}
|
||||||
Vendored
+33
-16
@@ -2,20 +2,20 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.chunk;
|
package baritone.cache;
|
||||||
|
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -28,34 +28,47 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public enum WorldScanner implements Helper {
|
public enum WorldScanner implements Helper {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
public List<BlockPos> scanLoadedChunks(List<String> blockTypes, int max) {
|
/**
|
||||||
List<Block> asBlocks = blockTypes.stream().map(ChunkPacker::stringToBlock).collect(Collectors.toList());
|
* Scans the world, up to your render distance, for the specified blocks.
|
||||||
if (asBlocks.contains(null)) {
|
*
|
||||||
throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString());
|
* @param blocks The blocks to scan for
|
||||||
|
* @param max The maximum number of blocks to scan before cutoff
|
||||||
|
* @param yLevelThreshold If a block is found within this Y level, the current result will be
|
||||||
|
* returned, if the value is negative, then this condition doesn't apply.
|
||||||
|
* @param maxSearchRadius The maximum chunk search radius
|
||||||
|
* @return The matching block positions
|
||||||
|
*/
|
||||||
|
public List<BlockPos> scanLoadedChunks(List<Block> blocks, int max, int yLevelThreshold, int maxSearchRadius) {
|
||||||
|
if (blocks.contains(null)) {
|
||||||
|
throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString());
|
||||||
}
|
}
|
||||||
LinkedList<BlockPos> res = new LinkedList<>();
|
LinkedList<BlockPos> res = new LinkedList<>();
|
||||||
if (asBlocks.isEmpty()) {
|
if (blocks.isEmpty()) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
ChunkProviderClient chunkProvider = world().getChunkProvider();
|
ChunkProviderClient chunkProvider = world().getChunkProvider();
|
||||||
|
|
||||||
|
int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius;
|
||||||
int playerChunkX = playerFeet().getX() >> 4;
|
int playerChunkX = playerFeet().getX() >> 4;
|
||||||
int playerChunkZ = playerFeet().getZ() >> 4;
|
int playerChunkZ = playerFeet().getZ() >> 4;
|
||||||
|
int playerY = playerFeet().getY();
|
||||||
|
|
||||||
int searchRadiusSq = 0;
|
int searchRadiusSq = 0;
|
||||||
|
boolean foundWithinY = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean allUnloaded = true;
|
boolean allUnloaded = true;
|
||||||
|
boolean foundChunks = false;
|
||||||
for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) {
|
for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) {
|
||||||
for (int zoff = -searchRadiusSq; zoff <= searchRadiusSq; zoff++) {
|
for (int zoff = -searchRadiusSq; zoff <= searchRadiusSq; zoff++) {
|
||||||
int distance = xoff * xoff + zoff * zoff;
|
int distance = xoff * xoff + zoff * zoff;
|
||||||
if (distance != searchRadiusSq) {
|
if (distance != searchRadiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
foundChunks = true;
|
||||||
int chunkX = xoff + playerChunkX;
|
int chunkX = xoff + playerChunkX;
|
||||||
int chunkZ = zoff + playerChunkZ;
|
int chunkZ = zoff + playerChunkZ;
|
||||||
Chunk chunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
Chunk chunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||||
@@ -79,8 +92,12 @@ public enum WorldScanner implements Helper {
|
|||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
IBlockState state = bsc.get(x, y, z);
|
IBlockState state = bsc.get(x, y, z);
|
||||||
if (asBlocks.contains(state.getBlock())) {
|
if (blocks.contains(state.getBlock())) {
|
||||||
res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z));
|
int yy = yReal | y;
|
||||||
|
res.add(new BlockPos(chunkX | x, yy, chunkZ | z));
|
||||||
|
if (Math.abs(yy - playerY) < yLevelThreshold) {
|
||||||
|
foundWithinY = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,10 +105,10 @@ public enum WorldScanner implements Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allUnloaded) {
|
if ((allUnloaded && foundChunks)
|
||||||
return res;
|
|| (res.size() >= max
|
||||||
}
|
&& (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY)))
|
||||||
if (res.size() >= max && searchRadiusSq > 26) {
|
) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
searchRadiusSq++;
|
searchRadiusSq++;
|
||||||
+14
-35
@@ -2,47 +2,30 @@
|
|||||||
* This file is part of Baritone.
|
* This file is part of Baritone.
|
||||||
*
|
*
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package baritone.event;
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.api.event;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.event.events.*;
|
import baritone.api.event.events.*;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.api.event.listener.IGameEventListener;
|
import baritone.api.event.listener.IGameEventListener;
|
||||||
import baritone.chunk.WorldProvider;
|
import baritone.api.utils.interfaces.Toggleable;
|
||||||
|
import baritone.cache.WorldProvider;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import baritone.utils.interfaces.Toggleable;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -126,7 +109,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
if (isPostPopulate || isPreUnload) {
|
if (isPostPopulate || isPreUnload) {
|
||||||
WorldProvider.INSTANCE.ifWorldLoaded(world -> {
|
WorldProvider.INSTANCE.ifWorldLoaded(world -> {
|
||||||
Chunk chunk = mc.world.getChunk(event.getX(), event.getZ());
|
Chunk chunk = mc.world.getChunk(event.getX(), event.getZ());
|
||||||
world.cache.queueForPacking(chunk);
|
world.getCachedWorld().queueForPacking(chunk);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,15 +136,11 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
|
|
||||||
BlockStateInterface.clearCachedChunk();
|
BlockStateInterface.clearCachedChunk();
|
||||||
|
|
||||||
switch (event.getState()) {
|
if (event.getState() == EventState.POST) {
|
||||||
case PRE:
|
cache.closeWorld();
|
||||||
break;
|
if (event.getWorld() != null) {
|
||||||
case POST:
|
cache.initWorld(event.getWorld());
|
||||||
cache.closeWorld();
|
}
|
||||||
if (event.getWorld() != null) {
|
|
||||||
cache.initWorld(event.getWorld());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
listeners.forEach(l -> {
|
listeners.forEach(l -> {
|
||||||
@@ -190,10 +169,10 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerRelativeMove(RelativeMoveEvent event) {
|
public void onPlayerRotationMove(RotationMoveEvent event) {
|
||||||
listeners.forEach(l -> {
|
listeners.forEach(l -> {
|
||||||
if (canDispatch(l)) {
|
if (canDispatch(l)) {
|
||||||
l.onPlayerRelativeMove(event);
|
l.onPlayerRotationMove(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user