Compare commits

...

80 Commits

Author SHA1 Message Date
Leijurv
33080a4e1c v1.2.9 2019-08-23 15:23:54 -07:00
Leijurv
dae6cc8e20 maintain current behavior 2019-08-23 15:23:36 -07:00
Leijurv
a2159d62e5 quite annoying 2019-08-23 15:23:00 -07:00
Leijurv
a092a0ba94 update badges 2019-08-23 15:22:59 -07:00
Leijurv
33faf5c9b0 Merge pull request #835 from IronException/master
added things to avoid
2019-08-23 15:22:42 -07:00
IronException
d927207b67 added things to avoid
Signs should also be avoided. A lot of history can get lost
2019-08-22 17:44:27 +02:00
Leijurv
b9f0da7d27 major unscuff of builder 2019-08-20 11:23:23 -07:00
Leijurv
1c36bf3300 repack on mine cmd 2019-08-17 22:01:53 -07:00
Leijurv
cca137d526 Merge pull request #808 from reb0rt/patch-2
Stop parseGoal from removing the last argument (when it shouldn't)
2019-08-17 21:13:59 -07:00
reb0rt
24da012903 Stop parseGoal from removing the last argument
isNumeric returns false if the input is anything other than a positive integer. This meant that baritone wouldn't properly set goals if they ended in anything other than a positive integer.
2019-08-18 13:04:39 +10:00
Leijurv
0eb7a5aed6 Merge pull request #805 from Graicc/master
Added amount of block mining to documentation
2019-08-17 09:37:03 -07:00
Graicc
5cbf1eef5f Grammer fix 2019-08-17 12:02:26 -04:00
Graicc
ed4fba330d Added mining certain amount of blocks to USAGE.md 2019-08-17 11:59:30 -04:00
Leijurv
9046eb500b crucial performance optimization 2019-08-16 21:16:41 -07:00
Leijurv
011b7427e2 fine lmao 2019-08-15 23:03:16 -07:00
Leijurv
13caaf6fa7 ok fine optifine 2019-08-15 19:27:46 -07:00
Brady
a98677dbda crucial performance optimization 2019-08-15 03:19:19 -05:00
Leijurv
6c1f0d3711 Merge pull request #764 from Scribblefoxx/master
Just a little fix, you know was coding away and thought, "hey! here is something cool!"
2019-08-10 08:20:50 -10:00
Scribblefoxx
e1e6a08eb2 Update Settings.java 2019-08-11 03:39:29 +10:00
Leijurv
7b21b0401d Merge pull request #712 from IronException/master
dimensional coords extension
2019-08-08 21:47:28 -10:00
Leijurv
4c935fc447 epicer cached bedrock level pathing 2019-08-08 18:09:25 -10:00
Leijurv
3d221dcda4 antiquated and does more harm than good 2019-08-08 18:04:49 -10:00
Friedolin2000
ac6c413fb8 dimensional coords extension 2019-08-08 22:45:18 +02:00
Leijurv
17a07ba85e better render 2019-08-08 09:56:06 -10:00
Leijurv
ca6f7003a5 Merge pull request #752 from cabaletta/raytrace-shaders
Disable lighting on path renderer
2019-08-08 09:55:16 -10:00
Howard Stark
d402ba61cc Disable lighting on path render 2019-08-08 09:36:55 -10:00
Leijurv
081fae98c4 1 year later 2019-08-01 23:47:32 -07:00
Leijurv
014d3b3a99 goal can never be null 2019-08-01 23:47:12 -07:00
Leijurv
19fe29ad1e i am stupid 2019-07-31 22:17:44 -07:00
Leijurv
8bcbd0231e bye 2019-07-31 21:45:57 -07:00
Leijurv
01c0e321b5 what was i THINKING 2019-07-31 20:58:45 -07:00
Leijurv
5f721b544e smh conner, imagine getting the same block position 2x without caching 2019-07-31 20:47:46 -07:00
Leijurv
57d4a79496 Merge pull request #701 from c0nn3r/master
Add parkour ascend
2019-07-30 21:55:37 -07:00
Conner
9541a45451 Resolve comments 2019-07-30 21:37:50 -07:00
Conner
bba4c09195 Add parkour ascend 2019-07-30 21:07:26 -07:00
Leijurv
06c62029c5 not iffy 2019-07-30 20:04:50 -07:00
Leijurv
6f251b64f1 i am very stupid 2019-07-29 17:35:06 -07:00
Leijurv
551b6b88d2 EXTREMELY old comment that is no longer true 2019-07-28 00:19:14 -07:00
Leijurv
07cbc47fb2 extra line 2019-07-27 23:51:23 -07:00
Leijurv
fe6ca97f21 whoops 2019-07-26 15:14:35 -07:00
Leijurv
1b481c6765 aristois badge 2019-07-26 15:14:04 -07:00
Leijurv
1c5e0b4d68 bump impact badge 2019-07-25 23:02:44 -07:00
Leijurv
bc849daccb v1.2.8 2019-07-24 15:38:14 -07:00
Leijurv
f5b4de023f update usage stuff 2019-07-24 15:33:39 -07:00
Leijurv
6dc7a7788e install for 1.14.4 2019-07-23 22:30:04 -07:00
Leijurv
0e51a73149 instanceof BlockLiquid checks this 2019-07-23 11:53:21 -07:00
Leijurv
44a092cd94 Merge pull request #622 from babbaj/schematica
fix crash
2019-07-22 23:57:54 -07:00
Babbaj
7000b6cda2 fix crash 2019-07-23 02:56:24 -04:00
Leijurv
7a17f7d253 Merge pull request #607 from babbaj/schematica
build the schematic schematica has open
2019-07-22 23:53:09 -07:00
Babbaj
821e73c1d3 fix usage.md 2019-07-23 02:48:40 -04:00
Babbaj
784bc52d6d add to usage.md 2019-07-23 02:46:53 -04:00
Leijurv
4338e34734 while this is cool, nothing will ever conceivably use it 2019-07-22 23:37:43 -07:00
Babbaj
61147536e5 ok 2019-07-22 16:51:09 -04:00
Leijurv
6b9737eb3f fix double jump on paused overshot sprint ascend 2019-07-21 22:04:15 -07:00
Babbaj
fe54372a53 resolve the issue 2019-07-21 22:33:22 -04:00
Babbaj
21e9c0b7c1 add get functions 2019-07-21 22:17:21 -04:00
Babbaj
8bf977060e dont need the fields 2019-07-21 22:06:36 -04:00
Babbaj
074ec333cf clean up a bit 2019-07-21 21:57:59 -04:00
Babbaj
d505ec4f9f build the schematic schematica has open 2019-07-21 21:05:43 -04:00
Leijurv
4d127acb9a reformat 2019-07-20 23:47:51 -07:00
Leijurv
df900c9e64 use origin 2019-07-19 18:55:32 -07:00
Leijurv
93a090c56e Merge pull request #588 from StijnSimons/master
I forgot players and items were entities too
2019-07-19 17:06:48 -07:00
StijnSimons
8b43d93259 i forgot players and items were entities too 2019-07-20 01:37:43 +02:00
Leijurv
053662d0af Merge pull request #554 from StijnSimons/master
FollowEntity and FollowEntities
2019-07-19 16:31:04 -07:00
Brady
af943a8253 Fix issue opening fence gates in some scenarios
If there are 2 fence gates at the player height, and they are approached
diagonally, there is a slight chance that Baritone will be caught in an
infinite loop of opening and closing the upper fence gate, being unable
to interact with the bottom one.
2019-07-18 21:18:02 -05:00
Leijurv
8151444671 privatize this too 2019-07-18 14:15:53 -07:00
Leijurv
f32147d9d5 privatize 2019-07-17 22:41:09 -07:00
Leijurv
515e0364f7 Merge pull request #564 from ZakME/patch-1
PICKUP_DROPPED - Remove 2nd Items.WHEAT
2019-07-16 23:01:09 -07:00
ZakME
09239f8180 PICKUP_DROPPED - Remove 2nd Items.WHEAT
PICKUP_DROPPED:
Remove 2nd Items.WHEAT
Re-order a few items for neatness
2019-07-16 23:50:03 -06:00
Brady
0d9f233e33 Add question template 2019-07-15 18:00:51 -05:00
Brady
e034437c63 Separate templates 2019-07-15 17:55:15 -05:00
Leijurv
72be046f34 Update ISSUE_TEMPLATE.md 2019-07-15 15:26:58 -07:00
StijnSimons
3ba8824eb0 More copy paste 2019-07-15 22:34:52 +02:00
StijnSimons
b51a261bd1 Added entityfollow
Hey look i can cntrl + c v
2019-07-15 22:31:55 +02:00
Leijurv
38602dd141 verify top side of block, fixes #541 2019-07-14 11:13:51 -07:00
Leijurv
cdbec60da0 Merge pull request #531 from StijnSimons/master
Added Spider, PigZombie and Enderman conditions
2019-07-13 09:15:53 -07:00
StijnSimons
2b41012c5b Enderman angry condition 2019-07-13 17:17:10 +02:00
Leijurv
6bb87d0a64 address an absolutely critical gap in documentation 2019-07-12 23:27:02 -07:00
Baddeveloper
b16f9edd2c Added EntitySpider and EntityPigZombie conditions 2019-07-12 19:12:00 +02:00
Leijurv
ce4b1e09ed fix parkour and multithread farm 2019-07-11 14:39:10 -07:00
45 changed files with 722 additions and 331 deletions

View File

@@ -1 +0,0 @@
<!-- No UwU's or OwO's allowed -->

25
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View File

@@ -0,0 +1,25 @@
---
name: Bug report
about: Please file a separate report for each issue
title: Please add a brief but descriptive title
labels: bug
assignees: ''
---
## Some information
Operating system:
Java version:
Minecraft version:
Baritone version:
Forge mods (if used):
## Exception, error or logs
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
## How to reproduce
Add your steps to reproduce the issue/bug experienced here.
## Final checklist
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
- [ ] I have not used any OwO's or UwU's in this issue.

13
.github/ISSUE_TEMPLATE/question.md vendored Normal file
View File

@@ -0,0 +1,13 @@
---
name: Question
about: Please file a separate report for each question
title: Please add a brief but descriptive title
labels: question
assignees: ''
---
## What do you need help with?
With as much detail as possible, describe your question and what you may need help with.
## Final checklist
- [ ] I have not used any OwO's or UwU's in this issue.

19
.github/ISSUE_TEMPLATE/suggestion.md vendored Normal file
View File

@@ -0,0 +1,19 @@
---
name: Suggestion
about: Please file a separate report for each suggestion
title: Please add a brief but descriptive title
labels: enhancement
assignees: ''
---
## Describe your suggestion
With as much detail as possible, describe what your suggestion would do for Baritone.
## Settings
If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.
## Context
Describe how your suggestion would improve Baritone, or the reason behind it being added.
## Final checklist
- [ ] I have not used any OwO's or UwU's in this issue.

View File

@@ -5,8 +5,9 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cabaletta/baritone&amp;utm_campaign=Badge_Grade)
[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/)
[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/)
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://github.com/cabaletta/baritone/tree/master/)
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/master/)
[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/)
[![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/)
[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
[![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/)
@@ -18,8 +19,9 @@
![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code)
[![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/)
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/)
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.8%20/%20v1.3.4%20/%20v1.4.1-brightgreen.svg)](https://impactdevelopment.github.io/)
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/)
[![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api)
[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/)
[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/)
[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/)
@@ -29,12 +31,14 @@ 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.
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
Have committed at least once a day for the last 11 months =D 🦀
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2

View File

@@ -2,6 +2,8 @@
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
## Prebuilt official releases
@@ -9,6 +11,8 @@ These releases are not always completely up to date with latest features, and ar
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` 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).

View File

@@ -18,16 +18,18 @@ To toggle a boolean setting, just say its name in chat (for example saying `allo
Some common examples:
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
- `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
- `goal` to set the goal to your player's feet
- `goal clear` to clear the goal
- `cancel` or `stop` to stop everything
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.)
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
- `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time).
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
- `schematica` to build the schematic that is currently open in schematica
- `tunnel` to dig just straight ahead and make a tunnel
- `farm` to automatically harvest, replant, or bone meal crops
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).

