├── .gitattributes ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── question.md │ ├── suggestion.md │ └── bug.md └── workflows │ ├── run_tests.yml │ └── gradle_build.yml ├── LICENSE-Part-2.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea └── copyright │ ├── profiles_settings.xml │ └── Baritone.xml ├── forge ├── src │ └── main │ │ ├── resources │ │ └── pack.mcmeta │ │ └── java │ │ └── baritone │ │ └── launch │ │ └── BaritoneForgeModXD.java └── gradle.properties ├── jitpack.yml ├── src ├── launch │ ├── resources │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── mixins.baritone.json │ └── java │ │ └── baritone │ │ └── launch │ │ ├── BaritoneMixinConnector.java │ │ └── mixins │ │ ├── MixinPalettedContainer$Data.java │ │ ├── MixinEntityRenderManager.java │ │ └── MixinPlayerController.java ├── schematica_api │ └── java │ │ ├── fi │ │ └── dy │ │ │ └── masa │ │ │ └── litematica │ │ │ ├── Litematica.java │ │ │ ├── world │ │ │ ├── SchematicWorldHandler.java │ │ │ └── WorldSchematic.java │ │ │ ├── schematic │ │ │ ├── LitematicaSchematic.java │ │ │ └── placement │ │ │ │ ├── SchematicPlacementManager.java │ │ │ │ ├── SubRegionPlacement.java │ │ │ │ └── SchematicPlacement.java │ │ │ └── data │ │ │ └── DataManager.java │ │ └── com │ │ └── github │ │ └── lunatrius │ │ ├── schematica │ │ ├── proxy │ │ │ ├── CommonProxy.java │ │ │ └── ClientProxy.java │ │ ├── Schematica.java │ │ ├── api │ │ │ └── ISchematic.java │ │ └── client │ │ │ └── world │ │ │ └── SchematicWorld.java │ │ └── core │ │ └── util │ │ └── math │ │ └── MBlockPos.java ├── main │ └── java │ │ └── baritone │ │ ├── pathing │ │ ├── precompute │ │ │ └── Ternary.java │ │ └── calc │ │ │ └── openset │ │ │ └── IOpenSet.java │ │ ├── KeepName.java │ │ ├── utils │ │ ├── accessor │ │ │ ├── IGuiScreen.java │ │ │ ├── IEntityRenderManager.java │ │ │ ├── IFireworkRocketEntity.java │ │ │ ├── IClientChunkProvider.java │ │ │ ├── IChunkProviderClient.java │ │ │ ├── IPlayerControllerMP.java │ │ │ ├── IChunkArray.java │ │ │ └── IPalettedContainer.java │ │ ├── BaritoneMath.java │ │ ├── PathingCommandContext.java │ │ ├── pathing │ │ │ ├── MutableMoveResult.java │ │ │ ├── PathingBlockType.java │ │ │ └── BetterWorldBorder.java │ │ ├── BaritoneProcessHelper.java │ │ ├── schematic │ │ │ ├── schematica │ │ │ │ ├── SchematicaHelper.java │ │ │ │ └── SchematicAdapter.java │ │ │ ├── SchematicSystem.java │ │ │ └── StaticSchematic.java │ │ └── PlayerMovementInput.java │ │ ├── process │ │ └── elytra │ │ │ ├── PathCalculationException.java │ │ │ └── NetherPath.java │ │ ├── command │ │ ├── CommandSystem.java │ │ └── defaults │ │ │ ├── GcCommand.java │ │ │ ├── ClickCommand.java │ │ │ ├── SchematicaCommand.java │ │ │ ├── SaveAllCommand.java │ │ │ └── ReloadAllCommand.java │ │ └── behavior │ │ └── Behavior.java ├── api │ └── java │ │ └── baritone │ │ └── api │ │ ├── utils │ │ ├── accessor │ │ │ └── IItemStack.java │ │ ├── interfaces │ │ │ └── IGoalRenderPos.java │ │ ├── BooleanBinaryOperator.java │ │ ├── IInputOverrideHandler.java │ │ ├── MyChunkPos.java │ │ ├── BooleanBinaryOperators.java │ │ ├── TypeUtils.java │ │ ├── PathCalculationResult.java │ │ ├── Pair.java │ │ └── input │ │ │ └── Input.java │ │ ├── command │ │ ├── ICommandSystem.java │ │ ├── exception │ │ │ ├── CommandInvalidStateException.java │ │ │ ├── CommandTooManyArgumentsException.java │ │ │ ├── CommandNoParserForTypeException.java │ │ │ ├── CommandNotEnoughArgumentsException.java │ │ │ ├── CommandException.java │ │ │ ├── CommandErrorMessageException.java │ │ │ ├── CommandNotFoundException.java │ │ │ ├── CommandUnhandledException.java │ │ │ ├── CommandInvalidArgumentException.java │ │ │ ├── CommandInvalidTypeException.java │ │ │ └── ICommandException.java │ │ ├── datatypes │ │ │ ├── IDatatypePostFunction.java │ │ │ ├── IDatatypeContext.java │ │ │ ├── ForDirection.java │ │ │ ├── ForAxis.java │ │ │ ├── IDatatypePost.java │ │ │ ├── RelativeGoalYLevel.java │ │ │ ├── IDatatypeFor.java │ │ │ ├── RelativeGoalXZ.java │ │ │ └── EntityClassById.java │ │ ├── manager │ │ │ └── ICommandManager.java │ │ └── IBaritoneChatControl.java │ │ ├── pathing │ │ ├── path │ │ │ └── IPathExecutor.java │ │ ├── calc │ │ │ └── IPathingControlManager.java │ │ ├── movement │ │ │ └── IMovement.java │ │ └── goals │ │ │ └── GoalAxis.java │ │ ├── process │ │ ├── IExploreProcess.java │ │ ├── IGetToBlockProcess.java │ │ ├── IFarmProcess.java │ │ ├── IElytraProcess.java │ │ ├── ICustomGoalProcess.java │ │ ├── IFollowProcess.java │ │ └── PathingCommand.java │ │ ├── event │ │ ├── events │ │ │ ├── type │ │ │ │ ├── EventState.java │ │ │ │ ├── ICancellable.java │ │ │ │ ├── Cancellable.java │ │ │ │ └── Overrideable.java │ │ │ ├── SprintStateEvent.java │ │ │ ├── PathEvent.java │ │ │ ├── TabCompleteEvent.java │ │ │ ├── ChatEvent.java │ │ │ ├── PlayerUpdateEvent.java │ │ │ ├── BlockChangeEvent.java │ │ │ ├── WorldEvent.java │ │ │ ├── RenderEvent.java │ │ │ ├── PacketEvent.java │ │ │ └── BlockInteractEvent.java │ │ └── listener │ │ │ └── IEventBus.java │ │ ├── behavior │ │ ├── IBehavior.java │ │ └── look │ │ │ ├── ITickableAimProcessor.java │ │ │ └── IAimProcessor.java │ │ ├── cache │ │ ├── IBlockTypeAccess.java │ │ ├── IWorldProvider.java │ │ ├── IWorldData.java │ │ └── ICachedRegion.java │ │ ├── schematic │ │ ├── CompositeSchematicEntry.java │ │ ├── WallsSchematic.java │ │ ├── ShellSchematic.java │ │ ├── AbstractSchematic.java │ │ ├── mask │ │ │ ├── AbstractMask.java │ │ │ ├── PreComputedMask.java │ │ │ └── operator │ │ │ │ └── NotMask.java │ │ ├── format │ │ │ └── ISchematicFormat.java │ │ ├── ISchematicSystem.java │ │ ├── FillSchematic.java │ │ └── ReplaceSchematic.java │ │ └── BaritoneAPI.java └── test │ └── java │ └── baritone │ ├── utils │ └── pathing │ │ └── PathingBlockTypeTest.java │ ├── cache │ └── CachedRegionTest.java │ └── pathing │ └── goals │ └── GoalGetToBlockTest.java ├── .gitlab-ci.yml ├── Dockerfile ├── gradle.properties ├── .gitignore ├── fabric └── src │ └── main │ └── resources │ └── fabric.mod.json ├── .gitmessage └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE-Part-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cabaletta/baritone/HEAD/LICENSE-Part-2.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cabaletta/baritone/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /forge/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "null", 4 | "pack_format": 8 5 | } 6 | } -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - curl -s "https://get.sdkman.io" | bash 3 | - sdk install java 17.0.5-tem 4 | - sdk use java 17.0.5-tem 5 | -------------------------------------------------------------------------------- /src/launch/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | MixinConfigs: mixins.baritone.json 3 | MixinConnector: baritone.launch.BaritoneMixinConnector 4 | Implementation-Title: Baritone 5 | Implementation-Version: version 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: java:8 2 | 3 | before_script: 4 | - which java 5 | - which javac 6 | 7 | build: 8 | script: 9 | - ./gradlew build 10 | - ./gradlew build -Pbaritone.forge_build 11 | artifacts: 12 | paths: 13 | - dist/* 14 | expire_in: 1 week 15 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:focal 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | RUN apt update -y 6 | 7 | RUN apt install \ 8 | openjdk-17-jdk \ 9 | git \ 10 | --assume-yes 11 | 12 | COPY . /code 13 | 14 | WORKDIR /code 15 | 16 | RUN ./gradlew build 17 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G 2 | 3 | mod_version=1.9.5 4 | maven_group=baritone 5 | archives_base_name=baritone 6 | 7 | java_version=17 8 | 9 | minecraft_version=1.19.4 10 | 11 | forge_version=45.0.43 12 | 13 | fabric_version=0.14.11 14 | 15 | nether_pathfinder_version=1.4.1 16 | 17 | // These dependencies are used for common and tweaker 18 | // while mod loaders usually ship their own version 19 | mixin_version=0.8.5 20 | asm_version=9.3 21 | -------------------------------------------------------------------------------- /.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 | - [x] I know how to properly use check boxes 14 | - [ ] I have not used any OwO's or UwU's in this issue. 15 | -------------------------------------------------------------------------------- /.github/workflows/run_tests.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Tests 3 | 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | test: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: '17' 19 | distribution: 'temurin' 20 | 21 | - name: Grant execute permission for gradlew 22 | run: chmod +x gradlew 23 | 24 | - name: Executing tests 25 | run: ./gradlew test 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | **/*.swp 3 | 4 | run/ 5 | autotest/ 6 | dist/ 7 | volderyarn/ 8 | 9 | # Gradle 10 | build/ 11 | .gradle/ 12 | classes/ 13 | *.class 14 | 15 | /out 16 | 17 | # IntelliJ Files 18 | .idea/ 19 | *.iml 20 | *.ipr 21 | *.iws 22 | /logs/ 23 | 24 | tweaker/logs/ 25 | common/logs/ 26 | 27 | # Eclipse Files 28 | .classpath 29 | .project 30 | .settings/ 31 | baritone_Client.launch 32 | 33 | # Copyright Files 34 | !/.idea/copyright/Baritone.xml 35 | !/.idea/copyright/profiles_settings.xml 36 | 37 | .vscode/launch.json 38 | .architectury-transformer 39 | 40 | 41 | mapping 42 | 43 | libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar 44 | libs/java-objc-bridge-1.1.jar 45 | 46 | mapping 47 | -------------------------------------------------------------------------------- /.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 | - [x] I know how to properly use check boxes 20 | - [ ] I have not used any OwO's or UwU's in this issue. 21 | -------------------------------------------------------------------------------- /forge/gradle.properties: -------------------------------------------------------------------------------- 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 | loom.platform=forge -------------------------------------------------------------------------------- /src/launch/resources/mixins.baritone.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "baritone.launch.mixins", 4 | "compatibilityLevel": "JAVA_17", 5 | "verbose": false, 6 | "injectors": { 7 | "maxShiftBy": 2, 8 | "defaultRequire": 1 9 | }, 10 | "client": [ 11 | "MixinChunkArray", 12 | "MixinClientChunkProvider", 13 | "MixinClientPlayerEntity", 14 | "MixinClientPlayNetHandler", 15 | "MixinCommandSuggestionHelper", 16 | "MixinEntity", 17 | "MixinEntityRenderManager", 18 | "MixinFireworkRocketEntity", 19 | "MixinItemStack", 20 | "MixinLivingEntity", 21 | "MixinLootContext", 22 | "MixinMinecraft", 23 | "MixinNetworkManager", 24 | "MixinPalettedContainer", 25 | "MixinPalettedContainer$Data", 26 | "MixinPlayerController", 27 | "MixinScreen", 28 | "MixinWorldRenderer" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/Litematica.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 fi.dy.masa.litematica; 19 | 20 | public class Litematica { 21 | } -------------------------------------------------------------------------------- /src/main/java/baritone/pathing/precompute/Ternary.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.precompute; 19 | 20 | public enum Ternary { 21 | YES, MAYBE, NO 22 | } 23 | -------------------------------------------------------------------------------- /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/utils/accessor/IItemStack.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.accessor; 19 | 20 | public interface IItemStack { 21 | 22 | int getBaritoneHash(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/baritone/KeepName.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 | // Annotation for classes and class members that should not be renamed by proguard 21 | public @interface KeepName {} 22 | -------------------------------------------------------------------------------- /fabric/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "schemaVersion": 1, 4 | "id": "baritone", 5 | "version": "${version}", 6 | 7 | "name": "Baritone", 8 | "description": "Google Maps for Blockgame", 9 | "authors": [ 10 | "leijurv", "Brady" 11 | ], 12 | "contact": { 13 | "homepage": "https://github.com/cabaletta/baritone", 14 | "sources": "https://github.com/cabaletta/baritone", 15 | "issues": "https://github.com/cabaletta/baritone/issues" 16 | }, 17 | 18 | "license": "LGPL-3.0", 19 | "icon": "assets/baritone/icon.png", 20 | 21 | "environment": "*", 22 | "entrypoints": { 23 | }, 24 | "mixins": [ 25 | "mixins.baritone.json" 26 | ], 27 | 28 | "depends": { 29 | "fabricloader": ">=0.11.0", 30 | "minecraft": "1.19.4" 31 | }, 32 | "custom": { 33 | "modmenu": { 34 | "links": { 35 | "modmenu.discord": "https://discord.gg/s6fRBAUpmr" 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.idea/copyright/Baritone.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /forge/src/main/java/baritone/launch/BaritoneForgeModXD.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;import net.minecraftforge.fml.common.Mod; 19 | 20 | @Mod("baritoe") 21 | public class BaritoneForgeModXD { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/accessor/IGuiScreen.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 java.net.URI; 21 | 22 | public interface IGuiScreen { 23 | 24 | void openLinkInvoker(URI url); 25 | } 26 | -------------------------------------------------------------------------------- /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.core.BlockPos; 21 | 22 | public interface IGoalRenderPos { 23 | 24 | BlockPos getGoalPos(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/accessor/IEntityRenderManager.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 | public interface IEntityRenderManager { 21 | 22 | double renderPosX(); 23 | 24 | double renderPosY(); 25 | 26 | double renderPosZ(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/accessor/IFireworkRocketEntity.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.entity.LivingEntity; 21 | 22 | public interface IFireworkRocketEntity { 23 | 24 | LivingEntity getBoostedEntity(); 25 | } 26 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/utils/BooleanBinaryOperator.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 | /** 21 | * @author Brady 22 | */ 23 | @FunctionalInterface 24 | public interface BooleanBinaryOperator { 25 | 26 | boolean applyAsBoolean(boolean a, boolean b); 27 | } 28 | -------------------------------------------------------------------------------- /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 | 24 | public static CommonProxy proxy; 25 | } 26 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/world/SchematicWorldHandler.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 fi.dy.masa.litematica.world; 19 | 20 | public class SchematicWorldHandler { 21 | 22 | public static WorldSchematic getSchematicWorld() { 23 | throw new LinkageError(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/ICommandSystem.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.command; 19 | 20 | import baritone.api.command.argparser.IArgParserManager; 21 | 22 | /** 23 | * @author Brady 24 | * @since 10/4/2019 25 | */ 26 | public interface ICommandSystem { 27 | 28 | IArgParserManager getParserManager(); 29 | } 30 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandInvalidStateException.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.command.exception; 19 | 20 | public class CommandInvalidStateException extends CommandErrorMessageException { 21 | 22 | public CommandInvalidStateException(String reason) { 23 | super(reason); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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/main/java/baritone/utils/accessor/IClientChunkProvider.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.client.multiplayer.ClientChunkCache; 21 | 22 | public interface IClientChunkProvider { 23 | ClientChunkCache createThreadSafeCopy(); 24 | 25 | IChunkArray extractReferenceArray(); 26 | } 27 | -------------------------------------------------------------------------------- /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 | 24 | public static SchematicWorld schematic; 25 | } 26 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/schematic/LitematicaSchematic.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 fi.dy.masa.litematica.schematic; 19 | 20 | import net.minecraft.core.BlockPos; 21 | 22 | public class LitematicaSchematic { 23 | 24 | public BlockPos getAreaSize(String name) { 25 | throw new LinkageError(); 26 | } 27 | } -------------------------------------------------------------------------------- /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.level.chunk.LevelChunk; 22 | 23 | public interface IChunkProviderClient { 24 | 25 | Long2ObjectMap loadedChunks(); 26 | } 27 | -------------------------------------------------------------------------------- /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 | 24 | void explore(int centerX, int centerZ); 25 | 26 | void applyJsonFilter(Path path, boolean invert) throws Exception; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/baritone/process/elytra/PathCalculationException.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 | 19 | package baritone.process.elytra; 20 | 21 | /** 22 | * @author Brady 23 | */ 24 | public final class PathCalculationException extends RuntimeException { 25 | 26 | public PathCalculationException(final String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/IDatatypePostFunction.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.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | 22 | /** 23 | * @author Brady 24 | * @since 9/26/2019 25 | */ 26 | public interface IDatatypePostFunction { 27 | 28 | T apply(O original) throws CommandException; 29 | } 30 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/data/DataManager.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 fi.dy.masa.litematica.data; 19 | 20 | import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager; 21 | 22 | public class DataManager { 23 | 24 | public static SchematicPlacementManager getSchematicPlacementManager() { 25 | throw new LinkageError(); 26 | } 27 | } -------------------------------------------------------------------------------- /.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 | Other mods (if used): 15 | 16 | ## Exception, error or logs 17 | Please find your `latest.log` or `debug.log` in this folder and attach it to the issue 18 | 19 | Linux: `~/.minecraft/logs/` 20 | 21 | Windows: `%appdata%/.minecraft/logs/` 22 | 23 | Mac: `/Library/Application\ Support/minecraft/logs/` 24 | 25 | ## How to reproduce 26 | Add your steps to reproduce the issue/bug experienced here. 27 | 28 | ## Modified settings 29 | To get the modified settings run `#modified` in game 30 | 31 | ## Final checklist 32 | - [x] I know how to properly use check boxes 33 | - [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). 34 | - [ ] I have included logs, exceptions and / or steps to reproduce the issue. 35 | - [ ] I have not used any OwO's or UwU's in this issue. 36 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/world/WorldSchematic.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 fi.dy.masa.litematica.world; 19 | 20 | import net.minecraft.world.level.Level; 21 | 22 | public abstract class WorldSchematic extends Level { 23 | private WorldSchematic() { 24 | super(null, null, null, null, null, false, false, 0, 0); 25 | throw new LinkageError(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandTooManyArgumentsException.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.command.exception; 19 | 20 | public class CommandTooManyArgumentsException extends CommandErrorMessageException { 21 | 22 | public CommandTooManyArgumentsException(int maxArgs) { 23 | super(String.format("Too many arguments (expected at most %d)", maxArgs)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandNoParserForTypeException.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.command.exception; 19 | 20 | public class CommandNoParserForTypeException extends CommandUnhandledException { 21 | 22 | public CommandNoParserForTypeException(Class klass) { 23 | super(String.format("Could not find a handler for type %s", klass.getSimpleName())); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandNotEnoughArgumentsException.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.command.exception; 19 | 20 | public class CommandNotEnoughArgumentsException extends CommandErrorMessageException { 21 | 22 | public CommandNotEnoughArgumentsException(int minArgs) { 23 | super(String.format("Not enough arguments (expected at least %d)", minArgs)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/launch/java/baritone/launch/BaritoneMixinConnector.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 org.spongepowered.asm.mixin.Mixins; 21 | import org.spongepowered.asm.mixin.connect.IMixinConnector; 22 | 23 | public class BaritoneMixinConnector implements IMixinConnector { 24 | 25 | @Override 26 | public void connect() { 27 | Mixins.addConfiguration("mixins.baritone.json"); 28 | } 29 | } -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandException.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.command.exception; 19 | 20 | public abstract class CommandException extends Exception implements ICommandException { 21 | 22 | protected CommandException(String reason) { 23 | super(reason); 24 | } 25 | 26 | protected CommandException(String reason, Throwable cause) { 27 | super(reason, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /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/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.core.BlockPos; 21 | import net.minecraft.world.level.block.state.BlockState; 22 | 23 | public interface ISchematic { 24 | 25 | BlockState getBlockState(BlockPos var1); 26 | 27 | int getWidth(); 28 | 29 | int getHeight(); 30 | 31 | int getLength(); 32 | } 33 | -------------------------------------------------------------------------------- /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/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.core.BlockPos; 21 | 22 | public interface IPlayerControllerMP { 23 | 24 | void setIsHittingBlock(boolean isHittingBlock); 25 | 26 | boolean isHittingBlock(); 27 | 28 | BlockPos getCurrentBlock(); 29 | 30 | void callSyncCurrentPlayItem(); 31 | 32 | void setDestroyDelay(int destroyDelay); 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/gradle_build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: 7 | push: 8 | pull_request: 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: Set up JDK 17 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: '17' 24 | distribution: 'temurin' 25 | cache: gradle 26 | 27 | - name: Grant execute permission for gradlew 28 | run: chmod +x gradlew 29 | 30 | - name: Build with Gradle 31 | run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)" 32 | 33 | - name: Archive Artifacts 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: Artifacts 37 | path: dist/ 38 | 39 | - name: Archive mapping.txt 40 | uses: actions/upload-artifact@v4 41 | with: 42 | name: Mappings 43 | path: mapping/ 44 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandErrorMessageException.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.command.exception; 19 | 20 | public abstract class CommandErrorMessageException extends CommandException { 21 | 22 | protected CommandErrorMessageException(String reason) { 23 | super(reason); 24 | } 25 | 26 | protected CommandErrorMessageException(String reason, Throwable cause) { 27 | super(reason, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/accessor/IChunkArray.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 java.util.concurrent.atomic.AtomicReferenceArray; 21 | import net.minecraft.world.level.chunk.LevelChunk; 22 | 23 | public interface IChunkArray { 24 | void copyFrom(IChunkArray other); 25 | 26 | AtomicReferenceArray getChunks(); 27 | 28 | int centerX(); 29 | 30 | int centerZ(); 31 | 32 | int viewDistance(); 33 | } 34 | -------------------------------------------------------------------------------- /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/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/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 | } 38 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/accessor/IPalettedContainer.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.BitStorage; 21 | import net.minecraft.world.level.chunk.Palette; 22 | 23 | public interface IPalettedContainer { 24 | 25 | Palette getPalette(); 26 | 27 | BitStorage getStorage(); 28 | 29 | 30 | public interface IData { 31 | 32 | Palette getPalette(); 33 | 34 | BitStorage getStorage(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /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/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.core.BlockPos; 21 | import net.minecraft.world.level.block.state.BlockState; 22 | 23 | /** 24 | * @author Brady 25 | * @since 8/4/2018 26 | */ 27 | public interface IBlockTypeAccess { 28 | 29 | BlockState getBlock(int x, int y, int z); 30 | 31 | default BlockState getBlock(BlockPos pos) { 32 | return getBlock(pos.getX(), pos.getY(), pos.getZ()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/event/events/TabCompleteEvent.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 LoganDark 24 | */ 25 | public final class TabCompleteEvent extends Cancellable { 26 | 27 | public final String prefix; 28 | public String[] completions; 29 | 30 | public TabCompleteEvent(String prefix) { 31 | this.prefix = prefix; 32 | this.completions = null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | 25 | public final MBlockPos position = (MBlockPos) (Object) "cringe"; 26 | 27 | public ISchematic getSchematic() { 28 | throw new LinkageError("LOL"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/CompositeSchematicEntry.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.schematic; 19 | 20 | public class CompositeSchematicEntry { 21 | 22 | public final ISchematic schematic; 23 | public final int x; 24 | public final int y; 25 | public final int z; 26 | 27 | public CompositeSchematicEntry(ISchematic schematic, int x, int y, int z) { 28 | this.schematic = schematic; 29 | this.x = x; 30 | this.y = y; 31 | this.z = z; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | 26 | @Test 27 | public void testBits() { 28 | for (PathingBlockType type : PathingBlockType.values()) { 29 | boolean[] bits = type.getBits(); 30 | assertTrue(type == PathingBlockType.fromBits(bits[0], bits[1])); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/WallsSchematic.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.schematic; 19 | 20 | import net.minecraft.world.level.block.state.BlockState; 21 | 22 | public class WallsSchematic extends MaskSchematic { 23 | 24 | public WallsSchematic(ISchematic schematic) { 25 | super(schematic); 26 | } 27 | 28 | @Override 29 | protected boolean partOfMask(int x, int y, int z, BlockState currentState) { 30 | return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/baritone/command/CommandSystem.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.command; 19 | 20 | import baritone.api.command.ICommandSystem; 21 | import baritone.api.command.argparser.IArgParserManager; 22 | import baritone.command.argparser.ArgParserManager; 23 | 24 | /** 25 | * @author Brady 26 | * @since 10/4/2019 27 | */ 28 | public enum CommandSystem implements ICommandSystem { 29 | INSTANCE; 30 | 31 | @Override 32 | public IArgParserManager getParserManager() { 33 | return ArgParserManager.INSTANCE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/ShellSchematic.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.schematic; 19 | 20 | import net.minecraft.world.level.block.state.BlockState; 21 | 22 | public class ShellSchematic extends MaskSchematic { 23 | 24 | public ShellSchematic(ISchematic schematic) { 25 | super(schematic); 26 | } 27 | 28 | @Override 29 | protected boolean partOfMask(int x, int y, int z, BlockState currentState) { 30 | return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.gitmessage: -------------------------------------------------------------------------------- 1 | (<ticket>) 2 | 3 | # 📝 Update README.md (WD-1234) 4 | # ✅ Add unit test for inputs (WD-1234) 5 | 6 | # <emoji> can be: 7 | # 🎨 :art: when improving structure of the code 8 | # ⚡️ :zap: when improving performance 9 | # 🔥 :fire: when removing code or files 10 | # ✨ :sparkles: when introducing new features 11 | # 🚧 :construction: when work in progress 12 | # 🔨 :hammer: when refactoring code 13 | # 📝 :memo: when writing docs 14 | # 💄 :lipstick: when updating the UI and style files 15 | # 📈 :chart_with_upwards_trend: when adding analytics or tracking code 16 | # 🌐 :globe_with_meridians: when adding internationalization and localization 17 | # ✏️ :pencil2: when fixing typos 18 | # 🚚 :truck: when moving or renaming files 19 | # ✅ :white_check_mark: when adding tests 20 | 21 | # 👌 :ok_hand: when updating code due to code review changes 22 | # 🐛 :bug: when fixing a bug 23 | # 🚑 :ambulance: when doing a critical hotfix 24 | # 🚨 :rotating_light: when removing linter warnings 25 | 26 | # 🔀 :twisted_rightwards_arrows: when merging branches 27 | # ⬆️ :arrow_up: when upgrading dependencies 28 | # ⬇️ :arrow_down: when downgrading dependencies 29 | # 🔧 :wrench: when changing configuration files 30 | # 🔖 :bookmark: when releasing / version tagging 31 | # 💚 :green_heart: when fixing the CI build 32 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SchematicPlacementManager.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package fi.dy.masa.litematica.schematic.placement; 19 | 20 | import java.util.List; 21 | 22 | public class SchematicPlacementManager { 23 | 24 | //in case of a java.lang.NoSuchMethodError try change the name of this method to getAllSchematicPlacements() 25 | //there are inconsistencies in the litematica mod about the naming of this method 26 | public List<SchematicPlacement> getAllSchematicsPlacements() { 27 | throw new LinkageError(); 28 | } 29 | } -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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/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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.process; 19 | 20 | import baritone.api.utils.BlockOptionalMeta; 21 | import net.minecraft.world.level.block.Block; 22 | 23 | /** 24 | * but it rescans the world every once in a while so it doesn't get fooled by its cache 25 | */ 26 | public interface IGetToBlockProcess extends IBaritoneProcess { 27 | 28 | void getToBlock(BlockOptionalMeta block); 29 | 30 | default void getToBlock(Block block) { 31 | getToBlock(new BlockOptionalMeta(block)); 32 | } 33 | 34 | boolean blacklistClosest(); 35 | } 36 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/utils/BooleanBinaryOperators.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.utils; 19 | 20 | /** 21 | * @author Brady 22 | */ 23 | public enum BooleanBinaryOperators implements BooleanBinaryOperator { 24 | OR((a, b) -> a || b), 25 | AND((a, b) -> a && b), 26 | XOR((a, b) -> a ^ b); 27 | 28 | private final BooleanBinaryOperator op; 29 | 30 | BooleanBinaryOperators(BooleanBinaryOperator op) { 31 | this.op = op; 32 | } 33 | 34 | @Override 35 | public boolean applyAsBoolean(boolean a, boolean b) { 36 | return this.op.applyAsBoolean(a, b); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/BaritoneMath.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils; 19 | 20 | /** 21 | * @author Brady 22 | */ 23 | public final class BaritoneMath { 24 | 25 | private static final double FLOOR_DOUBLE_D = 1_073_741_824.0; 26 | private static final int FLOOR_DOUBLE_I = 1_073_741_824; 27 | 28 | private BaritoneMath() {} 29 | 30 | public static int fastFloor(final double v) { 31 | return (int) (v + FLOOR_DOUBLE_D) - FLOOR_DOUBLE_I; 32 | } 33 | 34 | public static int fastCeil(final double v) { 35 | return FLOOR_DOUBLE_I - (int) (FLOOR_DOUBLE_D - v); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SubRegionPlacement.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package fi.dy.masa.litematica.schematic.placement; 19 | 20 | import net.minecraft.core.BlockPos; 21 | import net.minecraft.world.level.block.Mirror; 22 | import net.minecraft.world.level.block.Rotation; 23 | 24 | public class SubRegionPlacement { 25 | 26 | public BlockPos getPos() { 27 | throw new LinkageError(); 28 | } 29 | 30 | public Rotation getRotation() { 31 | throw new LinkageError(); 32 | } 33 | 34 | public Mirror getMirror() { 35 | throw new LinkageError(); 36 | } 37 | } -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package com.github.lunatrius.core.util.math; 19 | 20 | import net.minecraft.core.BlockPos; 21 | 22 | public class MBlockPos extends BlockPos { 23 | 24 | MBlockPos() { 25 | super(6, 6, 6); 26 | } 27 | 28 | @Override 29 | public int getX() { 30 | throw new LinkageError("LOL"); 31 | } 32 | 33 | @Override 34 | public int getY() { 35 | throw new LinkageError("LOL"); 36 | } 37 | 38 | @Override 39 | public int getZ() { 40 | throw new LinkageError("LOL"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 <https://www.gnu.org/licenses/>. 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/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 <https://www.gnu.org/licenses/>. 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 | 27 | public final CalculationContext desiredCalcContext; 28 | 29 | public PathingCommandContext(Goal goal, PathingCommandType commandType, CalculationContext context) { 30 | super(goal, commandType); 31 | this.desiredCalcContext = context; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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/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 <https://www.gnu.org/licenses/>. 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 | } 39 | } 40 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.cache; 19 | 20 | import java.util.function.Consumer; 21 | 22 | /** 23 | * @author Brady 24 | * @since 9/24/2018 25 | */ 26 | public interface IWorldProvider { 27 | 28 | /** 29 | * Returns the data of the currently loaded world 30 | * 31 | * @return The current world data 32 | */ 33 | IWorldData getCurrentWorld(); 34 | 35 | default void ifWorldLoaded(Consumer<IWorldData> callback) { 36 | final IWorldData currentWorld = this.getCurrentWorld(); 37 | if (currentWorld != null) { 38 | callback.accept(currentWorld); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/launch/java/baritone/launch/mixins/MixinPalettedContainer$Data.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.launch.mixins; 19 | 20 | import baritone.utils.accessor.IPalettedContainer.IData; 21 | import net.minecraft.util.BitStorage; 22 | import net.minecraft.world.level.chunk.Palette; 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.gen.Accessor; 25 | 26 | @Mixin(targets = "net/minecraft/world/level/chunk/PalettedContainer$Data") 27 | public abstract class MixinPalettedContainer$Data<T> implements IData<T> { 28 | 29 | @Accessor 30 | public abstract Palette<T> getPalette(); 31 | 32 | @Accessor 33 | public abstract BitStorage getStorage(); 34 | } 35 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 | 29 | public int x; 30 | public int y; 31 | public int z; 32 | public double cost; 33 | 34 | public MutableMoveResult() { 35 | reset(); 36 | } 37 | 38 | public final void reset() { 39 | x = 0; 40 | y = 0; 41 | z = 0; 42 | cost = ActionCosts.COST_INF; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 | } 34 | 35 | @Override 36 | public boolean isTemporary() { 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/AbstractSchematic.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic; 19 | 20 | public abstract class AbstractSchematic implements ISchematic { 21 | 22 | protected int x; 23 | protected int y; 24 | protected int z; 25 | 26 | public AbstractSchematic() { 27 | this(0, 0, 0); 28 | } 29 | 30 | public AbstractSchematic(int x, int y, int z) { 31 | this.x = x; 32 | this.y = y; 33 | this.z = z; 34 | } 35 | 36 | @Override 37 | public int widthX() { 38 | return x; 39 | } 40 | 41 | @Override 42 | public int heightY() { 43 | return y; 44 | } 45 | 46 | @Override 47 | public int lengthZ() { 48 | return z; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandNotFoundException.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.exception; 19 | 20 | import baritone.api.command.ICommand; 21 | import baritone.api.command.argument.ICommandArgument; 22 | 23 | import java.util.List; 24 | 25 | import static baritone.api.utils.Helper.HELPER; 26 | 27 | public class CommandNotFoundException extends CommandException { 28 | 29 | public final String command; 30 | 31 | public CommandNotFoundException(String command) { 32 | super(String.format("Command not found: %s", command)); 33 | this.command = command; 34 | } 35 | 36 | @Override 37 | public void handle(ICommand command, List<ICommandArgument> args) { 38 | HELPER.logDirect(getMessage()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandUnhandledException.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.exception; 19 | 20 | import baritone.api.command.ICommand; 21 | import baritone.api.command.argument.ICommandArgument; 22 | 23 | import java.util.List; 24 | 25 | import static baritone.api.utils.Helper.HELPER; 26 | 27 | public class CommandUnhandledException extends RuntimeException implements ICommandException { 28 | 29 | public CommandUnhandledException(String message) { 30 | super(message); 31 | } 32 | 33 | public CommandUnhandledException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | @Override 38 | public void handle(ICommand command, List<ICommandArgument> args) { 39 | HELPER.logUnhandledException(this); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/mask/AbstractMask.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic.mask; 19 | 20 | /** 21 | * @author Brady 22 | */ 23 | public abstract class AbstractMask implements Mask { 24 | 25 | private final int widthX; 26 | private final int heightY; 27 | private final int lengthZ; 28 | 29 | public AbstractMask(int widthX, int heightY, int lengthZ) { 30 | this.widthX = widthX; 31 | this.heightY = heightY; 32 | this.lengthZ = lengthZ; 33 | } 34 | 35 | @Override 36 | public int widthX() { 37 | return this.widthX; 38 | } 39 | 40 | @Override 41 | public int heightY() { 42 | return this.heightY; 43 | } 44 | 45 | @Override 46 | public int lengthZ() { 47 | return this.lengthZ; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/event/events/type/Overrideable.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events.type; 19 | 20 | /** 21 | * @author LoganDark 22 | */ 23 | public class Overrideable<T> { 24 | 25 | private T value; 26 | private boolean modified; 27 | 28 | public Overrideable(T current) { 29 | value = current; 30 | } 31 | 32 | public T get() { 33 | return value; 34 | } 35 | 36 | public void set(T newValue) { 37 | value = newValue; 38 | modified = true; 39 | } 40 | 41 | public boolean wasModified() { 42 | return modified; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return String.format( 48 | "Overrideable{modified=%b,value=%s}", 49 | modified, 50 | value.toString() 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/launch/java/baritone/launch/mixins/MixinEntityRenderManager.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.launch.mixins; 19 | 20 | import baritone.utils.accessor.IEntityRenderManager; 21 | import net.minecraft.client.renderer.entity.EntityRenderDispatcher; 22 | import org.spongepowered.asm.mixin.Mixin; 23 | 24 | @Mixin(EntityRenderDispatcher.class) 25 | public class MixinEntityRenderManager implements IEntityRenderManager { 26 | 27 | 28 | @Override 29 | public double renderPosX() { 30 | return ((EntityRenderDispatcher) (Object) this).camera.getPosition().x; 31 | } 32 | 33 | @Override 34 | public double renderPosY() { 35 | return ((EntityRenderDispatcher) (Object) this).camera.getPosition().y; 36 | } 37 | 38 | @Override 39 | public double renderPosZ() { 40 | return ((EntityRenderDispatcher) (Object) this).camera.getPosition().z; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/event/events/BlockChangeEvent.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events; 19 | 20 | import baritone.api.utils.Pair; 21 | import net.minecraft.core.BlockPos; 22 | import net.minecraft.world.level.ChunkPos; 23 | import net.minecraft.world.level.block.state.BlockState; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * @author Brady 29 | */ 30 | public final class BlockChangeEvent { 31 | 32 | private final ChunkPos chunk; 33 | private final List<Pair<BlockPos, BlockState>> blocks; 34 | 35 | public BlockChangeEvent(ChunkPos pos, List<Pair<BlockPos, BlockState>> blocks) { 36 | this.chunk = pos; 37 | this.blocks = blocks; 38 | } 39 | 40 | public ChunkPos getChunkPos() { 41 | return this.chunk; 42 | } 43 | 44 | public List<Pair<BlockPos, BlockState>> getBlocks() { 45 | return this.blocks; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/mask/PreComputedMask.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic.mask; 19 | 20 | /** 21 | * @author Brady 22 | */ 23 | final class PreComputedMask extends AbstractMask implements StaticMask { 24 | 25 | private final boolean[][][] mask; 26 | 27 | public PreComputedMask(StaticMask mask) { 28 | super(mask.widthX(), mask.heightY(), mask.lengthZ()); 29 | 30 | this.mask = new boolean[this.heightY()][this.lengthZ()][this.widthX()]; 31 | for (int y = 0; y < this.heightY(); y++) { 32 | for (int z = 0; z < this.lengthZ(); z++) { 33 | for (int x = 0; x < this.widthX(); x++) { 34 | this.mask[y][z][x] = mask.partOfMask(x, y, z); 35 | } 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public boolean partOfMask(int x, int y, int z) { 42 | return this.mask[y][z][x]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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<IBaritoneProcess> mostRecentInControl(); 42 | 43 | /** 44 | * @return The most recent pathing command executed 45 | */ 46 | Optional<PathingCommand> mostRecentCommand(); 47 | } 48 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.process; 19 | 20 | import net.minecraft.core.BlockPos; 21 | 22 | public interface IFarmProcess extends IBaritoneProcess { 23 | 24 | /** 25 | * Begin to search for crops to farm with in specified aria 26 | * from specified location. 27 | * 28 | * @param range The distance from center to farm from 29 | * @param pos The center position to base the range from 30 | */ 31 | void farm(int range, BlockPos pos); 32 | 33 | /** 34 | * Begin to search for nearby crops to farm. 35 | */ 36 | default void farm() {farm(0, null);} 37 | 38 | /** 39 | * Begin to search for crops to farm with in specified aria 40 | * from the position the command was executed. 41 | * 42 | * @param range The distance to search for crops to farm 43 | */ 44 | default void farm(int range) {farm(range, null);} 45 | } 46 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/behavior/look/ITickableAimProcessor.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.behavior.look; 19 | 20 | import baritone.api.utils.Rotation; 21 | 22 | /** 23 | * @author Brady 24 | */ 25 | public interface ITickableAimProcessor extends IAimProcessor { 26 | 27 | /** 28 | * Advances the internal state of this aim processor by a single tick. 29 | */ 30 | void tick(); 31 | 32 | /** 33 | * Calls {@link #tick()} the specified number of times. 34 | * 35 | * @param ticks The number of calls 36 | */ 37 | void advance(int ticks); 38 | 39 | /** 40 | * Returns the actual rotation as provided by {@link #peekRotation(Rotation)}, and then automatically advances the 41 | * internal state by one {@link #tick() tick}. 42 | * 43 | * @param rotation The desired rotation to set 44 | * @return The actual rotation 45 | */ 46 | Rotation nextRotation(Rotation rotation); 47 | } 48 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/IDatatypeContext.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.argument.IArgConsumer; 22 | 23 | /** 24 | * Provides an {@link IDatatype} with contextual information so 25 | * that it can perform the desired operation on the target level. 26 | * 27 | * @author Brady 28 | * @see IDatatype 29 | * @since 9/26/2019 30 | */ 31 | public interface IDatatypeContext { 32 | 33 | /** 34 | * Provides the {@link IBaritone} instance that is associated with the action relating to datatype handling. 35 | * 36 | * @return The context {@link IBaritone} instance. 37 | */ 38 | IBaritone getBaritone(); 39 | 40 | /** 41 | * Provides the {@link IArgConsumer}} to fetch input information from. 42 | * 43 | * @return The context {@link IArgConsumer}}. 44 | */ 45 | IArgConsumer getConsumer(); 46 | } 47 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.pathing.movement; 19 | 20 | import baritone.api.utils.BetterBlockPos; 21 | import net.minecraft.core.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/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 <https://www.gnu.org/licenses/>. 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<String>}, 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/process/IElytraProcess.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.process; 19 | 20 | import baritone.api.pathing.goals.Goal; 21 | import net.minecraft.core.BlockPos; 22 | 23 | public interface IElytraProcess extends IBaritoneProcess { 24 | 25 | void repackChunks(); 26 | 27 | /** 28 | * @return Where it is currently flying to, null if not active 29 | */ 30 | BlockPos currentDestination(); 31 | 32 | void pathTo(BlockPos destination); 33 | 34 | void pathTo(Goal destination); 35 | 36 | /** 37 | * Resets the state of the process but will maintain the same destination and will try to keep flying 38 | */ 39 | void resetState(); 40 | 41 | /** 42 | * @return {@code true} if the native library loaded and elytra is actually usable 43 | */ 44 | boolean isLoaded(); 45 | 46 | /* 47 | * FOR INTERNAL USE ONLY. MAY BE REMOVED AT ANY TIME. 48 | */ 49 | boolean isSafeToCancel(); 50 | } 51 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 | * @return The most recent set goal, which doesn't invalidate upon {@link #onLostControl()} 43 | */ 44 | Goal mostRecentGoal(); 45 | 46 | /** 47 | * Sets the goal and begins the path execution. 48 | * 49 | * @param goal The new goal 50 | */ 51 | default void setGoalAndPath(Goal goal) { 52 | this.setGoal(goal); 53 | this.path(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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<IPath> 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 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | pluginManagement { 19 | repositories { 20 | mavenLocal() 21 | maven { 22 | name = 'WagYourMaven' 23 | url = 'https://maven.wagyourtail.xyz/snapshots' 24 | } 25 | maven { 26 | name = 'ForgeMaven' 27 | url = 'https://maven.minecraftforge.net/' 28 | } 29 | maven { 30 | name = 'FabricMaven' 31 | url = 'https://maven.fabricmc.net/' 32 | } 33 | mavenCentral() 34 | gradlePluginPortal() { 35 | content { 36 | excludeGroup "org.apache.logging.log4j" 37 | } 38 | } 39 | } 40 | } 41 | 42 | rootProject.name = 'baritone' 43 | 44 | include("tweaker") 45 | if (System.getProperty("Baritone.enabled_platforms") == null) { 46 | System.setProperty("Baritone.enabled_platforms", "fabric,forge") 47 | } 48 | for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) { 49 | include(platform) 50 | } 51 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/format/ISchematicFormat.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic.format; 19 | 20 | import baritone.api.schematic.ISchematic; 21 | import baritone.api.schematic.IStaticSchematic; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.util.List; 27 | 28 | /** 29 | * The base of a {@link ISchematic} file format 30 | * 31 | * @author Brady 32 | * @since 12/23/2019 33 | */ 34 | public interface ISchematicFormat { 35 | 36 | /** 37 | * @return The parser for creating schematics of this format 38 | */ 39 | IStaticSchematic parse(InputStream input) throws IOException; 40 | 41 | /** 42 | * @param file The file to check against 43 | * @return Whether or not the specified file matches this schematic format 44 | */ 45 | boolean isFileType(File file); 46 | 47 | /** 48 | * @return A list of file extensions used by this format 49 | */ 50 | List<String> getFileExtensions(); 51 | } 52 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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/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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils.schematic.schematica; 19 | 20 | import baritone.api.schematic.IStaticSchematic; 21 | import com.github.lunatrius.schematica.Schematica; 22 | import com.github.lunatrius.schematica.proxy.ClientProxy; 23 | import net.minecraft.core.BlockPos; 24 | import net.minecraft.util.Tuple; 25 | import java.util.Optional; 26 | 27 | public enum SchematicaHelper { 28 | ; 29 | 30 | public static boolean isSchematicaPresent() { 31 | try { 32 | Class.forName(Schematica.class.getName()); 33 | return true; 34 | } catch (ClassNotFoundException | NoClassDefFoundError ex) { 35 | return false; 36 | } 37 | } 38 | 39 | public static Optional<Tuple<IStaticSchematic, BlockPos>> getOpenSchematic() { 40 | return Optional.ofNullable(ClientProxy.schematic) 41 | .map(world -> new Tuple<>(new SchematicAdapter(world), world.position)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/utils/Pair.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.utils; 19 | 20 | import java.util.Objects; 21 | 22 | /** 23 | * @author Brady 24 | */ 25 | public final class Pair<A, B> { 26 | 27 | private final A a; 28 | private final B b; 29 | 30 | public Pair(A a, B b) { 31 | this.a = a; 32 | this.b = b; 33 | } 34 | 35 | public A first() { 36 | return this.a; 37 | } 38 | 39 | public B second() { 40 | return this.b; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object o) { 45 | if (this == o) { 46 | return true; 47 | } 48 | if (o == null || o.getClass() != Pair.class) { 49 | return false; 50 | } 51 | Pair<?, ?> pair = (Pair<?, ?>) o; 52 | return Objects.equals(this.a, pair.a) && Objects.equals(this.b, pair.b); 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return 31 * Objects.hashCode(this.a) + Objects.hashCode(this.b); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/ForDirection.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | import baritone.api.command.helpers.TabCompleteHelper; 22 | import java.util.Locale; 23 | import java.util.stream.Stream; 24 | import net.minecraft.core.Direction; 25 | 26 | public enum ForDirection implements IDatatypeFor<Direction> { 27 | INSTANCE; 28 | 29 | @Override 30 | public Direction get(IDatatypeContext ctx) throws CommandException { 31 | return Direction.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US)); 32 | } 33 | 34 | @Override 35 | public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { 36 | return new TabCompleteHelper() 37 | .append(Stream.of(Direction.values()) 38 | .map(Direction::getName).map(String::toLowerCase)) 39 | .filterPrefix(ctx.getConsumer().getString()) 40 | .stream(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 <https://www.gnu.org/licenses/>. 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/command/manager/ICommandManager.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.manager; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.ICommand; 22 | import baritone.api.command.argument.ICommandArgument; 23 | import baritone.api.command.registry.Registry; 24 | import net.minecraft.util.Tuple; 25 | 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | /** 30 | * @author Brady 31 | * @since 9/21/2019 32 | */ 33 | public interface ICommandManager { 34 | 35 | IBaritone getBaritone(); 36 | 37 | Registry<ICommand> getRegistry(); 38 | 39 | /** 40 | * @param name The command name to search for. 41 | * @return The command, if found. 42 | */ 43 | ICommand getCommand(String name); 44 | 45 | boolean execute(String string); 46 | 47 | boolean execute(Tuple<String, List<ICommandArgument>> expanded); 48 | 49 | Stream<String> tabComplete(Tuple<String, List<ICommandArgument>> expanded); 50 | 51 | Stream<String> tabComplete(String prefix); 52 | } 53 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandInvalidArgumentException.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.exception; 19 | 20 | import baritone.api.command.argument.ICommandArgument; 21 | 22 | public abstract class CommandInvalidArgumentException extends CommandErrorMessageException { 23 | 24 | public final ICommandArgument arg; 25 | 26 | protected CommandInvalidArgumentException(ICommandArgument arg, String message) { 27 | super(formatMessage(arg, message)); 28 | this.arg = arg; 29 | } 30 | 31 | protected CommandInvalidArgumentException(ICommandArgument arg, String message, Throwable cause) { 32 | super(formatMessage(arg, message), cause); 33 | this.arg = arg; 34 | } 35 | 36 | private static String formatMessage(ICommandArgument arg, String message) { 37 | return String.format( 38 | "Error at argument #%s: %s", 39 | arg.getIndex() == -1 ? "<unknown>" : Integer.toString(arg.getIndex() + 1), 40 | message 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/ISchematicSystem.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic; 19 | 20 | import baritone.api.command.registry.Registry; 21 | import baritone.api.schematic.format.ISchematicFormat; 22 | 23 | import java.io.File; 24 | import java.util.List; 25 | import java.util.Optional; 26 | 27 | /** 28 | * @author Brady 29 | * @since 12/23/2019 30 | */ 31 | public interface ISchematicSystem { 32 | 33 | /** 34 | * @return The registry of supported schematic formats 35 | */ 36 | Registry<ISchematicFormat> getRegistry(); 37 | 38 | /** 39 | * Attempts to find an {@link ISchematicFormat} that supports the specified schematic file. 40 | * 41 | * @param file A schematic file 42 | * @return The corresponding format for the file, {@link Optional#empty()} if no candidates were found. 43 | */ 44 | Optional<ISchematicFormat> getByFile(File file); 45 | 46 | /** 47 | * @return A list of file extensions used by supported formats 48 | */ 49 | List<String> getFileExtensions(); 50 | } 51 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/ForAxis.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | import baritone.api.command.helpers.TabCompleteHelper; 22 | import net.minecraft.core.Direction; 23 | 24 | import java.util.Locale; 25 | import java.util.stream.Stream; 26 | 27 | public enum ForAxis implements IDatatypeFor<Direction.Axis> { 28 | INSTANCE; 29 | 30 | @Override 31 | public Direction.Axis get(IDatatypeContext ctx) throws CommandException { 32 | return Direction.Axis.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US)); 33 | } 34 | 35 | @Override 36 | public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { 37 | return new TabCompleteHelper() 38 | .append(Stream.of(Direction.Axis.values()) 39 | .map(Direction.Axis::getName).map(String::toLowerCase)) 40 | .filterPrefix(ctx.getConsumer().getString()) 41 | .stream(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/CommandInvalidTypeException.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.exception; 19 | 20 | import baritone.api.command.argument.ICommandArgument; 21 | 22 | public class CommandInvalidTypeException extends CommandInvalidArgumentException { 23 | 24 | public CommandInvalidTypeException(ICommandArgument arg, String expected) { 25 | super(arg, String.format("Expected %s", expected)); 26 | } 27 | 28 | public CommandInvalidTypeException(ICommandArgument arg, String expected, Throwable cause) { 29 | super(arg, String.format("Expected %s", expected), cause); 30 | } 31 | 32 | public CommandInvalidTypeException(ICommandArgument arg, String expected, String got) { 33 | super(arg, String.format("Expected %s, but got %s instead", expected, got)); 34 | } 35 | 36 | public CommandInvalidTypeException(ICommandArgument arg, String expected, String got, Throwable cause) { 37 | super(arg, String.format("Expected %s, but got %s instead", expected, got), cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api; 19 | 20 | import baritone.api.utils.SettingsUtil; 21 | 22 | /** 23 | * Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage. 24 | * 25 | * @author Brady 26 | * @since 9/23/2018 27 | */ 28 | public final class BaritoneAPI { 29 | 30 | private static final IBaritoneProvider provider; 31 | private static final Settings settings; 32 | 33 | static { 34 | settings = new Settings(); 35 | SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME); 36 | 37 | try { 38 | provider = (IBaritoneProvider) Class.forName("baritone.BaritoneProvider").newInstance(); 39 | } catch (ReflectiveOperationException ex) { 40 | throw new RuntimeException(ex); 41 | } 42 | } 43 | 44 | public static IBaritoneProvider getProvider() { 45 | return BaritoneAPI.provider; 46 | } 47 | 48 | public static Settings getSettings() { 49 | return BaritoneAPI.settings; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SchematicPlacement.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package fi.dy.masa.litematica.schematic.placement; 19 | 20 | import com.google.common.collect.ImmutableMap; 21 | import fi.dy.masa.litematica.schematic.LitematicaSchematic; 22 | import net.minecraft.core.BlockPos; 23 | import net.minecraft.world.level.block.Mirror; 24 | import net.minecraft.world.level.block.Rotation; 25 | 26 | public class SchematicPlacement { 27 | 28 | public String getName() { 29 | throw new LinkageError(); 30 | } 31 | 32 | public BlockPos getOrigin() { 33 | throw new LinkageError(); 34 | } 35 | 36 | public Rotation getRotation() { 37 | throw new LinkageError(); 38 | } 39 | 40 | public Mirror getMirror() { 41 | throw new LinkageError(); 42 | } 43 | 44 | public ImmutableMap<String, SubRegionPlacement> getEnabledRelativeSubRegionPlacements() { 45 | throw new LinkageError(); 46 | } 47 | 48 | public LitematicaSchematic getSchematic() { 49 | throw new LinkageError(); 50 | } 51 | } -------------------------------------------------------------------------------- /src/api/java/baritone/api/behavior/look/IAimProcessor.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.behavior.look; 19 | 20 | import baritone.api.utils.Rotation; 21 | 22 | /** 23 | * @author Brady 24 | */ 25 | public interface IAimProcessor { 26 | 27 | /** 28 | * Returns the actual rotation that will be used when the desired rotation is requested. The returned rotation 29 | * always reflects what would happen in the upcoming tick. In other words, it is a pure function, and no internal 30 | * state changes. If simulation of the rotation states beyond the next tick is required, then a 31 | * {@link IAimProcessor#fork fork} should be created. 32 | * 33 | * @param desired The desired rotation to set 34 | * @return The actual rotation 35 | */ 36 | Rotation peekRotation(Rotation desired); 37 | 38 | /** 39 | * Returns a copy of this {@link IAimProcessor} which has its own internal state and is manually tickable. 40 | * 41 | * @return The forked processor 42 | * @see ITickableAimProcessor 43 | */ 44 | ITickableAimProcessor fork(); 45 | } 46 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events; 19 | 20 | import baritone.api.event.events.type.EventState; 21 | import net.minecraft.client.multiplayer.ClientLevel; 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 ClientLevel world; 33 | 34 | /** 35 | * The state of the event 36 | */ 37 | private final EventState state; 38 | 39 | public WorldEvent(ClientLevel 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 ClientLevel 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/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 <https://www.gnu.org/licenses/>. 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/command/datatypes/IDatatypePost.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | 22 | import java.util.function.Function; 23 | 24 | /** 25 | * An {@link IDatatype} which acts as a {@link Function}, in essence. The only difference 26 | * is that it requires an {@link IDatatypeContext} to be provided due to the expectation that 27 | * implementations of {@link IDatatype} are singletons. 28 | */ 29 | public interface IDatatypePost<T, O> extends IDatatype { 30 | 31 | /** 32 | * Takes the expected input and transforms it based on the value held by {@code original}. If {@code original} 33 | * is null, it is expected that the implementation of this method has a case to handle it, such that a 34 | * {@link NullPointerException} will never be thrown as a result. 35 | * 36 | * @param ctx The datatype context 37 | * @param original The transformable value 38 | * @return The transformed value 39 | */ 40 | T apply(IDatatypeContext ctx, O original) throws CommandException; 41 | } 42 | -------------------------------------------------------------------------------- /src/launch/java/baritone/launch/mixins/MixinPlayerController.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.launch.mixins; 19 | 20 | import baritone.utils.accessor.IPlayerControllerMP; 21 | import net.minecraft.client.multiplayer.MultiPlayerGameMode; 22 | import net.minecraft.core.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(MultiPlayerGameMode.class) 28 | public abstract class MixinPlayerController implements IPlayerControllerMP { 29 | 30 | @Accessor("isDestroying") 31 | @Override 32 | public abstract void setIsHittingBlock(boolean isHittingBlock); 33 | 34 | @Accessor("isDestroying") 35 | @Override 36 | public abstract boolean isHittingBlock(); 37 | 38 | @Accessor("destroyBlockPos") 39 | @Override 40 | public abstract BlockPos getCurrentBlock(); 41 | 42 | @Invoker("ensureHasSentCarriedItem") 43 | @Override 44 | public abstract void callSyncCurrentPlayItem(); 45 | 46 | @Accessor("destroyDelay") 47 | @Override 48 | public abstract void setDestroyDelay(int destroyDelay); 49 | } 50 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events; 19 | 20 | import com.mojang.blaze3d.vertex.PoseStack; 21 | import org.joml.Matrix4f; 22 | 23 | /** 24 | * @author Brady 25 | * @since 8/5/2018 26 | */ 27 | public final class RenderEvent { 28 | 29 | /** 30 | * The current render partial ticks 31 | */ 32 | private final float partialTicks; 33 | 34 | private final Matrix4f projectionMatrix; 35 | private final PoseStack modelViewStack; 36 | 37 | public RenderEvent(float partialTicks, PoseStack modelViewStack, Matrix4f projectionMatrix) { 38 | this.partialTicks = partialTicks; 39 | this.modelViewStack = modelViewStack; 40 | this.projectionMatrix = projectionMatrix; 41 | } 42 | 43 | /** 44 | * @return The current render partial ticks 45 | */ 46 | public final float getPartialTicks() { 47 | return this.partialTicks; 48 | } 49 | 50 | public PoseStack getModelViewStack() { 51 | return this.modelViewStack; 52 | } 53 | 54 | public Matrix4f getProjectionMatrix() { 55 | return this.projectionMatrix; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events; 19 | 20 | import baritone.api.event.events.type.EventState; 21 | import net.minecraft.network.Connection; 22 | import net.minecraft.network.protocol.Packet; 23 | 24 | /** 25 | * @author Brady 26 | * @since 8/6/2018 27 | */ 28 | public final class PacketEvent { 29 | 30 | private final Connection networkManager; 31 | 32 | private final EventState state; 33 | 34 | private final Packet<?> packet; 35 | 36 | public PacketEvent(Connection networkManager, EventState state, Packet<?> packet) { 37 | this.networkManager = networkManager; 38 | this.state = state; 39 | this.packet = packet; 40 | } 41 | 42 | public final Connection 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 extends Packet<?>> T cast() { 56 | return (T) this.packet; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.process; 19 | 20 | import net.minecraft.world.entity.Entity; 21 | import net.minecraft.world.item.ItemStack; 22 | 23 | import java.util.List; 24 | import java.util.function.Predicate; 25 | 26 | /** 27 | * @author Brady 28 | * @since 9/23/2018 29 | */ 30 | public interface IFollowProcess extends IBaritoneProcess { 31 | 32 | /** 33 | * Set the follow target to any entities matching this predicate 34 | * 35 | * @param filter the predicate 36 | */ 37 | void follow(Predicate<Entity> filter); 38 | 39 | /** 40 | * Try to pick up any items matching this predicate 41 | * 42 | * @param filter the predicate 43 | */ 44 | void pickup(Predicate<ItemStack> filter); 45 | 46 | /** 47 | * @return The entities that are currently being followed. null if not currently following, empty if nothing matches the predicate 48 | */ 49 | List<Entity> following(); 50 | 51 | Predicate<Entity> currentFilter(); 52 | 53 | /** 54 | * Cancels the follow behavior, this will clear the current follow target. 55 | */ 56 | default void cancel() { 57 | onLostControl(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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/command/datatypes/RelativeGoalYLevel.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.argument.IArgConsumer; 21 | import baritone.api.command.exception.CommandException; 22 | import baritone.api.pathing.goals.GoalYLevel; 23 | import baritone.api.utils.BetterBlockPos; 24 | import java.util.stream.Stream; 25 | import net.minecraft.util.Mth; 26 | 27 | public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> { 28 | INSTANCE; 29 | 30 | @Override 31 | public GoalYLevel apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException { 32 | if (origin == null) { 33 | origin = BetterBlockPos.ORIGIN; 34 | } 35 | 36 | return new GoalYLevel( 37 | Mth.floor(ctx.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y)) 38 | ); 39 | } 40 | 41 | @Override 42 | public Stream<String> tabComplete(IDatatypeContext ctx) { 43 | final IArgConsumer consumer = ctx.getConsumer(); 44 | if (consumer.hasAtMost(1)) { 45 | return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE); 46 | } 47 | return Stream.empty(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/FillSchematic.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic; 19 | 20 | import baritone.api.utils.BlockOptionalMeta; 21 | import net.minecraft.world.level.block.Blocks; 22 | import net.minecraft.world.level.block.state.BlockState; 23 | 24 | import java.util.List; 25 | 26 | public class FillSchematic extends AbstractSchematic { 27 | 28 | private final BlockOptionalMeta bom; 29 | 30 | public FillSchematic(int x, int y, int z, BlockOptionalMeta bom) { 31 | super(x, y, z); 32 | this.bom = bom; 33 | } 34 | 35 | public FillSchematic(int x, int y, int z, BlockState state) { 36 | this(x, y, z, new BlockOptionalMeta(state.getBlock())); 37 | } 38 | 39 | public BlockOptionalMeta getBom() { 40 | return bom; 41 | } 42 | 43 | @Override 44 | public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) { 45 | if (bom.matches(current)) { 46 | return current; 47 | } 48 | for (BlockState placeable : approxPlaceable) { 49 | if (bom.matches(placeable)) { 50 | return placeable; 51 | } 52 | } 53 | return bom.getAnyBlockState(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/IBaritoneChatControl.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command; 19 | 20 | import baritone.api.Settings; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * @author Brady 26 | * @since 9/26/2019 27 | */ 28 | public interface IBaritoneChatControl { 29 | 30 | /** 31 | * In certain cases chat components need to execute commands for you. For example, the paginator automatically runs 32 | * commands when you click the forward and back arrows to show you the previous/next page. 33 | * <p> 34 | * If the prefix is changed in the meantime, then the command will go to chat. That's no good. So here's a permanent 35 | * prefix that forces a command to run, regardless of the current prefix, chat/prefix control being enabled, etc. 36 | * <p> 37 | * If used right (by both developers and users), it should be impossible to expose a command accidentally to the 38 | * server. As a rule of thumb, if you have a clickable chat component, always use this prefix. If you're suggesting 39 | * a command (a component that puts text into your text box, or something else), use {@link Settings#prefix}. 40 | */ 41 | String FORCE_COMMAND_PREFIX = String.format("<<%s>>", UUID.randomUUID().toString()); 42 | } 43 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/IDatatypeFor.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | 22 | import java.util.function.Supplier; 23 | 24 | /** 25 | * An {@link IDatatype} which acts as a {@link Supplier}, in essence. The only difference 26 | * is that it requires an {@link IDatatypeContext} to be provided due to the expectation that 27 | * implementations of {@link IDatatype} are singletons. 28 | */ 29 | public interface IDatatypeFor<T> extends IDatatype { 30 | 31 | /** 32 | * Consumes the desired amount of arguments from the specified {@link IDatatypeContext}, and 33 | * then returns the parsed value. This method will more than likely return a {@link IllegalArgumentException} 34 | * if the expected input does not conform to a parseable value. As far as a {@link CommandException} being 35 | * thrown is concerned, see the note below for specifics. 36 | * 37 | * @param ctx The context 38 | * @return The parsed data-type 39 | * @throws CommandException If there was an issue parsing using another type or arguments could not be polled. 40 | * @see IDatatypeContext 41 | */ 42 | T get(IDatatypeContext ctx) throws CommandException; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/baritone/command/defaults/GcCommand.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.command.defaults; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.Command; 22 | import baritone.api.command.argument.IArgConsumer; 23 | import baritone.api.command.exception.CommandException; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | public class GcCommand extends Command { 30 | 31 | public GcCommand(IBaritone baritone) { 32 | super(baritone, "gc"); 33 | } 34 | 35 | @Override 36 | public void execute(String label, IArgConsumer args) throws CommandException { 37 | args.requireMax(0); 38 | System.gc(); 39 | logDirect("ok called System.gc()"); 40 | } 41 | 42 | @Override 43 | public Stream<String> tabComplete(String label, IArgConsumer args) { 44 | return Stream.empty(); 45 | } 46 | 47 | @Override 48 | public String getShortDesc() { 49 | return "Call System.gc()"; 50 | } 51 | 52 | @Override 53 | public List<String> getLongDesc() { 54 | return Arrays.asList( 55 | "Calls System.gc().", 56 | "", 57 | "Usage:", 58 | "> gc" 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils.pathing; 19 | 20 | import net.minecraft.world.level.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.getMinX(); 35 | this.maxX = border.getMaxX(); 36 | this.minZ = border.getMinZ(); 37 | this.maxZ = border.getMaxZ(); 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/main/java/baritone/command/defaults/ClickCommand.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.command.defaults; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.Command; 22 | import baritone.api.command.argument.IArgConsumer; 23 | import baritone.api.command.exception.CommandException; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | public class ClickCommand extends Command { 30 | 31 | public ClickCommand(IBaritone baritone) { 32 | super(baritone, "click"); 33 | } 34 | 35 | @Override 36 | public void execute(String label, IArgConsumer args) throws CommandException { 37 | args.requireMax(0); 38 | baritone.openClick(); 39 | logDirect("aight dude"); 40 | } 41 | 42 | @Override 43 | public Stream<String> tabComplete(String label, IArgConsumer args) { 44 | return Stream.empty(); 45 | } 46 | 47 | @Override 48 | public String getShortDesc() { 49 | return "Open click"; 50 | } 51 | 52 | @Override 53 | public List<String> getLongDesc() { 54 | return Arrays.asList( 55 | "Opens click dude", 56 | "", 57 | "Usage:", 58 | "> click" 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/mask/operator/NotMask.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic.mask.operator; 19 | 20 | import baritone.api.schematic.mask.AbstractMask; 21 | import baritone.api.schematic.mask.Mask; 22 | import baritone.api.schematic.mask.StaticMask; 23 | import net.minecraft.world.level.block.state.BlockState; 24 | 25 | /** 26 | * @author Brady 27 | */ 28 | public final class NotMask extends AbstractMask { 29 | 30 | private final Mask source; 31 | 32 | public NotMask(Mask source) { 33 | super(source.widthX(), source.heightY(), source.lengthZ()); 34 | this.source = source; 35 | } 36 | 37 | @Override 38 | public boolean partOfMask(int x, int y, int z, BlockState currentState) { 39 | return !this.source.partOfMask(x, y, z, currentState); 40 | } 41 | 42 | public static final class Static extends AbstractMask implements StaticMask { 43 | 44 | private final StaticMask source; 45 | 46 | public Static(StaticMask source) { 47 | super(source.widthX(), source.heightY(), source.lengthZ()); 48 | this.source = source; 49 | } 50 | 51 | @Override 52 | public boolean partOfMask(int x, int y, int z) { 53 | return !this.source.partOfMask(x, y, z); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 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 boolean equals(Object o) { 47 | return o.getClass() == GoalAxis.class; 48 | } 49 | 50 | @Override 51 | public int hashCode() { 52 | return 201385781; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "GoalAxis"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/schematic/ReplaceSchematic.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.schematic; 19 | 20 | import baritone.api.utils.BlockOptionalMetaLookup; 21 | import net.minecraft.world.level.block.state.BlockState; 22 | 23 | public class ReplaceSchematic extends MaskSchematic { 24 | 25 | private final BlockOptionalMetaLookup filter; 26 | private final Boolean[][][] cache; 27 | 28 | public ReplaceSchematic(ISchematic schematic, BlockOptionalMetaLookup filter) { 29 | super(schematic); 30 | this.filter = filter; 31 | this.cache = new Boolean[widthX()][heightY()][lengthZ()]; 32 | } 33 | 34 | @Override 35 | public void reset() { 36 | // it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()] 37 | for (int x = 0; x < cache.length; x++) { 38 | for (int y = 0; y < cache[0].length; y++) { 39 | for (int z = 0; z < cache[0][0].length; z++) { 40 | cache[x][y][z] = null; 41 | } 42 | } 43 | } 44 | } 45 | 46 | @Override 47 | protected boolean partOfMask(int x, int y, int z, BlockState currentState) { 48 | if (cache[x][y][z] == null) { 49 | cache[x][y][z] = filter.has(currentState); 50 | } 51 | return cache[x][y][z]; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/exception/ICommandException.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.exception; 19 | 20 | import baritone.api.command.ICommand; 21 | import baritone.api.command.argument.ICommandArgument; 22 | import java.util.List; 23 | import net.minecraft.ChatFormatting; 24 | 25 | import static baritone.api.utils.Helper.HELPER; 26 | 27 | /** 28 | * The base for a Baritone Command Exception, checked or unchecked. Provides a 29 | * {@link #handle(ICommand, List)} method that is used to provide useful output 30 | * to the user for diagnosing issues that may have occurred during execution. 31 | * <p> 32 | * Anything implementing this interface should be assignable to {@link Exception}. 33 | * 34 | * @author Brady 35 | * @since 9/20/2019 36 | */ 37 | public interface ICommandException { 38 | 39 | /** 40 | * @return The exception details 41 | * @see Exception#getMessage() 42 | */ 43 | String getMessage(); 44 | 45 | /** 46 | * Called when this exception is thrown, to handle the exception. 47 | * 48 | * @param command The command that threw it. 49 | * @param args The arguments the command was called with. 50 | */ 51 | default void handle(ICommand command, List<ICommandArgument> args) { 52 | HELPER.logDirect(this.getMessage(), ChatFormatting.RED); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/baritone/utils/schematic/SchematicSystem.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils.schematic; 19 | 20 | import baritone.api.command.registry.Registry; 21 | import baritone.api.schematic.ISchematicSystem; 22 | import baritone.api.schematic.format.ISchematicFormat; 23 | import baritone.utils.schematic.format.DefaultSchematicFormats; 24 | 25 | import java.io.File; 26 | import java.util.Arrays; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | /** 31 | * @author Brady 32 | * @since 12/24/2019 33 | */ 34 | public enum SchematicSystem implements ISchematicSystem { 35 | INSTANCE; 36 | 37 | private final Registry<ISchematicFormat> registry = new Registry<>(); 38 | 39 | SchematicSystem() { 40 | Arrays.stream(DefaultSchematicFormats.values()).forEach(this.registry::register); 41 | } 42 | 43 | @Override 44 | public Registry<ISchematicFormat> getRegistry() { 45 | return this.registry; 46 | } 47 | 48 | @Override 49 | public Optional<ISchematicFormat> getByFile(File file) { 50 | return this.registry.stream().filter(format -> format.isFileType(file)).findFirst(); 51 | } 52 | 53 | @Override 54 | public List<String> getFileExtensions() { 55 | return this.registry.stream().map(ISchematicFormat::getFileExtensions).flatMap(List::stream).toList(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/baritone/command/defaults/SchematicaCommand.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.command.defaults; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.Command; 22 | import baritone.api.command.argument.IArgConsumer; 23 | import baritone.api.command.exception.CommandException; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | public class SchematicaCommand extends Command { 30 | 31 | public SchematicaCommand(IBaritone baritone) { 32 | super(baritone, "schematica"); 33 | } 34 | 35 | @Override 36 | public void execute(String label, IArgConsumer args) throws CommandException { 37 | args.requireMax(0); 38 | baritone.getBuilderProcess().buildOpenSchematic(); 39 | } 40 | 41 | @Override 42 | public Stream<String> tabComplete(String label, IArgConsumer args) { 43 | return Stream.empty(); 44 | } 45 | 46 | @Override 47 | public String getShortDesc() { 48 | return "Builds the loaded schematic"; 49 | } 50 | 51 | @Override 52 | public List<String> getLongDesc() { 53 | return Arrays.asList( 54 | "Builds the schematic currently open in Schematica.", 55 | "", 56 | "Usage:", 57 | "> schematica" 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils; 19 | 20 | import baritone.api.utils.input.Input; 21 | 22 | public class PlayerMovementInput extends net.minecraft.client.player.Input { 23 | 24 | private final InputOverrideHandler handler; 25 | 26 | PlayerMovementInput(InputOverrideHandler handler) { 27 | this.handler = handler; 28 | } 29 | 30 | @Override 31 | public void tick(boolean p_225607_1_, float f) { 32 | this.leftImpulse = 0.0F; 33 | this.forwardImpulse = 0.0F; 34 | 35 | this.jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style 36 | 37 | if (this.up = handler.isInputForcedDown(Input.MOVE_FORWARD)) { 38 | this.forwardImpulse++; 39 | } 40 | 41 | if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) { 42 | this.forwardImpulse--; 43 | } 44 | 45 | if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) { 46 | this.leftImpulse++; 47 | } 48 | 49 | if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) { 50 | this.leftImpulse--; 51 | } 52 | 53 | if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) { 54 | this.leftImpulse *= 0.3D; 55 | this.forwardImpulse *= 0.3D; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/baritone/command/defaults/SaveAllCommand.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.command.defaults; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.Command; 22 | import baritone.api.command.argument.IArgConsumer; 23 | import baritone.api.command.exception.CommandException; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | public class SaveAllCommand extends Command { 30 | 31 | public SaveAllCommand(IBaritone baritone) { 32 | super(baritone, "saveall"); 33 | } 34 | 35 | @Override 36 | public void execute(String label, IArgConsumer args) throws CommandException { 37 | args.requireMax(0); 38 | ctx.worldData().getCachedWorld().save(); 39 | logDirect("Saved"); 40 | } 41 | 42 | @Override 43 | public Stream<String> tabComplete(String label, IArgConsumer args) { 44 | return Stream.empty(); 45 | } 46 | 47 | @Override 48 | public String getShortDesc() { 49 | return "Saves Baritone's cache for this world"; 50 | } 51 | 52 | @Override 53 | public List<String> getLongDesc() { 54 | return Arrays.asList( 55 | "The saveall command saves Baritone's world cache.", 56 | "", 57 | "Usage:", 58 | "> saveall" 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils.schematic.schematica; 19 | 20 | import baritone.api.schematic.IStaticSchematic; 21 | import com.github.lunatrius.schematica.client.world.SchematicWorld; 22 | import java.util.List; 23 | import net.minecraft.core.BlockPos; 24 | import net.minecraft.world.level.block.state.BlockState; 25 | 26 | public final class SchematicAdapter implements IStaticSchematic { 27 | 28 | private final SchematicWorld schematic; 29 | 30 | public SchematicAdapter(SchematicWorld schematicWorld) { 31 | this.schematic = schematicWorld; 32 | } 33 | 34 | @Override 35 | public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) { 36 | return this.getDirect(x, y, z); 37 | } 38 | 39 | @Override 40 | public BlockState getDirect(int x, int y, int z) { 41 | return this.schematic.getSchematic().getBlockState(new BlockPos(x, y, z)); 42 | } 43 | 44 | @Override 45 | public int widthX() { 46 | return schematic.getSchematic().getWidth(); 47 | } 48 | 49 | @Override 50 | public int heightY() { 51 | return schematic.getSchematic().getHeight(); 52 | } 53 | 54 | @Override 55 | public int lengthZ() { 56 | return schematic.getSchematic().getLength(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.argument.IArgConsumer; 21 | import baritone.api.command.exception.CommandException; 22 | import baritone.api.pathing.goals.GoalXZ; 23 | import baritone.api.utils.BetterBlockPos; 24 | import java.util.stream.Stream; 25 | import net.minecraft.util.Mth; 26 | 27 | public enum RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> { 28 | INSTANCE; 29 | 30 | @Override 31 | public GoalXZ apply(IDatatypeContext ctx, BetterBlockPos origin) throws CommandException { 32 | if (origin == null) { 33 | origin = BetterBlockPos.ORIGIN; 34 | } 35 | 36 | final IArgConsumer consumer = ctx.getConsumer(); 37 | return new GoalXZ( 38 | Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)), 39 | Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z)) 40 | ); 41 | } 42 | 43 | @Override 44 | public Stream<String> tabComplete(IDatatypeContext ctx) { 45 | final IArgConsumer consumer = ctx.getConsumer(); 46 | if (consumer.hasAtMost(2)) { 47 | return consumer.tabCompleteDatatype(RelativeCoordinate.INSTANCE); 48 | } 49 | return Stream.empty(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/api/java/baritone/api/command/datatypes/EntityClassById.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.command.datatypes; 19 | 20 | import baritone.api.command.exception.CommandException; 21 | import baritone.api.command.helpers.TabCompleteHelper; 22 | import net.minecraft.core.registries.BuiltInRegistries; 23 | import net.minecraft.resources.ResourceLocation; 24 | import net.minecraft.world.entity.EntityType; 25 | 26 | import java.util.stream.Stream; 27 | 28 | public enum EntityClassById implements IDatatypeFor<EntityType> { 29 | INSTANCE; 30 | 31 | @Override 32 | public EntityType get(IDatatypeContext ctx) throws CommandException { 33 | ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString()); 34 | EntityType entity; 35 | if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) { 36 | throw new IllegalArgumentException("no entity found by that id"); 37 | } 38 | return entity; 39 | } 40 | 41 | @Override 42 | public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { 43 | return new TabCompleteHelper() 44 | .append(BuiltInRegistries.ENTITY_TYPE.stream().map(Object::toString)) 45 | .filterPrefixNamespaced(ctx.getConsumer().getString()) 46 | .sortAlphabetically() 47 | .stream(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/baritone/command/defaults/ReloadAllCommand.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.command.defaults; 19 | 20 | import baritone.api.IBaritone; 21 | import baritone.api.command.Command; 22 | import baritone.api.command.argument.IArgConsumer; 23 | import baritone.api.command.exception.CommandException; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.stream.Stream; 28 | 29 | public class ReloadAllCommand extends Command { 30 | 31 | public ReloadAllCommand(IBaritone baritone) { 32 | super(baritone, "reloadall"); 33 | } 34 | 35 | @Override 36 | public void execute(String label, IArgConsumer args) throws CommandException { 37 | args.requireMax(0); 38 | ctx.worldData().getCachedWorld().reloadAllFromDisk(); 39 | logDirect("Reloaded"); 40 | } 41 | 42 | @Override 43 | public Stream<String> tabComplete(String label, IArgConsumer args) { 44 | return Stream.empty(); 45 | } 46 | 47 | @Override 48 | public String getShortDesc() { 49 | return "Reloads Baritone's cache for this world"; 50 | } 51 | 52 | @Override 53 | public List<String> getLongDesc() { 54 | return Arrays.asList( 55 | "The reloadall command reloads Baritone's world cache.", 56 | "", 57 | "Usage:", 58 | "> reloadall" 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/baritone/process/elytra/NetherPath.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.process.elytra; 19 | 20 | import baritone.api.utils.BetterBlockPos; 21 | import net.minecraft.world.phys.Vec3; 22 | 23 | import java.util.AbstractList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Brady 29 | */ 30 | public final class NetherPath extends AbstractList<BetterBlockPos> { 31 | 32 | private static final NetherPath EMPTY_PATH = new NetherPath(Collections.emptyList()); 33 | 34 | private final List<BetterBlockPos> backing; 35 | 36 | NetherPath(List<BetterBlockPos> backing) { 37 | this.backing = backing; 38 | } 39 | 40 | @Override 41 | public BetterBlockPos get(int index) { 42 | return this.backing.get(index); 43 | } 44 | 45 | @Override 46 | public int size() { 47 | return this.backing.size(); 48 | } 49 | 50 | /** 51 | * @return The last position in the path, or {@code null} if empty 52 | */ 53 | public BetterBlockPos getLast() { 54 | return this.isEmpty() ? null : this.backing.get(this.backing.size() - 1); 55 | } 56 | 57 | public Vec3 getVec(int index) { 58 | final BetterBlockPos pos = this.get(index); 59 | return new Vec3(pos.x, pos.y, pos.z); 60 | } 61 | 62 | public static NetherPath emptyPath() { 63 | return EMPTY_PATH; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.pathing.goals; 19 | 20 | import baritone.api.pathing.goals.GoalGetToBlock; 21 | import org.junit.Test; 22 | 23 | import java.util.ArrayList; 24 | import java.util.Arrays; 25 | import java.util.List; 26 | import net.minecraft.core.BlockPos; 27 | 28 | import static org.junit.Assert.assertTrue; 29 | 30 | public class GoalGetToBlockTest { 31 | 32 | @Test 33 | public void isInGoal() { 34 | List<String> 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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.api.event.events; 19 | 20 | import net.minecraft.core.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/main/java/baritone/utils/schematic/StaticSchematic.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 <https://www.gnu.org/licenses/>. 16 | */ 17 | 18 | package baritone.utils.schematic; 19 | 20 | import baritone.api.schematic.AbstractSchematic; 21 | import baritone.api.schematic.IStaticSchematic; 22 | import java.util.List; 23 | import net.minecraft.world.level.block.state.BlockState; 24 | 25 | /** 26 | * Default implementation of {@link IStaticSchematic} 27 | * 28 | * @author Brady 29 | * @since 12/23/2019 30 | */ 31 | public class StaticSchematic extends AbstractSchematic implements IStaticSchematic { 32 | 33 | protected BlockState[][][] states; 34 | 35 | public StaticSchematic() {} 36 | 37 | public StaticSchematic(BlockState[][][] states) { 38 | this.states = states; 39 | boolean empty = states.length == 0 || states[0].length == 0 || states[0][0].length == 0; 40 | this.x = empty ? 0 : states.length; 41 | this.z = empty ? 0 : states[0].length; 42 | this.y = empty ? 0 : states[0][0].length; 43 | } 44 | 45 | @Override 46 | public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) { 47 | return this.states[x][z][y]; 48 | } 49 | 50 | @Override 51 | public BlockState getDirect(int x, int y, int z) { 52 | return this.states[x][z][y]; 53 | } 54 | 55 | @Override 56 | public BlockState[] getColumn(int x, int z) { 57 | return this.states[x][z]; 58 | } 59 | } 60 | --------------------------------------------------------------------------------