From 701bc772a8664cbbabddf8fea9084a7c416107bb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 1 Mar 2019 11:22:21 -0800 Subject: [PATCH 01/27] update impcat badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5aee5702..d59c7ba7 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) [![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.3-brightgreen.svg)](https://impactdevelopment.github.io/) [![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/) [![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/) From 3e47d485f9ba85854b52631895c069a3d7c7dc53 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 1 Mar 2019 12:11:47 -0800 Subject: [PATCH 02/27] emphasize and clarify lol --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index cd19a574..49ab838f 100644 --- a/SETUP.md +++ b/SETUP.md @@ -25,7 +25,7 @@ If another one of your Forge mods has a Baritone integration, you want `baritone - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. ## More Info -To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the next line** (starts with `"url"`). +To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal. You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`. From 81b22019dd2c7d837a262a41cdf565d2863a3395 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 21:43:11 -0800 Subject: [PATCH 03/27] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..3dc44d88 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at complaints@leijurv.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq From c4652285319ae47249105437065a7d9b7a90cfaf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 21:44:20 -0800 Subject: [PATCH 04/27] consistency with the previously existing anime policy --- CODE_OF_CONDUCT.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3dc44d88..8811361f 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,6 +14,7 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: +* No Anime * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism @@ -22,6 +23,7 @@ include: Examples of unacceptable behavior by participants include: +* Anime * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks From 5904441a7ec88fcb0deea3187a39291549e9d091 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 22:40:42 -0800 Subject: [PATCH 05/27] :heart: code of conduct --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d59c7ba7..f5cf2b18 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) +[![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) [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) From 66c7a3f513c86ffc89ed724d2af4e0977daed02b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 3 Mar 2019 21:29:31 -0800 Subject: [PATCH 06/27] this is really bad --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f5cf2b18..68654701 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ [![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.3-brightgreen.svg)](https://impactdevelopment.github.io/) [![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) -[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) -[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) +[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-red.svg)](https://github.com/zeroeightysix/KAMI/) +[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-red.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) From 558c14a3757425d3e294956c900a463e5199b337 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 13:11:36 -0800 Subject: [PATCH 07/27] little cleanup --- src/main/java/baritone/utils/GuiClickMeme.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 1db794ba..1163b1b0 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -28,7 +28,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.Display; import org.lwjgl.util.glu.GLU; import java.awt.*; @@ -45,7 +44,6 @@ public class GuiClickMeme extends GuiScreen { private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16); private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16); - private final FloatBuffer TO_SCREEN_BUFFER = BufferUtils.createFloatBuffer(3); private final FloatBuffer TO_WORLD_BUFFER = BufferUtils.createFloatBuffer(3); private BlockPos meme; From 2133ab39b7f8749efaa93d45a5074ce0812bb7ef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 19:44:36 -0800 Subject: [PATCH 08/27] better cache, needs more testing --- src/main/java/baritone/cache/CachedChunk.java | 35 ++++++++++++++++--- src/main/java/baritone/cache/ChunkPacker.java | 15 +++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index d2737190..05ef8f3e 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -86,6 +86,7 @@ public final class CachedChunk { temp.add(Blocks.WEB); temp.add(Blocks.NETHER_WART); temp.add(Blocks.LADDER); + temp.add(Blocks.VINE); BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp); } @@ -118,6 +119,8 @@ public final class CachedChunk { */ private final BitSet data; + private final BitSet special; + /** * The block names of each surface level block for generating an overview */ @@ -139,12 +142,27 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; + this.special = new BitSet(); calculateHeightMap(); + setSpecial(); + } + + private final void setSpecial() { + for (List list : specialBlockLocations.values()) { + for (BlockPos pos : list) { + System.out.println("Turning on bit"); + special.set(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()) >> 1); + } + } } public final IBlockState getBlock(int x, int y, int z, int dimension) { + int index = getPositionIndex(x, y, z); + PathingBlockType type = getType(index); int internalPos = z << 4 | x; - if (heightMap[internalPos] == y) { + if (heightMap[internalPos] == y && type != PathingBlockType.AVOID) { + // if the top block in a column is water, we cache it as AVOID but we don't want to just return default state water (which is not flowing) beacuse then it would try to path through it + // we have this exact block, it's a surface block /*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state); if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) { @@ -152,15 +170,24 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - PathingBlockType type = getType(x, y, z); + if (special.get(index >> 1)) { + // this block is special + for (Map.Entry> entry : specialBlockLocations.entrySet()) { + for (BlockPos pos : entry.getValue()) { + if (pos.getX() == x && pos.getY() == y && pos.getZ() == z) { + return ChunkPacker.stringToBlock(entry.getKey()).getDefaultState(); + } + } + } + } + if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { return Blocks.BEDROCK.getDefaultState(); } return ChunkPacker.pathingTypeToBlock(type, dimension); } - private PathingBlockType getType(int x, int y, int z) { - int index = getPositionIndex(x, y, z); + private PathingBlockType getType(int index) { return PathingBlockType.fromBits(data.get(index), data.get(index + 1)); } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 892369d5..7f447f87 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -90,7 +90,8 @@ public final class ChunkPacker { IBlockState[] blocks = new IBlockState[256]; for (int z = 0; z < 16; z++) { - https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html + https: +//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html for (int x = 0; x < 16; x++) { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); @@ -124,10 +125,16 @@ public final class ChunkPacker { if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) { // only water source blocks are plausibly usable, flowing water should be avoid // FLOWING_WATER is a waterfall, it doesn't really matter and caching it as AVOID just makes it look wrong - if (!MovementHelper.possiblyFlowing(state)) { - return PathingBlockType.WATER; + if (MovementHelper.possiblyFlowing(state)) { + return PathingBlockType.AVOID; } - if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) != -1000.0F) { + if (x == 0 || x == 15 || z == 0 || z == 15) { + if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) == -1000.0F) { + return PathingBlockType.WATER; + } + return PathingBlockType.AVOID; + } + if (MovementHelper.possiblyFlowing(chunk.getBlockState(x + 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x - 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z + 1)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z - 1))) { return PathingBlockType.AVOID; } return PathingBlockType.WATER; From 826f3788d043a42d74aa2fc84f6d4e0c752bd89f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 20:39:22 -0800 Subject: [PATCH 09/27] performance improvement and no allocation promise --- src/main/java/baritone/cache/CachedChunk.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 05ef8f3e..390ea3f3 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -18,6 +18,7 @@ package baritone.cache; import baritone.utils.pathing.PathingBlockType; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -119,7 +120,7 @@ public final class CachedChunk { */ private final BitSet data; - private final BitSet special; + private final Int2ObjectOpenHashMap special; /** * The block names of each surface level block for generating an overview @@ -142,16 +143,15 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; - this.special = new BitSet(); + this.special = new Int2ObjectOpenHashMap<>(); calculateHeightMap(); setSpecial(); } private final void setSpecial() { - for (List list : specialBlockLocations.values()) { - for (BlockPos pos : list) { - System.out.println("Turning on bit"); - special.set(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()) >> 1); + for (Map.Entry> entry : specialBlockLocations.entrySet()) { + for (BlockPos pos : entry.getValue()) { + special.put(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()), entry.getKey()); } } } @@ -170,15 +170,9 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - if (special.get(index >> 1)) { - // this block is special - for (Map.Entry> entry : specialBlockLocations.entrySet()) { - for (BlockPos pos : entry.getValue()) { - if (pos.getX() == x && pos.getY() == y && pos.getZ() == z) { - return ChunkPacker.stringToBlock(entry.getKey()).getDefaultState(); - } - } - } + String str = special.get(index); + if (str != null) { + return ChunkPacker.stringToBlock(str).getDefaultState(); } if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { From 0d15225b1d089dd09fdb36639e4b8d3a5057a0bf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:00:30 -0800 Subject: [PATCH 10/27] dont construct one unlesss we need to --- src/main/java/baritone/cache/CachedChunk.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 390ea3f3..10c17898 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -143,9 +143,13 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; - this.special = new Int2ObjectOpenHashMap<>(); + if (specialBlockLocations.isEmpty()) { + this.special = null; + } else { + this.special = new Int2ObjectOpenHashMap<>(); + setSpecial(); + } calculateHeightMap(); - setSpecial(); } private final void setSpecial() { @@ -170,9 +174,11 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - String str = special.get(index); - if (str != null) { - return ChunkPacker.stringToBlock(str).getDefaultState(); + if (special != null) { + String str = special.get(index); + if (str != null) { + return ChunkPacker.stringToBlock(str).getDefaultState(); + } } if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { From 71cb0f6d36387d223a55781e15beb9d1d7b7439e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:00:41 -0800 Subject: [PATCH 11/27] fix a weird way of getting stuck on a ladder --- .../pathing/movement/movements/MovementTraverse.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d618cf1a..4a5687fd 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -231,6 +231,13 @@ public class MovementTraverse extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); } + Block low = BlockStateInterface.get(ctx, src).getBlock(); + Block high = BlockStateInterface.get(ctx, src.up()).getBlock(); + if (!ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) { + // hitting W could cause us to climb the ladder instead of going forward + // wait until we're on the ground + return state; + } BlockPos into = dest.subtract(src).add(dest); Block intoBelow = BlockStateInterface.get(ctx, into).getBlock(); Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock(); From a73f5c1359c720d113a7f6ecd576b718deaeea33 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:20:13 -0800 Subject: [PATCH 12/27] crapton of performance improvements --- src/api/java/baritone/api/Settings.java | 5 +++++ src/api/java/baritone/api/cache/ICachedWorld.java | 4 ++-- src/main/java/baritone/cache/CachedChunk.java | 4 ++-- src/main/java/baritone/cache/CachedRegion.java | 13 +++++-------- src/main/java/baritone/cache/CachedWorld.java | 7 +++---- src/main/java/baritone/process/MineProcess.java | 5 +++-- .../java/baritone/utils/ExampleBaritoneControl.java | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 7b47a2a6..6be16dad 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -535,6 +535,11 @@ public final class Settings { */ public final Setting mineGoalUpdateInterval = new Setting<>(5); + /** + * After finding this many instances of the target block in the cache, it will stop expanding outward the chunk search. + */ + public final Setting maxCachedWorldScanCount = new Setting<>(10); + /** * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. */ diff --git a/src/api/java/baritone/api/cache/ICachedWorld.java b/src/api/java/baritone/api/cache/ICachedWorld.java index a435ebe0..e681ce51 100644 --- a/src/api/java/baritone/api/cache/ICachedWorld.java +++ b/src/api/java/baritone/api/cache/ICachedWorld.java @@ -20,7 +20,7 @@ package baritone.api.cache; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; -import java.util.LinkedList; +import java.util.ArrayList; /** * @author Brady @@ -68,7 +68,7 @@ public interface ICachedWorld { * @param maxRegionDistanceSq The maximum region distance, squared * @return The locations found that match the special block */ - LinkedList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq); + ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq); /** * Reloads all of the cached regions in this world from disk. Anything that is not saved diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 10c17898..08c80141 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -215,11 +215,11 @@ public final class CachedChunk { return specialBlockLocations; } - public final LinkedList getAbsoluteBlocks(String blockType) { + public final ArrayList getAbsoluteBlocks(String blockType) { if (specialBlockLocations.get(blockType) == null) { return null; } - LinkedList res = new LinkedList<>(); + ArrayList res = new ArrayList<>(); for (BlockPos pos : specialBlockLocations.get(blockType)) { res.add(new BlockPos(pos.getX() + x * 16, pos.getY(), pos.getZ() + z * 16)); } diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index d8426197..0081d941 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -87,19 +87,16 @@ public final class CachedRegion implements ICachedRegion { return chunks[x >> 4][z >> 4] != null; } - public final LinkedList getLocationsOf(String block) { - LinkedList res = new LinkedList<>(); + public final ArrayList getLocationsOf(String block) { + ArrayList res = new ArrayList<>(); for (int chunkX = 0; chunkX < 32; chunkX++) { for (int chunkZ = 0; chunkZ < 32; chunkZ++) { if (chunks[chunkX][chunkZ] == null) { continue; } - List locs = chunks[chunkX][chunkZ].getAbsoluteBlocks(block); - if (locs == null) { - continue; - } - for (BlockPos pos : locs) { - res.add(pos); + ArrayList locs = chunks[chunkX][chunkZ].getAbsoluteBlocks(block); + if (locs != null) { + res.addAll(locs); } } } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index db85339d..025ec773 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; @@ -109,8 +108,8 @@ public final class CachedWorld implements ICachedWorld, Helper { } @Override - public final LinkedList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { - LinkedList res = new LinkedList<>(); + public final ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { + ArrayList res = new ArrayList<>(); int centerRegionX = centerX >> 9; int centerRegionZ = centerZ >> 9; @@ -127,7 +126,7 @@ public final class CachedWorld implements ICachedWorld, Helper { CachedRegion region = getOrCreateRegion(regionX, regionZ); if (region != null) { // TODO: 100% verify if this or addAll is faster. - region.getLocationsOf(block).forEach(res::add); + res.addAll(region.getLocationsOf(block)); } } } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index a299bf31..699cf998 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -210,7 +210,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro //long b = System.currentTimeMillis(); for (Block m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { - locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); + // maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that + locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.get(), ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); } else { uninteresting.add(m); } @@ -221,7 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 26)); + locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 5)); // maxSearchRadius is NOT sq //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } locs.addAll(alreadyKnown); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 041a5401..61b9ebf1 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -376,7 +376,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } if (msg.startsWith("find")) { String blockType = msg.substring(4).trim(); - LinkedList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); + ArrayList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); logDirect("Have " + locs.size() + " locations"); for (BlockPos pos : locs) { Block actually = BlockStateInterface.get(ctx, pos).getBlock(); From 459720c348055a945cb7a89c86f345a56855d45b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:21:02 -0800 Subject: [PATCH 13/27] eh actually lets do the whole render distance! --- src/main/java/baritone/process/MineProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 699cf998..ac341cb8 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -222,7 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 5)); // maxSearchRadius is NOT sq + locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 32)); // maxSearchRadius is NOT sq //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } locs.addAll(alreadyKnown); From 8050b69f2fd13791b029d840b1c8fe8d11d71dfd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:30:04 -0800 Subject: [PATCH 14/27] no more .get :sunglasses: --- src/api/java/baritone/api/Settings.java | 6 +-- .../baritone/api/pathing/goals/GoalAxis.java | 4 +- .../baritone/api/pathing/goals/GoalXZ.java | 2 +- .../java/baritone/api/utils/SettingsUtil.java | 4 +- .../mixins/MixinChunkRenderContainer.java | 4 +- .../launch/mixins/MixinChunkRenderWorker.java | 2 +- .../launch/mixins/MixinRenderChunk.java | 4 +- .../launch/mixins/MixinRenderList.java | 2 +- .../launch/mixins/MixinVboRenderList.java | 2 +- .../baritone/behavior/InventoryBehavior.java | 4 +- .../java/baritone/behavior/LookBehavior.java | 6 +-- .../baritone/behavior/MemoryBehavior.java | 8 ++-- .../baritone/behavior/PathingBehavior.java | 12 ++--- .../java/baritone/cache/CachedRegion.java | 2 +- src/main/java/baritone/cache/CachedWorld.java | 4 +- .../java/baritone/cache/ContainerMemory.java | 2 +- .../pathing/calc/AStarPathFinder.java | 14 +++--- .../pathing/calc/AbstractNodeCostSearch.java | 2 +- .../pathing/movement/CalculationContext.java | 30 ++++++------- .../pathing/movement/MovementHelper.java | 14 +++--- .../movement/movements/MovementAscend.java | 2 +- .../movement/movements/MovementDiagonal.java | 2 +- .../movement/movements/MovementTraverse.java | 10 ++--- .../baritone/pathing/path/PathExecutor.java | 14 +++--- .../java/baritone/process/FollowProcess.java | 6 +-- .../baritone/process/GetToBlockProcess.java | 10 ++--- .../java/baritone/process/MineProcess.java | 22 +++++----- .../java/baritone/utils/BlockPlaceHelper.java | 2 +- .../baritone/utils/BlockStateInterface.java | 2 +- .../utils/ExampleBaritoneControl.java | 4 +- src/main/java/baritone/utils/Helper.java | 4 +- .../java/baritone/utils/PathRenderer.java | 44 +++++++++---------- .../baritone/utils/PathingControlManager.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- .../baritone/utils/pathing/Avoidance.java | 10 ++--- .../java/baritone/utils/pathing/Favoring.java | 2 +- .../java/baritone/utils/pathing/PathBase.java | 6 +-- .../utils/pathing/SegmentedCalculator.java | 2 +- 38 files changed, 137 insertions(+), 137 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 6be16dad..bdebd117 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -721,9 +721,9 @@ public final class Settings { this.klass = (Class) value.getClass(); } - @SuppressWarnings("unchecked") - public final K get() { - return (K) value; + @Deprecated + public final T get() { + return value; } public final String getName() { diff --git a/src/api/java/baritone/api/pathing/goals/GoalAxis.java b/src/api/java/baritone/api/pathing/goals/GoalAxis.java index d8811cf9..7c9b2670 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalAxis.java +++ b/src/api/java/baritone/api/pathing/goals/GoalAxis.java @@ -25,7 +25,7 @@ public class GoalAxis implements Goal { @Override public boolean isInGoal(int x, int y, int z) { - return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); + return y == BaritoneAPI.getSettings().axisHeight.value && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); } @Override @@ -39,7 +39,7 @@ public class GoalAxis implements Goal { double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2)); - return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y); + return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y); } @Override diff --git a/src/api/java/baritone/api/pathing/goals/GoalXZ.java b/src/api/java/baritone/api/pathing/goals/GoalXZ.java index 636c649f..7f8d16ab 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalXZ.java +++ b/src/api/java/baritone/api/pathing/goals/GoalXZ.java @@ -80,7 +80,7 @@ public class GoalXZ implements Goal { diagonal = z; } diagonal *= SQRT_2; - return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune + return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune } public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) { diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 84e9af68..051e8793 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -99,7 +99,7 @@ public class SettingsUtil { public static List modifiedSettings(Settings settings) { List modified = new ArrayList<>(); for (Settings.Setting setting : settings.allSettings) { - if (setting.get() == null) { + if (setting.value == null) { System.out.println("NULL SETTING?" + setting.getName()); continue; } @@ -122,7 +122,7 @@ public class SettingsUtil { if (io == null) { throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName()); } - return setting.getName() + " " + io.toString.apply(setting.get()); + return setting.getName() + " " + io.toString.apply(setting.value); } public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException { diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 0fc81487..78bd1607 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -41,10 +41,10 @@ public class MixinChunkRenderContainer { ) ) private BlockPos getPosition(RenderChunk renderChunkIn) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); - GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.get()); + GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value); GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); } return renderChunkIn.getPosition(); diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java index 2bd1521c..81e39382 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java @@ -43,7 +43,7 @@ public abstract class MixinChunkRenderWorker { ) ) private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java index 754f523f..22ab0bdd 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java @@ -47,7 +47,7 @@ public class MixinRenderChunk { if (!chunkCache.isEmpty()) { return false; } - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { @@ -76,7 +76,7 @@ public class MixinRenderChunk { ) ) private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderList.java b/src/launch/java/baritone/launch/mixins/MixinRenderList.java index e2f0ae90..98ae5bf5 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderList.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderList.java @@ -38,7 +38,7 @@ public class MixinRenderList { ) ) private void popMatrix() { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { // reset the blend func to normal (not dependent on constant alpha) GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); } diff --git a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java index f51d2234..bab98b3c 100644 --- a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java +++ b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java @@ -38,7 +38,7 @@ public class MixinVboRenderList { ) ) private void popMatrix() { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { // reset the blend func to normal (not dependent on constant alpha) GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); } diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 8a1ea943..cb5eb612 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -35,7 +35,7 @@ public class InventoryBehavior extends Behavior { @Override public void onTick(TickEvent event) { - if (!Baritone.settings().allowInventory.get()) { + if (!Baritone.settings().allowInventory.value) { return; } if (event.getType() == TickEvent.Type.OUT) { @@ -61,7 +61,7 @@ public class InventoryBehavior extends Behavior { private int firstValidThrowaway() { // TODO offhand idk NonNullList invy = ctx.player().inventory.mainInventory; for (int i = 0; i < invy.size(); i++) { - if (Baritone.settings().acceptableThrowawayItems.get().contains(invy.get(i).getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(invy.get(i).getItem())) { return i; } } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index df0921cf..323d81fc 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -53,7 +53,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { @Override public void updateTarget(Rotation target, boolean force) { this.target = target; - this.force = force || !Baritone.settings().freeLook.get(); + this.force = force || !Baritone.settings().freeLook.value; } @Override @@ -63,7 +63,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { } // Whether or not we're going to silently set our angles - boolean silent = Baritone.settings().antiCheatCompatibility.get() && !this.force; + boolean silent = Baritone.settings().antiCheatCompatibility.value && !this.force; switch (event.getState()) { case PRE: { @@ -109,7 +109,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() // Also the type has to be MOTION_UPDATE because that is called after JUMP - if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE && !this.force) { + if (!Baritone.settings().antiCheatCompatibility.value && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE && !this.force) { this.target = null; } } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 390ac859..8d3a0a8c 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -65,7 +65,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onTick(TickEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } if (event.getType() == TickEvent.Type.OUT) { @@ -83,7 +83,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onSendPacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } Packet p = event.getPacket(); @@ -122,7 +122,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onReceivePacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } Packet p = event.getPacket(); @@ -171,7 +171,7 @@ public final class MemoryBehavior extends Behavior { private void updateInventory() { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } int windowId = ctx.player().openContainer.windowId; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index e9e4d480..a7c5c34b 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -201,7 +201,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // and this path doesn't get us all the way there return; } - if (ticksRemainingInSegment(false).get() < Baritone.settings().planningTickLookahead.get()) { + if (ticksRemainingInSegment(false).get() < Baritone.settings().planningTickLookahead.value) { // and this path has 7.5 seconds or less left // don't include the current movement so a very long last movement (e.g. descend) doesn't trip it up // if we actually included current, it wouldn't start planning ahead until the last movement was done, if the last movement took more than 7.5 seconds on its own @@ -426,11 +426,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, long primaryTimeout; long failureTimeout; if (current == null) { - primaryTimeout = Baritone.settings().primaryTimeoutMS.get(); - failureTimeout = Baritone.settings().failureTimeoutMS.get(); + primaryTimeout = Baritone.settings().primaryTimeoutMS.value; + failureTimeout = Baritone.settings().failureTimeoutMS.value; } else { - primaryTimeout = Baritone.settings().planAheadPrimaryTimeoutMS.get(); - failureTimeout = Baritone.settings().planAheadFailureTimeoutMS.get(); + primaryTimeout = Baritone.settings().planAheadPrimaryTimeoutMS.value; + failureTimeout = Baritone.settings().planAheadFailureTimeoutMS.value; } CalculationContext context = new CalculationContext(baritone, true); // not safe to create on the other thread, it looks up a lot of stuff in minecraft AbstractNodeCostSearch pathfinder = createPathfinder(start, goal, current == null ? null : current.getPath(), context); @@ -494,7 +494,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, public static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) { Goal transformed = goal; - if (Baritone.settings().simplifyUnloadedYCoord.get() && goal instanceof IGoalRenderPos) { + if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) { BlockPos pos = ((IGoalRenderPos) goal).getGoalPos(); if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) { transformed = new GoalXZ(pos.getX(), pos.getZ()); diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 0081d941..e3a85dfc 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -303,7 +303,7 @@ public final class CachedRegion implements ICachedRegion { } public synchronized final void removeExpired() { - long expiry = Baritone.settings().cachedChunksExpirySeconds.get(); + long expiry = Baritone.settings().cachedChunksExpirySeconds.value; if (expiry < 0) { return; } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 025ec773..e8ea5cae 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -145,7 +145,7 @@ public final class CachedWorld implements ICachedWorld, Helper { @Override public final void save() { - if (!Baritone.settings().chunkCaching.get()) { + if (!Baritone.settings().chunkCaching.value) { System.out.println("Not saving to disk; chunk caching is disabled."); allRegions().forEach(region -> { if (region != null) { @@ -170,7 +170,7 @@ public final class CachedWorld implements ICachedWorld, Helper { * Delete regions that are too far from the player */ private synchronized void prune() { - if (!Baritone.settings().pruneRegionsFromRAM.get()) { + if (!Baritone.settings().pruneRegionsFromRAM.value) { return; } BlockPos pruneCenter = guessPosition(); diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java index 466bf710..c1cb7b34 100644 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ b/src/main/java/baritone/cache/ContainerMemory.java @@ -70,7 +70,7 @@ public class ContainerMemory implements IContainerMemory { } public synchronized void save() throws IOException { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE); diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index fda41cfd..57e9200d 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -62,20 +62,20 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { MutableMoveResult res = new MutableMoveResult(); BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world.getWorldBorder()); long startTime = System.currentTimeMillis(); - boolean slowPath = Baritone.settings().slowPath.get(); + boolean slowPath = Baritone.settings().slowPath.value; if (slowPath) { - logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.get() + "ms instead of " + primaryTimeout + "ms"); + logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.value + "ms instead of " + primaryTimeout + "ms"); } - long primaryTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.get() : primaryTimeout); - long failureTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.get() : failureTimeout); + long primaryTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.value : primaryTimeout); + long failureTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.value : failureTimeout); boolean failing = true; int numNodes = 0; int numMovementsConsidered = 0; int numEmptyChunk = 0; boolean isFavoring = !favoring.isEmpty(); int timeCheckInterval = 1 << 6; - int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get(); // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior - double minimumImprovement = Baritone.settings().minimumImprovementRepropagation.get() ? MIN_IMPROVEMENT : 0; + 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; 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) @@ -85,7 +85,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { } if (slowPath) { try { - Thread.sleep(Baritone.settings().slowPathTimeDelayMS.get()); + Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value); } catch (InterruptedException ex) { } } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index a9974e8d..a7d104cf 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -87,7 +87,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper { this.startZ = startZ; this.goal = goal; this.context = context; - this.map = new Long2ObjectOpenHashMap<>(Baritone.settings().pathingMapDefaultSize.value, Baritone.settings().pathingMapLoadFactor.get()); + this.map = new Long2ObjectOpenHashMap<>(Baritone.settings().pathingMapDefaultSize.value, Baritone.settings().pathingMapLoadFactor.value); } public void cancel() { diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 4c3b299d..6c4c326b 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -76,27 +76,27 @@ public class CalculationContext { this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld(); this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread); // TODO TODO TODO this.toolSet = new ToolSet(player); - this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(baritone.getPlayerContext(), false); - this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether(); - this.canSprint = Baritone.settings().allowSprint.get() && player.getFoodStats().getFoodLevel() > 6; - this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get(); - this.allowBreak = Baritone.settings().allowBreak.get(); - this.allowParkour = Baritone.settings().allowParkour.get(); - this.allowParkourPlace = Baritone.settings().allowParkourPlace.get(); - this.allowJumpAt256 = Baritone.settings().allowJumpAt256.get(); - this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.get(); - this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.get(); - this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get(); - this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get(); + this.hasThrowaway = Baritone.settings().allowPlace.value && MovementHelper.throwaway(baritone.getPlayerContext(), false); + this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether(); + this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6; + this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; + this.allowBreak = Baritone.settings().allowBreak.value; + this.allowParkour = Baritone.settings().allowParkour.value; + this.allowParkourPlace = Baritone.settings().allowParkourPlace.value; + this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value; + this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value; + this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value; + this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.value; + this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.value; int depth = EnchantmentHelper.getDepthStriderModifier(player); if (depth > 3) { depth = 3; } float mult = depth / 3.0F; this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; - this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); - this.jumpPenalty = Baritone.settings().jumpPenalty.get(); - this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.get(); + this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.value; + this.jumpPenalty = Baritone.settings().jumpPenalty.value; + this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.value; // why cache these things here, why not let the movements just get directly from settings? // because if some movements are calculated one way and others are calculated another way, // then you get a wildly inconsistent path that isn't optimal for either scenario. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 592aecd0..7d2552b5 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -113,7 +113,7 @@ public interface MovementHelper extends ActionCosts, Helper { return false; // Don't walk through flowing liquids } if (block instanceof BlockLiquid) { - if (Baritone.settings().assumeWalkOnWater.get()) { + if (Baritone.settings().assumeWalkOnWater.value) { return false; } IBlockState up = bsi.get0(x, y + 1, z); @@ -275,7 +275,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (state.isBlockNormalCube()) { return true; } - if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.get())) { // TODO reconsider this + if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this return true; } if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) { @@ -293,17 +293,17 @@ public interface MovementHelper extends ActionCosts, Helper { } if (isFlowing(x, y, z, state, bsi) || block == Blocks.FLOWING_WATER) { // the only scenario in which we can walk on flowing water is if it's under still water with jesus off - return isWater(up) && !Baritone.settings().assumeWalkOnWater.get(); + return isWater(up) && !Baritone.settings().assumeWalkOnWater.value; } // if assumeWalkOnWater is on, we can only walk on water if there isn't water above it // if assumeWalkOnWater is off, we can only walk on water if there is water above it - return isWater(up) ^ Baritone.settings().assumeWalkOnWater.get(); + return isWater(up) ^ Baritone.settings().assumeWalkOnWater.value; } if (block == Blocks.GLASS || block == Blocks.STAINED_GLASS) { return true; } if (block instanceof BlockSlab) { - if (!Baritone.settings().allowWalkOnBottomSlab.get()) { + if (!Baritone.settings().allowWalkOnBottomSlab.value) { if (((BlockSlab) block).isDouble()) { return true; } @@ -415,14 +415,14 @@ public interface MovementHelper extends ActionCosts, Helper { // and then it's called during execution // since this function is never called during cost calculation, we don't need to migrate // acceptableThrowawayItems to the CalculationContext - if (Baritone.settings().acceptableThrowawayItems.get().contains(item.getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(item.getItem())) { if (select) { p.inventory.currentItem = i; } return true; } } - if (Baritone.settings().acceptableThrowawayItems.get().contains(p.inventory.offHandInventory.get(0).getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(p.inventory.offHandInventory.get(0).getItem())) { // main hand takes precedence over off hand // that means that if we have block A selected in main hand and block B in off hand, right clicking places block B // we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 5bb6281f..3dc65990 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -176,7 +176,7 @@ public class MovementAscend extends Movement { return state; // don't jump while walking from a non double slab into a bottom slab } - if (Baritone.settings().assumeStep.get() || ctx.playerFeet().equals(src.up())) { + if (Baritone.settings().assumeStep.value || ctx.playerFeet().equals(src.up())) { // no need to hit space if we're already jumping return state; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f156ff1b..9761f617 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -182,7 +182,7 @@ public class MovementDiagonal extends Movement { } public boolean sprint() { - if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.get()) { + if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) { return false; } for (int i = 0; i < 4; i++) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 4a5687fd..21783605 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -152,7 +152,7 @@ public class MovementTraverse extends Movement { super.updateState(state); if (state.getStatus() != MovementStatus.RUNNING) { // if the setting is enabled - if (!Baritone.settings().walkWhileBreaking.get()) { + if (!Baritone.settings().walkWhileBreaking.value) { return state; } // and if we're prepping (aka mining the block in front) @@ -241,7 +241,7 @@ public class MovementTraverse extends Movement { BlockPos into = dest.subtract(src).add(dest); Block intoBelow = BlockStateInterface.get(ctx, into).getBlock(); Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock(); - if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.get()) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { + if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { state.setInput(Input.SPRINT, true); } Block destDown = BlockStateInterface.get(ctx, dest.down()).getBlock(); @@ -264,12 +264,12 @@ public class MovementTraverse extends Movement { } double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D))); PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false); - if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.get()) { + if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.SNEAK, true); } switch (p) { case READY_TO_PLACE: { - if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.get()) { + if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.CLICK_RIGHT, true); } return state; @@ -343,4 +343,4 @@ public class MovementTraverse extends Movement { } return super.prepared(state); } -} \ No newline at end of file +} diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index b025f689..2c2f7ad9 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -229,7 +229,7 @@ public class PathExecutor implements IPathExecutor, Helper { costEstimateIndex = pathPosition; // do this only once, when the movement starts, and deliberately get the cost as cached when this path was calculated, not the cost as it is right now currentMovementOriginalCostEstimate = movement.getCost(); - for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { + for (int i = 1; i < Baritone.settings().costVerificationLookahead.value && pathPosition + i < path.length() - 1; i++) { if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF && canCancel) { logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); cancel(); @@ -243,7 +243,7 @@ public class PathExecutor implements IPathExecutor, Helper { cancel(); return true; } - if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.get() && canCancel) { + if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.value && canCancel) { // don't do this if the movement was calculated while loaded // that means that this isn't a cache error, it's just part of the path interfering with a later part logDebug("Original cost " + currentMovementOriginalCostEstimate + " current cost " + currentCost + ". Cancelling."); @@ -273,7 +273,7 @@ public class PathExecutor implements IPathExecutor, Helper { ctx.player().setSprinting(false); // letting go of control doesn't make you stop sprinting actually } ticksOnCurrent++; - if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { + if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.value) { // only cancel if the total time has exceeded the initial estimate // as you break the blocks required, the remaining cost goes down, to the point where // ticksOnCurrent is greater than recalculateCost + 100 @@ -527,7 +527,7 @@ public class PathExecutor implements IPathExecutor, Helper { } private static boolean sprintableAscend(IPlayerContext ctx, MovementTraverse current, MovementAscend next, IMovement nextnext) { - if (!Baritone.settings().sprintAscends.get()) { + if (!Baritone.settings().sprintAscends.value) { return false; } if (!current.getDirection().equals(next.getDirection().down())) { @@ -569,7 +569,7 @@ public class PathExecutor implements IPathExecutor, Helper { if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(ctx, next.getDest().down())) { return true; } - return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get(); + return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.value; } private void onChangeInPathPosition() { @@ -612,8 +612,8 @@ public class PathExecutor implements IPathExecutor, Helper { } private PathExecutor cutIfTooLong() { - if (pathPosition > Baritone.settings().maxPathHistoryLength.get()) { - int cutoffAmt = Baritone.settings().pathHistoryCutoffAmount.get(); + if (pathPosition > Baritone.settings().maxPathHistoryLength.value) { + int cutoffAmt = Baritone.settings().pathHistoryCutoffAmount.value; CutoffPath newPath = new CutoffPath(path, cutoffAmt, path.length() - 1); if (!newPath.getDest().equals(path.getDest())) { throw new IllegalStateException(); diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 3d25c076..6e377dec 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -58,13 +58,13 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo private Goal towards(Entity following) { BlockPos pos; - if (Baritone.settings().followOffsetDistance.get() == 0) { + if (Baritone.settings().followOffsetDistance.value == 0) { pos = new BlockPos(following); } else { - GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); + GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value); pos = new BlockPos(g.getX(), following.posY, g.getZ()); } - return new GoalNear(pos, Baritone.settings().followRadius.get()); + return new GoalNear(pos, Baritone.settings().followRadius.value); } diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index cb80926b..7f63c6e2 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -67,7 +67,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl rescan(new ArrayList<>(), new CalculationContext(baritone)); } if (knownLocations.isEmpty()) { - if (Baritone.settings().exploreForBlocks.get() && !calcFailed) { + if (Baritone.settings().exploreForBlocks.value && !calcFailed) { return new PathingCommand(new GoalRunAway(1, start) { @Override public boolean isInGoal(int x, int y, int z) { @@ -83,7 +83,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new)); if (calcFailed) { - if (Baritone.settings().blacklistOnGetToBlockFailure.get()) { + if (Baritone.settings().blacklistOnGetToBlockFailure.value) { logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances"); blacklistClosest(); return onTick(false, isSafeToCancel); // gamer moment @@ -95,7 +95,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl return new PathingCommand(goal, PathingCommandType.CANCEL_AND_SET_GOAL); } } - int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain List current = new ArrayList<>(knownLocations); CalculationContext context = new CalculationContext(baritone, true); @@ -200,14 +200,14 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } private boolean walkIntoInsteadOfAdjacent(Block block) { - if (!Baritone.settings().enterPortal.get()) { + if (!Baritone.settings().enterPortal.value) { return false; } return block == Blocks.PORTAL; } private boolean rightClickOnArrival(Block block) { - if (!Baritone.settings().rightClickContainerOnArrival.get()) { + if (!Baritone.settings().rightClickContainerOnArrival.value) { return false; } return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index ac341cb8..121ddb8f 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -85,13 +85,13 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro cancel(); return null; } - int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain List curr = new ArrayList<>(knownOreLocations); CalculationContext context = new CalculationContext(baritone, true); Baritone.getExecutor().execute(() -> rescan(curr, context)); } - if (Baritone.settings().legitMine.get()) { + if (Baritone.settings().legitMine.value) { addNearby(); } PathingCommand command = updateGoal(); @@ -115,7 +115,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } private PathingCommand updateGoal() { - boolean legit = Baritone.settings().legitMine.get(); + boolean legit = Baritone.settings().legitMine.value; List locs = knownOreLocations; if (!locs.isEmpty()) { List locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT); @@ -129,7 +129,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } // only in non-Xray mode (aka legit mode) do we do this - int y = Baritone.settings().legitMineYLevel.get(); + int y = Baritone.settings().legitMineYLevel.value; if (branchPoint == null) { /*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) { // cool, path is over and we are at desired y @@ -157,7 +157,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (mining == null) { return; } - if (Baritone.settings().legitMine.get()) { + if (Baritone.settings().legitMine.value) { return; } List locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already); @@ -171,18 +171,18 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } private static Goal coalesce(IPlayerContext ctx, BlockPos loc, List locs) { - if (!Baritone.settings().forceInternalMining.get()) { + if (!Baritone.settings().forceInternalMining.value) { return new GoalTwoBlocks(loc); } // Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of) - boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR); - boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR); + boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR); + boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR); return upwardGoal == downwardGoal ? new GoalTwoBlocks(loc) : upwardGoal ? new GoalBlock(loc) : new GoalBlock(loc.down()); } public static List droppedItemsScan(List mining, World world) { - if (!Baritone.settings().mineScanDroppedItems.get()) { + if (!Baritone.settings().mineScanDroppedItems.value) { return new ArrayList<>(); } Set searchingFor = new HashSet<>(); @@ -211,7 +211,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro for (Block m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { // maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that - locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.get(), ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); + locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); } else { uninteresting.add(m); } @@ -242,7 +242,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro // is an x-ray and it'll get caught if (mining.contains(bsi.get0(x, y, z).getBlock())) { BlockPos pos = new BlockPos(x, y, z); - if ((Baritone.settings().legitMineIncludeDiagonals.get() && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) { + if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) { knownOreLocations.add(pos); } } diff --git a/src/main/java/baritone/utils/BlockPlaceHelper.java b/src/main/java/baritone/utils/BlockPlaceHelper.java index e93bf807..8e7ef44a 100644 --- a/src/main/java/baritone/utils/BlockPlaceHelper.java +++ b/src/main/java/baritone/utils/BlockPlaceHelper.java @@ -40,7 +40,7 @@ public class BlockPlaceHelper implements Helper { if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) { return; } - rightClickTimer = Baritone.settings().rightClickSpeed.get(); + rightClickTimer = Baritone.settings().rightClickSpeed.value; for (EnumHand hand : EnumHand.values()) { if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) { ctx.player().swingArm(hand); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 5f8cac6a..84bdce5f 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -66,7 +66,7 @@ public class BlockStateInterface { } else { this.loadedChunks = worldLoaded; // this will only be used on the main thread } - this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.get(); + this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value; if (!Minecraft.getMinecraft().isCallingFromMinecraftThread()) { throw new IllegalStateException(); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 61b9ebf1..7988d796 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -89,14 +89,14 @@ public class ExampleBaritoneControl extends Behavior implements Helper { @Override public void onSendChatMessage(ChatEvent event) { String msg = event.getMessage(); - if (Baritone.settings().prefixControl.get() && msg.startsWith(COMMAND_PREFIX)) { + if (Baritone.settings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) { if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { logDirect("Invalid command"); } event.cancel(); // always cancel if using prefixControl return; } - if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) { + if (!Baritone.settings().chatControl.value && !Baritone.settings().removePrefix.value) { return; } if (runCommand(msg)) { diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index f85f240c..7bcc605c 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -50,7 +50,7 @@ public interface Helper { * @param message The message to display in chat */ default void logDebug(String message) { - if (!Baritone.settings().chatDebug.get()) { + if (!Baritone.settings().chatDebug.value) { //System.out.println("Suppressed debug message:"); //System.out.println(message); return; @@ -67,6 +67,6 @@ public interface Helper { ITextComponent component = MESSAGE_PREFIX.createCopy(); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(new TextComponentString(" " + message)); - Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.get().accept(component)); + Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.value.accept(component)); } } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index c0af870e..e3da0e3e 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -81,9 +81,9 @@ public final class PathRenderer implements Helper { } if (goal != null && Baritone.settings().renderGoal.value) { - drawDankLitGoalBox(renderView, goal, partialTicks, Baritone.settings().colorGoalBox.get()); + drawDankLitGoalBox(renderView, goal, partialTicks, Baritone.settings().colorGoalBox.value); } - if (!Baritone.settings().renderPath.get()) { + if (!Baritone.settings().renderPath.value) { return; } @@ -97,28 +97,28 @@ public final class PathRenderer implements Helper { // Render the current path, if there is one if (current != null && current.getPath() != null) { int renderBegin = Math.max(current.getPosition() - 3, 0); - drawPath(current.getPath(), renderBegin, renderView, partialTicks, Baritone.settings().colorCurrentPath.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(current.getPath(), renderBegin, renderView, partialTicks, Baritone.settings().colorCurrentPath.value, Baritone.settings().fadePath.value, 10, 20); } if (next != null && next.getPath() != null) { - drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20); } //long split = System.nanoTime(); if (current != null) { - drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.get()); - drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.get()); - drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.get()); + drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.value); + drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.value); + drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.value); } // If there is a path calculation currently running, render the path calculation process behavior.getInProgress().ifPresent(currentlyRunning -> { currentlyRunning.bestPathSoFar().ifPresent(p -> { - drawPath(p, 0, renderView, partialTicks, Baritone.settings().colorBestPathSoFar.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(p, 0, renderView, partialTicks, Baritone.settings().colorBestPathSoFar.value, Baritone.settings().fadePath.value, 10, 20); }); currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> { - drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.get(), Baritone.settings().fadePath.get(), 10, 20); - drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.get()); + drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.value, Baritone.settings().fadePath.value, 10, 20); + drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value); }); }); //long end = System.nanoTime(); @@ -132,10 +132,10 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); 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.get()); + GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderPathIgnoreDepth.get()) { + if (Baritone.settings().renderPathIgnoreDepth.value) { GlStateManager.disableDepth(); } List positions = path.positions(); @@ -178,7 +178,7 @@ public final class PathRenderer implements Helper { drawLine(player, x1, y1, z1, x2, y2, z2); tessellator.draw(); } - if (Baritone.settings().renderPathIgnoreDepth.get()) { + if (Baritone.settings().renderPathIgnoreDepth.value) { GlStateManager.enableDepth(); } //GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f); @@ -203,11 +203,11 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); - GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); + GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderSelectionBoxesIgnoreDepth.get()) { + if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -249,7 +249,7 @@ public final class PathRenderer implements Helper { TESSELLATOR.draw(); }); - if (Baritone.settings().renderSelectionBoxesIgnoreDepth.get()) { + if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) { GlStateManager.enableDepth(); } @@ -292,12 +292,12 @@ public final class PathRenderer implements Helper { } else if (goal instanceof GoalXZ) { GoalXZ goalPos = (GoalXZ) goal; - if (Baritone.settings().renderGoalXZBeacon.get()) { + if (Baritone.settings().renderGoalXZBeacon.value) { glPushAttrib(GL_LIGHTING_BIT); mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -313,7 +313,7 @@ public final class PathRenderer implements Helper { color.getColorComponents(null) ); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.enableDepth(); } @@ -342,10 +342,10 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F); - GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.get()); + GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -363,7 +363,7 @@ public final class PathRenderer implements Helper { BUFFER.pos(minX, maxY, maxZ).endVertex(); TESSELLATOR.draw(); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.enableDepth(); } GlStateManager.depthMask(true); diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 54ed848a..8d1616c4 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -136,7 +136,7 @@ public class PathingControlManager implements IPathingControlManager { p.secretInternalSetGoalAndPath(command.goal); break; case REVALIDATE_GOAL_AND_PATH: - if (Baritone.settings().cancelOnGoalInvalidation.get() && (command.goal == null || revalidateGoal(command.goal))) { + if (Baritone.settings().cancelOnGoalInvalidation.value && (command.goal == null || revalidateGoal(command.goal))) { p.softCancelIfSafe(); } p.secretInternalSetGoalAndPath(command.goal); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index bfa4e251..31f23f20 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -55,7 +55,7 @@ public class ToolSet { breakStrengthCache = new HashMap<>(); this.player = player; - if (Baritone.settings().considerPotionEffects.get()) { + if (Baritone.settings().considerPotionEffects.value) { double amplifier = potionAmplifier(); Function amplify = x -> amplifier * x; backendCalculation = amplify.compose(this::getBestDestructionTime); diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index 1f61dc57..9b32b1df 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -57,17 +57,17 @@ public class Avoidance { } public static List create(IPlayerContext ctx) { - if (!Baritone.settings().avoidance.get()) { + if (!Baritone.settings().avoidance.value) { return Collections.emptyList(); } List res = new ArrayList<>(); - double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.get(); - double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.get(); + double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value; + double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value; if (mobSpawnerCoeff != 1.0D) { - ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.get()))); + ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value))); } if (mobCoeff != 1.0D) { - ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.get()))); + ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; } diff --git a/src/main/java/baritone/utils/pathing/Favoring.java b/src/main/java/baritone/utils/pathing/Favoring.java index 7ffe49ff..45bb8a09 100644 --- a/src/main/java/baritone/utils/pathing/Favoring.java +++ b/src/main/java/baritone/utils/pathing/Favoring.java @@ -37,7 +37,7 @@ public final class Favoring { public Favoring(IPath previous) { // create one just from previous path, no mob avoidances favorings = new Long2DoubleOpenHashMap(); favorings.defaultReturnValue(1.0D); - double coeff = Baritone.settings().backtrackCostFavoringCoefficient.get(); + double coeff = Baritone.settings().backtrackCostFavoringCoefficient.value; if (coeff != 1D && previous != null) { previous.positions().forEach(pos -> favorings.put(BetterBlockPos.longHash(pos), coeff)); } diff --git a/src/main/java/baritone/utils/pathing/PathBase.java b/src/main/java/baritone/utils/pathing/PathBase.java index 3acf80b4..8bac2dc7 100644 --- a/src/main/java/baritone/utils/pathing/PathBase.java +++ b/src/main/java/baritone/utils/pathing/PathBase.java @@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos; public abstract class PathBase implements IPath { @Override public PathBase cutoffAtLoadedChunks(Object bsi0) { // <-- cursed cursed cursed - if (!Baritone.settings().cutoffAtLoadBoundary.get()) { + if (!Baritone.settings().cutoffAtLoadBoundary.value) { return this; } BlockStateInterface bsi = (BlockStateInterface) bsi0; @@ -43,14 +43,14 @@ public abstract class PathBase implements IPath { @Override public PathBase staticCutoff(Goal destination) { - int min = BaritoneAPI.getSettings().pathCutoffMinimumLength.get(); + int min = BaritoneAPI.getSettings().pathCutoffMinimumLength.value; if (length() < min) { return this; } if (destination == null || destination.isInGoal(getDest())) { return this; } - double factor = BaritoneAPI.getSettings().pathCutoffFactor.get(); + double factor = BaritoneAPI.getSettings().pathCutoffFactor.value; int newLength = (int) ((length() - min) * factor) + min - 1; return new CutoffPath(this, newLength); } diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java index e1d6dd10..489d560d 100644 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java @@ -88,7 +88,7 @@ public class SegmentedCalculator { private PathCalculationResult segment(Optional previous) { BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null)), context); // this is on another thread, so cannot include mob avoidances. - return search.calculate(Baritone.settings().primaryTimeoutMS.get(), Baritone.settings().failureTimeoutMS.get()); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer + 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 onCompletion, Runnable onFailure) { From b3c580e657218a18d2fdeb920ab7608a39256e92 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:49:21 -0800 Subject: [PATCH 15/27] teensy javadoc --- src/api/java/baritone/api/Settings.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bdebd117..0e31d942 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -721,6 +721,11 @@ public final class Settings { this.klass = (Class) value.getClass(); } + /** + * Deprecated! Please use .value directly instead + * + * @return the current setting value + */ @Deprecated public final T get() { return value; @@ -739,6 +744,9 @@ public final class Settings { return SettingsUtil.settingToString(this); } + /** + * Reset this setting to its default value + */ public void reset() { value = defaultValue; } From 74d7483b3c228ab464c16ff4b4005df2a568ffee Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Mar 2019 12:26:52 -0800 Subject: [PATCH 16/27] explore --- src/api/java/baritone/api/Settings.java | 7 ++ src/main/java/baritone/Baritone.java | 11 +- src/main/java/baritone/cache/CachedWorld.java | 4 + .../java/baritone/process/ExploreProcess.java | 100 ++++++++++++++++++ .../utils/ExampleBaritoneControl.java | 15 +++ 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 src/main/java/baritone/process/ExploreProcess.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0e31d942..b9a45960 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -625,6 +625,13 @@ public final class Settings { */ public final Setting followRadius = new Setting<>(3); + /** + * true = exploration uses pythagorean distance to choose closest uncached chunk + *

+ * false = exploration uses manhattan / taxicab distance to choose + */ + public final Setting exploreUsePythagorean = new Setting<>(false); + /** * Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds * -1 to disable diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 51a6ff69..ea8d40f2 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -25,10 +25,7 @@ import baritone.api.utils.IPlayerContext; import baritone.behavior.*; import baritone.cache.WorldProvider; import baritone.event.GameEventHandler; -import baritone.process.CustomGoalProcess; -import baritone.process.FollowProcess; -import baritone.process.GetToBlockProcess; -import baritone.process.MineProcess; +import baritone.process.*; import baritone.utils.*; import baritone.utils.player.PrimaryPlayerContext; import net.minecraft.client.Minecraft; @@ -80,6 +77,7 @@ public class Baritone implements IBaritone { private MineProcess mineProcess; private GetToBlockProcess getToBlockProcess; private CustomGoalProcess customGoalProcess; + private ExploreProcess exploreProcess; private PathingControlManager pathingControlManager; @@ -118,6 +116,7 @@ public class Baritone implements IBaritone { mineProcess = new MineProcess(this); customGoalProcess = new CustomGoalProcess(this); // very high iq getToBlockProcess = new GetToBlockProcess(this); + exploreProcess = new ExploreProcess(this); } this.worldProvider = new WorldProvider(); @@ -177,6 +176,10 @@ public class Baritone implements IBaritone { return this.lookBehavior; } + public ExploreProcess getExploreProcess() { + return this.exploreProcess; + } + @Override public MineProcess getMineProcess() { return this.mineProcess; diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index e8ea5cae..7e34fa08 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -107,6 +107,10 @@ public final class CachedWorld implements ICachedWorld, Helper { return region.isCached(blockX & 511, blockZ & 511); } + public final boolean regionLoaded(int blockX, int blockZ) { + return getRegion(blockX >> 9, blockZ >> 9) != null; + } + @Override public final ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { ArrayList res = new ArrayList<>(); diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java new file mode 100644 index 00000000..3f8d0f82 --- /dev/null +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -0,0 +1,100 @@ +/* + * 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 . + */ + +package baritone.process; + +import baritone.Baritone; +import baritone.api.cache.ICachedWorld; +import baritone.api.pathing.goals.GoalXZ; +import baritone.api.process.PathingCommand; +import baritone.api.process.PathingCommandType; +import baritone.cache.CachedWorld; +import baritone.utils.BaritoneProcessHelper; +import net.minecraft.util.math.BlockPos; + +public class ExploreProcess extends BaritoneProcessHelper { + + private BlockPos explorationOrigin; + + public ExploreProcess(Baritone baritone) { + super(baritone, 0); + } + + @Override + public boolean isActive() { + return explorationOrigin != null; + } + + public void explore(int centerX, int centerZ) { + explorationOrigin = new BlockPos(centerX, 0, centerZ); + } + + @Override + public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { + if (calcFailed) { + logDirect("Failed"); + onLostControl(); + return null; + } + BlockPos closestUncached = closestUncachedChunk(explorationOrigin); + if (closestUncached == null) { + logDebug("awaiting region load from disk"); + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + } + System.out.println("Closest uncached: " + closestUncached); + return new PathingCommand(new GoalXZ(closestUncached.getX(), closestUncached.getZ()), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH); + } + + private BlockPos closestUncachedChunk(BlockPos pos) { + int chunkX = pos.getX() >> 4; + int chunkZ = pos.getZ() >> 4; + ICachedWorld cache = baritone.getWorldProvider().getCurrentWorld().getCachedWorld(); + for (int dist = 0; ; dist++) { + for (int dx = -dist; dx <= dist; dx++) { + for (int dz = -dist; dz <= dist; dz++) { + int trueDist = Baritone.settings().exploreUsePythagorean.value ? dx * dx + dz + dz : Math.abs(dx) + Math.abs(dz); + if (trueDist != dist) { + continue; // not considering this one just yet in our expanding search + } + int centerX = (chunkX + dx) * 16 + 8; + int centerZ = (chunkZ + dz) * 18 + 8; + + if (cache.isCached(centerX, centerZ)) { + continue; + } + if (!((CachedWorld) cache).regionLoaded(centerX, centerZ)) { + Baritone.getExecutor().execute(() -> { + ((CachedWorld) cache).tryLoadFromDisk(centerX >> 9, centerZ >> 9); + }); + return null; // we still need to load regions from disk in order to decide properly + } + return new BlockPos(centerX, 0, centerZ); + } + } + } + } + + @Override + public void onLostControl() { + explorationOrigin = null; + } + + @Override + public String displayName() { + return "Exploring around " + explorationOrigin + ", currently going to " + closestUncachedChunk(explorationOrigin); + } +} diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 7988d796..89aa0fb5 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -374,6 +374,21 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("ok"); return true; } + if (msg.startsWith("explore")) { + String rest = msg.substring("explore".length()).trim(); + int centerX; + int centerZ; + try { + centerX = Integer.parseInt(rest.split(" ")[0]); + centerZ = Integer.parseInt(rest.split(" ")[1]); + } catch (Exception ex) { + centerX = ctx.playerFeet().x; + centerZ = ctx.playerFeet().z; + } + baritone.getExploreProcess().explore(centerX, centerZ); + logDirect("Exploring from " + centerX + "," + centerZ); + return true; + } if (msg.startsWith("find")) { String blockType = msg.substring(4).trim(); ArrayList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); From d80ae57964f0175fa8c8b1c83482f73b4e71c3f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 6 Mar 2019 22:44:57 -0800 Subject: [PATCH 17/27] disconnect on arrival --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/PathingBehavior.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index b9a45960..99fe5241 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -570,6 +570,11 @@ public final class Settings { */ public final Setting axisHeight = new Setting<>(120); + /** + * Disconnect from the server upon arriving at your goal + */ + public final Setting disconnectOnArrival = new Setting<>(false); + /** * Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit" * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index a7c5c34b..915e5066 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -141,6 +141,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, logDebug("All done. At " + goal); queuePathEvent(PathEvent.AT_GOAL); next = null; + if (Baritone.settings().disconnectOnArrival.value) { + ctx.world().sendQuittingDisconnectingPacket(); + } return; } if (next != null && !next.getPath().positions().contains(ctx.playerFeet()) && !next.getPath().positions().contains(expectedSegmentStart)) { // can contain either one From d90f391b5e9dae3fc99ef371fcc70fb442f0678e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 7 Mar 2019 18:18:31 -0800 Subject: [PATCH 18/27] 7 lmao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68654701..9216add1 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi 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 [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 6 months =D 🦀 +Have committed at least once a day for the last 7 months =D 🦀 1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2 From 76297e817669c4757cf9f8a2304cf953c506fb5f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 8 Mar 2019 08:43:28 -0800 Subject: [PATCH 19/27] add click to usage --- USAGE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/USAGE.md b/USAGE.md index 6a07518b..2750ac78 100644 --- a/USAGE.md +++ b/USAGE.md @@ -34,6 +34,7 @@ Some common examples: - `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.) +- `click` to click your destination on the screen. left click to path into it, right click to path on top of it. - `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). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). From ecac546c6d7ebc3191681c82c9ae70d501f4d176 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 9 Mar 2019 23:15:03 -0800 Subject: [PATCH 20/27] actually trolling is fine --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8811361f..ae74fc3e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -26,7 +26,7 @@ Examples of unacceptable behavior by participants include: * Anime * The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* ~~Trolling, insulting/derogatory comments, and personal or political attacks~~ * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission From d144d308908ec356aae4a77c0a329652b13d5567 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 10 Mar 2019 23:43:00 -0700 Subject: [PATCH 21/27] crucial clarification --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9216add1..02ed2bc5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ 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 [30x 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.9, 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). Have committed at least once a day for the last 7 months =D 🦀 From 580af2ab065605cfc42e49bd7666050980215c74 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 18:24:31 -0700 Subject: [PATCH 22/27] processes tied in priority --- .../api/process/IBaritoneProcess.java | 14 +++++++++- .../baritone/api/process/PathingCommand.java | 5 ++++ .../movement/movements/MovementAscend.java | 4 +++ .../movement/movements/MovementPillar.java | 4 +++ .../baritone/process/CustomGoalProcess.java | 10 +++---- .../java/baritone/process/ExploreProcess.java | 2 +- .../java/baritone/process/FollowProcess.java | 2 +- .../baritone/process/GetToBlockProcess.java | 7 +++-- .../java/baritone/process/MineProcess.java | 2 +- .../baritone/utils/BaritoneProcessHelper.java | 9 +----- .../utils/ExampleBaritoneControl.java | 15 ++++++++++ .../baritone/utils/PathingControlManager.java | 28 +++++++++++++------ 12 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/api/java/baritone/api/process/IBaritoneProcess.java b/src/api/java/baritone/api/process/IBaritoneProcess.java index 01e833c0..0339179c 100644 --- a/src/api/java/baritone/api/process/IBaritoneProcess.java +++ b/src/api/java/baritone/api/process/IBaritoneProcess.java @@ -35,6 +35,16 @@ import baritone.api.event.events.PathEvent; */ public interface IBaritoneProcess { + /** + * Default priority. Most normal processes should have this value. + *

+ * Some examples of processes that should have different values might include some kind of automated mob avoidance + * that would be temporary and would forcefully take control. Same for something that pauses pathing for auto eat, etc. + *

+ * The value is -1 beacuse that's what Impact 4.5's beta auto walk returns and I want to tie with it. + */ + double DEFAULT_PRIORITY = -1; + /** * Would this process like to be in control? * @@ -82,7 +92,9 @@ public interface IBaritoneProcess { * * @return A double representing the priority */ - double priority(); + default double priority() { + return DEFAULT_PRIORITY; + } /** * Returns a user-friendly name for this process. Suitable for a HUD. diff --git a/src/api/java/baritone/api/process/PathingCommand.java b/src/api/java/baritone/api/process/PathingCommand.java index 2caef158..61445f8a 100644 --- a/src/api/java/baritone/api/process/PathingCommand.java +++ b/src/api/java/baritone/api/process/PathingCommand.java @@ -53,4 +53,9 @@ public class PathingCommand { this.goal = goal; this.commandType = commandType; } + + @Override + public String toString() { + return commandType + " " + goal; + } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 3dc65990..d3ef9def 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -155,6 +155,10 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.SUCCESS); } + if (ctx.playerFeet().y < src.y) { + return state.setStatus(MovementStatus.UNREACHABLE); + } + IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace); if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) { ticksWithoutPlacement++; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 1bbfa6f9..e899ce63 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -148,6 +148,10 @@ public class MovementPillar extends Movement { return state; } + if (ctx.playerFeet().y < src.y) { + return state.setStatus(MovementStatus.UNREACHABLE); + } + IBlockState fromDown = BlockStateInterface.get(ctx, src); if (MovementHelper.isWater(fromDown.getBlock()) && MovementHelper.isWater(ctx, dest)) { // stay centered while swimming up a water column diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index a6234227..2c8a3c33 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -24,8 +24,6 @@ import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; import baritone.utils.BaritoneProcessHelper; -import java.util.Objects; - /** * As set by ExampleBaritoneControl or something idk * @@ -46,7 +44,7 @@ public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomG private State state; public CustomGoalProcess(Baritone baritone) { - super(baritone, 3); + super(baritone); } @Override @@ -79,20 +77,20 @@ public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomG public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { switch (this.state) { case GOAL_SET: - if (!baritone.getPathingBehavior().isPathing() && Objects.equals(baritone.getPathingBehavior().getGoal() + "", this.goal + "")) { - this.state = State.NONE; - } return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL); case PATH_REQUESTED: + // return FORCE_REVALIDATE_GOAL_AND_PATH just once PathingCommand ret = new PathingCommand(this.goal, PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH); this.state = State.EXECUTING; return ret; case EXECUTING: if (calcFailed) { onLostControl(); + return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL); } if (this.goal == null || this.goal.isInGoal(ctx.playerFeet())) { onLostControl(); // we're there xd + return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL); } return new PathingCommand(this.goal, PathingCommandType.SET_GOAL_AND_PATH); default: diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index 3f8d0f82..3343d882 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -31,7 +31,7 @@ public class ExploreProcess extends BaritoneProcessHelper { private BlockPos explorationOrigin; public ExploreProcess(Baritone baritone) { - super(baritone, 0); + super(baritone); } @Override diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 6e377dec..04e80e03 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -46,7 +46,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo private List cache; public FollowProcess(Baritone baritone) { - super(baritone, 1); + super(baritone); } @Override diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 7f63c6e2..4a2aa3e2 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -44,7 +44,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl private int tickCount = 0; public GetToBlockProcess(Baritone baritone) { - super(baritone, 2); + super(baritone); } @Override @@ -161,7 +161,10 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl @Override public String displayName() { - return "Get To Block " + gettingTo; + if (knownLocations.isEmpty()) { + return "Exploring randomly to find " + gettingTo + ", no known locations"; + } + return "Get To Block " + gettingTo + ", " + knownLocations.size() + " known locations"; } private synchronized void rescan(List known, CalculationContext context) { diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 121ddb8f..495fb0ee 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -60,7 +60,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro private int tickCount; public MineProcess(Baritone baritone) { - super(baritone, 0); + super(baritone); } @Override diff --git a/src/main/java/baritone/utils/BaritoneProcessHelper.java b/src/main/java/baritone/utils/BaritoneProcessHelper.java index 1a66eaa5..61c2fd44 100644 --- a/src/main/java/baritone/utils/BaritoneProcessHelper.java +++ b/src/main/java/baritone/utils/BaritoneProcessHelper.java @@ -25,12 +25,10 @@ public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper protected final Baritone baritone; protected final IPlayerContext ctx; - private final double priority; - public BaritoneProcessHelper(Baritone baritone, double priority) { + public BaritoneProcessHelper(Baritone baritone) { this.baritone = baritone; this.ctx = baritone.getPlayerContext(); - this.priority = priority; baritone.getPathingControlManager().registerProcess(this); } @@ -38,9 +36,4 @@ public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper public boolean isTemporary() { return false; } - - @Override - public double priority() { - return priority; - } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 89aa0fb5..ca88a828 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -24,6 +24,7 @@ import baritone.api.cache.IWaypoint; import baritone.api.event.events.ChatEvent; import baritone.api.pathing.goals.*; import baritone.api.pathing.movement.ActionCosts; +import baritone.api.process.IBaritoneProcess; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.SettingsUtil; import baritone.behavior.Behavior; @@ -225,6 +226,20 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } return true; } + if (msg.equals("proc")) { + Optional proc = baritone.getPathingControlManager().mostRecentInControl(); + if (!proc.isPresent()) { + logDirect("No process is in control"); + return true; + } + IBaritoneProcess p = proc.get(); + logDirect("Class: " + p.getClass()); + logDirect("Priority: " + p.priority()); + logDirect("Temporary: " + p.isTemporary()); + logDirect("Display name: " + p.displayName()); + logDirect("Command: " + baritone.getPathingControlManager().mostRecentCommand()); + return true; + } if (msg.equals("version")) { String version = ExampleBaritoneControl.class.getPackage().getImplementationVersion(); if (version == null) { diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 8d1616c4..a01a1036 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -29,11 +29,11 @@ import baritone.pathing.path.PathExecutor; import net.minecraft.util.math.BlockPos; import java.util.*; -import java.util.stream.Stream; public class PathingControlManager implements IPathingControlManager { private final Baritone baritone; private final HashSet processes; // unGh + private final List active; private IBaritoneProcess inControlLastTick; private IBaritoneProcess inControlThisTick; private PathingCommand command; @@ -41,13 +41,13 @@ public class PathingControlManager implements IPathingControlManager { public PathingControlManager(Baritone baritone) { this.baritone = baritone; this.processes = new HashSet<>(); + this.active = new ArrayList<>(); baritone.getGameEventHandler().registerEventListener(new AbstractGameEventListener() { // needs to be after all behavior ticks @Override public void onTick(TickEvent event) { - if (event.getType() == TickEvent.Type.OUT) { - return; + if (event.getType() == TickEvent.Type.IN) { + postTick(); } - postTick(); } }); } @@ -62,6 +62,7 @@ public class PathingControlManager implements IPathingControlManager { inControlLastTick = null; inControlThisTick = null; command = null; + active.clear(); for (IBaritoneProcess proc : processes) { proc.onLostControl(); if (proc.isActive() && !proc.isTemporary()) { // it's okay only for a temporary thing (like combat pause) to maintain control even if you say to cancel @@ -87,6 +88,7 @@ public class PathingControlManager implements IPathingControlManager { command = executeProcesses(); if (command == null) { p.cancelSegmentIfSafe(); + p.secretInternalSetGoal(null); return; } switch (command.commandType) { @@ -172,12 +174,20 @@ public class PathingControlManager implements IPathingControlManager { public PathingCommand executeProcesses() { - Stream inContention = processes.stream() - .filter(IBaritoneProcess::isActive) - .sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); + for (IBaritoneProcess process : processes) { + if (process.isActive()) { + if (!active.contains(process)) { + // put a newly active process at the very front of the queue + active.add(0, process); + } + } else { + active.remove(process); + } + } + // ties are broken by which was added to the beginning of the list first + active.sort(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); - - Iterator iterator = inContention.iterator(); + Iterator iterator = active.iterator(); while (iterator.hasNext()) { IBaritoneProcess proc = iterator.next(); From 6b7aca308191f33925c05ebea196b9c1fb863161 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 19:23:41 -0700 Subject: [PATCH 23/27] force revalidate on control change --- src/main/java/baritone/utils/PathingControlManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index a01a1036..addcc791 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -24,6 +24,7 @@ import baritone.api.pathing.calc.IPathingControlManager; import baritone.api.pathing.goals.Goal; import baritone.api.process.IBaritoneProcess; import baritone.api.process.PathingCommand; +import baritone.api.process.PathingCommandType; import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; import net.minecraft.util.math.BlockPos; @@ -91,6 +92,11 @@ public class PathingControlManager implements IPathingControlManager { p.secretInternalSetGoal(null); return; } + if (inControlThisTick != inControlLastTick && command.commandType != PathingCommandType.REQUEST_PAUSE) { + // if control has changed, and the new process wants to do something + p.cancelSegmentIfSafe(); + // get rid of the in progress stuff from the last process + } switch (command.commandType) { case REQUEST_PAUSE: p.requestPause(); From 7cfa8376042e85c4f7e95e81cf51d39076ab0186 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 20:06:19 -0700 Subject: [PATCH 24/27] blacklistClosestOnFailure --- src/api/java/baritone/api/Settings.java | 8 ++++--- .../baritone/process/GetToBlockProcess.java | 4 ++-- .../java/baritone/process/MineProcess.java | 24 +++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 99fe5241..c70d60de 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -485,10 +485,12 @@ public final class Settings { public final Setting sprintInWater = new Setting<>(true); /** - * When GetToBlockProcess fails to calculate a path, instead of just giving up, mark the closest instances - * of that block as "unreachable" and go towards the next closest + * When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance + * of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not. + * This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break) + * Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them. */ - public final Setting blacklistOnGetToBlockFailure = new Setting<>(true); + public final Setting blacklistClosestOnFailure = new Setting<>(true); /** * 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 Rarely randomly crashes, see this issue. diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 4a2aa3e2..caebc865 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -83,7 +83,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new)); if (calcFailed) { - if (Baritone.settings().blacklistOnGetToBlockFailure.value) { + if (Baritone.settings().blacklistClosestOnFailure.value) { logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances"); blacklistClosest(); return onTick(false, isSafeToCancel); // gamer moment @@ -168,7 +168,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } private synchronized void rescan(List known, CalculationContext context) { - List positions = MineProcess.searchWorld(context, Collections.singletonList(gettingTo), 64, known); + List positions = MineProcess.searchWorld(context, Collections.singletonList(gettingTo), 64, known, blacklist); positions.removeIf(blacklist::contains); knownLocations = positions; } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 495fb0ee..1c2760de 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -54,6 +54,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro private List mining; private List knownOreLocations; + private List blacklist; // inaccessible private BlockPos branchPoint; private GoalRunAway branchPointRunaway; private int desiredQuantity; @@ -80,6 +81,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } } + if (calcFailed && !knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { + knownOreLocations.stream().sorted(Comparator.comparingDouble(ctx.player()::getDistanceSq)).findFirst().ifPresent(blacklist::add); + knownOreLocations.removeIf(blacklist::contains); + calcFailed = false; // 😎 + } if (calcFailed) { logDirect("Unable to find any path to " + mining + ", canceling Mine"); cancel(); @@ -118,7 +124,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro boolean legit = Baritone.settings().legitMine.value; List locs = knownOreLocations; if (!locs.isEmpty()) { - List locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT); + List locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT, blacklist); // can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(ctx, loc, locs2)).toArray(Goal[]::new)); knownOreLocations = locs2; @@ -160,10 +166,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (Baritone.settings().legitMine.value) { return; } - List locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already); + List locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already, blacklist); locs.addAll(droppedItemsScan(mining, ctx.world())); if (locs.isEmpty()) { - logDebug("No locations for " + mining + " known, cancelling"); + logDirect("No locations for " + mining + " known, cancelling"); cancel(); return; } @@ -204,7 +210,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return ret; } - public static List searchWorld(CalculationContext ctx, List mining, int max, List alreadyKnown) { + public static List searchWorld(CalculationContext ctx, List mining, int max, List alreadyKnown, List blacklist) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>(); //long b = System.currentTimeMillis(); @@ -216,6 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro uninteresting.add(m); } } + locs = prune(ctx, locs, mining, max, blacklist); //System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms"); if (locs.isEmpty()) { uninteresting = mining; @@ -226,7 +233,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } locs.addAll(alreadyKnown); - return prune(ctx, locs, mining, max); + return prune(ctx, locs, mining, max, blacklist); } private void addNearby() { @@ -249,10 +256,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } } } - knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, mining, ORE_LOCATIONS_COUNT); + knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, mining, ORE_LOCATIONS_COUNT, blacklist); } - public static List prune(CalculationContext ctx, List locs2, List mining, int max) { + private static List prune(CalculationContext ctx, List locs2, List mining, int max, List blacklist) { List dropped = droppedItemsScan(mining, ctx.world); dropped.removeIf(drop -> { for (BlockPos pos : locs2) { @@ -272,6 +279,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro // remove any that are implausible to mine (encased in bedrock, or touching lava) .filter(pos -> MineProcess.plausibleToBreak(ctx.bsi, pos)) + .filter(pos -> !blacklist.contains(pos)) + .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq)) .collect(Collectors.toList()); @@ -300,6 +309,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks); this.desiredQuantity = quantity; this.knownOreLocations = new ArrayList<>(); + this.blacklist = new ArrayList<>(); this.branchPoint = null; this.branchPointRunaway = null; if (mining != null) { From 88e41f37b1e4537b7481dbca35177297a6d48dde Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 20:08:52 -0700 Subject: [PATCH 25/27] explain whats happening --- src/main/java/baritone/process/GetToBlockProcess.java | 2 +- src/main/java/baritone/process/MineProcess.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index caebc865..a7a28db0 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -84,7 +84,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new)); if (calcFailed) { if (Baritone.settings().blacklistClosestOnFailure.value) { - logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances"); + logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances..."); blacklistClosest(); return onTick(false, isSafeToCancel); // gamer moment } else { diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 1c2760de..322a966e 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -82,6 +82,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } } if (calcFailed && !knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { + logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance..."); knownOreLocations.stream().sorted(Comparator.comparingDouble(ctx.player()::getDistanceSq)).findFirst().ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); calcFailed = false; // 😎 From 416b5b66d2d2e666492a930fa867c661fc1e00d2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 20:57:46 -0700 Subject: [PATCH 26/27] break fewer beds --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index ca88a828..719ddf00 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -533,7 +533,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return true; } } - Goal goal = new GoalBlock(waypoint.getLocation()); + Goal goal = waypoint.getTag() == Waypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation()); customGoalProcess.setGoalAndPath(goal); return true; } From a5a795a22c65860488f72198d9e4c619c1786f67 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 11 Mar 2019 22:21:35 -0700 Subject: [PATCH 27/27] lower case ok --- README.md | 2 +- src/main/java/baritone/utils/GuiClickMeme.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02ed2bc5..a971cad0 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ That's what it's for, sure! (As long as usage is in compliance with the LGPL 3 L ## How is it so fast? -Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pain) +Magic. (Hours of [leijurv](https://github.com/leijurv) enduring excruciating pain) ## Why is it called Baritone? diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 1163b1b0..9d9ce9b2 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -40,7 +40,7 @@ import static org.lwjgl.opengl.GL11.*; public class GuiClickMeme extends GuiScreen { - // My name is Brady and I grant Leijurv permission to use this pasted code + // My name is Brady and I grant leijurv permission to use this pasted code private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16); private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16); @@ -58,7 +58,7 @@ public class GuiClickMeme extends GuiScreen { int mx = Mouse.getX(); int my = Mouse.getY(); Vec3d near = toWorld(mx, my, 0); - Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - Leijurv + Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv if (near != null && far != null) { Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ); RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), false, false, true);