View File

@@ -16,7 +16,7 @@
*/
group 'baritone'
version '1.2.7'
version '1.2.9'
buildscript {
repositories {
@@ -55,6 +55,14 @@ sourceSets {
launch {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
schematica_api {
compileClasspath += main.compileClasspath
}
main {
compileClasspath += schematica_api.output
}
}
minecraft {

View File

@@ -31,6 +31,11 @@
# need to keep mixin names
-keep class baritone.launch.** { *; }
#try to keep usage of schematica in separate classes
-keep class baritone.utils.schematic.schematica.**
#proguard doesnt like it when it cant find our fake schematica classes
-dontwarn baritone.utils.schematic.schematica.**
# copy all necessary libraries into tempLibraries to build
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with

View File

@@ -128,5 +128,8 @@ public interface IBaritone {
*/
IEventBus getGameEventHandler();
/**
* Open click
*/
void openClick();
}

View File

@@ -124,6 +124,13 @@ public final class Settings {
*/
public final Setting<Boolean> allowJumpAt256 = new Setting<>(false);
/**
* This should be monetized it's so good
* <p>
* Defaults to true, but only actually takes effect if allowParkour is also true
*/
public final Setting<Boolean> allowParkourAscend = new Setting<>(true);
/**
* Allow descending diagonally
* <p>
@@ -165,7 +172,9 @@ public final class Settings {
Blocks.FURNACE,
Blocks.LIT_FURNACE,
Blocks.CHEST,
Blocks.TRAPPED_CHEST
Blocks.TRAPPED_CHEST,
Blocks.STANDING_SIGN,
Blocks.WALL_SIGN
)));
/**
@@ -179,7 +188,7 @@ public final class Settings {
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
* <p>
* Never turn this on lol
* Almost never turn this on lol
*/
public final Setting<Boolean> allowVines = new Setting<>(false);
@@ -690,11 +699,36 @@ public final class Settings {
*/
public final Setting<Boolean> goalBreakFromAbove = new Setting<>(false);
/**
* Build in map art mode, which makes baritone only care about the top block in each column
*/
public final Setting<Boolean> mapArtMode = new Setting<>(false);
/**
* Override builder's behavior to not attempt to correct blocks that are currently water
*/
public final Setting<Boolean> okIfWater = new Setting<>(false);
/**
* The set of incorrect blocks can never grow beyond this size
*/
public final Setting<Integer> incorrectSize = new Setting<>(100);
/**
* Multiply the cost of breaking a block that's correct in the builder's schematic by this coefficient
*/
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
/**
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
*/
public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
/**
* Trim incorrect positions too far away, helps performance but hurts reliability in very large schematics
*/
public final Setting<Boolean> distanceTrim = new Setting<>(true);
/**
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
* <p>

View File

@@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
return build(schematicFile, file, origin);
}
void buildOpenSchematic();
void pause();
void resume();

View File

@@ -35,48 +35,24 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ReportedException;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.world.DimensionType;
import net.minecraft.world.chunk.Chunk;
import java.nio.file.Path;
import java.util.*;
import static org.apache.commons.lang3.math.NumberUtils.isCreatable;
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
private static final String HELP_MSG =
"baritone - Output settings into chat\n" +
"settings - Same as baritone\n" +
"goal - Create a goal (one number is '<Y>', two is '<X> <Z>', three is '<X> <Y> <Z>, 'clear' to clear)\n" +
"path - Go towards goal\n" +
"repack - (debug) Repacks chunk cache\n" +
"rescan - (debug) Same as repack\n" +
"axis - Paths towards the closest axis or diagonal axis, at y=120\n" +
"cancel - Cancels current path\n" +
"forcecancel - sudo cancel (only use if very glitched, try toggling 'pause' first)\n" +
"gc - Calls System.gc();\n" +
"invert - Runs away from the goal instead of towards it\n" +
"follow - Follows a player 'follow username'\n" +
"reloadall - (debug) Reloads chunk cache\n" +
"saveall - (debug) Saves chunk cache\n" +
"find - (debug) outputs how many blocks of a certain type are within the cache\n" +
"mine - Paths to and mines specified blocks 'mine x_ore y_ore ...'\n" +
"thisway - Creates a goal X blocks where you're facing\n" +
"list - Lists waypoints under a category\n" +
"get - Same as list\n" +
"show - Same as list\n" +
"save - Saves a waypoint (works but don't try to make sense of it)\n" +
"delete - Deletes a waypoint\n" +
"goto - Paths towards specified block or waypoint\n" +
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
"sethome - Sets \"home\"\n" +
"home - Paths towards \"home\" \n" +
"costs - (debug) all movement costs from current location\n" +
"damn - Daniel\n" +
"Go to https://github.com/cabaletta/baritone/blob/master/USAGE.md for more information";
private static final String COMMAND_PREFIX = "#";
public final IBaritone baritone;
@@ -147,9 +123,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
if (msg.equals("") || msg.equals("help") || msg.equals("?")) {
for (String line : HELP_MSG.split("\n")) {
logDirect(line);
}
ITextComponent component = MESSAGE_PREFIX.createCopy();
component.getStyle().setColor(TextFormatting.GRAY);
TextComponentString helpLink = new TextComponentString(" Click here for instructions on how to use Baritone (https://github.com/cabaletta/baritone/blob/master/USAGE.md)");
helpLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/cabaletta/baritone/blob/master/USAGE.md"));
component.appendSibling(helpLink);
BaritoneAPI.getSettings().logger.value.accept(component);
return true;
}
if (msg.contains(" ")) {
@@ -262,20 +241,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
if (msg.equals("repack") || msg.equals("rescan")) {
ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider();
int playerChunkX = ctx.playerFeet().getX() >> 4;
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
int count = 0;
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
Chunk chunk = cli.getLoadedChunk(x, z);
if (chunk != null) {
count++;
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
}
}
}
logDirect("Queued " + count + " chunks for repacking");
logDirect("Queued " + repack() + " chunks for repacking");
return true;
}
if (msg.startsWith("build")) {
@@ -284,7 +250,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
try {
String[] coords = msg.substring("build".length()).trim().split(" ");
file = coords[0] + ".schematic";
origin = new BlockPos(parseOrDefault(coords[1], ctx.playerFeet().x), parseOrDefault(coords[2], ctx.playerFeet().y), parseOrDefault(coords[3], ctx.playerFeet().z));
origin = new BlockPos(parseOrDefault(coords[1], ctx.playerFeet().x, 1), parseOrDefault(coords[2], ctx.playerFeet().y, 1), parseOrDefault(coords[3], ctx.playerFeet().z, 1));
} catch (Exception ex) {
file = msg.substring(5).trim() + ".schematic";
origin = ctx.playerFeet();
@@ -294,6 +260,10 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
logDirect(success ? "Loaded" : "Unable to load");
return true;
}
if (msg.startsWith("schematica")) {
baritone.getBuilderProcess().buildOpenSchematic();
return true;
}
if (msg.equals("come")) {
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
logDirect("Coming");
@@ -390,7 +360,8 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
}
if (msg.equals("render")) {
BetterBlockPos pf = ctx.playerFeet();
Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pf.x - 500, pf.y - 500, pf.z - 500, pf.x + 500, pf.y + 500, pf.z + 500);
int dist = (Minecraft.getMinecraft().gameSettings.renderDistanceChunks + 1) * 16;
Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pf.x - dist, pf.y - 256, pf.z - dist, pf.x + dist, pf.y + 256, pf.z + dist);
logDirect("okay");
return true;
}
@@ -406,11 +377,34 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
}
return true;
}
if (msg.startsWith("followentities")) {
baritone.getFollowProcess().follow(Entity.class::isInstance);
logDirect("Following any entities");
return true;
}
if (msg.startsWith("followplayers")) {
baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A
logDirect("Following any players");
return true;
}
if (msg.startsWith("followentity")) {
String name = msg.substring(12).trim();
Optional<Entity> toFollow = Optional.empty();
for (Entity entity : ctx.world().loadedEntityList) {
String entityName = entity.getName().trim().toLowerCase();
if ((entityName.contains(name) || name.contains(entityName)) && !(entity instanceof EntityItem || entity instanceof EntityPlayer)) { // We dont want it following players while `#follow` exists.
toFollow = Optional.of(entity);
}
}
if (!toFollow.isPresent()) {
logDirect("Entity not found");
return true;
}
Entity effectivelyFinal = toFollow.get();
baritone.getFollowProcess().follow(effectivelyFinal::equals);
logDirect("Following entity " + toFollow.get());
return true;
}
if (msg.startsWith("follow")) {
String name = msg.substring(6).trim();
Optional<Entity> toFollow = Optional.empty();
@@ -495,6 +489,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
if (msg.startsWith("find")) {
repack();
String blockType = msg.substring(4).trim();
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
logDirect("Have " + locs.size() + " locations");
@@ -507,6 +502,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
if (msg.startsWith("mine")) {
repack();
String[] blockTypes = msg.substring(4).trim().split(" ");
try {
int quantity = Integer.parseInt(blockTypes[1]);
@@ -586,7 +582,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
}
if (msg.startsWith("delete")) {
String name = msg.substring(6).trim();
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
if (waypoint == null) {
logDirect("No user defined position under the name '" + name + "' found.");
return true;
@@ -596,6 +592,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
if (msg.startsWith("goto")) {
repack();
String waypointType = msg.substring(4).trim();
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
// for example, "show deaths"
@@ -669,8 +666,25 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return false;
}
private int parseOrDefault(String str, int i) {
return str.equals("~") ? i : str.startsWith("~") ? Integer.parseInt(str.substring(1)) + i : Integer.parseInt(str);
private int repack() {
ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider();
int playerChunkX = ctx.playerFeet().getX() >> 4;
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
int count = 0;
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
Chunk chunk = cli.getLoadedChunk(x, z);
if (chunk != null && !chunk.isEmpty()) {
count++;
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
}
}
}
return count;
}
private int parseOrDefault(String str, int i, double dimensionFactor) {
return str.equals("~") ? i : str.startsWith("~") ? (int) (Integer.parseInt(str.substring(1)) * dimensionFactor) + i : (int) (Integer.parseInt(str) * dimensionFactor);
}
private void log(List<ItemStack> stacks) {
@@ -685,19 +699,23 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
Goal goal;
try {
BetterBlockPos playerFeet = ctx.playerFeet();
switch (params.length) {
int length = params.length - 1; // length has to be smaller when a dimension parameter is added
if (params.length < 1 || (isCreatable(params[params.length - 1]) || params[params.length - 1].startsWith("~"))) {
length = params.length;
}
switch (length) {
case 0:
goal = new GoalBlock(playerFeet);
break;
case 1:
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y));
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y, 1));
break;
case 2:
goal = new GoalXZ(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.z));
goal = new GoalXZ(parseOrDefault(params[0], playerFeet.x, calculateDimensionFactor(params[params.length - 1])), parseOrDefault(params[1], playerFeet.z, calculateDimensionFactor(params[params.length - 1])));
break;
case 3:
goal = new GoalBlock(new BlockPos(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.y), parseOrDefault(params[2], playerFeet.z)));
goal = new GoalBlock(new BlockPos(parseOrDefault(params[0], playerFeet.x, calculateDimensionFactor(params[params.length - 1])), parseOrDefault(params[1], playerFeet.y, 1), parseOrDefault(params[2], playerFeet.z, calculateDimensionFactor(params[params.length - 1]))));
break;
default:
logDirect("unable to understand lol");
@@ -709,4 +727,23 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
}
return goal;
}
private double calculateDimensionFactor(String to) {
return Math.pow(8, ctx.world().provider.getDimensionType().getId() - getDimensionByName(to.toLowerCase()).getId());
}
private DimensionType getDimensionByName(String name) {
if ("the_end".contains(name)) {
return DimensionType.THE_END;
}
if ("the_overworld".contains(name) || "surface".contains(name)) {
return DimensionType.OVERWORLD;
}
if ("the_nether".contains(name) || "hell".contains(name)) {
return DimensionType.NETHER;
}
return ctx.world().provider.getDimensionType();
}
}

View File

@@ -27,7 +27,7 @@ public class MyChunkPos {
@SerializedName("x")
public int x;
@SerializedName("y")
@SerializedName("z")
public int z;
@Override

View File

@@ -148,12 +148,12 @@ public class Baritone implements IBaritone {
}
@Override
public CustomGoalProcess getCustomGoalProcess() { // Iffy
public CustomGoalProcess getCustomGoalProcess() {
return this.customGoalProcess;
}
@Override
public GetToBlockProcess getGetToBlockProcess() { // Iffy
public GetToBlockProcess getGetToBlockProcess() {
return this.getToBlockProcess;
}

View File

@@ -26,6 +26,7 @@ import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ClickType;
import net.minecraft.item.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import java.util.ArrayList;
@@ -132,9 +133,12 @@ public final class InventoryBehavior extends Behavior {
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && maybe.equals(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(ctx.world(), ctx.playerFeet(), EnumFacing.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ, stack.getItem().getMetadata(stack.getMetadata()), ctx.player())))) {
return true; // gotem
}
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
return true;
}
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
return true;

View File

@@ -135,7 +135,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
) {
// when it was *just* started, currentBest will be empty so we need to also check calcFrom since that's always present
inProgress.cancel(); // cancellation doesn't dispatch any events
inProgress = null; // this is safe since we hold both locks
}
}
}
@@ -339,7 +338,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
// just cancel the current path
public void secretInternalSegmentCancel() {
private void secretInternalSegmentCancel() {
queuePathEvent(PathEvent.CANCELED);
synchronized (pathPlanLock) {
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
@@ -361,12 +360,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
}
/*public void secretCursedFunctionDoNotCall(IPath path) {
synchronized (pathPlanLock) {
current = new PathExecutor(this, path);
}
}*/
public CalculationContext secretInternalGetCalculationContext() {
return context;
}
@@ -495,7 +488,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
}
if (talkAboutIt && current != null && current.getPath() != null) {
if (goal == null || goal.isInGoal(current.getPath().getDest())) {
if (goal.isInGoal(current.getPath().getDest())) {
logDebug("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
} else {
logDebug("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
@@ -508,7 +501,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
});
}
public static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
Goal transformed = goal;
if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) {
BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();

View File

@@ -26,7 +26,10 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import java.util.*;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
/**
* @author Brady
@@ -35,57 +38,57 @@ import java.util.*;
public final class CachedChunk {
public static final ImmutableSet<Block> BLOCKS_TO_KEEP_TRACK_OF = ImmutableSet.of(
Blocks.DIAMOND_BLOCK,
//Blocks.COAL_ORE,
Blocks.COAL_BLOCK,
//Blocks.IRON_ORE,
Blocks.IRON_BLOCK,
//Blocks.GOLD_ORE,
Blocks.GOLD_BLOCK,
Blocks.EMERALD_ORE,
Blocks.EMERALD_BLOCK,
Blocks.DIAMOND_BLOCK,
//Blocks.COAL_ORE,
Blocks.COAL_BLOCK,
//Blocks.IRON_ORE,
Blocks.IRON_BLOCK,
//Blocks.GOLD_ORE,
Blocks.GOLD_BLOCK,
Blocks.EMERALD_ORE,
Blocks.EMERALD_BLOCK,
Blocks.ENDER_CHEST,
Blocks.FURNACE,
Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.END_PORTAL,
Blocks.END_PORTAL_FRAME,
Blocks.MOB_SPAWNER,
Blocks.BARRIER,
Blocks.OBSERVER,
Blocks.WHITE_SHULKER_BOX,
Blocks.ORANGE_SHULKER_BOX,
Blocks.MAGENTA_SHULKER_BOX,
Blocks.LIGHT_BLUE_SHULKER_BOX,
Blocks.YELLOW_SHULKER_BOX,
Blocks.LIME_SHULKER_BOX,
Blocks.PINK_SHULKER_BOX,
Blocks.GRAY_SHULKER_BOX,
Blocks.SILVER_SHULKER_BOX,
Blocks.CYAN_SHULKER_BOX,
Blocks.PURPLE_SHULKER_BOX,
Blocks.BLUE_SHULKER_BOX,
Blocks.BROWN_SHULKER_BOX,
Blocks.GREEN_SHULKER_BOX,
Blocks.RED_SHULKER_BOX,
Blocks.BLACK_SHULKER_BOX,
Blocks.PORTAL,
Blocks.HOPPER,
Blocks.BEACON,
Blocks.BREWING_STAND,
Blocks.SKULL,
Blocks.ENCHANTING_TABLE,
Blocks.ANVIL,
Blocks.LIT_FURNACE,
Blocks.BED,
Blocks.DRAGON_EGG,
Blocks.JUKEBOX,
Blocks.END_GATEWAY,
Blocks.WEB,
Blocks.NETHER_WART,
Blocks.LADDER,
Blocks.VINE
Blocks.ENDER_CHEST,
Blocks.FURNACE,
Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.END_PORTAL,
Blocks.END_PORTAL_FRAME,
Blocks.MOB_SPAWNER,
Blocks.BARRIER,
Blocks.OBSERVER,
Blocks.WHITE_SHULKER_BOX,
Blocks.ORANGE_SHULKER_BOX,
Blocks.MAGENTA_SHULKER_BOX,
Blocks.LIGHT_BLUE_SHULKER_BOX,
Blocks.YELLOW_SHULKER_BOX,
Blocks.LIME_SHULKER_BOX,
Blocks.PINK_SHULKER_BOX,
Blocks.GRAY_SHULKER_BOX,
Blocks.SILVER_SHULKER_BOX,
Blocks.CYAN_SHULKER_BOX,
Blocks.PURPLE_SHULKER_BOX,
Blocks.BLUE_SHULKER_BOX,
Blocks.BROWN_SHULKER_BOX,
Blocks.GREEN_SHULKER_BOX,
Blocks.RED_SHULKER_BOX,
Blocks.BLACK_SHULKER_BOX,
Blocks.PORTAL,
Blocks.HOPPER,
Blocks.BEACON,
Blocks.BREWING_STAND,
Blocks.SKULL,
Blocks.ENCHANTING_TABLE,
Blocks.ANVIL,
Blocks.LIT_FURNACE,
Blocks.BED,
Blocks.DRAGON_EGG,
Blocks.JUKEBOX,
Blocks.END_GATEWAY,
Blocks.WEB,
Blocks.NETHER_WART,
Blocks.LADDER,
Blocks.VINE
);
@@ -179,8 +182,17 @@ public final class CachedChunk {
}
}
if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) {
return Blocks.BEDROCK.getDefaultState();
if (type == PathingBlockType.SOLID) {
if (y == 127 && dimension == -1) {
// nether roof is always unbreakable
return Blocks.BEDROCK.getDefaultState();
}
if (y < 5 && dimension == 0) {
// solid blocks below 5 are commonly bedrock
// however, returning bedrock always would be a little yikes
// discourage paths that include breaking blocks below 5 a little more heavily just so that it takes paths breaking what's known to be stone (at 5 or above) instead of what could maybe be bedrock (below 5)
return Blocks.OBSIDIAN.getDefaultState();
}
}
return ChunkPacker.pathingTypeToBlock(type, dimension);
}

View File

@@ -76,6 +76,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
int timeCheckInterval = 1 << 6;
int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.value; // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior
double minimumImprovement = Baritone.settings().minimumImprovementRepropagation.value ? MIN_IMPROVEMENT : 0;
Moves[] allMoves = Moves.values();
while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && !cancelRequested) {
if ((numNodes & (timeCheckInterval - 1)) == 0) { // only call this once every 64 nodes (about half a millisecond)
long now = System.currentTimeMillis(); // since nanoTime is slow on windows (takes many microseconds)
@@ -95,7 +96,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
logDebug("Took " + (System.currentTimeMillis() - startTime) + "ms, " + numMovementsConsidered + " movements considered");
return Optional.of(new Path(startNode, currentNode, numNodes, goal, calcContext));
}
for (Moves moves : Moves.values()) {
for (Moves moves : allMoves) {
int newX = currentNode.x + moves.xOffset;
int newZ = currentNode.z + moves.zOffset;
if ((newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) && !calcContext.isLoaded(newX, newZ)) {

View File

@@ -127,7 +127,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper {
return new PathCalculationResult(PathCalculationResult.Type.SUCCESS_SEGMENT, path);
}
} catch (Exception e) {
Helper.HELPER.logDebug("Pathing exception: " + e);
Helper.HELPER.logDirect("Pathing exception: " + e);
e.printStackTrace();
return new PathCalculationResult(PathCalculationResult.Type.EXCEPTION);
} finally {

View File

@@ -72,28 +72,9 @@ class Path extends PathBase {
this.start = new BetterBlockPos(start.x, start.y, start.z);
this.end = new BetterBlockPos(end.x, end.y, end.z);
this.numNodes = numNodes;
this.path = new ArrayList<>();
this.movements = new ArrayList<>();
this.nodes = new ArrayList<>();
this.goal = goal;
this.context = context;
assemblePath(end);
}
@Override
public Goal getGoal() {
return goal;
}
/**
* Assembles this path given the end node.
*
* @param end The end node
*/
private void assemblePath(PathNode end) {
if (!path.isEmpty() || !movements.isEmpty()) {
throw new IllegalStateException();
}
PathNode current = end;
LinkedList<BetterBlockPos> tempPath = new LinkedList<>();
LinkedList<PathNode> tempNodes = new LinkedList<>();
@@ -107,8 +88,13 @@ class Path extends PathBase {
// Can't directly convert from the PathNode pseudo linked list to an array because we don't know how long it is
// inserting into a LinkedList<E> keeps track of length, then when we addall (which calls .toArray) it's able
// to performantly do that conversion since it knows the length.
path.addAll(tempPath);
nodes.addAll(tempNodes);
this.path = new ArrayList<>(tempPath);
this.nodes = new ArrayList<>(tempNodes);
}
@Override
public Goal getGoal() {
return goal;
}
private boolean assembleMovements() {

View File

@@ -58,6 +58,7 @@ public class CalculationContext {
public final boolean allowParkour;
public final boolean allowParkourPlace;
public final boolean allowJumpAt256;
public final boolean allowParkourAscend;
public final boolean assumeWalkOnWater;
public final boolean allowDiagonalDescend;
public final boolean allowDownward;
@@ -90,6 +91,7 @@ public class CalculationContext {
this.allowParkour = Baritone.settings().allowParkour.value;
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
this.allowDownward = Baritone.settings().allowDownward.value;

View File

@@ -134,7 +134,7 @@ public interface MovementHelper extends ActionCosts, Helper {
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
// has already been accounted for above
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
return block.isPassable(null, null);
return block.isPassable(null, BlockPos.ORIGIN);
}
/**
@@ -254,7 +254,6 @@ public interface MovementHelper extends ActionCosts, Helper {
static boolean avoidWalkingInto(Block block) {
return block instanceof BlockLiquid
|| block instanceof BlockDynamicLiquid
|| block == Blocks.MAGMA
|| block == Blocks.CACTUS
|| block == Blocks.FIRE
@@ -507,7 +506,7 @@ public interface MovementHelper extends ActionCosts, Helper {
return PlaceResult.NO_OPTION;
}
double faceX = (placeAt.getX() + against1.getX() + 1.0D) * 0.5D;
double faceY = (placeAt.getY() + against1.getY() + 1.0D) * 0.5D;
double faceY = (placeAt.getY() + against1.getY() + 0.5D) * 0.5D;
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());

View File

@@ -276,7 +276,7 @@ public enum Moves {
}
},
PARKOUR_NORTH(0, 0, -4, true, false) {
PARKOUR_NORTH(0, 0, -4, true, true) {
@Override
public Movement apply0(CalculationContext context, BetterBlockPos src) {
return MovementParkour.cost(context, src, EnumFacing.NORTH);
@@ -288,7 +288,7 @@ public enum Moves {
}
},
PARKOUR_SOUTH(0, 0, +4, true, false) {
PARKOUR_SOUTH(0, 0, +4, true, true) {
@Override
public Movement apply0(CalculationContext context, BetterBlockPos src) {
return MovementParkour.cost(context, src, EnumFacing.SOUTH);
@@ -300,7 +300,7 @@ public enum Moves {
}
},
PARKOUR_EAST(+4, 0, 0, true, false) {
PARKOUR_EAST(+4, 0, 0, true, true) {
@Override
public Movement apply0(CalculationContext context, BetterBlockPos src) {
return MovementParkour.cost(context, src, EnumFacing.EAST);
@@ -312,7 +312,7 @@ public enum Moves {
}
},
PARKOUR_WEST(-4, 0, 0, true, false) {
PARKOUR_WEST(-4, 0, 0, true, true) {
@Override
public Movement apply0(CalculationContext context, BetterBlockPos src) {
return MovementParkour.cost(context, src, EnumFacing.WEST);

View File

@@ -168,7 +168,7 @@ public class MovementAscend extends Movement {
return state;
}
if (ctx.playerFeet().equals(dest)) {
if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.add(getDirection().down()))) {
return state.setStatus(MovementStatus.SUCCESS);
}

View File

@@ -43,18 +43,20 @@ public class MovementParkour extends Movement {
private final EnumFacing direction;
private final int dist;
private final boolean ascend;
private MovementParkour(IBaritone baritone, BetterBlockPos src, int dist, EnumFacing dir) {
super(baritone, src, src.offset(dir, dist), EMPTY, src.offset(dir, dist).down());
private MovementParkour(IBaritone baritone, BetterBlockPos src, int dist, EnumFacing dir, boolean ascend) {
super(baritone, src, src.offset(dir, dist).up(ascend ? 1 : 0), EMPTY, src.offset(dir, dist).down(ascend ? 0 : 1));
this.direction = dir;
this.dist = dist;
this.ascend = ascend;
}
public static MovementParkour cost(CalculationContext context, BetterBlockPos src, EnumFacing direction) {
MutableMoveResult res = new MutableMoveResult();
cost(context, src.x, src.y, src.z, direction, res);
int dist = Math.abs(res.x - src.x) + Math.abs(res.z - src.z);
return new MovementParkour(context.getBaritone(), src, dist, direction);
return new MovementParkour(context.getBaritone(), src, dist, direction, res.y > src.y);
}
public static void cost(CalculationContext context, int x, int y, int z, EnumFacing dir, MutableMoveResult res) {
@@ -103,19 +105,36 @@ public class MovementParkour extends Movement {
}
}
for (int i = 2; i <= maxJump; i++) {
// TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly?
for (int y2 = 0; y2 < 4; y2++) {
if (!MovementHelper.fullyPassable(context, x + xDiff * i, y + y2, z + zDiff * i)) {
return;
}
int destX = x + xDiff * i;
int destZ = z + zDiff * i;
if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) {
return;
}
IBlockState landingOn = context.bsi.get0(x + xDiff * i, y - 1, z + zDiff * i);
if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) {
return;
}
IBlockState destInto = context.bsi.get0(destX, y, destZ);
if (!MovementHelper.fullyPassable(destInto)) {
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
res.x = destX;
res.y = y + 1;
res.z = destZ;
res.cost = i * SPRINT_ONE_BLOCK_COST + context.jumpPenalty;
}
return;
}
IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
// farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, x + xDiff * i, y - 1, z + zDiff * i, landingOn)) {
res.x = x + xDiff * i;
res.y = y;
res.z = z + zDiff * i;
res.cost = costFromJumpDistance(i) + context.jumpPenalty;
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) {
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
res.x = destX;
res.y = y;
res.z = destZ;
res.cost = costFromJumpDistance(i) + context.jumpPenalty;
}
return;
}
if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) {
return;
}
}
@@ -136,6 +155,9 @@ public class MovementParkour extends Movement {
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi)) {
return;
}
if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
return;
}
for (int i = 0; i < 5; i++) {
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
@@ -153,6 +175,11 @@ public class MovementParkour extends Movement {
}
}
private static boolean checkOvershootSafety(BlockStateInterface bsi, int x, int y, int z) {
// we're going to walk into these two blocks after the landing of the parkour anyway, so make sure they aren't avoidWalkingInto
return !MovementHelper.avoidWalkingInto(bsi.get0(x, y, z).getBlock()) && !MovementHelper.avoidWalkingInto(bsi.get0(x, y + 1, z).getBlock());
}
private static double costFromJumpDistance(int dist) {
switch (dist) {
case 2:
@@ -171,7 +198,7 @@ public class MovementParkour extends Movement {
public double calculateCost(CalculationContext context) {
MutableMoveResult res = new MutableMoveResult();
cost(context, src.x, src.y, src.z, direction, res);
if (res.x != dest.x || res.z != dest.z) {
if (res.x != dest.x || res.y != dest.y || res.z != dest.z) {
return COST_INF;
}
return res.cost;
@@ -202,16 +229,12 @@ public class MovementParkour extends Movement {
if (state.getStatus() != MovementStatus.RUNNING) {
return state;
}
if (ctx.player().isHandActive()) {
logDebug("Pausing parkour since hand is active");
return state;
}
if (ctx.playerFeet().y < src.y) {
// we have fallen
logDebug("sorry");
return state.setStatus(MovementStatus.UNREACHABLE);
}
if (dist >= 4) {
if (dist >= 4 || ascend) {
state.setInput(Input.SPRINT, true);
}
MovementHelper.moveTowards(ctx, state, dest);
@@ -226,12 +249,13 @@ public class MovementParkour extends Movement {
state.setStatus(MovementStatus.SUCCESS);
}
} else if (!ctx.playerFeet().equals(src)) {
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) {
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) {
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
state.setInput(Input.CLICK_RIGHT, true);
}
if (dist == 3) { // this is a 2 block gap, dest = src + direction * 3
// prevent jumping too late by checking for ascend
if (dist == 3 && !ascend) { // this is a 2 block gap, dest = src + direction * 3
double xDiff = (src.x + 0.5) - ctx.player().posX;
double zDiff = (src.z + 0.5) - ctx.player().posZ;
double distFromStart = Math.max(Math.abs(xDiff), Math.abs(zDiff));

View File

@@ -37,6 +37,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import java.util.Optional;
import java.util.Set;
public class MovementTraverse extends Movement {
@@ -202,12 +203,15 @@ public class MovementTraverse extends Movement {
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor)
&& (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)
|| pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src))
&& !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
.setInput(Input.CLICK_RIGHT, true);
if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) {
boolean notPassable = pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src);
boolean canOpen = !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()));
if (notPassable && canOpen) {
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
.setInput(Input.CLICK_RIGHT, true);
}
}
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
@@ -215,8 +219,10 @@ public class MovementTraverse extends Movement {
: !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1]
: null;
if (blocked != null) {
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true))
.setInput(Input.CLICK_RIGHT, true);
Optional<Rotation> rotation = RotationUtils.reachable(ctx, blocked);
if (rotation.isPresent()) {
return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true);
}
}
}

View File

@@ -43,8 +43,7 @@ import java.util.*;
import static baritone.api.pathing.movement.MovementStatus.*;
/**
* Behavior to execute a precomputed path. Does not (yet) deal with path segmentation or stitching
* or cutting (jumping onto the next path if it starts with a backtrack of this path's ending)
* Behavior to execute a precomputed path
*
* @author leijurv
*/

View File

@@ -34,7 +34,9 @@ import baritone.utils.BaritoneProcessHelper;
import baritone.utils.BlockStateInterface;
import baritone.utils.PathingCommandContext;
import baritone.utils.schematic.AirSchematic;
import baritone.utils.schematic.MapArtSchematic;
import baritone.utils.schematic.Schematic;
import baritone.utils.schematic.schematica.SchematicaHelper;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
@@ -106,6 +108,20 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return true;
}
@Override
public void buildOpenSchematic() {
if (SchematicaHelper.isSchematicaPresent()) {
Optional<Tuple<ISchematic, BlockPos>> schematic = SchematicaHelper.getOpenSchematic();
if (schematic.isPresent()) {
this.build(schematic.get().getFirst().toString(), schematic.get().getFirst(), schematic.get().getSecond());
} else {
logDirect("No schematic currently open");
}
} else {
logDirect("Schematica is not present");
}
}
public void clearArea(BlockPos corner1, BlockPos corner2) {
BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ()));
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
@@ -115,7 +131,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
private static ISchematic parse(NBTTagCompound schematic) {
return new Schematic(schematic);
return Baritone.settings().mapArtMode.value ? new MapArtSchematic(schematic) : new Schematic(schematic);
}
@Override
@@ -359,7 +375,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
logDirect("Repeating build in vector " + repeat + ", new origin is " + origin);
return onTick(calcFailed, isSafeToCancel);
}
trim();
if (Baritone.settings().distanceTrim.value) {
trim();
}
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
@@ -419,7 +437,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
}
Goal goal = assemble(bcc, approxPlacable.subList(0, 9));
if (goal == null) {
goal = assemble(bcc, approxPlacable); // we're far away, so assume that we have our whole inventory to recalculate placable properly
@@ -498,6 +515,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
} else {
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
observedCompleted.remove(BetterBlockPos.longHash(blockX, blockY, blockZ));
if (incorrectPositions.size() > Baritone.settings().incorrectSize.value) {
return;
}
}
continue;
}
@@ -506,6 +526,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
// and we've never seen this position be correct
// therefore mark as incorrect
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
if (incorrectPositions.size() > Baritone.settings().incorrectSize.value) {
return;
}
}
}
}
@@ -604,7 +627,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
return new GoalAdjacent(pos, allowSameLevel);
return new GoalAdjacent(pos, pos.offset(facing), allowSameLevel);
}
}
return new GoalPlace(pos);
@@ -627,9 +650,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
public static class GoalAdjacent extends GoalGetToBlock {
private boolean allowSameLevel;
private BlockPos no;
public GoalAdjacent(BlockPos pos, boolean allowSameLevel) {
public GoalAdjacent(BlockPos pos, BlockPos no, boolean allowSameLevel) {
super(pos);
this.no = no;
this.allowSameLevel = allowSameLevel;
}
@@ -637,6 +662,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (x == this.x && y == this.y && z == this.z) {
return false;
}
if (x == no.getX() && y == no.getY() && z == no.getZ()) {
return false;
}
if (!allowSameLevel && y == this.y - 1) {
return false;
}
@@ -696,6 +724,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
private boolean valid(IBlockState current, IBlockState desired) {
// TODO more complicated comparison logic I guess
if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) {
return true;
}
return desired == null || current.equals(desired);
}
@@ -775,7 +806,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
// it should be a real block
// is it already that block?
if (valid(bsi.get0(x, y, z), sch)) {
return 3;
return Baritone.settings().breakCorrectBlockPenaltyMultiplier.value;
} else {
// can break if it's wrong
// would be great to return less than 1 here, but that would actually make the cost calculation messed up

View File

@@ -140,6 +140,9 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl
centers.add(new BlockPos(centerX, 0, centerZ));
}
}
if (dist % 10 == 0) {
count = Math.min(filter.countRemain(), Baritone.settings().exploreChunkSetMinimumSize.value);
}
if (centers.size() >= count) {
return centers.stream().map(pos -> createGoal(pos.getX(), pos.getZ())).toArray(Goal[]::new);
}

View File

@@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalComposite;
import baritone.api.process.IFarmProcess;
import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType;
import baritone.api.utils.RayTraceUtils;
import baritone.api.utils.Rotation;
import baritone.api.utils.RotationUtils;
import baritone.api.utils.input.Input;
@@ -40,7 +41,9 @@ import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@@ -54,6 +57,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
private boolean active;
private List<BlockPos> locations;
private int tickCount;
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
Items.BEETROOT_SEEDS,
Items.MELON_SEEDS,
@@ -65,17 +71,16 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
private static final List<Item> PICKUP_DROPPED = Arrays.asList(
Items.BEETROOT_SEEDS,
Items.WHEAT,
Items.BEETROOT,
Items.MELON_SEEDS,
Items.MELON,
Item.getItemFromBlock(Blocks.MELON_BLOCK),
Items.WHEAT_SEEDS,
Items.WHEAT,
Items.PUMPKIN_SEEDS,
Item.getItemFromBlock(Blocks.PUMPKIN),
Items.POTATO,
Items.CARROT,
Items.BEETROOT,
Item.getItemFromBlock(Blocks.PUMPKIN),
Item.getItemFromBlock(Blocks.MELON_BLOCK),
Items.NETHER_WART,
Items.REEDS,
Item.getItemFromBlock(Blocks.CACTUS)
@@ -93,6 +98,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
@Override
public void farm() {
active = true;
locations = null;
}
private enum Harvest {
@@ -164,9 +170,12 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
if (Baritone.settings().replantNetherWart.value) {
scan.add(Blocks.SOUL_SAND);
}
List<BlockPos> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4);
if (Baritone.settings().mineGoalUpdateInterval.value != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.value == 0) {
Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10));
}
if (locations == null) {
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
}
List<BlockPos> toBreak = new ArrayList<>();
List<BlockPos> openFarmland = new ArrayList<>();
List<BlockPos> bonemealable = new ArrayList<>();
@@ -216,11 +225,14 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
boolean soulsand = openSoulsand.contains(pos);
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
baritone.getLookBehavior().updateTarget(rot.get(), true);
if (ctx.isLookingAt(pos)) {
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) {
baritone.getLookBehavior().updateTarget(rot.get(), true);
if (ctx.isLookingAt(pos)) {
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
}
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
}
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
}
}
for (BlockPos pos : bonemealable) {

View File

@@ -38,7 +38,7 @@ public final class BlockBreakHelper implements Helper {
this.playerContext = playerContext;
}
public void tryBreakBlock(BlockPos pos, EnumFacing side) {
private void tryBreakBlock(BlockPos pos, EnumFacing side) {
if (playerContext.playerController().onPlayerDamageBlock(pos, side)) {
playerContext.player().swingArm(EnumHand.MAIN_HAND);
}

View File

@@ -122,6 +122,7 @@ public final class PathRenderer implements Helper {
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
GlStateManager.enableBlend();
GlStateManager.disableLighting();
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
@@ -176,6 +177,7 @@ public final class PathRenderer implements Helper {
//GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.disableBlend();
}

View File

@@ -126,7 +126,7 @@ public class PathingControlManager implements IPathingControlManager {
}
}
public void postTick() {
private void postTick() {
// if we did this in pretick, it would suck
// we use the time between ticks as calculation time
// therefore, we only cancel and recalculate after the tick for the current path has executed

View File

@@ -21,7 +21,10 @@ import baritone.Baritone;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.IPlayerContext;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
@@ -70,6 +73,9 @@ public class Avoidance {
if (mobCoeff != 1.0D) {
ctx.world().loadedEntityList.stream()
.filter(entity -> entity instanceof EntityMob)
.filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5)
.filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry())
.filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming())
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
}
return res;

View File

@@ -1,110 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.pathing;
import baritone.Baritone;
import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.goals.Goal;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.PathCalculationResult;
import baritone.cache.CachedWorld;
import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.path.SplicedPath;
import net.minecraft.util.EnumFacing;
import java.util.Optional;
import java.util.function.Consumer;
/**
* Calculate and splice many path segments to reach a goal
*
* @author leijurv
*/
public class SegmentedCalculator {
private final BetterBlockPos start;
private final Goal goal;
private final CalculationContext context;
private SegmentedCalculator(BetterBlockPos start, Goal goal, CalculationContext context) {
this.start = start;
this.goal = goal;
this.context = context;
}
private Optional<IPath> doCalc() {
Optional<IPath> soFar = Optional.empty();
while (true) {
PathCalculationResult result = segment(soFar.orElse(null));
switch (result.getType()) {
case SUCCESS_SEGMENT:
case SUCCESS_TO_GOAL:
break;
case FAILURE: // if path calculation failed, we're done
case EXCEPTION: // if path calculation threw an exception, we're done
return soFar;
default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled
throw new IllegalStateException();
}
IPath segment = result.getPath().orElseThrow(IllegalStateException::new); // path calculation result type is SUCCESS_SEGMENT, so the path must be present
IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment);
loadAdjacent(combined.getDest().getX(), combined.getDest().getZ());
soFar = Optional.of(combined);
if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) {
return soFar;
}
}
}
private void loadAdjacent(int blockX, int blockZ) {
BetterBlockPos bp = new BetterBlockPos(blockX, 64, blockZ);
CachedWorld cached = (CachedWorld) context.getBaritone().getPlayerContext().worldData().getCachedWorld();
for (int i = 0; i < 4; i++) {
// pathing thread is not allowed to load new cached regions from disk
// it checks if every chunk is loaded before getting blocks from it
// so you see path segments ending at multiples of 512 (plus or minus one) on either x or z axis
// this loads every adjacent chunk to the segment end, so it can continue into the next cached region
BetterBlockPos toLoad = bp.offset(EnumFacing.byHorizontalIndex(i), 16);
cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9);
}
}
private PathCalculationResult segment(IPath previous) {
BetterBlockPos segmentStart = previous != null ? previous.getDest() : start;
AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous, context), context); // this is on another thread, so cannot include mob avoidances.
return search.calculate(Baritone.settings().primaryTimeoutMS.value, Baritone.settings().failureTimeoutMS.value); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer
}
public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer<IPath> onCompletion, Runnable onFailure) {
Baritone.getExecutor().execute(() -> {
Optional<IPath> result;
try {
result = new SegmentedCalculator(start, goal, context).doCalc();
} catch (Exception ex) {
ex.printStackTrace();
result = Optional.empty();
}
if (result.isPresent()) {
onCompletion.accept(result.get());
} else {
onFailure.run();
}
});
}
}

