├── .gitattributes
├── .github
├── PULL_REQUEST_TEMPLATE.md
└── ISSUE_TEMPLATE
│ ├── question.md
│ ├── suggestion.md
│ └── bug.md
├── LICENSE-Part-2.jpg
├── src
├── main
│ ├── resources
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── baritone.api.IBaritoneProvider
│ └── java
│ │ └── baritone
│ │ ├── utils
│ │ ├── accessor
│ │ │ ├── IChunkProviderClient.java
│ │ │ ├── IPlayerControllerMP.java
│ │ │ ├── IAnvilChunkLoader.java
│ │ │ └── IChunkProviderServer.java
│ │ ├── PathingCommandContext.java
│ │ ├── pathing
│ │ │ ├── MutableMoveResult.java
│ │ │ ├── PathingBlockType.java
│ │ │ ├── BetterWorldBorder.java
│ │ │ ├── Favoring.java
│ │ │ └── PathBase.java
│ │ ├── BaritoneProcessHelper.java
│ │ ├── schematic
│ │ │ ├── schematica
│ │ │ │ ├── SchematicaHelper.java
│ │ │ │ └── SchematicAdapter.java
│ │ │ ├── AirSchematic.java
│ │ │ └── MapArtSchematic.java
│ │ ├── PlayerMovementInput.java
│ │ ├── player
│ │ │ ├── PrimaryPlayerContext.java
│ │ │ └── PrimaryPlayerController.java
│ │ └── BlockPlaceHelper.java
│ │ ├── behavior
│ │ └── Behavior.java
│ │ ├── BaritoneProvider.java
│ │ ├── pathing
│ │ ├── calc
│ │ │ └── openset
│ │ │ │ ├── IOpenSet.java
│ │ │ │ └── LinkedListOpenSet.java
│ │ ├── path
│ │ │ └── CutoffPath.java
│ │ └── movement
│ │ │ └── MovementState.java
│ │ └── cache
│ │ └── WorldData.java
├── launch
│ ├── resources
│ │ └── mixins.baritone.json
│ └── java
│ │ └── baritone
│ │ └── launch
│ │ ├── mixins
│ │ ├── MixinAnvilChunkLoader.java
│ │ ├── MixinChunkProviderServer.java
│ │ ├── MixinChunkProviderClient.java
│ │ ├── MixinPlayerControllerMP.java
│ │ ├── MixinEntityRenderer.java
│ │ ├── MixinRenderList.java
│ │ ├── MixinVboRenderList.java
│ │ ├── MixinChunkRenderContainer.java
│ │ ├── MixinChunkRenderWorker.java
│ │ └── MixinWorldClient.java
│ │ └── BaritoneTweaker.java
├── schematica_api
│ └── java
│ │ └── com
│ │ └── github
│ │ └── lunatrius
│ │ ├── schematica
│ │ ├── proxy
│ │ │ ├── CommonProxy.java
│ │ │ └── ClientProxy.java
│ │ ├── Schematica.java
│ │ ├── api
│ │ │ └── ISchematic.java
│ │ └── client
│ │ │ └── world
│ │ │ └── SchematicWorld.java
│ │ └── core
│ │ └── util
│ │ └── math
│ │ └── MBlockPos.java
├── api
│ └── java
│ │ └── baritone
│ │ └── api
│ │ ├── process
│ │ ├── IFarmProcess.java
│ │ ├── IExploreProcess.java
│ │ ├── IGetToBlockProcess.java
│ │ ├── ICustomGoalProcess.java
│ │ ├── IFollowProcess.java
│ │ ├── PathingCommand.java
│ │ ├── PathingCommandType.java
│ │ ├── IMineProcess.java
│ │ └── IBuilderProcess.java
│ │ ├── utils
│ │ ├── interfaces
│ │ │ └── IGoalRenderPos.java
│ │ ├── MyChunkPos.java
│ │ ├── IInputOverrideHandler.java
│ │ ├── TypeUtils.java
│ │ ├── PathCalculationResult.java
│ │ ├── input
│ │ │ └── Input.java
│ │ ├── IPlayerController.java
│ │ ├── RayTraceUtils.java
│ │ ├── BlockUtils.java
│ │ ├── Helper.java
│ │ └── ISchematic.java
│ │ ├── pathing
│ │ ├── path
│ │ │ └── IPathExecutor.java
│ │ ├── calc
│ │ │ ├── IPathingControlManager.java
│ │ │ └── IPathFinder.java
│ │ ├── movement
│ │ │ ├── IMovement.java
│ │ │ └── MovementStatus.java
│ │ └── goals
│ │ │ ├── GoalAxis.java
│ │ │ ├── Goal.java
│ │ │ ├── GoalYLevel.java
│ │ │ ├── GoalComposite.java
│ │ │ ├── GoalNear.java
│ │ │ ├── GoalGetToBlock.java
│ │ │ ├── GoalTwoBlocks.java
│ │ │ ├── GoalStrictDirection.java
│ │ │ ├── GoalBlock.java
│ │ │ └── GoalRunAway.java
│ │ ├── cache
│ │ ├── IWorldProvider.java
│ │ ├── IBlockTypeAccess.java
│ │ ├── IRememberedInventory.java
│ │ ├── IContainerMemory.java
│ │ ├── IWorldData.java
│ │ ├── ICachedRegion.java
│ │ ├── IWaypointCollection.java
│ │ └── IWorldScanner.java
│ │ ├── event
│ │ ├── events
│ │ │ ├── type
│ │ │ │ ├── EventState.java
│ │ │ │ ├── ICancellable.java
│ │ │ │ └── Cancellable.java
│ │ │ ├── SprintStateEvent.java
│ │ │ ├── PathEvent.java
│ │ │ ├── RenderEvent.java
│ │ │ ├── ChatEvent.java
│ │ │ ├── PlayerUpdateEvent.java
│ │ │ ├── WorldEvent.java
│ │ │ ├── PacketEvent.java
│ │ │ ├── TickEvent.java
│ │ │ ├── BlockInteractEvent.java
│ │ │ ├── RotationMoveEvent.java
│ │ │ └── ChunkEvent.java
│ │ └── listener
│ │ │ ├── IEventBus.java
│ │ │ └── AbstractGameEventListener.java
│ │ ├── behavior
│ │ ├── IBehavior.java
│ │ └── ILookBehavior.java
│ │ ├── BaritoneAPI.java
│ │ └── IBaritoneProvider.java
└── test
│ └── java
│ └── baritone
│ ├── utils
│ └── pathing
│ │ └── PathingBlockTypeTest.java
│ ├── cache
│ └── CachedRegionTest.java
│ └── pathing
│ ├── goals
│ └── GoalGetToBlockTest.java
│ └── movement
│ └── ActionCostsTest.java
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── scripts
└── xvfb_1.16.4-1_amd64.deb
├── .idea
└── copyright
│ ├── profiles_settings.xml
│ └── Baritone.xml
├── .gitignore
├── Dockerfile
├── settings.gradle
├── .travis.yml
└── gradlew.bat
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/LICENSE-Part-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TJPlaysNow/baritone/master/LICENSE-Part-2.jpg
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/baritone.api.IBaritoneProvider:
--------------------------------------------------------------------------------
1 | baritone.BaritoneProvider
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TJPlaysNow/baritone/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/scripts/xvfb_1.16.4-1_amd64.deb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TJPlaysNow/baritone/master/scripts/xvfb_1.16.4-1_amd64.deb
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jul 31 21:56:56 PDT 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | **/*.swp
3 |
4 | run/
5 | autotest/
6 | dist/
7 |
8 | # Gradle
9 | build/
10 | .gradle/
11 | classes/
12 | *.class
13 |
14 | # IntelliJ Files
15 | .idea/
16 | *.iml
17 | /logs/
18 |
19 | # Copyright Files
20 | !/.idea/copyright/Baritone.xml
21 | !/.idea/copyright/profiles_settings.xml
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Please file a separate report for each question
4 | title: Please add a brief but descriptive title
5 | labels: question
6 | assignees: ''
7 | ---
8 |
9 | ## What do you need help with?
10 | With as much detail as possible, describe your question and what you may need help with.
11 |
12 | ## Final checklist
13 | - [ ] I have not used any OwO's or UwU's in this issue.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/suggestion.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Suggestion
3 | about: Please file a separate report for each suggestion
4 | title: Please add a brief but descriptive title
5 | labels: enhancement
6 | assignees: ''
7 | ---
8 |
9 | ## Describe your suggestion
10 | With as much detail as possible, describe what your suggestion would do for Baritone.
11 |
12 | ## Settings
13 | If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.
14 |
15 | ## Context
16 | Describe how your suggestion would improve Baritone, or the reason behind it being added.
17 |
18 | ## Final checklist
19 | - [ ] I have not used any OwO's or UwU's in this issue.
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:stretch
2 |
3 | RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
4 |
5 | ENV DEBIAN_FRONTEND noninteractive
6 |
7 | RUN apt update -y
8 |
9 | RUN apt install \
10 | openjdk-8-jdk \
11 | --assume-yes
12 |
13 | RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
14 |
15 | COPY . /code
16 |
17 | WORKDIR /code
18 |
19 | # this .deb is specially patched to support lwjgl
20 | # source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
21 | RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
22 |
23 | RUN ./gradlew build
24 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | rootProject.name = 'baritone'
19 |
20 |
--------------------------------------------------------------------------------
/src/launch/resources/mixins.baritone.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "package": "baritone.launch.mixins",
4 | "refmap": "mixins.baritone.refmap.json",
5 | "compatibilityLevel": "JAVA_8",
6 | "verbose": false,
7 | "injectors": {
8 | "maxShiftBy": 2
9 | },
10 | "client": [
11 | "MixinAnvilChunkLoader",
12 | "MixinChunkProviderClient",
13 | "MixinChunkProviderServer",
14 | "MixinChunkRenderContainer",
15 | "MixinChunkRenderWorker",
16 | "MixinEntityLivingBase",
17 | "MixinEntityPlayerSP",
18 | "MixinEntityRenderer",
19 | "MixinMinecraft",
20 | "MixinNetHandlerPlayClient",
21 | "MixinNetworkManager",
22 | "MixinPlayerControllerMP",
23 | "MixinRenderChunk",
24 | "MixinRenderList",
25 | "MixinVboRenderList",
26 | "MixinWorldClient"
27 | ]
28 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Please file a separate report for each issue
4 | title: Please add a brief but descriptive title
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 | ## Some information
10 | Operating system:
11 | Java version:
12 | Minecraft version:
13 | Baritone version:
14 | Forge mods (if used):
15 |
16 | ## Exception, error or logs
17 | You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
18 |
19 | ## How to reproduce
20 | Add your steps to reproduce the issue/bug experienced here.
21 |
22 | ## Final checklist
23 | - [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
24 | - [ ] I have included logs, exceptions and / or steps to reproduce the issue.
25 | - [ ] I have not used any OwO's or UwU's in this issue.
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.schematica.proxy;
19 |
20 | public abstract class CommonProxy {}
21 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IFarmProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | public interface IFarmProcess extends IBaritoneProcess {
21 | void farm();
22 | }
23 |
--------------------------------------------------------------------------------
/.idea/copyright/Baritone.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/interfaces/IGoalRenderPos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils.interfaces;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | public interface IGoalRenderPos {
23 | BlockPos getGoalPos();
24 | }
25 |
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.schematica;
19 |
20 | import com.github.lunatrius.schematica.proxy.CommonProxy;
21 |
22 | public class Schematica {
23 | public static CommonProxy proxy;
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/accessor/IChunkProviderClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.accessor;
19 |
20 | import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
21 | import net.minecraft.world.chunk.Chunk;
22 |
23 | public interface IChunkProviderClient {
24 | Long2ObjectMap loadedChunks();
25 | }
26 |
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.schematica.proxy;
19 |
20 | import com.github.lunatrius.schematica.client.world.SchematicWorld;
21 |
22 | public class ClientProxy extends CommonProxy {
23 | public static SchematicWorld schematic;
24 | }
25 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/path/IPathExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.path;
19 |
20 | import baritone.api.pathing.calc.IPath;
21 |
22 | /**
23 | * @author Brady
24 | * @since 10/8/2018
25 | */
26 | public interface IPathExecutor {
27 |
28 | IPath getPath();
29 |
30 | int getPosition();
31 | }
32 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IExploreProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import java.nio.file.Path;
21 |
22 | public interface IExploreProcess extends IBaritoneProcess {
23 | void explore(int centerX, int centerZ);
24 |
25 | void applyJsonFilter(Path path, boolean invert) throws Exception;
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/accessor/IPlayerControllerMP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.accessor;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | public interface IPlayerControllerMP {
23 | void setIsHittingBlock(boolean isHittingBlock);
24 |
25 | BlockPos getCurrentBlock();
26 |
27 | void callSyncCurrentPlayItem();
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.accessor;
19 |
20 | import baritone.cache.WorldProvider;
21 |
22 | import java.io.File;
23 |
24 | /**
25 | * @author Brady
26 | * @see WorldProvider
27 | * @since 8/4/2018
28 | */
29 | public interface IAnvilChunkLoader {
30 |
31 | File getChunkSaveLocation();
32 | }
33 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IWorldProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | /**
21 | * @author Brady
22 | * @since 9/24/2018
23 | */
24 | public interface IWorldProvider {
25 |
26 | /**
27 | * Returns the data of the currently loaded world
28 | *
29 | * @return The current world data
30 | */
31 | IWorldData getCurrentWorld();
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/accessor/IChunkProviderServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.accessor;
19 |
20 | import net.minecraft.world.WorldProvider;
21 | import net.minecraft.world.chunk.storage.IChunkLoader;
22 |
23 | /**
24 | * @author Brady
25 | * @see WorldProvider
26 | * @since 8/4/2018
27 | */
28 | public interface IChunkProviderServer {
29 |
30 | IChunkLoader getChunkLoader();
31 | }
32 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IGetToBlockProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import net.minecraft.block.Block;
21 |
22 | /**
23 | * but it rescans the world every once in a while so it doesn't get fooled by its cache
24 | */
25 | public interface IGetToBlockProcess extends IBaritoneProcess {
26 |
27 | void getToBlock(Block block);
28 |
29 | boolean blacklistClosest();
30 | }
31 |
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.schematica.api;
19 |
20 | import net.minecraft.block.state.IBlockState;
21 | import net.minecraft.util.math.BlockPos;
22 |
23 | public interface ISchematic {
24 | IBlockState getBlockState(BlockPos var1);
25 |
26 | int getWidth();
27 |
28 | int getHeight();
29 |
30 | int getLength();
31 | }
32 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/type/EventState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events.type;
19 |
20 | /**
21 | * @author Brady
22 | * @since 8/2/2018
23 | */
24 | public enum EventState {
25 |
26 | /**
27 | * Before the dispatching of what the event is targetting
28 | */
29 | PRE,
30 |
31 | /**
32 | * After the dispatching of what the event is targetting
33 | */
34 | POST
35 | }
36 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/type/ICancellable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events.type;
19 |
20 | /**
21 | * @author Brady
22 | * @since 10/11/2018
23 | */
24 | public interface ICancellable {
25 |
26 | /**
27 | * Cancels this event
28 | */
29 | void cancel();
30 |
31 | /**
32 | * @return Whether or not this event has been cancelled
33 | */
34 | boolean isCancelled();
35 | }
36 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/SprintStateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | /**
21 | * @author Brady
22 | * @since 1/18/2019
23 | */
24 | public final class SprintStateEvent {
25 |
26 | private Boolean state;
27 |
28 | public final void setState(boolean state) {
29 | this.state = state;
30 | }
31 |
32 | public final Boolean getState() {
33 | return this.state;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/behavior/IBehavior.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.behavior;
19 |
20 | import baritone.api.event.listener.AbstractGameEventListener;
21 | import baritone.api.event.listener.IGameEventListener;
22 |
23 | /**
24 | * A behavior is simply a type that is able to listen to events.
25 | *
26 | * @author Brady
27 | * @see IGameEventListener
28 | * @since 9/23/2018
29 | */
30 | public interface IBehavior extends AbstractGameEventListener {}
31 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/MyChunkPos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import com.google.gson.annotations.SerializedName;
21 |
22 | /**
23 | * Need a non obfed chunkpos that we can load using GSON
24 | */
25 | public class MyChunkPos {
26 |
27 | @SerializedName("x")
28 | public int x;
29 |
30 | @SerializedName("z")
31 | public int z;
32 |
33 | @Override
34 | public String toString() {
35 | return x + ", " + z;
36 | }
37 | }
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/IInputOverrideHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import baritone.api.behavior.IBehavior;
21 | import baritone.api.utils.input.Input;
22 |
23 | /**
24 | * @author Brady
25 | * @since 11/12/2018
26 | */
27 | public interface IInputOverrideHandler extends IBehavior {
28 |
29 | boolean isInputForcedDown(Input input);
30 |
31 | void setInputForceState(Input input, boolean forced);
32 |
33 | void clearAllKeys();
34 | }
35 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/PathEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | public enum PathEvent {
21 | CALC_STARTED,
22 | CALC_FINISHED_NOW_EXECUTING,
23 | CALC_FAILED,
24 | NEXT_SEGMENT_CALC_STARTED,
25 | NEXT_SEGMENT_CALC_FINISHED,
26 | CONTINUING_ONTO_PLANNED_NEXT,
27 | SPLICING_ONTO_NEXT_EARLY,
28 | AT_GOAL,
29 | PATH_FINISHED_NEXT_STILL_CALCULATING,
30 | NEXT_CALC_FAILED,
31 | DISCARD_NEXT,
32 | CANCELED;
33 | }
34 |
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.schematica.client.world;
19 |
20 | import com.github.lunatrius.core.util.math.MBlockPos;
21 | import com.github.lunatrius.schematica.api.ISchematic;
22 |
23 | public class SchematicWorld {
24 | public final MBlockPos position = (MBlockPos)(Object)"cringe";
25 |
26 | public ISchematic getSchematic() {
27 | throw new LinkageError("LOL");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IBlockTypeAccess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | import net.minecraft.block.state.IBlockState;
21 | import net.minecraft.util.math.BlockPos;
22 |
23 | /**
24 | * @author Brady
25 | * @since 8/4/2018
26 | */
27 | public interface IBlockTypeAccess {
28 |
29 | IBlockState getBlock(int x, int y, int z);
30 |
31 | default IBlockState getBlock(BlockPos pos) {
32 | return getBlock(pos.getX(), pos.getY(), pos.getZ());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/baritone/utils/pathing/PathingBlockTypeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertTrue;
23 |
24 | public class PathingBlockTypeTest {
25 | @Test
26 | public void testBits() {
27 | for (PathingBlockType type : PathingBlockType.values()) {
28 | boolean[] bits = type.getBits();
29 | assertTrue(type == PathingBlockType.fromBits(bits[0], bits[1]));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IRememberedInventory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | import net.minecraft.item.ItemStack;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * @author Brady
26 | * @since 9/23/2018
27 | */
28 | public interface IRememberedInventory {
29 |
30 | /**
31 | * @return The contents of this inventory
32 | */
33 | List getContents();
34 |
35 | /**
36 | * @return The number of slots in this inventory
37 | */
38 | int getSize();
39 | }
40 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/type/Cancellable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events.type;
19 |
20 | /**
21 | * @author Brady
22 | * @since 8/1/2018
23 | */
24 | public class Cancellable implements ICancellable {
25 |
26 | /**
27 | * Whether or not this event has been cancelled
28 | */
29 | private boolean cancelled;
30 |
31 | @Override
32 | public final void cancel() {
33 | this.cancelled = true;
34 | }
35 |
36 | @Override
37 | public final boolean isCancelled() {
38 | return this.cancelled;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package com.github.lunatrius.core.util.math;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | public class MBlockPos extends BlockPos {
23 | MBlockPos() {
24 | super(6, 6, 6);
25 | }
26 |
27 | @Override
28 | public int getX() {
29 | throw new LinkageError("LOL");
30 | }
31 |
32 | @Override
33 | public int getY() {
34 | throw new LinkageError("LOL");
35 | }
36 |
37 | @Override
38 | public int getZ() {
39 | throw new LinkageError("LOL");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/RenderEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | /**
21 | * @author Brady
22 | * @since 8/5/2018
23 | */
24 | public final class RenderEvent {
25 |
26 | /**
27 | * The current render partial ticks
28 | */
29 | private final float partialTicks;
30 |
31 | public RenderEvent(float partialTicks) {
32 | this.partialTicks = partialTicks;
33 | }
34 |
35 | /**
36 | * @return The current render partial ticks
37 | */
38 | public final float getPartialTicks() {
39 | return this.partialTicks;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/PathingCommandContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils;
19 |
20 | import baritone.api.pathing.goals.Goal;
21 | import baritone.api.process.PathingCommand;
22 | import baritone.api.process.PathingCommandType;
23 | import baritone.pathing.movement.CalculationContext;
24 |
25 | public class PathingCommandContext extends PathingCommand {
26 | public final CalculationContext desiredCalcContext;
27 |
28 | public PathingCommandContext(Goal goal, PathingCommandType commandType, CalculationContext context) {
29 | super(goal, commandType);
30 | this.desiredCalcContext = context;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/ChatEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.Cancellable;
21 |
22 | /**
23 | * @author Brady
24 | * @since 8/1/2018
25 | */
26 | public final class ChatEvent extends Cancellable {
27 |
28 | /**
29 | * The message being sent
30 | */
31 | private final String message;
32 |
33 | public ChatEvent(String message) {
34 | this.message = message;
35 | }
36 |
37 | /**
38 | * @return The message being sent
39 | */
40 | public final String getMessage() {
41 | return this.message;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/listener/IEventBus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.listener;
19 |
20 | /**
21 | * A type of {@link IGameEventListener} that can have additional listeners
22 | * registered so that they receive the events that are dispatched to this
23 | * listener.
24 | *
25 | * @author Brady
26 | * @since 11/14/2018
27 | */
28 | public interface IEventBus extends IGameEventListener {
29 |
30 | /**
31 | * Registers the specified {@link IGameEventListener} to this event bus
32 | *
33 | * @param listener The listener
34 | */
35 | void registerEventListener(IGameEventListener listener);
36 | }
37 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.EventState;
21 |
22 | /**
23 | * @author Brady
24 | * @since 8/21/2018
25 | */
26 | public final class PlayerUpdateEvent {
27 |
28 | /**
29 | * The state of the event
30 | */
31 | private final EventState state;
32 |
33 | public PlayerUpdateEvent(EventState state) {
34 | this.state = state;
35 | }
36 |
37 | /**
38 | * @return The state of the event
39 | */
40 | public final EventState getState() {
41 | return this.state;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/pathing/MutableMoveResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | import baritone.api.pathing.movement.ActionCosts;
21 |
22 | /**
23 | * The result of a calculated movement, with destination x, y, z, and the cost of performing the movement
24 | *
25 | * @author leijurv
26 | */
27 | public final class MutableMoveResult {
28 | public int x;
29 | public int y;
30 | public int z;
31 | public double cost;
32 |
33 | public MutableMoveResult() {
34 | reset();
35 | }
36 |
37 | public final void reset() {
38 | x = 0;
39 | y = 0;
40 | z = 0;
41 | cost = ActionCosts.COST_INF;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/baritone/behavior/Behavior.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.behavior;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.behavior.IBehavior;
22 | import baritone.api.utils.IPlayerContext;
23 |
24 | /**
25 | * A type of game event listener that is given {@link Baritone} instance context.
26 | *
27 | * @author Brady
28 | * @since 8/1/2018
29 | */
30 | public class Behavior implements IBehavior {
31 |
32 | public final Baritone baritone;
33 | public final IPlayerContext ctx;
34 |
35 | protected Behavior(Baritone baritone) {
36 | this.baritone = baritone;
37 | this.ctx = baritone.getPlayerContext();
38 | baritone.registerBehavior(this);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/pathing/PathingBlockType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | /**
21 | * @author Brady
22 | * @since 8/4/2018
23 | */
24 | public enum PathingBlockType {
25 |
26 | AIR(0b00),
27 | WATER(0b01),
28 | AVOID(0b10),
29 | SOLID(0b11);
30 |
31 | private final boolean[] bits;
32 |
33 | PathingBlockType(int bits) {
34 | this.bits = new boolean[]{
35 | (bits & 0b10) != 0,
36 | (bits & 0b01) != 0
37 | };
38 | }
39 |
40 | public final boolean[] getBits() {
41 | return this.bits;
42 | }
43 |
44 | public static PathingBlockType fromBits(boolean b1, boolean b2) {
45 | return b1 ? b2 ? SOLID : AVOID : b2 ? WATER : AIR;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | sudo: required
4 |
5 | services:
6 | - docker
7 |
8 | install:
9 | - travis_retry docker build -t cabaletta/baritone .
10 |
11 | script:
12 | - docker run --rm cabaletta/baritone ./gradlew javadoc
13 | - docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
14 | - docker cp baritone:/code/dist dist
15 | - ls dist
16 | - cat dist/checksums.txt
17 |
18 | deploy:
19 | provider: releases
20 | api_key:
21 | secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s=
22 | all_branches: true
23 | file_glob: true
24 | file:
25 | - dist/*
26 | skip_cleanup: true
27 | on:
28 | tags: true
29 | repo: cabaletta/baritone
30 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.utils.accessor.IAnvilChunkLoader;
21 | import net.minecraft.world.chunk.storage.AnvilChunkLoader;
22 | import org.spongepowered.asm.mixin.Final;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.Shadow;
25 |
26 | import java.io.File;
27 |
28 | /**
29 | * @author Brady
30 | * @since 9/4/2018
31 | */
32 | @Mixin(AnvilChunkLoader.class)
33 | public class MixinAnvilChunkLoader implements IAnvilChunkLoader {
34 |
35 | @Shadow
36 | @Final
37 | private File chunkSaveLocation;
38 |
39 | @Override
40 | public File getChunkSaveLocation() {
41 | return this.chunkSaveLocation;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/BaritoneProcessHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.process.IBaritoneProcess;
22 | import baritone.api.utils.Helper;
23 | import baritone.api.utils.IPlayerContext;
24 |
25 | public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper {
26 |
27 | protected final Baritone baritone;
28 | protected final IPlayerContext ctx;
29 |
30 | public BaritoneProcessHelper(Baritone baritone) {
31 | this.baritone = baritone;
32 | this.ctx = baritone.getPlayerContext();
33 | baritone.getPathingControlManager().registerProcess(this);
34 | }
35 |
36 | @Override
37 | public boolean isTemporary() {
38 | return false;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.utils.accessor.IChunkProviderServer;
21 | import net.minecraft.world.chunk.storage.IChunkLoader;
22 | import net.minecraft.world.gen.ChunkProviderServer;
23 | import org.spongepowered.asm.mixin.Final;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.Shadow;
26 |
27 | /**
28 | * @author Brady
29 | * @since 9/4/2018
30 | */
31 | @Mixin(ChunkProviderServer.class)
32 | public class MixinChunkProviderServer implements IChunkProviderServer {
33 |
34 | @Shadow
35 | @Final
36 | private IChunkLoader chunkLoader;
37 |
38 | @Override
39 | public IChunkLoader getChunkLoader() {
40 | return this.chunkLoader;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/ICustomGoalProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import baritone.api.pathing.goals.Goal;
21 |
22 | public interface ICustomGoalProcess extends IBaritoneProcess {
23 |
24 | /**
25 | * Sets the pathing goal
26 | *
27 | * @param goal The new goal
28 | */
29 | void setGoal(Goal goal);
30 |
31 | /**
32 | * Starts path calculation and execution.
33 | */
34 | void path();
35 |
36 | /**
37 | * @return The current goal
38 | */
39 | Goal getGoal();
40 |
41 | /**
42 | * Sets the goal and begins the path execution.
43 | *
44 | * @param goal The new goal
45 | */
46 | default void setGoalAndPath(Goal goal) {
47 | this.setGoal(goal);
48 | this.path();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinChunkProviderClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.utils.accessor.IChunkProviderClient;
21 | import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
22 | import net.minecraft.client.multiplayer.ChunkProviderClient;
23 | import net.minecraft.world.chunk.Chunk;
24 | import org.spongepowered.asm.mixin.Final;
25 | import org.spongepowered.asm.mixin.Mixin;
26 | import org.spongepowered.asm.mixin.Shadow;
27 |
28 | @Mixin(ChunkProviderClient.class)
29 | public class MixinChunkProviderClient implements IChunkProviderClient {
30 |
31 | @Shadow
32 | @Final
33 | private Long2ObjectMap loadedChunks;
34 |
35 | @Override
36 | public Long2ObjectMap loadedChunks() {
37 | return this.loadedChunks;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IContainerMemory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | import java.util.Map;
23 |
24 | /**
25 | * @author Brady
26 | * @since 9/23/2018
27 | */
28 | public interface IContainerMemory {
29 |
30 | /**
31 | * Gets a remembered inventory by its block position.
32 | *
33 | * @param pos The position of the container block
34 | * @return The remembered inventory
35 | */
36 | IRememberedInventory getInventoryByPos(BlockPos pos);
37 |
38 | /**
39 | * Gets the map of all block positions to their remembered inventories.
40 | *
41 | * @return Map of block positions to their respective remembered inventories
42 | */
43 | Map getRememberedInventories();
44 | }
45 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/behavior/ILookBehavior.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.behavior;
19 |
20 | import baritone.api.utils.Rotation;
21 |
22 | /**
23 | * @author Brady
24 | * @since 9/23/2018
25 | */
26 | public interface ILookBehavior extends IBehavior {
27 |
28 | /**
29 | * Updates the current {@link ILookBehavior} target to target
30 | * the specified rotations on the next tick. If force is {@code true},
31 | * then freeLook will be overriden and angles will be set regardless.
32 | * If any sort of block interaction is required, force should be {@code true},
33 | * otherwise, it should be {@code false};
34 | *
35 | * @param rotation The target rotations
36 | * @param force Whether or not to "force" the rotations
37 | */
38 | void updateTarget(Rotation rotation, boolean force);
39 | }
40 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinPlayerControllerMP.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.utils.accessor.IPlayerControllerMP;
21 | import net.minecraft.client.multiplayer.PlayerControllerMP;
22 | import net.minecraft.util.math.BlockPos;
23 | import org.spongepowered.asm.mixin.Mixin;
24 | import org.spongepowered.asm.mixin.gen.Accessor;
25 | import org.spongepowered.asm.mixin.gen.Invoker;
26 |
27 | @Mixin(PlayerControllerMP.class)
28 | public abstract class MixinPlayerControllerMP implements IPlayerControllerMP {
29 | @Accessor
30 | @Override
31 | public abstract void setIsHittingBlock(boolean isHittingBlock);
32 |
33 | @Accessor
34 | @Override
35 | public abstract BlockPos getCurrentBlock();
36 |
37 | @Invoker
38 | @Override
39 | public abstract void callSyncCurrentPlayItem();
40 | }
41 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IWorldData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | /**
21 | * @author Brady
22 | * @since 9/24/2018
23 | */
24 | public interface IWorldData {
25 |
26 | /**
27 | * Returns the cached world for this world. A cached world is a simplified format
28 | * of a regular world, intended for use on multiplayer servers where chunks are not
29 | * traditionally stored to disk, allowing for long distance pathing with minimal disk usage.
30 | *
31 | * @return The cached world for this world
32 | */
33 | ICachedWorld getCachedWorld();
34 |
35 | /**
36 | * @return The waypoint collection for this world
37 | */
38 | IWaypointCollection getWaypoints();
39 |
40 | /**
41 | * @return The {@link IContainerMemory} instance
42 | * @see IContainerMemory
43 | */
44 | IContainerMemory getContainerMemory();
45 | }
46 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/calc/IPathingControlManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.calc;
19 |
20 | import baritone.api.process.IBaritoneProcess;
21 | import baritone.api.process.PathingCommand;
22 |
23 | import java.util.Optional;
24 |
25 | /**
26 | * @author leijurv
27 | */
28 | public interface IPathingControlManager {
29 |
30 | /**
31 | * Registers a process with this pathing control manager. See {@link IBaritoneProcess} for more details.
32 | *
33 | * @param process The process
34 | * @see IBaritoneProcess
35 | */
36 | void registerProcess(IBaritoneProcess process);
37 |
38 | /**
39 | * @return The most recent {@link IBaritoneProcess} that had control
40 | */
41 | Optional mostRecentInControl();
42 |
43 | /**
44 | * @return The most recent pathing command executed
45 | */
46 | Optional mostRecentCommand();
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/baritone/BaritoneProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone;
19 |
20 | import baritone.api.IBaritone;
21 | import baritone.api.IBaritoneProvider;
22 | import baritone.api.cache.IWorldScanner;
23 | import baritone.cache.WorldScanner;
24 |
25 | import java.util.Collections;
26 | import java.util.List;
27 |
28 | /**
29 | * @author Brady
30 | * @since 9/29/2018
31 | */
32 | public final class BaritoneProvider implements IBaritoneProvider {
33 |
34 | private final Baritone primary = new Baritone();
35 | private final List all = Collections.singletonList(primary);
36 |
37 | @Override
38 | public IBaritone getPrimaryBaritone() {
39 | return primary;
40 | }
41 |
42 | @Override
43 | public List getAllBaritones() {
44 | return all;
45 | }
46 |
47 | @Override
48 | public IWorldScanner getWorldScanner() {
49 | return WorldScanner.INSTANCE;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/TypeUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import java.lang.reflect.ParameterizedType;
21 | import java.lang.reflect.Type;
22 |
23 | /**
24 | * @author Brady
25 | * @since 4/20/2019
26 | */
27 | public final class TypeUtils {
28 |
29 | private TypeUtils() {}
30 |
31 | /**
32 | * Resolves the "base type" for the specified type. For example, if the specified
33 | * type is {@code List}, then {@code List.class} will be returned. If the
34 | * specified type is already a class, then it is directly returned.
35 | *
36 | * @param type The type to resolve
37 | * @return The base class
38 | */
39 | public static Class> resolveBaseClass(Type type) {
40 | return type instanceof Class ? (Class>) type
41 | : type instanceof ParameterizedType ? (Class>) ((ParameterizedType) type).getRawType()
42 | : null;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/movement/IMovement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.movement;
19 |
20 | import baritone.api.utils.BetterBlockPos;
21 | import net.minecraft.util.math.BlockPos;
22 |
23 | /**
24 | * @author Brady
25 | * @since 10/8/2018
26 | */
27 | public interface IMovement {
28 |
29 | double getCost();
30 |
31 | MovementStatus update();
32 |
33 | /**
34 | * Resets the current state status to {@link MovementStatus#PREPPING}
35 | */
36 | void reset();
37 |
38 | /**
39 | * Resets the cache for special break, place, and walk into blocks
40 | */
41 | void resetBlockCache();
42 |
43 | /**
44 | * @return Whether or not it is safe to cancel the current movement state
45 | */
46 | boolean safeToCancel();
47 |
48 | boolean calculatedWhileLoaded();
49 |
50 | BetterBlockPos getSrc();
51 |
52 | BetterBlockPos getDest();
53 |
54 | BlockPos getDirection();
55 | }
56 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IFollowProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import net.minecraft.entity.Entity;
21 |
22 | import java.util.List;
23 | import java.util.function.Predicate;
24 |
25 | /**
26 | * @author Brady
27 | * @since 9/23/2018
28 | */
29 | public interface IFollowProcess extends IBaritoneProcess {
30 |
31 | /**
32 | * Set the follow target to any entities matching this predicate
33 | *
34 | * @param filter the predicate
35 | */
36 | void follow(Predicate filter);
37 |
38 | /**
39 | * @return The entities that are currently being followed. null if not currently following, empty if nothing matches the predicate
40 | */
41 | List following();
42 |
43 | Predicate currentFilter();
44 |
45 | /**
46 | * Cancels the follow behavior, this will clear the current follow target.
47 | */
48 | default void cancel() {
49 | onLostControl();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/PathCalculationResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import baritone.api.pathing.calc.IPath;
21 |
22 | import java.util.Objects;
23 | import java.util.Optional;
24 |
25 | public class PathCalculationResult {
26 |
27 | private final IPath path;
28 | private final Type type;
29 |
30 | public PathCalculationResult(Type type) {
31 | this(type, null);
32 | }
33 |
34 | public PathCalculationResult(Type type, IPath path) {
35 | Objects.requireNonNull(type);
36 | this.path = path;
37 | this.type = type;
38 | }
39 |
40 | public final Optional getPath() {
41 | return Optional.ofNullable(this.path);
42 | }
43 |
44 | public final Type getType() {
45 | return this.type;
46 | }
47 |
48 | public enum Type {
49 | SUCCESS_TO_GOAL,
50 | SUCCESS_SEGMENT,
51 | FAILURE,
52 | CANCELLATION,
53 | EXCEPTION,
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.schematic.schematica;
19 |
20 | import baritone.api.utils.ISchematic;
21 | import com.github.lunatrius.schematica.Schematica;
22 | import com.github.lunatrius.schematica.proxy.ClientProxy;
23 | import net.minecraft.util.Tuple;
24 | import net.minecraft.util.math.BlockPos;
25 |
26 | import java.util.Optional;
27 |
28 | public enum SchematicaHelper {
29 | ;
30 |
31 | public static boolean isSchematicaPresent() {
32 | try {
33 | Class.forName(Schematica.class.getName());
34 | return true;
35 | } catch (ClassNotFoundException | NoClassDefFoundError ex) {
36 | return false;
37 | }
38 | }
39 |
40 | public static Optional> getOpenSchematic() {
41 | return Optional.ofNullable(ClientProxy.schematic)
42 | .map(world -> new Tuple<>(new SchematicAdapter(world), world.position));
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/baritone/pathing/calc/openset/IOpenSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.calc.openset;
19 |
20 | import baritone.pathing.calc.PathNode;
21 |
22 | /**
23 | * An open set for A* or similar graph search algorithm
24 | *
25 | * @author leijurv
26 | */
27 | public interface IOpenSet {
28 |
29 | /**
30 | * Inserts the specified node into the heap
31 | *
32 | * @param node The node
33 | */
34 | void insert(PathNode node);
35 |
36 | /**
37 | * @return {@code true} if the heap has no elements; {@code false} otherwise.
38 | */
39 | boolean isEmpty();
40 |
41 | /**
42 | * Removes and returns the minimum element in the heap.
43 | *
44 | * @return The minimum element in the heap
45 | */
46 | PathNode removeLowest();
47 |
48 | /**
49 | * A faster path has been found to this node, decreasing its cost. Perform a decrease-key operation.
50 | *
51 | * @param node The node
52 | */
53 | void update(PathNode node);
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/schematic/AirSchematic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.schematic;
19 |
20 | import baritone.api.utils.ISchematic;
21 | import net.minecraft.block.state.IBlockState;
22 | import net.minecraft.init.Blocks;
23 |
24 | public class AirSchematic implements ISchematic {
25 |
26 | private final int widthX;
27 | private final int heightY;
28 | private final int lengthZ;
29 |
30 | public AirSchematic(int widthX, int heightY, int lengthZ) {
31 | this.widthX = widthX;
32 | this.heightY = heightY;
33 | this.lengthZ = lengthZ;
34 | }
35 |
36 | @Override
37 | public IBlockState desiredState(int x, int y, int z) {
38 | return Blocks.AIR.getDefaultState();
39 | }
40 |
41 | @Override
42 | public int widthX() {
43 | return widthX;
44 | }
45 |
46 | @Override
47 | public int heightY() {
48 | return heightY;
49 | }
50 |
51 | @Override
52 | public int lengthZ() {
53 | return lengthZ;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/ICachedRegion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | /**
21 | * @author Brady
22 | * @since 9/24/2018
23 | */
24 | public interface ICachedRegion extends IBlockTypeAccess {
25 |
26 | /**
27 | * Returns whether or not the block at the specified X and Z coordinates
28 | * is cached in this world. Similar to {@link ICachedWorld#isCached(int, int)},
29 | * however, the block coordinates should in on a scale from 0 to 511 (inclusive)
30 | * because region sizes are 512x512 blocks.
31 | *
32 | * @param blockX The block X coordinate
33 | * @param blockZ The block Z coordinate
34 | * @return Whether or not the specified XZ location is cached
35 | * @see ICachedWorld#isCached(int, int)
36 | */
37 | boolean isCached(int blockX, int blockZ);
38 |
39 | /**
40 | * @return The X coordinate of this region
41 | */
42 | int getX();
43 |
44 | /**
45 | * @return The Z coordinate of this region
46 | */
47 | int getZ();
48 | }
49 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/input/Input.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils.input;
19 |
20 | /**
21 | * An {@link Enum} representing the inputs that control the player's
22 | * behavior. This includes moving, interacting with blocks, jumping,
23 | * sneaking, and sprinting.
24 | */
25 | public enum Input {
26 |
27 | /**
28 | * The move forward input
29 | */
30 | MOVE_FORWARD,
31 |
32 | /**
33 | * The move back input
34 | */
35 | MOVE_BACK,
36 |
37 | /**
38 | * The move left input
39 | */
40 | MOVE_LEFT,
41 |
42 | /**
43 | * The move right input
44 | */
45 | MOVE_RIGHT,
46 |
47 | /**
48 | * The attack input
49 | */
50 | CLICK_LEFT,
51 |
52 | /**
53 | * The use item input
54 | */
55 | CLICK_RIGHT,
56 |
57 | /**
58 | * The jump input
59 | */
60 | JUMP,
61 |
62 | /**
63 | * The sneak input
64 | */
65 | SNEAK,
66 |
67 | /**
68 | * The sprint input
69 | */
70 | SPRINT
71 | }
72 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/WorldEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.EventState;
21 | import net.minecraft.client.multiplayer.WorldClient;
22 |
23 | /**
24 | * @author Brady
25 | * @since 8/4/2018
26 | */
27 | public final class WorldEvent {
28 |
29 | /**
30 | * The new world that is being loaded. {@code null} if being unloaded.
31 | */
32 | private final WorldClient world;
33 |
34 | /**
35 | * The state of the event
36 | */
37 | private final EventState state;
38 |
39 | public WorldEvent(WorldClient world, EventState state) {
40 | this.world = world;
41 | this.state = state;
42 | }
43 |
44 | /**
45 | * @return The new world that is being loaded. {@code null} if being unloaded.
46 | */
47 | public final WorldClient getWorld() {
48 | return this.world;
49 | }
50 |
51 | /**
52 | * @return The state of the event
53 | */
54 | public final EventState getState() {
55 | return this.state;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/BaritoneAPI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 |
22 | import java.util.Iterator;
23 | import java.util.ServiceLoader;
24 |
25 | /**
26 | * Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
27 | *
28 | * @author Brady
29 | * @since 9/23/2018
30 | */
31 | public final class BaritoneAPI {
32 |
33 | private static final IBaritoneProvider provider;
34 | private static final Settings settings;
35 |
36 | static {
37 | ServiceLoader baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
38 | Iterator instances = baritoneLoader.iterator();
39 | provider = instances.next();
40 |
41 | settings = new Settings();
42 | SettingsUtil.readAndApply(settings);
43 | }
44 |
45 | public static IBaritoneProvider getProvider() {
46 | return BaritoneAPI.provider;
47 | }
48 |
49 | public static Settings getSettings() {
50 | return BaritoneAPI.settings;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/baritone/cache/CachedRegionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.cache;
19 |
20 | import org.junit.Test;
21 |
22 | import static junit.framework.TestCase.assertEquals;
23 |
24 | public class CachedRegionTest {
25 |
26 | @Test
27 | public void blockPosSaving() {
28 | for (int x = 0; x < 16; x++) {
29 | for (int z = 0; z < 16; z++) {
30 | for (int y = 0; y < 256; y++) {
31 | byte part1 = (byte) (z << 4 | x);
32 | byte part2 = (byte) (y);
33 | byte xz = part1;
34 | int X = xz & 0x0f;
35 | int Z = (xz >>> 4) & 0x0f;
36 | int Y = part2 & 0xff;
37 | if (x != X || y != Y || z != Z) {
38 | System.out.println(x + " " + X + " " + y + " " + Y + " " + z + " " + Z);
39 | }
40 | assertEquals(x, X);
41 | assertEquals(y, Y);
42 | assertEquals(z, Z);
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalAxis.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.BaritoneAPI;
21 |
22 | public class GoalAxis implements Goal {
23 |
24 | private static final double SQRT_2_OVER_2 = Math.sqrt(2) / 2;
25 |
26 | @Override
27 | public boolean isInGoal(int x, int y, int z) {
28 | return y == BaritoneAPI.getSettings().axisHeight.value && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z));
29 | }
30 |
31 | @Override
32 | public double heuristic(int x0, int y, int z0) {
33 | int x = Math.abs(x0);
34 | int z = Math.abs(z0);
35 |
36 | int shrt = Math.min(x, z);
37 | int lng = Math.max(x, z);
38 | int diff = lng - shrt;
39 |
40 | double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2));
41 |
42 | return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return "GoalAxis";
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.schematic.schematica;
19 |
20 | import baritone.api.utils.ISchematic;
21 |
22 | import com.github.lunatrius.schematica.client.world.SchematicWorld;
23 | import net.minecraft.block.state.IBlockState;
24 | import net.minecraft.util.math.BlockPos;
25 |
26 | public final class SchematicAdapter implements ISchematic {
27 | private final SchematicWorld schematic;
28 |
29 | public SchematicAdapter(SchematicWorld schematicWorld) {
30 | this.schematic = schematicWorld;
31 | }
32 |
33 | @Override
34 | public IBlockState desiredState(int x, int y, int z) {
35 | return schematic.getSchematic().getBlockState(new BlockPos(x, y, z));
36 | }
37 |
38 | @Override
39 | public int widthX() {
40 | return schematic.getSchematic().getWidth();
41 | }
42 |
43 | @Override
44 | public int heightY() {
45 | return schematic.getSchematic().getHeight();
46 | }
47 |
48 | @Override
49 | public int lengthZ() {
50 | return schematic.getSchematic().getLength();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/PacketEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.EventState;
21 | import net.minecraft.network.NetworkManager;
22 | import net.minecraft.network.Packet;
23 |
24 | /**
25 | * @author Brady
26 | * @since 8/6/2018
27 | */
28 | public final class PacketEvent {
29 |
30 | private final NetworkManager networkManager;
31 |
32 | private final EventState state;
33 |
34 | private final Packet> packet;
35 |
36 | public PacketEvent(NetworkManager networkManager, EventState state, Packet> packet) {
37 | this.networkManager = networkManager;
38 | this.state = state;
39 | this.packet = packet;
40 | }
41 |
42 | public final NetworkManager getNetworkManager() {
43 | return this.networkManager;
44 | }
45 |
46 | public final EventState getState() {
47 | return this.state;
48 | }
49 |
50 | public final Packet> getPacket() {
51 | return this.packet;
52 | }
53 |
54 | @SuppressWarnings("unchecked")
55 | public final > T cast() {
56 | return (T) this.packet;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.api.BaritoneAPI;
21 | import baritone.api.IBaritone;
22 | import baritone.api.event.events.RenderEvent;
23 | import net.minecraft.client.renderer.EntityRenderer;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Inject;
27 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28 |
29 | @Mixin(EntityRenderer.class)
30 | public class MixinEntityRenderer {
31 |
32 | @Inject(
33 | method = "renderWorldPass",
34 | at = @At(
35 | value = "INVOKE_STRING",
36 | target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
37 | args = {"ldc=hand"}
38 | )
39 | )
40 | private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
41 | for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
42 | ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/PathingCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import baritone.api.pathing.goals.Goal;
21 |
22 | import java.util.Objects;
23 |
24 | /**
25 | * @author leijurv
26 | */
27 | public class PathingCommand {
28 |
29 | /**
30 | * The target goal, may be {@code null}.
31 | */
32 | public final Goal goal;
33 |
34 | /**
35 | * The command type.
36 | *
37 | * @see PathingCommandType
38 | */
39 | public final PathingCommandType commandType;
40 |
41 | /**
42 | * Create a new {@link PathingCommand}.
43 | *
44 | * @param goal The target goal, may be {@code null}.
45 | * @param commandType The command type, cannot be {@code null}.
46 | * @throws NullPointerException if {@code commandType} is {@code null}.
47 | * @see Goal
48 | * @see PathingCommandType
49 | */
50 | public PathingCommand(Goal goal, PathingCommandType commandType) {
51 | Objects.requireNonNull(commandType);
52 |
53 | this.goal = goal;
54 | this.commandType = commandType;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return commandType + " " + goal;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/TickEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.EventState;
21 |
22 | public final class TickEvent {
23 |
24 | private final EventState state;
25 | private final Type type;
26 | private final int count;
27 |
28 | private static int overallTickCount;
29 |
30 | public TickEvent(EventState state, Type type) {
31 | this.state = state;
32 | this.type = type;
33 | this.count = incrementCount();
34 | }
35 |
36 | private static synchronized int incrementCount() {
37 | return overallTickCount++;
38 | }
39 |
40 | public int getCount() {
41 | return count;
42 | }
43 |
44 | public Type getType() {
45 | return type;
46 | }
47 |
48 | public EventState getState() {
49 | return state;
50 | }
51 |
52 |
53 | public enum Type {
54 | /**
55 | * When guarantees can be made about
56 | * the game state and in-game variables.
57 | */
58 | IN,
59 | /**
60 | * No guarantees can be made about the game state.
61 | * This probably means we are at the main menu.
62 | */
63 | OUT,
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/pathing/BetterWorldBorder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | import net.minecraft.world.border.WorldBorder;
21 |
22 | /**
23 | * Essentially, a "rule" for the path finder, prevents proposed movements from attempting to venture
24 | * into the world border, and prevents actual movements from placing blocks in the world border.
25 | */
26 | public class BetterWorldBorder {
27 |
28 | private final double minX;
29 | private final double maxX;
30 | private final double minZ;
31 | private final double maxZ;
32 |
33 | public BetterWorldBorder(WorldBorder border) {
34 | this.minX = border.minX();
35 | this.maxX = border.maxX();
36 | this.minZ = border.minZ();
37 | this.maxZ = border.maxZ();
38 | }
39 |
40 | public boolean entirelyContains(int x, int z) {
41 | return x + 1 > minX && x < maxX && z + 1 > minZ && z < maxZ;
42 | }
43 |
44 | public boolean canPlaceAt(int x, int z) {
45 | // move it in 1 block on all sides
46 | // because we can't place a block at the very edge against a block outside the border
47 | // it won't let us right click it
48 | return x > minX && x + 1 < maxX && z > minZ && z + 1 < maxZ;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/PathingCommandType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import baritone.api.Settings;
21 |
22 | public enum PathingCommandType {
23 |
24 | /**
25 | * Set the goal and path.
26 | *
27 | * If you use this alongside a {@code null} goal, it will continue along its current path and current goal.
28 | */
29 | SET_GOAL_AND_PATH,
30 |
31 | /**
32 | * Has no effect on the current goal or path, just requests a pause
33 | */
34 | REQUEST_PAUSE,
35 |
36 | /**
37 | * Set the goal (regardless of {@code null}), and request a cancel of the current path (when safe)
38 | */
39 | CANCEL_AND_SET_GOAL,
40 |
41 | /**
42 | * Set the goal and path.
43 | *
44 | * If {@link Settings#cancelOnGoalInvalidation} is {@code true}, revalidate the
45 | * current goal, and cancel if it's no longer valid, or if the new goal is {@code null}.
46 | */
47 | REVALIDATE_GOAL_AND_PATH,
48 |
49 | /**
50 | * Set the goal and path.
51 | *
52 | * Cancel the current path if the goals are not equal
53 | */
54 | FORCE_REVALIDATE_GOAL_AND_PATH,
55 |
56 | /**
57 | * Go and ask the next process what to do
58 | */
59 | DEFER
60 | }
61 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinRenderList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.Baritone;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.client.renderer.GlStateManager;
23 | import net.minecraft.client.renderer.RenderList;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Redirect;
27 |
28 | import static org.lwjgl.opengl.GL11.*;
29 |
30 | @Mixin(RenderList.class)
31 | public class MixinRenderList {
32 |
33 | @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
34 | method = "renderChunkLayer",
35 | at = @At(
36 | value = "INVOKE",
37 | target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
38 | )
39 | )
40 | private void popMatrix() {
41 | if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
42 | // reset the blend func to normal (not dependent on constant alpha)
43 | GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
44 | }
45 | GlStateManager.popMatrix();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/Goal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | /**
23 | * An abstract Goal for pathing, can be anything from a specific block to just a Y coordinate.
24 | *
25 | * @author leijurv
26 | */
27 | public interface Goal {
28 |
29 | /**
30 | * Returns whether or not the specified position
31 | * meets the requirement for this goal based.
32 | *
33 | * @param x The goal X position
34 | * @param y The goal Y position
35 | * @param z The goal Z position
36 | * @return Whether or not it satisfies this goal
37 | */
38 | boolean isInGoal(int x, int y, int z);
39 |
40 | /**
41 | * Estimate the number of ticks it will take to get to the goal
42 | *
43 | * @param x The goal X position
44 | * @param y The goal Y position
45 | * @param z The goal Z position
46 | * @return The estimate number of ticks to satisfy the goal
47 | */
48 | double heuristic(int x, int y, int z);
49 |
50 | default boolean isInGoal(BlockPos pos) {
51 | return isInGoal(pos.getX(), pos.getY(), pos.getZ());
52 | }
53 |
54 | default double heuristic(BlockPos pos) {
55 | return heuristic(pos.getX(), pos.getY(), pos.getZ());
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.Baritone;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.client.renderer.GlStateManager;
23 | import net.minecraft.client.renderer.VboRenderList;
24 | import org.spongepowered.asm.mixin.Mixin;
25 | import org.spongepowered.asm.mixin.injection.At;
26 | import org.spongepowered.asm.mixin.injection.Redirect;
27 |
28 | import static org.lwjgl.opengl.GL11.*;
29 |
30 | @Mixin(VboRenderList.class)
31 | public class MixinVboRenderList {
32 |
33 | @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
34 | method = "renderChunkLayer",
35 | at = @At(
36 | value = "INVOKE",
37 | target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
38 | )
39 | )
40 | private void popMatrix() {
41 | if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
42 | // reset the blend func to normal (not dependent on constant alpha)
43 | GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
44 | }
45 | GlStateManager.popMatrix();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/PlayerMovementInput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils;
19 |
20 | import baritone.api.utils.input.Input;
21 | import net.minecraft.util.MovementInput;
22 |
23 | public class PlayerMovementInput extends MovementInput {
24 | private final InputOverrideHandler handler;
25 |
26 | PlayerMovementInput(InputOverrideHandler handler) {
27 | this.handler = handler;
28 | }
29 |
30 | public void updatePlayerMoveState() {
31 | this.moveStrafe = 0.0F;
32 | this.moveForward = 0.0F;
33 |
34 | jump = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
35 |
36 | if (this.forwardKeyDown = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
37 | this.moveForward++;
38 | }
39 |
40 | if (this.backKeyDown = handler.isInputForcedDown(Input.MOVE_BACK)) {
41 | this.moveForward--;
42 | }
43 |
44 | if (this.leftKeyDown = handler.isInputForcedDown(Input.MOVE_LEFT)) {
45 | this.moveStrafe++;
46 | }
47 |
48 | if (this.rightKeyDown = handler.isInputForcedDown(Input.MOVE_RIGHT)) {
49 | this.moveStrafe--;
50 | }
51 |
52 | if (this.sneak = handler.isInputForcedDown(Input.SNEAK)) {
53 | this.moveStrafe *= 0.3D;
54 | this.moveForward *= 0.3D;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/IPlayerController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import net.minecraft.client.entity.EntityPlayerSP;
21 | import net.minecraft.entity.player.EntityPlayer;
22 | import net.minecraft.inventory.ClickType;
23 | import net.minecraft.item.ItemStack;
24 | import net.minecraft.util.EnumActionResult;
25 | import net.minecraft.util.EnumFacing;
26 | import net.minecraft.util.EnumHand;
27 | import net.minecraft.util.math.BlockPos;
28 | import net.minecraft.util.math.Vec3d;
29 | import net.minecraft.world.GameType;
30 | import net.minecraft.world.World;
31 |
32 | /**
33 | * @author Brady
34 | * @since 12/14/2018
35 | */
36 | public interface IPlayerController {
37 |
38 | boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side);
39 |
40 | void resetBlockRemoving();
41 |
42 | ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player);
43 |
44 | void setGameType(GameType type);
45 |
46 | GameType getGameType();
47 |
48 | default double getBlockReachDistance() {
49 | return this.getGameType().isCreative() ? 5.0F : 4.5F;
50 | }
51 |
52 | EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand);
53 |
54 | EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand);
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.goals;
19 |
20 | import baritone.api.pathing.goals.GoalGetToBlock;
21 | import net.minecraft.util.math.BlockPos;
22 | import org.junit.Test;
23 |
24 | import java.util.ArrayList;
25 | import java.util.Arrays;
26 | import java.util.List;
27 |
28 | import static org.junit.Assert.assertTrue;
29 |
30 | public class GoalGetToBlockTest {
31 |
32 | @Test
33 | public void isInGoal() {
34 | List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,-1,1", "0,-1,-1", "1,-1,0", "-1,-1,0", "0,1,0", "0,-1,0", "0,-2,0"));
35 | for (int x = -10; x <= 10; x++) {
36 | for (int y = -10; y <= 10; y++) {
37 | for (int z = -10; z <= 10; z++) {
38 | boolean inGoal = new GoalGetToBlock(new BlockPos(0, 0, 0)).isInGoal(new BlockPos(x, y, z));
39 | String repr = x + "," + y + "," + z;
40 | System.out.println(repr + " " + inGoal);
41 | if (inGoal) {
42 | assertTrue(repr, acceptableOffsets.contains(repr));
43 | acceptableOffsets.remove(repr);
44 | }
45 | }
46 | }
47 | }
48 | assertTrue(acceptableOffsets.toString(), acceptableOffsets.isEmpty());
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/BlockInteractEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import net.minecraft.util.math.BlockPos;
21 |
22 | /**
23 | * Called when the local player interacts with a block, can be either {@link Type#START_BREAK} or {@link Type#USE}.
24 | *
25 | * @author Brady
26 | * @since 8/22/2018
27 | */
28 | public final class BlockInteractEvent {
29 |
30 | /**
31 | * The position of the block interacted with
32 | */
33 | private final BlockPos pos;
34 |
35 | /**
36 | * The type of interaction that occurred
37 | */
38 | private final Type type;
39 |
40 | public BlockInteractEvent(BlockPos pos, Type type) {
41 | this.pos = pos;
42 | this.type = type;
43 | }
44 |
45 | /**
46 | * @return The position of the block interacted with
47 | */
48 | public final BlockPos getPos() {
49 | return this.pos;
50 | }
51 |
52 | /**
53 | * @return The type of interaction with the target block
54 | */
55 | public final Type getType() {
56 | return this.type;
57 | }
58 |
59 | public enum Type {
60 |
61 | /**
62 | * We're starting to break the target block.
63 | */
64 | START_BREAK,
65 |
66 | /**
67 | * We're right clicking on the target block. Either placing or interacting with.
68 | */
69 | USE
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalYLevel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.pathing.movement.ActionCosts;
21 | import baritone.api.utils.SettingsUtil;
22 |
23 | /**
24 | * Useful for mining (getting to diamond / iron level)
25 | *
26 | * @author leijurv
27 | */
28 | public class GoalYLevel implements Goal, ActionCosts {
29 |
30 | /**
31 | * The target Y level
32 | */
33 | public final int level;
34 |
35 | public GoalYLevel(int level) {
36 | this.level = level;
37 | }
38 |
39 | @Override
40 | public boolean isInGoal(int x, int y, int z) {
41 | return y == level;
42 | }
43 |
44 | @Override
45 | public double heuristic(int x, int y, int z) {
46 | return calculate(level, y);
47 | }
48 |
49 | public static double calculate(int goalY, int currentY) {
50 | if (currentY > goalY) {
51 | // need to descend
52 | return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY);
53 | }
54 | if (currentY < goalY) {
55 | // need to ascend
56 | return (goalY - currentY) * JUMP_ONE_BLOCK_COST;
57 | }
58 | return 0;
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return String.format(
64 | "GoalYLevel{y=%s}",
65 | SettingsUtil.maybeCensor(level)
66 | );
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IWaypointCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | import java.util.Set;
21 |
22 | /**
23 | * @author Brady
24 | * @since 9/24/2018
25 | */
26 | public interface IWaypointCollection {
27 |
28 | /**
29 | * Adds a waypoint to this collection
30 | *
31 | * @param waypoint The waypoint
32 | */
33 | void addWaypoint(IWaypoint waypoint);
34 |
35 | /**
36 | * Removes a waypoint from this collection
37 | *
38 | * @param waypoint The waypoint
39 | */
40 | void removeWaypoint(IWaypoint waypoint);
41 |
42 | /**
43 | * Gets the most recently created waypoint by the specified {@link IWaypoint.Tag}
44 | *
45 | * @param tag The tag
46 | * @return The most recently created waypoint with the specified tag
47 | */
48 | IWaypoint getMostRecentByTag(IWaypoint.Tag tag);
49 |
50 | /**
51 | * Gets all of the waypoints that have the specified tag
52 | *
53 | * @param tag The tag
54 | * @return All of the waypoints with the specified tag
55 | * @see IWaypointCollection#getAllWaypoints()
56 | */
57 | Set getByTag(IWaypoint.Tag tag);
58 |
59 | /**
60 | * Gets all of the waypoints in this collection, regardless of the tag.
61 | *
62 | * @return All of the waypoints in this collection
63 | * @see IWaypointCollection#getByTag(IWaypoint.Tag)
64 | */
65 | Set getAllWaypoints();
66 | }
67 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/movement/MovementStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.movement;
19 |
20 | /**
21 | * @author Brady
22 | * @since 10/8/2018
23 | */
24 | public enum MovementStatus {
25 |
26 | /**
27 | * We are preparing the movement to be executed. This is when any blocks obstructing the destination are broken.
28 | */
29 | PREPPING(false),
30 |
31 | /**
32 | * We are waiting for the movement to begin, after {@link MovementStatus#PREPPING}.
33 | */
34 | WAITING(false),
35 |
36 | /**
37 | * The movement is currently in progress, after {@link MovementStatus#WAITING}
38 | */
39 | RUNNING(false),
40 |
41 | /**
42 | * The movement has been completed and we are at our destination
43 | */
44 | SUCCESS(true),
45 |
46 | /**
47 | * There was a change in state between calculation and actual
48 | * movement execution, and the movement has now become impossible.
49 | */
50 | UNREACHABLE(true),
51 |
52 | /**
53 | * Unused
54 | */
55 | FAILED(true),
56 |
57 | /**
58 | * "Unused"
59 | */
60 | CANCELED(true);
61 |
62 | /**
63 | * Whether or not this status indicates a complete movement.
64 | */
65 | private final boolean complete;
66 |
67 | MovementStatus(boolean complete) {
68 | this.complete = complete;
69 | }
70 |
71 | public final boolean isComplete() {
72 | return this.complete;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/BaritoneTweaker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch;
19 |
20 | import io.github.impactdevelopment.simpletweaker.SimpleTweaker;
21 | import net.minecraft.launchwrapper.Launch;
22 | import net.minecraft.launchwrapper.LaunchClassLoader;
23 | import org.spongepowered.asm.launch.MixinBootstrap;
24 | import org.spongepowered.asm.mixin.MixinEnvironment;
25 | import org.spongepowered.asm.mixin.Mixins;
26 | import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
27 |
28 | import java.util.List;
29 |
30 | /**
31 | * @author Brady
32 | * @since 7/31/2018
33 | */
34 | public class BaritoneTweaker extends SimpleTweaker {
35 |
36 | @Override
37 | public void injectIntoClassLoader(LaunchClassLoader classLoader) {
38 | super.injectIntoClassLoader(classLoader);
39 |
40 | MixinBootstrap.init();
41 |
42 | // noinspection unchecked
43 | List tweakClasses = (List) Launch.blackboard.get("TweakClasses");
44 |
45 | String obfuscation = ObfuscationServiceMCP.NOTCH;
46 | if (tweakClasses.stream().anyMatch(s -> s.contains("net.minecraftforge.fml.common.launcher"))) {
47 | obfuscation = ObfuscationServiceMCP.SEARGE;
48 | }
49 |
50 | MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
51 | MixinEnvironment.getDefaultEnvironment().setObfuscationContext(obfuscation);
52 |
53 | Mixins.addConfiguration("mixins.baritone.json");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/pathing/Favoring.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | import baritone.api.pathing.calc.IPath;
21 | import baritone.api.utils.BetterBlockPos;
22 | import baritone.api.utils.Helper;
23 | import baritone.api.utils.IPlayerContext;
24 | import baritone.pathing.movement.CalculationContext;
25 | import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
26 |
27 | public final class Favoring {
28 | private final Long2DoubleOpenHashMap favorings;
29 |
30 | public Favoring(IPlayerContext ctx, IPath previous, CalculationContext context) {
31 | this(previous, context);
32 | for (Avoidance avoid : Avoidance.create(ctx)) {
33 | avoid.applySpherical(favorings);
34 | }
35 | Helper.HELPER.logDebug("Favoring size: " + favorings.size());
36 | }
37 |
38 | public Favoring(IPath previous, CalculationContext context) { // create one just from previous path, no mob avoidances
39 | favorings = new Long2DoubleOpenHashMap();
40 | favorings.defaultReturnValue(1.0D);
41 | double coeff = context.backtrackCostFavoringCoefficient;
42 | if (coeff != 1D && previous != null) {
43 | previous.positions().forEach(pos -> favorings.put(BetterBlockPos.longHash(pos), coeff));
44 | }
45 | }
46 |
47 | public boolean isEmpty() {
48 | return favorings.isEmpty();
49 | }
50 |
51 | public double calculate(long hash) {
52 | return favorings.get(hash);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/player/PrimaryPlayerContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.player;
19 |
20 | import baritone.api.BaritoneAPI;
21 | import baritone.api.cache.IWorldData;
22 | import baritone.api.utils.Helper;
23 | import baritone.api.utils.IPlayerContext;
24 | import baritone.api.utils.IPlayerController;
25 | import baritone.api.utils.RayTraceUtils;
26 | import net.minecraft.client.entity.EntityPlayerSP;
27 | import net.minecraft.util.math.RayTraceResult;
28 | import net.minecraft.world.World;
29 |
30 | /**
31 | * Implementation of {@link IPlayerContext} that provides information about the primary player.
32 | *
33 | * @author Brady
34 | * @since 11/12/2018
35 | */
36 | public enum PrimaryPlayerContext implements IPlayerContext, Helper {
37 |
38 | INSTANCE;
39 |
40 | @Override
41 | public EntityPlayerSP player() {
42 | return mc.player;
43 | }
44 |
45 | @Override
46 | public IPlayerController playerController() {
47 | return PrimaryPlayerController.INSTANCE;
48 | }
49 |
50 | @Override
51 | public World world() {
52 | return mc.world;
53 | }
54 |
55 | @Override
56 | public IWorldData worldData() {
57 | return BaritoneAPI.getProvider().getPrimaryBaritone().getWorldProvider().getCurrentWorld();
58 | }
59 |
60 | @Override
61 | public RayTraceResult objectMouseOver() {
62 | return RayTraceUtils.rayTraceTowards(player(), playerRotations(), playerController().getBlockReachDistance());
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalComposite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import java.util.Arrays;
21 |
22 | /**
23 | * A composite of many goals, any one of which satisfies the composite.
24 | * For example, a GoalComposite of block goals for every oak log in loaded chunks
25 | * would result in it pathing to the easiest oak log to get to
26 | *
27 | * @author avecowa
28 | */
29 | public class GoalComposite implements Goal {
30 |
31 | /**
32 | * An array of goals that any one of must be satisfied
33 | */
34 | private final Goal[] goals;
35 |
36 | public GoalComposite(Goal... goals) {
37 | this.goals = goals;
38 | }
39 |
40 | @Override
41 | public boolean isInGoal(int x, int y, int z) {
42 | for (Goal goal : goals) {
43 | if (goal.isInGoal(x, y, z)) {
44 | return true;
45 | }
46 | }
47 | return false;
48 | }
49 |
50 | @Override
51 | public double heuristic(int x, int y, int z) {
52 | double min = Double.MAX_VALUE;
53 | for (Goal g : goals) {
54 | // TODO technically this isn't admissible...?
55 | min = Math.min(min, g.heuristic(x, y, z)); // whichever is closest
56 | }
57 | return min;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "GoalComposite" + Arrays.toString(goals);
63 | }
64 |
65 | public Goal[] goals() {
66 | return goals;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/test/java/baritone/pathing/movement/ActionCostsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.movement;
19 |
20 | import org.junit.Test;
21 |
22 | import static baritone.api.pathing.movement.ActionCosts.*;
23 | import static org.junit.Assert.assertEquals;
24 |
25 | public class ActionCostsTest {
26 | @Test
27 | public void testFallNBlocksCost() {
28 | assertEquals(FALL_N_BLOCKS_COST.length, 257); // Fall 0 blocks through fall 256 blocks
29 | for (int i = 0; i < 257; i++) {
30 | double blocks = ticksToBlocks(FALL_N_BLOCKS_COST[i]);
31 | assertEquals(blocks, i, 0.000000000001); // If you add another 0 the test fails at i=217 LOL
32 | }
33 | assertEquals(FALL_1_25_BLOCKS_COST, 6.2344, 0.00001);
34 | assertEquals(FALL_0_25_BLOCKS_COST, 3.0710, 0.00001);
35 | assertEquals(JUMP_ONE_BLOCK_COST, 3.1634, 0.00001);
36 | }
37 |
38 | public double ticksToBlocks(double ticks) {
39 | double fallDistance = 0;
40 | int integralComponent = (int) Math.floor(ticks);
41 | for (int tick = 0; tick < integralComponent; tick++) {
42 | fallDistance += velocity(tick);
43 | }
44 | double partialTickComponent = ticks - Math.floor(ticks);
45 | double finalPartialTickVelocity = velocity(integralComponent);
46 | double finalPartialTickDistance = finalPartialTickVelocity * partialTickComponent;
47 | fallDistance += finalPartialTickDistance;
48 | return fallDistance;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/RayTraceUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import net.minecraft.entity.Entity;
21 | import net.minecraft.util.math.RayTraceResult;
22 | import net.minecraft.util.math.Vec3d;
23 |
24 | /**
25 | * @author Brady
26 | * @since 8/25/2018
27 | */
28 | public final class RayTraceUtils {
29 |
30 | private RayTraceUtils() {}
31 |
32 | /**
33 | * Performs a block raytrace with the specified rotations. This should only be used when
34 | * any entity collisions can be ignored, because this method will not recognize if an
35 | * entity is in the way or not. The local player's block reach distance will be used.
36 | *
37 | * @param entity The entity representing the raytrace source
38 | * @param rotation The rotation to raytrace towards
39 | * @param blockReachDistance The block reach distance of the entity
40 | * @return The calculated raytrace result
41 | */
42 | public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
43 | Vec3d start = entity.getPositionEyes(1.0F);
44 | Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
45 | Vec3d end = start.add(
46 | direction.x * blockReachDistance,
47 | direction.y * blockReachDistance,
48 | direction.z * blockReachDistance
49 | );
50 | return entity.world.rayTraceBlocks(start, end, false, false, true);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/RotationMoveEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import net.minecraft.entity.Entity;
21 | import net.minecraft.entity.EntityLivingBase;
22 |
23 | /**
24 | * @author Brady
25 | * @since 8/21/2018
26 | */
27 | public final class RotationMoveEvent {
28 |
29 | /**
30 | * The type of event
31 | */
32 | private final Type type;
33 |
34 | /**
35 | * The yaw rotation
36 | */
37 | private float yaw;
38 |
39 | public RotationMoveEvent(Type type, float yaw) {
40 | this.type = type;
41 | this.yaw = yaw;
42 | }
43 |
44 | /**
45 | * Set the yaw movement rotation
46 | *
47 | * @param yaw Yaw rotation
48 | */
49 | public final void setYaw(float yaw) {
50 | this.yaw = yaw;
51 | }
52 |
53 | /**
54 | * @return The yaw rotation
55 | */
56 | public final float getYaw() {
57 | return this.yaw;
58 | }
59 |
60 | /**
61 | * @return The type of the event
62 | */
63 | public final Type getType() {
64 | return this.type;
65 | }
66 |
67 | public enum Type {
68 |
69 | /**
70 | * Called when the player's motion is updated.
71 | *
72 | * @see Entity#moveRelative(float, float, float, float)
73 | */
74 | MOTION_UPDATE,
75 |
76 | /**
77 | * Called when the player jumps.
78 | *
79 | * @see EntityLivingBase#jump
80 | */
81 | JUMP
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/pathing/PathBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.pathing;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.BaritoneAPI;
22 | import baritone.api.pathing.calc.IPath;
23 | import baritone.api.pathing.goals.Goal;
24 | import baritone.pathing.path.CutoffPath;
25 | import baritone.utils.BlockStateInterface;
26 | import net.minecraft.util.math.BlockPos;
27 |
28 | public abstract class PathBase implements IPath {
29 | @Override
30 | public PathBase cutoffAtLoadedChunks(Object bsi0) { // <-- cursed cursed cursed
31 | if (!Baritone.settings().cutoffAtLoadBoundary.value) {
32 | return this;
33 | }
34 | BlockStateInterface bsi = (BlockStateInterface) bsi0;
35 | for (int i = 0; i < positions().size(); i++) {
36 | BlockPos pos = positions().get(i);
37 | if (!bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) {
38 | return new CutoffPath(this, i);
39 | }
40 | }
41 | return this;
42 | }
43 |
44 | @Override
45 | public PathBase staticCutoff(Goal destination) {
46 | int min = BaritoneAPI.getSettings().pathCutoffMinimumLength.value;
47 | if (length() < min) {
48 | return this;
49 | }
50 | if (destination == null || destination.isInGoal(getDest())) {
51 | return this;
52 | }
53 | double factor = BaritoneAPI.getSettings().pathCutoffFactor.value;
54 | int newLength = (int) ((length() - min) * factor) + min - 1;
55 | return new CutoffPath(this, newLength);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.listener;
19 |
20 | import baritone.api.event.events.*;
21 |
22 | /**
23 | * An implementation of {@link IGameEventListener} that has all methods
24 | * overridden with empty bodies, allowing inheritors of this class to choose
25 | * which events they would like to listen in on.
26 | *
27 | * @author Brady
28 | * @see IGameEventListener
29 | * @since 8/1/2018
30 | */
31 | public interface AbstractGameEventListener extends IGameEventListener {
32 |
33 | @Override
34 | default void onTick(TickEvent event) {}
35 |
36 | @Override
37 | default void onPlayerUpdate(PlayerUpdateEvent event) {}
38 |
39 | @Override
40 | default void onSendChatMessage(ChatEvent event) {}
41 |
42 | @Override
43 | default void onChunkEvent(ChunkEvent event) {}
44 |
45 | @Override
46 | default void onRenderPass(RenderEvent event) {}
47 |
48 | @Override
49 | default void onWorldEvent(WorldEvent event) {}
50 |
51 | @Override
52 | default void onSendPacket(PacketEvent event) {}
53 |
54 | @Override
55 | default void onReceivePacket(PacketEvent event) {}
56 |
57 | @Override
58 | default void onPlayerRotationMove(RotationMoveEvent event) {}
59 |
60 | @Override
61 | default void onPlayerSprintState(SprintStateEvent event) {}
62 |
63 | @Override
64 | default void onBlockInteract(BlockInteractEvent event) {}
65 |
66 | @Override
67 | default void onPlayerDeath() {}
68 |
69 | @Override
70 | default void onPathEvent(PathEvent event) {}
71 | }
72 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalNear.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import baritone.api.utils.interfaces.IGoalRenderPos;
22 | import net.minecraft.util.math.BlockPos;
23 |
24 | public class GoalNear implements Goal, IGoalRenderPos {
25 | private final int x;
26 | private final int y;
27 | private final int z;
28 | private final int rangeSq;
29 |
30 | public GoalNear(BlockPos pos, int range) {
31 | this.x = pos.getX();
32 | this.y = pos.getY();
33 | this.z = pos.getZ();
34 | this.rangeSq = range * range;
35 | }
36 |
37 | @Override
38 | public boolean isInGoal(int x, int y, int z) {
39 | int xDiff = x - this.x;
40 | int yDiff = y - this.y;
41 | int zDiff = z - this.z;
42 | return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff <= rangeSq;
43 | }
44 |
45 | @Override
46 | public double heuristic(int x, int y, int z) {
47 | int xDiff = x - this.x;
48 | int yDiff = y - this.y;
49 | int zDiff = z - this.z;
50 | return GoalBlock.calculate(xDiff, yDiff, zDiff);
51 | }
52 |
53 | @Override
54 | public BlockPos getGoalPos() {
55 | return new BlockPos(x, y, z);
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | return String.format(
61 | "GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}",
62 | SettingsUtil.maybeCensor(x),
63 | SettingsUtil.maybeCensor(y),
64 | SettingsUtil.maybeCensor(z),
65 | rangeSq
66 | );
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/baritone/pathing/path/CutoffPath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.path;
19 |
20 | import baritone.api.pathing.calc.IPath;
21 | import baritone.api.pathing.goals.Goal;
22 | import baritone.api.pathing.movement.IMovement;
23 | import baritone.api.utils.BetterBlockPos;
24 | import baritone.utils.pathing.PathBase;
25 |
26 | import java.util.Collections;
27 | import java.util.List;
28 |
29 | public class CutoffPath extends PathBase {
30 |
31 | private final List path;
32 |
33 | private final List movements;
34 |
35 | private final int numNodes;
36 |
37 | private final Goal goal;
38 |
39 | public CutoffPath(IPath prev, int firstPositionToInclude, int lastPositionToInclude) {
40 | path = prev.positions().subList(firstPositionToInclude, lastPositionToInclude + 1);
41 | movements = prev.movements().subList(firstPositionToInclude, lastPositionToInclude);
42 | numNodes = prev.getNumNodesConsidered();
43 | goal = prev.getGoal();
44 | sanityCheck();
45 | }
46 |
47 | public CutoffPath(IPath prev, int lastPositionToInclude) {
48 | this(prev, 0, lastPositionToInclude);
49 | }
50 |
51 | @Override
52 | public Goal getGoal() {
53 | return goal;
54 | }
55 |
56 | @Override
57 | public List movements() {
58 | return Collections.unmodifiableList(movements);
59 | }
60 |
61 | @Override
62 | public List positions() {
63 | return Collections.unmodifiableList(path);
64 | }
65 |
66 | @Override
67 | public int getNumNodesConsidered() {
68 | return numNodes;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/BlockPlaceHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.utils.Helper;
22 | import baritone.api.utils.IPlayerContext;
23 | import net.minecraft.util.EnumActionResult;
24 | import net.minecraft.util.EnumHand;
25 | import net.minecraft.util.math.RayTraceResult;
26 |
27 | public class BlockPlaceHelper implements Helper {
28 | private final IPlayerContext ctx;
29 | private int rightClickTimer;
30 |
31 | public BlockPlaceHelper(IPlayerContext playerContext) {
32 | this.ctx = playerContext;
33 | }
34 |
35 | public void tick(boolean rightClickRequested) {
36 | if (rightClickTimer > 0) {
37 | rightClickTimer--;
38 | return;
39 | }
40 | RayTraceResult mouseOver = ctx.objectMouseOver();
41 | if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) {
42 | return;
43 | }
44 | rightClickTimer = Baritone.settings().rightClickSpeed.value;
45 | for (EnumHand hand : EnumHand.values()) {
46 | if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) {
47 | ctx.player().swingArm(hand);
48 | return;
49 | }
50 | if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == EnumActionResult.SUCCESS) {
51 | return;
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import baritone.api.utils.interfaces.IGoalRenderPos;
22 | import net.minecraft.util.math.BlockPos;
23 |
24 |
25 | /**
26 | * Don't get into the block, but get directly adjacent to it. Useful for chests.
27 | *
28 | * @author avecowa
29 | */
30 | public class GoalGetToBlock implements Goal, IGoalRenderPos {
31 |
32 | public final int x;
33 | public final int y;
34 | public final int z;
35 |
36 | public GoalGetToBlock(BlockPos pos) {
37 | this.x = pos.getX();
38 | this.y = pos.getY();
39 | this.z = pos.getZ();
40 | }
41 |
42 | @Override
43 | public BlockPos getGoalPos() {
44 | return new BlockPos(x, y, z);
45 | }
46 |
47 | @Override
48 | public boolean isInGoal(int x, int y, int z) {
49 | int xDiff = x - this.x;
50 | int yDiff = y - this.y;
51 | int zDiff = z - this.z;
52 | return Math.abs(xDiff) + Math.abs(yDiff < 0 ? yDiff + 1 : yDiff) + Math.abs(zDiff) <= 1;
53 | }
54 |
55 | @Override
56 | public double heuristic(int x, int y, int z) {
57 | int xDiff = x - this.x;
58 | int yDiff = y - this.y;
59 | int zDiff = z - this.z;
60 | return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return String.format(
66 | "GoalGetToBlock{x=%s,y=%s,z=%s}",
67 | SettingsUtil.maybeCensor(x),
68 | SettingsUtil.maybeCensor(y),
69 | SettingsUtil.maybeCensor(z)
70 | );
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IMineProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import net.minecraft.block.Block;
21 |
22 | /**
23 | * @author Brady
24 | * @since 9/23/2018
25 | */
26 | public interface IMineProcess extends IBaritoneProcess {
27 |
28 | /**
29 | * Begin to search for and mine the specified blocks until
30 | * the number of specified items to get from the blocks that
31 | * are mined. This is based on the first target block to mine.
32 | *
33 | * @param quantity The number of items to get from blocks mined
34 | * @param blocks The blocks to mine
35 | */
36 | void mineByName(int quantity, String... blocks);
37 |
38 | /**
39 | * Begin to search for and mine the specified blocks until
40 | * the number of specified items to get from the blocks that
41 | * are mined. This is based on the first target block to mine.
42 | *
43 | * @param quantity The number of items to get from blocks mined
44 | * @param blocks The blocks to mine
45 | */
46 | void mine(int quantity, Block... blocks);
47 |
48 | /**
49 | * Begin to search for and mine the specified blocks.
50 | *
51 | * @param blocks The blocks to mine
52 | */
53 | default void mineByName(String... blocks) {
54 | mineByName(0, blocks);
55 | }
56 |
57 | /**
58 | * Begin to search for and mine the specified blocks.
59 | *
60 | * @param blocks The blocks to mine
61 | */
62 | default void mine(Block... blocks) {
63 | mine(0, blocks);
64 | }
65 |
66 | /**
67 | * Cancels the current mining task
68 | */
69 | default void cancel() {
70 | onLostControl();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.Baritone;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.client.renderer.ChunkRenderContainer;
23 | import net.minecraft.client.renderer.GlStateManager;
24 | import net.minecraft.client.renderer.chunk.RenderChunk;
25 | import net.minecraft.util.math.BlockPos;
26 | import org.lwjgl.opengl.GL14;
27 | import org.spongepowered.asm.mixin.Mixin;
28 | import org.spongepowered.asm.mixin.injection.At;
29 | import org.spongepowered.asm.mixin.injection.Redirect;
30 |
31 | import static org.lwjgl.opengl.GL11.*;
32 |
33 | @Mixin(ChunkRenderContainer.class)
34 | public class MixinChunkRenderContainer {
35 |
36 | @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second
37 | method = "preRenderChunk",
38 | at = @At(
39 | value = "INVOKE",
40 | target = "net/minecraft/client/renderer/chunk/RenderChunk.getPosition()Lnet/minecraft/util/math/BlockPos;"
41 | )
42 | )
43 | private BlockPos getPosition(RenderChunk renderChunkIn) {
44 | if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
45 | GlStateManager.enableAlpha();
46 | GlStateManager.enableBlend();
47 | GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
48 | GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
49 | }
50 | return renderChunkIn.getPosition();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/process/IBuilderProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.process;
19 |
20 | import baritone.api.utils.ISchematic;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.util.math.BlockPos;
23 | import net.minecraft.util.math.Vec3i;
24 |
25 | import java.io.File;
26 |
27 | /**
28 | * @author Brady
29 | * @since 1/15/2019
30 | */
31 | public interface IBuilderProcess extends IBaritoneProcess {
32 |
33 | /**
34 | * Requests a build for the specified schematic, labeled as specified, with the specified origin.
35 | *
36 | * @param name A user-friendly name for the schematic
37 | * @param schematic The object representation of the schematic
38 | * @param origin The origin position of the schematic being built
39 | */
40 | void build(String name, ISchematic schematic, Vec3i origin);
41 |
42 | /**
43 | * Requests a build for the specified schematic, labeled as specified, with the specified origin.
44 | *
45 | * @param name A user-friendly name for the schematic
46 | * @param schematic The file path of the schematic
47 | * @param origin The origin position of the schematic being built
48 | * @return Whether or not the schematic was able to load from file
49 | */
50 | boolean build(String name, File schematic, Vec3i origin);
51 |
52 | default boolean build(String schematicFile, BlockPos origin) {
53 | File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
54 | return build(schematicFile, file, origin);
55 | }
56 |
57 | void buildOpenSchematic();
58 |
59 | void pause();
60 |
61 | void resume();
62 |
63 | void clearArea(BlockPos corner1, BlockPos corner2);
64 | }
65 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.BaritoneAPI;
22 | import baritone.api.utils.IPlayerContext;
23 | import net.minecraft.client.Minecraft;
24 | import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
25 | import net.minecraft.util.math.BlockPos;
26 | import net.minecraft.world.World;
27 | import org.spongepowered.asm.mixin.Mixin;
28 | import org.spongepowered.asm.mixin.Shadow;
29 | import org.spongepowered.asm.mixin.injection.At;
30 | import org.spongepowered.asm.mixin.injection.Redirect;
31 |
32 | @Mixin(ChunkRenderWorker.class)
33 | public abstract class MixinChunkRenderWorker {
34 |
35 | @Shadow
36 | protected abstract boolean isChunkExisting(BlockPos pos, World worldIn);
37 |
38 | @Redirect(
39 | method = "processTask",
40 | at = @At(
41 | value = "INVOKE",
42 | target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z"
43 | )
44 | )
45 | private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
46 | if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
47 | Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
48 | IPlayerContext ctx = baritone.getPlayerContext();
49 | if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
50 | return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world);
51 | }
52 | }
53 |
54 | return this.isChunkExisting(pos, world);
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/calc/IPathFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.calc;
19 |
20 | import baritone.api.pathing.goals.Goal;
21 | import baritone.api.utils.PathCalculationResult;
22 |
23 | import java.util.Optional;
24 |
25 | /**
26 | * Generic path finder interface
27 | *
28 | * @author leijurv
29 | */
30 | public interface IPathFinder {
31 |
32 | Goal getGoal();
33 |
34 | /**
35 | * Calculate the path in full. Will take several seconds.
36 | *
37 | * @param primaryTimeout If a path is found, the path finder will stop after this amount of time
38 | * @param failureTimeout If a path isn't found, the path finder will continue for this amount of time
39 | * @return The final path
40 | */
41 | PathCalculationResult calculate(long primaryTimeout, long failureTimeout);
42 |
43 | /**
44 | * Intended to be called concurrently with calculatePath from a different thread to tell if it's finished yet
45 | *
46 | * @return Whether or not this finder is finished
47 | */
48 | boolean isFinished();
49 |
50 | /**
51 | * Called for path rendering. Returns a path to the most recent node popped from the open set and considered.
52 | *
53 | * @return The temporary path
54 | */
55 | Optional pathToMostRecentNodeConsidered();
56 |
57 | /**
58 | * The best path so far, according to the most forgiving coefficient heuristic (the reason being that that path is
59 | * most likely to represent the true shape of the path to the goal, assuming it's within a possible cost heuristic.
60 | * That's almost always a safe assumption, but in the case of a nearly impossible path, it still works by providing
61 | * a theoretically plausible but practically unlikely path)
62 | *
63 | * @return The temporary path
64 | */
65 | Optional bestPathSoFar();
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/schematic/MapArtSchematic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.schematic;
19 |
20 | import net.minecraft.block.BlockAir;
21 | import net.minecraft.block.state.IBlockState;
22 | import net.minecraft.nbt.NBTTagCompound;
23 |
24 | import java.util.OptionalInt;
25 | import java.util.function.Predicate;
26 |
27 | public class MapArtSchematic extends Schematic {
28 |
29 | private final int[][] heightMap;
30 |
31 | public MapArtSchematic(NBTTagCompound schematic) {
32 | super(schematic);
33 | heightMap = new int[widthX][lengthZ];
34 |
35 | for (int x = 0; x < widthX; x++) {
36 | for (int z = 0; z < lengthZ; z++) {
37 | IBlockState[] column = states[x][z];
38 |
39 | OptionalInt lowestBlockY = lastIndexMatching(column, state -> !(state.getBlock() instanceof BlockAir));
40 | if (lowestBlockY.isPresent()) {
41 | heightMap[x][z] = lowestBlockY.getAsInt();
42 | } else {
43 | System.out.println("Column " + x + "," + z + " has no blocks, but it's apparently map art? wtf");
44 | System.out.println("Letting it be whatever");
45 | heightMap[x][z] = 256;
46 | }
47 |
48 | }
49 | }
50 | }
51 |
52 | private static OptionalInt lastIndexMatching(T[] arr, Predicate super T> predicate) {
53 | for (int y = arr.length - 1; y >= 0; y--) {
54 | if (predicate.test(arr[y])) {
55 | return OptionalInt.of(y);
56 | }
57 | }
58 | return OptionalInt.empty();
59 | }
60 |
61 | @Override
62 | public boolean inSchematic(int x, int y, int z) {
63 | // in map art, we only care about coordinates in or above the art
64 | return super.inSchematic(x, y, z) && y >= heightMap[x][z];
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/BlockUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import net.minecraft.block.Block;
21 | import net.minecraft.util.ResourceLocation;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 | import java.util.Objects;
26 |
27 | public class BlockUtils {
28 | private static transient Map resourceCache = new HashMap<>();
29 |
30 | public static String blockToString(Block block) {
31 | ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
32 | String name = loc.getPath(); // normally, only write the part after the minecraft:
33 | if (!loc.getNamespace().equals("minecraft")) {
34 | // Baritone is running on top of forge with mods installed, perhaps?
35 | name = loc.toString(); // include the namespace with the colon
36 | }
37 | return name;
38 | }
39 |
40 | public static Block stringToBlockRequired(String name) {
41 | Block block = stringToBlockNullable(name);
42 | Objects.requireNonNull(block);
43 | return block;
44 | }
45 |
46 | public static Block stringToBlockNullable(String name) {
47 | // do NOT just replace this with a computeWithAbsent, it isn't thread safe
48 | Block block = resourceCache.get(name); // map is never mutated in place so this is safe
49 | if (block != null) {
50 | return block;
51 | }
52 | if (resourceCache.containsKey(name)) {
53 | return null; // cached as null
54 | }
55 | block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
56 | Map copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
57 | copy.put(name, block);
58 | resourceCache = copy;
59 | return block;
60 | }
61 |
62 | private BlockUtils() {}
63 | }
64 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import baritone.api.utils.interfaces.IGoalRenderPos;
22 | import net.minecraft.util.math.BlockPos;
23 |
24 | /**
25 | * Useful if the goal is just to mine a block. This goal will be satisfied if the specified
26 | * {@link BlockPos} is at to or above the specified position for this goal.
27 | *
28 | * @author leijurv
29 | */
30 | public class GoalTwoBlocks implements Goal, IGoalRenderPos {
31 |
32 | /**
33 | * The X block position of this goal
34 | */
35 | protected final int x;
36 |
37 | /**
38 | * The Y block position of this goal
39 | */
40 | protected final int y;
41 |
42 | /**
43 | * The Z block position of this goal
44 | */
45 | protected final int z;
46 |
47 | public GoalTwoBlocks(BlockPos pos) {
48 | this(pos.getX(), pos.getY(), pos.getZ());
49 | }
50 |
51 | public GoalTwoBlocks(int x, int y, int z) {
52 | this.x = x;
53 | this.y = y;
54 | this.z = z;
55 | }
56 |
57 | @Override
58 | public boolean isInGoal(int x, int y, int z) {
59 | return x == this.x && (y == this.y || y == this.y - 1) && z == this.z;
60 | }
61 |
62 | @Override
63 | public double heuristic(int x, int y, int z) {
64 | int xDiff = x - this.x;
65 | int yDiff = y - this.y;
66 | int zDiff = z - this.z;
67 | return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
68 | }
69 |
70 | @Override
71 | public BlockPos getGoalPos() {
72 | return new BlockPos(x, y, z);
73 | }
74 |
75 | @Override
76 | public String toString() {
77 | return String.format(
78 | "GoalTwoBlocks{x=%s,y=%s,z=%s}",
79 | SettingsUtil.maybeCensor(x),
80 | SettingsUtil.maybeCensor(y),
81 | SettingsUtil.maybeCensor(z)
82 | );
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/Helper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import baritone.api.BaritoneAPI;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.util.text.ITextComponent;
23 | import net.minecraft.util.text.TextComponentString;
24 | import net.minecraft.util.text.TextFormatting;
25 |
26 | /**
27 | * @author Brady
28 | * @since 8/1/2018
29 | */
30 | public interface Helper {
31 |
32 | /**
33 | * Instance of {@link Helper}. Used for static-context reference.
34 | */
35 | Helper HELPER = new Helper() {};
36 |
37 | ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format(
38 | "%s[%sBaritone%s]%s",
39 | TextFormatting.DARK_PURPLE,
40 | TextFormatting.LIGHT_PURPLE,
41 | TextFormatting.DARK_PURPLE,
42 | TextFormatting.GRAY
43 | ));
44 |
45 | Minecraft mc = Minecraft.getMinecraft();
46 |
47 | /**
48 | * Send a message to chat only if chatDebug is on
49 | *
50 | * @param message The message to display in chat
51 | */
52 | default void logDebug(String message) {
53 | if (!BaritoneAPI.getSettings().chatDebug.value) {
54 | //System.out.println("Suppressed debug message:");
55 | //System.out.println(message);
56 | return;
57 | }
58 | logDirect(message);
59 | }
60 |
61 | /**
62 | * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command)
63 | *
64 | * @param message The message to display in chat
65 | */
66 | default void logDirect(String message) {
67 | ITextComponent component = MESSAGE_PREFIX.createCopy();
68 | component.getStyle().setColor(TextFormatting.GRAY);
69 | component.appendSibling(new TextComponentString(" " + message));
70 | Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/IBaritoneProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api;
19 |
20 | import baritone.api.cache.IWorldScanner;
21 | import net.minecraft.client.entity.EntityPlayerSP;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * Provides the present {@link IBaritone} instances
27 | *
28 | * @author leijurv
29 | */
30 | public interface IBaritoneProvider {
31 |
32 | /**
33 | * Returns the primary {@link IBaritone} instance. This instance is persistent, and
34 | * is represented by the local player that is created by the game itself, not a "bot"
35 | * player through Baritone.
36 | *
37 | * @return The primary {@link IBaritone} instance.
38 | */
39 | IBaritone getPrimaryBaritone();
40 |
41 | /**
42 | * Returns all of the active {@link IBaritone} instances. This includes the local one
43 | * returned by {@link #getPrimaryBaritone()}.
44 | *
45 | * @return All active {@link IBaritone} instances.
46 | * @see #getBaritoneForPlayer(EntityPlayerSP)
47 | */
48 | List getAllBaritones();
49 |
50 | /**
51 | * Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
52 | * replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
53 | * {@code bot-system} is merged into {@code master}.
54 | *
55 | * @param player The player
56 | * @return The {@link IBaritone} instance.
57 | */
58 | default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
59 | for (IBaritone baritone : getAllBaritones()) {
60 | if (player.equals(baritone.getPlayerContext().player())) {
61 | return baritone;
62 | }
63 | }
64 | return null;
65 | }
66 |
67 | /**
68 | * Returns the {@link IWorldScanner} instance. This is not a type returned by
69 | * {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
70 | *
71 | * @return The {@link IWorldScanner} instance.
72 | */
73 | IWorldScanner getWorldScanner();
74 | }
75 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/cache/IWorldScanner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.cache;
19 |
20 | import baritone.api.utils.IPlayerContext;
21 | import net.minecraft.block.Block;
22 | import net.minecraft.util.math.BlockPos;
23 | import net.minecraft.util.math.ChunkPos;
24 |
25 | import java.util.List;
26 |
27 | /**
28 | * @author Brady
29 | * @since 10/6/2018
30 | */
31 | public interface IWorldScanner {
32 |
33 | /**
34 | * Scans the world, up to the specified max chunk radius, for the specified blocks.
35 | *
36 | * @param ctx The {@link IPlayerContext} containing player and world info that the
37 | * scan is based upon
38 | * @param blocks The blocks to scan for
39 | * @param max The maximum number of blocks to scan before cutoff
40 | * @param yLevelThreshold If a block is found within this Y level, the current result will be
41 | * returned, if the value is negative, then this condition doesn't apply.
42 | * @param maxSearchRadius The maximum chunk search radius
43 | * @return The matching block positions
44 | */
45 | List scanChunkRadius(IPlayerContext ctx, List blocks, int max, int yLevelThreshold, int maxSearchRadius);
46 |
47 | /**
48 | * Scans a single chunk for the specified blocks.
49 | *
50 | * @param ctx The {@link IPlayerContext} containing player and world info that the
51 | * scan is based upon
52 | * @param blocks The blocks to scan for
53 | * @param pos The position of the target chunk
54 | * @param max The maximum number of blocks to scan before cutoff
55 | * @param yLevelThreshold If a block is found within this Y level, the current result will be
56 | * returned, if the value is negative, then this condition doesn't apply.
57 | * @return The matching block positions
58 | */
59 | List scanChunk(IPlayerContext ctx, List blocks, ChunkPos pos, int max, int yLevelThreshold);
60 | }
61 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import net.minecraft.util.EnumFacing;
22 | import net.minecraft.util.math.BlockPos;
23 |
24 | /**
25 | * Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
26 | */
27 | public class GoalStrictDirection implements Goal {
28 | public final int x;
29 | public final int y;
30 | public final int z;
31 | public final int dx;
32 | public final int dz;
33 |
34 | public GoalStrictDirection(BlockPos origin, EnumFacing direction) {
35 | x = origin.getX();
36 | y = origin.getY();
37 | z = origin.getZ();
38 | dx = direction.getXOffset();
39 | dz = direction.getZOffset();
40 | if (dx == 0 && dz == 0) {
41 | throw new IllegalArgumentException(direction + "");
42 | }
43 | }
44 |
45 | @Override
46 | public boolean isInGoal(int x, int y, int z) {
47 | return false;
48 | }
49 |
50 | @Override
51 | public double heuristic(int x, int y, int z) {
52 | int distanceFromStartInDesiredDirection = (x - this.x) * dx + (z - this.z) * dz;
53 |
54 | int distanceFromStartInIncorrectDirection = Math.abs((x - this.x) * dz) + Math.abs((z - this.z) * dx);
55 |
56 | int verticalDistanceFromStart = Math.abs(y - this.y);
57 |
58 | // we want heuristic to decrease as desiredDirection increases
59 | double heuristic = -distanceFromStartInDesiredDirection * 100;
60 |
61 | heuristic += distanceFromStartInIncorrectDirection * 1000;
62 | heuristic += verticalDistanceFromStart * 1000;
63 | return heuristic;
64 | }
65 |
66 | @Override
67 | public String toString() {
68 | return String.format(
69 | "GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}",
70 | SettingsUtil.maybeCensor(x),
71 | SettingsUtil.maybeCensor(y),
72 | SettingsUtil.maybeCensor(z),
73 | SettingsUtil.maybeCensor(dx),
74 | SettingsUtil.maybeCensor(dz)
75 | );
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/baritone/cache/WorldData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.cache;
19 |
20 | import baritone.Baritone;
21 | import baritone.api.cache.ICachedWorld;
22 | import baritone.api.cache.IContainerMemory;
23 | import baritone.api.cache.IWaypointCollection;
24 | import baritone.api.cache.IWorldData;
25 |
26 | import java.io.IOException;
27 | import java.nio.file.Path;
28 |
29 | /**
30 | * Data about a world, from baritone's point of view. Includes cached chunks, waypoints, and map data.
31 | *
32 | * @author leijurv
33 | */
34 | public class WorldData implements IWorldData {
35 |
36 | public final CachedWorld cache;
37 | private final WaypointCollection waypoints;
38 | private final ContainerMemory containerMemory;
39 | //public final MapData map;
40 | public final Path directory;
41 | public final int dimension;
42 |
43 | WorldData(Path directory, int dimension) {
44 | this.directory = directory;
45 | this.cache = new CachedWorld(directory.resolve("cache"), dimension);
46 | this.waypoints = new WaypointCollection(directory.resolve("waypoints"));
47 | this.containerMemory = new ContainerMemory(directory.resolve("containers"));
48 | this.dimension = dimension;
49 | }
50 |
51 | public void onClose() {
52 | Baritone.getExecutor().execute(() -> {
53 | System.out.println("Started saving the world in a new thread");
54 | cache.save();
55 | });
56 | Baritone.getExecutor().execute(() -> {
57 | System.out.println("Started saving saved containers in a new thread");
58 | try {
59 | containerMemory.save();
60 | } catch (IOException e) {
61 | e.printStackTrace();
62 | System.out.println("Failed to save saved containers");
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | public ICachedWorld getCachedWorld() {
69 | return this.cache;
70 | }
71 |
72 | @Override
73 | public IWaypointCollection getWaypoints() {
74 | return this.waypoints;
75 | }
76 |
77 | @Override
78 | public IContainerMemory getContainerMemory() {
79 | return this.containerMemory;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.calc.openset;
19 |
20 | import baritone.pathing.calc.PathNode;
21 |
22 | /**
23 | * A linked list implementation of an open set. This is the original implementation from MineBot.
24 | * It has incredibly fast insert performance, at the cost of O(n) removeLowest.
25 | * It sucks. BinaryHeapOpenSet results in more than 10x more nodes considered in 4 seconds.
26 | *
27 | * @author leijurv
28 | */
29 | class LinkedListOpenSet implements IOpenSet {
30 | private Node first = null;
31 |
32 | @Override
33 | public boolean isEmpty() {
34 | return first == null;
35 | }
36 |
37 | @Override
38 | public void insert(PathNode pathNode) {
39 | Node node = new Node();
40 | node.val = pathNode;
41 | node.nextOpen = first;
42 | first = node;
43 | }
44 |
45 | @Override
46 | public void update(PathNode node) {
47 |
48 | }
49 |
50 | @Override
51 | public PathNode removeLowest() {
52 | if (first == null) {
53 | return null;
54 | }
55 | Node current = first.nextOpen;
56 | if (current == null) {
57 | Node n = first;
58 | first = null;
59 | return n.val;
60 | }
61 | Node previous = first;
62 | double bestValue = first.val.combinedCost;
63 | Node bestNode = first;
64 | Node beforeBest = null;
65 | while (current != null) {
66 | double comp = current.val.combinedCost;
67 | if (comp < bestValue) {
68 | bestValue = comp;
69 | bestNode = current;
70 | beforeBest = previous;
71 | }
72 | previous = current;
73 | current = current.nextOpen;
74 | }
75 | if (beforeBest == null) {
76 | first = first.nextOpen;
77 | bestNode.nextOpen = null;
78 | return bestNode.val;
79 | }
80 | beforeBest.nextOpen = bestNode.nextOpen;
81 | bestNode.nextOpen = null;
82 | return bestNode.val;
83 | }
84 |
85 | public static class Node { //wrapper with next
86 | private Node nextOpen;
87 | private PathNode val;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/event/events/ChunkEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.event.events;
19 |
20 | import baritone.api.event.events.type.EventState;
21 |
22 | /**
23 | * @author Brady
24 | * @since 8/2/2018
25 | */
26 | public final class ChunkEvent {
27 |
28 | /**
29 | * The state of the event
30 | */
31 | private final EventState state;
32 |
33 | /**
34 | * The type of chunk event that occurred
35 | *
36 | * @see Type
37 | */
38 | private final Type type;
39 |
40 | /**
41 | * The Chunk X position.
42 | */
43 | private final int x;
44 |
45 | /**
46 | * The Chunk Z position.
47 | */
48 | private final int z;
49 |
50 | public ChunkEvent(EventState state, Type type, int x, int z) {
51 | this.state = state;
52 | this.type = type;
53 | this.x = x;
54 | this.z = z;
55 | }
56 |
57 | /**
58 | * @return The state of the event
59 | */
60 | public final EventState getState() {
61 | return this.state;
62 | }
63 |
64 | /**
65 | * @return The type of chunk event that occurred;
66 | */
67 | public final Type getType() {
68 | return this.type;
69 | }
70 |
71 | /**
72 | * @return The Chunk X position.
73 | */
74 | public final int getX() {
75 | return this.x;
76 | }
77 |
78 | /**
79 | * @return The Chunk Z position.
80 | */
81 | public final int getZ() {
82 | return this.z;
83 | }
84 |
85 | public enum Type {
86 |
87 | /**
88 | * When the chunk is constructed.
89 | */
90 | LOAD,
91 |
92 | /**
93 | * When the chunk is deconstructed.
94 | */
95 | UNLOAD,
96 |
97 | /**
98 | * When the chunk is being populated with blocks, tile entities, etc.
99 | *
100 | * And it's a full chunk
101 | */
102 | POPULATE_FULL,
103 |
104 | /**
105 | * When the chunk is being populated with blocks, tile entities, etc.
106 | *
107 | * And it's a partial chunk
108 | */
109 | POPULATE_PARTIAL
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/java/baritone/pathing/movement/MovementState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.pathing.movement;
19 |
20 | import baritone.api.pathing.movement.MovementStatus;
21 | import baritone.api.utils.Rotation;
22 | import baritone.api.utils.input.Input;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 | import java.util.Optional;
27 |
28 | public class MovementState {
29 |
30 | private MovementStatus status;
31 | private MovementTarget target = new MovementTarget();
32 | private final Map inputState = new HashMap<>();
33 |
34 | public MovementState setStatus(MovementStatus status) {
35 | this.status = status;
36 | return this;
37 | }
38 |
39 | public MovementStatus getStatus() {
40 | return status;
41 | }
42 |
43 | public MovementTarget getTarget() {
44 | return this.target;
45 | }
46 |
47 | public MovementState setTarget(MovementTarget target) {
48 | this.target = target;
49 | return this;
50 | }
51 |
52 | public MovementState setInput(Input input, boolean forced) {
53 | this.inputState.put(input, forced);
54 | return this;
55 | }
56 |
57 | public Map getInputStates() {
58 | return this.inputState;
59 | }
60 |
61 | public static class MovementTarget {
62 |
63 | /**
64 | * Yaw and pitch angles that must be matched
65 | */
66 | public Rotation rotation;
67 |
68 | /**
69 | * Whether or not this target must force rotations.
70 | *
71 | * {@code true} if we're trying to place or break blocks, {@code false} if we're trying to look at the movement location
72 | */
73 | private boolean forceRotations;
74 |
75 | public MovementTarget() {
76 | this(null, false);
77 | }
78 |
79 | public MovementTarget(Rotation rotation, boolean forceRotations) {
80 | this.rotation = rotation;
81 | this.forceRotations = forceRotations;
82 | }
83 |
84 | public final Optional getRotation() {
85 | return Optional.ofNullable(this.rotation);
86 | }
87 |
88 | public boolean hasToForceRotations() {
89 | return this.forceRotations;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/launch/java/baritone/launch/mixins/MixinWorldClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.launch.mixins;
19 |
20 | import baritone.api.BaritoneAPI;
21 | import baritone.api.IBaritone;
22 | import baritone.api.event.events.ChunkEvent;
23 | import baritone.api.event.events.type.EventState;
24 | import net.minecraft.client.multiplayer.WorldClient;
25 | import org.spongepowered.asm.mixin.Mixin;
26 | import org.spongepowered.asm.mixin.injection.At;
27 | import org.spongepowered.asm.mixin.injection.Inject;
28 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29 |
30 | /**
31 | * @author Brady
32 | * @since 8/2/2018
33 | */
34 | @Mixin(WorldClient.class)
35 | public class MixinWorldClient {
36 |
37 | @Inject(
38 | method = "doPreChunk",
39 | at = @At("HEAD")
40 | )
41 | private void preDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
42 | for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
43 | if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
44 | ibaritone.getGameEventHandler().onChunkEvent(
45 | new ChunkEvent(
46 | EventState.PRE,
47 | loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
48 | chunkX,
49 | chunkZ
50 | )
51 | );
52 | }
53 | }
54 |
55 | }
56 |
57 | @Inject(
58 | method = "doPreChunk",
59 | at = @At("RETURN")
60 | )
61 | private void postDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
62 | for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
63 | if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
64 | ibaritone.getGameEventHandler().onChunkEvent(
65 | new ChunkEvent(
66 | EventState.POST,
67 | loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
68 | chunkX,
69 | chunkZ
70 | )
71 | );
72 | }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import baritone.api.utils.interfaces.IGoalRenderPos;
22 | import net.minecraft.util.math.BlockPos;
23 |
24 | /**
25 | * A specific BlockPos goal
26 | *
27 | * @author leijurv
28 | */
29 | public class GoalBlock implements Goal, IGoalRenderPos {
30 |
31 | /**
32 | * The X block position of this goal
33 | */
34 | public final int x;
35 |
36 | /**
37 | * The Y block position of this goal
38 | */
39 | public final int y;
40 |
41 | /**
42 | * The Z block position of this goal
43 | */
44 | public final int z;
45 |
46 | public GoalBlock(BlockPos pos) {
47 | this(pos.getX(), pos.getY(), pos.getZ());
48 | }
49 |
50 | public GoalBlock(int x, int y, int z) {
51 | this.x = x;
52 | this.y = y;
53 | this.z = z;
54 | }
55 |
56 | @Override
57 | public boolean isInGoal(int x, int y, int z) {
58 | return x == this.x && y == this.y && z == this.z;
59 | }
60 |
61 | @Override
62 | public double heuristic(int x, int y, int z) {
63 | int xDiff = x - this.x;
64 | int yDiff = y - this.y;
65 | int zDiff = z - this.z;
66 | return calculate(xDiff, yDiff, zDiff);
67 | }
68 |
69 | @Override
70 | public String toString() {
71 | return String.format(
72 | "GoalBlock{x=%s,y=%s,z=%s}",
73 | SettingsUtil.maybeCensor(x),
74 | SettingsUtil.maybeCensor(y),
75 | SettingsUtil.maybeCensor(z)
76 | );
77 | }
78 |
79 | /**
80 | * @return The position of this goal as a {@link BlockPos}
81 | */
82 | @Override
83 | public BlockPos getGoalPos() {
84 | return new BlockPos(x, y, z);
85 | }
86 |
87 | public static double calculate(double xDiff, int yDiff, double zDiff) {
88 | double heuristic = 0;
89 |
90 | // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be
91 | // therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
92 | heuristic += GoalYLevel.calculate(yDiff, 0);
93 |
94 | //use the pythagorean and manhattan mixture from GoalXZ
95 | heuristic += GoalXZ.calculate(xDiff, zDiff);
96 | return heuristic;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/pathing/goals/GoalRunAway.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.pathing.goals;
19 |
20 | import baritone.api.utils.SettingsUtil;
21 | import net.minecraft.util.math.BlockPos;
22 |
23 | import java.util.Arrays;
24 |
25 | /**
26 | * Useful for automated combat (retreating specifically)
27 | *
28 | * @author leijurv
29 | */
30 | public class GoalRunAway implements Goal {
31 |
32 | private final BlockPos[] from;
33 |
34 | private final double distanceSq;
35 |
36 | private final Integer maintainY;
37 |
38 | public GoalRunAway(double distance, BlockPos... from) {
39 | this(distance, null, from);
40 | }
41 |
42 | public GoalRunAway(double distance, Integer maintainY, BlockPos... from) {
43 | if (from.length == 0) {
44 | throw new IllegalArgumentException();
45 | }
46 | this.from = from;
47 | this.distanceSq = distance * distance;
48 | this.maintainY = maintainY;
49 | }
50 |
51 | @Override
52 | public boolean isInGoal(int x, int y, int z) {
53 | if (maintainY != null && maintainY != y) {
54 | return false;
55 | }
56 | for (BlockPos p : from) {
57 | int diffX = x - p.getX();
58 | int diffZ = z - p.getZ();
59 | double distSq = diffX * diffX + diffZ * diffZ;
60 | if (distSq < distanceSq) {
61 | return false;
62 | }
63 | }
64 | return true;
65 | }
66 |
67 | @Override
68 | public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock
69 | double min = Double.MAX_VALUE;
70 | for (BlockPos p : from) {
71 | double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
72 | if (h < min) {
73 | min = h;
74 | }
75 | }
76 | min = -min;
77 | if (maintainY != null) {
78 | min = min * 0.6 + GoalYLevel.calculate(maintainY, y) * 1.5;
79 | }
80 | return min;
81 | }
82 |
83 | @Override
84 | public String toString() {
85 | if (maintainY != null) {
86 | return String.format(
87 | "GoalRunAwayFromMaintainY y=%s, %s",
88 | SettingsUtil.maybeCensor(maintainY),
89 | Arrays.asList(from)
90 | );
91 | } else {
92 | return "GoalRunAwayFrom" + Arrays.asList(from);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/baritone/utils/player/PrimaryPlayerController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.utils.player;
19 |
20 | import baritone.api.utils.Helper;
21 | import baritone.api.utils.IPlayerController;
22 | import net.minecraft.client.entity.EntityPlayerSP;
23 | import net.minecraft.client.multiplayer.WorldClient;
24 | import net.minecraft.entity.player.EntityPlayer;
25 | import net.minecraft.inventory.ClickType;
26 | import net.minecraft.item.ItemStack;
27 | import net.minecraft.util.EnumActionResult;
28 | import net.minecraft.util.EnumFacing;
29 | import net.minecraft.util.EnumHand;
30 | import net.minecraft.util.math.BlockPos;
31 | import net.minecraft.util.math.Vec3d;
32 | import net.minecraft.world.GameType;
33 | import net.minecraft.world.World;
34 |
35 | /**
36 | * Implementation of {@link IPlayerController} that chains to the primary player controller's methods
37 | *
38 | * @author Brady
39 | * @since 12/14/2018
40 | */
41 | public enum PrimaryPlayerController implements IPlayerController, Helper {
42 |
43 | INSTANCE;
44 |
45 | @Override
46 | public boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side) {
47 | return mc.playerController.onPlayerDamageBlock(pos, side);
48 | }
49 |
50 | @Override
51 | public void resetBlockRemoving() {
52 | mc.playerController.resetBlockRemoving();
53 | }
54 |
55 | @Override
56 | public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player) {
57 | return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player);
58 | }
59 |
60 | @Override
61 | public void setGameType(GameType type) {
62 | mc.playerController.setGameType(type);
63 | }
64 |
65 | @Override
66 | public GameType getGameType() {
67 | return mc.playerController.getCurrentGameType();
68 | }
69 |
70 | @Override
71 | public EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand) {
72 | // primaryplayercontroller is always in a WorldClient so this is ok
73 | return mc.playerController.processRightClickBlock(player, (WorldClient) world, pos, direction, vec, hand);
74 | }
75 |
76 | @Override
77 | public EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand) {
78 | return mc.playerController.processRightClick(player, world, hand);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/api/java/baritone/api/utils/ISchematic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Baritone.
3 | *
4 | * Baritone is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * Baritone is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with Baritone. If not, see .
16 | */
17 |
18 | package baritone.api.utils;
19 |
20 | import net.minecraft.block.state.IBlockState;
21 | import net.minecraft.util.EnumFacing;
22 |
23 | /**
24 | * Basic representation of a schematic. Provides the dimensions and
25 | * the desired statefor a given position relative to the origin.
26 | *
27 | * @author leijurv
28 | */
29 | public interface ISchematic {
30 |
31 | /**
32 | * Does the block at this coordinate matter to the schematic?
33 | *
34 | * Normally just a check for if the coordinate is in the cube.
35 | *
36 | * However, in the case of something like a map art, anything that's below the level of the map art doesn't matter,
37 | * so this function should return false in that case. (i.e. it doesn't really have to be air below the art blocks)
38 | *
39 | * @param x The x position of the block, relative to the origin
40 | * @param y The y position of the block, relative to the origin
41 | * @param z The z position of the block, relative to the origin
42 | * @return Whether or not the specified position is within the bounds of this schematic
43 | */
44 | default boolean inSchematic(int x, int y, int z) {
45 | return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
46 | }
47 |
48 | default int size(EnumFacing.Axis axis) {
49 | switch (axis) {
50 | case X:
51 | return widthX();
52 | case Y:
53 | return heightY();
54 | case Z:
55 | return lengthZ();
56 | default:
57 | throw new UnsupportedOperationException(axis + "");
58 | }
59 | }
60 |
61 | /**
62 | * Returns the desired block state at a given (X, Y, Z) position relative to the origin (0, 0, 0).
63 | *
64 | * @param x The x position of the block, relative to the origin
65 | * @param y The y position of the block, relative to the origin
66 | * @param z The z position of the block, relative to the origin
67 | * @return The desired block state at the specified position
68 | */
69 | IBlockState desiredState(int x, int y, int z);
70 |
71 | /**
72 | * @return The width (X axis length) of this schematic
73 | */
74 | int widthX();
75 |
76 | /**
77 | * @return The height (Y axis length) of this schematic
78 | */
79 | int heightY();
80 |
81 | /**
82 | * @return The length (Z axis length) of this schematic
83 | */
84 | int lengthZ();
85 | }
--------------------------------------------------------------------------------