diff --git a/FEATURES.md b/FEATURES.md index cd2a90fe1..e3714a8c7 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -11,6 +11,7 @@ - **Avoiding dangerous blocks** Obviously, it knows not to walk through fire or on magma, not to corner over lava (that deals some damage), not to break any blocks touching a liquid (it might drown), etc. - **Parkour** Sprint jumping over 1, 2, or 3 block gaps - **Parkour place** Sprint jumping over a 3 block gap and placing the block to land on while executing the jump. It's really cool. +- **Pigs** It can sort of control pigs. I wouldn't rely on it though. # Pathing method Baritone uses A*, with some modifications: @@ -46,7 +47,6 @@ Things it doesn't have yet See issues for more. Things it may not ever have, from most likely to least likely =( -- Pigs - Boats - Horses (2x3 path instead of 1x2) - Elytra diff --git a/IMPACT.md b/IMPACT.md deleted file mode 100644 index cc12252ee..000000000 --- a/IMPACT.md +++ /dev/null @@ -1 +0,0 @@ -Impact 4.4 is out. See INSTALL.md \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index 9df3d6bf7..f05e02808 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,11 +1,10 @@ # Integration between Baritone and Impact Impact 4.4 has Baritone included. -These instructions apply to Impact 4.3 (and potentially other hacked clients). +These instructions apply to Impact 4.3 (and potentially other "hacked clients"). To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`). - ## An Introduction There are some basic steps to getting Baritone setup with Impact. - Acquiring a build of Baritone @@ -26,14 +25,7 @@ Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMe The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone . && docker run --rm cabaletta/baritone cat /code/dist/checksums.txt` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). ### Building Baritone yourself -There are a few steps to this -- Clone this repository -- Setup the project as instructed in the README -- Run the ``build`` gradle task. You can either do this using IntelliJ's gradle UI or through a -command line - - Windows: ``gradlew build`` - - Mac/Linux: ``./gradlew build`` -- The build should be exported into ``/build/libs/baritone-X.Y.Z.jar`` +You can either build Baritone through a command line or through IntelliJ's UI, information on that can be found [here](SETUP.md#building). ## Placing Baritone in the libraries directory ``/libraries`` is a neat directory in your Minecraft Installation Directory diff --git a/README.md b/README.md index 6bffdc242..8fa78e8cc 100644 --- a/README.md +++ b/README.md @@ -6,50 +6,39 @@ [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) +[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) +[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) +[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) +![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) +![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) -[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-brightgreen.svg)](https://impactdevelopment.github.io/) +[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) +[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) +[![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) +[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-green.svg)](https://impactdevelopment.github.io/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) -[![Asuna integration](https://img.shields.io/badge/Asuna%20integration-v1.0.0-orange.svg)](https://github.com/EmotionalLove/Asuna/) -[![Future integration](https://img.shields.io/badge/Future%20integration-%3F%3F%3F-red.svg)](https://futureclient.net/) +[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) +[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) +[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) +[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) +[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) + A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Here are some links to help to get started: - [Features](FEATURES.md) +- [Setup](SETUP.md) + - [Installation](INSTALL.md) -# Setup - -## Command Line -On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. - -Running Baritone: - -``` -$ gradlew runClient -``` - -Building Baritone: -``` -$ gradlew build -``` - -To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). - -## IntelliJ's Gradle UI -- Open the project in IntelliJ as a Gradle project -- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` -- Refresh the Gradle project (or, to be safe, just restart IntelliJ) -- Select the "Minecraft Client" launch config -- In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`. - # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 000000000..6400990d4 --- /dev/null +++ b/SETUP.md @@ -0,0 +1,79 @@ +# Setup + +- Clone or download Baritone + + ![Image](https://i.imgur.com/kbqBtoN.png) + - If you choose to download, make sure you extract the ZIP archive. +- Follow one of the instruction sets below, based on your preference + +## Command Line +On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. + +Setting up the Environment: + +``` +$ gradlew setupDecompWorkspace +$ gradlew --refresh-dependencies +``` + +Running Baritone: + +``` +$ gradlew runClient +``` + +For information on how to build baritone, see [Building Baritone](#building-baritone) + +## IntelliJ +- Open the project in IntelliJ as a Gradle project + + ![Image](https://i.imgur.com/jw7Q6vY.png) + +- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` + + ![Image](https://i.imgur.com/QEfVvWP.png) + +- Refresh the Gradle project (or, to be safe, just restart IntelliJ) + + ![Image](https://i.imgur.com/3V7EdWr.png) + +- Select the "Minecraft Client" launch config + + ![Image](https://i.imgur.com/1qz2QGV.png) + +- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config + + ![Image](https://i.imgur.com/s4ly0ZF.png) + +- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`. + + ![Image](https://i.imgur.com/hrLhG9u.png) + +# Building + +Make sure that you have properly [setup](#setup) the environment before trying to build it. + +## Command Line + +``` +$ gradlew build +``` + +## IntelliJ + +- Navigate to the gradle tasks on the right tab as follows + + ![Image](https://i.imgur.com/PE6r9iN.png) + +- Right click on **build** and press **Run** + +## Artifacts + +Building Baritone will result in 3 artifacts created in the ``dist`` directory. + +- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. +- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. +- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. + +## More Info +To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). diff --git a/src/api/java/baritone/api/event/events/SprintStateEvent.java b/src/api/java/baritone/api/event/events/SprintStateEvent.java index 6027c79e2..606728017 100644 --- a/src/api/java/baritone/api/event/events/SprintStateEvent.java +++ b/src/api/java/baritone/api/event/events/SprintStateEvent.java @@ -21,7 +21,7 @@ package baritone.api.event.events; * @author Brady * @since 1/18/2019 */ -public class SprintStateEvent { +public final class SprintStateEvent { private Boolean state; diff --git a/src/api/java/baritone/api/process/IBaritoneProcess.java b/src/api/java/baritone/api/process/IBaritoneProcess.java index c2eb2f49e..01e833c0b 100644 --- a/src/api/java/baritone/api/process/IBaritoneProcess.java +++ b/src/api/java/baritone/api/process/IBaritoneProcess.java @@ -25,8 +25,8 @@ import baritone.api.event.events.PathEvent; *