View File

@@ -17,8 +17,8 @@
package baritone.utils.schematic;
import net.minecraft.block.BlockAir;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import java.util.OptionalInt;
@@ -36,7 +36,7 @@ public class MapArtSchematic extends Schematic {
for (int z = 0; z < lengthZ; z++) {
IBlockState[] column = states[x][z];
OptionalInt lowestBlockY = lastIndexMatching(column, block -> block != Blocks.AIR);
OptionalInt lowestBlockY = lastIndexMatching(column, state -> !(state.getBlock() instanceof BlockAir));
if (lowestBlockY.isPresent()) {
heightMap[x][z] = lowestBlockY.getAsInt();
} else {

View File

@@ -0,0 +1,52 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.schematic.schematica;
import baritone.api.utils.ISchematic;
import com.github.lunatrius.schematica.client.world.SchematicWorld;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
public final class SchematicAdapter implements ISchematic {
private final SchematicWorld schematic;
public SchematicAdapter(SchematicWorld schematicWorld) {
this.schematic = schematicWorld;
}
@Override
public IBlockState desiredState(int x, int y, int z) {
return schematic.getSchematic().getBlockState(new BlockPos(x, y, z));
}
@Override
public int widthX() {
return schematic.getSchematic().getWidth();
}
@Override
public int heightY() {
return schematic.getSchematic().getHeight();
}
@Override
public int lengthZ() {
return schematic.getSchematic().getLength();
}
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.schematic.schematica;
import baritone.api.utils.ISchematic;
import com.github.lunatrius.schematica.Schematica;
import com.github.lunatrius.schematica.proxy.ClientProxy;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import java.util.Optional;
public enum SchematicaHelper {
;
public static boolean isSchematicaPresent() {
try {
Class.forName(Schematica.class.getName());
return true;
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
return false;
}
}
public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() {
return Optional.ofNullable(ClientProxy.schematic)
.map(world -> new Tuple<>(new SchematicAdapter(world), world.position));
}
}

View File

@@ -0,0 +1,41 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.core.util.math;
import net.minecraft.util.math.BlockPos;
public class MBlockPos extends BlockPos {
MBlockPos() {
super(6, 6, 6);
}
@Override
public int getX() {
throw new LinkageError("LOL");
}
@Override
public int getY() {
throw new LinkageError("LOL");
}
@Override
public int getZ() {
throw new LinkageError("LOL");
}
}

View File

@@ -0,0 +1,24 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.schematica;
import com.github.lunatrius.schematica.proxy.CommonProxy;
public class Schematica {
public static CommonProxy proxy;
}

View File

@@ -0,0 +1,31 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.schematica.api;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
public interface ISchematic {
IBlockState getBlockState(BlockPos var1);
int getWidth();
int getHeight();
int getLength();
}

View File

@@ -0,0 +1,29 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.schematica.client.world;
import com.github.lunatrius.core.util.math.MBlockPos;
import com.github.lunatrius.schematica.api.ISchematic;
public class SchematicWorld {
public final MBlockPos position = (MBlockPos)(Object)"cringe";
public ISchematic getSchematic() {
throw new LinkageError("LOL");
}
}

View File

@@ -0,0 +1,24 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.schematica.proxy;
import com.github.lunatrius.schematica.client.world.SchematicWorld;
public class ClientProxy extends CommonProxy {
public static SchematicWorld schematic;
}

View File

@@ -0,0 +1,20 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package com.github.lunatrius.schematica.proxy;
public abstract class CommonProxy {}