* Differences between a baritone process and a behavior: *

*

* That's it actually diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 48ac8c949..bbf920113 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -23,6 +23,7 @@ import baritone.api.event.events.ChatEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.SprintStateEvent; import baritone.api.event.events.type.EventState; +import baritone.behavior.LookBehavior; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.PlayerCapabilities; @@ -102,4 +103,14 @@ public class MixinEntityPlayerSP { BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerSprintState(event); return event.getState() == null ? keyBinding.isKeyDown() : event.getState(); } + + @Inject( + method = "updateRidden", + at = @At( + value = "HEAD" + ) + ) + private void updateRidden(CallbackInfo cb) { + ((LookBehavior) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getLookBehavior()).pig(); + } } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 31e769135..c2d0326c9 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -95,6 +95,12 @@ public final class LookBehavior extends Behavior implements ILookBehavior { } } + public void pig() { + if (this.target != null) { + ctx.player().rotationYaw = this.target.getYaw(); + } + } + @Override public void onPlayerRotationMove(RotationMoveEvent event) { if (this.target != null && !this.force) { diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 83cf460d5..fe2efa4eb 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -24,6 +24,7 @@ import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.WorldServer; +import org.apache.commons.lang3.SystemUtils; import java.io.File; import java.io.FileOutputStream; @@ -76,7 +77,11 @@ public class WorldProvider implements IWorldProvider, Helper { directory = new File(directory, "baritone"); readme = directory; } else { // Otherwise, the server must be remote... - directory = new File(Baritone.getDir(), mc.getCurrentServerData().serverIP); + String folderName = mc.getCurrentServerData().serverIP; + if (SystemUtils.IS_OS_WINDOWS) { + folderName = folderName.replace(":", "_"); + } + directory = new File(Baritone.getDir(), folderName); readme = Baritone.getDir(); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index d7c3fd717..e0423632d 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -78,6 +78,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { "costs - (debug) all movement costs from current location\n" + "damn - Daniel "; + private static final String COMMAND_PREFIX = "#"; + public ExampleBaritoneControl(Baritone baritone) { super(baritone); } @@ -89,13 +91,16 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } String msg = event.getMessage(); if (Baritone.settings().prefix.get()) { - if (!msg.startsWith("#")) { - return; + if (msg.startsWith(COMMAND_PREFIX)) { + if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { + logDirect("Invalid command"); + } + event.cancel(); // always cancel if using prefix + } + } else { + if (runCommand(msg)) { + event.cancel(); } - msg = msg.substring(1); - } - if (runCommand(msg)) { - event.cancel(); } } @@ -122,7 +127,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { for (String line : HELP_MSG.split("\n")) { logDirect(line); } - return false; + return true; } if (msg.contains(" ")) { String[] data = msg.split(" "); diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index deca0951d..9f07efdf4 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -216,8 +216,9 @@ public final class PathRenderer implements Helper { double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; + BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe? positions.forEach(pos -> { - IBlockState state = BlockStateInterface.get(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext(), pos); + IBlockState state = bsi.get0(pos); AxisAlignedBB toDraw; if (state.getBlock().equals(Blocks.AIR)) { toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(player.world, pos);