From 91c4d8292dea32a653c934f7554f7b5835e7f58e Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 26 Aug 2018 02:53:50 -0500 Subject: [PATCH 001/329] Cleaned up 7 duplicate switch statements --- src/main/java/baritone/pathing/movement/Movement.java | 5 +++++ .../pathing/movement/movements/MovementAscend.java | 10 ++-------- .../pathing/movement/movements/MovementDescend.java | 10 ++-------- .../pathing/movement/movements/MovementDiagonal.java | 10 ++-------- .../pathing/movement/movements/MovementDownward.java | 10 ++-------- .../pathing/movement/movements/MovementFall.java | 10 ++-------- .../pathing/movement/movements/MovementPillar.java | 10 ++-------- .../pathing/movement/movements/MovementTraverse.java | 10 ++-------- 8 files changed, 19 insertions(+), 56 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 27cbb08e..ee9bf27a 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -266,6 +266,11 @@ public abstract class Movement implements Helper, MovementHelper { } else if (state.getStatus() == MovementStatus.PREPPING) { state.setStatus(MovementStatus.WAITING); } + + if (state.getStatus() == MovementStatus.WAITING) { + state.setStatus(MovementStatus.RUNNING); + } + return state; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index f3225337..1dce611c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -122,14 +122,8 @@ public class MovementAscend extends Movement { super.updateState(state); // TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump // for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly) - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementStatus.RUNNING) + return state; if (playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 6e299bd1..b9004d9a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -65,14 +65,8 @@ public class MovementDescend extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementStatus.RUNNING) + return state; BlockPos playerFeet = playerFeet(); if (playerFeet.equals(dest)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 7bde41c7..8ece8a44 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -52,14 +52,8 @@ public class MovementDiagonal extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementState.MovementStatus.RUNNING) + return state; if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 724b8688..8262035c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -60,14 +60,8 @@ public class MovementDownward extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementState.MovementStatus.RUNNING) + return state; if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 5c40c706..6117b418 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -80,14 +80,8 @@ public class MovementFall extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementStatus.RUNNING) + return state; BlockPos playerFeet = playerFeet(); Rotation targetRotation = null; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index dba55466..794eb317 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -107,14 +107,8 @@ public class MovementPillar extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementState.MovementStatus.RUNNING) + return state; IBlockState fromDown = BlockStateInterface.get(src); boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index e92fc527..485fc5a7 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -129,14 +129,8 @@ public class MovementTraverse extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } + if (state.getStatus() != MovementState.MovementStatus.RUNNING) + return state; Block fd = BlockStateInterface.get(src.down()).getBlock(); boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine; From 12ec7ea990667fdc996da255b82360c67f80ad7b Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 2 Sep 2018 18:01:41 -0500 Subject: [PATCH 002/329] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 29771860..c3dd39ab 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,12 @@ PathingBehavior.INSTANCE.setGoal(new GoalXZ(10000, 20000)); PathingBehavior.INSTANCE.path(); ``` -# Can I use Baritone as a library in my hacked client? +# FAQ + +## Can I use Baritone as a library in my hacked client? Sure! -# How is it so fast? +## How is it so fast? -Magic \ No newline at end of file +Magic From 5dbf1014b313b36d416d5e11f051c0e25131f19c Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 2 Sep 2018 21:28:55 -0500 Subject: [PATCH 003/329] Fix usage of characters that can't be mapped to ascii --- src/main/java/baritone/utils/Helper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index c973b1ca..ffb0f21b 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -33,7 +33,13 @@ import net.minecraft.util.text.TextFormatting; */ public interface Helper { - ITextComponent MESSAGE_PREFIX = new TextComponentString("§5[§dBaritone§5]§7"); + ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format( + "%s[%sBaritone%s]%s", + TextFormatting.DARK_PURPLE, + TextFormatting.LIGHT_PURPLE, + TextFormatting.DARK_PURPLE, + TextFormatting.GRAY + )); Minecraft mc = Minecraft.getMinecraft(); From 31a87a8938e5b4fd4a2d71cee7d72a6926b78e04 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 2 Sep 2018 23:26:57 -0500 Subject: [PATCH 004/329] Added travis badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c3dd39ab..63bc2c8b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![](https://travis-ci.com/cabaletta/baritone.svg?branch=master) + # Baritone A Minecraft bot. 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. From bac07ce1006b9a123bc188d2ad4ce2d685be3bcf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:15:18 -0700 Subject: [PATCH 005/329] slabs --- src/main/java/baritone/chunk/ChunkPacker.java | 15 ++++---- .../baritone/pathing/movement/Movement.java | 20 +--------- .../pathing/movement/MovementHelper.java | 7 +++- .../movement/movements/MovementAscend.java | 37 +++++++++++++++++-- .../movement/movements/MovementDescend.java | 12 +++--- .../movement/movements/MovementDiagonal.java | 6 ++- .../movement/movements/MovementDownward.java | 5 +-- .../movement/movements/MovementFall.java | 6 +++ .../movement/movements/MovementPillar.java | 18 ++++++--- .../movement/movements/MovementTraverse.java | 9 +++-- src/main/java/baritone/utils/Helper.java | 8 ++-- 11 files changed, 91 insertions(+), 52 deletions(-) diff --git a/src/main/java/baritone/chunk/ChunkPacker.java b/src/main/java/baritone/chunk/ChunkPacker.java index fef3c0a5..e52f6a54 100644 --- a/src/main/java/baritone/chunk/ChunkPacker.java +++ b/src/main/java/baritone/chunk/ChunkPacker.java @@ -20,10 +20,7 @@ package baritone.chunk; import baritone.pathing.movement.MovementHelper; import baritone.utils.Helper; import baritone.utils.pathing.PathingBlockType; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDoublePlant; -import net.minecraft.block.BlockFlower; -import net.minecraft.block.BlockTallGrass; +import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; @@ -50,10 +47,11 @@ public final class ChunkPacker implements Helper { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { int index = CachedChunk.getPositionIndex(x, y, z); - Block block = chunk.getBlockState(x, y, z).getBlock(); - boolean[] bits = getPathingBlockType(block).getBits(); + IBlockState state = chunk.getBlockState(x, y, z); + boolean[] bits = getPathingBlockType(state).getBits(); bitSet.set(index, bits[0]); bitSet.set(index + 1, bits[1]); + Block block = state.getBlock(); if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) { String name = blockToString(block); specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z)); @@ -103,13 +101,14 @@ public final class ChunkPacker implements Helper { return Block.getBlockFromName(name); } - private static PathingBlockType getPathingBlockType(Block block) { + private static PathingBlockType getPathingBlockType(IBlockState state) { + Block block = state.getBlock(); if (block.equals(Blocks.WATER)) { // only water source blocks are plausibly usable, flowing water should be avoid return PathingBlockType.WATER; } - if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER)) { + if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || (block instanceof BlockSlab && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM)) { return PathingBlockType.AVOID; } // We used to do an AABB check here diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 715bfd68..9d2f5869 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -21,13 +21,7 @@ import baritone.Baritone; import baritone.behavior.impl.LookBehavior; import baritone.behavior.impl.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; -import baritone.pathing.movement.movements.MovementDownward; -import baritone.pathing.movement.movements.MovementPillar; -import baritone.pathing.movement.movements.MovementTraverse; import baritone.utils.*; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLadder; -import net.minecraft.block.BlockVine; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -78,21 +72,11 @@ public abstract class Movement implements Helper, MovementHelper { if (cost == null) { if (context == null) context = new CalculationContext(); - cost = calculateCost0(context); + cost = calculateCost(context); } return cost; } - private double calculateCost0(CalculationContext context) { - if (!(this instanceof MovementPillar) && !(this instanceof MovementTraverse) && !(this instanceof MovementDownward)) { - Block fromDown = BlockStateInterface.get(src.down()).getBlock(); - if (fromDown instanceof BlockLadder || fromDown instanceof BlockVine) { - return COST_INF; - } - } - return calculateCost(context); - } - protected abstract double calculateCost(CalculationContext context); public double recalculateCost() { @@ -101,7 +85,7 @@ public abstract class Movement implements Helper, MovementHelper { } public double calculateCostWithoutCaching() { - return calculateCost0(new CalculationContext()); + return calculateCost(new CalculationContext()); } /** diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 909c21a7..3b5aa748 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -186,6 +186,9 @@ public interface MovementHelper extends ActionCosts, Helper { */ static boolean canWalkOn(BlockPos pos, IBlockState state) { Block block = state.getBlock(); + if (block == Blocks.AIR) { + return false; + } if (block instanceof BlockLadder || (Baritone.settings().allowVines.get() && block instanceof BlockVine)) { // TODO reconsider this return true; } @@ -198,8 +201,8 @@ public interface MovementHelper extends ActionCosts, Helper { if (Blocks.ENDER_CHEST.equals(block) || Blocks.CHEST.equals(block)) { return true; } - if (block instanceof BlockAir) { - return false; + if (block instanceof BlockSlab) { + return true; } if (BlockStateInterface.isWater(block)) { if (BlockStateInterface.isFlowing(state)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index a50dfba8..bc94ca48 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -28,6 +28,7 @@ import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; +import net.minecraft.block.BlockSlab; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; @@ -53,7 +54,31 @@ public class MovementAscend extends Movement { @Override protected double calculateCost(CalculationContext context) { + IBlockState srcDown = BlockStateInterface.get(src.down()); + if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) { + return COST_INF; + } + // we can jump from soul sand, but not from a bottom slab + // the only thing we can ascend onto from a bottom slab is another bottom slab + boolean jumpingFromBottomSlab = false; + if (srcDown.getBlock() instanceof BlockSlab) { + BlockSlab jumpingFrom = (BlockSlab) srcDown.getBlock(); + if (!jumpingFrom.isDouble()) { + jumpingFromBottomSlab = srcDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM; + } + } IBlockState toPlace = BlockStateInterface.get(positionToPlace); + boolean jumpingToBottomSlab = false; + if (toPlace.getBlock() instanceof BlockSlab) { + BlockSlab jumpingTo = (BlockSlab) toPlace.getBlock(); + if (!jumpingTo.isDouble() && toPlace.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + jumpingToBottomSlab = true; + } else if (jumpingFromBottomSlab) { + return COST_INF; + } + } else if (jumpingFromBottomSlab) { + return COST_INF; + } if (!MovementHelper.canWalkOn(positionToPlace, toPlace)) { if (!context.hasThrowaway()) { return COST_INF; @@ -96,9 +121,11 @@ public class MovementAscend extends Movement { // it's possible srcUp is AIR from the start, and srcUp2 is falling // and in that scenario, when we arrive and break srcUp2, that lets srcUp3 fall on us and suffocate us } - // TODO maybe change behavior if src.down() is soul sand? double walk = WALK_ONE_BLOCK_COST; - if (toPlace.getBlock().equals(Blocks.SOUL_SAND)) { + if (jumpingToBottomSlab && !jumpingFromBottomSlab) { + return walk + getTotalHardnessOfBlocksToBreak(context); // we don't hit space we just walk into the slab + } + if (!jumpingToBottomSlab && toPlace.getBlock().equals(Blocks.SOUL_SAND)) { walk *= WALK_ONE_OVER_SOUL_SAND_COST / WALK_ONE_BLOCK_COST; } // we hit space immediately on entering this action @@ -123,7 +150,8 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.SUCCESS); } - if (!MovementHelper.canWalkOn(positionToPlace)) { + IBlockState jumpingOnto = BlockStateInterface.get(positionToPlace); + if (!MovementHelper.canWalkOn(positionToPlace, jumpingOnto)) { for (int i = 0; i < 4; i++) { BlockPos anAgainst = positionToPlace.offset(HORIZONTALS[i]); if (anAgainst.equals(src)) { @@ -161,6 +189,9 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.UNREACHABLE); } MovementHelper.moveTowards(state, dest); + if (jumpingOnto.getBlock() instanceof BlockSlab && !((BlockSlab) jumpingOnto.getBlock()).isDouble() && jumpingOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM && !(BlockStateInterface.get(src.down()).getBlock() instanceof BlockSlab)) { + return state; // don't jump while walking from a non slab into a bottom slab + } if (headBonkClear()) { return state.setInput(InputOverrideHandler.Input.JUMP, true); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 7a07abb1..8ab66af1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -25,8 +25,6 @@ import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import net.minecraft.block.Block; -import net.minecraft.block.BlockLadder; -import net.minecraft.block.BlockVine; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; @@ -44,18 +42,22 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { + Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { + return COST_INF; + } if (!MovementHelper.canWalkOn(positionToPlace)) { return COST_INF; } Block tmp1 = BlockStateInterface.get(dest).getBlock(); - if (tmp1 instanceof BlockLadder || tmp1 instanceof BlockVine) { + if (tmp1 == Blocks.LADDER || tmp1 == Blocks.VINE) { return COST_INF; } // we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel) double walk = WALK_OFF_BLOCK_COST; - if (BlockStateInterface.get(src.down()).getBlock().equals(Blocks.SOUL_SAND)) { + if (fromDown == Blocks.SOUL_SAND) { // use this ratio to apply the soul sand speed penalty to our 0.8 block distance - walk *= WALK_ONE_OVER_SOUL_SAND_COST / WALK_ONE_BLOCK_COST; + walk = WALK_ONE_OVER_SOUL_SAND_COST; } return walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST) + getTotalHardnessOfBlocksToBreak(context); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 1ce5537f..2bf8bdf1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -75,6 +75,10 @@ public class MovementDiagonal extends Movement { @Override protected double calculateCost(CalculationContext context) { + Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { + return COST_INF; + } if (!MovementHelper.canWalkThrough(positionsToBreak[4]) || !MovementHelper.canWalkThrough(positionsToBreak[5])) { return COST_INF; } @@ -88,7 +92,7 @@ public class MovementDiagonal extends Movement { if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } - if (BlockStateInterface.get(src.down()).getBlock().equals(Blocks.SOUL_SAND)) { + if (fromDown == Blocks.SOUL_SAND) { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } Block cuttingOver1 = BlockStateInterface.get(positionsToBreak[2].down()).getBlock(); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index ece2c8f5..13555399 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -23,9 +23,8 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import net.minecraft.block.Block; -import net.minecraft.block.BlockLadder; -import net.minecraft.block.BlockVine; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; public class MovementDownward extends Movement { @@ -49,7 +48,7 @@ public class MovementDownward extends Movement { } IBlockState d = BlockStateInterface.get(dest); Block td = d.getBlock(); - boolean ladder = td instanceof BlockLadder || td instanceof BlockVine; + boolean ladder = td == Blocks.LADDER || td == Blocks.VINE; if (ladder) { return LADDER_DOWN_ONE_COST; } else { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index ee019c98..95509574 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,7 +25,9 @@ import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; +import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -43,6 +45,10 @@ public class MovementFall extends Movement { @Override protected double calculateCost(CalculationContext context) { + Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { + return COST_INF; + } if (!MovementHelper.canWalkOn(dest.down())) { return COST_INF; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index d7ff3016..fecd79ec 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -47,11 +47,16 @@ public class MovementPillar extends Movement { protected double calculateCost(CalculationContext context) { Block fromDown = BlockStateInterface.get(src).getBlock(); boolean ladder = fromDown instanceof BlockLadder || fromDown instanceof BlockVine; - Block fromDownDown = BlockStateInterface.get(src.down()).getBlock(); + IBlockState fromDownDown = BlockStateInterface.get(src.down()); if (!ladder) { - if (fromDownDown instanceof BlockLadder || fromDownDown instanceof BlockVine) { + if (fromDownDown.getBlock() instanceof BlockLadder || fromDownDown.getBlock() instanceof BlockVine) { return COST_INF; } + if (fromDownDown.getBlock() instanceof BlockSlab) { + if (!((BlockSlab) fromDownDown.getBlock()).isDouble() && fromDownDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + return COST_INF; // can't pillar up from a bottom slab onto a non ladder + } + } } if (!context.hasThrowaway() && !ladder) { return COST_INF; @@ -87,7 +92,7 @@ public class MovementPillar extends Movement { //} } } - if (fromDown instanceof BlockLiquid || fromDownDown instanceof BlockLiquid) {//can't pillar on water or in water + if (fromDown instanceof BlockLiquid || fromDownDown.getBlock() instanceof BlockLiquid) {//can't pillar on water or in water return COST_INF; } if (ladder) { @@ -142,9 +147,12 @@ public class MovementPillar extends Movement { return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } - if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) + if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) { return state.setStatus(MovementState.MovementStatus.SUCCESS); - + } + if (fromDown.getBlock() instanceof BlockSlab && !((BlockSlab) fromDown.getBlock()).isDouble() && fromDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + state.setInput(InputOverrideHandler.Input.JUMP, true); + } /* if (thePlayer.getPosition0().getX() != from.getX() || thePlayer.getPosition0().getZ() != from.getZ()) { Baritone.moveTowardsBlock(from); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index a959455b..af0b7b27 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -85,7 +85,7 @@ public class MovementTraverse extends Movement { return WC + hardness1 + hardness2; } else {//this is a bridge, so we need to place a block Block srcDown = BlockStateInterface.get(src.down()).getBlock(); - if (srcDown instanceof BlockLadder || srcDown instanceof BlockVine) { + if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) { return COST_INF; } if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(positionToPlace, destOn)) { @@ -107,8 +107,8 @@ public class MovementTraverse extends Movement { return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); } } - if (Blocks.SOUL_SAND.equals(srcDown)) { - return COST_INF; // can't sneak and backplace against soul sand =/ + if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) { + return COST_INF; // can't sneak and backplace against soul sand or half slabs =/ } WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are placing, we are sneaking return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); @@ -206,7 +206,8 @@ public class MovementTraverse extends Movement { return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } state.setInput(InputOverrideHandler.Input.SNEAK, true); - if (BlockStateInterface.get(playerFeet().down()).getBlock().equals(Blocks.SOUL_SAND)) { // see issue #118 + Block standingOn = BlockStateInterface.get(playerFeet().down()).getBlock(); + if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118 double dist = Math.max(Math.abs(dest.getX() + 0.5 - player().posX), Math.abs(dest.getZ() + 0.5 - player().posZ)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon MovementHelper.moveTowards(state, dest); diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index c973b1ca..63fc6df7 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import net.minecraft.block.BlockSlab; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.WorldClient; @@ -47,10 +48,11 @@ public interface Helper { default BlockPos playerFeet() { // TODO find a better way to deal with soul sand!!!!! - return new BlockPos(player().posX, player().posY + 0.1251, player().posZ); - /*if (BlockStateInterface.get(feet).getBlock().equals(Blocks.SOUL_SAND) && player().posY > feet.getY() + 0.874999) { + BlockPos feet = new BlockPos(player().posX, player().posY + 0.1251, player().posZ); + if (BlockStateInterface.get(feet).getBlock() instanceof BlockSlab) { return feet.up(); - }*/ + } + return feet; } default Vec3d playerFeetAsVec() { From 16f88aa858c2f7d6a4f2c26f4b6a631be04d1875 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:18:30 -0700 Subject: [PATCH 006/329] setting --- src/main/java/baritone/Settings.java | 6 ++++++ src/main/java/baritone/pathing/movement/MovementHelper.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 78c2d4b3..2e6f0e39 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -77,6 +77,12 @@ public class Settings { */ public Setting allowVines = new Setting<>(false); + /** + * Slab behavior is complicated, disable this for higher path reliability. Leave enabled if you have bottom slabs + * everywhere in your base. + */ + public Setting allowWalkOnBottomSlab = new Setting<>(true); + /** * This is the big A* setting. * As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 3b5aa748..5561f365 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -202,6 +202,12 @@ public interface MovementHelper extends ActionCosts, Helper { return true; } if (block instanceof BlockSlab) { + if (!Baritone.settings().allowWalkOnBottomSlab.get()) { + if (((BlockSlab) block).isDouble()) { + return true; + } + return state.getValue(BlockSlab.HALF) != BlockSlab.EnumBlockHalf.BOTTOM; + } return true; } if (BlockStateInterface.isWater(block)) { From d328438cf2266097ed3a707af30428073b967b53 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:21:26 -0700 Subject: [PATCH 007/329] no falling onto half slab --- .../pathing/movement/movements/MovementFall.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 95509574..0cb9780a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -27,6 +27,8 @@ import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; +import net.minecraft.block.BlockSlab; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -49,9 +51,15 @@ public class MovementFall extends Movement { if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return COST_INF; } - if (!MovementHelper.canWalkOn(dest.down())) { + IBlockState fallOnto = BlockStateInterface.get(dest.down()); + if (!MovementHelper.canWalkOn(dest.down(), fallOnto)) { return COST_INF; } + if (fallOnto.getBlock() instanceof BlockSlab) { + if (!((BlockSlab) fallOnto.getBlock()).isDouble() && fallOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect + } + } double placeBucketCost = 0.0; if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeightNoWater()) { if (!context.hasWaterBucket()) { From 7473e34602a32324714d3d603007b5d78043e040 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:24:44 -0700 Subject: [PATCH 008/329] check for top or double slab --- .../pathing/movement/movements/MovementAscend.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index bc94ca48..46162806 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -189,8 +189,11 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.UNREACHABLE); } MovementHelper.moveTowards(state, dest); - if (jumpingOnto.getBlock() instanceof BlockSlab && !((BlockSlab) jumpingOnto.getBlock()).isDouble() && jumpingOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM && !(BlockStateInterface.get(src.down()).getBlock() instanceof BlockSlab)) { - return state; // don't jump while walking from a non slab into a bottom slab + if (jumpingOnto.getBlock() instanceof BlockSlab && !((BlockSlab) jumpingOnto.getBlock()).isDouble() && jumpingOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + IBlockState from = BlockStateInterface.get(src.down()); + if (!(from.getBlock() instanceof BlockSlab) || ((BlockSlab) from.getBlock()).isDouble() || from.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) { + return state; // don't jump while walking from a non double slab into a bottom slab + } } if (headBonkClear()) { From 5151c7770365d3cea12742c25fa471094dc3af2d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:25:44 -0700 Subject: [PATCH 009/329] Move badge below header --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63bc2c8b..d69f76e9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ +# Baritone ![](https://travis-ci.com/cabaletta/baritone.svg?branch=master) -# Baritone A Minecraft bot. 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. From 4b2f98ccfd16b29c3d431a91d7f68cf029f165e1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 09:50:26 -0700 Subject: [PATCH 010/329] consolidate and simplify into MovementHelper.isBottomSlab --- src/main/java/baritone/chunk/ChunkPacker.java | 7 +++-- .../pathing/movement/MovementHelper.java | 10 +++++++ .../movement/movements/MovementAscend.java | 29 +++++-------------- .../movement/movements/MovementFall.java | 7 ++--- .../movement/movements/MovementPillar.java | 2 +- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/baritone/chunk/ChunkPacker.java b/src/main/java/baritone/chunk/ChunkPacker.java index e52f6a54..82a36709 100644 --- a/src/main/java/baritone/chunk/ChunkPacker.java +++ b/src/main/java/baritone/chunk/ChunkPacker.java @@ -20,7 +20,10 @@ package baritone.chunk; import baritone.pathing.movement.MovementHelper; import baritone.utils.Helper; import baritone.utils.pathing.PathingBlockType; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockTallGrass; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; @@ -108,7 +111,7 @@ public final class ChunkPacker implements Helper { return PathingBlockType.WATER; } - if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || (block instanceof BlockSlab && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM)) { + if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || MovementHelper.isBottomSlab(state)) { return PathingBlockType.AVOID; } // We used to do an AABB check here diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 5561f365..3e019745 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -270,6 +270,16 @@ public interface MovementHelper extends ActionCosts, Helper { return 0; // we won't actually mine it, so don't check fallings above } + static boolean isBottomSlab(IBlockState state) { + return state.getBlock() instanceof BlockSlab + && !((BlockSlab) state.getBlock()).isDouble() + && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM; + } + + static boolean isBottomSlab(BlockPos pos) { + return isBottomSlab(BlockStateInterface.get(pos)); + } + /** * The entity the player is currently looking at * diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 46162806..d666ff6a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -28,7 +28,6 @@ import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; -import net.minecraft.block.BlockSlab; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; @@ -59,25 +58,12 @@ public class MovementAscend extends Movement { return COST_INF; } // we can jump from soul sand, but not from a bottom slab - // the only thing we can ascend onto from a bottom slab is another bottom slab - boolean jumpingFromBottomSlab = false; - if (srcDown.getBlock() instanceof BlockSlab) { - BlockSlab jumpingFrom = (BlockSlab) srcDown.getBlock(); - if (!jumpingFrom.isDouble()) { - jumpingFromBottomSlab = srcDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM; - } - } + boolean jumpingFromBottomSlab = MovementHelper.isBottomSlab(srcDown); IBlockState toPlace = BlockStateInterface.get(positionToPlace); - boolean jumpingToBottomSlab = false; - if (toPlace.getBlock() instanceof BlockSlab) { - BlockSlab jumpingTo = (BlockSlab) toPlace.getBlock(); - if (!jumpingTo.isDouble() && toPlace.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { - jumpingToBottomSlab = true; - } else if (jumpingFromBottomSlab) { - return COST_INF; - } - } else if (jumpingFromBottomSlab) { - return COST_INF; + boolean jumpingToBottomSlab = MovementHelper.isBottomSlab(toPlace); + + if (jumpingFromBottomSlab && !jumpingToBottomSlab) { + return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab } if (!MovementHelper.canWalkOn(positionToPlace, toPlace)) { if (!context.hasThrowaway()) { @@ -189,9 +175,8 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.UNREACHABLE); } MovementHelper.moveTowards(state, dest); - if (jumpingOnto.getBlock() instanceof BlockSlab && !((BlockSlab) jumpingOnto.getBlock()).isDouble() && jumpingOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { - IBlockState from = BlockStateInterface.get(src.down()); - if (!(from.getBlock() instanceof BlockSlab) || ((BlockSlab) from.getBlock()).isDouble() || from.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) { + if (MovementHelper.isBottomSlab(jumpingOnto)) { + if (!MovementHelper.isBottomSlab(src.down())) { return state; // don't jump while walking from a non double slab into a bottom slab } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 0cb9780a..e82640d2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -27,7 +27,6 @@ import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; -import net.minecraft.block.BlockSlab; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -55,10 +54,8 @@ public class MovementFall extends Movement { if (!MovementHelper.canWalkOn(dest.down(), fallOnto)) { return COST_INF; } - if (fallOnto.getBlock() instanceof BlockSlab) { - if (!((BlockSlab) fallOnto.getBlock()).isDouble() && fallOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { - return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect - } + if (MovementHelper.isBottomSlab(fallOnto)) { + return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } double placeBucketCost = 0.0; if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeightNoWater()) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index fecd79ec..481553fa 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -150,7 +150,7 @@ public class MovementPillar extends Movement { if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) { return state.setStatus(MovementState.MovementStatus.SUCCESS); } - if (fromDown.getBlock() instanceof BlockSlab && !((BlockSlab) fromDown.getBlock()).isDouble() && fromDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { + if (MovementHelper.isBottomSlab(src.down())) { state.setInput(InputOverrideHandler.Input.JUMP, true); } /* From c2fc241d893fa2ef592324c5f900375e406cf73e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 10:04:48 -0700 Subject: [PATCH 011/329] impact integration instructions --- IMPACT.md | 16 ++++++++++++++++ README.md | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 IMPACT.md diff --git a/IMPACT.md b/IMPACT.md new file mode 100644 index 00000000..52934a64 --- /dev/null +++ b/IMPACT.md @@ -0,0 +1,16 @@ +# Integration between Baritone and Impact + +Baritone will be in Impact 4.4 with nice integrations with its hacks, but if you're impatient you can run Baritone on top of Impact 4.3 right now. + +First, clone and setup Baritone (instructions in main README.md). + +Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. + +Then, copy it into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. + +Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. + +- Add the Baritone tweak class to line 7 "minecraftArguments" like so: `"minecraftArguments": " ... --tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine",`. You need the Optifine tweaker even though there is no Optifine involved, for reasons I don't quite understand. +- Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0" },` between Impact and ClientAPI, which should be between lines 15 and 16. + +Restart the Minecraft launcher, then load Impact 4.3 as normal, and it should now include Baritone. \ No newline at end of file diff --git a/README.md b/README.md index d69f76e9..63d241e4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Features +Baritone + Impact + # Setup - Open the project in IntelliJ as a Gradle project - Run the Gradle task `setupDecompWorkspace` From b3b9bb8aa523c8df64b1f0b9d88b5ea023735b0a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 10:11:42 -0700 Subject: [PATCH 012/329] prebuilt jar --- IMPACT.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index 52934a64..29b15aea 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,11 +2,11 @@ Baritone will be in Impact 4.4 with nice integrations with its hacks, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -First, clone and setup Baritone (instructions in main README.md). +You can either build Baritone yourself, or download the jar from Septmeber 3 from here -Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. +To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. -Then, copy it into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. +Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. From dcfc7a1bd6c10a2e5710f94f2aed94abcbdaf5ff Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 10:13:11 -0700 Subject: [PATCH 013/329] added note --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 29b15aea..7e1cc6a4 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -6,7 +6,7 @@ You can either build Baritone yourself, or download the jar from Septmeber 3 fro To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. -Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. +Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. Note the rename from `baritone-1.0.0.jar` to `baritone-1.0.jar`. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. From da67c4aca9075f50a431eeb51eb27b19edaad2dd Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 3 Sep 2018 12:42:00 -0500 Subject: [PATCH 014/329] Make some changes to the Impact installation --- IMPACT.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index 7e1cc6a4..b57a0dfe 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,15 +2,15 @@ Baritone will be in Impact 4.4 with nice integrations with its hacks, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar from Septmeber 3 from here +You can either build Baritone yourself, or download the jar from Steptember 3 from here To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. -Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. Note the rename from `baritone-1.0.0.jar` to `baritone-1.0.jar`. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0/baritone-1.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0` in libraries first. +Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0.0` in libraries first. Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. - Add the Baritone tweak class to line 7 "minecraftArguments" like so: `"minecraftArguments": " ... --tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine",`. You need the Optifine tweaker even though there is no Optifine involved, for reasons I don't quite understand. -- Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0" },` between Impact and ClientAPI, which should be between lines 15 and 16. +- Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0.0" },` between Impact and ClientAPI, which should be between lines 15 and 16. -Restart the Minecraft launcher, then load Impact 4.3 as normal, and it should now include Baritone. \ No newline at end of file +Restart the Minecraft launcher, then load Impact 4.3 as normal, and it should now include Baritone. From ba7dc46442039fc45d013629bf7b2fb1af95acff Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 3 Sep 2018 12:43:27 -0500 Subject: [PATCH 015/329] Another Impact install update --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index b57a0dfe..44a3fc0a 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -8,7 +8,7 @@ To build it yourself, clone and setup Baritone (instructions in main README.md). Copy the jar into place. It should be `build/libs/baritone-1.0.0.jar` in baritone. Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0.0` in libraries first. -Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. +Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json` or copy your existing installation and rename the version folder, json, and id in the json. - Add the Baritone tweak class to line 7 "minecraftArguments" like so: `"minecraftArguments": " ... --tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine",`. You need the Optifine tweaker even though there is no Optifine involved, for reasons I don't quite understand. - Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0.0" },` between Impact and ClientAPI, which should be between lines 15 and 16. From 53d9d3da5e4360fec52a7e625a39f2333a3aaa4f Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 3 Sep 2018 12:58:21 -0500 Subject: [PATCH 016/329] lol --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 44a3fc0a..859a2423 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its hacks, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar from Steptember 3 from here +You can either build Baritone yourself, or download the jar from September 3 from here To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From bfd41f94734ddf02f0b52be39ccafae96c4949d4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 11:27:59 -0700 Subject: [PATCH 017/329] stairs --- src/main/java/baritone/pathing/movement/MovementHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 3e019745..80026c6f 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -210,6 +210,9 @@ public interface MovementHelper extends ActionCosts, Helper { } return true; } + if (block instanceof BlockStairs) { + return true; + } if (BlockStateInterface.isWater(block)) { if (BlockStateInterface.isFlowing(state)) { return false; From 6eb293c97a37f098d67af874e0b428d06d660e8a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 11:33:02 -0700 Subject: [PATCH 018/329] update documentation --- FEATURES.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 8147fc22..436aefc8 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -5,7 +5,8 @@ - **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. - **Falling** Baritone will fall up to 3 blocks onto solid ground (configurable, if you have Feather Falling and/or don't mind taking a little damage). If you have a water bucket on your hotbar, it will fall up to 23 blocks and place the bucket beneath it. It will fall an unlimited distance into existing still water. - **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). -- **Fence gates and doors** +- **Opening fence gates and doors** +- **Slabs and stairs** - **Falling blocks** Baritone understands the costs of breaking blocks with falling blocks on top, and includes all of their break costs. Additionally, since it avoids breaking any blocks touching a liquid, it won't break the bottom of a gravel stack below a lava lake (anymore). - **Avoiding dangerous blocks** Obviously, it knows not to walk through fire or on magma, not to corner over lava (that deals some damage), not to break any blocks touching a liquid (it might drown), etc. @@ -35,9 +36,7 @@ And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one o # Future features Things it doesn't have yet - Trapdoors -- Slabs (double, top, and bottom) - Sprint jumping in a 1x2 corridor -- Stairs See issues for more. From 4690bcb5ac236f596131d28844fa2b4891ca24d9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 11:43:06 -0700 Subject: [PATCH 019/329] add example --- FEATURES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FEATURES.md b/FEATURES.md index 8147fc22..d75cca87 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -2,7 +2,7 @@ - **Long distance pathing and splicing** Baritone calculates paths in segments, and precalculates the next segment when the current one is about to end, so that it's moving towards the goal at all times. - **Chunk caching** Baritone simplifies chunks to a compacted internal 2-bit representation (AIR, SOLID, WATER, AVOID) and stores them in RAM for better very-long-distance pathing. There is also an option to save these cached chunks to disk. Example - **Block breaking** Baritone considers breaking blocks as part of its path. It also takes into account your current tool set and hot bar. For example, if you have a Eff V diamond pick, it may choose to mine through a stone barrier, while if you only had a wood pick it might be faster to climb over it. -- **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. +- **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. Example - **Falling** Baritone will fall up to 3 blocks onto solid ground (configurable, if you have Feather Falling and/or don't mind taking a little damage). If you have a water bucket on your hotbar, it will fall up to 23 blocks and place the bucket beneath it. It will fall an unlimited distance into existing still water. - **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). - **Fence gates and doors** From 574fd05376cbea1b7bf1c46c6fe722813c5ac7ef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 12:03:49 -0700 Subject: [PATCH 020/329] fix bucket check, fixes #128 --- .../baritone/pathing/movement/movements/MovementFall.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index ee019c98..7061d2f2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -26,6 +26,7 @@ import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; import net.minecraft.block.BlockFalling; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -96,7 +97,7 @@ public class MovementFall extends Movement { BlockPos playerFeet = playerFeet(); Rotation targetRotation = null; if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) { - if (!player().inventory.hasItemStack(STACK_BUCKET_WATER) || world().provider.isNether()) { + if (!InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) || world().provider.isNether()) { state.setStatus(MovementStatus.UNREACHABLE); return state; } @@ -119,7 +120,7 @@ public class MovementFall extends Movement { } if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 // lilypads || BlockStateInterface.isWater(dest))) { - if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_EMPTY)) { + if (BlockStateInterface.isWater(dest) && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); if (player().motionY >= 0) { return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); From 53f2ab5901cf143a3b29e869838df51954dba865 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 12:06:58 -0700 Subject: [PATCH 021/329] fix badge link destination --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63d241e4..b95cc957 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Baritone -![](https://travis-ci.com/cabaletta/baritone.svg?branch=master) +[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) A Minecraft bot. 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. From dd1a20a04792f0fb1c5d5669fce3bd23142da151 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 16:14:14 -0700 Subject: [PATCH 022/329] final makes things faster --- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 6e4fc599..ec8891f4 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -26,7 +26,7 @@ import net.minecraft.util.math.Vec3i; * * @author leijurv */ -public class BetterBlockPos extends BlockPos { +public final class BetterBlockPos extends BlockPos { public final int x; public final int y; public final int z; From 07a9829865c47501de76fabac43ffabb7877c2c1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 16:24:43 -0700 Subject: [PATCH 023/329] accurate debug --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index fa8b5076..73442998 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -200,7 +200,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { return Optional.of(new Path(startNode, bestSoFar[i], numNodes)); } } - displayChatMessageRaw("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + bestDist + " blocks"); + displayChatMessageRaw("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); displayChatMessageRaw("No path found =("); currentlyRunning = null; return Optional.empty(); From bfafca541fc9b2edadde20215883e428d130e837 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 17:01:04 -0700 Subject: [PATCH 024/329] add proguard --- proguard.pro | 360 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 proguard.pro diff --git a/proguard.pro b/proguard.pro new file mode 100644 index 00000000..7e09a64a --- /dev/null +++ b/proguard.pro @@ -0,0 +1,360 @@ +-injars baritone-1.0.0.jar +-outjars Obfuscated + +-libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' + +-libraryjars 'tempLibraries/1.12.2.jar' + +-libraryjars 'tempLibraries/authlib-1.5.25.jar' +-libraryjars 'tempLibraries/codecjorbis-20101023.jar' +-libraryjars 'tempLibraries/codecwav-20101023.jar' +-libraryjars 'tempLibraries/commons-codec-1.10.jar' +-libraryjars 'tempLibraries/commons-compress-1.8.1.jar' +-libraryjars 'tempLibraries/commons-io-2.5.jar' +-libraryjars 'tempLibraries/commons-lang3-3.5.jar' +-libraryjars 'tempLibraries/commons-logging-1.1.3.jar' +-libraryjars 'tempLibraries/fastutil-7.1.0.jar' +-libraryjars 'tempLibraries/gson-2.8.0.jar' +-libraryjars 'tempLibraries/guava-21.0.jar' +-libraryjars 'tempLibraries/httpclient-4.3.3.jar' +-libraryjars 'tempLibraries/httpcore-4.3.2.jar' +-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar' +-libraryjars 'tempLibraries/java-objc-bridge-1.0.0-natives-osx.jar' +-libraryjars 'tempLibraries/java-objc-bridge-1.0.0.jar' +-libraryjars 'tempLibraries/jinput-2.0.5.jar' +-libraryjars 'tempLibraries/jinput-platform-2.0.5-natives-osx.jar' +-libraryjars 'tempLibraries/jna-4.4.0.jar' +-libraryjars 'tempLibraries/jopt-simple-5.0.3.jar' +-libraryjars 'tempLibraries/jsr305-3.0.1-sources.jar' +-libraryjars 'tempLibraries/jsr305-3.0.1.jar' +-libraryjars 'tempLibraries/jutils-1.0.0.jar' +-libraryjars 'tempLibraries/libraryjavasound-20101123.jar' +-libraryjars 'tempLibraries/librarylwjglopenal-20100824.jar' +-libraryjars 'tempLibraries/log4j-api-2.8.1.jar' +-libraryjars 'tempLibraries/log4j-core-2.8.1.jar' +-libraryjars 'tempLibraries/lwjgl-2.9.2-nightly-20140822.jar' +-libraryjars 'tempLibraries/lwjgl-platform-2.9.2-nightly-20140822-natives-osx.jar' +-libraryjars 'tempLibraries/lwjgl_util-2.9.2-nightly-20140822.jar' +-libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar' +-libraryjars 'tempLibraries/oshi-core-1.1.jar' +-libraryjars 'tempLibraries/patchy-1.1.jar' +-libraryjars 'tempLibraries/platform-3.4.0.jar' +-libraryjars 'tempLibraries/realms-1.10.22.jar' +-libraryjars 'tempLibraries/soundsystem-20120107.jar' +-libraryjars 'tempLibraries/text2speech-1.10.3.jar' + +-libraryjars 'tempLibraries/mixin-0.7.8-SNAPSHOT.jar' +-libraryjars 'tempLibraries/launchwrapper-1.12.jar' + +-keepattributes Signature +-keepattributes *Annotation* + +-optimizationpasses 20 +-verbose + +-allowaccessmodification +-mergeinterfacesaggressively +-overloadaggressively +-flattenpackagehierarchy +-repackageclasses +-dontusemixedcaseclassnames + +-overloadaggressively + +-repackageclasses 'baritone' + +-keep class baritone.behavior.** { *; } +-keep class baritone.api.** { *; } +-keep class baritone.* { *; } +-keep class baritone.pathing.goals.** { *; } + +-keep class baritone.launch.** { *; } + +# Keep - Applications. Keep all application classes, along with their 'main' +# methods. +-keepclasseswithmembers public class * { + public static void main(java.lang.String[]); +} + +# Also keep - Enumerations. Keep the special static methods that are required in +# enumeration classes. +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Also keep - Database drivers. Keep all implementations of java.sql.Driver. +-keep class * extends java.sql.Driver + +# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI, +# along with the special 'createUI' method. +-keep class * extends javax.swing.plaf.ComponentUI { + public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent); +} + +# Keep names - Native method names. Keep all native class/method names. +-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * { + native ; +} + +# Remove - System method calls. Remove all invocations of System +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.System { + public static long currentTimeMillis(); + static java.lang.Class getCallerClass(); + public static int identityHashCode(java.lang.Object); + public static java.lang.SecurityManager getSecurityManager(); + public static java.util.Properties getProperties(); + public static java.lang.String getProperty(java.lang.String); + public static java.lang.String getenv(java.lang.String); + public static java.lang.String mapLibraryName(java.lang.String); + public static java.lang.String getProperty(java.lang.String,java.lang.String); +} + +# Remove - Math method calls. Remove all invocations of Math +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.Math { + public static double sin(double); + public static double cos(double); + public static double tan(double); + public static double asin(double); + public static double acos(double); + public static double atan(double); + public static double toRadians(double); + public static double toDegrees(double); + public static double exp(double); + public static double log(double); + public static double log10(double); + public static double sqrt(double); + public static double cbrt(double); + public static double IEEEremainder(double,double); + public static double ceil(double); + public static double floor(double); + public static double rint(double); + public static double atan2(double,double); + public static double pow(double,double); + public static int round(float); + public static long round(double); + public static double random(); + public static int abs(int); + public static long abs(long); + public static float abs(float); + public static double abs(double); + public static int max(int,int); + public static long max(long,long); + public static float max(float,float); + public static double max(double,double); + public static int min(int,int); + public static long min(long,long); + public static float min(float,float); + public static double min(double,double); + public static double ulp(double); + public static float ulp(float); + public static double signum(double); + public static float signum(float); + public static double sinh(double); + public static double cosh(double); + public static double tanh(double); + public static double hypot(double,double); + public static double expm1(double); + public static double log1p(double); +} + +# Remove - Number method calls. Remove all invocations of Number +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.* extends java.lang.Number { + public static java.lang.String toString(byte); + public static java.lang.Byte valueOf(byte); + public static byte parseByte(java.lang.String); + public static byte parseByte(java.lang.String,int); + public static java.lang.Byte valueOf(java.lang.String,int); + public static java.lang.Byte valueOf(java.lang.String); + public static java.lang.Byte decode(java.lang.String); + public int compareTo(java.lang.Byte); + public static java.lang.String toString(short); + public static short parseShort(java.lang.String); + public static short parseShort(java.lang.String,int); + public static java.lang.Short valueOf(java.lang.String,int); + public static java.lang.Short valueOf(java.lang.String); + public static java.lang.Short valueOf(short); + public static java.lang.Short decode(java.lang.String); + public static short reverseBytes(short); + public int compareTo(java.lang.Short); + public static java.lang.String toString(int,int); + public static java.lang.String toHexString(int); + public static java.lang.String toOctalString(int); + public static java.lang.String toBinaryString(int); + public static java.lang.String toString(int); + public static int parseInt(java.lang.String,int); + public static int parseInt(java.lang.String); + public static java.lang.Integer valueOf(java.lang.String,int); + public static java.lang.Integer valueOf(java.lang.String); + public static java.lang.Integer valueOf(int); + public static java.lang.Integer getInteger(java.lang.String); + public static java.lang.Integer getInteger(java.lang.String,int); + public static java.lang.Integer getInteger(java.lang.String,java.lang.Integer); + public static java.lang.Integer decode(java.lang.String); + public static int highestOneBit(int); + public static int lowestOneBit(int); + public static int numberOfLeadingZeros(int); + public static int numberOfTrailingZeros(int); + public static int bitCount(int); + public static int rotateLeft(int,int); + public static int rotateRight(int,int); + public static int reverse(int); + public static int signum(int); + public static int reverseBytes(int); + public int compareTo(java.lang.Integer); + public static java.lang.String toString(long,int); + public static java.lang.String toHexString(long); + public static java.lang.String toOctalString(long); + public static java.lang.String toBinaryString(long); + public static java.lang.String toString(long); + public static long parseLong(java.lang.String,int); + public static long parseLong(java.lang.String); + public static java.lang.Long valueOf(java.lang.String,int); + public static java.lang.Long valueOf(java.lang.String); + public static java.lang.Long valueOf(long); + public static java.lang.Long decode(java.lang.String); + public static java.lang.Long getLong(java.lang.String); + public static java.lang.Long getLong(java.lang.String,long); + public static java.lang.Long getLong(java.lang.String,java.lang.Long); + public static long highestOneBit(long); + public static long lowestOneBit(long); + public static int numberOfLeadingZeros(long); + public static int numberOfTrailingZeros(long); + public static int bitCount(long); + public static long rotateLeft(long,int); + public static long rotateRight(long,int); + public static long reverse(long); + public static int signum(long); + public static long reverseBytes(long); + public int compareTo(java.lang.Long); + public static java.lang.String toString(float); + public static java.lang.String toHexString(float); + public static java.lang.Float valueOf(java.lang.String); + public static java.lang.Float valueOf(float); + public static float parseFloat(java.lang.String); + public static boolean isNaN(float); + public static boolean isInfinite(float); + public static int floatToIntBits(float); + public static int floatToRawIntBits(float); + public static float intBitsToFloat(int); + public static int compare(float,float); + public boolean isNaN(); + public boolean isInfinite(); + public int compareTo(java.lang.Float); + public static java.lang.String toString(double); + public static java.lang.String toHexString(double); + public static java.lang.Double valueOf(java.lang.String); + public static java.lang.Double valueOf(double); + public static double parseDouble(java.lang.String); + public static boolean isNaN(double); + public static boolean isInfinite(double); + public static long doubleToLongBits(double); + public static long doubleToRawLongBits(double); + public static double longBitsToDouble(long); + public static int compare(double,double); + public boolean isNaN(); + public boolean isInfinite(); + public int compareTo(java.lang.Double); + public byte byteValue(); + public short shortValue(); + public int intValue(); + public long longValue(); + public float floatValue(); + public double doubleValue(); + public int compareTo(java.lang.Object); + public boolean equals(java.lang.Object); + public int hashCode(); + public java.lang.String toString(); +} + +# Remove - String method calls. Remove all invocations of String +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.String { + public static java.lang.String copyValueOf(char[]); + public static java.lang.String copyValueOf(char[],int,int); + public static java.lang.String valueOf(boolean); + public static java.lang.String valueOf(char); + public static java.lang.String valueOf(char[]); + public static java.lang.String valueOf(char[],int,int); + public static java.lang.String valueOf(double); + public static java.lang.String valueOf(float); + public static java.lang.String valueOf(int); + public static java.lang.String valueOf(java.lang.Object); + public static java.lang.String valueOf(long); + public boolean contentEquals(java.lang.StringBuffer); + public boolean endsWith(java.lang.String); + public boolean equalsIgnoreCase(java.lang.String); + public boolean equals(java.lang.Object); + public boolean matches(java.lang.String); + public boolean regionMatches(boolean,int,java.lang.String,int,int); + public boolean regionMatches(int,java.lang.String,int,int); + public boolean startsWith(java.lang.String); + public boolean startsWith(java.lang.String,int); + public byte[] getBytes(); + public byte[] getBytes(java.lang.String); + public char charAt(int); + public char[] toCharArray(); + public int compareToIgnoreCase(java.lang.String); + public int compareTo(java.lang.Object); + public int compareTo(java.lang.String); + public int hashCode(); + public int indexOf(int); + public int indexOf(int,int); + public int indexOf(java.lang.String); + public int indexOf(java.lang.String,int); + public int lastIndexOf(int); + public int lastIndexOf(int,int); + public int lastIndexOf(java.lang.String); + public int lastIndexOf(java.lang.String,int); + public int length(); + public java.lang.CharSequence subSequence(int,int); + public java.lang.String concat(java.lang.String); + public java.lang.String replaceAll(java.lang.String,java.lang.String); + public java.lang.String replace(char,char); + public java.lang.String replaceFirst(java.lang.String,java.lang.String); + public java.lang.String[] split(java.lang.String); + public java.lang.String[] split(java.lang.String,int); + public java.lang.String substring(int); + public java.lang.String substring(int,int); + public java.lang.String toLowerCase(); + public java.lang.String toLowerCase(java.util.Locale); + public java.lang.String toString(); + public java.lang.String toUpperCase(); + public java.lang.String toUpperCase(java.util.Locale); + public java.lang.String trim(); +} + +# Remove - StringBuffer method calls. Remove all invocations of StringBuffer +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.StringBuffer { + public java.lang.String toString(); + public char charAt(int); + public int capacity(); + public int codePointAt(int); + public int codePointBefore(int); + public int indexOf(java.lang.String,int); + public int lastIndexOf(java.lang.String); + public int lastIndexOf(java.lang.String,int); + public int length(); + public java.lang.String substring(int); + public java.lang.String substring(int,int); +} + +# Remove - StringBuilder method calls. Remove all invocations of StringBuilder +# methods without side effects whose return values are not used. +-assumenosideeffects public class java.lang.StringBuilder { + public java.lang.String toString(); + public char charAt(int); + public int capacity(); + public int codePointAt(int); + public int codePointBefore(int); + public int indexOf(java.lang.String,int); + public int lastIndexOf(java.lang.String); + public int lastIndexOf(java.lang.String,int); + public int length(); + public java.lang.String substring(int); + public java.lang.String substring(int,int); +} From a2f0a1839a870d9e1f4e48de40ab817899ce88c2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Sep 2018 20:42:28 -0700 Subject: [PATCH 025/329] fix goal get to block --- .../pathing/goals/GoalGetToBlock.java | 43 ++++++++++------ .../pathing/goals/GoalGetToBlockTest.java | 49 +++++++++++++++++++ 2 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 9c847918..ed927a12 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -17,32 +17,47 @@ package baritone.pathing.goals; -import net.minecraft.util.EnumFacing; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; + /** * Don't get into the block, but get directly adjacent to it. Useful for chests. * * @author avecowa */ -public class GoalGetToBlock extends GoalComposite { +public class GoalGetToBlock implements Goal { - private final BlockPos pos; + private final int x; + private final int y; + private final int z; public GoalGetToBlock(BlockPos pos) { - super(adjacentBlocks(pos)); - this.pos = pos; - } - - private static BlockPos[] adjacentBlocks(BlockPos pos) { - BlockPos[] sides = new BlockPos[6]; - for (int i = 0; i < 6; i++) { - sides[i] = pos.offset(EnumFacing.values()[i]); - } - return sides; + this.x = pos.getX(); + this.y = pos.getY(); + this.z = pos.getZ(); } public BlockPos getGoalPos() { - return pos; + return new BetterBlockPos(x, y, z); + } + + @Override + public boolean isInGoal(BlockPos pos) { + int xDiff = pos.getX() - this.x; + int yDiff = pos.getY() - this.y; + int zDiff = pos.getZ() - this.z; + if (yDiff == -2 && xDiff == 0 && zDiff == 0) { + return true; + } + return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1; + } + + @Override + public double heuristic(BlockPos pos) { + int xDiff = pos.getX() - this.x; + int yDiff = pos.getY() - this.y; + int zDiff = pos.getZ() - this.z; + return GoalBlock.calculate(xDiff, yDiff, zDiff); } } diff --git a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java new file mode 100644 index 00000000..3c3905aa --- /dev/null +++ b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java @@ -0,0 +1,49 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.pathing.goals; + +import net.minecraft.util.math.BlockPos; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class GoalGetToBlockTest { + + @Test + public void isInGoal() { + List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,1,0", "0,-1,0", "0,-2,0")); + for (int x = -10; x <= 10; x++) { + for (int y = -10; y <= 10; y++) { + for (int z = -10; z <= 10; z++) { + boolean inGoal = new GoalGetToBlock(new BlockPos(0, 0, 0)).isInGoal(new BlockPos(x, y, z)); + String repr = x + "," + y + "," + z; + System.out.println(repr + " " + inGoal); + if (inGoal) { + assertTrue(repr, acceptableOffsets.contains(repr)); + acceptableOffsets.remove(repr); + } + } + } + } + assertTrue(acceptableOffsets.toString(), acceptableOffsets.isEmpty()); + } +} \ No newline at end of file From 5cfb270a32f36910d5219c4a2718a29519aa5f60 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 08:48:55 -0700 Subject: [PATCH 026/329] update proguard --- proguard.pro | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/proguard.pro b/proguard.pro index 7e09a64a..7f0cfcdc 100644 --- a/proguard.pro +++ b/proguard.pro @@ -1,6 +1,36 @@ -injars baritone-1.0.0.jar -outjars Obfuscated + +-keepattributes Signature +-keepattributes *Annotation* + +-optimizationpasses 20 +-verbose + +-allowaccessmodification # anything not kept can be changed from public to private and inlined etc +-mergeinterfacesaggressively +-overloadaggressively +-dontusemixedcaseclassnames + +# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with mcp +-flattenpackagehierarchy +-repackageclasses 'baritone' + +#-keep class baritone.behavior.** { *; } +#-keep class baritone.api.** { *; } +#-keep class baritone.* { *; } +#-keep class baritone.pathing.goals.** { *; } + +# setting names are reflected from field names, so keep field names +-keepclassmembers class baritone.Settings { + public ; +} + +# need to keep mixin names +-keep class baritone.launch.** { *; } + +# copy all necessary libraries into tempLibraries to build -libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' -libraryjars 'tempLibraries/1.12.2.jar' @@ -46,29 +76,8 @@ -libraryjars 'tempLibraries/mixin-0.7.8-SNAPSHOT.jar' -libraryjars 'tempLibraries/launchwrapper-1.12.jar' --keepattributes Signature --keepattributes *Annotation* --optimizationpasses 20 --verbose --allowaccessmodification --mergeinterfacesaggressively --overloadaggressively --flattenpackagehierarchy --repackageclasses --dontusemixedcaseclassnames - --overloadaggressively - --repackageclasses 'baritone' - --keep class baritone.behavior.** { *; } --keep class baritone.api.** { *; } --keep class baritone.* { *; } --keep class baritone.pathing.goals.** { *; } - --keep class baritone.launch.** { *; } # Keep - Applications. Keep all application classes, along with their 'main' # methods. From 2452a69089af1ae7b04248163c04c3114b2b5bca Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 08:50:42 -0700 Subject: [PATCH 027/329] mine many block types at once --- .../java/baritone/behavior/impl/MineBehavior.java | 14 +++++++++----- .../baritone/utils/ExampleBaritoneControl.java | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 32f92877..f34aa480 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -29,6 +29,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -44,7 +45,7 @@ public class MineBehavior extends Behavior { private MineBehavior() { } - String mining; + List mining; @Override public void onTick(TickEvent event) { @@ -54,14 +55,17 @@ public class MineBehavior extends Behavior { if (mining == null) { return; } - List locs = new ArrayList<>(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(mining, 1, 1)); + List locs = new ArrayList<>(); + for (String m : mining) { + locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); + } BlockPos playerFeet = playerFeet(); locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); // remove any that are within loaded chunks that aren't actually what we want locs.removeAll(locs.stream() .filter(pos -> !(world().getChunk(pos) instanceof EmptyChunk)) - .filter(pos -> !ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).equalsIgnoreCase(mining)) + .filter(pos -> !mining.contains(ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).toLowerCase())) .collect(Collectors.toList())); if (locs.size() > 30) { locs = locs.subList(0, 30); @@ -75,8 +79,8 @@ public class MineBehavior extends Behavior { PathingBehavior.INSTANCE.path(); } - public void mine(String mining) { - this.mining = mining; + public void mine(String... mining) { + this.mining = new ArrayList<>(Arrays.asList(mining)); } public void cancel() { diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 75a36994..5bc75d3f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -189,8 +189,8 @@ public class ExampleBaritoneControl extends Behavior { } if (msg.toLowerCase().startsWith("mine")) { String blockType = msg.toLowerCase().substring(4).trim(); - MineBehavior.INSTANCE.mine(blockType); - displayChatMessageRaw("Started mining blocks of type " + blockType); + MineBehavior.INSTANCE.mine(blockType.split(" ")); + displayChatMessageRaw("Started mining blocks of type " + Arrays.toString(blockType.split(" "))); event.cancel(); return; } From f51bcc8b8919709139670f541d96918676eb7a32 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 08:51:58 -0700 Subject: [PATCH 028/329] forgot null check --- src/main/java/baritone/behavior/impl/MineBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index f34aa480..1e1fdb08 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -80,7 +80,7 @@ public class MineBehavior extends Behavior { } public void mine(String... mining) { - this.mining = new ArrayList<>(Arrays.asList(mining)); + this.mining = mining == null ? null : new ArrayList<>(Arrays.asList(mining)); } public void cancel() { From 438392840b75c5296e8c580e245d33563cbf3ab5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 08:56:34 -0700 Subject: [PATCH 029/329] possible fix to concurrentmodificationexception on path start --- src/main/java/baritone/Baritone.java | 2 ++ src/main/java/baritone/utils/ToolSet.java | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 5baacec8..0b571264 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -21,6 +21,7 @@ import baritone.api.event.GameEventHandler; import baritone.behavior.Behavior; import baritone.behavior.impl.*; import baritone.utils.InputOverrideHandler; +import baritone.utils.ToolSet; import net.minecraft.client.Minecraft; import java.io.File; @@ -81,6 +82,7 @@ public enum Baritone { registerBehavior(LocationTrackingBehavior.INSTANCE); registerBehavior(FollowBehavior.INSTANCE); registerBehavior(MineBehavior.INSTANCE); + this.gameEventHandler.registerEventListener(ToolSet.INTERNAL_EVENT_LISTENER); } this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone"); if (!Files.exists(dir.toPath())) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 415d8ebd..ce24b708 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -17,7 +17,6 @@ package baritone.utils; -import baritone.Baritone; import baritone.api.event.events.ItemSlotEvent; import baritone.api.event.listener.AbstractGameEventListener; import net.minecraft.block.Block; @@ -46,11 +45,7 @@ public class ToolSet implements Helper { /** * Instance of the internal event listener used to hook into Baritone's event bus */ - private static final InternalEventListener INTERNAL_EVENT_LISTENER = new InternalEventListener(); - - static { - Baritone.INSTANCE.getGameEventHandler().registerEventListener(INTERNAL_EVENT_LISTENER); - } + public static final InternalEventListener INTERNAL_EVENT_LISTENER = new InternalEventListener(); /** * A list of tools on the hotbar that should be considered. From 424113f052d8612c79db6c03a0b8db65688e5609 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 09:55:56 -0700 Subject: [PATCH 030/329] don't sprint if hunger is too low --- src/main/java/baritone/pathing/path/PathExecutor.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 88ca6e30..818f9bbb 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -19,10 +19,7 @@ package baritone.pathing.path; import baritone.Baritone; import baritone.api.event.events.TickEvent; -import baritone.pathing.movement.ActionCosts; -import baritone.pathing.movement.Movement; -import baritone.pathing.movement.MovementHelper; -import baritone.pathing.movement.MovementState; +import baritone.pathing.movement.*; import baritone.pathing.movement.movements.MovementDescend; import baritone.pathing.movement.movements.MovementDiagonal; import baritone.pathing.movement.movements.MovementFall; @@ -274,7 +271,7 @@ public class PathExecutor implements Helper { } private void sprintIfRequested() { - if (!Baritone.settings().allowSprint.get()) { + if (!new CalculationContext().canSprint()) { player().setSprinting(false); return; } From ebd4930fe476dcd740e24536a4b8759c680fe3bf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 09:57:19 -0700 Subject: [PATCH 031/329] fix horrendous typo --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 859a2423..95faedc6 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -1,6 +1,6 @@ # Integration between Baritone and Impact -Baritone will be in Impact 4.4 with nice integrations with its hacks, but if you're impatient you can run Baritone on top of Impact 4.3 right now. +Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. You can either build Baritone yourself, or download the jar from September 3 from here From 3fd1063e3c43e5fdeaf2028cb5e9af1478dd0f7b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 10:06:48 -0700 Subject: [PATCH 032/329] cache on block not blockstate --- src/main/java/baritone/utils/ToolSet.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 415d8ebd..a5684280 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -72,10 +72,10 @@ public class ToolSet implements Helper { private Map slotCache = new HashMap<>(); /** - * A cache mapping a {@link IBlockState} to how long it will take to break + * A cache mapping a {@link Block} to how long it will take to break * with this toolset, given the optimum tool is used. */ - private Map breakStrengthCache = new HashMap<>(); + private Map breakStrengthCache = new HashMap<>(); /** * Create a toolset from the current player's inventory (but don't calculate any hardness values just yet) @@ -146,7 +146,7 @@ public class ToolSet implements Helper { * @return how long it would take in ticks */ public double getStrVsBlock(IBlockState state, BlockPos pos) { - return this.breakStrengthCache.computeIfAbsent(state, s -> calculateStrVsBlock(s, pos)); + return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(state, pos)); } /** From 288e57d275a90b78ba32f5de61450a15a99cd988 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 13:20:49 -0700 Subject: [PATCH 033/329] fix warning --- src/main/java/baritone/behavior/impl/MineBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 1e1fdb08..185cacd2 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -80,11 +80,11 @@ public class MineBehavior extends Behavior { } public void mine(String... mining) { - this.mining = mining == null ? null : new ArrayList<>(Arrays.asList(mining)); + this.mining = mining == null || mining.length == 0 ? null : new ArrayList<>(Arrays.asList(mining)); } public void cancel() { PathingBehavior.INSTANCE.cancel(); - mine(null); + mine(); } } From 9f156e8e2797cd4b4ad94745f0cf1617f868a99c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 13:23:26 -0700 Subject: [PATCH 034/329] updated dropbox file name and link --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 95faedc6..7fa22435 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar from September 3 from here +You can either build Baritone yourself, or download the jar from September 4 from here To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From 0bd3f9f68010861c38cae7af1f2bb650210c707f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 13:57:56 -0700 Subject: [PATCH 035/329] fix water fall logic --- .../java/baritone/pathing/movement/MovementHelper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 80026c6f..82b20c41 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -214,13 +214,14 @@ public interface MovementHelper extends ActionCosts, Helper { return true; } if (BlockStateInterface.isWater(block)) { - if (BlockStateInterface.isFlowing(state)) { - return false; - } Block up = BlockStateInterface.get(pos.up()).getBlock(); if (up instanceof BlockLilyPad) { return true; } + if (BlockStateInterface.isFlowing(state)) { + // the only scenario in which we can walk on flowing water is if it's under still water with jesus off + return BlockStateInterface.isWater(up) && !Baritone.settings().assumeWalkOnWater.get(); + } // 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 BlockStateInterface.isWater(up) ^ Baritone.settings().assumeWalkOnWater.get(); From 7cc23bc89bb12e3e718453397cacaa92cb1b7cda Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:03:59 -0700 Subject: [PATCH 036/329] scan for uninteresting blocks in loaded chunks, fixes #99 --- .../baritone/behavior/impl/MineBehavior.java | 43 ++++++--- .../java/baritone/chunk/WorldScanner.java | 92 +++++++++++++++++++ .../utils/ExampleBaritoneControl.java | 32 +++---- 3 files changed, 135 insertions(+), 32 deletions(-) create mode 100644 src/main/java/baritone/chunk/WorldScanner.java diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 185cacd2..bbd1c594 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -19,8 +19,10 @@ package baritone.behavior.impl; import baritone.api.event.events.TickEvent; import baritone.behavior.Behavior; +import baritone.chunk.CachedChunk; import baritone.chunk.ChunkPacker; import baritone.chunk.WorldProvider; +import baritone.chunk.WorldScanner; import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; @@ -55,21 +57,7 @@ public class MineBehavior extends Behavior { if (mining == null) { return; } - List locs = new ArrayList<>(); - for (String m : mining) { - locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); - } - BlockPos playerFeet = playerFeet(); - locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); - - // remove any that are within loaded chunks that aren't actually what we want - locs.removeAll(locs.stream() - .filter(pos -> !(world().getChunk(pos) instanceof EmptyChunk)) - .filter(pos -> !mining.contains(ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).toLowerCase())) - .collect(Collectors.toList())); - if (locs.size() > 30) { - locs = locs.subList(0, 30); - } + List locs = scanFor(mining, 64); if (locs.isEmpty()) { displayChatMessageRaw("No locations for " + mining + " known, cancelling"); cancel(); @@ -79,6 +67,31 @@ public class MineBehavior extends Behavior { PathingBehavior.INSTANCE.path(); } + public static List scanFor(List mining, int max) { + List locs = new ArrayList<>(); + List uninteresting = new ArrayList<>(); + for (String m : mining) { + if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(ChunkPacker.stringToBlock(m))) { + locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); + } else { + uninteresting.add(m); + } + } + locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet(); + locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); + + // remove any that are within loaded chunks that aren't actually what we want + locs.removeAll(locs.stream() + .filter(pos -> !(MineBehavior.INSTANCE.world().getChunk(pos) instanceof EmptyChunk)) + .filter(pos -> !mining.contains(ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).toLowerCase())) + .collect(Collectors.toList())); + if (locs.size() > max) { + locs = locs.subList(0, max); + } + return locs; + } + public void mine(String... mining) { this.mining = mining == null || mining.length == 0 ? null : new ArrayList<>(Arrays.asList(mining)); } diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java new file mode 100644 index 00000000..62e20944 --- /dev/null +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -0,0 +1,92 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.chunk; + +import baritone.utils.Helper; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.multiplayer.ChunkProviderClient; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.BlockStateContainer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +public enum WorldScanner implements Helper { + INSTANCE; + + public List scanLoadedChunks(List blockTypes, int max) { + List asBlocks = blockTypes.stream().map(ChunkPacker::stringToBlock).collect(Collectors.toList()); + if (asBlocks.contains(null)) { + throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString()); + } + LinkedList res = new LinkedList<>(); + ChunkProviderClient chunkProvider = world().getChunkProvider(); + + int playerChunkX = playerFeet().getX() >> 4; + int playerChunkZ = playerFeet().getZ() >> 4; + + int searchRadius = 0; + while (true) { + boolean allUnloaded = true; + for (int xoff = -searchRadius; xoff <= searchRadius; xoff++) { + for (int zoff = -searchRadius; zoff <= searchRadius; zoff++) { + int distance = xoff * xoff + zoff * zoff; + if (distance != searchRadius) { + continue; + } + int chunkX = xoff + playerChunkX; + int chunkZ = zoff + playerChunkZ; + Chunk chunk = chunkProvider.getLoadedChunk(chunkX, chunkZ); + if (chunk == null) { + continue; + } + allUnloaded = false; + ExtendedBlockStorage[] chunkInternalStorageArray = chunk.getBlockStorageArray(); + for (int y0 = 0; y0 < 16; y0++) { + ExtendedBlockStorage extendedblockstorage = chunkInternalStorageArray[y0]; + if (extendedblockstorage == null) { + continue; + } + BlockStateContainer bsc = extendedblockstorage.getData(); + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + IBlockState state = bsc.get(x, y, z); + if (asBlocks.contains(state.getBlock())) { + res.add(new BlockPos(chunkX * 16 + x, y0 * 16 + y, chunkZ * 16 + z)); + } + } + } + } + } + } + } + if (allUnloaded) { + return res; + } + if (res.size() >= max) { + return res; + } + searchRadius++; + } + } +} diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 5bc75d3f..16dabf4f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -38,10 +38,8 @@ import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.chunk.EmptyChunk; import java.util.*; -import java.util.stream.Collectors; public class ExampleBaritoneControl extends Behavior { public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl(); @@ -188,9 +186,16 @@ public class ExampleBaritoneControl extends Behavior { return; } if (msg.toLowerCase().startsWith("mine")) { - String blockType = msg.toLowerCase().substring(4).trim(); - MineBehavior.INSTANCE.mine(blockType.split(" ")); - displayChatMessageRaw("Started mining blocks of type " + Arrays.toString(blockType.split(" "))); + String[] blockTypes = msg.toLowerCase().substring(4).trim().split(" "); + for (String s : blockTypes) { + if (ChunkPacker.stringToBlock(s) == null) { + displayChatMessageRaw(s + " isn't a valid block name"); + event.cancel(); + return; + } + } + MineBehavior.INSTANCE.mine(blockTypes); + displayChatMessageRaw("Started mining blocks of type " + Arrays.toString(blockTypes)); event.cancel(); return; } @@ -235,21 +240,14 @@ public class ExampleBaritoneControl extends Behavior { String mining = waypointType; //displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); - List locs = new ArrayList<>(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(mining, 1, 1)); - if (locs.isEmpty()) { + if (ChunkPacker.stringToBlock(mining) == null) { displayChatMessageRaw("No locations for " + mining + " known, cancelling"); return; } - BlockPos playerFeet = playerFeet(); - locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); - - // remove any that are within loaded chunks that aren't actually what we want - locs.removeAll(locs.stream() - .filter(pos -> !(world().getChunk(pos) instanceof EmptyChunk)) - .filter(pos -> !ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).equalsIgnoreCase(mining)) - .collect(Collectors.toList())); - if (locs.size() > 30) { - locs = locs.subList(0, 30); + List locs = MineBehavior.scanFor(Arrays.asList(mining), 64); + if (locs.isEmpty()) { + displayChatMessageRaw("No locations for " + mining + " known, cancelling"); + return; } PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new))); PathingBehavior.INSTANCE.path(); From 4f07d655d6b88247c811a14961b8366c63e3f704 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:08:21 -0700 Subject: [PATCH 037/329] don't scan empty --- src/main/java/baritone/behavior/impl/MineBehavior.java | 8 +++++++- src/main/java/baritone/chunk/WorldScanner.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index bbd1c594..d4b09b7b 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -70,6 +70,7 @@ public class MineBehavior extends Behavior { public static List scanFor(List mining, int max) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>(); + //long b = System.currentTimeMillis(); for (String m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(ChunkPacker.stringToBlock(m))) { locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); @@ -77,7 +78,12 @@ public class MineBehavior extends Behavior { uninteresting.add(m); } } - locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + //System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms"); + if (!uninteresting.isEmpty()) { + //long before = System.currentTimeMillis(); + locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); + } BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet(); locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 62e20944..fe3c0ea5 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -39,6 +39,9 @@ public enum WorldScanner implements Helper { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString()); } LinkedList res = new LinkedList<>(); + if (asBlocks.isEmpty()) { + return res; + } ChunkProviderClient chunkProvider = world().getChunkProvider(); int playerChunkX = playerFeet().getX() >> 4; From 8c9bb85d4b5982f1962dba52a4388d2a8882b164 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 17:18:30 -0500 Subject: [PATCH 038/329] Fully separate dependency on launch package from other packages --- .../java/baritone/chunk/WorldProvider.java | 4 +- .../launch/mixins/MixinAnvilChunkLoader.java | 41 +++++++++++++++++++ .../mixins/MixinChunkProviderServer.java | 40 ++++++++++++++++++ .../accessor/IAnvilChunkLoader.java | 9 +--- .../accessor/IChunkProviderServer.java | 8 +--- src/main/resources/mixins.baritone.json | 7 ++-- 6 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java create mode 100644 src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java rename src/main/java/baritone/{launch/mixins => utils}/accessor/IAnvilChunkLoader.java (74%) rename src/main/java/baritone/{launch/mixins => utils}/accessor/IChunkProviderServer.java (76%) diff --git a/src/main/java/baritone/chunk/WorldProvider.java b/src/main/java/baritone/chunk/WorldProvider.java index 709ddff8..275b6ac1 100644 --- a/src/main/java/baritone/chunk/WorldProvider.java +++ b/src/main/java/baritone/chunk/WorldProvider.java @@ -18,8 +18,8 @@ package baritone.chunk; import baritone.Baritone; -import baritone.launch.mixins.accessor.IAnvilChunkLoader; -import baritone.launch.mixins.accessor.IChunkProviderServer; +import baritone.utils.accessor.IAnvilChunkLoader; +import baritone.utils.accessor.IChunkProviderServer; import baritone.utils.Helper; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.server.integrated.IntegratedServer; diff --git a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java new file mode 100644 index 00000000..96f38b87 --- /dev/null +++ b/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java @@ -0,0 +1,41 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.utils.accessor.IAnvilChunkLoader; +import net.minecraft.world.chunk.storage.AnvilChunkLoader; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.io.File; + +/** + * @author Brady + * @since 9/4/2018 + */ +@Mixin(AnvilChunkLoader.class) +public class MixinAnvilChunkLoader implements IAnvilChunkLoader { + + @Shadow @Final private File chunkSaveLocation; + + @Override + public File getChunkSaveLocation() { + return this.chunkSaveLocation; + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java new file mode 100644 index 00000000..9a454d01 --- /dev/null +++ b/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java @@ -0,0 +1,40 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.utils.accessor.IChunkProviderServer; +import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraft.world.gen.ChunkProviderServer; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +/** + * @author Brady + * @since 9/4/2018 + */ +@Mixin(ChunkProviderServer.class) +public class MixinChunkProviderServer implements IChunkProviderServer { + + @Shadow @Final private IChunkLoader chunkLoader; + + @Override + public IChunkLoader getChunkLoader() { + return this.chunkLoader; + } +} diff --git a/src/main/java/baritone/launch/mixins/accessor/IAnvilChunkLoader.java b/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java similarity index 74% rename from src/main/java/baritone/launch/mixins/accessor/IAnvilChunkLoader.java rename to src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java index 3972ff32..900e3fb4 100644 --- a/src/main/java/baritone/launch/mixins/accessor/IAnvilChunkLoader.java +++ b/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java @@ -15,11 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.launch.mixins.accessor; - -import net.minecraft.world.chunk.storage.AnvilChunkLoader; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +package baritone.utils.accessor; import java.io.File; @@ -27,8 +23,7 @@ import java.io.File; * @author Brady * @since 8/4/2018 11:36 AM */ -@Mixin(AnvilChunkLoader.class) public interface IAnvilChunkLoader { - @Accessor File getChunkSaveLocation(); + File getChunkSaveLocation(); } diff --git a/src/main/java/baritone/launch/mixins/accessor/IChunkProviderServer.java b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java similarity index 76% rename from src/main/java/baritone/launch/mixins/accessor/IChunkProviderServer.java rename to src/main/java/baritone/utils/accessor/IChunkProviderServer.java index 460014fc..bb3dcb5e 100644 --- a/src/main/java/baritone/launch/mixins/accessor/IChunkProviderServer.java +++ b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java @@ -15,19 +15,15 @@ * along with Baritone. If not, see . */ -package baritone.launch.mixins.accessor; +package baritone.utils.accessor; import net.minecraft.world.chunk.storage.IChunkLoader; -import net.minecraft.world.gen.ChunkProviderServer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; /** * @author Brady * @since 8/4/2018 11:33 AM */ -@Mixin(ChunkProviderServer.class) public interface IChunkProviderServer { - @Accessor IChunkLoader getChunkLoader(); + IChunkLoader getChunkLoader(); } diff --git a/src/main/resources/mixins.baritone.json b/src/main/resources/mixins.baritone.json index c0b5d3bb..989c9355 100755 --- a/src/main/resources/mixins.baritone.json +++ b/src/main/resources/mixins.baritone.json @@ -8,7 +8,9 @@ "maxShiftBy": 2 }, "client": [ + "MixinAnvilChunkLoader", "MixinBlockPos", + "MixinChunkProviderServer", "MixinEntity", "MixinEntityPlayerSP", "MixinEntityRenderer", @@ -20,9 +22,6 @@ "MixinMinecraft", "MixinNetHandlerPlayClient", "MixinNetworkManager", - "MixinWorldClient", - - "accessor.IAnvilChunkLoader", - "accessor.IChunkProviderServer" + "MixinWorldClient" ] } \ No newline at end of file From e7d41ba4fc9a95a38a26997e25206351c7d809db Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:18:51 -0700 Subject: [PATCH 039/329] optimize chunk packer with extended block storage --- src/main/java/baritone/chunk/ChunkPacker.java | 63 +++++++++++++++---- .../java/baritone/chunk/WorldScanner.java | 5 +- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/chunk/ChunkPacker.java b/src/main/java/baritone/chunk/ChunkPacker.java index 82a36709..4622369c 100644 --- a/src/main/java/baritone/chunk/ChunkPacker.java +++ b/src/main/java/baritone/chunk/ChunkPacker.java @@ -28,7 +28,9 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.BlockStateContainer; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import java.util.*; @@ -40,28 +42,65 @@ public final class ChunkPacker implements Helper { private ChunkPacker() {} + private static BitSet originalPacker(Chunk chunk) { + BitSet bitSet = new BitSet(CachedChunk.SIZE); + for (int y = 0; y < 256; y++) { + for (int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { + int index = CachedChunk.getPositionIndex(x, y, z); + IBlockState state = chunk.getBlockState(x, y, z); + boolean[] bits = getPathingBlockType(state).getBits(); + bitSet.set(index, bits[0]); + bitSet.set(index + 1, bits[1]); + } + } + } + return bitSet; + } + public static CachedChunk pack(Chunk chunk) { long start = System.nanoTime() / 1000000L; Map> specialBlocks = new HashMap<>(); BitSet bitSet = new BitSet(CachedChunk.SIZE); try { - for (int y = 0; y < 256; y++) { - for (int z = 0; z < 16; z++) { - for (int x = 0; x < 16; x++) { - int index = CachedChunk.getPositionIndex(x, y, z); - IBlockState state = chunk.getBlockState(x, y, z); - boolean[] bits = getPathingBlockType(state).getBits(); - bitSet.set(index, bits[0]); - bitSet.set(index + 1, bits[1]); - Block block = state.getBlock(); - if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) { - String name = blockToString(block); - specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z)); + ExtendedBlockStorage[] chunkInternalStorageArray = chunk.getBlockStorageArray(); + for (int y0 = 0; y0 < 16; y0++) { + ExtendedBlockStorage extendedblockstorage = chunkInternalStorageArray[y0]; + if (extendedblockstorage == null) { + // any 16x16x16 area that's all air will have null storage + // for example, in an ocean biome, with air from y=64 to y=256 + // the first 4 extended blocks storages will be full + // and the remaining 12 will be null + + // since the index into the bitset is calculated from the x y and z + // and doesn't function as an append, we can entirely skip the scanning + // since a bitset is initialized to all zero, and air is saved as zeros + continue; + } + BlockStateContainer bsc = extendedblockstorage.getData(); + int yReal = y0 << 4; + for (int x = 0; x < 16; x++) { + for (int y1 = 0; y1 < 16; y1++) { + for (int z = 0; z < 16; z++) { + int y = y1 | yReal; + int index = CachedChunk.getPositionIndex(x, y, z); + IBlockState state = bsc.get(x, y1, z); + boolean[] bits = getPathingBlockType(state).getBits(); + bitSet.set(index, bits[0]); + bitSet.set(index + 1, bits[1]); + Block block = state.getBlock(); + if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) { + String name = blockToString(block); + specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z)); + } } } } } + /*if (!bitSet.equals(originalPacker(chunk))) { + throw new IllegalStateException(); + }*/ } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index fe3c0ea5..120d6635 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -64,18 +64,21 @@ public enum WorldScanner implements Helper { } allUnloaded = false; ExtendedBlockStorage[] chunkInternalStorageArray = chunk.getBlockStorageArray(); + chunkX = chunkX << 4; + chunkZ = chunkZ << 4; for (int y0 = 0; y0 < 16; y0++) { ExtendedBlockStorage extendedblockstorage = chunkInternalStorageArray[y0]; if (extendedblockstorage == null) { continue; } + int yReal = y0 << 4; BlockStateContainer bsc = extendedblockstorage.getData(); for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { IBlockState state = bsc.get(x, y, z); if (asBlocks.contains(state.getBlock())) { - res.add(new BlockPos(chunkX * 16 + x, y0 * 16 + y, chunkZ * 16 + z)); + res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z)); } } } From 69d8bd56fa3c54e7668725c9e507319a6107ceef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:23:54 -0700 Subject: [PATCH 040/329] rearranged loop order --- src/main/java/baritone/chunk/ChunkPacker.java | 10 ++++++---- src/main/java/baritone/chunk/WorldScanner.java | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/chunk/ChunkPacker.java b/src/main/java/baritone/chunk/ChunkPacker.java index 4622369c..583dddc0 100644 --- a/src/main/java/baritone/chunk/ChunkPacker.java +++ b/src/main/java/baritone/chunk/ChunkPacker.java @@ -80,10 +80,12 @@ public final class ChunkPacker implements Helper { } BlockStateContainer bsc = extendedblockstorage.getData(); int yReal = y0 << 4; - for (int x = 0; x < 16; x++) { - for (int y1 = 0; y1 < 16; y1++) { - for (int z = 0; z < 16; z++) { - int y = y1 | yReal; + // the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x; + // for better cache locality, iterate in that order + for (int y1 = 0; y1 < 16; y1++) { + int y = y1 | yReal; + for (int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { int index = CachedChunk.getPositionIndex(x, y, z); IBlockState state = bsc.get(x, y1, z); boolean[] bits = getPathingBlockType(state).getBits(); diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 120d6635..cf4fb117 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -73,9 +73,11 @@ public enum WorldScanner implements Helper { } int yReal = y0 << 4; BlockStateContainer bsc = extendedblockstorage.getData(); - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { + // the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x; + // for better cache locality, iterate in that order + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { IBlockState state = bsc.get(x, y, z); if (asBlocks.contains(state.getBlock())) { res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z)); From 2bb01fdd208756846ab1b4b3cc2a56db9050b11b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:33:38 -0700 Subject: [PATCH 041/329] decrease scan rate --- .../java/baritone/behavior/impl/MineBehavior.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index d4b09b7b..0b4b3b2a 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -17,7 +17,7 @@ package baritone.behavior.impl; -import baritone.api.event.events.TickEvent; +import baritone.api.event.events.PathEvent; import baritone.behavior.Behavior; import baritone.chunk.CachedChunk; import baritone.chunk.ChunkPacker; @@ -50,10 +50,11 @@ public class MineBehavior extends Behavior { List mining; @Override - public void onTick(TickEvent event) { - if (event.getType() == TickEvent.Type.OUT) { - return; - } + public void onPathEvent(PathEvent event) { + updateGoal(); + } + + public void updateGoal() { if (mining == null) { return; } @@ -100,6 +101,7 @@ public class MineBehavior extends Behavior { public void mine(String... mining) { this.mining = mining == null || mining.length == 0 ? null : new ArrayList<>(Arrays.asList(mining)); + updateGoal(); } public void cancel() { From 0c4fd39845c96cb06508c9d7f7d2c73cea9508e1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:53:11 -0700 Subject: [PATCH 042/329] better error message --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 16dabf4f..9c28f058 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -105,7 +105,11 @@ public class ExampleBaritoneControl extends Behavior { } if (msg.equals("path")) { if (!PathingBehavior.INSTANCE.path()) { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + if (PathingBehavior.INSTANCE.getGoal() == null) { + displayChatMessageRaw("No goal."); + } else { + displayChatMessageRaw("Currently executing a path. Please cancel it first."); + } } event.cancel(); return; From 81ffbddc94197052e69fc89c9930ecaa67984f18 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 16:02:31 -0700 Subject: [PATCH 043/329] start with more than one chunk --- src/main/java/baritone/chunk/WorldScanner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index cf4fb117..09edd1e5 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -47,7 +47,7 @@ public enum WorldScanner implements Helper { int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; - int searchRadius = 0; + int searchRadius = 2; while (true) { boolean allUnloaded = true; for (int xoff = -searchRadius; xoff <= searchRadius; xoff++) { From d40418d344e9f7813560ef9e22059cf09653187f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 16:04:44 -0700 Subject: [PATCH 044/329] move updateState after calculateCost for consistency with every other movement --- .../movement/movements/MovementDiagonal.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 2bf8bdf1..b71909d1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -50,29 +50,6 @@ public class MovementDiagonal extends Movement { super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); } - @Override - public MovementState updateState(MovementState state) { - super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; - } - - if (playerFeet().equals(dest)) { - state.setStatus(MovementState.MovementStatus.SUCCESS); - return state; - } - if (!BlockStateInterface.isLiquid(playerFeet())) { - state.setInput(InputOverrideHandler.Input.SPRINT, true); - } - MovementHelper.moveTowards(state, dest); - return state; - } - @Override protected double calculateCost(CalculationContext context) { Block fromDown = BlockStateInterface.get(src.down()).getBlock(); @@ -139,6 +116,29 @@ public class MovementDiagonal extends Movement { return multiplier * SQRT_2; } + @Override + public MovementState updateState(MovementState state) { + super.updateState(state); + switch (state.getStatus()) { + case WAITING: + state.setStatus(MovementState.MovementStatus.RUNNING); + case RUNNING: + break; + default: + return state; + } + + if (playerFeet().equals(dest)) { + state.setStatus(MovementState.MovementStatus.SUCCESS); + return state; + } + if (!BlockStateInterface.isLiquid(playerFeet())) { + state.setInput(InputOverrideHandler.Input.SPRINT, true); + } + MovementHelper.moveTowards(state, dest); + return state; + } + @Override protected boolean prepared(MovementState state) { return true; From 40e86df0801227eab41470478a2aae2bf1189bab Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 18:06:17 -0500 Subject: [PATCH 045/329] Remove unnecessary abstract mixin class modifiers --- src/main/java/baritone/launch/mixins/MixinBlockPos.java | 2 +- src/main/java/baritone/launch/mixins/MixinKeyBinding.java | 2 +- src/main/java/baritone/launch/mixins/MixinNetworkManager.java | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/launch/mixins/MixinBlockPos.java b/src/main/java/baritone/launch/mixins/MixinBlockPos.java index 1cf52132..49e01c96 100644 --- a/src/main/java/baritone/launch/mixins/MixinBlockPos.java +++ b/src/main/java/baritone/launch/mixins/MixinBlockPos.java @@ -29,7 +29,7 @@ import javax.annotation.Nonnull; * @since 8/25/2018 */ @Mixin(BlockPos.class) -public abstract class MixinBlockPos extends Vec3i { +public class MixinBlockPos extends Vec3i { public MixinBlockPos(int xIn, int yIn, int zIn) { super(xIn, yIn, zIn); diff --git a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java b/src/main/java/baritone/launch/mixins/MixinKeyBinding.java index 085ddc74..db850188 100755 --- a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/main/java/baritone/launch/mixins/MixinKeyBinding.java @@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; * @since 7/31/2018 11:44 PM */ @Mixin(KeyBinding.class) -public abstract class MixinKeyBinding { +public class MixinKeyBinding { @Inject( method = "isKeyDown", diff --git a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java b/src/main/java/baritone/launch/mixins/MixinNetworkManager.java index 472d4f04..46664e7c 100644 --- a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/main/java/baritone/launch/mixins/MixinNetworkManager.java @@ -37,12 +37,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; * @since 8/6/2018 9:30 PM */ @Mixin(NetworkManager.class) -public abstract class MixinNetworkManager { +public class MixinNetworkManager { @Shadow private Channel channel; - @Shadow protected abstract void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_) throws Exception; - @Inject( method = "dispatchPacket", at = @At("HEAD") From 1e6599cc4222a2055cee4305dd40f06fb2137c2b Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 18:08:29 -0500 Subject: [PATCH 046/329] Consolidate plugins in build.gradle --- build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index bdb3c311..a3717498 100755 --- a/build.gradle +++ b/build.gradle @@ -38,15 +38,14 @@ buildscript { } apply plugin: 'java' +apply plugin: 'net.minecraftforge.gradle.tweaker-client' +apply plugin: 'org.spongepowered.mixin' sourceCompatibility = targetCompatibility = '1.8' compileJava { sourceCompatibility = targetCompatibility = '1.8' } -apply plugin: 'net.minecraftforge.gradle.tweaker-client' -apply plugin: 'org.spongepowered.mixin' - minecraft { version = '1.12.2' mappings = 'snapshot_20180731' From a45f291d6721170cb7b802ba466b59d7982c5c26 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 16:19:10 -0700 Subject: [PATCH 047/329] vine and ladder fixes --- .../movement/movements/MovementTraverse.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index af0b7b27..12eda431 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -57,15 +57,16 @@ public class MovementTraverse extends Movement { IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); IBlockState destOn = BlockStateInterface.get(positionToPlace); + Block srcDown = BlockStateInterface.getBlock(src.down()); if (MovementHelper.canWalkOn(positionToPlace, destOn)) {//this is a walk, not a bridge double WC = WALK_ONE_BLOCK_COST; if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) { WC = WALK_ONE_IN_WATER_COST; } else { - if (Blocks.SOUL_SAND.equals(destOn.getBlock())) { + if (destOn.getBlock() == Blocks.SOUL_SAND) { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } - if (Blocks.SOUL_SAND.equals(BlockStateInterface.get(src.down()).getBlock())) { + if (srcDown == Blocks.SOUL_SAND) { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } } @@ -82,9 +83,12 @@ public class MovementTraverse extends Movement { } return WC; } + if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) { + hardness1 *= 5; + hardness2 *= 5; + } return WC + hardness1 + hardness2; } else {//this is a bridge, so we need to place a block - Block srcDown = BlockStateInterface.get(src.down()).getBlock(); if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) { return COST_INF; } @@ -130,6 +134,8 @@ public class MovementTraverse extends Movement { return state; } + state.setInput(InputOverrideHandler.Input.SNEAK, false); + Block fd = BlockStateInterface.get(src.down()).getBlock(); boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine; IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); @@ -186,7 +192,7 @@ public class MovementTraverse extends Movement { state.setInput(InputOverrideHandler.Input.SPRINT, true); } Block destDown = BlockStateInterface.get(dest.down()).getBlock(); - if (ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) { + if (whereAmI.getY() != dest.getY() && ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) { new MovementPillar(dest.down(), dest).updateState(state); // i'm sorry return state; } @@ -264,4 +270,15 @@ public class MovementTraverse extends Movement { } } } + + @Override + protected boolean prepared(MovementState state) { + if (playerFeet().equals(src) || playerFeet().equals(src.down())) { + Block block = BlockStateInterface.getBlock(src.down()); + if (block == Blocks.LADDER || block == Blocks.VINE) { + state.setInput(InputOverrideHandler.Input.SNEAK, true); + } + } + return super.prepared(state); + } } From bba2458f8eb8d51fb3d3301ffb06ebbf155419ba Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 18:48:00 -0500 Subject: [PATCH 048/329] Separate "launch" into another SourceSet --- build.gradle | 12 +- .../java/baritone/launch/BaritoneTweaker.java | 142 +++---- .../baritone/launch/BaritoneTweakerForge.java | 88 ++--- .../launch/BaritoneTweakerOptifine.java | 68 ++-- .../launch/mixins/MixinAnvilChunkLoader.java | 17 + .../baritone/launch/mixins/MixinBlockPos.java | 0 .../mixins/MixinChunkProviderServer.java | 17 + .../baritone/launch/mixins/MixinEntity.java | 0 .../launch/mixins/MixinEntityPlayerSP.java | 0 .../launch/mixins/MixinEntityRenderer.java | 0 .../launch/mixins/MixinGameSettings.java | 88 ++--- .../launch/mixins/MixinGuiContainer.java | 94 ++--- .../launch/mixins/MixinGuiScreen.java | 96 ++--- .../launch/mixins/MixinInventoryPlayer.java | 0 .../launch/mixins/MixinKeyBinding.java | 86 ++--- .../launch/mixins/MixinMinecraft.java | 352 +++++++++--------- .../mixins/MixinNetHandlerPlayClient.java | 0 .../launch/mixins/MixinNetworkManager.java | 0 .../launch/mixins/MixinWorldClient.java | 0 .../resources/mixins.baritone.json | 52 +-- 20 files changed, 578 insertions(+), 534 deletions(-) rename src/{main => launch}/java/baritone/launch/BaritoneTweaker.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/BaritoneTweakerForge.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/BaritoneTweakerOptifine.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinAnvilChunkLoader.java (65%) rename src/{main => launch}/java/baritone/launch/mixins/MixinBlockPos.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinChunkProviderServer.java (65%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntity.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntityPlayerSP.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntityRenderer.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinGameSettings.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinGuiContainer.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinGuiScreen.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinInventoryPlayer.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinKeyBinding.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinMinecraft.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinNetworkManager.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinWorldClient.java (100%) rename src/{main => launch}/resources/mixins.baritone.json (95%) mode change 100755 => 100644 diff --git a/build.gradle b/build.gradle index a3717498..86c29def 100755 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,12 @@ compileJava { sourceCompatibility = targetCompatibility = '1.8' } +sourceSets { + launch { + compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output + } +} + minecraft { version = '1.12.2' mappings = 'snapshot_20180731' @@ -64,7 +70,7 @@ repositories { } dependencies { - runtime implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') { + runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') { // Mixin includes a lot of dependencies that are too up-to-date exclude module: 'launchwrapper' exclude module: 'guava' @@ -79,3 +85,7 @@ mixin { defaultObfuscationEnv notch add sourceSets.main, 'mixins.baritone.refmap.json' } + +jar { + from sourceSets.launch.output +} diff --git a/src/main/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/BaritoneTweaker.java rename to src/launch/java/baritone/launch/BaritoneTweaker.java index 04941f79..e281ece3 --- a/src/main/java/baritone/launch/BaritoneTweaker.java +++ b/src/launch/java/baritone/launch/BaritoneTweaker.java @@ -1,71 +1,71 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.LaunchClassLoader; -import org.spongepowered.asm.launch.MixinBootstrap; -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.asm.mixin.Mixins; -import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 9:59 PM - */ -public class BaritoneTweaker implements ITweaker { - - List args; - - @Override - public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(args); - if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); - if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); - if (profile != null) addArg("version", profile); - } - - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) { - MixinBootstrap.init(); - MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); - MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH); - Mixins.addConfiguration("mixins.baritone.json"); - } - - @Override - public final String getLaunchTarget() { - return "net.minecraft.client.main.Main"; - } - - @Override - public final String[] getLaunchArguments() { - return this.args.toArray(new String[0]); - } - - private void addArg(String label, String value) { - if (!args.contains("--" + label) && value != null) { - this.args.add("--" + label); - this.args.add(value); - } - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.LaunchClassLoader; +import org.spongepowered.asm.launch.MixinBootstrap; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.Mixins; +import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 9:59 PM + */ +public class BaritoneTweaker implements ITweaker { + + List args; + + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(args); + if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); + if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); + if (profile != null) addArg("version", profile); + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) { + MixinBootstrap.init(); + MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); + MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH); + Mixins.addConfiguration("mixins.baritone.json"); + } + + @Override + public final String getLaunchTarget() { + return "net.minecraft.client.main.Main"; + } + + @Override + public final String[] getLaunchArguments() { + return this.args.toArray(new String[0]); + } + + private void addArg(String label, String value) { + if (!args.contains("--" + label) && value != null) { + this.args.add("--" + label); + this.args.add(value); + } + } +} diff --git a/src/main/java/baritone/launch/BaritoneTweakerForge.java b/src/launch/java/baritone/launch/BaritoneTweakerForge.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/BaritoneTweakerForge.java rename to src/launch/java/baritone/launch/BaritoneTweakerForge.java index 9a45520c..c1699058 --- a/src/main/java/baritone/launch/BaritoneTweakerForge.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerForge.java @@ -1,44 +1,44 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import net.minecraft.launchwrapper.LaunchClassLoader; -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:09 PM - */ -public class BaritoneTweakerForge extends BaritoneTweaker { - - @Override - public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(); - } - - @Override - public final void injectIntoClassLoader(LaunchClassLoader classLoader) { - super.injectIntoClassLoader(classLoader); - MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import net.minecraft.launchwrapper.LaunchClassLoader; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 10:09 PM + */ +public class BaritoneTweakerForge extends BaritoneTweaker { + + @Override + public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(); + } + + @Override + public final void injectIntoClassLoader(LaunchClassLoader classLoader) { + super.injectIntoClassLoader(classLoader); + MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE); + } +} diff --git a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/BaritoneTweakerOptifine.java rename to src/launch/java/baritone/launch/BaritoneTweakerOptifine.java index 380a0b0f..8d0872aa --- a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java @@ -1,34 +1,34 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:10 PM - */ -public class BaritoneTweakerOptifine extends BaritoneTweaker { - - @Override - public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 10:10 PM + */ +public class BaritoneTweakerOptifine extends BaritoneTweaker { + + @Override + public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java similarity index 65% rename from src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java rename to src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java index 96f38b87..3133c9cd 100644 --- a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java +++ b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java @@ -15,6 +15,23 @@ * along with Baritone. If not, see . */ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + package baritone.launch.mixins; import baritone.utils.accessor.IAnvilChunkLoader; diff --git a/src/main/java/baritone/launch/mixins/MixinBlockPos.java b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinBlockPos.java rename to src/launch/java/baritone/launch/mixins/MixinBlockPos.java diff --git a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java similarity index 65% rename from src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java rename to src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java index 9a454d01..41f90481 100644 --- a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java @@ -15,6 +15,23 @@ * along with Baritone. If not, see . */ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + package baritone.launch.mixins; import baritone.utils.accessor.IChunkProviderServer; diff --git a/src/main/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntity.java rename to src/launch/java/baritone/launch/mixins/MixinEntity.java diff --git a/src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java rename to src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java diff --git a/src/main/java/baritone/launch/mixins/MixinEntityRenderer.java b/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntityRenderer.java rename to src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java diff --git a/src/main/java/baritone/launch/mixins/MixinGameSettings.java b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinGameSettings.java rename to src/launch/java/baritone/launch/mixins/MixinGameSettings.java index b68cce51..f5bae8ef --- a/src/main/java/baritone/launch/mixins/MixinGameSettings.java +++ b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java @@ -1,44 +1,44 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.settings.GameSettings; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 8/1/2018 12:28 AM - */ -@Mixin(GameSettings.class) -public class MixinGameSettings { - - @Redirect( - method = "isKeyDown", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.settings.GameSettings; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 8/1/2018 12:28 AM + */ +@Mixin(GameSettings.class) +public class MixinGameSettings { + + @Redirect( + method = "isKeyDown", + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private static boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/mixins/MixinGuiContainer.java rename to src/launch/java/baritone/launch/mixins/MixinGuiContainer.java index dd9bf715..c2c62d76 --- a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java @@ -1,47 +1,47 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.inventory.GuiContainer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:47 PM - */ -@Mixin(GuiContainer.class) -public class MixinGuiContainer { - - @Redirect( - method = { - "mouseClicked", - "mouseReleased" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.gui.inventory.GuiContainer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 7/31/2018 10:47 PM + */ +@Mixin(GuiContainer.class) +public class MixinGuiContainer { + + @Redirect( + method = { + "mouseClicked", + "mouseReleased" + }, + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/mixins/MixinGuiScreen.java rename to src/launch/java/baritone/launch/mixins/MixinGuiScreen.java index 47877058..11a3e7f4 --- a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java +++ b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java @@ -1,48 +1,48 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.GuiScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:38 PM - */ -@Mixin(GuiScreen.class) -public class MixinGuiScreen { - - @Redirect( - method = { - "isCtrlKeyDown", - "isShiftKeyDown", - "isAltKeyDown" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 7/31/2018 10:38 PM + */ +@Mixin(GuiScreen.class) +public class MixinGuiScreen { + + @Redirect( + method = { + "isCtrlKeyDown", + "isShiftKeyDown", + "isAltKeyDown" + }, + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private static boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java b/src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java rename to src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java diff --git a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinKeyBinding.java rename to src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index db850188..838802cd --- a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -1,43 +1,43 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.settings.KeyBinding; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -/** - * @author Brady - * @since 7/31/2018 11:44 PM - */ -@Mixin(KeyBinding.class) -public class MixinKeyBinding { - - @Inject( - method = "isKeyDown", - at = @At("HEAD"), - cancellable = true - ) - private void isKeyDown(CallbackInfoReturnable cir) { - if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) - cir.setReturnValue(true); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.settings.KeyBinding; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * @author Brady + * @since 7/31/2018 11:44 PM + */ +@Mixin(KeyBinding.class) +public class MixinKeyBinding { + + @Inject( + method = "isKeyDown", + at = @At("HEAD"), + cancellable = true + ) + private void isKeyDown(CallbackInfoReturnable cir) { + if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) + cir.setReturnValue(true); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinMinecraft.java rename to src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 49c587ba..bc419516 --- a/src/main/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -1,176 +1,176 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import baritone.api.event.events.BlockInteractEvent; -import baritone.api.event.events.TickEvent; -import baritone.api.event.events.WorldEvent; -import baritone.api.event.events.type.EventState; -import baritone.behavior.impl.PathingBehavior; -import baritone.utils.ExampleBaritoneControl; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.lib.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -/** - * @author Brady - * @since 7/31/2018 10:51 PM - */ -@Mixin(Minecraft.class) -public class MixinMinecraft { - - @Shadow - private int leftClickCounter; - @Shadow - public EntityPlayerSP player; - @Shadow - public WorldClient world; - - @Inject( - method = "init", - at = @At("RETURN") - ) - private void init(CallbackInfo ci) { - Baritone.INSTANCE.init(); - ExampleBaritoneControl.INSTANCE.initAndRegister(); - } - - @Inject( - method = "runTick", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;", - ordinal = 5, - shift = At.Shift.BY, - by = -3 - ) - ) - private void runTick(CallbackInfo ci) { - Minecraft mc = (Minecraft) (Object) this; - Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent( - EventState.PRE, - (mc.player != null && mc.world != null) - ? TickEvent.Type.IN - : TickEvent.Type.OUT - )); - } - - @Redirect( - method = "runTickKeyboard", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean Keyboard$isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } - - @Inject( - method = "processKeyBinds", - at = @At("HEAD") - ) - private void runTickKeyboard(CallbackInfo ci) { - Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds(); - } - - @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", - at = @At("HEAD") - ) - private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { - // If we're unloading the world but one doesn't exist, ignore it - if (this.world == null && world == null) { - return; - } - - Baritone.INSTANCE.getGameEventHandler().onWorldEvent( - new WorldEvent( - world, - EventState.PRE - ) - ); - } - - @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", - at = @At("RETURN") - ) - private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { - // still fire event for both null, as that means we've just finished exiting a world - - Baritone.INSTANCE.getGameEventHandler().onWorldEvent( - new WorldEvent( - world, - EventState.POST - ) - ); - } - - @Redirect( - method = "runTick", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z" - ) - ) - private boolean isAllowUserInput(GuiScreen screen) { - return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput; - } - - @Inject( - method = "clickMouse", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z" - ), - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void onBlockBreak(CallbackInfo ci, BlockPos pos) { - Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK)); - } - - @Inject( - method = "rightClickMouse", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V" - ), - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { - Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import baritone.api.event.events.BlockInteractEvent; +import baritone.api.event.events.TickEvent; +import baritone.api.event.events.WorldEvent; +import baritone.api.event.events.type.EventState; +import baritone.behavior.impl.PathingBehavior; +import baritone.utils.ExampleBaritoneControl; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.lib.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +/** + * @author Brady + * @since 7/31/2018 10:51 PM + */ +@Mixin(Minecraft.class) +public class MixinMinecraft { + + @Shadow + private int leftClickCounter; + @Shadow + public EntityPlayerSP player; + @Shadow + public WorldClient world; + + @Inject( + method = "init", + at = @At("RETURN") + ) + private void init(CallbackInfo ci) { + Baritone.INSTANCE.init(); + ExampleBaritoneControl.INSTANCE.initAndRegister(); + } + + @Inject( + method = "runTick", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;", + ordinal = 5, + shift = At.Shift.BY, + by = -3 + ) + ) + private void runTick(CallbackInfo ci) { + Minecraft mc = (Minecraft) (Object) this; + Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent( + EventState.PRE, + (mc.player != null && mc.world != null) + ? TickEvent.Type.IN + : TickEvent.Type.OUT + )); + } + + @Redirect( + method = "runTickKeyboard", + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private boolean Keyboard$isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } + + @Inject( + method = "processKeyBinds", + at = @At("HEAD") + ) + private void runTickKeyboard(CallbackInfo ci) { + Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds(); + } + + @Inject( + method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", + at = @At("HEAD") + ) + private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { + // If we're unloading the world but one doesn't exist, ignore it + if (this.world == null && world == null) { + return; + } + + Baritone.INSTANCE.getGameEventHandler().onWorldEvent( + new WorldEvent( + world, + EventState.PRE + ) + ); + } + + @Inject( + method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", + at = @At("RETURN") + ) + private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { + // still fire event for both null, as that means we've just finished exiting a world + + Baritone.INSTANCE.getGameEventHandler().onWorldEvent( + new WorldEvent( + world, + EventState.POST + ) + ); + } + + @Redirect( + method = "runTick", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z" + ) + ) + private boolean isAllowUserInput(GuiScreen screen) { + return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput; + } + + @Inject( + method = "clickMouse", + at = @At( + value = "INVOKE", + target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + private void onBlockBreak(CallbackInfo ci, BlockPos pos) { + Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK)); + } + + @Inject( + method = "rightClickMouse", + at = @At( + value = "INVOKE", + target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { + Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java rename to src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java diff --git a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinNetworkManager.java rename to src/launch/java/baritone/launch/mixins/MixinNetworkManager.java diff --git a/src/main/java/baritone/launch/mixins/MixinWorldClient.java b/src/launch/java/baritone/launch/mixins/MixinWorldClient.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinWorldClient.java rename to src/launch/java/baritone/launch/mixins/MixinWorldClient.java diff --git a/src/main/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json old mode 100755 new mode 100644 similarity index 95% rename from src/main/resources/mixins.baritone.json rename to src/launch/resources/mixins.baritone.json index 989c9355..7f9bda48 --- a/src/main/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -1,27 +1,27 @@ -{ - "required": true, - "package": "baritone.launch.mixins", - "refmap": "mixins.baritone.refmap.json", - "compatibilityLevel": "JAVA_8", - "verbose": false, - "injectors": { - "maxShiftBy": 2 - }, - "client": [ - "MixinAnvilChunkLoader", - "MixinBlockPos", - "MixinChunkProviderServer", - "MixinEntity", - "MixinEntityPlayerSP", - "MixinEntityRenderer", - "MixinGameSettings", - "MixinGuiContainer", - "MixinGuiScreen", - "MixinInventoryPlayer", - "MixinKeyBinding", - "MixinMinecraft", - "MixinNetHandlerPlayClient", - "MixinNetworkManager", - "MixinWorldClient" - ] +{ + "required": true, + "package": "baritone.launch.mixins", + "refmap": "mixins.baritone.refmap.json", + "compatibilityLevel": "JAVA_8", + "verbose": false, + "injectors": { + "maxShiftBy": 2 + }, + "client": [ + "MixinAnvilChunkLoader", + "MixinBlockPos", + "MixinChunkProviderServer", + "MixinEntity", + "MixinEntityPlayerSP", + "MixinEntityRenderer", + "MixinGameSettings", + "MixinGuiContainer", + "MixinGuiScreen", + "MixinInventoryPlayer", + "MixinKeyBinding", + "MixinMinecraft", + "MixinNetHandlerPlayClient", + "MixinNetworkManager", + "MixinWorldClient" + ] } \ No newline at end of file From 2cf9a3a74bb3de1fed446f32824d1bde4e1ff3e6 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 18:50:53 -0500 Subject: [PATCH 049/329] Fix bad refmap SourceSet link --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 86c29def..8a2639f8 100755 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,7 @@ dependencies { mixin { defaultObfuscationEnv notch - add sourceSets.main, 'mixins.baritone.refmap.json' + add sourceSets.launch, 'mixins.baritone.refmap.json' } jar { From de84a49391f37b54a7eb2dc2b494357029b7657e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 17:13:42 -0700 Subject: [PATCH 050/329] fix tool set once and for all, fixes #136 --- .../launch/mixins/MixinInventoryPlayer.java | 62 ------- src/launch/resources/mixins.baritone.json | 1 - src/main/java/baritone/Baritone.java | 2 - src/main/java/baritone/Settings.java | 5 + .../baritone/api/event/GameEventHandler.java | 5 - .../listener/AbstractGameEventListener.java | 3 - .../event/listener/IGameEventListener.java | 10 -- .../baritone/pathing/movement/Movement.java | 2 +- .../pathing/movement/MovementHelper.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 156 ++++++------------ 10 files changed, 58 insertions(+), 190 deletions(-) delete mode 100644 src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java diff --git a/src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java b/src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java deleted file mode 100644 index dfaa4b19..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import baritone.api.event.events.ItemSlotEvent; -import net.minecraft.entity.player.InventoryPlayer; -import org.spongepowered.asm.lib.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 8/20/2018 - */ -@Mixin(InventoryPlayer.class) -public class MixinInventoryPlayer { - - @Redirect( - method = "getDestroySpeed", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/entity/player/InventoryPlayer.currentItem:I" - ) - ) - private int getDestroySpeed$getCurrentItem(InventoryPlayer inventory) { - ItemSlotEvent event = new ItemSlotEvent(inventory.currentItem); - Baritone.INSTANCE.getGameEventHandler().onQueryItemSlotForBlocks(event); - return event.getSlot(); - } - - @Redirect( - method = "canHarvestBlock", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/entity/player/InventoryPlayer.currentItem:I" - ) - ) - private int canHarvestBlock$getCurrentItem(InventoryPlayer inventory) { - ItemSlotEvent event = new ItemSlotEvent(inventory.currentItem); - Baritone.INSTANCE.getGameEventHandler().onQueryItemSlotForBlocks(event); - return event.getSlot(); - } -} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 7f9bda48..b1a8ed31 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -17,7 +17,6 @@ "MixinGameSettings", "MixinGuiContainer", "MixinGuiScreen", - "MixinInventoryPlayer", "MixinKeyBinding", "MixinMinecraft", "MixinNetHandlerPlayClient", diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 0b571264..5baacec8 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -21,7 +21,6 @@ import baritone.api.event.GameEventHandler; import baritone.behavior.Behavior; import baritone.behavior.impl.*; import baritone.utils.InputOverrideHandler; -import baritone.utils.ToolSet; import net.minecraft.client.Minecraft; import java.io.File; @@ -82,7 +81,6 @@ public enum Baritone { registerBehavior(LocationTrackingBehavior.INSTANCE); registerBehavior(FollowBehavior.INSTANCE); registerBehavior(MineBehavior.INSTANCE); - this.gameEventHandler.registerEventListener(ToolSet.INTERNAL_EVENT_LISTENER); } this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone"); if (!Files.exists(dir.toPath())) { diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 2e6f0e39..1eed4333 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -83,6 +83,11 @@ public class Settings { */ public Setting allowWalkOnBottomSlab = new Setting<>(true); + /** + * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly. + */ + public Setting considerPotionEffects = new Setting<>(true); + /** * This is the big A* setting. * As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path. diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 45e86885..1ec2d834 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -159,11 +159,6 @@ public final class GameEventHandler implements IGameEventListener, Helper { dispatch(listener -> listener.onReceivePacket(event)); } - @Override - public final void onQueryItemSlotForBlocks(ItemSlotEvent event) { - dispatch(listener -> listener.onQueryItemSlotForBlocks(event)); - } - @Override public void onPlayerRelativeMove(RelativeMoveEvent event) { dispatch(listener -> listener.onPlayerRelativeMove(event)); diff --git a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java index b47468bd..3b228e9d 100644 --- a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java +++ b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java @@ -74,9 +74,6 @@ public interface AbstractGameEventListener extends IGameEventListener { @Override default void onReceivePacket(PacketEvent event) {} - @Override - default void onQueryItemSlotForBlocks(ItemSlotEvent event) {} - @Override default void onPlayerRelativeMove(RelativeMoveEvent event) {} diff --git a/src/main/java/baritone/api/event/listener/IGameEventListener.java b/src/main/java/baritone/api/event/listener/IGameEventListener.java index 9be19aab..81f91774 100644 --- a/src/main/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/main/java/baritone/api/event/listener/IGameEventListener.java @@ -36,7 +36,6 @@ package baritone.api.event.listener; import baritone.api.event.events.*; import io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiGameOver; @@ -44,7 +43,6 @@ import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.util.text.ITextComponent; @@ -120,14 +118,6 @@ public interface IGameEventListener { */ void onReceivePacket(PacketEvent event); - /** - * Run when a query is made for a player's inventory current slot in the context of blocks - * - * @see InventoryPlayer#getDestroySpeed(IBlockState) - * @see InventoryPlayer#canHarvestBlock(IBlockState) - */ - void onQueryItemSlotForBlocks(ItemSlotEvent event); - /** * Run once per game tick from before and after the player's moveRelative method is called * diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 9d2f5869..5eba39ab 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -149,7 +149,7 @@ public abstract class Movement implements Helper, MovementHelper { somethingInTheWay = true; Optional reachable = LookBehaviorUtils.reachable(blockPos); if (reachable.isPresent()) { - player().inventory.currentItem = new ToolSet().getBestSlot(BlockStateInterface.get(blockPos)); + MovementHelper.switchToBestToolFor(BlockStateInterface.get(blockPos)); state.setTarget(new MovementState.MovementTarget(reachable.get(), true)).setInput(Input.CLICK_LEFT, true); return false; } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 82b20c41..06c880d8 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -261,7 +261,7 @@ public interface MovementHelper extends ActionCosts, Helper { return COST_INF; } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table - double result = m / context.getToolSet().getStrVsBlock(state, position); + double result = m / context.getToolSet().getStrVsBlock(state); if (includeFalling) { BlockPos up = position.up(); IBlockState above = BlockStateInterface.get(up); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index e8243ba6..8a97980c 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -17,55 +17,24 @@ package baritone.utils; -import baritone.api.event.events.ItemSlotEvent; -import baritone.api.event.listener.AbstractGameEventListener; +import baritone.Baritone; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.item.Item; -import net.minecraft.item.ItemAir; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.init.Enchantments; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; /** * A cached list of the best tools on the hotbar for any block * - * @author avecowa, Brady + * @author avecowa, Brady, leijurv */ public class ToolSet implements Helper { - /** - * Instance of the internal event listener used to hook into Baritone's event bus - */ - public static final InternalEventListener INTERNAL_EVENT_LISTENER = new InternalEventListener(); - - /** - * A list of tools on the hotbar that should be considered. - * Note that if there are no tools on the hotbar this list will still have one (null) entry. - */ - private List tools; - - /** - * A mapping from the tools array to what hotbar slots the tool is actually in. - * tools.get(i) will be on your hotbar in slot slots.get(i) - */ - private List slots; - - /** - * A mapping from a block to which tool index is best for it. - * The values in this map are *not* hotbar slots indexes, they need to be looked up in slots - * in order to be converted into hotbar slots. - */ - private Map slotCache = new HashMap<>(); - /** * A cache mapping a {@link Block} to how long it will take to break * with this toolset, given the optimum tool is used. @@ -75,30 +44,7 @@ public class ToolSet implements Helper { /** * Create a toolset from the current player's inventory (but don't calculate any hardness values just yet) */ - public ToolSet() { - EntityPlayerSP p = Minecraft.getMinecraft().player; - NonNullList inv = p.inventory.mainInventory; - tools = new ArrayList<>(); - slots = new ArrayList<>(); - boolean fnull = false; - for (byte i = 0; i < 9; i++) { - if (!fnull || ((!(inv.get(i).getItem() instanceof ItemAir)) && inv.get(i).getItem() instanceof ItemTool)) { - tools.add(inv.get(i).getItem() instanceof ItemTool ? (ItemTool) inv.get(i).getItem() : null); - slots.add(i); - fnull |= (inv.get(i).getItem() instanceof ItemAir) || (!inv.get(i).getItem().isDamageable()); - } - } - } - - /** - * A caching wrapper around getBestToolIndex - * - * @param state the blockstate to be mined - * @return get which tool on the hotbar is best for mining it - */ - public Item getBestTool(IBlockState state) { - return tools.get(slotCache.computeIfAbsent(state.getBlock(), block -> getBestToolIndex(state))); - } + public ToolSet() {} /** * Calculate which tool on the hotbar is best for mining @@ -106,15 +52,11 @@ public class ToolSet implements Helper { * @param b the blockstate to be mined * @return a byte indicating the index in the tools array that worked best */ - private byte getBestToolIndex(IBlockState b) { + public byte getBestSlot(IBlockState b) { byte best = 0; - float value = -1; - for (byte i = 0; i < tools.size(); i++) { - Item item = tools.get(i); - if (item == null) - continue; - - float v = item.getDestroySpeed(new ItemStack(item), b); + double value = -1; + for (byte i = 0; i < 9; i++) { + double v = calculateStrVsBlock(i, b); if (v > value || value == -1) { value = v; best = i; @@ -123,25 +65,14 @@ public class ToolSet implements Helper { return best; } - /** - * Get which hotbar slot should be selected for fastest mining - * - * @param state the blockstate to be mined - * @return a byte indicating which hotbar slot worked best - */ - public byte getBestSlot(IBlockState state) { - return slots.get(slotCache.computeIfAbsent(state.getBlock(), block -> getBestToolIndex(state))); - } - /** * Using the best tool on the hotbar, how long would it take to mine this block * * @param state the blockstate to be mined - * @param pos the blockpos to be mined * @return how long it would take in ticks */ - public double getStrVsBlock(IBlockState state, BlockPos pos) { - return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(state, pos)); + public double getStrVsBlock(IBlockState state) { + return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(getBestSlot(state), state)); } /** @@ -149,36 +80,51 @@ public class ToolSet implements Helper { * in this toolset is used. * * @param state the blockstate to be mined - * @param pos the blockpos to be mined * @return how long it would take in ticks */ - private double calculateStrVsBlock(IBlockState state, BlockPos pos) { + private double calculateStrVsBlock(byte slot, IBlockState state) { // Calculate the slot with the best item - byte slot = this.getBestSlot(state); + ItemStack contents = player().inventory.getStackInSlot(slot); - INTERNAL_EVENT_LISTENER.setOverrideSlot(slot); - - // Calculate the relative hardness of the block to the player - float hardness = state.getPlayerRelativeBlockHardness(player(), world(), pos); - - // Restore the old slot - INTERNAL_EVENT_LISTENER.setOverrideSlot(-1); - - return hardness; - } - - private static final class InternalEventListener implements AbstractGameEventListener { - - private int overrideSlot; - - @Override - public void onQueryItemSlotForBlocks(ItemSlotEvent event) { - if (this.overrideSlot >= 0) - event.setSlot(this.overrideSlot); + float blockHard = state.getBlockHardness(null, null); + if (blockHard < 0) { + return 0; } - final void setOverrideSlot(int overrideSlot) { - this.overrideSlot = overrideSlot; + float speed = contents.getDestroySpeed(state); + if (speed > 1) { + int effLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, contents); + if (effLevel > 0 && !contents.isEmpty()) { + speed += effLevel * effLevel + 1; + } + } + + if (Baritone.settings().considerPotionEffects.get()) { + if (player().isPotionActive(MobEffects.HASTE)) { + speed *= 1 + (player().getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2; + } + if (player().isPotionActive(MobEffects.MINING_FATIGUE)) { + switch (player().getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier()) { + case 0: + speed *= 0.3; + break; + case 1: + speed *= 0.09; + break; + case 2: + speed *= 0.0027; + break; + default: + speed *= 0.00081; + break; + } + } + } + speed /= blockHard; + if (state.getMaterial().isToolNotRequired() || (!contents.isEmpty() && contents.canHarvestBlock(state))) { + return speed / 30; + } else { + return speed / 100; } } } From db3aa5a7143c79f765638a73b90fbbfc07a55d7e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Sep 2018 19:52:06 -0700 Subject: [PATCH 051/329] lets allow it, fixes #137 --- src/main/java/baritone/pathing/movement/MovementHelper.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 06c880d8..6897d5a4 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -55,9 +55,7 @@ public interface MovementHelper extends ActionCosts, Helper { || BlockStateInterface.isLiquid(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())) || BlockStateInterface.isLiquid(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())) || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)) - || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)) - || (!(b instanceof BlockLilyPad && BlockStateInterface.isWater(below)) && below instanceof BlockLiquid);//if it's a lilypad above water, it's ok to break, otherwise don't break if its liquid - // TODO revisit this. why is it not okay to break non-lilypads that are right above water? + || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)); } /** From 008422680dfd03b220cbb44f87f548f3549a3631 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Sep 2018 21:08:18 -0700 Subject: [PATCH 052/329] that should NOT have been there --- .../java/baritone/pathing/movement/CalculationContext.java | 1 - .../baritone/pathing/movement/movements/MovementParkour.java | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/main/java/baritone/pathing/movement/movements/MovementParkour.java diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 2aca1f82..bd05ec5e 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -46,7 +46,6 @@ public class CalculationContext implements Helper { } public CalculationContext(ToolSet toolSet) { - player().setSprinting(true); this.toolSet = toolSet; this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(false); this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether(); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java new file mode 100644 index 00000000..56d7cbce --- /dev/null +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -0,0 +1,4 @@ +package baritone.pathing.movement.movements; + +public class MovementParkour { +} From 8a7013d8d3963884a8dff8cf113766f604e7128b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Sep 2018 21:31:36 -0700 Subject: [PATCH 053/329] add readme for gradlew run --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index b95cc957..ba4897ee 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,14 @@ the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. ## Command Line On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. + +Running Baritone: + +``` +$ gradlew run +``` + +Setting up for IntelliJ: ``` $ gradlew setupDecompWorkspace $ gradlew --refresh-dependencies From 63b04df95da2ca369a15060c882161055124b311 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Sep 2018 07:48:27 -0700 Subject: [PATCH 054/329] parkour --- FEATURES.md | 4 +- src/main/java/baritone/Settings.java | 5 + .../pathing/calc/AStarPathFinder.java | 6 +- .../baritone/pathing/movement/Movement.java | 4 + .../pathing/movement/MovementHelper.java | 34 ++++ .../movement/movements/MovementParkour.java | 151 ++++++++++++++++++ .../utils/pathing/BetterBlockPos.java | 6 + 7 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 src/main/java/baritone/pathing/movement/movements/MovementParkour.java diff --git a/FEATURES.md b/FEATURES.md index 998b546a..98bae9e2 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -9,6 +9,7 @@ - **Slabs and stairs** - **Falling blocks** Baritone understands the costs of breaking blocks with falling blocks on top, and includes all of their break costs. Additionally, since it avoids breaking any blocks touching a liquid, it won't break the bottom of a gravel stack below a lava lake (anymore). - **Avoiding dangerous blocks** Obviously, it knows not to walk through fire or on magma, not to corner over lava (that deals some damage), not to break any blocks touching a liquid (it might drown), etc. +- **Parkour** Sprint jumping over 1, 2, or 3 block gaps # Pathing method Baritone uses a modified version of A*. @@ -41,8 +42,7 @@ Things it doesn't have yet See issues for more. Things it may not ever have, from most likely to least likely =( -- Parkour (jumping over gaps of any length) -- Boats - Pigs +- Boats - Horses (2x3 path instead of 1x2) - Elytra diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 1eed4333..5bb57549 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -83,6 +83,11 @@ public class Settings { */ public Setting allowWalkOnBottomSlab = new Setting<>(true); + /** + * You know what it is + */ + public Setting allowParkour = new Setting<>(true); // disable in release because its sketchy af lol + /** * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly. */ diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 73442998..893d9686 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -233,7 +233,11 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.EAST), new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.EAST), - new MovementPillar(pos, new BetterBlockPos(x, y + 1, z)) + new MovementPillar(pos, new BetterBlockPos(x, y + 1, z)), + MovementParkour.calculate(pos, EnumFacing.NORTH), + MovementParkour.calculate(pos, EnumFacing.SOUTH), + MovementParkour.calculate(pos, EnumFacing.EAST), + MovementParkour.calculate(pos, EnumFacing.WEST), }; } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 5eba39ab..76871934 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -84,6 +84,10 @@ public abstract class Movement implements Helper, MovementHelper { return getCost(null); } + protected void override(double cost) { + this.cost = cost; + } + public double calculateCostWithoutCaching() { return calculateCost(new CalculationContext()); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6897d5a4..7c9a8c36 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -70,6 +70,9 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkThrough(BlockPos pos, IBlockState state) { Block block = state.getBlock(); + if (block == Blocks.AIR) { + return true; + } if (block instanceof BlockFire || block instanceof BlockTripWire || block instanceof BlockWeb @@ -106,6 +109,37 @@ public interface MovementHelper extends ActionCosts, Helper { return block.isPassable(mc.world, pos); } + /** + * canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click), + * not including water, and not including ladders or vines or cobwebs (they slow us down) + * + * @return + */ + static boolean fullyPassable(BlockPos pos) { + return fullyPassable(pos, BlockStateInterface.get(pos)); + } + + static boolean fullyPassable(BlockPos pos, IBlockState state) { + Block block = state.getBlock(); + if (block == Blocks.AIR) { + return true; + } + if (block == Blocks.FIRE + || block == Blocks.TRIPWIRE + || block == Blocks.WEB + || block == Blocks.VINE + || block == Blocks.LADDER + || block instanceof BlockDoor + || block instanceof BlockFenceGate + || block instanceof BlockSnow + || block instanceof BlockLiquid + || block instanceof BlockTrapDoor + || block instanceof BlockEndPortal) { + return false; + } + return block.isPassable(mc.world, pos); + } + static boolean isReplacable(BlockPos pos, IBlockState state) { // for MovementTraverse and MovementAscend // block double plant defaults to true when the block doesn't match, so don't need to check that case diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java new file mode 100644 index 00000000..3749e6ec --- /dev/null +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -0,0 +1,151 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.pathing.movement.movements; + +import baritone.Baritone; +import baritone.pathing.movement.CalculationContext; +import baritone.pathing.movement.Movement; +import baritone.pathing.movement.MovementHelper; +import baritone.pathing.movement.MovementState; +import baritone.utils.BlockStateInterface; +import baritone.utils.InputOverrideHandler; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; + +public class MovementParkour extends Movement { + + final EnumFacing direction; + final int dist; + + private MovementParkour(BlockPos src, int dist, EnumFacing dir) { + super(src, src.offset(dir, dist), new BlockPos[]{}); + this.direction = dir; + this.dist = dist; + super.override(costFromJumpDistance(dist)); + } + + public static MovementParkour calculate(BlockPos src, EnumFacing dir) { + if (!Baritone.settings().allowParkour.get()) { + return null; + } + IBlockState standingOn = BlockStateInterface.get(src.down()); + if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || MovementHelper.isBottomSlab(standingOn)) { + return null; + } + BlockPos adjBlock = src.down().offset(dir); + IBlockState adj = BlockStateInterface.get(adjBlock); + if (MovementHelper.avoidWalkingInto(adj.getBlock())) { // magma sucks + return null; + } + if (MovementHelper.canWalkOn(adjBlock, adj)) { // don't parkour if we could just traverse (for now) + return null; + } + + if (!MovementHelper.fullyPassable(src.offset(dir))) { + return null; + } + if (!MovementHelper.fullyPassable(src.up().offset(dir))) { + return null; + } + for (int i = 2; i <= 4; i++) { + BlockPos dest = src.offset(dir, i); + if (!MovementHelper.fullyPassable(dest)) { + return null; + } + if (!MovementHelper.fullyPassable(dest.up())) { + return null; + } + if (MovementHelper.canWalkOn(dest.down())) { + return new MovementParkour(src, i, dir); + } + } + return null; + } + + private static double costFromJumpDistance(int dist) { + switch (dist) { + case 2: + return WALK_ONE_BLOCK_COST * 2; // IDK LOL + case 3: + return WALK_ONE_BLOCK_COST * 3; + case 4: + return SPRINT_ONE_BLOCK_COST * 3; + } + throw new IllegalStateException("LOL"); + } + + + @Override + protected double calculateCost(CalculationContext context) { + if (!MovementHelper.canWalkOn(dest.down())) { + return COST_INF; + } + if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(src.down().offset(direction)).getBlock())) { + return COST_INF; + } + for (int i = 1; i <= 4; i++) { + BlockPos d = src.offset(direction, i); + if (!MovementHelper.fullyPassable(d)) { + return COST_INF; + } + if (!MovementHelper.fullyPassable(d.up())) { + return COST_INF; + } + if (d.equals(dest)) { + return costFromJumpDistance(i); + } + } + throw new IllegalStateException("invalid jump distance?"); + } + + @Override + public MovementState updateState(MovementState state) { + super.updateState(state); + switch (state.getStatus()) { + case WAITING: + state.setStatus(MovementState.MovementStatus.RUNNING); + case RUNNING: + break; + default: + return state; + } + if (dist >= 4) { + state.setInput(InputOverrideHandler.Input.SPRINT, true); + } + MovementHelper.moveTowards(state, dest); + if (playerFeet().equals(dest)) { + if (player().posY - playerFeet().getY() < 0.01) { + state.setStatus(MovementState.MovementStatus.SUCCESS); + } + } else if (!playerFeet().equals(src)) { + if (playerFeet().equals(src.offset(direction)) || player().posY - playerFeet().getY() > 0.0001) { + state.setInput(InputOverrideHandler.Input.JUMP, true); + } else { + state.setInput(InputOverrideHandler.Input.SPRINT, false); + if (playerFeet().equals(src.offset(direction, -1))) { + MovementHelper.moveTowards(state, src); + } else { + MovementHelper.moveTowards(state, src.offset(direction, -1)); + } + } + } + return state; + } +} \ No newline at end of file diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index ec8891f4..6a05c109 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -119,4 +119,10 @@ public final class BetterBlockPos extends BlockPos { Vec3i vec = dir.getDirectionVec(); return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ()); } + + @Override + public BlockPos offset(EnumFacing dir, int dist) { + Vec3i vec = dir.getDirectionVec(); + return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); + } } From 915b03a44e4d0c46b9f45a438c1f68b82b25bb34 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Sep 2018 07:54:12 -0700 Subject: [PATCH 055/329] lol --- .../baritone/pathing/movement/movements/MovementParkour.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 3749e6ec..05a88ded 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -86,7 +86,7 @@ public class MovementParkour extends Movement { case 3: return WALK_ONE_BLOCK_COST * 3; case 4: - return SPRINT_ONE_BLOCK_COST * 3; + return SPRINT_ONE_BLOCK_COST * 4; } throw new IllegalStateException("LOL"); } From b746e56631adf7ddf5048f31643277d830c29a76 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Sep 2018 10:13:50 -0700 Subject: [PATCH 056/329] lol you can't jump with a ceiling above you --- .../movement/movements/MovementParkour.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 05a88ded..edae2abf 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -66,11 +66,10 @@ public class MovementParkour extends Movement { } for (int i = 2; i <= 4; i++) { BlockPos dest = src.offset(dir, i); - if (!MovementHelper.fullyPassable(dest)) { - return null; - } - if (!MovementHelper.fullyPassable(dest.up())) { - return null; + for (int y = 0; y < 3; y++) { + if (!MovementHelper.fullyPassable(dest.up(y))) { + return null; + } } if (MovementHelper.canWalkOn(dest.down())) { return new MovementParkour(src, i, dir); @@ -102,11 +101,10 @@ public class MovementParkour extends Movement { } for (int i = 1; i <= 4; i++) { BlockPos d = src.offset(direction, i); - if (!MovementHelper.fullyPassable(d)) { - return COST_INF; - } - if (!MovementHelper.fullyPassable(d.up())) { - return COST_INF; + for (int y = 0; y < 3; y++) { + if (!MovementHelper.fullyPassable(d.up(y))) { + return COST_INF; + } } if (d.equals(dest)) { return costFromJumpDistance(i); From 9757422626984e78cc7dd81258d724c7582a03ec Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Sep 2018 10:14:41 -0700 Subject: [PATCH 057/329] also check where we might hit our head --- .../baritone/pathing/movement/movements/MovementParkour.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index edae2abf..40f9b5a3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -66,7 +66,8 @@ public class MovementParkour extends Movement { } for (int i = 2; i <= 4; i++) { BlockPos dest = src.offset(dir, i); - for (int y = 0; y < 3; y++) { + // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? + for (int y = 0; y < 4; y++) { if (!MovementHelper.fullyPassable(dest.up(y))) { return null; } @@ -101,7 +102,7 @@ public class MovementParkour extends Movement { } for (int i = 1; i <= 4; i++) { BlockPos d = src.offset(direction, i); - for (int y = 0; y < 3; y++) { + for (int y = 0; y < 4; y++) { if (!MovementHelper.fullyPassable(d.up(y))) { return COST_INF; } From e51c729acbd59ac49a58596ef956407b0a7e225c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Sep 2018 21:31:10 -0700 Subject: [PATCH 058/329] update in progress --- FEATURES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FEATURES.md b/FEATURES.md index 998b546a..397755eb 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -37,11 +37,11 @@ And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one o Things it doesn't have yet - Trapdoors - Sprint jumping in a 1x2 corridor +- Parkour (jumping over gaps of any length) [IN PROGRESS] See issues for more. Things it may not ever have, from most likely to least likely =( -- Parkour (jumping over gaps of any length) - Boats - Pigs - Horses (2x3 path instead of 1x2) From 0d515b336f1637b5dc633c89c2f466130581b416 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 10:50:49 -0700 Subject: [PATCH 059/329] can get to block at eye level adjacent too --- src/main/java/baritone/pathing/goals/GoalGetToBlock.java | 3 +++ src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index ed927a12..bc32c5ca 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -50,6 +50,9 @@ public class GoalGetToBlock implements Goal { if (yDiff == -2 && xDiff == 0 && zDiff == 0) { return true; } + if (yDiff == -1) { + yDiff = 0; + } return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1; } diff --git a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java index 3c3905aa..a908a8dd 100644 --- a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java +++ b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java @@ -30,7 +30,7 @@ public class GoalGetToBlockTest { @Test public void isInGoal() { - List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,1,0", "0,-1,0", "0,-2,0")); + List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,-1,1", "0,-1,-1", "1,-1,0", "-1,-1,0", "0,1,0", "0,-1,0", "0,-2,0")); for (int x = -10; x <= 10; x++) { for (int y = -10; y <= 10; y++) { for (int z = -10; z <= 10; z++) { From 439ff92727699e4c04f6f509141c579089a11098 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 13:33:51 -0700 Subject: [PATCH 060/329] crucial performance optimization --- src/main/java/baritone/pathing/goals/GoalGetToBlock.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index bc32c5ca..30937772 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -47,11 +47,8 @@ public class GoalGetToBlock implements Goal { int xDiff = pos.getX() - this.x; int yDiff = pos.getY() - this.y; int zDiff = pos.getZ() - this.z; - if (yDiff == -2 && xDiff == 0 && zDiff == 0) { - return true; - } - if (yDiff == -1) { - yDiff = 0; + if (yDiff < 0) { + yDiff++; } return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1; } From dcad5fb79e5f7ee24546a95c13169c63c909c65a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 13:34:34 -0700 Subject: [PATCH 061/329] shouldn't be on master yet --- .../baritone/pathing/movement/movements/MovementParkour.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/main/java/baritone/pathing/movement/movements/MovementParkour.java diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java deleted file mode 100644 index 56d7cbce..00000000 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ /dev/null @@ -1,4 +0,0 @@ -package baritone.pathing.movement.movements; - -public class MovementParkour { -} From 99323463e3ebfd2cd13c70074ffb59588de3afe8 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Sep 2018 19:00:36 -0500 Subject: [PATCH 062/329] Fix improper treatment of unbreakable blocks --- .../java/baritone/pathing/movement/MovementHelper.java | 6 +++++- src/main/java/baritone/utils/ToolSet.java | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6897d5a4..49fc5968 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -259,7 +259,11 @@ public interface MovementHelper extends ActionCosts, Helper { return COST_INF; } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table - double result = m / context.getToolSet().getStrVsBlock(state); + double strVsBlock = context.getToolSet().getStrVsBlock(state); + if (strVsBlock < 0) + return COST_INF; + + double result = m / strVsBlock; if (includeFalling) { BlockPos up = position.up(); IBlockState above = BlockStateInterface.get(up); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 8a97980c..e31fe09e 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -77,7 +77,7 @@ public class ToolSet implements Helper { /** * Calculates how long would it take to mine the specified block given the best tool - * in this toolset is used. + * in this toolset is used. A negative value is returned if the specified block is unbreakable. * * @param state the blockstate to be mined * @return how long it would take in ticks @@ -87,9 +87,8 @@ public class ToolSet implements Helper { ItemStack contents = player().inventory.getStackInSlot(slot); float blockHard = state.getBlockHardness(null, null); - if (blockHard < 0) { - return 0; - } + if (blockHard < 0) + return -1; float speed = contents.getDestroySpeed(state); if (speed > 1) { From d17cc96e90d560b6d6d8d3c50f710c9a085e3ca6 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Sep 2018 19:40:15 -0500 Subject: [PATCH 063/329] Constructor fix --- .../baritone/pathing/movement/movements/MovementDiagonal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 127d277c..1a11295e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -47,7 +47,7 @@ public class MovementDiagonal extends Movement { } public MovementDiagonal(BlockPos start, BlockPos end, BlockPos dir1, BlockPos dir2) { - super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}, new BlockPos[]{end.down()}); + super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); } @Override From 2d969b55ef36ba2f98ffd18a2ff57730b9de2aa9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 18:23:05 -0700 Subject: [PATCH 064/329] fix world scanner radius --- src/main/java/baritone/chunk/WorldScanner.java | 12 ++++++------ .../baritone/utils/interfaces/IGoalRenderPos.java | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/main/java/baritone/utils/interfaces/IGoalRenderPos.java diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 09edd1e5..27345670 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -47,13 +47,13 @@ public enum WorldScanner implements Helper { int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; - int searchRadius = 2; + int searchRadiusSq = 0; while (true) { boolean allUnloaded = true; - for (int xoff = -searchRadius; xoff <= searchRadius; xoff++) { - for (int zoff = -searchRadius; zoff <= searchRadius; zoff++) { + for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) { + for (int zoff = -searchRadiusSq; zoff <= searchRadiusSq; zoff++) { int distance = xoff * xoff + zoff * zoff; - if (distance != searchRadius) { + if (distance != searchRadiusSq) { continue; } int chunkX = xoff + playerChunkX; @@ -91,10 +91,10 @@ public enum WorldScanner implements Helper { if (allUnloaded) { return res; } - if (res.size() >= max) { + if (res.size() >= max && searchRadiusSq < 26) { return res; } - searchRadius++; + searchRadiusSq++; } } } diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java new file mode 100644 index 00000000..cdc7cd00 --- /dev/null +++ b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java @@ -0,0 +1,4 @@ +package baritone.utils.interfaces; + +public class IGoalRenderPos { +} From 85babda97e3d27dfe1fa427a29bdd2d1779f2c31 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 18:23:32 -0700 Subject: [PATCH 065/329] render more goals, fixes #25 --- .../baritone/pathing/goals/GoalBlock.java | 3 ++- .../pathing/goals/GoalGetToBlock.java | 3 ++- .../java/baritone/pathing/goals/GoalNear.java | 3 ++- .../baritone/pathing/goals/GoalTwoBlocks.java | 5 +++-- .../pathing/movement/MovementHelper.java | 1 + .../java/baritone/utils/PathRenderer.java | 13 ++++++----- .../utils/interfaces/IGoalRenderPos.java | 22 ++++++++++++++++++- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 78d7b87d..9e6ea556 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -24,7 +25,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalBlock implements Goal { +public class GoalBlock implements Goal, IGoalRenderPos { /** * The X block position of this goal diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 30937772..4e81018b 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; @@ -26,7 +27,7 @@ import net.minecraft.util.math.BlockPos; * * @author avecowa */ -public class GoalGetToBlock implements Goal { +public class GoalGetToBlock implements Goal, IGoalRenderPos { private final int x; private final int y; diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 2ec6bf1d..e78788ac 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -17,9 +17,10 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; -public class GoalNear implements Goal { +public class GoalNear implements Goal, IGoalRenderPos { final int x; final int y; final int z; diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 65571a49..021103a1 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -25,7 +26,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalTwoBlocks implements Goal { +public class GoalTwoBlocks implements Goal, IGoalRenderPos { /** * The X block position of this goal @@ -69,7 +70,7 @@ public class GoalTwoBlocks implements Goal { } public BlockPos getGoalPos() { - return new BlockPos(x, y, z); + return new BlockPos(x, y - 1, z); } @Override diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 7c9a8c36..1369a42f 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -124,6 +124,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.AIR) { return true; } + // exceptions - blocks that are isPassasble true, but we can't actually jump through if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 6fd3466e..c4ea8103 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -19,9 +19,10 @@ package baritone.utils; import baritone.Baritone; import baritone.pathing.goals.Goal; -import baritone.pathing.goals.GoalBlock; +import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -183,13 +184,13 @@ public final class PathRenderer implements Helper { double maxY; double y1; double y2; - if (goal instanceof GoalBlock) { - BlockPos goalPos = ((GoalBlock) goal).getGoalPos(); + if (goal instanceof IGoalRenderPos) { + BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos(); minX = goalPos.getX() + 0.002 - renderPosX; maxX = goalPos.getX() + 1 - 0.002 - renderPosX; minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; - double y = MathHelper.sin((float) (((float) (System.nanoTime() / 1000000L) % 2000L) / 2000F * Math.PI * 2)); + double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); y1 = 1 + y + goalPos.getY() - renderPosY; y2 = 1 - y + goalPos.getY() - renderPosY; minY = goalPos.getY() - renderPosY; @@ -207,7 +208,9 @@ public final class PathRenderer implements Helper { minY = 0 - renderPosY; maxY = 256 - renderPosY; } else { - // TODO GoalComposite + for (Goal g : ((GoalComposite) goal).goals()) { + drawLitDankGoalBox(player, g, partialTicks, color); + } return; } diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java index cdc7cd00..0aed1ea4 100644 --- a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java +++ b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java @@ -1,4 +1,24 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + package baritone.utils.interfaces; -public class IGoalRenderPos { +import net.minecraft.util.math.BlockPos; + +public interface IGoalRenderPos { + BlockPos getGoalPos(); } From 6ad9451798621a9b9c61d810c1579d585a7abb36 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 20:43:12 -0700 Subject: [PATCH 066/329] smaller cuter boxes for goaltwoblocks --- src/main/java/baritone/pathing/goals/GoalTwoBlocks.java | 2 +- src/main/java/baritone/utils/PathRenderer.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 021103a1..dcd8d17d 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -70,7 +70,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { } public BlockPos getGoalPos() { - return new BlockPos(x, y - 1, z); + return new BlockPos(x, y, z); } @Override diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index c4ea8103..8f3cf37b 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -20,6 +20,7 @@ package baritone.utils; import baritone.Baritone; import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; +import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; import baritone.utils.interfaces.IGoalRenderPos; @@ -191,10 +192,18 @@ public final class PathRenderer implements Helper { minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); + if (goal instanceof GoalTwoBlocks) { + y /= 2; + } y1 = 1 + y + goalPos.getY() - renderPosY; y2 = 1 - y + goalPos.getY() - renderPosY; minY = goalPos.getY() - renderPosY; maxY = minY + 2; + if (goal instanceof GoalTwoBlocks) { + y1 -= 0.5; + y2 -= 0.5; + maxY--; + } } else if (goal instanceof GoalXZ) { GoalXZ goalPos = (GoalXZ) goal; From 3261687ee08ecadbe37d1f1fb608501673e252a3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 18:23:32 -0700 Subject: [PATCH 067/329] render more goals, fixes #25 --- .../baritone/pathing/goals/GoalBlock.java | 3 ++- .../pathing/goals/GoalGetToBlock.java | 3 ++- .../java/baritone/pathing/goals/GoalNear.java | 3 ++- .../baritone/pathing/goals/GoalTwoBlocks.java | 5 ++-- .../java/baritone/utils/PathRenderer.java | 13 ++++++---- .../utils/interfaces/IGoalRenderPos.java | 24 +++++++++++++++++++ 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/main/java/baritone/utils/interfaces/IGoalRenderPos.java diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 78d7b87d..9e6ea556 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -24,7 +25,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalBlock implements Goal { +public class GoalBlock implements Goal, IGoalRenderPos { /** * The X block position of this goal diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 30937772..4e81018b 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; @@ -26,7 +27,7 @@ import net.minecraft.util.math.BlockPos; * * @author avecowa */ -public class GoalGetToBlock implements Goal { +public class GoalGetToBlock implements Goal, IGoalRenderPos { private final int x; private final int y; diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 2ec6bf1d..e78788ac 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -17,9 +17,10 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; -public class GoalNear implements Goal { +public class GoalNear implements Goal, IGoalRenderPos { final int x; final int y; final int z; diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 65571a49..021103a1 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -25,7 +26,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalTwoBlocks implements Goal { +public class GoalTwoBlocks implements Goal, IGoalRenderPos { /** * The X block position of this goal @@ -69,7 +70,7 @@ public class GoalTwoBlocks implements Goal { } public BlockPos getGoalPos() { - return new BlockPos(x, y, z); + return new BlockPos(x, y - 1, z); } @Override diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 6fd3466e..c4ea8103 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -19,9 +19,10 @@ package baritone.utils; import baritone.Baritone; import baritone.pathing.goals.Goal; -import baritone.pathing.goals.GoalBlock; +import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -183,13 +184,13 @@ public final class PathRenderer implements Helper { double maxY; double y1; double y2; - if (goal instanceof GoalBlock) { - BlockPos goalPos = ((GoalBlock) goal).getGoalPos(); + if (goal instanceof IGoalRenderPos) { + BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos(); minX = goalPos.getX() + 0.002 - renderPosX; maxX = goalPos.getX() + 1 - 0.002 - renderPosX; minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; - double y = MathHelper.sin((float) (((float) (System.nanoTime() / 1000000L) % 2000L) / 2000F * Math.PI * 2)); + double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); y1 = 1 + y + goalPos.getY() - renderPosY; y2 = 1 - y + goalPos.getY() - renderPosY; minY = goalPos.getY() - renderPosY; @@ -207,7 +208,9 @@ public final class PathRenderer implements Helper { minY = 0 - renderPosY; maxY = 256 - renderPosY; } else { - // TODO GoalComposite + for (Goal g : ((GoalComposite) goal).goals()) { + drawLitDankGoalBox(player, g, partialTicks, color); + } return; } diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java new file mode 100644 index 00000000..0aed1ea4 --- /dev/null +++ b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java @@ -0,0 +1,24 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.interfaces; + +import net.minecraft.util.math.BlockPos; + +public interface IGoalRenderPos { + BlockPos getGoalPos(); +} From 9052781889776458ede26003e951d0c78647d286 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 20:43:12 -0700 Subject: [PATCH 068/329] smaller cuter boxes for goaltwoblocks --- src/main/java/baritone/pathing/goals/GoalTwoBlocks.java | 2 +- src/main/java/baritone/utils/PathRenderer.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 021103a1..dcd8d17d 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -70,7 +70,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { } public BlockPos getGoalPos() { - return new BlockPos(x, y - 1, z); + return new BlockPos(x, y, z); } @Override diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index c4ea8103..8f3cf37b 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -20,6 +20,7 @@ package baritone.utils; import baritone.Baritone; import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; +import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; import baritone.utils.interfaces.IGoalRenderPos; @@ -191,10 +192,18 @@ public final class PathRenderer implements Helper { minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); + if (goal instanceof GoalTwoBlocks) { + y /= 2; + } y1 = 1 + y + goalPos.getY() - renderPosY; y2 = 1 - y + goalPos.getY() - renderPosY; minY = goalPos.getY() - renderPosY; maxY = minY + 2; + if (goal instanceof GoalTwoBlocks) { + y1 -= 0.5; + y2 -= 0.5; + maxY--; + } } else if (goal instanceof GoalXZ) { GoalXZ goalPos = (GoalXZ) goal; From 132e277388770dbd0d7a6b5ed3bbc47076eac925 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 21:32:25 -0700 Subject: [PATCH 069/329] { } --- .../java/baritone/launch/BaritoneTweaker.java | 12 +++++++--- .../launch/mixins/MixinEntityPlayerSP.java | 3 ++- .../launch/mixins/MixinKeyBinding.java | 3 ++- .../launch/mixins/MixinNetworkManager.java | 10 ++++---- .../baritone/api/event/GameEventHandler.java | 6 +++-- src/main/java/baritone/behavior/Behavior.java | 3 ++- .../baritone/behavior/impl/LookBehavior.java | 8 ++++--- .../behavior/impl/LookBehaviorUtils.java | 8 ++++--- .../behavior/impl/MemoryBehavior.java | 17 +++++++------- .../behavior/impl/PathingBehavior.java | 3 ++- src/main/java/baritone/chunk/CachedChunk.java | 3 ++- .../java/baritone/chunk/CachedRegion.java | 12 ++++++---- src/main/java/baritone/chunk/CachedWorld.java | 18 ++++++++++----- src/main/java/baritone/chunk/Waypoints.java | 3 ++- .../java/baritone/chunk/WorldProvider.java | 7 +++--- .../java/baritone/pathing/calc/PathNode.java | 3 ++- .../baritone/pathing/movement/Movement.java | 9 +++++--- .../pathing/movement/MovementHelper.java | 23 +++++++++++-------- .../movement/movements/MovementAscend.java | 3 ++- .../movement/movements/MovementDescend.java | 3 ++- .../movement/movements/MovementDiagonal.java | 3 ++- .../movement/movements/MovementDownward.java | 3 ++- .../movement/movements/MovementFall.java | 6 ++--- .../movement/movements/MovementPillar.java | 3 ++- .../movement/movements/MovementTraverse.java | 4 ++-- .../baritone/utils/BlockStateInterface.java | 3 ++- src/main/java/baritone/utils/ToolSet.java | 3 ++- 27 files changed, 114 insertions(+), 68 deletions(-) diff --git a/src/launch/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java index e281ece3..9638214c 100644 --- a/src/launch/java/baritone/launch/BaritoneTweaker.java +++ b/src/launch/java/baritone/launch/BaritoneTweaker.java @@ -39,9 +39,15 @@ public class BaritoneTweaker implements ITweaker { @Override public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { this.args = new ArrayList<>(args); - if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); - if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); - if (profile != null) addArg("version", profile); + if (gameDir != null) { + addArg("gameDir", gameDir.getAbsolutePath()); + } + if (assetsDir != null) { + addArg("assetsDir", assetsDir.getAbsolutePath()); + } + if (profile != null) { + addArg("version", profile); + } } @Override diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 9da39df3..9a45659e 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -42,8 +42,9 @@ public class MixinEntityPlayerSP { private void sendChatMessage(String msg, CallbackInfo ci) { ChatEvent event = new ChatEvent(msg); Baritone.INSTANCE.getGameEventHandler().onSendChatMessage(event); - if (event.isCancelled()) + if (event.isCancelled()) { ci.cancel(); + } } @Inject( diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 838802cd..4285c14d 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -37,7 +37,8 @@ public class MixinKeyBinding { cancellable = true ) private void isKeyDown(CallbackInfoReturnable cir) { - if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) + if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) { cir.setReturnValue(true); + } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index 46664e7c..b0fedc62 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -39,13 +39,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(NetworkManager.class) public class MixinNetworkManager { - @Shadow private Channel channel; + @Shadow + private Channel channel; @Inject( method = "dispatchPacket", at = @At("HEAD") ) - private void preDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { + private void preDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket)); } @@ -53,7 +54,7 @@ public class MixinNetworkManager { method = "dispatchPacket", at = @At("RETURN") ) - private void postDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { + private void postDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket)); } @@ -73,7 +74,8 @@ public class MixinNetworkManager { at = @At("RETURN") ) private void postProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (this.channel.isOpen()) + if (this.channel.isOpen()) { Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet)); + } } } diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 1ec2d834..af2a4020 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -80,8 +80,9 @@ public final class GameEventHandler implements IGameEventListener, Helper { if (inputHandler.isInputForcedDown(keyBinding) && !keyBinding.isKeyDown()) { int keyCode = keyBinding.getKeyCode(); - if (keyCode < Keyboard.KEYBOARD_SIZE) + if (keyCode < Keyboard.KEYBOARD_SIZE) { KeyBinding.onTick(keyCode < 0 ? keyCode + 100 : keyCode); + } } } @@ -141,8 +142,9 @@ public final class GameEventHandler implements IGameEventListener, Helper { break; case POST: cache.closeWorld(); - if (event.getWorld() != null) + if (event.getWorld() != null) { cache.initWorld(event.getWorld()); + } break; } diff --git a/src/main/java/baritone/behavior/Behavior.java b/src/main/java/baritone/behavior/Behavior.java index ad5e3a88..5bf6c5c6 100644 --- a/src/main/java/baritone/behavior/Behavior.java +++ b/src/main/java/baritone/behavior/Behavior.java @@ -52,8 +52,9 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper { @Override public final boolean setEnabled(boolean enabled) { boolean newState = getNewState(this.enabled, enabled); - if (newState == this.enabled) + if (newState == this.enabled) { return this.enabled; + } if (this.enabled = newState) { onStart(); diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java index 080d75d5..b740618a 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/impl/LookBehavior.java @@ -19,9 +19,9 @@ package baritone.behavior.impl; import baritone.Baritone; import baritone.Settings; -import baritone.behavior.Behavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RelativeMoveEvent; +import baritone.behavior.Behavior; import baritone.utils.Rotation; public class LookBehavior extends Behavior { @@ -57,8 +57,9 @@ public class LookBehavior extends Behavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - if (this.target == null) + if (this.target == null) { return; + } // Whether or not we're going to silently set our angles boolean silent = Baritone.settings().antiCheatCompatibility.get(); @@ -102,8 +103,9 @@ public class LookBehavior extends Behavior { player().rotationYaw = this.lastYaw; // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() - if (!Baritone.settings().antiCheatCompatibility.get()) + if (!Baritone.settings().antiCheatCompatibility.get()) { this.target = null; + } break; } } diff --git a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java index 91b046e0..a7896d03 100644 --- a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java @@ -67,9 +67,10 @@ public final class LookBehaviorUtils implements Helper { return Optional.of(new Rotation(mc.player.rotationYaw, mc.player.rotationPitch + 0.0001f)); } Optional possibleRotation = reachableCenter(pos); - System.out.println("center: " + possibleRotation); - if (possibleRotation.isPresent()) + //System.out.println("center: " + possibleRotation); + if (possibleRotation.isPresent()) { return possibleRotation; + } IBlockState state = BlockStateInterface.get(pos); AxisAlignedBB aabb = state.getBoundingBox(mc.world, pos); @@ -78,8 +79,9 @@ public final class LookBehaviorUtils implements Helper { double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y); double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z); possibleRotation = reachableOffset(pos, new Vec3d(pos).add(xDiff, yDiff, zDiff)); - if (possibleRotation.isPresent()) + if (possibleRotation.isPresent()) { return possibleRotation; + } } return Optional.empty(); } diff --git a/src/main/java/baritone/behavior/impl/MemoryBehavior.java b/src/main/java/baritone/behavior/impl/MemoryBehavior.java index 8f43a8e8..93657988 100644 --- a/src/main/java/baritone/behavior/impl/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/impl/MemoryBehavior.java @@ -1,9 +1,9 @@ package baritone.behavior.impl; -import baritone.behavior.Behavior; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; +import baritone.behavior.Behavior; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; import net.minecraft.network.play.client.CPacketCloseWindow; @@ -38,8 +38,9 @@ public class MemoryBehavior extends Behavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - if (event.getState() == EventState.PRE) + if (event.getState() == EventState.PRE) { updateInventory(); + } } @Override @@ -86,13 +87,13 @@ public class MemoryBehavior extends Behavior { this.futureInventories.stream() .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) .findFirst().ifPresent(matched -> { - // Remove the future inventory - this.futureInventories.remove(matched); + // Remove the future inventory + this.futureInventories.remove(matched); - // Setup the remembered inventory - RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); - inventory.windowId = packet.getWindowId(); - inventory.size = packet.getSlotCount(); + // Setup the remembered inventory + RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); + inventory.windowId = packet.getWindowId(); + inventory.size = packet.getSlotCount(); }); } diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index fa651a87..14060fba 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -389,8 +389,9 @@ public class PathingBehavior extends Behavior { }); long end = System.nanoTime(); //System.out.println((end - split) + " " + (split - start)); - // if (end - start > 0) + // if (end - start > 0) { // System.out.println("Frame took " + (split - start) + " " + (end - split)); + //} } } diff --git a/src/main/java/baritone/chunk/CachedChunk.java b/src/main/java/baritone/chunk/CachedChunk.java index 418a015e..56f7662a 100644 --- a/src/main/java/baritone/chunk/CachedChunk.java +++ b/src/main/java/baritone/chunk/CachedChunk.java @@ -199,7 +199,8 @@ public final class CachedChunk implements IBlockTypeAccess { * @throws IllegalArgumentException if the bitset size exceeds the maximum size */ private static void validateSize(BitSet data) { - if (data.size() > SIZE) + if (data.size() > SIZE) { throw new IllegalArgumentException("BitSet of invalid length provided"); + } } } diff --git a/src/main/java/baritone/chunk/CachedRegion.java b/src/main/java/baritone/chunk/CachedRegion.java index e15164e4..ee305527 100644 --- a/src/main/java/baritone/chunk/CachedRegion.java +++ b/src/main/java/baritone/chunk/CachedRegion.java @@ -112,13 +112,15 @@ public final class CachedRegion implements IBlockTypeAccess { } try { Path path = Paths.get(directory); - if (!Files.exists(path)) + if (!Files.exists(path)) { Files.createDirectories(path); + } System.out.println("Saving region " + x + "," + z + " to disk " + path); Path regionFile = getRegionFile(path, this.x, this.z); - if (!Files.exists(regionFile)) + if (!Files.exists(regionFile)) { Files.createFile(regionFile); + } try ( FileOutputStream fileOut = new FileOutputStream(regionFile.toFile()); GZIPOutputStream gzipOut = new GZIPOutputStream(fileOut, 16384); @@ -175,12 +177,14 @@ public final class CachedRegion implements IBlockTypeAccess { public synchronized void load(String directory) { try { Path path = Paths.get(directory); - if (!Files.exists(path)) + if (!Files.exists(path)) { Files.createDirectories(path); + } Path regionFile = getRegionFile(path, this.x, this.z); - if (!Files.exists(regionFile)) + if (!Files.exists(regionFile)) { return; + } System.out.println("Loading region " + x + "," + z + " from disk " + path); long start = System.nanoTime() / 1000000L; diff --git a/src/main/java/baritone/chunk/CachedWorld.java b/src/main/java/baritone/chunk/CachedWorld.java index 56d8ef38..14097c16 100644 --- a/src/main/java/baritone/chunk/CachedWorld.java +++ b/src/main/java/baritone/chunk/CachedWorld.java @@ -128,9 +128,11 @@ public final class CachedWorld implements IBlockTypeAccess { int regionX = xoff + playerRegionX; int regionZ = zoff + playerRegionZ; CachedRegion region = getOrCreateRegion(regionX, regionZ); - if (region != null) - for (BlockPos pos : region.getLocationsOf(block)) + if (region != null) { + for (BlockPos pos : region.getLocationsOf(block)) { res.add(pos); + } + } } } if (res.size() >= minimum) { @@ -153,8 +155,9 @@ public final class CachedWorld implements IBlockTypeAccess { } long start = System.nanoTime() / 1000000L; this.cachedRegions.values().parallelStream().forEach(region -> { - if (region != null) + if (region != null) { region.save(this.directory); + } }); long now = System.nanoTime() / 1000000L; System.out.println("World save took " + (now - start) + "ms"); @@ -163,8 +166,9 @@ public final class CachedWorld implements IBlockTypeAccess { public final void reloadAllFromDisk() { long start = System.nanoTime() / 1000000L; this.cachedRegions.values().forEach(region -> { - if (region != null) + if (region != null) { region.load(this.directory); + } }); long now = System.nanoTime() / 1000000L; System.out.println("World load took " + (now - start) + "ms"); @@ -199,8 +203,9 @@ public final class CachedWorld implements IBlockTypeAccess { public void forEachRegion(Consumer consumer) { this.cachedRegions.forEach((id, r) -> { - if (r != null) + if (r != null) { consumer.accept(r); + } }); } @@ -213,8 +218,9 @@ public final class CachedWorld implements IBlockTypeAccess { * @return The region ID */ private long getRegionID(int regionX, int regionZ) { - if (!isRegionInWorld(regionX, regionZ)) + if (!isRegionInWorld(regionX, regionZ)) { return 0; + } return (long) regionX & 0xFFFFFFFFL | ((long) regionZ & 0xFFFFFFFFL) << 32; } diff --git a/src/main/java/baritone/chunk/Waypoints.java b/src/main/java/baritone/chunk/Waypoints.java index d75ff733..ec587fea 100644 --- a/src/main/java/baritone/chunk/Waypoints.java +++ b/src/main/java/baritone/chunk/Waypoints.java @@ -61,8 +61,9 @@ public class Waypoints { waypoints.put(tag, new HashSet<>()); Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4"); - if (!Files.exists(fileName)) + if (!Files.exists(fileName)) { return; + } try ( FileInputStream fileIn = new FileInputStream(fileName.toFile()); diff --git a/src/main/java/baritone/chunk/WorldProvider.java b/src/main/java/baritone/chunk/WorldProvider.java index 275b6ac1..007f037d 100644 --- a/src/main/java/baritone/chunk/WorldProvider.java +++ b/src/main/java/baritone/chunk/WorldProvider.java @@ -18,9 +18,9 @@ package baritone.chunk; import baritone.Baritone; +import baritone.utils.Helper; import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; -import baritone.utils.Helper; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.WorldServer; @@ -69,7 +69,7 @@ public enum WorldProvider implements Helper { directory = new File(directory, "baritone"); readme = directory; - + } else { //remote directory = new File(Baritone.INSTANCE.getDir(), mc.getCurrentServerData().serverIP); @@ -102,7 +102,8 @@ public enum WorldProvider implements Helper { } public final void ifWorldLoaded(Consumer currentWorldConsumer) { - if (this.currentWorld != null) + if (this.currentWorld != null) { currentWorldConsumer.accept(this.currentWorld); + } } } diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 314c996b..ac6f8b8b 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -103,8 +103,9 @@ public class PathNode { // GOTTA GO FAST // ALL THESE CHECKS ARE FOR PEOPLE WHO WANT SLOW CODE // SKRT SKRT - //if (obj == null || !(obj instanceof PathNode)) + //if (obj == null || !(obj instanceof PathNode)) { // return false; + //} //final PathNode other = (PathNode) obj; //return Objects.equals(this.pos, other.pos) && Objects.equals(this.goal, other.goal); diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index d3d86463..d1e2230d 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -70,8 +70,9 @@ public abstract class Movement implements Helper, MovementHelper { public double getCost(CalculationContext context) { if (cost == null) { - if (context == null) + if (context == null) { context = new CalculationContext(); + } cost = calculateCost(context); } return cost; @@ -128,13 +129,15 @@ public abstract class Movement implements Helper, MovementHelper { }); latestState.getInputStates().replaceAll((input, forced) -> false); - if (!this.didBreakLastTick) + if (!this.didBreakLastTick) { BlockBreakHelper.stopBreakingBlock(); + } currentState = latestState; - if (isFinished()) + if (isFinished()) { onFinish(latestState); + } return currentState.getStatus(); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 49fc5968..f93ea82d 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -70,10 +70,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkThrough(BlockPos pos, IBlockState state) { Block block = state.getBlock(); - if (block instanceof BlockFire - || block instanceof BlockTripWire - || block instanceof BlockWeb - || block instanceof BlockEndPortal) {//you can't actually walk through a lilypad from the side, and you shouldn't walk through fire + if (block instanceof BlockFire || block instanceof BlockTripWire || block instanceof BlockWeb || block instanceof BlockEndPortal) { return false; } if (block instanceof BlockDoor || block instanceof BlockFenceGate) { @@ -127,30 +124,35 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) { - if (playerPos.equals(doorPos)) + if (playerPos.equals(doorPos)) { return false; + } IBlockState state = BlockStateInterface.get(doorPos); - if (!(state.getBlock() instanceof BlockDoor)) + if (!(state.getBlock() instanceof BlockDoor)) { return true; + } return isHorizontalBlockPassable(doorPos, state, playerPos, BlockDoor.OPEN); } static boolean isGatePassable(BlockPos gatePos, BlockPos playerPos) { - if (playerPos.equals(gatePos)) + if (playerPos.equals(gatePos)) { return false; + } IBlockState state = BlockStateInterface.get(gatePos); - if (!(state.getBlock() instanceof BlockFenceGate)) + if (!(state.getBlock() instanceof BlockFenceGate)) { return true; + } return isHorizontalBlockPassable(gatePos, state, playerPos, BlockFenceGate.OPEN); } static boolean isHorizontalBlockPassable(BlockPos blockPos, IBlockState blockState, BlockPos playerPos, PropertyBool propertyOpen) { - if (playerPos.equals(blockPos)) + if (playerPos.equals(blockPos)) { return false; + } EnumFacing.Axis facing = blockState.getValue(BlockHorizontal.FACING).getAxis(); boolean open = blockState.getValue(propertyOpen); @@ -260,8 +262,9 @@ public interface MovementHelper extends ActionCosts, Helper { } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table double strVsBlock = context.getToolSet().getStrVsBlock(state); - if (strVsBlock < 0) + if (strVsBlock < 0) { return COST_INF; + } double result = m / strVsBlock; if (includeFalling) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index e79929be..474fd162 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -123,8 +123,9 @@ public class MovementAscend extends Movement { super.updateState(state); // TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump // for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly) - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 86d9db99..d8d9d3b2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -67,8 +67,9 @@ public class MovementDescend extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } BlockPos playerFeet = playerFeet(); if (playerFeet.equals(dest)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 1a11295e..d343234c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -119,8 +119,9 @@ public class MovementDiagonal extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 3be854ad..9565e932 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -60,8 +60,9 @@ public class MovementDownward extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } if (playerFeet().equals(dest)) { state.setStatus(MovementState.MovementStatus.SUCCESS); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index db3b997a..40fa291d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -96,8 +96,9 @@ public class MovementFall extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementStatus.RUNNING) + if (state.getStatus() != MovementStatus.RUNNING) { return state; + } BlockPos playerFeet = playerFeet(); Rotation targetRotation = null; @@ -123,8 +124,7 @@ public class MovementFall extends Movement { } else { state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), false)); } - if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 // lilypads - || BlockStateInterface.isWater(dest))) { + if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 || BlockStateInterface.isWater(dest))) { // 0.094 because lilypads if (BlockStateInterface.isWater(dest) && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); if (player().motionY >= 0) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 6d5a1a05..6933a83f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -121,8 +121,9 @@ public class MovementPillar extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; + } IBlockState fromDown = BlockStateInterface.get(src); boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index b12088d9..44c594c0 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -125,9 +125,9 @@ public class MovementTraverse extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - if (state.getStatus() != MovementState.MovementStatus.RUNNING) + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { return state; - + } state.setInput(InputOverrideHandler.Input.SNEAK, false); Block fd = BlockStateInterface.get(src.down()).getBlock(); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index cd3ca646..efb83e36 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -35,8 +35,9 @@ public class BlockStateInterface implements Helper { public static IBlockState get(BlockPos pos) { // wrappers for chunk caching capability // Invalid vertical position - if (pos.getY() < 0 || pos.getY() >= 256) + if (pos.getY() < 0 || pos.getY() >= 256) { return Blocks.AIR.getDefaultState(); + } if (!Baritone.settings().pathThroughCachedOnly.get()) { Chunk cached = prev; diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index e31fe09e..9a6ca4d7 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -87,8 +87,9 @@ public class ToolSet implements Helper { ItemStack contents = player().inventory.getStackInSlot(slot); float blockHard = state.getBlockHardness(null, null); - if (blockHard < 0) + if (blockHard < 0) { return -1; + } float speed = contents.getDestroySpeed(state); if (speed > 1) { From 9577967da1a2e52056d9f4af280525ec750c4a71 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 8 Sep 2018 08:15:10 -0700 Subject: [PATCH 070/329] final --- src/main/java/baritone/pathing/calc/PathNode.java | 2 +- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index ac6f8b8b..45190fa7 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -26,7 +26,7 @@ import baritone.utils.pathing.BetterBlockPos; * * @author leijurv */ -public class PathNode { +public final class PathNode { /** * The position of this node diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index ec8891f4..53d20075 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -60,12 +60,12 @@ public final class BetterBlockPos extends BlockPos { } @Override - public final int hashCode() { + public int hashCode() { return (int) hashCode; } @Override - public final boolean equals(Object o) { + public boolean equals(Object o) { if (o == null) { return false; } From fadb17f3644a39ca26e7aafb24c7f41825562ec0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 8 Sep 2018 14:16:54 -0700 Subject: [PATCH 071/329] that was dumb --- src/main/java/baritone/utils/PathRenderer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 8f3cf37b..ae078268 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -216,11 +216,13 @@ public final class PathRenderer implements Helper { y2 = 0; minY = 0 - renderPosY; maxY = 256 - renderPosY; - } else { + } else if (goal instanceof GoalComposite) { for (Goal g : ((GoalComposite) goal).goals()) { drawLitDankGoalBox(player, g, partialTicks, color); } return; + } else { + return; } GlStateManager.enableBlend(); From b45a2c94eaaaac8c9f057456a1951e478a6324e5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 8 Sep 2018 20:45:40 -0700 Subject: [PATCH 072/329] direct invocation --- .../baritone/api/event/GameEventHandler.java | 89 ++++++++++++++----- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index af2a4020..32634213 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -49,7 +49,6 @@ import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; /** * @author Brady @@ -61,12 +60,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { @Override public final void onTick(TickEvent event) { - dispatch(listener -> listener.onTick(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onTick(event); + } + } } @Override public final void onPlayerUpdate(PlayerUpdateEvent event) { - dispatch(listener -> listener.onPlayerUpdate(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerUpdate(event); + } + } } @Override @@ -86,12 +93,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { } } - dispatch(IGameEventListener::onProcessKeyBinds); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onProcessKeyBinds(); + } + } } @Override public final void onSendChatMessage(ChatEvent event) { - dispatch(listener -> listener.onSendChatMessage(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onSendChatMessage(event); + } + } } @Override @@ -117,18 +132,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { } - dispatch(listener -> listener.onChunkEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onChunkEvent(event); + } + } } @Override public final void onRenderPass(RenderEvent event) { - /* - WorldProvider.INSTANCE.ifWorldLoaded(world -> world.forEachRegion(region -> region.forEachChunk(chunk -> { - drawChunkLine(region.getX() * 512 + chunk.getX() * 16, region.getZ() * 512 + chunk.getZ() * 16, event.getPartialTicks()); - }))); - */ - - dispatch(listener -> listener.onRenderPass(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onRenderPass(event); + } + } } @Override @@ -148,47 +165,71 @@ public final class GameEventHandler implements IGameEventListener, Helper { break; } - dispatch(listener -> listener.onWorldEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onWorldEvent(event); + } + } } @Override public final void onSendPacket(PacketEvent event) { - dispatch(listener -> listener.onSendPacket(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onSendPacket(event); + } + } } @Override public final void onReceivePacket(PacketEvent event) { - dispatch(listener -> listener.onReceivePacket(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onReceivePacket(event); + } + } } @Override public void onPlayerRelativeMove(RelativeMoveEvent event) { - dispatch(listener -> listener.onPlayerRelativeMove(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerRelativeMove(event); + } + } } @Override public void onBlockInteract(BlockInteractEvent event) { - dispatch(listener -> listener.onBlockInteract(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onBlockInteract(event); + } + } } @Override public void onPlayerDeath() { - dispatch(IGameEventListener::onPlayerDeath); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPlayerDeath(); + } + } } @Override public void onPathEvent(PathEvent event) { - dispatch(listener -> listener.onPathEvent(event)); + for (IGameEventListener l : listeners) { + if (canDispatch(l)) { + l.onPathEvent(event); + } + } } public final void registerEventListener(IGameEventListener listener) { this.listeners.add(listener); } - private void dispatch(Consumer dispatchFunction) { - this.listeners.stream().filter(this::canDispatch).forEach(dispatchFunction); - } - private boolean canDispatch(IGameEventListener listener) { return !(listener instanceof Toggleable) || ((Toggleable) listener).isEnabled(); } From b143dcff5f9670e498c277ecfafed572b9647949 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 9 Sep 2018 00:27:24 -0500 Subject: [PATCH 073/329] You can use it in COMPLIANCE --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba4897ee..cdd31b0d 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ PathingBehavior.INSTANCE.path(); ## Can I use Baritone as a library in my hacked client? -Sure! +Sure! (As long as usage is in compliance with the GPL 3 License) ## How is it so fast? From 489b9dea98efb1560412b69c2b77d1849b3cf2af Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 18:23:05 -0700 Subject: [PATCH 074/329] fix world scanner radius --- src/main/java/baritone/chunk/WorldScanner.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 09edd1e5..27345670 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -47,13 +47,13 @@ public enum WorldScanner implements Helper { int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; - int searchRadius = 2; + int searchRadiusSq = 0; while (true) { boolean allUnloaded = true; - for (int xoff = -searchRadius; xoff <= searchRadius; xoff++) { - for (int zoff = -searchRadius; zoff <= searchRadius; zoff++) { + for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) { + for (int zoff = -searchRadiusSq; zoff <= searchRadiusSq; zoff++) { int distance = xoff * xoff + zoff * zoff; - if (distance != searchRadius) { + if (distance != searchRadiusSq) { continue; } int chunkX = xoff + playerChunkX; @@ -91,10 +91,10 @@ public enum WorldScanner implements Helper { if (allUnloaded) { return res; } - if (res.size() >= max) { + if (res.size() >= max && searchRadiusSq < 26) { return res; } - searchRadius++; + searchRadiusSq++; } } } From 02ebc1947be5b5b4957a05808fc71984e4c3e837 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 07:18:03 -0700 Subject: [PATCH 075/329] actually disable by default --- src/main/java/baritone/Settings.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 5bb57549..bfab655e 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -85,8 +85,10 @@ public class Settings { /** * You know what it is + *

+ * But it's very unreliable and falls off when cornering like all the time so. */ - public Setting allowParkour = new Setting<>(true); // disable in release because its sketchy af lol + public Setting allowParkour = new Setting<>(false); /** * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly. From 387e27e8de2e5af210f9dec0437dad99133b6d0b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 08:11:33 -0700 Subject: [PATCH 076/329] movementhelper overhaul --- .../pathing/movement/MovementHelper.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 79ad6371..832663cc 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -73,7 +73,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.AIR) { return true; } - if (block instanceof BlockFire || block instanceof BlockTripWire || block instanceof BlockWeb || block instanceof BlockEndPortal) { + if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL) { return false; } if (block instanceof BlockDoor || block instanceof BlockFenceGate) { @@ -206,10 +206,11 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidWalkingInto(Block block) { return BlockStateInterface.isLava(block) - || block instanceof BlockCactus - || block instanceof BlockFire - || block instanceof BlockEndPortal - || block instanceof BlockWeb; + || block == Blocks.MAGMA + || block == Blocks.CACTUS + || block == Blocks.FIRE + || block == Blocks.END_PORTAL + || block == Blocks.WEB; } /** @@ -221,31 +222,22 @@ public interface MovementHelper extends ActionCosts, Helper { */ static boolean canWalkOn(BlockPos pos, IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR) { + if (block == Blocks.AIR || block == Blocks.MAGMA) { return false; } - if (block instanceof BlockLadder || (Baritone.settings().allowVines.get() && block instanceof BlockVine)) { // TODO reconsider this - return true; - } - if (block instanceof BlockGlass || block instanceof BlockStainedGlass) { - return true; - } - if (Blocks.FARMLAND.equals(block) || Blocks.GRASS_PATH.equals(block)) { - return true; - } - if (Blocks.ENDER_CHEST.equals(block) || Blocks.CHEST.equals(block)) { - return true; - } - if (block instanceof BlockSlab) { - if (!Baritone.settings().allowWalkOnBottomSlab.get()) { - if (((BlockSlab) block).isDouble()) { - return true; - } - return state.getValue(BlockSlab.HALF) != BlockSlab.EnumBlockHalf.BOTTOM; + if (state.isBlockNormalCube()) { + if (BlockStateInterface.isLava(block) || BlockStateInterface.isWater(block)) { + throw new IllegalStateException(); } return true; } - if (block instanceof BlockStairs) { + if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.get())) { // TODO reconsider this + return true; + } + if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) { + return true; + } + if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) { return true; } if (BlockStateInterface.isWater(block)) { @@ -261,20 +253,28 @@ public interface MovementHelper extends ActionCosts, Helper { // if assumeWalkOnWater is off, we can only walk on water if there is water above it return BlockStateInterface.isWater(up) ^ Baritone.settings().assumeWalkOnWater.get(); } - if (Blocks.MAGMA.equals(block)) { - return false; + if (block instanceof BlockGlass || block instanceof BlockStainedGlass) { + return true; } - return state.isBlockNormalCube() && !BlockStateInterface.isLava(block); + if (block instanceof BlockSlab) { + if (!Baritone.settings().allowWalkOnBottomSlab.get()) { + if (((BlockSlab) block).isDouble()) { + return true; + } + return state.getValue(BlockSlab.HALF) != BlockSlab.EnumBlockHalf.BOTTOM; + } + return true; + } + if (block instanceof BlockStairs) { + return true; + } + return false; } static boolean canWalkOn(BlockPos pos) { return canWalkOn(pos, BlockStateInterface.get(pos)); } - static boolean canFall(BlockPos pos) { - return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling; - } - static boolean canPlaceAgainst(BlockPos pos) { IBlockState state = BlockStateInterface.get(pos); // TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it @@ -288,7 +288,7 @@ public interface MovementHelper extends ActionCosts, Helper { static double getMiningDurationTicks(CalculationContext context, BlockPos position, IBlockState state, boolean includeFalling) { Block block = state.getBlock(); - if (!block.equals(Blocks.AIR) && !canWalkThrough(position, state)) { // TODO is the air check really necessary? Isn't air canWalkThrough? + if (!canWalkThrough(position, state)) { if (!context.allowBreak()) { return COST_INF; } From b69acadca6f43fc585dd378dec7eae7ddd9dd1e9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 08:53:15 -0700 Subject: [PATCH 077/329] start of blockstateinterface overhaul --- .../movement/movements/MovementAscend.java | 2 +- .../baritone/utils/BlockStateInterface.java | 42 ++++++++----------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 474fd162..1177b376 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -69,7 +69,7 @@ public class MovementAscend extends Movement { if (!context.hasThrowaway()) { return COST_INF; } - if (!BlockStateInterface.isAir(toPlace) && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { + if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { return COST_INF; } // TODO: add ability to place against .down() as well as the cardinal directions diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index efb83e36..4fa2449d 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -21,21 +21,29 @@ import baritone.Baritone; import baritone.chunk.WorldData; import baritone.chunk.WorldProvider; import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; +/** + * Wraps get for chuck caching capability + * + * @author leijurv + */ public class BlockStateInterface implements Helper { private static Chunk prev = null; - public static IBlockState get(BlockPos pos) { // wrappers for chunk caching capability + public static IBlockState get(BlockPos pos) { + return get(pos.getX(), pos.getY(), pos.getZ()); + } + + public static IBlockState get(int x, int y, int z) { // Invalid vertical position - if (pos.getY() < 0 || pos.getY() >= 256) { + if (y < 0 || y >= 256) { return Blocks.AIR.getDefaultState(); } @@ -46,18 +54,18 @@ public class BlockStateInterface implements Helper { // if it's the same chunk as last time // we can just skip the mc.world.getChunk lookup // which is a Long2ObjectOpenHashMap.get - if (cached != null && cached.x == pos.getX() >> 4 && cached.z == pos.getZ() >> 4) { - return cached.getBlockState(pos); + if (cached != null && cached.x == x >> 4 && cached.z == z >> 4) { + return cached.getBlockState(x, y, z); } - Chunk chunk = mc.world.getChunk(pos); + Chunk chunk = mc.world.getChunk(x >> 4, z >> 4); if (chunk.isLoaded()) { prev = chunk; - return chunk.getBlockState(pos); + return chunk.getBlockState(x, y, z); } } WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); if (world != null) { - IBlockState type = world.cache.getBlock(pos); + IBlockState type = world.cache.getBlock(x, y, z); if (type != null) { return type; } @@ -88,7 +96,7 @@ public class BlockStateInterface implements Helper { * @return Whether or not the block is water */ public static boolean isWater(Block b) { - return waterFlowing.equals(b) || waterStill.equals(b); + return b == waterFlowing || b == waterStill; } /** @@ -103,7 +111,7 @@ public class BlockStateInterface implements Helper { } public static boolean isLava(Block b) { - return lavaFlowing.equals(b) || lavaStill.equals(b); + return b == lavaFlowing || b == lavaStill; } /** @@ -122,18 +130,4 @@ public class BlockStateInterface implements Helper { && state.getPropertyKeys().contains(BlockLiquid.LEVEL) && state.getValue(BlockLiquid.LEVEL) != 0; } - - public static boolean isAir(BlockPos pos) { - return BlockStateInterface.getBlock(pos).equals(Blocks.AIR); - } - - public static boolean isAir(IBlockState state) { - return state.getBlock().equals(Blocks.AIR); - } - - static boolean canFall(BlockPos pos) { - return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling; - } - - } From a8ef421757b5eb76d6af7d0cc830dd0a6144ba5d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 08:57:20 -0700 Subject: [PATCH 078/329] epic performance --- .../pathing/movement/MovementHelper.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 832663cc..1dbcfae5 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -48,14 +48,18 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockPos pos, IBlockState state) { Block b = state.getBlock(); - Block below = BlockStateInterface.get(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock(); - return Blocks.ICE.equals(b) // ice becomes water, and water can mess up the path + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + Block below = BlockStateInterface.get(x, y - 1, z).getBlock(); + return b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons - || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))//don't break anything touching liquid on any side - || BlockStateInterface.isLiquid(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())) - || BlockStateInterface.isLiquid(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())) - || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)) - || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)); + // call BlockStateInterface.get directly with x,y,z. no need to make 5 new BlockPos for no reason + || BlockStateInterface.get(x, y + 1, z) instanceof BlockLiquid//don't break anything touching liquid on any side + || BlockStateInterface.get(x + 1, y, z) instanceof BlockLiquid + || BlockStateInterface.get(x - 1, y, z) instanceof BlockLiquid + || BlockStateInterface.get(x, y, z + 1) instanceof BlockLiquid + || BlockStateInterface.get(x, y, z - 1) instanceof BlockLiquid; } /** From dce51d856b20ec13f2fca4b7ac3b12a23f3662fd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 08:58:36 -0700 Subject: [PATCH 079/329] more specific return type --- .../java/baritone/utils/pathing/BetterBlockPos.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index d25812c0..3cf47478 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -83,7 +83,7 @@ public final class BetterBlockPos extends BlockPos { } @Override - public BlockPos up() { + public BetterBlockPos up() { // this is unimaginably faster than blockpos.up // that literally calls // this.up(1) @@ -97,31 +97,31 @@ public final class BetterBlockPos extends BlockPos { } @Override - public BlockPos up(int amt) { + public BetterBlockPos up(int amt) { // see comment in up() return amt == 0 ? this : new BetterBlockPos(x, y + amt, z); } @Override - public BlockPos down() { + public BetterBlockPos down() { // see comment in up() return new BetterBlockPos(x, y - 1, z); } @Override - public BlockPos down(int amt) { + public BetterBlockPos down(int amt) { // see comment in up() return new BetterBlockPos(x, y - amt, z); } @Override - public BlockPos offset(EnumFacing dir) { + public BetterBlockPos offset(EnumFacing dir) { Vec3i vec = dir.getDirectionVec(); return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ()); } @Override - public BlockPos offset(EnumFacing dir, int dist) { + public BetterBlockPos offset(EnumFacing dir, int dist) { Vec3i vec = dir.getDirectionVec(); return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); } From 760f68cb059e8297ebb1b158b958bba30656a9a5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 09:22:35 -0700 Subject: [PATCH 080/329] instead of casting to BetterBlockPos at runtime, let the compiler verify that --- .../java/baritone/pathing/calc/AStarPathFinder.java | 2 +- .../java/baritone/pathing/movement/Movement.java | 13 +++++++------ .../baritone/pathing/movement/MovementHelper.java | 5 +++-- .../pathing/movement/movements/MovementAscend.java | 7 ++++--- .../pathing/movement/movements/MovementDescend.java | 3 ++- .../movement/movements/MovementDiagonal.java | 7 ++++--- .../movement/movements/MovementDownward.java | 3 ++- .../pathing/movement/movements/MovementFall.java | 3 ++- .../pathing/movement/movements/MovementParkour.java | 5 +++-- .../pathing/movement/movements/MovementPillar.java | 5 +++-- .../movement/movements/MovementTraverse.java | 3 ++- 11 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 893d9686..7435c3f0 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -109,7 +109,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { if (movementToGetToNeighbor == null) { continue; } - BetterBlockPos dest = (BetterBlockPos) movementToGetToNeighbor.getDest(); + BetterBlockPos dest = movementToGetToNeighbor.getDest(); int chunkX = currentNodePos.x >> 4; int chunkZ = currentNodePos.z >> 4; if (dest.x >> 4 != chunkX || dest.z >> 4 != chunkZ) { diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 0ee4a35f..ddf36034 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -22,6 +22,7 @@ import baritone.behavior.impl.LookBehavior; import baritone.behavior.impl.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.*; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -39,9 +40,9 @@ public abstract class Movement implements Helper, MovementHelper { private MovementState currentState = new MovementState().setStatus(MovementStatus.PREPPING); - protected final BlockPos src; + protected final BetterBlockPos src; - protected final BlockPos dest; + protected final BetterBlockPos dest; /** * The positions that need to be broken before this movement can ensue @@ -57,14 +58,14 @@ public abstract class Movement implements Helper, MovementHelper { private Double cost; - protected Movement(BlockPos src, BlockPos dest, BlockPos[] toBreak, BlockPos toPlace) { + protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) { this.src = src; this.dest = dest; this.positionsToBreak = toBreak; this.positionToPlace = toPlace; } - protected Movement(BlockPos src, BlockPos dest, BlockPos[] toBreak) { + protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak) { this(src, dest, toBreak, null); } @@ -185,11 +186,11 @@ public abstract class Movement implements Helper, MovementHelper { && currentState.getStatus() != MovementStatus.WAITING); } - public BlockPos getSrc() { + public BetterBlockPos getSrc() { return src; } - public BlockPos getDest() { + public BetterBlockPos getDest() { return dest; } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1dbcfae5..6aa2f5e0 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -23,6 +23,7 @@ import baritone.pathing.movement.MovementState.MovementTarget; import baritone.pathing.movement.movements.MovementDescend; import baritone.pathing.movement.movements.MovementFall; import baritone.utils.*; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; @@ -401,7 +402,7 @@ public interface MovementHelper extends ActionCosts, Helper { )).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); } - static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) { + static Movement generateMovementFallOrDescend(BetterBlockPos pos, BetterBlockPos dest, CalculationContext calcContext) { // A //SA // A @@ -423,7 +424,7 @@ public interface MovementHelper extends ActionCosts, Helper { // we're clear for a fall 2 // let's see how far we can fall for (int fallHeight = 3; true; fallHeight++) { - BlockPos onto = dest.down(fallHeight); + BetterBlockPos onto = dest.down(fallHeight); if (onto.getY() < 0) { // when pathing in the end, where you could plausibly fall into the void // this check prevents it from getting the block at y=-1 and crashing diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 1177b376..9ddb7760 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -26,6 +26,7 @@ import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; @@ -41,7 +42,7 @@ public class MovementAscend extends Movement { private int ticksWithoutPlacement = 0; - public MovementAscend(BlockPos src, BlockPos dest) { + public MovementAscend(BetterBlockPos src, BetterBlockPos dest) { super(src, dest, new BlockPos[]{dest, src.up(2), dest.up()}, dest.down()); } @@ -155,8 +156,8 @@ public class MovementAscend extends Movement { if (player().isSneaking()) { state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } - if (ticksWithoutPlacement > 20) { - // After 20 ticks without placement, we might be standing in the way, move back + if (ticksWithoutPlacement > 10) { + // After 10 ticks without placement, we might be standing in the way, move back state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); } } else { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index d8d9d3b2..593c410a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -24,13 +24,14 @@ import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; public class MovementDescend extends Movement { - public MovementDescend(BlockPos start, BlockPos end) { + public MovementDescend(BetterBlockPos start, BetterBlockPos end) { super(start, end, new BlockPos[]{end.up(2), end.up(), end}, end.down()); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index d343234c..121ea7c7 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -23,6 +23,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.BlockMagma; import net.minecraft.block.state.IBlockState; @@ -37,16 +38,16 @@ public class MovementDiagonal extends Movement { private static final double SQRT_2 = Math.sqrt(2); - public MovementDiagonal(BlockPos start, EnumFacing dir1, EnumFacing dir2) { + public MovementDiagonal(BetterBlockPos start, EnumFacing dir1, EnumFacing dir2) { this(start, start.offset(dir1), start.offset(dir2), dir2); // super(start, start.offset(dir1).offset(dir2), new BlockPos[]{start.offset(dir1), start.offset(dir1).up(), start.offset(dir2), start.offset(dir2).up(), start.offset(dir1).offset(dir2), start.offset(dir1).offset(dir2).up()}, new BlockPos[]{start.offset(dir1).offset(dir2).down()}); } - public MovementDiagonal(BlockPos start, BlockPos dir1, BlockPos dir2, EnumFacing drr2) { + private MovementDiagonal(BetterBlockPos start, BetterBlockPos dir1, BetterBlockPos dir2, EnumFacing drr2) { this(start, dir1.offset(drr2), dir1, dir2); } - public MovementDiagonal(BlockPos start, BlockPos end, BlockPos dir1, BlockPos dir2) { + private MovementDiagonal(BetterBlockPos start, BetterBlockPos end, BetterBlockPos dir1, BetterBlockPos dir2) { super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 9565e932..48d26161 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -22,6 +22,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -31,7 +32,7 @@ public class MovementDownward extends Movement { private int numTicks = 0; - public MovementDownward(BlockPos start, BlockPos end) { + public MovementDownward(BetterBlockPos start, BetterBlockPos end) { super(start, end, new BlockPos[]{end}); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 40fa291d..dbcde285 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; @@ -41,7 +42,7 @@ public class MovementFall extends Movement { private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET); private static final ItemStack STACK_BUCKET_EMPTY = new ItemStack(Items.BUCKET); - public MovementFall(BlockPos src, BlockPos dest) { + public MovementFall(BetterBlockPos src, BetterBlockPos dest) { super(src, dest, MovementFall.buildPositionsToBreak(src, dest)); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 40f9b5a3..1041ae07 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -24,6 +24,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; @@ -34,14 +35,14 @@ public class MovementParkour extends Movement { final EnumFacing direction; final int dist; - private MovementParkour(BlockPos src, int dist, EnumFacing dir) { + private MovementParkour(BetterBlockPos src, int dist, EnumFacing dir) { super(src, src.offset(dir, dist), new BlockPos[]{}); this.direction = dir; this.dist = dist; super.override(costFromJumpDistance(dist)); } - public static MovementParkour calculate(BlockPos src, EnumFacing dir) { + public static MovementParkour calculate(BetterBlockPos src, EnumFacing dir) { if (!Baritone.settings().allowParkour.get()) { return null; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 6933a83f..73a591ad 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -25,6 +25,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Rotation; import baritone.utils.Utils; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -33,7 +34,7 @@ import net.minecraft.util.math.BlockPos; public class MovementPillar extends Movement { private int numTicks = 0; - public MovementPillar(BlockPos start, BlockPos end) { + public MovementPillar(BetterBlockPos start, BetterBlockPos end) { super(start, end, new BlockPos[]{start.up(2)}, start); } @@ -169,7 +170,7 @@ public class MovementPillar extends Movement { state.setInput(InputOverrideHandler.Input.SNEAK, true); // Otherwise jump - if (numTicks > 40) { + if (numTicks > 20) { double diffX = player().posX - (dest.getX() + 0.5); double diffZ = player().posZ - (dest.getZ() + 0.5); double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 44c594c0..da206d5e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -42,7 +43,7 @@ public class MovementTraverse extends Movement { */ private boolean wasTheBridgeBlockAlwaysThere = true; - public MovementTraverse(BlockPos from, BlockPos to) { + public MovementTraverse(BetterBlockPos from, BetterBlockPos to) { super(from, to, new BlockPos[]{to.up(), to}, to.down()); } From 07b0e2cdbfbcee5e136bb58759e5e3f67bbadf56 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 09:50:19 -0700 Subject: [PATCH 081/329] block state interface cache region too --- .../pathing/calc/AStarPathFinder.java | 2 ++ .../baritone/utils/BlockStateInterface.java | 33 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 7435c3f0..e1cc7372 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -28,6 +28,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.movements.*; import baritone.pathing.path.IPath; +import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.client.Minecraft; @@ -72,6 +73,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { currentlyRunning = this; CachedWorld cachedWorld = Optional.ofNullable(WorldProvider.INSTANCE.getCurrentWorld()).map(w -> w.cache).orElse(null); ChunkProviderClient chunkProvider = Minecraft.getMinecraft().world.getChunkProvider(); + BlockStateInterface.clearCachedChunk(); long startTime = System.nanoTime() / 1000000L; boolean slowPath = Baritone.settings().slowPath.get(); if (slowPath) { diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 4fa2449d..bd3186e1 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.chunk.CachedRegion; import baritone.chunk.WorldData; import baritone.chunk.WorldProvider; import net.minecraft.block.Block; @@ -35,6 +36,13 @@ import net.minecraft.world.chunk.Chunk; public class BlockStateInterface implements Helper { private static Chunk prev = null; + private static CachedRegion prevCached = null; + + private static IBlockState AIR = Blocks.AIR.getDefaultState(); + public static final Block waterFlowing = Blocks.FLOWING_WATER; + public static final Block waterStill = Blocks.WATER; + public static final Block lavaFlowing = Blocks.FLOWING_LAVA; + public static final Block lavaStill = Blocks.LAVA; public static IBlockState get(BlockPos pos) { return get(pos.getX(), pos.getY(), pos.getZ()); @@ -44,7 +52,7 @@ public class BlockStateInterface implements Helper { // Invalid vertical position if (y < 0 || y >= 256) { - return Blocks.AIR.getDefaultState(); + return AIR; } if (!Baritone.settings().pathThroughCachedOnly.get()) { @@ -63,30 +71,39 @@ public class BlockStateInterface implements Helper { return chunk.getBlockState(x, y, z); } } + // same idea here, skip the Long2ObjectOpenHashMap.get if at all possible + // except here, it's 512x512 tiles instead of 16x16, so even better repetition + CachedRegion cached = prevCached; + if (cached != null && cached.getX() == x >> 9 && cached.getZ() == z >> 9) { + IBlockState type = cached.getBlock(x & 511, y, z & 511); + if (type == null) { + return AIR; + } + return type; + } WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); if (world != null) { + CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); + if (region != null) { + prevCached = region; + } IBlockState type = world.cache.getBlock(x, y, z); if (type != null) { return type; } } - - - return Blocks.AIR.getDefaultState(); + return AIR; } public static void clearCachedChunk() { prev = null; + prevCached = null; } public static Block getBlock(BlockPos pos) { return get(pos).getBlock(); } - public static final Block waterFlowing = Blocks.FLOWING_WATER; - public static final Block waterStill = Blocks.WATER; - public static final Block lavaFlowing = Blocks.FLOWING_LAVA; - public static final Block lavaStill = Blocks.LAVA; /** * Returns whether or not the specified block is From 44ece7c510df5163ecc7a3ad83e755de66dd7f69 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 09:54:09 -0700 Subject: [PATCH 082/329] prevent double lookup --- src/main/java/baritone/utils/BlockStateInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index bd3186e1..cf56737a 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -87,7 +87,7 @@ public class BlockStateInterface implements Helper { if (region != null) { prevCached = region; } - IBlockState type = world.cache.getBlock(x, y, z); + IBlockState type = region.getBlock(x & 511, y, z & 511); if (type != null) { return type; } From ef4de2b15997d2cb7de8ce74e1b96d3da09186f8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 09:55:59 -0700 Subject: [PATCH 083/329] oh look and another bug --- src/main/java/baritone/utils/BlockStateInterface.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index cf56737a..9a7c7028 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -86,10 +86,10 @@ public class BlockStateInterface implements Helper { CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); if (region != null) { prevCached = region; - } - IBlockState type = region.getBlock(x & 511, y, z & 511); - if (type != null) { - return type; + IBlockState type = region.getBlock(x & 511, y, z & 511); + if (type != null) { + return type; + } } } return AIR; From 4a13b54e50d56e77f0c31de053b0b2e4cd519171 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 10:27:47 -0700 Subject: [PATCH 084/329] brady was right and I was wrong --- .../baritone/api/event/GameEventHandler.java | 52 +++++++++---------- .../pathing/movement/MovementHelper.java | 1 + 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 32634213..9e569980 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -60,20 +60,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { @Override public final void onTick(TickEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onTick(event); } - } + }); } @Override public final void onPlayerUpdate(PlayerUpdateEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onPlayerUpdate(event); } - } + }); } @Override @@ -93,20 +93,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { } } - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onProcessKeyBinds(); } - } + }); } @Override public final void onSendChatMessage(ChatEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onSendChatMessage(event); } - } + }); } @Override @@ -132,20 +132,20 @@ public final class GameEventHandler implements IGameEventListener, Helper { } - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onChunkEvent(event); } - } + }); } @Override public final void onRenderPass(RenderEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onRenderPass(event); } - } + }); } @Override @@ -165,65 +165,65 @@ public final class GameEventHandler implements IGameEventListener, Helper { break; } - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onWorldEvent(event); } - } + }); } @Override public final void onSendPacket(PacketEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onSendPacket(event); } - } + }); } @Override public final void onReceivePacket(PacketEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onReceivePacket(event); } - } + }); } @Override public void onPlayerRelativeMove(RelativeMoveEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onPlayerRelativeMove(event); } - } + }); } @Override public void onBlockInteract(BlockInteractEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onBlockInteract(event); } - } + }); } @Override public void onPlayerDeath() { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onPlayerDeath(); } - } + }); } @Override public void onPathEvent(PathEvent event) { - for (IGameEventListener l : listeners) { + listeners.forEach(l -> { if (canDispatch(l)) { l.onPathEvent(event); } - } + }); } public final void registerEventListener(IGameEventListener listener) { diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6aa2f5e0..1036b69f 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -419,6 +419,7 @@ public interface MovementHelper extends ActionCosts, Helper { //this doesn't guarantee descend is possible, it just guarantees fall is impossible return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1 + // we can't cost shortcut descend because !canWalkThrough doesn't mean canWalkOn } // we're clear for a fall 2 From 7b712fe677d38f7b9b82355270ace383e58a8e58 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 11:00:57 -0700 Subject: [PATCH 085/329] add synchronization, fixes #145 --- .../baritone/api/event/GameEventHandler.java | 3 +-- src/main/java/baritone/chunk/CachedWorld.java | 21 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 9e569980..2ac27792 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -48,7 +48,6 @@ import net.minecraft.world.chunk.Chunk; import org.lwjgl.input.Keyboard; import java.util.ArrayList; -import java.util.List; /** * @author Brady @@ -56,7 +55,7 @@ import java.util.List; */ public final class GameEventHandler implements IGameEventListener, Helper { - private final List listeners = new ArrayList<>(); + private final ArrayList listeners = new ArrayList<>(); @Override public final void onTick(TickEvent event) { diff --git a/src/main/java/baritone/chunk/CachedWorld.java b/src/main/java/baritone/chunk/CachedWorld.java index 14097c16..de6ebd5f 100644 --- a/src/main/java/baritone/chunk/CachedWorld.java +++ b/src/main/java/baritone/chunk/CachedWorld.java @@ -28,9 +28,10 @@ import net.minecraft.world.chunk.Chunk; 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; -import java.util.function.Consumer; /** * @author Brady @@ -154,7 +155,7 @@ public final class CachedWorld implements IBlockTypeAccess { return; } long start = System.nanoTime() / 1000000L; - this.cachedRegions.values().parallelStream().forEach(region -> { + allRegions().parallelStream().forEach(region -> { if (region != null) { region.save(this.directory); } @@ -163,9 +164,13 @@ public final class CachedWorld implements IBlockTypeAccess { System.out.println("World save took " + (now - start) + "ms"); } + private synchronized List allRegions() { + return new ArrayList<>(this.cachedRegions.values()); + } + public final void reloadAllFromDisk() { long start = System.nanoTime() / 1000000L; - this.cachedRegions.values().forEach(region -> { + allRegions().forEach(region -> { if (region != null) { region.load(this.directory); } @@ -181,7 +186,7 @@ public final class CachedWorld implements IBlockTypeAccess { * @param regionZ The region Z coordinate * @return The region located at the specified coordinates */ - public final CachedRegion getRegion(int regionX, int regionZ) { + public final synchronized CachedRegion getRegion(int regionX, int regionZ) { return cachedRegions.get(getRegionID(regionX, regionZ)); } @@ -201,14 +206,6 @@ public final class CachedWorld implements IBlockTypeAccess { }); } - public void forEachRegion(Consumer consumer) { - this.cachedRegions.forEach((id, r) -> { - if (r != null) { - consumer.accept(r); - } - }); - } - /** * Returns the region ID based on the region coordinates. 0 will be * returned if the specified region coordinates are out of bounds. From 6801d00d7e11a41790af9072190c3960af0004f2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 11:06:02 -0700 Subject: [PATCH 086/329] enable 1-skipback --- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 818f9bbb..c1281359 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -90,7 +90,7 @@ public class PathExecutor implements Helper { if (!whereShouldIBe.equals(whereAmI)) { //System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI); if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip - for (int i = 0; i < pathPosition - 2 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks + for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks if (whereAmI.equals(path.positions().get(i))) { displayChatMessageRaw("Skipping back " + (pathPosition - i) + " steps, to " + i); int previousPos = pathPosition; From 4221c07d1f00d6b9deee6940b7795056899e2958 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 13:04:41 -0700 Subject: [PATCH 087/329] i don't know how i keep getting worldscanner wrong lol --- src/main/java/baritone/chunk/WorldScanner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 27345670..47d377b1 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -91,7 +91,7 @@ public enum WorldScanner implements Helper { if (allUnloaded) { return res; } - if (res.size() >= max && searchRadiusSq < 26) { + if (res.size() >= max && searchRadiusSq > 26) { return res; } searchRadiusSq++; From d29a37664c05f72e2d7b1d8b1289828675e005bb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 13:09:56 -0700 Subject: [PATCH 088/329] clarify error messages --- .../java/baritone/utils/ExampleBaritoneControl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 9c28f058..492c3652 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -108,7 +108,11 @@ public class ExampleBaritoneControl extends Behavior { if (PathingBehavior.INSTANCE.getGoal() == null) { displayChatMessageRaw("No goal."); } else { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + if (PathingBehavior.INSTANCE.getGoal().isInGoal(playerFeet())) { + displayChatMessageRaw("Already in goal"); + } else { + displayChatMessageRaw("Currently executing a path. Please cancel it first."); + } } } event.cancel(); @@ -266,7 +270,9 @@ public class ExampleBaritoneControl extends Behavior { Goal goal = new GoalBlock(waypoint.location); PathingBehavior.INSTANCE.setGoal(goal); if (!PathingBehavior.INSTANCE.path()) { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + if (!goal.isInGoal(playerFeet())) { + displayChatMessageRaw("Currently executing a path. Please cancel it first."); + } } event.cancel(); return; From d8ca6cad4e9d95eb006325864029853d4697a799 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 13:19:48 -0700 Subject: [PATCH 089/329] i am an idiot 2: electric boogaloo --- .../baritone/pathing/movement/MovementHelper.java | 11 +++++------ .../java/baritone/utils/ExampleBaritoneControl.java | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1036b69f..dc66d202 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -52,15 +52,14 @@ public interface MovementHelper extends ActionCosts, Helper { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); - Block below = BlockStateInterface.get(x, y - 1, z).getBlock(); return b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call BlockStateInterface.get directly with x,y,z. no need to make 5 new BlockPos for no reason - || BlockStateInterface.get(x, y + 1, z) instanceof BlockLiquid//don't break anything touching liquid on any side - || BlockStateInterface.get(x + 1, y, z) instanceof BlockLiquid - || BlockStateInterface.get(x - 1, y, z) instanceof BlockLiquid - || BlockStateInterface.get(x, y, z + 1) instanceof BlockLiquid - || BlockStateInterface.get(x, y, z - 1) instanceof BlockLiquid; + || BlockStateInterface.get(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side + || BlockStateInterface.get(x + 1, y, z).getBlock() instanceof BlockLiquid + || BlockStateInterface.get(x - 1, y, z).getBlock() instanceof BlockLiquid + || BlockStateInterface.get(x, y, z + 1).getBlock() instanceof BlockLiquid + || BlockStateInterface.get(x, y, z - 1).getBlock() instanceof BlockLiquid; } /** diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 492c3652..c3eb40aa 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -314,6 +314,9 @@ public class ExampleBaritoneControl extends Behavior { if (msg.toLowerCase().equals("costs")) { Movement[] movements = AStarPathFinder.getConnectedPositions(new BetterBlockPos(playerFeet()), new CalculationContext()); List moves = new ArrayList<>(Arrays.asList(movements)); + while (moves.contains(null)) { + moves.remove(null); + } moves.sort(Comparator.comparingDouble(movement -> movement.getCost(new CalculationContext()))); for (Movement move : moves) { String[] parts = move.getClass().toString().split("\\."); From 8fa0d63ae5d6ba396210e51343cebc6e725a8e45 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 15:33:53 -0700 Subject: [PATCH 090/329] add link to benchmark --- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 3cf47478..574e0250 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -23,6 +23,10 @@ import net.minecraft.util.math.Vec3i; /** * A better BlockPos that has fewer hash collisions (and slightly more performant offsets) + *

+ * Is it really faster to subclass BlockPos and calculate a hash in the constructor like this, taking everything into account? + * Yes. It's called BETTER BlockPos for a reason. Source: + * https://docs.google.com/spreadsheets/d/1GWjOjOZINkg_0MkRgKRPH1kUzxjsnEROD9u3UFh_DJc/edit * * @author leijurv */ From ecbb34366f861e77a75e713737a25710e8d64d16 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 9 Sep 2018 17:37:12 -0500 Subject: [PATCH 091/329] Hyperlink the benchmark spreadsheet for BetterBlockPos --- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 574e0250..216a8b63 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -26,7 +26,7 @@ import net.minecraft.util.math.Vec3i; *

* Is it really faster to subclass BlockPos and calculate a hash in the constructor like this, taking everything into account? * Yes. It's called BETTER BlockPos for a reason. Source: - * https://docs.google.com/spreadsheets/d/1GWjOjOZINkg_0MkRgKRPH1kUzxjsnEROD9u3UFh_DJc/edit + * Benchmark Spreadsheet * * @author leijurv */ From 075ad3f244166e24066cdb79a1d4c6b9b499bab7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Sep 2018 15:38:59 -0700 Subject: [PATCH 092/329] almost forgot crucial performance numbers --- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 216a8b63..895d982f 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -25,7 +25,7 @@ import net.minecraft.util.math.Vec3i; * A better BlockPos that has fewer hash collisions (and slightly more performant offsets) *

* Is it really faster to subclass BlockPos and calculate a hash in the constructor like this, taking everything into account? - * Yes. It's called BETTER BlockPos for a reason. Source: + * Yes. 20% faster actually. It's called BETTER BlockPos for a reason. Source: * Benchmark Spreadsheet * * @author leijurv From 72eec135d02d09b773240c175edb3c8accab8654 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 10 Sep 2018 09:22:32 -0700 Subject: [PATCH 093/329] misc improvements --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 2 +- src/main/java/baritone/pathing/calc/PathNode.java | 3 ++- .../pathing/movement/movements/MovementParkour.java | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index e1cc7372..d03e52f8 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -158,8 +158,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { if (neighbor.isOpen) { openSet.update(neighbor); } else { - openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there neighbor.isOpen = true; + openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there } for (int i = 0; i < bestSoFar.length; i++) { double heuristic = neighbor.estimatedCostToGoal + neighbor.cost / COEFFICIENTS[i]; diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 45190fa7..3d984548 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -18,6 +18,7 @@ package baritone.pathing.calc; import baritone.pathing.goals.Goal; +import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.Movement; import baritone.utils.pathing.BetterBlockPos; @@ -81,7 +82,7 @@ public final class PathNode { public PathNode(BetterBlockPos pos, Goal goal) { this.pos = pos; this.previous = null; - this.cost = Short.MAX_VALUE; + this.cost = ActionCosts.COST_INF; this.goal = goal; this.estimatedCostToGoal = goal.heuristic(pos); this.previousMovement = null; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 1041ae07..8cd37c73 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -65,6 +65,12 @@ public class MovementParkour extends Movement { if (!MovementHelper.fullyPassable(src.up().offset(dir))) { return null; } + if (!MovementHelper.fullyPassable(src.up(2).offset(dir))) { + return null; + } + if (!MovementHelper.fullyPassable(src.up(2))) { + return null; + } for (int i = 2; i <= 4; i++) { BlockPos dest = src.offset(dir, i); // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? From a59d30d11e8a23d575b9aace500a3b2ef0946369 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 10 Sep 2018 10:42:55 -0700 Subject: [PATCH 094/329] update commit and link --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 7fa22435..574e5a0c 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar from September 4 from here +You can either build Baritone yourself, or download the jar (as of commit 72eec13, built on September 10) from here. To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From fb07e471418b4848c661b05ac9676acf77e19c93 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 10 Sep 2018 10:47:31 -0700 Subject: [PATCH 095/329] better instructions --- IMPACT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index 574e5a0c..ec7b6707 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -6,9 +6,9 @@ You can either build Baritone yourself, or download the jar (as of commit Date: Mon, 10 Sep 2018 14:48:18 -0700 Subject: [PATCH 096/329] misc cleanup --- .../pathing/calc/AStarPathFinder.java | 29 ++++++++++++------- .../pathing/calc/AbstractNodeCostSearch.java | 6 ++-- .../movement/movements/MovementParkour.java | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index d03e52f8..bf553e18 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -210,36 +210,43 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { public static Movement[] getConnectedPositions(BetterBlockPos pos, CalculationContext calcContext) { - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); + int x = pos.x; + int y = pos.y; + int z = pos.z; BetterBlockPos east = new BetterBlockPos(x + 1, y, z); BetterBlockPos west = new BetterBlockPos(x - 1, y, z); BetterBlockPos south = new BetterBlockPos(x, y, z + 1); BetterBlockPos north = new BetterBlockPos(x, y, z - 1); return new Movement[]{ + new MovementDownward(pos, new BetterBlockPos(x, y - 1, z)), + + new MovementPillar(pos, new BetterBlockPos(x, y + 1, z)), + new MovementTraverse(pos, east), new MovementTraverse(pos, west), new MovementTraverse(pos, north), new MovementTraverse(pos, south), + new MovementAscend(pos, new BetterBlockPos(x + 1, y + 1, z)), new MovementAscend(pos, new BetterBlockPos(x - 1, y + 1, z)), new MovementAscend(pos, new BetterBlockPos(x, y + 1, z + 1)), new MovementAscend(pos, new BetterBlockPos(x, y + 1, z - 1)), + MovementHelper.generateMovementFallOrDescend(pos, east, calcContext), MovementHelper.generateMovementFallOrDescend(pos, west, calcContext), MovementHelper.generateMovementFallOrDescend(pos, north, calcContext), MovementHelper.generateMovementFallOrDescend(pos, south, calcContext), - new MovementDownward(pos, new BetterBlockPos(x, y - 1, z)), - new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.WEST), + new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.EAST), - new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), + new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.WEST), new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.EAST), - new MovementPillar(pos, new BetterBlockPos(x, y + 1, z)), - MovementParkour.calculate(pos, EnumFacing.NORTH), - MovementParkour.calculate(pos, EnumFacing.SOUTH), - MovementParkour.calculate(pos, EnumFacing.EAST), - MovementParkour.calculate(pos, EnumFacing.WEST), + + new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), + + MovementParkour.generate(pos, EnumFacing.EAST), + MovementParkour.generate(pos, EnumFacing.WEST), + MovementParkour.generate(pos, EnumFacing.NORTH), + MovementParkour.generate(pos, EnumFacing.SOUTH), }; } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 5804cb1a..92c85b1d 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -107,9 +107,9 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * @return The distance, squared */ protected double getDistFromStartSq(PathNode n) { - int xDiff = n.pos.getX() - start.getX(); - int yDiff = n.pos.getY() - start.getY(); - int zDiff = n.pos.getZ() - start.getZ(); + int xDiff = n.pos.x - start.x; + int yDiff = n.pos.y - start.y; + int zDiff = n.pos.z - start.z; return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 8cd37c73..b14abbca 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -42,7 +42,7 @@ public class MovementParkour extends Movement { super.override(costFromJumpDistance(dist)); } - public static MovementParkour calculate(BetterBlockPos src, EnumFacing dir) { + public static MovementParkour generate(BetterBlockPos src, EnumFacing dir) { if (!Baritone.settings().allowParkour.get()) { return null; } From a67e6fd1638818d7856001b39dd599a0fbf57690 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 10 Sep 2018 17:18:01 -0500 Subject: [PATCH 097/329] Create and use injection point on pre/post jump, fixes #146 Also removed ItemSlotEvent because @leijurv is retarded --- .../baritone/launch/mixins/MixinEntity.java | 6 +- .../launch/mixins/MixinEntityLivingBase.java | 57 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + .../baritone/api/event/GameEventHandler.java | 4 +- .../api/event/events/ItemSlotEvent.java | 56 ------------------ ...eMoveEvent.java => RotationMoveEvent.java} | 36 +++++++++++- .../listener/AbstractGameEventListener.java | 2 +- .../event/listener/IGameEventListener.java | 5 +- .../baritone/behavior/impl/LookBehavior.java | 7 ++- 9 files changed, 106 insertions(+), 68 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java delete mode 100644 src/main/java/baritone/api/event/events/ItemSlotEvent.java rename src/main/java/baritone/api/event/events/{RelativeMoveEvent.java => RotationMoveEvent.java} (59%) diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java index 2a0134d3..22be4154 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -18,7 +18,7 @@ package baritone.launch.mixins; import baritone.Baritone; -import baritone.api.event.events.RelativeMoveEvent; +import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.type.EventState; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -41,7 +41,7 @@ public class MixinEntity { private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { Entity _this = (Entity) (Object) this; if (_this == Minecraft.getMinecraft().player) - Baritone.INSTANCE.getGameEventHandler().onPlayerRelativeMove(new RelativeMoveEvent(EventState.PRE)); + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.MOTION_UPDATE)); } @Inject( @@ -51,6 +51,6 @@ public class MixinEntity { private void postMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { Entity _this = (Entity) (Object) this; if (_this == Minecraft.getMinecraft().player) - Baritone.INSTANCE.getGameEventHandler().onPlayerRelativeMove(new RelativeMoveEvent(EventState.POST)); + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.MOTION_UPDATE)); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java new file mode 100644 index 00000000..61f6db7a --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java @@ -0,0 +1,57 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import baritone.api.event.events.RotationMoveEvent; +import baritone.api.event.events.type.EventState; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** + * @author Brady + * @since 9/10/2018 + */ +@Mixin(EntityLivingBase.class) +public class MixinEntityLivingBase { + + @Inject( + method = "jump", + at = @At("HEAD") + ) + private void preJump(CallbackInfo ci) { + Entity _this = (Entity) (Object) this; + if (_this == Minecraft.getMinecraft().player) + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.PRE, RotationMoveEvent.Type.JUMP)); + } + + @Inject( + method = "jump", + at = @At("RETURN") + ) + private void postJump(CallbackInfo ci) { + Entity _this = (Entity) (Object) this; + if (_this == Minecraft.getMinecraft().player) + Baritone.INSTANCE.getGameEventHandler().onPlayerRotationMove(new RotationMoveEvent(EventState.POST, RotationMoveEvent.Type.JUMP)); + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index b1a8ed31..413bbbe7 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -12,6 +12,7 @@ "MixinBlockPos", "MixinChunkProviderServer", "MixinEntity", + "MixinEntityLivingBase", "MixinEntityPlayerSP", "MixinEntityRenderer", "MixinGameSettings", diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 2ac27792..299ff323 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -190,10 +190,10 @@ public final class GameEventHandler implements IGameEventListener, Helper { } @Override - public void onPlayerRelativeMove(RelativeMoveEvent event) { + public void onPlayerRotationMove(RotationMoveEvent event) { listeners.forEach(l -> { if (canDispatch(l)) { - l.onPlayerRelativeMove(event); + l.onPlayerRotationMove(event); } }); } diff --git a/src/main/java/baritone/api/event/events/ItemSlotEvent.java b/src/main/java/baritone/api/event/events/ItemSlotEvent.java deleted file mode 100644 index 82e69177..00000000 --- a/src/main/java/baritone/api/event/events/ItemSlotEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.api.event.events; - -import baritone.api.event.listener.IGameEventListener; - -/** - * Called in some cases where a player's inventory has it's current slot queried. - *

- * @see IGameEventListener#onQueryItemSlotForBlocks() - * - * @author Brady - * @since 8/20/2018 - */ -public final class ItemSlotEvent { - - /** - * The current slot index - */ - private int slot; - - public ItemSlotEvent(int slot) { - this.slot = slot; - } - - /** - * Sets the new slot index that will be used - * - * @param slot The slot index - */ - public final void setSlot(int slot) { - this.slot = slot; - } - - /** - * @return The current slot index - */ - public final int getSlot() { - return this.slot; - } -} diff --git a/src/main/java/baritone/api/event/events/RelativeMoveEvent.java b/src/main/java/baritone/api/event/events/RotationMoveEvent.java similarity index 59% rename from src/main/java/baritone/api/event/events/RelativeMoveEvent.java rename to src/main/java/baritone/api/event/events/RotationMoveEvent.java index 14798fd5..7bedf857 100644 --- a/src/main/java/baritone/api/event/events/RelativeMoveEvent.java +++ b/src/main/java/baritone/api/event/events/RotationMoveEvent.java @@ -18,20 +18,28 @@ package baritone.api.event.events; import baritone.api.event.events.type.EventState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; /** * @author Brady * @since 8/21/2018 */ -public final class RelativeMoveEvent { +public final class RotationMoveEvent { + + /** + * The type of event + */ + private final Type type; /** * The state of the event */ private final EventState state; - public RelativeMoveEvent(EventState state) { + public RotationMoveEvent(EventState state, Type type) { this.state = state; + this.type = type; } /** @@ -40,4 +48,28 @@ public final class RelativeMoveEvent { public final EventState getState() { return this.state; } + + /** + * @return The type of the event + */ + public final Type getType() { + return this.type; + } + + public enum Type { + + /** + * Called when the player's motion is updated. + * + * @see Entity#moveRelative(float, float, float, float) + */ + MOTION_UPDATE, + + /** + * Called when the player jumps. + * + * @see EntityLivingBase#jump + */ + JUMP + } } diff --git a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java index 3b228e9d..5839e6d5 100644 --- a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java +++ b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java @@ -75,7 +75,7 @@ public interface AbstractGameEventListener extends IGameEventListener { default void onReceivePacket(PacketEvent event) {} @Override - default void onPlayerRelativeMove(RelativeMoveEvent event) {} + default void onPlayerRotationMove(RotationMoveEvent event) {} @Override default void onBlockInteract(BlockInteractEvent event) {} diff --git a/src/main/java/baritone/api/event/listener/IGameEventListener.java b/src/main/java/baritone/api/event/listener/IGameEventListener.java index 81f91774..c63cbfbc 100644 --- a/src/main/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/main/java/baritone/api/event/listener/IGameEventListener.java @@ -43,6 +43,7 @@ import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.util.text.ITextComponent; @@ -120,10 +121,12 @@ public interface IGameEventListener { /** * Run once per game tick from before and after the player's moveRelative method is called + * and before and after the player jumps. * * @see Entity#moveRelative(float, float, float, float) + * @see EntityLivingBase#jump() */ - void onPlayerRelativeMove(RelativeMoveEvent event); + void onPlayerRotationMove(RotationMoveEvent event); /** * Called when the local player interacts with a block, whether it is breaking or opening/placing. diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java index b740618a..904087ab 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/impl/LookBehavior.java @@ -20,7 +20,7 @@ package baritone.behavior.impl; import baritone.Baritone; import baritone.Settings; import baritone.api.event.events.PlayerUpdateEvent; -import baritone.api.event.events.RelativeMoveEvent; +import baritone.api.event.events.RotationMoveEvent; import baritone.behavior.Behavior; import baritone.utils.Rotation; @@ -92,7 +92,7 @@ public class LookBehavior extends Behavior { } @Override - public void onPlayerRelativeMove(RelativeMoveEvent event) { + public void onPlayerRotationMove(RotationMoveEvent event) { if (this.target != null && !this.force) { switch (event.getState()) { case PRE: @@ -103,7 +103,8 @@ public class LookBehavior extends Behavior { player().rotationYaw = this.lastYaw; // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() - if (!Baritone.settings().antiCheatCompatibility.get()) { + // 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.target = null; } break; From 9daf46e30c061ee82f95f4b5da54d0968c4b28b0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 06:37:08 -0700 Subject: [PATCH 098/329] typos --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- src/main/java/baritone/utils/Helper.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index dc66d202..6aab4bd5 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -125,7 +125,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.AIR) { return true; } - // exceptions - blocks that are isPassasble true, but we can't actually jump through + // exceptions - blocks that are isPassable true, but we can't actually jump through if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index 383e7bf0..30e1f398 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -77,7 +77,9 @@ public interface Helper { if (!Baritone.settings().chatDebug.get()) { System.out.println("Suppressed debug message:"); System.out.println(message); - return; + /*if (!Stream.of(Thread.currentThread().getStackTrace()).map(StackTraceElement::getClassName).anyMatch(x -> x.equals(ExampleBaritoneControl.class.getName()))) { + return; + }*/ } ITextComponent component = MESSAGE_PREFIX.createCopy(); From a0a480e2cca46b3b72d2b5ee4213b8c834b768db Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 11 Sep 2018 12:05:12 -0500 Subject: [PATCH 099/329] Move api package in main to api sourceset --- .../api/event/events/BlockInteractEvent.java | 0 .../baritone/api/event/events/ChatEvent.java | 0 .../baritone/api/event/events/ChunkEvent.java | 0 .../api/event/events/PacketEvent.java | 0 .../baritone/api/event/events/PathEvent.java | 0 .../api/event/events/PlayerUpdateEvent.java | 0 .../api/event/events/RenderEvent.java | 0 .../api/event/events/RotationMoveEvent.java | 0 .../baritone/api/event/events/TickEvent.java | 0 .../baritone/api/event/events/WorldEvent.java | 0 .../api/event/events/type/Cancellable.java | 0 .../api/event/events/type/EventState.java | 0 .../listener/AbstractGameEventListener.java | 0 .../event/listener/IGameEventListener.java | 0 src/main/java/baritone/Baritone.java | 5 +++-- .../{api => }/event/GameEventHandler.java | 19 +------------------ 16 files changed, 4 insertions(+), 20 deletions(-) rename src/{main => api}/java/baritone/api/event/events/BlockInteractEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/ChatEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/ChunkEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/PacketEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/PathEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/PlayerUpdateEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/RenderEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/RotationMoveEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/TickEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/WorldEvent.java (100%) rename src/{main => api}/java/baritone/api/event/events/type/Cancellable.java (100%) rename src/{main => api}/java/baritone/api/event/events/type/EventState.java (100%) rename src/{main => api}/java/baritone/api/event/listener/AbstractGameEventListener.java (100%) rename src/{main => api}/java/baritone/api/event/listener/IGameEventListener.java (100%) rename src/main/java/baritone/{api => }/event/GameEventHandler.java (89%) diff --git a/src/main/java/baritone/api/event/events/BlockInteractEvent.java b/src/api/java/baritone/api/event/events/BlockInteractEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/BlockInteractEvent.java rename to src/api/java/baritone/api/event/events/BlockInteractEvent.java diff --git a/src/main/java/baritone/api/event/events/ChatEvent.java b/src/api/java/baritone/api/event/events/ChatEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/ChatEvent.java rename to src/api/java/baritone/api/event/events/ChatEvent.java diff --git a/src/main/java/baritone/api/event/events/ChunkEvent.java b/src/api/java/baritone/api/event/events/ChunkEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/ChunkEvent.java rename to src/api/java/baritone/api/event/events/ChunkEvent.java diff --git a/src/main/java/baritone/api/event/events/PacketEvent.java b/src/api/java/baritone/api/event/events/PacketEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/PacketEvent.java rename to src/api/java/baritone/api/event/events/PacketEvent.java diff --git a/src/main/java/baritone/api/event/events/PathEvent.java b/src/api/java/baritone/api/event/events/PathEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/PathEvent.java rename to src/api/java/baritone/api/event/events/PathEvent.java diff --git a/src/main/java/baritone/api/event/events/PlayerUpdateEvent.java b/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/PlayerUpdateEvent.java rename to src/api/java/baritone/api/event/events/PlayerUpdateEvent.java diff --git a/src/main/java/baritone/api/event/events/RenderEvent.java b/src/api/java/baritone/api/event/events/RenderEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/RenderEvent.java rename to src/api/java/baritone/api/event/events/RenderEvent.java diff --git a/src/main/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/RotationMoveEvent.java rename to src/api/java/baritone/api/event/events/RotationMoveEvent.java diff --git a/src/main/java/baritone/api/event/events/TickEvent.java b/src/api/java/baritone/api/event/events/TickEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/TickEvent.java rename to src/api/java/baritone/api/event/events/TickEvent.java diff --git a/src/main/java/baritone/api/event/events/WorldEvent.java b/src/api/java/baritone/api/event/events/WorldEvent.java similarity index 100% rename from src/main/java/baritone/api/event/events/WorldEvent.java rename to src/api/java/baritone/api/event/events/WorldEvent.java diff --git a/src/main/java/baritone/api/event/events/type/Cancellable.java b/src/api/java/baritone/api/event/events/type/Cancellable.java similarity index 100% rename from src/main/java/baritone/api/event/events/type/Cancellable.java rename to src/api/java/baritone/api/event/events/type/Cancellable.java diff --git a/src/main/java/baritone/api/event/events/type/EventState.java b/src/api/java/baritone/api/event/events/type/EventState.java similarity index 100% rename from src/main/java/baritone/api/event/events/type/EventState.java rename to src/api/java/baritone/api/event/events/type/EventState.java diff --git a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java similarity index 100% rename from src/main/java/baritone/api/event/listener/AbstractGameEventListener.java rename to src/api/java/baritone/api/event/listener/AbstractGameEventListener.java diff --git a/src/main/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java similarity index 100% rename from src/main/java/baritone/api/event/listener/IGameEventListener.java rename to src/api/java/baritone/api/event/listener/IGameEventListener.java diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 5baacec8..3c7bf24c 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -17,9 +17,10 @@ package baritone; -import baritone.api.event.GameEventHandler; +import baritone.api.event.listener.IGameEventListener; import baritone.behavior.Behavior; import baritone.behavior.impl.*; +import baritone.event.GameEventHandler; import baritone.utils.InputOverrideHandler; import net.minecraft.client.Minecraft; @@ -99,7 +100,7 @@ public enum Baritone { return this.initialized; } - public final GameEventHandler getGameEventHandler() { + public final IGameEventListener getGameEventHandler() { return this.gameEventHandler; } diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java similarity index 89% rename from src/main/java/baritone/api/event/GameEventHandler.java rename to src/main/java/baritone/event/GameEventHandler.java index 299ff323..e6dba1ec 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -15,24 +15,7 @@ * along with Baritone. If not, see . */ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.api.event; +package baritone.event; import baritone.Baritone; import baritone.api.event.events.*; From 35ed0f6821170034372c0154ce62e820c02b1b69 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 10:28:03 -0700 Subject: [PATCH 100/329] refactor chunk to cache --- .../baritone/behavior/impl/LocationTrackingBehavior.java | 4 ++-- src/main/java/baritone/behavior/impl/MineBehavior.java | 8 ++++---- src/main/java/baritone/{chunk => cache}/CachedChunk.java | 2 +- src/main/java/baritone/{chunk => cache}/CachedRegion.java | 2 +- src/main/java/baritone/{chunk => cache}/CachedWorld.java | 2 +- src/main/java/baritone/{chunk => cache}/ChunkPacker.java | 2 +- src/main/java/baritone/{chunk => cache}/Waypoint.java | 2 +- src/main/java/baritone/{chunk => cache}/Waypoints.java | 2 +- src/main/java/baritone/{chunk => cache}/WorldData.java | 2 +- .../java/baritone/{chunk => cache}/WorldProvider.java | 2 +- src/main/java/baritone/{chunk => cache}/WorldScanner.java | 2 +- src/main/java/baritone/event/GameEventHandler.java | 2 +- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 4 ++-- src/main/java/baritone/utils/BlockStateInterface.java | 6 +++--- src/main/java/baritone/utils/ExampleBaritoneControl.java | 6 +++--- .../java/baritone/{chunk => cache}/CachedRegionTest.java | 2 +- 16 files changed, 25 insertions(+), 25 deletions(-) rename src/main/java/baritone/{chunk => cache}/CachedChunk.java (99%) rename src/main/java/baritone/{chunk => cache}/CachedRegion.java (99%) rename src/main/java/baritone/{chunk => cache}/CachedWorld.java (99%) rename src/main/java/baritone/{chunk => cache}/ChunkPacker.java (99%) rename src/main/java/baritone/{chunk => cache}/Waypoint.java (99%) rename src/main/java/baritone/{chunk => cache}/Waypoints.java (99%) rename src/main/java/baritone/{chunk => cache}/WorldData.java (98%) rename src/main/java/baritone/{chunk => cache}/WorldProvider.java (99%) rename src/main/java/baritone/{chunk => cache}/WorldScanner.java (99%) rename src/test/java/baritone/{chunk => cache}/CachedRegionTest.java (98%) diff --git a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java index ba075dd3..47dfcd7c 100644 --- a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java @@ -18,8 +18,8 @@ package baritone.behavior.impl; import baritone.behavior.Behavior; -import baritone.chunk.Waypoint; -import baritone.chunk.WorldProvider; +import baritone.cache.Waypoint; +import baritone.cache.WorldProvider; import baritone.api.event.events.BlockInteractEvent; import baritone.utils.BlockStateInterface; import net.minecraft.block.BlockBed; diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 0b4b3b2a..ab68783e 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -19,10 +19,10 @@ package baritone.behavior.impl; import baritone.api.event.events.PathEvent; import baritone.behavior.Behavior; -import baritone.chunk.CachedChunk; -import baritone.chunk.ChunkPacker; -import baritone.chunk.WorldProvider; -import baritone.chunk.WorldScanner; +import baritone.cache.CachedChunk; +import baritone.cache.ChunkPacker; +import baritone.cache.WorldProvider; +import baritone.cache.WorldScanner; import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; diff --git a/src/main/java/baritone/chunk/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java similarity index 99% rename from src/main/java/baritone/chunk/CachedChunk.java rename to src/main/java/baritone/cache/CachedChunk.java index 56f7662a..fbab3161 100644 --- a/src/main/java/baritone/chunk/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.utils.pathing.IBlockTypeAccess; import baritone.utils.pathing.PathingBlockType; diff --git a/src/main/java/baritone/chunk/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java similarity index 99% rename from src/main/java/baritone/chunk/CachedRegion.java rename to src/main/java/baritone/cache/CachedRegion.java index ee305527..1e5e8ea5 100644 --- a/src/main/java/baritone/chunk/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.utils.pathing.IBlockTypeAccess; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/baritone/chunk/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java similarity index 99% rename from src/main/java/baritone/chunk/CachedWorld.java rename to src/main/java/baritone/cache/CachedWorld.java index de6ebd5f..d56882b4 100644 --- a/src/main/java/baritone/chunk/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.Baritone; import baritone.utils.pathing.IBlockTypeAccess; diff --git a/src/main/java/baritone/chunk/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java similarity index 99% rename from src/main/java/baritone/chunk/ChunkPacker.java rename to src/main/java/baritone/cache/ChunkPacker.java index 583dddc0..7167df34 100644 --- a/src/main/java/baritone/chunk/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.pathing.movement.MovementHelper; import baritone.utils.Helper; diff --git a/src/main/java/baritone/chunk/Waypoint.java b/src/main/java/baritone/cache/Waypoint.java similarity index 99% rename from src/main/java/baritone/chunk/Waypoint.java rename to src/main/java/baritone/cache/Waypoint.java index 8b290d56..7cd5ace3 100644 --- a/src/main/java/baritone/chunk/Waypoint.java +++ b/src/main/java/baritone/cache/Waypoint.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import com.google.common.collect.ImmutableList; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/chunk/Waypoints.java b/src/main/java/baritone/cache/Waypoints.java similarity index 99% rename from src/main/java/baritone/chunk/Waypoints.java rename to src/main/java/baritone/cache/Waypoints.java index ec587fea..82cf893f 100644 --- a/src/main/java/baritone/chunk/Waypoints.java +++ b/src/main/java/baritone/cache/Waypoints.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/chunk/WorldData.java b/src/main/java/baritone/cache/WorldData.java similarity index 98% rename from src/main/java/baritone/chunk/WorldData.java rename to src/main/java/baritone/cache/WorldData.java index 3cd7b737..a7d0b72a 100644 --- a/src/main/java/baritone/chunk/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import java.nio.file.Path; diff --git a/src/main/java/baritone/chunk/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java similarity index 99% rename from src/main/java/baritone/chunk/WorldProvider.java rename to src/main/java/baritone/cache/WorldProvider.java index 007f037d..0275301d 100644 --- a/src/main/java/baritone/chunk/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.Baritone; import baritone.utils.Helper; diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java similarity index 99% rename from src/main/java/baritone/chunk/WorldScanner.java rename to src/main/java/baritone/cache/WorldScanner.java index 47d377b1..2b1ebe23 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import baritone.utils.Helper; import net.minecraft.block.Block; diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index e6dba1ec..c681bc29 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -21,7 +21,7 @@ import baritone.Baritone; import baritone.api.event.events.*; import baritone.api.event.events.type.EventState; import baritone.api.event.listener.IGameEventListener; -import baritone.chunk.WorldProvider; +import baritone.cache.WorldProvider; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.InputOverrideHandler; diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index bf553e18..674d5b64 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -18,8 +18,8 @@ package baritone.pathing.calc; import baritone.Baritone; -import baritone.chunk.CachedWorld; -import baritone.chunk.WorldProvider; +import baritone.cache.CachedWorld; +import baritone.cache.WorldProvider; import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 9a7c7028..1ccd5ac6 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -18,9 +18,9 @@ package baritone.utils; import baritone.Baritone; -import baritone.chunk.CachedRegion; -import baritone.chunk.WorldData; -import baritone.chunk.WorldProvider; +import baritone.cache.CachedRegion; +import baritone.cache.WorldData; +import baritone.cache.WorldProvider; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index c3eb40aa..b12db109 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -24,9 +24,9 @@ import baritone.behavior.Behavior; import baritone.behavior.impl.FollowBehavior; import baritone.behavior.impl.MineBehavior; import baritone.behavior.impl.PathingBehavior; -import baritone.chunk.ChunkPacker; -import baritone.chunk.Waypoint; -import baritone.chunk.WorldProvider; +import baritone.cache.ChunkPacker; +import baritone.cache.Waypoint; +import baritone.cache.WorldProvider; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.goals.*; diff --git a/src/test/java/baritone/chunk/CachedRegionTest.java b/src/test/java/baritone/cache/CachedRegionTest.java similarity index 98% rename from src/test/java/baritone/chunk/CachedRegionTest.java rename to src/test/java/baritone/cache/CachedRegionTest.java index 8350390c..dc595e2e 100644 --- a/src/test/java/baritone/chunk/CachedRegionTest.java +++ b/src/test/java/baritone/cache/CachedRegionTest.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.chunk; +package baritone.cache; import org.junit.Test; From 3dfde818d3a42116445d1c90ada770c7d0189f01 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 11:29:54 -0700 Subject: [PATCH 101/329] api source set --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8a2639f8..1ab9fe8d 100755 --- a/build.gradle +++ b/build.gradle @@ -87,5 +87,5 @@ mixin { } jar { - from sourceSets.launch.output + from sourceSets.launch.output, sourceSets.api.output } From ab1037bcfd9f504af53f1c2bb93f1956c1ece4f7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 11:56:59 -0700 Subject: [PATCH 102/329] blockstateinterface reorg --- src/main/java/baritone/cache/CachedWorld.java | 16 ++---------- .../baritone/utils/BlockStateInterface.java | 26 +++++++++---------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index d56882b4..d903c2cd 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -18,10 +18,9 @@ package baritone.cache; import baritone.Baritone; -import baritone.utils.pathing.IBlockTypeAccess; +import baritone.utils.Helper; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; @@ -37,7 +36,7 @@ import java.util.concurrent.LinkedBlockingQueue; * @author Brady * @since 8/4/2018 12:02 AM */ -public final class CachedWorld implements IBlockTypeAccess { +public final class CachedWorld implements Helper { /** * The maximum number of regions in any direction from (0,0) @@ -92,16 +91,6 @@ public final class CachedWorld implements IBlockTypeAccess { } } - @Override - public final IBlockState getBlock(int x, int y, int z) { - // no point in doing getOrCreate region, if we don't have it we don't have it - CachedRegion region = getRegion(x >> 9, z >> 9); - if (region == null) { - return null; - } - return region.getBlock(x & 511, y, z & 511); - } - public final boolean isCached(BlockPos pos) { int x = pos.getX(); int z = pos.getZ(); @@ -112,7 +101,6 @@ public final class CachedWorld implements IBlockTypeAccess { return region.isCached(x & 511, z & 511); } - public final LinkedList getLocationsOf(String block, int minimum, int maxRegionDistanceSq) { LinkedList res = new LinkedList<>(); int playerRegionX = playerFeet().getX() >> 9; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 1ccd5ac6..bb4d094d 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -74,25 +74,23 @@ public class BlockStateInterface implements Helper { // same idea here, skip the Long2ObjectOpenHashMap.get if at all possible // except here, it's 512x512 tiles instead of 16x16, so even better repetition CachedRegion cached = prevCached; - if (cached != null && cached.getX() == x >> 9 && cached.getZ() == z >> 9) { - IBlockState type = cached.getBlock(x & 511, y, z & 511); - if (type == null) { + if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) { + WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); + if (world == null) { return AIR; } - return type; - } - WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); - if (world != null) { CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); - if (region != null) { - prevCached = region; - IBlockState type = region.getBlock(x & 511, y, z & 511); - if (type != null) { - return type; - } + if (region == null) { + return AIR; } + prevCached = region; + cached = region; } - return AIR; + IBlockState type = cached.getBlock(x & 511, y, z & 511); + if (type == null) { + return AIR; + } + return type; } public static void clearCachedChunk() { From bafc938424164088852b06b5d12752c400bdcc5c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 13:15:13 -0700 Subject: [PATCH 103/329] possibly fix parkour cost calculation issue --- .../baritone/pathing/movement/movements/MovementParkour.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index b14abbca..07126ca1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -109,7 +109,7 @@ public class MovementParkour extends Movement { } for (int i = 1; i <= 4; i++) { BlockPos d = src.offset(direction, i); - for (int y = 0; y < 4; y++) { + for (int y = 0; y < (i == 1 ? 3 : 4); y++) { if (!MovementHelper.fullyPassable(d.up(y))) { return COST_INF; } From ff2714b15fe05fcb338ffe68a2b0bab5d05c15f1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 13:45:43 -0700 Subject: [PATCH 104/329] refactor logging, fixes #153 --- .../baritone/behavior/impl/MineBehavior.java | 2 +- .../behavior/impl/PathingBehavior.java | 22 +++--- .../pathing/calc/AStarPathFinder.java | 10 +-- .../movement/movements/MovementPillar.java | 2 +- .../movement/movements/MovementTraverse.java | 6 +- .../java/baritone/pathing/path/IPath.java | 8 +- .../baritone/pathing/path/PathExecutor.java | 20 ++--- .../utils/ExampleBaritoneControl.java | 76 +++++++++---------- src/main/java/baritone/utils/Helper.java | 17 ++++- 9 files changed, 86 insertions(+), 77 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index ab68783e..5b0d6a5a 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -60,7 +60,7 @@ public class MineBehavior extends Behavior { } List locs = scanFor(mining, 64); if (locs.isEmpty()) { - displayChatMessageRaw("No locations for " + mining + " known, cancelling"); + logDebug("No locations for " + mining + " known, cancelling"); cancel(); return; } diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index 14060fba..cd4cf357 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -77,14 +77,14 @@ public class PathingBehavior extends Behavior { if (current.failed() || current.finished()) { current = null; if (goal == null || goal.isInGoal(playerFeet())) { - displayChatMessageRaw("All done. At " + goal); + logDebug("All done. At " + goal); dispatchPathEvent(PathEvent.AT_GOAL); next = null; return; } if (next != null && !next.getPath().positions().contains(playerFeet())) { // if the current path failed, we may not actually be on the next one, so make sure - displayChatMessageRaw("Discarding next path as it does not contain current position"); + logDebug("Discarding next path as it does not contain current position"); // for example if we had a nicely planned ahead path that starts where current ends // that's all fine and good // but if we fail in the middle of current @@ -94,7 +94,7 @@ public class PathingBehavior extends Behavior { next = null; } if (next != null) { - displayChatMessageRaw("Continuing on to planned next path"); + logDebug("Continuing on to planned next path"); dispatchPathEvent(PathEvent.CONTINUING_ONTO_PLANNED_NEXT); current = next; next = null; @@ -118,7 +118,7 @@ public class PathingBehavior extends Behavior { if (next != null) { if (next.getPath().positions().contains(playerFeet())) { // jump directly onto the next path - displayChatMessageRaw("Splicing into planned next path early..."); + logDebug("Splicing into planned next path early..."); dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY); current = next; next = null; @@ -141,7 +141,7 @@ public class PathingBehavior extends Behavior { } if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) { // and this path has 5 seconds or less left - displayChatMessageRaw("Path almost over. Planning ahead..."); + logDebug("Path almost over. Planning ahead..."); dispatchPathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED); findPathInNewThread(current.getPath().getDest(), false, Optional.of(current.getPath())); } @@ -248,7 +248,7 @@ public class PathingBehavior extends Behavior { } new Thread(() -> { if (talkAboutIt) { - displayChatMessageRaw("Starting to search for path from " + start + " to " + goal); + logDebug("Starting to search for path from " + start + " to " + goal); } Optional path = findPath(start, previous); @@ -280,9 +280,9 @@ public class PathingBehavior extends Behavior { if (talkAboutIt && current != null && current.getPath() != null) { if (goal == null || goal.isInGoal(current.getPath().getDest())) { - displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); + logDebug("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); } else { - displayChatMessageRaw("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); + logDebug("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered"); } } @@ -301,7 +301,7 @@ public class PathingBehavior extends Behavior { private Optional findPath(BlockPos start, Optional previous) { Goal goal = this.goal; if (goal == null) { - displayChatMessageRaw("no goal"); + logDebug("no goal"); return Optional.empty(); } if (Baritone.settings().simplifyUnloadedYCoord.get()) { @@ -320,7 +320,7 @@ public class PathingBehavior extends Behavior { } // TODO simplify each individual goal in a GoalComposite if (pos != null && world().getChunk(pos) instanceof EmptyChunk) { - displayChatMessageRaw("Simplifying " + goal.getClass() + " to GoalXZ due to distance"); + logDebug("Simplifying " + goal.getClass() + " to GoalXZ due to distance"); goal = new GoalXZ(pos.getX(), pos.getZ()); } } @@ -334,7 +334,7 @@ public class PathingBehavior extends Behavior { IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions)); return pf.calculate(timeout); } catch (Exception e) { - displayChatMessageRaw("Pathing exception: " + e); + logDebug("Pathing exception: " + e); e.printStackTrace(); return Optional.empty(); } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 674d5b64..16bc1997 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -77,7 +77,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { long startTime = System.nanoTime() / 1000000L; boolean slowPath = Baritone.settings().slowPath.get(); if (slowPath) { - displayChatMessageRaw("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.get() + "ms instead of " + timeout + "ms"); + logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.get() + "ms instead of " + timeout + "ms"); } long timeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.get() : timeout); //long lastPrintout = 0; @@ -102,7 +102,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { numNodes++; if (goal.isInGoal(currentNodePos)) { currentlyRunning = null; - displayChatMessageRaw("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); + logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); return Optional.of(new Path(startNode, currentNode, numNodes)); } Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order @@ -191,7 +191,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { bestDist = dist; } if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - displayChatMessageRaw("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i] + ", " + numMovementsConsidered + " movements considered"); + logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i] + ", " + numMovementsConsidered + " movements considered"); if (COEFFICIENTS[i] >= 3) { System.out.println("Warning: cost coefficient is greater than three! Probably means that"); System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)"); @@ -202,8 +202,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { return Optional.of(new Path(startNode, bestSoFar[i], numNodes)); } } - displayChatMessageRaw("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); - displayChatMessageRaw("No path found =("); + logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); + logDebug("No path found =("); currentlyRunning = null; return Optional.empty(); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 73a591ad..db5bbf49 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -139,7 +139,7 @@ public class MovementPillar extends Movement { if (ladder) { BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite()); if (against == null) { - displayChatMessageRaw("Unable to climb vines"); + logDebug("Unable to climb vines"); return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index da206d5e..67430d05 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -171,7 +171,7 @@ public class MovementTraverse extends Movement { boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionToPlace) || ladder; BlockPos whereAmI = playerFeet(); if (whereAmI.getY() != dest.getY() && !ladder) { - displayChatMessageRaw("Wrong Y coordinate"); + logDebug("Wrong Y coordinate"); if (whereAmI.getY() < dest.getY()) { state.setInput(InputOverrideHandler.Input.JUMP, true); } @@ -203,7 +203,7 @@ public class MovementTraverse extends Movement { against1 = against1.down(); if (MovementHelper.canPlaceAgainst(against1)) { if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block - displayChatMessageRaw("bb pls get me some blocks. dirt or cobble"); + logDebug("bb pls get me some blocks. dirt or cobble"); return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } state.setInput(InputOverrideHandler.Input.SNEAK, true); @@ -240,7 +240,7 @@ public class MovementTraverse extends Movement { // If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block - displayChatMessageRaw("bb pls get me some blocks. dirt or cobble"); + logDebug("bb pls get me some blocks. dirt or cobble"); return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D; diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index 39c17993..0db487d5 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -128,12 +128,12 @@ public interface IPath extends Helper { for (int i = 0; i < positions().size(); i++) { BlockPos pos = positions().get(i); if (Minecraft.getMinecraft().world.getChunk(pos) instanceof EmptyChunk) { - displayChatMessageRaw("Cutting off path at edge of loaded chunks"); - displayChatMessageRaw("Length decreased by " + (positions().size() - i - 1)); + logDebug("Cutting off path at edge of loaded chunks"); + logDebug("Length decreased by " + (positions().size() - i - 1)); return new CutoffPath(this, i); } } - displayChatMessageRaw("Path ends within loaded chunks"); + logDebug("Path ends within loaded chunks"); return this; } @@ -146,7 +146,7 @@ public interface IPath extends Helper { } double factor = Baritone.settings().pathCutoffFactor.get(); int newLength = (int) (length() * factor); - //displayChatMessageRaw("Static cutoff " + length() + " to " + newLength); + //logDebug("Static cutoff " + length() + " to " + newLength); return new CutoffPath(this, newLength); } } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index c1281359..5a8af7db 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -92,7 +92,7 @@ public class PathExecutor implements Helper { if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks if (whereAmI.equals(path.positions().get(i))) { - displayChatMessageRaw("Skipping back " + (pathPosition - i) + " steps, to " + i); + logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i); int previousPos = pathPosition; pathPosition = Math.max(i - 1, 0); // previous step might not actually be done for (int j = pathPosition; j <= previousPos; j++) { @@ -105,7 +105,7 @@ public class PathExecutor implements Helper { for (int i = pathPosition + 2; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing) if (whereAmI.equals(path.positions().get(i))) { if (i - pathPosition > 2) { - displayChatMessageRaw("Skipping forward " + (i - pathPosition) + " steps, to " + i); + logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i); } System.out.println("Double skip sundae"); pathPosition = i - 1; @@ -121,7 +121,7 @@ public class PathExecutor implements Helper { ticksAway++; System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + distanceFromPath + ". Threshold: " + MAX_DIST_FROM_PATH); if (ticksAway > MAX_TICKS_AWAY) { - displayChatMessageRaw("Too far away from path for too long, cancelling path"); + logDebug("Too far away from path for too long, cancelling path"); System.out.println("Too many ticks"); pathPosition = path.length() + 3; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); @@ -134,7 +134,7 @@ public class PathExecutor implements Helper { if (distanceFromPath > MAX_MAX_DIST_FROM_PATH) { if (!(path.movements().get(pathPosition) instanceof MovementFall)) { // might be midair if (pathPosition == 0 || !(path.movements().get(pathPosition - 1) instanceof MovementFall)) { // might have overshot the landing - displayChatMessageRaw("too far from path"); + logDebug("too far from path"); pathPosition = path.length() + 3; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); failed = true; @@ -211,7 +211,7 @@ public class PathExecutor implements Helper { } long end = System.nanoTime() / 1000000L; if (end - start > 0) { - //displayChatMessageRaw("Recalculating break and place took " + (end - start) + "ms"); + //logDebug("Recalculating break and place took " + (end - start) + "ms"); } Movement movement = path.movements().get(pathPosition); if (costEstimateIndex == null || costEstimateIndex != pathPosition) { @@ -220,7 +220,7 @@ public class PathExecutor implements Helper { currentMovementInitialCostEstimate = movement.getCost(null); for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) { - displayChatMessageRaw("Something has changed in the world and a future movement has become impossible. Cancelling."); + logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); pathPosition = path.length() + 3; failed = true; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); @@ -230,7 +230,7 @@ public class PathExecutor implements Helper { } double currentCost = movement.recalculateCost(); if (currentCost >= ActionCosts.COST_INF) { - displayChatMessageRaw("Something has changed in the world and this movement has become impossible. Cancelling."); + logDebug("Something has changed in the world and this movement has become impossible. Cancelling."); pathPosition = path.length() + 3; failed = true; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); @@ -238,7 +238,7 @@ public class PathExecutor implements Helper { } MovementState.MovementStatus movementStatus = movement.update(); if (movementStatus == UNREACHABLE || movementStatus == FAILED) { - displayChatMessageRaw("Movement returns status " + movementStatus); + logDebug("Movement returns status " + movementStatus); pathPosition = path.length() + 3; failed = true; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); @@ -259,7 +259,7 @@ public class PathExecutor implements Helper { // as you break the blocks required, the remaining cost goes down, to the point where // ticksOnCurrent is greater than recalculateCost + 100 // this is why we cache cost at the beginning, and don't recalculate for this comparison every tick - displayChatMessageRaw("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling."); + logDebug("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling."); movement.cancel(); Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); pathPosition = path.length() + 3; @@ -318,7 +318,7 @@ public class PathExecutor implements Helper { } return; } - //displayChatMessageRaw("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); + //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); } player().setSprinting(false); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index b12db109..6a301a6c 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -92,26 +92,26 @@ public class ExampleBaritoneControl extends Behavior { goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2]))); break; default: - displayChatMessageRaw("unable to understand lol"); + logDirect("unable to understand lol"); return; } } catch (NumberFormatException ex) { - displayChatMessageRaw("unable to parse integer " + ex); + logDirect("unable to parse integer " + ex); return; } PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Goal: " + goal); + logDirect("Goal: " + goal); return; } if (msg.equals("path")) { if (!PathingBehavior.INSTANCE.path()) { if (PathingBehavior.INSTANCE.getGoal() == null) { - displayChatMessageRaw("No goal."); + logDirect("No goal."); } else { if (PathingBehavior.INSTANCE.getGoal().isInGoal(playerFeet())) { - displayChatMessageRaw("Already in goal"); + logDirect("Already in goal"); } else { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + logDirect("Currently executing a path. Please cancel it first."); } } } @@ -123,13 +123,13 @@ public class ExampleBaritoneControl extends Behavior { FollowBehavior.INSTANCE.cancel(); MineBehavior.INSTANCE.cancel(); event.cancel(); - displayChatMessageRaw("ok canceled"); + logDirect("ok canceled"); return; } if (msg.toLowerCase().equals("forcecancel")) { AbstractNodeCostSearch.forceCancel(); event.cancel(); - displayChatMessageRaw("ok force canceled"); + logDirect("ok force canceled"); return; } if (msg.toLowerCase().equals("invert")) { @@ -140,8 +140,8 @@ public class ExampleBaritoneControl extends Behavior { } else if (goal instanceof GoalBlock) { runAwayFrom = ((GoalBlock) goal).getGoalPos(); } else { - displayChatMessageRaw("Goal must be GoalXZ or GoalBlock to invert"); - displayChatMessageRaw("Inverting goal of player feet"); + logDirect("Goal must be GoalXZ or GoalBlock to invert"); + logDirect("Inverting goal of player feet"); runAwayFrom = playerFeet(); } PathingBehavior.INSTANCE.setGoal(new GoalRunAway(1, runAwayFrom) { @@ -151,7 +151,7 @@ public class ExampleBaritoneControl extends Behavior { } }); if (!PathingBehavior.INSTANCE.path()) { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + logDirect("Currently executing a path. Please cancel it first."); } event.cancel(); return; @@ -159,31 +159,31 @@ public class ExampleBaritoneControl extends Behavior { if (msg.toLowerCase().equals("follow")) { Optional entity = MovementHelper.whatEntityAmILookingAt(); if (!entity.isPresent()) { - displayChatMessageRaw("You aren't looking at an entity bruh"); + logDirect("You aren't looking at an entity bruh"); event.cancel(); return; } FollowBehavior.INSTANCE.follow(entity.get()); - displayChatMessageRaw("Following " + entity.get()); + logDirect("Following " + entity.get()); event.cancel(); return; } if (msg.toLowerCase().equals("reloadall")) { WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk(); - displayChatMessageRaw("ok"); + logDirect("ok"); event.cancel(); return; } if (msg.toLowerCase().equals("saveall")) { WorldProvider.INSTANCE.getCurrentWorld().cache.save(); - displayChatMessageRaw("ok"); + logDirect("ok"); event.cancel(); return; } if (msg.toLowerCase().startsWith("find")) { String blockType = msg.toLowerCase().substring(4).trim(); LinkedList locs = WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(blockType, 1, 4); - displayChatMessageRaw("Have " + locs.size() + " locations"); + logDirect("Have " + locs.size() + " locations"); for (BlockPos pos : locs) { Block actually = BlockStateInterface.get(pos).getBlock(); if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) { @@ -197,20 +197,20 @@ public class ExampleBaritoneControl extends Behavior { String[] blockTypes = msg.toLowerCase().substring(4).trim().split(" "); for (String s : blockTypes) { if (ChunkPacker.stringToBlock(s) == null) { - displayChatMessageRaw(s + " isn't a valid block name"); + logDirect(s + " isn't a valid block name"); event.cancel(); return; } } MineBehavior.INSTANCE.mine(blockTypes); - displayChatMessageRaw("Started mining blocks of type " + Arrays.toString(blockTypes)); + logDirect("Started mining blocks of type " + Arrays.toString(blockTypes)); event.cancel(); return; } if (msg.toLowerCase().startsWith("thisway")) { Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim())); PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Goal: " + goal); + logDirect("Goal: " + goal); event.cancel(); return; } @@ -222,7 +222,7 @@ public class ExampleBaritoneControl extends Behavior { } Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); if (tag == null) { - displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); + logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); return; } @@ -230,9 +230,9 @@ public class ExampleBaritoneControl extends Behavior { // might as well show them from oldest to newest List sorted = new ArrayList<>(waypoints); sorted.sort(Comparator.comparingLong(Waypoint::creationTimestamp)); - displayChatMessageRaw("Waypoints under tag " + tag + ":"); + logDirect("Waypoints under tag " + tag + ":"); for (Waypoint waypoint : sorted) { - displayChatMessageRaw(waypoint.toString()); + logDirect(waypoint.toString()); } event.cancel(); return; @@ -246,15 +246,15 @@ public class ExampleBaritoneControl extends Behavior { Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); if (tag == null) { String mining = waypointType; - //displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); + //logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); if (ChunkPacker.stringToBlock(mining) == null) { - displayChatMessageRaw("No locations for " + mining + " known, cancelling"); + logDirect("No locations for " + mining + " known, cancelling"); return; } List locs = MineBehavior.scanFor(Arrays.asList(mining), 64); if (locs.isEmpty()) { - displayChatMessageRaw("No locations for " + mining + " known, cancelling"); + logDirect("No locations for " + mining + " known, cancelling"); return; } PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new))); @@ -263,7 +263,7 @@ public class ExampleBaritoneControl extends Behavior { } Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag); if (waypoint == null) { - displayChatMessageRaw("None saved for tag " + tag); + logDirect("None saved for tag " + tag); event.cancel(); return; } @@ -271,7 +271,7 @@ public class ExampleBaritoneControl extends Behavior { PathingBehavior.INSTANCE.setGoal(goal); if (!PathingBehavior.INSTANCE.path()) { if (!goal.isInGoal(playerFeet())) { - displayChatMessageRaw("Currently executing a path. Please cancel it first."); + logDirect("Currently executing a path. Please cancel it first."); } } event.cancel(); @@ -283,30 +283,30 @@ public class ExampleBaritoneControl extends Behavior { BlockPos spawnPoint = player().getBedLocation(); // for some reason the default spawnpoint is underground sometimes Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getZ()); - displayChatMessageRaw("spawn not saved, defaulting to world spawn. set goal to " + goal); + logDirect("spawn not saved, defaulting to world spawn. set goal to " + goal); PathingBehavior.INSTANCE.setGoal(goal); } else { Goal goal = new GoalBlock(waypoint.location); PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Set goal to most recent bed " + goal); + logDirect("Set goal to most recent bed " + goal); } event.cancel(); return; } if (msg.toLowerCase().equals("sethome")) { WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet())); - displayChatMessageRaw("Saved. Say home to set goal."); + logDirect("Saved. Say home to set goal."); event.cancel(); return; } if (msg.toLowerCase().equals("home")) { Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME); if (waypoint == null) { - displayChatMessageRaw("home not saved"); + logDirect("home not saved"); } else { Goal goal = new GoalBlock(waypoint.location); PathingBehavior.INSTANCE.setGoal(goal); - displayChatMessageRaw("Set goal to saved home " + goal); + logDirect("Set goal to saved home " + goal); } event.cancel(); return; @@ -325,7 +325,7 @@ public class ExampleBaritoneControl extends Behavior { if (cost >= ActionCosts.COST_INF) { strCost = "IMPOSSIBLE"; } - displayChatMessageRaw(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost); + logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost); } event.cancel(); return; @@ -335,13 +335,13 @@ public class ExampleBaritoneControl extends Behavior { if (msg.equalsIgnoreCase(setting.getName())) { setting.value ^= true; event.cancel(); - displayChatMessageRaw("Toggled " + setting.getName() + " to " + setting.value); + logDirect("Toggled " + setting.getName() + " to " + setting.value); return; } } if (msg.toLowerCase().equals("baritone") || msg.toLowerCase().equals("settings")) { for (Settings.Setting setting : Baritone.settings().allSettings) { - displayChatMessageRaw(setting.toString()); + logDirect(setting.toString()); } event.cancel(); return; @@ -362,11 +362,11 @@ public class ExampleBaritoneControl extends Behavior { setting.value = Double.parseDouble(data[1]); } } catch (NumberFormatException e) { - displayChatMessageRaw("Unable to parse " + data[1]); + logDirect("Unable to parse " + data[1]); event.cancel(); return; } - displayChatMessageRaw(setting.toString()); + logDirect(setting.toString()); event.cancel(); return; } @@ -374,7 +374,7 @@ public class ExampleBaritoneControl extends Behavior { } if (Baritone.settings().byLowerName.containsKey(msg.toLowerCase())) { Settings.Setting setting = Baritone.settings().byLowerName.get(msg.toLowerCase()); - displayChatMessageRaw(setting.toString()); + logDirect(setting.toString()); event.cancel(); return; } diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index 30e1f398..9bcf082d 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -73,15 +73,24 @@ public interface Helper { return new Rotation(player().rotationYaw, player().rotationPitch); } - default void displayChatMessageRaw(String message) { + /** + * Send a message to chat only if chatDebug is on + * @param message + */ + default void logDebug(String message) { if (!Baritone.settings().chatDebug.get()) { System.out.println("Suppressed debug message:"); System.out.println(message); - /*if (!Stream.of(Thread.currentThread().getStackTrace()).map(StackTraceElement::getClassName).anyMatch(x -> x.equals(ExampleBaritoneControl.class.getName()))) { - return; - }*/ + return; } + logDirect(message); + } + /** + * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command) + * @param message + */ + default void logDirect(String message) { ITextComponent component = MESSAGE_PREFIX.createCopy(); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(new TextComponentString(" " + message)); From e6c574063e86547d07e2c27db4004668fd2e855d Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 11 Sep 2018 17:37:26 -0500 Subject: [PATCH 105/329] Prevent flying capabilities when pathing, fixes #130 --- src/main/java/baritone/behavior/impl/PathingBehavior.java | 1 + src/main/java/baritone/pathing/path/PathExecutor.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index cd4cf357..f5c81acd 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -196,6 +196,7 @@ public class PathingBehavior extends Behavior { next = null; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel); + mc.playerController.setPlayerCapabilities(mc.player); } /** diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 5a8af7db..e59d9aa7 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -236,6 +236,7 @@ public class PathExecutor implements Helper { Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); return true; } + player().capabilities.allowFlying = false; MovementState.MovementStatus movementStatus = movement.update(); if (movementStatus == UNREACHABLE || movementStatus == FAILED) { logDebug("Movement returns status " + movementStatus); From 1bf34d42e2f88d3bc8eb0924b4ff1984a83447b3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 15:50:46 -0700 Subject: [PATCH 106/329] added maxCostIncrease, fixes #154 --- src/main/java/baritone/Settings.java | 6 ++++++ src/main/java/baritone/pathing/path/PathExecutor.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index bfab655e..c2a618b9 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -144,6 +144,12 @@ public class Settings { */ public Setting cutoffAtLoadBoundary = new Setting<>(false); + /** + * If a movement's cost increases by more than this amount between calculation and execution (due to changes + * in the environment / world), cancel and recalculate + */ + public Setting maxCostIncrease = new Setting<>(10D); + /** * Stop 5 movements before anything that made the path COST_INF. * For example, if lava has spread across the path, don't walk right up to it then recalculate, it might diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index e59d9aa7..93e12e09 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -236,6 +236,13 @@ public class PathExecutor implements Helper { Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); return true; } + if (currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) { + logDebug("Original cost " + currentMovementInitialCostEstimate + " current cost " + currentCost + ". Cancelling."); + pathPosition = path.length() + 3; + failed = true; + Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + return true; + } player().capabilities.allowFlying = false; MovementState.MovementStatus movementStatus = movement.update(); if (movementStatus == UNREACHABLE || movementStatus == FAILED) { From acd9cecd669f1ab23d28de58e542d3949e6f846d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 18:26:10 -0700 Subject: [PATCH 107/329] improve path safety --- .../behavior/impl/PathingBehavior.java | 10 +++++-- .../java/baritone/pathing/path/IPath.java | 29 +------------------ .../baritone/pathing/path/PathExecutor.java | 13 +++++++++ 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index f5c81acd..8ce34ecc 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -40,7 +40,7 @@ import java.awt.*; import java.util.Collections; import java.util.Optional; -public class PathingBehavior extends Behavior { +public final class PathingBehavior extends Behavior { public static final PathingBehavior INSTANCE = new PathingBehavior(); @@ -66,7 +66,7 @@ public class PathingBehavior extends Behavior { @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { - this.cancel(); + softCancel(); // no player, so can't fix capabilities return; } if (current == null) { @@ -191,11 +191,15 @@ public class PathingBehavior extends Behavior { return Optional.ofNullable(current).map(PathExecutor::getPath); } - public void cancel() { + private void softCancel() { current = null; next = null; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel); + } + + public void cancel() { + softCancel(); mc.playerController.setPlayerCapabilities(mc.player); } diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index 0db487d5..575aacb1 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -58,33 +58,6 @@ public interface IPath extends Helper { return positions().size(); } - /** - * What's the next step - * - * @param currentPosition the current position - * @return - */ - default Movement subsequentMovement(BlockPos currentPosition) { - List pos = positions(); - List movements = movements(); - for (int i = 0; i < pos.size(); i++) { - if (currentPosition.equals(pos.get(i))) { - return movements.get(i); - } - } - throw new UnsupportedOperationException(currentPosition + " not in path"); - } - - /** - * Determines whether or not a position is within this path. - * - * @param pos The position to check - * @return Whether or not the specified position is in this class - */ - default boolean isInPath(BlockPos pos) { - return positions().contains(pos); - } - default Tuple closestPathPos(double x, double y, double z) { double best = -1; BlockPos bestPos = null; @@ -146,7 +119,7 @@ public interface IPath extends Helper { } double factor = Baritone.settings().pathCutoffFactor.get(); int newLength = (int) (length() * factor); - //logDebug("Static cutoff " + length() + " to " + newLength); + logDebug("Static cutoff " + length() + " to " + newLength); return new CutoffPath(this, newLength); } } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 93e12e09..ab132ca0 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -291,6 +291,19 @@ public class PathExecutor implements Helper { } Movement movement = path.movements().get(pathPosition); if (movement instanceof MovementDescend && pathPosition < path.length() - 2) { + BlockPos descendStart = movement.getSrc(); + BlockPos descendEnd = movement.getDest(); + BlockPos into = descendEnd.subtract(descendStart.down()).add(descendEnd); + if (into.getY() != descendEnd.getY()) { + throw new IllegalStateException(); // sanity check + } + for (int i = 0; i <= 2; i++) { + if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(into.up(i)))) { + logDebug("Sprinting would be unsafe"); + player().setSprinting(false); + return; + } + } Movement next = path.movements().get(pathPosition + 1); if (next instanceof MovementDescend) { if (next.getDirection().equals(movement.getDirection())) { From 9334cf1dd45b30c98c3d874234eb90ec40d3f230 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 18:33:03 -0700 Subject: [PATCH 108/329] stop walking into liquids, fixes #155 --- src/main/java/baritone/cache/ChunkPacker.java | 2 +- src/main/java/baritone/pathing/movement/MovementHelper.java | 3 ++- .../baritone/pathing/movement/movements/MovementParkour.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 7167df34..9dffe5ae 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -152,7 +152,7 @@ public final class ChunkPacker implements Helper { return PathingBlockType.WATER; } - if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || MovementHelper.isBottomSlab(state)) { + if (MovementHelper.avoidWalkingInto(block) || block == Blocks.FLOWING_WATER || MovementHelper.isBottomSlab(state)) { return PathingBlockType.AVOID; } // We used to do an AABB check here diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6aab4bd5..3f68cba6 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -209,7 +209,8 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean avoidWalkingInto(Block block) { - return BlockStateInterface.isLava(block) + return block instanceof BlockLiquid + || block instanceof BlockDynamicLiquid || block == Blocks.MAGMA || block == Blocks.CACTUS || block == Blocks.FIRE diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 07126ca1..24f8883f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -52,7 +52,7 @@ public class MovementParkour extends Movement { } BlockPos adjBlock = src.down().offset(dir); IBlockState adj = BlockStateInterface.get(adjBlock); - if (MovementHelper.avoidWalkingInto(adj.getBlock())) { // magma sucks + if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks return null; } if (MovementHelper.canWalkOn(adjBlock, adj)) { // don't parkour if we could just traverse (for now) From 0412298555094c905837618c8ec2e2123a6fd9ba Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 19:05:45 -0700 Subject: [PATCH 109/329] don't try to place against water, actually fixes #155 --- .../baritone/pathing/movement/movements/MovementTraverse.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 67430d05..9ee084ae 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -115,6 +115,9 @@ public class MovementTraverse extends Movement { if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) { return COST_INF; // can't sneak and backplace against soul sand or half slabs =/ } + if (srcDown == Blocks.FLOWING_WATER || srcDown == Blocks.WATER) { + return COST_INF; // this is obviously impossible + } WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are placing, we are sneaking return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); } From 3afc77bc9a1e711ef4228437e1f694c091418827 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 19:39:47 -0700 Subject: [PATCH 110/329] fix infinite recalc when jumping over flowing water --- .../pathing/movement/movements/MovementParkour.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 24f8883f..a53a4d32 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; @@ -43,6 +44,7 @@ public class MovementParkour extends Movement { } public static MovementParkour generate(BetterBlockPos src, EnumFacing dir) { + // MUST BE KEPT IN SYNC WITH calculateCost if (!Baritone.settings().allowParkour.get()) { return null; } @@ -101,10 +103,12 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { + // MUST BE KEPT IN SYNC WITH generate if (!MovementHelper.canWalkOn(dest.down())) { return COST_INF; } - if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(src.down().offset(direction)).getBlock())) { + Block walkOff = BlockStateInterface.get(src.down().offset(direction)).getBlock(); + if (MovementHelper.avoidWalkingInto(walkOff) && walkOff != Blocks.WATER && walkOff != Blocks.FLOWING_WATER) { return COST_INF; } for (int i = 1; i <= 4; i++) { From 5669204b4a89159fc59164dd239ba8722372b092 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 20:09:53 -0700 Subject: [PATCH 111/329] skynet --- .../pathing/calc/AStarPathFinder.java | 8 +- .../movement/movements/MovementParkour.java | 84 ++++++++++++++++++- 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 16bc1997..643df531 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -243,10 +243,10 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), - MovementParkour.generate(pos, EnumFacing.EAST), - MovementParkour.generate(pos, EnumFacing.WEST), - MovementParkour.generate(pos, EnumFacing.NORTH), - MovementParkour.generate(pos, EnumFacing.SOUTH), + MovementParkour.generate(pos, EnumFacing.EAST, calcContext), + MovementParkour.generate(pos, EnumFacing.WEST, calcContext), + MovementParkour.generate(pos, EnumFacing.NORTH, calcContext), + MovementParkour.generate(pos, EnumFacing.SOUTH, calcContext), }; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index a53a4d32..61056ff2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -18,20 +18,28 @@ package baritone.pathing.movement.movements; import baritone.Baritone; +import baritone.behavior.impl.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; +import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import java.util.Objects; public class MovementParkour extends Movement { + protected static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; + final EnumFacing direction; final int dist; @@ -43,7 +51,7 @@ public class MovementParkour extends Movement { super.override(costFromJumpDistance(dist)); } - public static MovementParkour generate(BetterBlockPos src, EnumFacing dir) { + public static MovementParkour generate(BetterBlockPos src, EnumFacing dir, CalculationContext context) { // MUST BE KEPT IN SYNC WITH calculateCost if (!Baritone.settings().allowParkour.get()) { return null; @@ -85,6 +93,27 @@ public class MovementParkour extends Movement { return new MovementParkour(src, i, dir); } } + BlockPos dest = src.offset(dir, 4); + BlockPos positionToPlace = dest.down(); + IBlockState toPlace = BlockStateInterface.get(positionToPlace); + if (!context.hasThrowaway()) { + return null; + } + if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { + return null; + } + for (int i = 0; i < 5; i++) { + BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); + if (against1.up().equals(src.offset(dir, 3))) { // we can't turn around that fast + continue; + } + if (MovementHelper.canPlaceAgainst(against1)) { + // holy jesus we gonna do it + MovementParkour ret = new MovementParkour(src, 4, dir); + ret.override(costFromJumpDistance(4) + context.placeBlockCost()); + return ret; + } + } return null; } @@ -104,8 +133,30 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { // MUST BE KEPT IN SYNC WITH generate + boolean placing = false; if (!MovementHelper.canWalkOn(dest.down())) { - return COST_INF; + if (dist != 4) { + return COST_INF; + } + BlockPos positionToPlace = dest.down(); + IBlockState toPlace = BlockStateInterface.get(positionToPlace); + if (!context.hasThrowaway()) { + return COST_INF; + } + if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { + return COST_INF; + } + for (int i = 0; i < 5; i++) { + BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); + if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast + continue; + } + if (MovementHelper.canPlaceAgainst(against1)) { + // holy jesus we gonna do it + placing = true; + break; + } + } } Block walkOff = BlockStateInterface.get(src.down().offset(direction)).getBlock(); if (MovementHelper.avoidWalkingInto(walkOff) && walkOff != Blocks.WATER && walkOff != Blocks.FLOWING_WATER) { @@ -119,7 +170,7 @@ public class MovementParkour extends Movement { } } if (d.equals(dest)) { - return costFromJumpDistance(i); + return costFromJumpDistance(i) + (placing ? context.placeBlockCost() : 0); } } throw new IllegalStateException("invalid jump distance?"); @@ -146,6 +197,33 @@ public class MovementParkour extends Movement { } } else if (!playerFeet().equals(src)) { if (playerFeet().equals(src.offset(direction)) || player().posY - playerFeet().getY() > 0.0001) { + + if (!MovementHelper.canWalkOn(dest.down())) { + BlockPos positionToPlace = dest.down(); + for (int i = 0; i < 5; i++) { + BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); + if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast + continue; + } + if (MovementHelper.canPlaceAgainst(against1)) { + if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block + return state.setStatus(MovementState.MovementStatus.UNREACHABLE); + } + double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D; + double faceY = (dest.getY() + against1.getY()) * 0.5D; + double faceZ = (dest.getZ() + against1.getZ() + 1.0D) * 0.5D; + state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true)); + EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit; + + LookBehaviorUtils.getSelectedBlock().ifPresent(selectedBlock -> { + if (Objects.equals(selectedBlock, against1) && selectedBlock.offset(side).equals(dest.down())) { + state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); + } + }); + } + } + } + state.setInput(InputOverrideHandler.Input.JUMP, true); } else { state.setInput(InputOverrideHandler.Input.SPRINT, false); From e82f6b8e35377120372659c3f3bf62834821eb65 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 20:24:27 -0700 Subject: [PATCH 112/329] assumeStep --- src/main/java/baritone/Settings.java | 5 +++++ .../baritone/pathing/movement/movements/MovementAscend.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index c2a618b9..1f18219e 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -62,6 +62,11 @@ public class Settings { */ public Setting assumeWalkOnWater = new Setting<>(false); + /** + * Assume step functionality; don't jump on an Ascend. + */ + public Setting assumeStep = new Setting<>(false); + /** * Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.) */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 9ddb7760..60591d88 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -17,6 +17,7 @@ package baritone.pathing.movement.movements; +import baritone.Baritone; import baritone.behavior.impl.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; @@ -177,6 +178,10 @@ public class MovementAscend extends Movement { } } + if (Baritone.settings().assumeStep.get()) { + return state; + } + if (headBonkClear()) { return state.setInput(InputOverrideHandler.Input.JUMP, true); } From 7f983c92f40387e698eb982015334e0fbe4690bd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Sep 2018 20:50:29 -0700 Subject: [PATCH 113/329] assumeSafeWalk --- src/main/java/baritone/Settings.java | 9 +++++++++ .../pathing/movement/movements/MovementTraverse.java | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 1f18219e..d29ec995 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -67,6 +67,15 @@ public class Settings { */ public Setting assumeStep = new Setting<>(false); + /** + * Assume safe walk functionality; don't sneak on a backplace traverse. + *

+ * Warning: if you do something janky like sneak-backplace from an ender chest, if this is true + * it won't sneak right click, it'll just right click, which means it'll open the chest instead of placing + * against it. That's why this defaults to off. + */ + public Setting assumeSafeWalk = new Setting<>(false); + /** * Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.) */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 9ee084ae..df0f3a27 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -17,6 +17,7 @@ package baritone.pathing.movement.movements; +import baritone.Baritone; import baritone.behavior.impl.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; @@ -209,7 +210,9 @@ public class MovementTraverse extends Movement { logDebug("bb pls get me some blocks. dirt or cobble"); return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } - state.setInput(InputOverrideHandler.Input.SNEAK, true); + if (!Baritone.settings().assumeSafeWalk.get()) { + state.setInput(InputOverrideHandler.Input.SNEAK, true); + } Block standingOn = BlockStateInterface.get(playerFeet().down()).getBlock(); if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118 double dist = Math.max(Math.abs(dest.getX() + 0.5 - player().posX), Math.abs(dest.getZ() + 0.5 - player().posZ)); @@ -238,7 +241,9 @@ public class MovementTraverse extends Movement { return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); } } - state.setInput(InputOverrideHandler.Input.SNEAK, true); + if (!Baritone.settings().assumeSafeWalk.get()) { + state.setInput(InputOverrideHandler.Input.SNEAK, true); + } if (whereAmI.equals(dest)) { // If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); From 39a3c1cd4ac23b3a68f1c60709cc06c6bbe0f72c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 12 Sep 2018 07:55:40 -0700 Subject: [PATCH 114/329] oh my god --- src/main/java/baritone/pathing/movement/ActionCosts.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/ActionCosts.java b/src/main/java/baritone/pathing/movement/ActionCosts.java index 9baff727..3be99c9f 100644 --- a/src/main/java/baritone/pathing/movement/ActionCosts.java +++ b/src/main/java/baritone/pathing/movement/ActionCosts.java @@ -24,8 +24,8 @@ public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieI */ double WALK_ONE_BLOCK_COST = 20 / 4.317; // 4.633 double WALK_ONE_IN_WATER_COST = 20 / 2.2; - double WALK_ONE_OVER_SOUL_SAND_COST = WALK_ONE_BLOCK_COST * 0.5; // 0.4 in BlockSoulSand but effectively about half - double SPRINT_ONE_OVER_SOUL_SAND_COST = WALK_ONE_OVER_SOUL_SAND_COST / 0.75; + double WALK_ONE_OVER_SOUL_SAND_COST = WALK_ONE_BLOCK_COST * 2; // 0.4 in BlockSoulSand but effectively about half + double SPRINT_ONE_OVER_SOUL_SAND_COST = WALK_ONE_OVER_SOUL_SAND_COST * 0.75; double LADDER_UP_ONE_COST = 20 / 2.35; double LADDER_DOWN_ONE_COST = 20 / 3.0; double SNEAK_ONE_BLOCK_COST = 20 / 1.3; From 2fd888b9eebf3e3b691e55c6603e46969677412f Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 12 Sep 2018 17:12:06 -0500 Subject: [PATCH 115/329] Replace String lists containing block names with actual block lists It just makes sense like wtf --- .../behavior/impl/FollowBehavior.java | 9 ++++-- .../baritone/behavior/impl/MineBehavior.java | 28 +++++++++++-------- src/main/java/baritone/cache/ChunkPacker.java | 3 +- .../java/baritone/cache/WorldScanner.java | 12 ++++---- .../utils/ExampleBaritoneControl.java | 5 ++-- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/FollowBehavior.java b/src/main/java/baritone/behavior/impl/FollowBehavior.java index 55ec5539..8f9a8615 100644 --- a/src/main/java/baritone/behavior/impl/FollowBehavior.java +++ b/src/main/java/baritone/behavior/impl/FollowBehavior.java @@ -29,6 +29,7 @@ import net.minecraft.util.math.BlockPos; * @author leijurv */ public class FollowBehavior extends Behavior { + public static final FollowBehavior INSTANCE = new FollowBehavior(); private FollowBehavior() { @@ -49,8 +50,12 @@ public class FollowBehavior extends Behavior { PathingBehavior.INSTANCE.path(); } - public void follow(Entity follow) { - this.following = follow; + public void follow(Entity entity) { + this.following = entity; + } + + public Entity following() { + return this.following; } public void cancel() { diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 5b0d6a5a..9b220d01 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -27,6 +27,7 @@ import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; import baritone.utils.BlockStateInterface; +import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -47,14 +48,14 @@ public class MineBehavior extends Behavior { private MineBehavior() { } - List mining; + private List mining; @Override public void onPathEvent(PathEvent event) { updateGoal(); } - public void updateGoal() { + private void updateGoal() { if (mining == null) { return; } @@ -68,13 +69,13 @@ public class MineBehavior extends Behavior { PathingBehavior.INSTANCE.path(); } - public static List scanFor(List mining, int max) { + public static List scanFor(List mining, int max) { List locs = new ArrayList<>(); - List uninteresting = new ArrayList<>(); + List uninteresting = new ArrayList<>(); //long b = System.currentTimeMillis(); - for (String m : mining) { - if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(ChunkPacker.stringToBlock(m))) { - locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); + for (Block m : mining) { + if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { + locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(ChunkPacker.blockToString(m), 1, 1)); } else { uninteresting.add(m); } @@ -91,7 +92,7 @@ public class MineBehavior extends Behavior { // remove any that are within loaded chunks that aren't actually what we want locs.removeAll(locs.stream() .filter(pos -> !(MineBehavior.INSTANCE.world().getChunk(pos) instanceof EmptyChunk)) - .filter(pos -> !mining.contains(ChunkPacker.blockToString(BlockStateInterface.get(pos).getBlock()).toLowerCase())) + .filter(pos -> !mining.contains(BlockStateInterface.get(pos).getBlock())) .collect(Collectors.toList())); if (locs.size() > max) { locs = locs.subList(0, max); @@ -99,13 +100,18 @@ public class MineBehavior extends Behavior { return locs; } - public void mine(String... mining) { - this.mining = mining == null || mining.length == 0 ? null : new ArrayList<>(Arrays.asList(mining)); + public void mine(String... blocks) { + this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList()); + updateGoal(); + } + + public void mine(Block... blocks) { + this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks); updateGoal(); } public void cancel() { PathingBehavior.INSTANCE.cancel(); - mine(); + mine((String[]) null); } } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 9dffe5ae..5c2374ce 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -124,8 +124,7 @@ public final class ChunkPacker implements Helper { blockNames[z << 4 | x] = "air"; } } - CachedChunk cached = new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks); - return cached; + return new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks); } public static String blockToString(Block block) { diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 2b1ebe23..975683d1 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -28,18 +28,16 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import java.util.LinkedList; import java.util.List; -import java.util.stream.Collectors; public enum WorldScanner implements Helper { INSTANCE; - public List scanLoadedChunks(List blockTypes, int max) { - List asBlocks = blockTypes.stream().map(ChunkPacker::stringToBlock).collect(Collectors.toList()); - if (asBlocks.contains(null)) { - throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString()); + public List scanLoadedChunks(List blocks, int max) { + if (blocks.contains(null)) { + throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString()); } LinkedList res = new LinkedList<>(); - if (asBlocks.isEmpty()) { + if (blocks.isEmpty()) { return res; } ChunkProviderClient chunkProvider = world().getChunkProvider(); @@ -79,7 +77,7 @@ public enum WorldScanner implements Helper { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { IBlockState state = bsc.get(x, y, z); - if (asBlocks.contains(state.getBlock())) { + if (blocks.contains(state.getBlock())) { res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z)); } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 6a301a6c..3abd11b5 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -246,13 +246,14 @@ public class ExampleBaritoneControl extends Behavior { Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); if (tag == null) { String mining = waypointType; + Block block = ChunkPacker.stringToBlock(mining); //logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); - if (ChunkPacker.stringToBlock(mining) == null) { + if (block == null) { logDirect("No locations for " + mining + " known, cancelling"); return; } - List locs = MineBehavior.scanFor(Arrays.asList(mining), 64); + List locs = MineBehavior.scanFor(Collections.singletonList(block), 64); if (locs.isEmpty()) { logDirect("No locations for " + mining + " known, cancelling"); return; From fb8ee44447dbd02eab59a48eb37dbdb37c862a08 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 12 Sep 2018 17:25:01 -0500 Subject: [PATCH 116/329] Remove hacky "softCancel" thing --- .../java/baritone/behavior/impl/PathingBehavior.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index 8ce34ecc..531741fe 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -66,9 +66,10 @@ public final class PathingBehavior extends Behavior { @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { - softCancel(); // no player, so can't fix capabilities + this.cancel(); return; } + mc.playerController.setPlayerCapabilities(mc.player); if (current == null) { return; } @@ -191,18 +192,13 @@ public final class PathingBehavior extends Behavior { return Optional.ofNullable(current).map(PathExecutor::getPath); } - private void softCancel() { + public void cancel() { current = null; next = null; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel); } - public void cancel() { - softCancel(); - mc.playerController.setPlayerCapabilities(mc.player); - } - /** * Start calculating a path if we aren't already * From 0a0209d2e15c1ec69e96de27ef0383d2d9d25453 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 12 Sep 2018 17:53:29 -0500 Subject: [PATCH 117/329] Move Behavior to api --- .../java/baritone/api}/behavior/Behavior.java | 44 ++++--------------- .../api}/utils/interfaces/Toggleable.java | 12 ++++- src/main/java/baritone/Baritone.java | 2 +- .../behavior/impl/FollowBehavior.java | 2 +- .../impl/LocationTrackingBehavior.java | 5 ++- .../baritone/behavior/impl/LookBehavior.java | 5 ++- .../behavior/impl/MemoryBehavior.java | 5 ++- .../baritone/behavior/impl/MineBehavior.java | 6 ++- .../behavior/impl/PathingBehavior.java | 5 ++- .../java/baritone/event/GameEventHandler.java | 2 +- .../utils/ExampleBaritoneControl.java | 5 ++- 11 files changed, 41 insertions(+), 52 deletions(-) rename src/{main/java/baritone => api/java/baritone/api}/behavior/Behavior.java (59%) rename src/{main/java/baritone => api/java/baritone/api}/utils/interfaces/Toggleable.java (81%) diff --git a/src/main/java/baritone/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java similarity index 59% rename from src/main/java/baritone/behavior/Behavior.java rename to src/api/java/baritone/api/behavior/Behavior.java index 5bf6c5c6..67d3c25b 100644 --- a/src/main/java/baritone/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -15,19 +15,18 @@ * along with Baritone. If not, see . */ -package baritone.behavior; +package baritone.api.behavior; import baritone.api.event.listener.AbstractGameEventListener; -import baritone.utils.Helper; -import baritone.utils.interfaces.Toggleable; +import baritone.api.utils.interfaces.Toggleable; /** - * A generic bot behavior. + * A type of game event listener that can be toggled. * * @author Brady * @since 8/1/2018 6:29 PM */ -public class Behavior implements AbstractGameEventListener, Toggleable, Helper { +public class Behavior implements AbstractGameEventListener, Toggleable { /** * Whether or not this behavior is enabled @@ -51,35 +50,18 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper { */ @Override public final boolean setEnabled(boolean enabled) { - boolean newState = getNewState(this.enabled, enabled); - if (newState == this.enabled) { + if (enabled == this.enabled) return this.enabled; - } - if (this.enabled = newState) { - onStart(); + if (this.enabled = enabled) { + this.onEnable(); } else { - onCancel(); + this.onDisable(); } return this.enabled; } - /** - * Function to determine what the new enabled state of this - * {@link Behavior} should be given the old state, and the - * proposed state. Intended to be overridden by behaviors - * that should always be active, given that the bot itself is - * active. - * - * @param oldState The old state - * @param proposedState The proposed state - * @return The new state - */ - public boolean getNewState(boolean oldState, boolean proposedState) { - return proposedState; - } - /** * @return Whether or not this {@link Behavior} is active. */ @@ -87,14 +69,4 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper { public final boolean isEnabled() { return this.enabled; } - - /** - * Called when the state changes from disabled to enabled - */ - public void onStart() {} - - /** - * Called when the state changes from enabled to disabled - */ - public void onCancel() {} } diff --git a/src/main/java/baritone/utils/interfaces/Toggleable.java b/src/api/java/baritone/api/utils/interfaces/Toggleable.java similarity index 81% rename from src/main/java/baritone/utils/interfaces/Toggleable.java rename to src/api/java/baritone/api/utils/interfaces/Toggleable.java index ba23bd34..bf43220a 100644 --- a/src/main/java/baritone/utils/interfaces/Toggleable.java +++ b/src/api/java/baritone/api/utils/interfaces/Toggleable.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.utils.interfaces; +package baritone.api.utils.interfaces; /** * @author Brady @@ -41,4 +41,14 @@ public interface Toggleable { * @return Whether or not this {@link Toggleable} object is enabled */ boolean isEnabled(); + + /** + * Called when the state changes from disabled to enabled + */ + default void onEnable() {} + + /** + * Called when the state changes from enabled to disabled + */ + default void onDisable() {} } diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 3c7bf24c..6c7acc5f 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -18,7 +18,7 @@ package baritone; import baritone.api.event.listener.IGameEventListener; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.behavior.impl.*; import baritone.event.GameEventHandler; import baritone.utils.InputOverrideHandler; diff --git a/src/main/java/baritone/behavior/impl/FollowBehavior.java b/src/main/java/baritone/behavior/impl/FollowBehavior.java index 8f9a8615..eb67dfa0 100644 --- a/src/main/java/baritone/behavior/impl/FollowBehavior.java +++ b/src/main/java/baritone/behavior/impl/FollowBehavior.java @@ -18,7 +18,7 @@ package baritone.behavior.impl; import baritone.api.event.events.TickEvent; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.pathing.goals.GoalNear; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java index 47dfcd7c..fb7d9db8 100644 --- a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java @@ -17,11 +17,12 @@ package baritone.behavior.impl; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; import baritone.api.event.events.BlockInteractEvent; import baritone.utils.BlockStateInterface; +import baritone.utils.Helper; import net.minecraft.block.BlockBed; /** @@ -33,7 +34,7 @@ import net.minecraft.block.BlockBed; * @author Brady * @since 8/22/2018 */ -public final class LocationTrackingBehavior extends Behavior { +public final class LocationTrackingBehavior extends Behavior implements Helper { public static final LocationTrackingBehavior INSTANCE = new LocationTrackingBehavior(); diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java index 904087ab..ddf58619 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/impl/LookBehavior.java @@ -21,10 +21,11 @@ import baritone.Baritone; import baritone.Settings; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; +import baritone.utils.Helper; import baritone.utils.Rotation; -public class LookBehavior extends Behavior { +public class LookBehavior extends Behavior implements Helper { public static final LookBehavior INSTANCE = new LookBehavior(); diff --git a/src/main/java/baritone/behavior/impl/MemoryBehavior.java b/src/main/java/baritone/behavior/impl/MemoryBehavior.java index 93657988..5d99c2d1 100644 --- a/src/main/java/baritone/behavior/impl/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/impl/MemoryBehavior.java @@ -3,7 +3,8 @@ package baritone.behavior.impl; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; +import baritone.utils.Helper; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; import net.minecraft.network.play.client.CPacketCloseWindow; @@ -20,7 +21,7 @@ import java.util.*; * @author Brady * @since 8/6/2018 9:47 PM */ -public class MemoryBehavior extends Behavior { +public class MemoryBehavior extends Behavior implements Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index 9b220d01..a36aa02f 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -18,7 +18,7 @@ package baritone.behavior.impl; import baritone.api.event.events.PathEvent; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.cache.CachedChunk; import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; @@ -27,6 +27,7 @@ import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; import baritone.utils.BlockStateInterface; +import baritone.utils.Helper; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -42,7 +43,8 @@ import java.util.stream.Collectors; * * @author leijurv */ -public class MineBehavior extends Behavior { +public class MineBehavior extends Behavior implements Helper { + public static final MineBehavior INSTANCE = new MineBehavior(); private MineBehavior() { diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java index 531741fe..d29ecd10 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java @@ -22,7 +22,7 @@ import baritone.api.event.events.PathEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RenderEvent; import baritone.api.event.events.TickEvent; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; @@ -31,6 +31,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; import baritone.pathing.path.PathExecutor; import baritone.utils.BlockStateInterface; +import baritone.utils.Helper; import baritone.utils.PathRenderer; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; @@ -40,7 +41,7 @@ import java.awt.*; import java.util.Collections; import java.util.Optional; -public final class PathingBehavior extends Behavior { +public final class PathingBehavior extends Behavior implements Helper { public static final PathingBehavior INSTANCE = new PathingBehavior(); diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index c681bc29..5d2c6558 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -25,7 +25,7 @@ import baritone.cache.WorldProvider; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.InputOverrideHandler; -import baritone.utils.interfaces.Toggleable; +import baritone.api.utils.interfaces.Toggleable; import net.minecraft.client.settings.KeyBinding; import net.minecraft.world.chunk.Chunk; import org.lwjgl.input.Keyboard; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 3abd11b5..54c72ec0 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -20,7 +20,7 @@ package baritone.utils; import baritone.Baritone; import baritone.Settings; import baritone.api.event.events.ChatEvent; -import baritone.behavior.Behavior; +import baritone.api.behavior.Behavior; import baritone.behavior.impl.FollowBehavior; import baritone.behavior.impl.MineBehavior; import baritone.behavior.impl.PathingBehavior; @@ -41,7 +41,8 @@ import net.minecraft.util.math.BlockPos; import java.util.*; -public class ExampleBaritoneControl extends Behavior { +public class ExampleBaritoneControl extends Behavior implements Helper { + public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl(); private ExampleBaritoneControl() { From ef396829f0f25ee8b662830a4495423430e50cce Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 12 Sep 2018 17:58:33 -0500 Subject: [PATCH 118/329] Collapse impl package for default behaviors --- .../launch/mixins/MixinMinecraft.java | 2 +- src/main/java/baritone/Baritone.java | 2 +- .../behavior/{impl => }/FollowBehavior.java | 6 +++--- .../{impl => }/LocationTrackingBehavior.java | 2 +- .../behavior/{impl => }/LookBehavior.java | 4 ++-- .../{impl => }/LookBehaviorUtils.java | 2 +- .../behavior/{impl => }/MemoryBehavior.java | 21 +++++++++++++++++-- .../behavior/{impl => }/MineBehavior.java | 4 ++-- .../behavior/{impl => }/PathingBehavior.java | 2 +- .../pathing/calc/AbstractNodeCostSearch.java | 2 +- .../baritone/pathing/movement/Movement.java | 4 ++-- .../pathing/movement/MovementHelper.java | 2 +- .../movement/movements/MovementAscend.java | 2 +- .../movement/movements/MovementParkour.java | 2 +- .../movement/movements/MovementTraverse.java | 2 +- .../utils/ExampleBaritoneControl.java | 6 +++--- .../java/baritone/utils/RayTraceUtils.java | 2 +- 17 files changed, 42 insertions(+), 25 deletions(-) rename src/main/java/baritone/behavior/{impl => }/FollowBehavior.java (93%) rename src/main/java/baritone/behavior/{impl => }/LocationTrackingBehavior.java (98%) rename src/main/java/baritone/behavior/{impl => }/LookBehavior.java (97%) rename src/main/java/baritone/behavior/{impl => }/LookBehaviorUtils.java (99%) rename src/main/java/baritone/behavior/{impl => }/MemoryBehavior.java (88%) rename src/main/java/baritone/behavior/{impl => }/MineBehavior.java (97%) rename src/main/java/baritone/behavior/{impl => }/PathingBehavior.java (99%) diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index bc419516..6ea14221 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -22,7 +22,7 @@ import baritone.api.event.events.BlockInteractEvent; import baritone.api.event.events.TickEvent; import baritone.api.event.events.WorldEvent; import baritone.api.event.events.type.EventState; -import baritone.behavior.impl.PathingBehavior; +import baritone.behavior.PathingBehavior; import baritone.utils.ExampleBaritoneControl; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 6c7acc5f..fb373c6e 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -19,7 +19,7 @@ package baritone; import baritone.api.event.listener.IGameEventListener; import baritone.api.behavior.Behavior; -import baritone.behavior.impl.*; +import baritone.behavior.*; import baritone.event.GameEventHandler; import baritone.utils.InputOverrideHandler; import net.minecraft.client.Minecraft; diff --git a/src/main/java/baritone/behavior/impl/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java similarity index 93% rename from src/main/java/baritone/behavior/impl/FollowBehavior.java rename to src/main/java/baritone/behavior/FollowBehavior.java index eb67dfa0..0a7fff6b 100644 --- a/src/main/java/baritone/behavior/impl/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.api.event.events.TickEvent; import baritone.api.behavior.Behavior; @@ -28,14 +28,14 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class FollowBehavior extends Behavior { +public final class FollowBehavior extends Behavior { public static final FollowBehavior INSTANCE = new FollowBehavior(); private FollowBehavior() { } - Entity following; + private Entity following; @Override public void onTick(TickEvent event) { diff --git a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/LocationTrackingBehavior.java similarity index 98% rename from src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java rename to src/main/java/baritone/behavior/LocationTrackingBehavior.java index fb7d9db8..cf41543c 100644 --- a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/LocationTrackingBehavior.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.api.behavior.Behavior; import baritone.cache.Waypoint; diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java similarity index 97% rename from src/main/java/baritone/behavior/impl/LookBehavior.java rename to src/main/java/baritone/behavior/LookBehavior.java index ddf58619..fa10d27d 100644 --- a/src/main/java/baritone/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.Baritone; import baritone.Settings; @@ -25,7 +25,7 @@ import baritone.api.behavior.Behavior; import baritone.utils.Helper; import baritone.utils.Rotation; -public class LookBehavior extends Behavior implements Helper { +public final class LookBehavior extends Behavior implements Helper { public static final LookBehavior INSTANCE = new LookBehavior(); diff --git a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java similarity index 99% rename from src/main/java/baritone/behavior/impl/LookBehaviorUtils.java rename to src/main/java/baritone/behavior/LookBehaviorUtils.java index a7896d03..bbab90bf 100644 --- a/src/main/java/baritone/behavior/impl/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.utils.*; import net.minecraft.block.BlockFire; diff --git a/src/main/java/baritone/behavior/impl/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java similarity index 88% rename from src/main/java/baritone/behavior/impl/MemoryBehavior.java rename to src/main/java/baritone/behavior/MemoryBehavior.java index 5d99c2d1..ee89ebbf 100644 --- a/src/main/java/baritone/behavior/impl/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -1,4 +1,21 @@ -package baritone.behavior.impl; +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.behavior; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; @@ -21,7 +38,7 @@ import java.util.*; * @author Brady * @since 8/6/2018 9:47 PM */ -public class MemoryBehavior extends Behavior implements Helper { +public final class MemoryBehavior extends Behavior implements Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java similarity index 97% rename from src/main/java/baritone/behavior/impl/MineBehavior.java rename to src/main/java/baritone/behavior/MineBehavior.java index a36aa02f..2dbb0dbb 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.api.event.events.PathEvent; import baritone.api.behavior.Behavior; @@ -43,7 +43,7 @@ import java.util.stream.Collectors; * * @author leijurv */ -public class MineBehavior extends Behavior implements Helper { +public final class MineBehavior extends Behavior implements Helper { public static final MineBehavior INSTANCE = new MineBehavior(); diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java similarity index 99% rename from src/main/java/baritone/behavior/impl/PathingBehavior.java rename to src/main/java/baritone/behavior/PathingBehavior.java index d29ecd10..944af0d2 100644 --- a/src/main/java/baritone/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.behavior.impl; +package baritone.behavior; import baritone.Baritone; import baritone.api.event.events.PathEvent; diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 92c85b1d..2432699a 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -17,7 +17,7 @@ package baritone.pathing.calc; -import baritone.behavior.impl.PathingBehavior; +import baritone.behavior.PathingBehavior; import baritone.pathing.goals.Goal; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index ddf36034..0c59bfc0 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -18,8 +18,8 @@ package baritone.pathing.movement; import baritone.Baritone; -import baritone.behavior.impl.LookBehavior; -import baritone.behavior.impl.LookBehaviorUtils; +import baritone.behavior.LookBehavior; +import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 3f68cba6..8f886f7e 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -18,7 +18,7 @@ package baritone.pathing.movement; import baritone.Baritone; -import baritone.behavior.impl.LookBehaviorUtils; +import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.pathing.movement.movements.MovementDescend; import baritone.pathing.movement.movements.MovementFall; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 60591d88..b802b53a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -18,7 +18,7 @@ package baritone.pathing.movement.movements; import baritone.Baritone; -import baritone.behavior.impl.LookBehaviorUtils; +import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 61056ff2..dc586fac 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -18,7 +18,7 @@ package baritone.pathing.movement.movements; import baritone.Baritone; -import baritone.behavior.impl.LookBehaviorUtils; +import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index df0f3a27..2dfd9311 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -18,7 +18,7 @@ package baritone.pathing.movement.movements; import baritone.Baritone; -import baritone.behavior.impl.LookBehaviorUtils; +import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 54c72ec0..19efa55f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -21,9 +21,9 @@ import baritone.Baritone; import baritone.Settings; import baritone.api.event.events.ChatEvent; import baritone.api.behavior.Behavior; -import baritone.behavior.impl.FollowBehavior; -import baritone.behavior.impl.MineBehavior; -import baritone.behavior.impl.PathingBehavior; +import baritone.behavior.FollowBehavior; +import baritone.behavior.MineBehavior; +import baritone.behavior.PathingBehavior; import baritone.cache.ChunkPacker; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java index 123e283d..02ae52df 100644 --- a/src/main/java/baritone/utils/RayTraceUtils.java +++ b/src/main/java/baritone/utils/RayTraceUtils.java @@ -20,7 +20,7 @@ package baritone.utils; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import static baritone.behavior.impl.LookBehaviorUtils.calcVec3dFromRotation; +import static baritone.behavior.LookBehaviorUtils.calcVec3dFromRotation; /** * @author Brady From 796be3da793a8b689d3d0dde83340a289d7fce1d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 12 Sep 2018 16:29:10 -0700 Subject: [PATCH 119/329] can't break nether roof, fixes #164 --- src/main/java/baritone/cache/CachedChunk.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index fbab3161..0debcc84 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -128,6 +128,9 @@ public final class CachedChunk implements IBlockTypeAccess { return state; } PathingBlockType type = getType(x, y, z); + if (type == PathingBlockType.SOLID && y == 128 && mc.player.dimension == -1) { + return Blocks.BEDROCK.getDefaultState(); + } return ChunkPacker.pathingTypeToBlock(type); } From 315c1bf63cd67594c13030f2207c5feea36b968f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 12 Sep 2018 16:40:27 -0700 Subject: [PATCH 120/329] help i cannot math into number --- src/main/java/baritone/cache/CachedChunk.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 0debcc84..a79d3733 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -128,7 +128,7 @@ public final class CachedChunk implements IBlockTypeAccess { return state; } PathingBlockType type = getType(x, y, z); - if (type == PathingBlockType.SOLID && y == 128 && mc.player.dimension == -1) { + if (type == PathingBlockType.SOLID && y == 127 && mc.player.dimension == -1) { return Blocks.BEDROCK.getDefaultState(); } return ChunkPacker.pathingTypeToBlock(type); From df765a14b09d24f412bf262ff227aa29fe467d78 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 12 Sep 2018 20:49:53 -0700 Subject: [PATCH 121/329] update prebuilt baritone --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index ec7b6707..4c552963 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar (as of commit 72eec13, built on September 10) from here. +You can either build Baritone yourself, or download the jar (as of commit 315c1bf, built on September 12) from here. To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From 4c5c35069d0394c72bc9092222d9c17f993d3565 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 09:44:51 -0500 Subject: [PATCH 122/329] Remove keycode state forcing It was a feature that was in the source of MineBot, but was actually never used. --- .../launch/mixins/MixinGameSettings.java | 44 ----------------- .../launch/mixins/MixinGuiContainer.java | 47 ------------------ .../launch/mixins/MixinGuiScreen.java | 48 ------------------- .../launch/mixins/MixinMinecraft.java | 12 ----- src/launch/resources/mixins.baritone.json | 3 -- .../baritone/utils/InputOverrideHandler.java | 25 ---------- 6 files changed, 179 deletions(-) delete mode 100644 src/launch/java/baritone/launch/mixins/MixinGameSettings.java delete mode 100644 src/launch/java/baritone/launch/mixins/MixinGuiContainer.java delete mode 100644 src/launch/java/baritone/launch/mixins/MixinGuiScreen.java diff --git a/src/launch/java/baritone/launch/mixins/MixinGameSettings.java b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java deleted file mode 100644 index f5bae8ef..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinGameSettings.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.settings.GameSettings; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 8/1/2018 12:28 AM - */ -@Mixin(GameSettings.class) -public class MixinGameSettings { - - @Redirect( - method = "isKeyDown", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java deleted file mode 100644 index c2c62d76..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.inventory.GuiContainer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:47 PM - */ -@Mixin(GuiContainer.class) -public class MixinGuiContainer { - - @Redirect( - method = { - "mouseClicked", - "mouseReleased" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java deleted file mode 100644 index 11a3e7f4..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.GuiScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:38 PM - */ -@Mixin(GuiScreen.class) -public class MixinGuiScreen { - - @Redirect( - method = { - "isCtrlKeyDown", - "isShiftKeyDown", - "isAltKeyDown" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 6ea14221..2bcc54b9 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -85,18 +85,6 @@ public class MixinMinecraft { )); } - @Redirect( - method = "runTickKeyboard", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean Keyboard$isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } - @Inject( method = "processKeyBinds", at = @At("HEAD") diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 413bbbe7..9ea70330 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -15,9 +15,6 @@ "MixinEntityLivingBase", "MixinEntityPlayerSP", "MixinEntityRenderer", - "MixinGameSettings", - "MixinGuiContainer", - "MixinGuiScreen", "MixinKeyBinding", "MixinMinecraft", "MixinNetHandlerPlayClient", diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index 9860e2e1..8540bcd4 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -57,14 +57,8 @@ public final class InputOverrideHandler implements Helper { */ private final Map inputForceStateMap = new HashMap<>(); - /** - * Maps keycodes to whether or not we are forcing their state down. - */ - private final Map keyCodeForceStateMap = new HashMap<>(); - public final void clearAllKeys() { inputForceStateMap.clear(); - keyCodeForceStateMap.clear(); } /** @@ -87,25 +81,6 @@ public final class InputOverrideHandler implements Helper { inputForceStateMap.put(input.getKeyBinding(), forced); } - /** - * A redirection in multiple places of {@link Keyboard#isKeyDown}. - * - * @return Whether or not the specified key is down or overridden. - */ - public boolean isKeyDown(int keyCode) { - return Keyboard.isKeyDown(keyCode) || keyCodeForceStateMap.getOrDefault(keyCode, false); - } - - /** - * Sets whether or not the specified key code is being forced down. - * - * @param keyCode The key code - * @param forced Whether or not the state is being forced - */ - public final void setKeyForceState(int keyCode, boolean forced) { - keyCodeForceStateMap.put(keyCode, forced); - } - /** * An {@link Enum} representing the possible inputs that we may want to force. */ From 530bdfae0fa227a3c43b27e94cb57ee052324d5d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 09:15:50 -0700 Subject: [PATCH 123/329] add save command --- .../java/baritone/utils/ExampleBaritoneControl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 19efa55f..b418f067 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -19,8 +19,8 @@ package baritone.utils; import baritone.Baritone; import baritone.Settings; -import baritone.api.event.events.ChatEvent; import baritone.api.behavior.Behavior; +import baritone.api.event.events.ChatEvent; import baritone.behavior.FollowBehavior; import baritone.behavior.MineBehavior; import baritone.behavior.PathingBehavior; @@ -41,7 +41,7 @@ import net.minecraft.util.math.BlockPos; import java.util.*; -public class ExampleBaritoneControl extends Behavior implements Helper { +public class ExampleBaritoneControl extends Behavior implements Helper { public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl(); @@ -238,6 +238,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } + if (msg.toLowerCase().equals("save")) { + String name = msg.substring(4).trim(); + WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.HOME, playerFeet())); + logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); + event.cancel(); + return; + } if (msg.toLowerCase().startsWith("goto")) { String waypointType = msg.toLowerCase().substring(4).trim(); if (waypointType.endsWith("s") && Waypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) { From d07eb3f4862ed675842915088a8643db04fdde4c Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 11:58:52 -0500 Subject: [PATCH 124/329] jurv is a noob --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 7f0cfcdc..86ddc1a2 100644 --- a/proguard.pro +++ b/proguard.pro @@ -13,7 +13,7 @@ -overloadaggressively -dontusemixedcaseclassnames -# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with mcp +# instead of obfing to a, b, c, obf to baritone.a, baritone.b, baritone.c so as to not conflict with minecraft's obfd classes -flattenpackagehierarchy -repackageclasses 'baritone' From d536d311d6435f8b9291cebea048cd838144cbd0 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 12:14:10 -0500 Subject: [PATCH 125/329] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cdd31b0d..9204c4b9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone + Impact # Setup + +## IntelliJ's Gradle UI - Open the project in IntelliJ as a Gradle project - Run the Gradle task `setupDecompWorkspace` - Run the Gradle task `genIntellijRuns` From 651bfac786d1277056b1f8aa1b41bf4c768584d8 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 14:12:41 -0500 Subject: [PATCH 126/329] Fix copyright comment detection --- .idea/copyright/Baritone.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.idea/copyright/Baritone.xml b/.idea/copyright/Baritone.xml index c0916294..aaaf59bb 100644 --- a/.idea/copyright/Baritone.xml +++ b/.idea/copyright/Baritone.xml @@ -1,5 +1,6 @@ + From 380f21bb386dd77c80c32e18a95cdd79d6b8ac87 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 14:48:23 -0500 Subject: [PATCH 127/329] Remove pythagoreanMetric setting --- src/main/java/baritone/Settings.java | 6 ------ src/main/java/baritone/pathing/goals/GoalXZ.java | 3 --- 2 files changed, 9 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index d29ec995..eb673efd 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -145,12 +145,6 @@ public class Settings { */ public Setting minimumImprovementRepropagation = new Setting<>(true); - /** - * Use a pythagorean metric (as opposed to the more accurate hybrid diagonal / traverse). - * You probably don't want this. It roughly triples nodes considered for no real advantage. - */ - public Setting pythagoreanMetric = new Setting<>(false); - /** * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is * entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified. diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index 8abfb221..71808222 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -65,9 +65,6 @@ public class GoalXZ implements Goal { } public static double calculate(double xDiff, double zDiff) { - if (Baritone.settings().pythagoreanMetric.get()) { - return Math.sqrt(xDiff * xDiff + zDiff * zDiff) * Baritone.settings().costHeuristic.get(); - } //This is a combination of pythagorean and manhattan distance //It takes into account the fact that pathing can either walk diagonally or forwards From 13628789c8d97a3f106807c7a1bb470c6cf1930d Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 13 Sep 2018 15:10:29 -0500 Subject: [PATCH 128/329] We should only care about real client-sided packet flow Prior to this commit, IntegratedServer packets would be picked up by PacketEvent --- .../launch/mixins/MixinNetworkManager.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index b0fedc62..d1e6a2d5 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -24,8 +24,10 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.EnumPacketDirection; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -42,12 +44,18 @@ public class MixinNetworkManager { @Shadow private Channel channel; + @Shadow + @Final + private EnumPacketDirection direction; + @Inject( method = "dispatchPacket", at = @At("HEAD") ) private void preDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { - Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket)); + if (this.direction == EnumPacketDirection.CLIENTBOUND) { + Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.PRE, inPacket)); + } } @Inject( @@ -55,7 +63,9 @@ public class MixinNetworkManager { at = @At("RETURN") ) private void postDispatchPacket(Packet inPacket, final GenericFutureListener>[] futureListeners, CallbackInfo ci) { - Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket)); + if (this.direction == EnumPacketDirection.CLIENTBOUND) { + Baritone.INSTANCE.getGameEventHandler().onSendPacket(new PacketEvent(EventState.POST, inPacket)); + } } @Inject( @@ -66,7 +76,8 @@ public class MixinNetworkManager { ) ) private void preProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.PRE, packet)); + if (this.direction == EnumPacketDirection.CLIENTBOUND) { + Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.PRE, packet));} } @Inject( @@ -74,7 +85,7 @@ public class MixinNetworkManager { at = @At("RETURN") ) private void postProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (this.channel.isOpen()) { + if (this.channel.isOpen() && this.direction == EnumPacketDirection.CLIENTBOUND) { Baritone.INSTANCE.getGameEventHandler().onReceivePacket(new PacketEvent(EventState.POST, packet)); } } From 33a0a2a7f9e659fd7ba56c166acb7931192d5ba5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 15:39:48 -0700 Subject: [PATCH 129/329] derp --- 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 b418f067..da201494 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -238,7 +238,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("save")) { + if (msg.toLowerCase().startsWith("save")) { String name = msg.substring(4).trim(); WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.HOME, playerFeet())); logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); From 924cea342baf05bb0293ab39e9f796d749ef43af Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 15:41:00 -0700 Subject: [PATCH 130/329] user defined not home --- 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 da201494..7a9326c2 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -240,7 +240,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } if (msg.toLowerCase().startsWith("save")) { String name = msg.substring(4).trim(); - WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.HOME, playerFeet())); + WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.USER, playerFeet())); logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); event.cancel(); return; From e3830643f6bc93faa5391f8f1781a2a76c0fefc2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 16:18:26 -0700 Subject: [PATCH 131/329] only fail on movement cost increase if calced through cached, fixes #165 --- .../pathing/calc/AbstractNodeCostSearch.java | 1 + src/main/java/baritone/pathing/calc/Path.java | 17 ++++++++++++++++- .../baritone/pathing/movement/Movement.java | 11 +++++++++++ src/main/java/baritone/pathing/path/IPath.java | 6 ++++++ .../baritone/pathing/path/PathExecutor.java | 2 +- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 2432699a..2f376082 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -83,6 +83,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { this.cancelRequested = false; try { Optional path = calculate0(timeout); + path.ifPresent(IPath::postprocess); isFinished = true; return path; } catch (Exception e) { diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 96c8950e..d0ad696e 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -54,6 +54,8 @@ class Path implements IPath { private final int numNodes; + private volatile boolean verified; + Path(PathNode start, PathNode end, int numNodes) { this.start = start.pos; this.end = end.pos; @@ -61,7 +63,6 @@ class Path implements IPath { this.path = new ArrayList<>(); this.movements = new ArrayList<>(); assemblePath(start, end); - sanityCheck(); } /** @@ -116,8 +117,22 @@ class Path implements IPath { } } + @Override + public void postprocess() { + if (verified) { + throw new IllegalStateException(); + } + verified = true; + // more post processing here + movements.forEach(Movement::checkLoadedChunk); + sanityCheck(); + } + @Override public List movements() { + if (!verified) { + throw new IllegalStateException(); + } return Collections.unmodifiableList(movements); } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 0c59bfc0..5aaf1be1 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -26,6 +26,7 @@ import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.chunk.EmptyChunk; import java.util.ArrayList; import java.util.Arrays; @@ -290,6 +291,16 @@ public abstract class Movement implements Helper, MovementHelper { return getDest().subtract(getSrc()); } + private Boolean calculatedWhileLoaded; + + public void checkLoadedChunk() { + calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk); + } + + public boolean calculatedWhileLoaded() { + return calculatedWhileLoaded; + } + public List toBreakCached = null; public List toPlaceCached = null; public List toWalkIntoCached = null; diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index 575aacb1..c9b473b5 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -49,6 +49,12 @@ public interface IPath extends Helper { */ List positions(); + /** + * This path is actually going to be executed in the world. Do whatever additional processing is required. + * (as opposed to Path objects that are just constructed every frame for rendering) + */ + default void postprocess() {} + /** * Number of positions in this path * diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index ab132ca0..8506eeb7 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -236,7 +236,7 @@ public class PathExecutor implements Helper { Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); return true; } - if (currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) { + if (!movement.calculatedWhileLoaded() && currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) { logDebug("Original cost " + currentMovementInitialCostEstimate + " current cost " + currentCost + ". Cancelling."); pathPosition = path.length() + 3; failed = true; From 7d0914bd43a7cf0536b6b769c1d880a794bf29ef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 16:40:55 -0700 Subject: [PATCH 132/329] don't crash on thisway typo lol --- .../java/baritone/utils/ExampleBaritoneControl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 7a9326c2..dab4ca01 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -209,9 +209,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.toLowerCase().startsWith("thisway")) { - Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim())); - PathingBehavior.INSTANCE.setGoal(goal); - logDirect("Goal: " + goal); + try { + Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim())); + PathingBehavior.INSTANCE.setGoal(goal); + logDirect("Goal: " + goal); + } catch (NumberFormatException ex) { + logDirect("Error unable to parse '" + msg.substring(7).trim() + "' to a double."); + } event.cancel(); return; } From 5f9b6683ac205fec481b7e1212d85b1377c04648 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 17:01:16 -0700 Subject: [PATCH 133/329] update prebuilt jar --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 4c552963..bfa61776 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar (as of commit 315c1bf, built on September 12) from here. +You can either build Baritone yourself, or download the jar (as of commit 7d0914b, built on September 13) from here. To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From 853cbf355453cdfae8dd3b8dbf608eee7a5ae612 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 18:00:08 -0700 Subject: [PATCH 134/329] add waypoint user --- src/main/java/baritone/cache/Waypoint.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/Waypoint.java b/src/main/java/baritone/cache/Waypoint.java index 7cd5ace3..a8f162a5 100644 --- a/src/main/java/baritone/cache/Waypoint.java +++ b/src/main/java/baritone/cache/Waypoint.java @@ -21,7 +21,8 @@ import com.google.common.collect.ImmutableList; import net.minecraft.util.math.BlockPos; import org.apache.commons.lang3.ArrayUtils; -import java.util.*; +import java.util.Date; +import java.util.List; /** * A single waypoint @@ -75,7 +76,7 @@ public class Waypoint { HOME("home", "base"), DEATH("death"), BED("bed", "spawn"), - USER(); + USER("user"); private static final List TAG_LIST = ImmutableList.builder().add(Tag.values()).build(); From 6b45b847846d3b5032d38b9f17ea80c7c470ef00 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Sep 2018 18:40:50 -0700 Subject: [PATCH 135/329] special request from plutie#9079 --- src/main/java/baritone/cache/CachedChunk.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index a79d3733..7ef5b429 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -63,6 +63,7 @@ public final class CachedChunk implements IBlockTypeAccess { add(Blocks.DRAGON_EGG); add(Blocks.JUKEBOX); add(Blocks.END_GATEWAY); + add(Blocks.WEB); }}); /** From d7a646789e6f5a804db095830d3e64c9547ce1dc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 08:40:34 -0700 Subject: [PATCH 136/329] fixes to parkour place --- src/main/java/baritone/Settings.java | 5 +++++ .../movement/movements/MovementParkour.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index eb673efd..fddb7bce 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -104,6 +104,11 @@ public class Settings { */ public Setting allowParkour = new Setting<>(false); + /** + * Like parkour, but even more unreliable! + */ + public Setting allowParkourPlace = new Setting<>(false); + /** * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly. */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index dc586fac..130d7244 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -81,7 +81,7 @@ public class MovementParkour extends Movement { if (!MovementHelper.fullyPassable(src.up(2))) { return null; } - for (int i = 2; i <= 4; i++) { + for (int i = 2; i <= (context.canSprint() ? 4 : 3); i++) { BlockPos dest = src.offset(dir, i); // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? for (int y = 0; y < 4; y++) { @@ -93,6 +93,12 @@ public class MovementParkour extends Movement { return new MovementParkour(src, i, dir); } } + if (!context.canSprint()) { + return null; + } + if (!Baritone.settings().allowParkourPlace.get()) { + return null; + } BlockPos dest = src.offset(dir, 4); BlockPos positionToPlace = dest.down(); IBlockState toPlace = BlockStateInterface.get(positionToPlace); @@ -133,11 +139,17 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { // MUST BE KEPT IN SYNC WITH generate + if (!context.canSprint() && dist >= 4) { + return COST_INF; + } boolean placing = false; if (!MovementHelper.canWalkOn(dest.down())) { if (dist != 4) { return COST_INF; } + if (!Baritone.settings().allowParkourPlace.get()) { + return COST_INF; + } BlockPos positionToPlace = dest.down(); IBlockState toPlace = BlockStateInterface.get(positionToPlace); if (!context.hasThrowaway()) { From a38da64c4900e57b64b8774f766eed44a35134a1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 09:05:29 -0700 Subject: [PATCH 137/329] make the left click workaround optional --- src/main/java/baritone/Settings.java | 8 +++++++ .../baritone/pathing/movement/Movement.java | 21 ++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index fddb7bce..895f76a4 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -314,6 +314,14 @@ public class Settings { */ public Setting prefix = new Setting<>(false); + /** + * true: can mine blocks when in inventory, chat, or tabbed away in ESC menu + * false: works on cosmic prisons + *

+ * LOL + */ + public Setting leftClickWorkaround = new Setting<>(true); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 5aaf1be1..b574a91b 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -119,18 +119,19 @@ public abstract class Movement implements Helper, MovementHelper { this.didBreakLastTick = false; latestState.getInputStates().forEach((input, forced) -> { - RayTraceResult trace = mc.objectMouseOver; - boolean isBlockTrace = trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK; - boolean isLeftClick = forced && input == Input.CLICK_LEFT; + if (Baritone.settings().leftClickWorkaround.get()) { + RayTraceResult trace = mc.objectMouseOver; + boolean isBlockTrace = trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK; + boolean isLeftClick = forced && input == Input.CLICK_LEFT; - // If we're forcing left click, we're in a gui screen, and we're looking - // at a block, break the block without a direct game input manipulation. - if (mc.currentScreen != null && isLeftClick && isBlockTrace) { - BlockBreakHelper.tryBreakBlock(trace.getBlockPos(), trace.sideHit); - this.didBreakLastTick = true; - return; + // If we're forcing left click, we're in a gui screen, and we're looking + // at a block, break the block without a direct game input manipulation. + if (mc.currentScreen != null && isLeftClick && isBlockTrace) { + BlockBreakHelper.tryBreakBlock(trace.getBlockPos(), trace.sideHit); + this.didBreakLastTick = true; + return; + } } - Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced); }); latestState.getInputStates().replaceAll((input, forced) -> false); From 001070d40668db5745c37133b71ac554b420c32d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 09:21:52 -0700 Subject: [PATCH 138/329] more robust path destination verification --- .../baritone/api/event/events/PathEvent.java | 3 +- .../baritone/api/event/events/TickEvent.java | 7 ++++ .../java/baritone/behavior/MineBehavior.java | 36 +++++++++++++++---- .../pathing/calc/AStarPathFinder.java | 4 +-- .../pathing/calc/AbstractNodeCostSearch.java | 4 +-- src/main/java/baritone/pathing/calc/Path.java | 11 +++++- .../baritone/pathing/path/CutoffPath.java | 9 +++++ .../java/baritone/pathing/path/IPath.java | 7 ++++ .../utils/ExampleBaritoneControl.java | 4 +-- 9 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/api/java/baritone/api/event/events/PathEvent.java b/src/api/java/baritone/api/event/events/PathEvent.java index a3fee3f8..c134ba96 100644 --- a/src/api/java/baritone/api/event/events/PathEvent.java +++ b/src/api/java/baritone/api/event/events/PathEvent.java @@ -28,5 +28,6 @@ public enum PathEvent { AT_GOAL, PATH_FINISHED_NEXT_STILL_CALCULATING, NEXT_CALC_FAILED, - DISCARD_NEXT + DISCARD_NEXT, + CANCELED; } diff --git a/src/api/java/baritone/api/event/events/TickEvent.java b/src/api/java/baritone/api/event/events/TickEvent.java index e82c31ad..362a88cc 100644 --- a/src/api/java/baritone/api/event/events/TickEvent.java +++ b/src/api/java/baritone/api/event/events/TickEvent.java @@ -24,9 +24,16 @@ public final class TickEvent { private final EventState state; private final Type type; + private static int count; + public TickEvent(EventState state, Type type) { this.state = state; this.type = type; + count++; + } + + public int getCount() { + return count; } public Type getType() { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 2dbb0dbb..6d9564bd 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -17,8 +17,9 @@ package baritone.behavior; -import baritone.api.event.events.PathEvent; import baritone.api.behavior.Behavior; +import baritone.api.event.events.PathEvent; +import baritone.api.event.events.TickEvent; import baritone.cache.CachedChunk; import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; @@ -26,16 +27,14 @@ import baritone.cache.WorldScanner; import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; +import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -52,6 +51,31 @@ public final class MineBehavior extends Behavior implements Helper { private List mining; + @Override + public void onTick(TickEvent event) { + if (mining == null) { + return; + } + if (event.getCount() % 5 == 0) { + updateGoal(); + } + Optional path = PathingBehavior.INSTANCE.getPath(); + if (!path.isPresent()) { + return; + } + Goal currentGoal = PathingBehavior.INSTANCE.getGoal(); + if (currentGoal == null) { + return; + } + Goal intended = path.get().getGoal(); + BlockPos end = path.get().getDest(); + if (intended.isInGoal(end) && !currentGoal.isInGoal(end)) { + // this path used to end in the goal + // but the goal has changed, so there's no reason to continue... + PathingBehavior.INSTANCE.cancel(); + } + } + @Override public void onPathEvent(PathEvent event) { updateGoal(); @@ -113,7 +137,7 @@ public final class MineBehavior extends Behavior implements Helper { } public void cancel() { - PathingBehavior.INSTANCE.cancel(); mine((String[]) null); + PathingBehavior.INSTANCE.cancel(); } } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 643df531..ddf61b7a 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -103,7 +103,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { if (goal.isInGoal(currentNodePos)) { currentlyRunning = null; logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); - return Optional.of(new Path(startNode, currentNode, numNodes)); + return Optional.of(new Path(startNode, currentNode, numNodes, goal)); } Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order shuffle(possibleMovements); @@ -199,7 +199,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { } System.out.println("Path goes for " + Math.sqrt(dist) + " blocks"); currentlyRunning = null; - return Optional.of(new Path(startNode, bestSoFar[i], numNodes)); + return Optional.of(new Path(startNode, bestSoFar[i], numNodes, goal)); } } logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 2f376082..3b8bfade 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -140,7 +140,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { @Override public Optional pathToMostRecentNodeConsidered() { - return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0)); + return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); } @Override @@ -153,7 +153,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { continue; } if (getDistFromStartSq(bestSoFar[i]) > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - return Optional.of(new Path(startNode, bestSoFar[i], 0)); + return Optional.of(new Path(startNode, bestSoFar[i], 0, goal)); } } // instead of returning bestSoFar[0], be less misleading diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index d0ad696e..bec1e3a0 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -17,6 +17,7 @@ package baritone.pathing.calc; +import baritone.pathing.goals.Goal; import baritone.pathing.movement.Movement; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; @@ -52,19 +53,27 @@ class Path implements IPath { final List movements; + final Goal goal; + private final int numNodes; private volatile boolean verified; - Path(PathNode start, PathNode end, int numNodes) { + Path(PathNode start, PathNode end, int numNodes, Goal goal) { this.start = start.pos; this.end = end.pos; this.numNodes = numNodes; this.path = new ArrayList<>(); this.movements = new ArrayList<>(); + this.goal = goal; assemblePath(start, end); } + @Override + public Goal getGoal() { + return goal; + } + /** * Assembles this path given the start and end nodes. * diff --git a/src/main/java/baritone/pathing/path/CutoffPath.java b/src/main/java/baritone/pathing/path/CutoffPath.java index 51618918..ea10e8c5 100644 --- a/src/main/java/baritone/pathing/path/CutoffPath.java +++ b/src/main/java/baritone/pathing/path/CutoffPath.java @@ -17,6 +17,7 @@ package baritone.pathing.path; +import baritone.pathing.goals.Goal; import baritone.pathing.movement.Movement; import baritone.utils.pathing.BetterBlockPos; @@ -31,10 +32,18 @@ public class CutoffPath implements IPath { private final int numNodes; + final Goal goal; + public CutoffPath(IPath prev, int lastPositionToInclude) { path = prev.positions().subList(0, lastPositionToInclude + 1); movements = prev.movements().subList(0, lastPositionToInclude + 1); numNodes = prev.getNumNodesConsidered(); + goal = prev.getGoal(); + } + + @Override + public Goal getGoal() { + return goal; } @Override diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index c9b473b5..5ab8f7aa 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -64,6 +64,13 @@ public interface IPath extends Helper { return positions().size(); } + /** + * What goal was this path calculated towards? + * + * @return + */ + Goal getGoal(); + default Tuple closestPathPos(double x, double y, double z) { double best = -1; BlockPos bestPos = null; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index dab4ca01..65208d76 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -120,9 +120,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.toLowerCase().equals("cancel")) { - PathingBehavior.INSTANCE.cancel(); - FollowBehavior.INSTANCE.cancel(); MineBehavior.INSTANCE.cancel(); + FollowBehavior.INSTANCE.cancel(); + PathingBehavior.INSTANCE.cancel(); event.cancel(); logDirect("ok canceled"); return; From 1bd15e5d5bd23918d0c6fbe61716d56611aa1407 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 11:35:41 -0700 Subject: [PATCH 139/329] added link to plutie's jenkins --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index bfa61776..369dc664 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the jar (as of commit 7d0914b, built on September 13) from here. +You can either build Baritone yourself, or download the "official" jar (as of commit 7d0914b, built on September 13) from here. If you really want the cutting edge latest release, and you trust @Plutie#9079, commits are automatically built on their Jenkins here. To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From 7d94cb259fc7e19b487d390c7f72bc316159d649 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 12:24:53 -0700 Subject: [PATCH 140/329] world scanner do 1 chunk only if blocks at same y have been found --- src/main/java/baritone/cache/WorldScanner.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 975683d1..76118093 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -44,8 +44,10 @@ public enum WorldScanner implements Helper { int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; + int playerY = playerFeet().getY(); int searchRadiusSq = 0; + boolean foundWithinY = false; while (true) { boolean allUnloaded = true; for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) { @@ -78,7 +80,11 @@ public enum WorldScanner implements Helper { for (int x = 0; x < 16; x++) { IBlockState state = bsc.get(x, y, z); if (blocks.contains(state.getBlock())) { - res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z)); + int yy = yReal | y; + res.add(new BlockPos(chunkX | x, yy, chunkZ | z)); + if (Math.abs(yy - playerY) < 10) { + foundWithinY = true; + } } } } @@ -89,7 +95,7 @@ public enum WorldScanner implements Helper { if (allUnloaded) { return res; } - if (res.size() >= max && searchRadiusSq > 26) { + if (res.size() >= max && (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY))) { return res; } searchRadiusSq++; From 29391af5ad76386f27037f8c98f902857d46f81a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 15:57:46 -0700 Subject: [PATCH 141/329] solidarity --- .../pathing/movement/movements/MovementParkour.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 130d7244..1d0dcdd4 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -191,13 +191,8 @@ public class MovementParkour extends Movement { @Override public MovementState updateState(MovementState state) { super.updateState(state); - switch (state.getStatus()) { - case WAITING: - state.setStatus(MovementState.MovementStatus.RUNNING); - case RUNNING: - break; - default: - return state; + if (state.getStatus() != MovementState.MovementStatus.RUNNING) { + return state; } if (dist >= 4) { state.setInput(InputOverrideHandler.Input.SPRINT, true); From 13cfb8e3696c221f8d87b2b5d49bcbc19f7e5e07 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 16:45:51 -0700 Subject: [PATCH 142/329] walkWhileBreaking, fixes #147 --- src/main/java/baritone/Settings.java | 5 +++ .../movement/movements/MovementTraverse.java | 32 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 895f76a4..cb2f4632 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -322,6 +322,11 @@ public class Settings { */ public Setting leftClickWorkaround = new Setting<>(true); + /** + * Don't stop walking forward when you need to break blocks in your way + */ + public Setting walkWhileBreaking = new Setting<>(true); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 2dfd9311..36c0cfc9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; +import baritone.utils.Rotation; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; @@ -131,8 +132,37 @@ public class MovementTraverse extends Movement { public MovementState updateState(MovementState state) { super.updateState(state); if (state.getStatus() != MovementState.MovementStatus.RUNNING) { - return state; + // if the setting is enabled + if (!Baritone.settings().walkWhileBreaking.get()) { + return state; + } + // and if we're prepping (aka mining the block in front) + if (state.getStatus() != MovementState.MovementStatus.PREPPING) { + return state; + } + // and if it's fine to walk into the blocks in front + if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(positionsToBreak[0]).getBlock())) { + return state; + } + if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(positionsToBreak[1]).getBlock())) { + return state; + } + // and we aren't already pressed up against the block + double dist = Math.max(Math.abs(player().posX - (dest.getX() + 0.5D)), Math.abs(player().posZ - (dest.getZ() + 0.5D))); + if (dist < 0.83) { + return state; + } + + // combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break + // it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw + float yawToDest = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())).getFirst(); + float pitchToBreak = state.getTarget().getRotation().get().getSecond(); + + state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true)); + return state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); } + + //sneak may have been set to true in the PREPPING state while mining an adjacent block state.setInput(InputOverrideHandler.Input.SNEAK, false); Block fd = BlockStateInterface.get(src.down()).getBlock(); From 12b64ead5ca182be5944b8656546f6de00ce167e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Sep 2018 18:29:35 -0700 Subject: [PATCH 143/329] a much needed path executor overhaul --- .../api/event/events/type/EventState.java | 2 +- .../baritone/pathing/movement/Movement.java | 1 + .../java/baritone/pathing/path/IPath.java | 4 +- .../baritone/pathing/path/PathExecutor.java | 206 +++++++++--------- .../baritone/utils/InputOverrideHandler.java | 3 +- src/main/java/baritone/utils/Utils.java | 11 + 6 files changed, 119 insertions(+), 108 deletions(-) diff --git a/src/api/java/baritone/api/event/events/type/EventState.java b/src/api/java/baritone/api/event/events/type/EventState.java index a7fccff1..bba516a6 100644 --- a/src/api/java/baritone/api/event/events/type/EventState.java +++ b/src/api/java/baritone/api/event/events/type/EventState.java @@ -31,7 +31,7 @@ public enum EventState { /** * Indicates that whatever movement the event is being - * dispatched as a result of has already occured. + * dispatched as a result of has already occurred. */ POST } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index b574a91b..5c7aae36 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -102,6 +102,7 @@ public abstract class Movement implements Helper, MovementHelper { * @return Status */ public MovementStatus update() { + player().capabilities.allowFlying = false; MovementState latestState = updateState(currentState); if (BlockStateInterface.isLiquid(playerFeet())) { latestState.setInput(Input.JUMP, true); diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index 5ab8f7aa..f007f899 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -71,11 +71,11 @@ public interface IPath extends Helper { */ Goal getGoal(); - default Tuple closestPathPos(double x, double y, double z) { + default Tuple closestPathPos() { double best = -1; BlockPos bestPos = null; for (BlockPos pos : positions()) { - double dist = Utils.distanceToCenter(pos, x, y, z); + double dist = Utils.playerDistanceToCenter(pos); if (dist < best || best == -1) { best = dist; bestPos = pos; diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 8506eeb7..734849ca 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -26,7 +26,7 @@ import baritone.pathing.movement.movements.MovementFall; import baritone.pathing.movement.movements.MovementTraverse; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; -import net.minecraft.client.entity.EntityPlayerSP; +import baritone.utils.Utils; import net.minecraft.init.Blocks; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; @@ -75,18 +75,11 @@ public class PathExecutor implements Helper { if (event.getType() == TickEvent.Type.OUT) { throw new IllegalStateException(); } - if (pathPosition >= path.length()) { - //stop bugging me, I'm done - //TODO Baritone.INSTANCE.behaviors.remove(this) - return true; + if (pathPosition >= path.length() - 1) { + return true; // stop bugging me, I'm done } BlockPos whereShouldIBe = path.positions().get(pathPosition); - EntityPlayerSP thePlayer = mc.player; BlockPos whereAmI = playerFeet(); - if (pathPosition == path.length() - 1) { - pathPosition++; - return true; - } if (!whereShouldIBe.equals(whereAmI)) { //System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI); if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip @@ -98,7 +91,7 @@ public class PathExecutor implements Helper { for (int j = pathPosition; j <= previousPos; j++) { path.movements().get(j).reset(); } - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + clearKeys(); return false; } } @@ -109,38 +102,28 @@ public class PathExecutor implements Helper { } System.out.println("Double skip sundae"); pathPosition = i - 1; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + clearKeys(); return false; } } } } - Tuple status = path.closestPathPos(thePlayer.posX, thePlayer.posY, thePlayer.posZ); - double distanceFromPath = status.getFirst(); - if (distanceFromPath > MAX_DIST_FROM_PATH) { + Tuple status = path.closestPathPos(); + if (possiblyOffPath(status, MAX_DIST_FROM_PATH)) { ticksAway++; - System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + distanceFromPath + ". Threshold: " + MAX_DIST_FROM_PATH); + System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + status.getFirst() + ". Threshold: " + MAX_DIST_FROM_PATH); if (ticksAway > MAX_TICKS_AWAY) { logDebug("Too far away from path for too long, cancelling path"); - System.out.println("Too many ticks"); - pathPosition = path.length() + 3; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); - failed = true; + cancel(); return false; } } else { ticksAway = 0; } - if (distanceFromPath > MAX_MAX_DIST_FROM_PATH) { - if (!(path.movements().get(pathPosition) instanceof MovementFall)) { // might be midair - if (pathPosition == 0 || !(path.movements().get(pathPosition - 1) instanceof MovementFall)) { // might have overshot the landing - logDebug("too far from path"); - pathPosition = path.length() + 3; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); - failed = true; - return false; - } - } + if (possiblyOffPath(status, MAX_MAX_DIST_FROM_PATH)) { // ok, stop right away, we're way too far. + logDebug("too far from path"); + cancel(); + return false; } //this commented block is literally cursed. /*Out.log(actions.get(pathPosition)); @@ -176,23 +159,24 @@ public class PathExecutor implements Helper { }*/ long start = System.nanoTime() / 1000000L; for (int i = pathPosition - 10; i < pathPosition + 10; i++) { - if (i >= 0 && i < path.movements().size()) { - Movement m = path.movements().get(i); - HashSet prevBreak = new HashSet<>(m.toBreak()); - HashSet prevPlace = new HashSet<>(m.toPlace()); - HashSet prevWalkInto = new HashSet<>(m.toWalkInto()); - m.toBreakCached = null; - m.toPlaceCached = null; - m.toWalkIntoCached = null; - if (!prevBreak.equals(new HashSet<>(m.toBreak()))) { - recalcBP = true; - } - if (!prevPlace.equals(new HashSet<>(m.toPlace()))) { - recalcBP = true; - } - if (!prevWalkInto.equals(new HashSet<>(m.toWalkInto()))) { - recalcBP = true; - } + if (i < 0 || i >= path.movements().size()) { + continue; + } + Movement m = path.movements().get(i); + HashSet prevBreak = new HashSet<>(m.toBreak()); + HashSet prevPlace = new HashSet<>(m.toPlace()); + HashSet prevWalkInto = new HashSet<>(m.toWalkInto()); + m.toBreakCached = null; + m.toPlaceCached = null; + m.toWalkIntoCached = null; + if (!prevBreak.equals(new HashSet<>(m.toBreak()))) { + recalcBP = true; + } + if (!prevPlace.equals(new HashSet<>(m.toPlace()))) { + recalcBP = true; + } + if (!prevWalkInto.equals(new HashSet<>(m.toWalkInto()))) { + recalcBP = true; } } if (recalcBP) { @@ -221,9 +205,7 @@ public class PathExecutor implements Helper { for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) { logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); - pathPosition = path.length() + 3; - failed = true; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + cancel(); return true; } } @@ -231,108 +213,98 @@ public class PathExecutor implements Helper { double currentCost = movement.recalculateCost(); if (currentCost >= ActionCosts.COST_INF) { logDebug("Something has changed in the world and this movement has become impossible. Cancelling."); - pathPosition = path.length() + 3; - failed = true; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + cancel(); return true; } if (!movement.calculatedWhileLoaded() && currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) { logDebug("Original cost " + currentMovementInitialCostEstimate + " current cost " + currentCost + ". Cancelling."); - pathPosition = path.length() + 3; - failed = true; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + cancel(); return true; } - player().capabilities.allowFlying = false; MovementState.MovementStatus movementStatus = movement.update(); if (movementStatus == UNREACHABLE || movementStatus == FAILED) { logDebug("Movement returns status " + movementStatus); - pathPosition = path.length() + 3; - failed = true; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + cancel(); return true; } if (movementStatus == SUCCESS) { //System.out.println("Movement done, next path"); pathPosition++; ticksOnCurrent = 0; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + clearKeys(); onTick(event); return true; } else { sprintIfRequested(); ticksOnCurrent++; if (ticksOnCurrent > currentMovementInitialCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { - // only fail if the total time has exceeded the initial estimate + // 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 // this is why we cache cost at the beginning, and don't recalculate for this comparison every tick logDebug("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling."); - movement.cancel(); - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); - pathPosition = path.length() + 3; - failed = true; + cancel(); return true; } } return false; // movement is in progress } + private boolean possiblyOffPath(Tuple status, double leniency) { + double distanceFromPath = status.getFirst(); + if (distanceFromPath > leniency) { + // when we're midair in the middle of a fall, we're very far from both the beginning and the end, but we aren't actually off path + if (path.movements().get(pathPosition) instanceof MovementFall) { + BlockPos fallDest = path.positions().get(pathPosition + 1); // .get(pathPosition) is the block we fell off of + if (Utils.playerFlatDistanceToCenter(fallDest) < 0.5) { + return false; + } + return true; + } else { + return true; + } + } else { + return false; + } + } + private void sprintIfRequested() { + + // first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint if (!new CalculationContext().canSprint()) { player().setSprinting(false); return; } + + // if the movement requested sprinting, then we're done if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown(mc.gameSettings.keyBindSprint)) { if (!player().isSprinting()) { player().setSprinting(true); } return; } - Movement movement = path.movements().get(pathPosition); - if (movement instanceof MovementDescend && pathPosition < path.length() - 2) { - BlockPos descendStart = movement.getSrc(); - BlockPos descendEnd = movement.getDest(); - BlockPos into = descendEnd.subtract(descendStart.down()).add(descendEnd); - if (into.getY() != descendEnd.getY()) { - throw new IllegalStateException(); // sanity check - } - for (int i = 0; i <= 2; i++) { - if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(into.up(i)))) { + + // however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it + Movement current = path.movements().get(pathPosition); + if (current instanceof MovementDescend && pathPosition < path.length() - 2) { + + // (dest - src) + dest is offset 1 more in the same direction + // so it's the block we'd need to worry about running into if we decide to sprint straight through this descend + + BlockPos into = current.getDest().subtract(current.getSrc().down()).add(current.getDest()); + for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks + if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(into.up(y)))) { logDebug("Sprinting would be unsafe"); player().setSprinting(false); return; } } + Movement next = path.movements().get(pathPosition + 1); - if (next instanceof MovementDescend) { - if (next.getDirection().equals(movement.getDirection())) { - if (playerFeet().equals(movement.getDest())) { - pathPosition++; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); - } - if (!player().isSprinting()) { - player().setSprinting(true); - } - return; - } - } - if (next instanceof MovementTraverse) { - if (next.getDirection().down().equals(movement.getDirection()) && MovementHelper.canWalkOn(next.getDest().down())) { - if (playerFeet().equals(movement.getDest())) { - pathPosition++; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); - } - if (!player().isSprinting()) { - player().setSprinting(true); - } - return; - } - } - if (next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get()) { - if (playerFeet().equals(movement.getDest())) { + if (canSprintInto(current, next)) { + if (playerFeet().equals(current.getDest())) { pathPosition++; - Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + clearKeys(); } if (!player().isSprinting()) { player().setSprinting(true); @@ -344,6 +316,34 @@ public class PathExecutor implements Helper { player().setSprinting(false); } + private static boolean canSprintInto(Movement current, Movement next) { + if (next instanceof MovementDescend) { + if (next.getDirection().equals(current.getDirection())) { + return true; + } + } + if (next instanceof MovementTraverse) { + if (next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(next.getDest().down())) { + return true; + } + } + if (next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get()) { + return true; + } + return false; + } + + private static void clearKeys() { + // i'm just sick and tired of this snippet being everywhere lol + Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + } + + private void cancel() { + clearKeys(); + pathPosition = path.length() + 3; + failed = true; + } + public int getPosition() { return pathPosition; } diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index 8540bcd4..6024df63 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -35,7 +35,6 @@ package baritone.utils; import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.Keyboard; import java.util.HashMap; import java.util.Map; @@ -134,7 +133,7 @@ public final class InputOverrideHandler implements Helper { /** * The actual game {@link KeyBinding} being forced. */ - private KeyBinding keyBinding; + private final KeyBinding keyBinding; Input(KeyBinding keyBinding) { this.keyBinding = keyBinding; diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 9f1ac3b3..4aedce6a 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -19,6 +19,7 @@ package baritone.utils; import net.minecraft.block.BlockFire; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -112,6 +113,16 @@ public final class Utils { return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); } + public static double playerDistanceToCenter(BlockPos pos) { + EntityPlayerSP player = (new Helper() {}).player(); + return distanceToCenter(pos, player.posX, player.posY, player.posZ); + } + + public static double playerFlatDistanceToCenter(BlockPos pos) { + EntityPlayerSP player = (new Helper() {}).player(); + return distanceToCenter(pos, player.posX, pos.getY() + 0.5, player.posZ); + } + public static double degToRad(double deg) { return deg * DEG_TO_RAD; } From 5513d0669f0ccc97a619bd14488d9c6673492565 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 07:04:22 -0700 Subject: [PATCH 144/329] helps with nether fortresses --- src/main/java/baritone/cache/CachedChunk.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 7ef5b429..6705ffa5 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -64,6 +64,7 @@ public final class CachedChunk implements IBlockTypeAccess { add(Blocks.JUKEBOX); add(Blocks.END_GATEWAY); add(Blocks.WEB); + add(Blocks.NETHER_WART); }}); /** From 1745ce6a6241cd8e7c4d866ac52db5eed68981ba Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 07:38:53 -0700 Subject: [PATCH 145/329] fix wrong y coordinate on path beginning --- .../baritone/pathing/path/PathExecutor.java | 17 +++++++++++------ src/main/java/baritone/utils/Helper.java | 8 +++++--- .../baritone/utils/pathing/BetterBlockPos.java | 5 +++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 734849ca..2b787a8a 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -20,13 +20,11 @@ package baritone.pathing.path; import baritone.Baritone; import baritone.api.event.events.TickEvent; import baritone.pathing.movement.*; -import baritone.pathing.movement.movements.MovementDescend; -import baritone.pathing.movement.movements.MovementDiagonal; -import baritone.pathing.movement.movements.MovementFall; -import baritone.pathing.movement.movements.MovementTraverse; +import baritone.pathing.movement.movements.*; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.Utils; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.init.Blocks; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; @@ -78,9 +76,16 @@ public class PathExecutor implements Helper { if (pathPosition >= path.length() - 1) { return true; // stop bugging me, I'm done } - BlockPos whereShouldIBe = path.positions().get(pathPosition); - BlockPos whereAmI = playerFeet(); + BetterBlockPos whereShouldIBe = path.positions().get(pathPosition); + BetterBlockPos whereAmI = playerFeet(); if (!whereShouldIBe.equals(whereAmI)) { + + if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1) { + // avoid the Wrong Y coordinate bug + new MovementDownward(whereAmI, whereShouldIBe).update(); + return false; + } + //System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI); if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index 9bcf082d..0b729014 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -18,11 +18,11 @@ package baritone.utils; import baritone.Baritone; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.BlockSlab; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -52,9 +52,9 @@ public interface Helper { return mc.world; } - default BlockPos playerFeet() { + default BetterBlockPos playerFeet() { // TODO find a better way to deal with soul sand!!!!! - BlockPos feet = new BlockPos(player().posX, player().posY + 0.1251, player().posZ); + BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ); if (BlockStateInterface.get(feet).getBlock() instanceof BlockSlab) { return feet.up(); } @@ -75,6 +75,7 @@ public interface Helper { /** * Send a message to chat only if chatDebug is on + * * @param message */ default void logDebug(String message) { @@ -88,6 +89,7 @@ public interface Helper { /** * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command) + * * @param message */ default void logDirect(String message) { diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 895d982f..f908dd78 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -19,6 +19,7 @@ package baritone.utils.pathing; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3i; /** @@ -59,6 +60,10 @@ public final class BetterBlockPos extends BlockPos { this.hashCode = hash; } + public BetterBlockPos(double x, double y, double z) { + this(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z)); + } + public BetterBlockPos(BlockPos pos) { this(pos.getX(), pos.getY(), pos.getZ()); } From 9b375e1f5f5978f055b80595900f6460aaa56bbd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 07:42:03 -0700 Subject: [PATCH 146/329] fix path not derendering once finished --- src/main/java/baritone/pathing/path/PathExecutor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 2b787a8a..23c82e83 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -73,7 +73,10 @@ public class PathExecutor implements Helper { if (event.getType() == TickEvent.Type.OUT) { throw new IllegalStateException(); } - if (pathPosition >= path.length() - 1) { + if (pathPosition == path.length() - 1) { + pathPosition++; + } + if (pathPosition >= path.length()) { return true; // stop bugging me, I'm done } BetterBlockPos whereShouldIBe = path.positions().get(pathPosition); From 19b47d77e5f24e859bd327d94e9e0d081ab25fc6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 07:51:46 -0700 Subject: [PATCH 147/329] can still fall into water if assumeWalkOnWater is true --- .../pathing/movement/movements/MovementFall.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index dbcde285..ccdae099 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -60,7 +60,8 @@ public class MovementFall extends Movement { return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } double placeBucketCost = 0.0; - if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeightNoWater()) { + boolean destIsWater = BlockStateInterface.isWater(dest); + if (!destIsWater && src.getY() - dest.getY() > context.maxFallHeightNoWater()) { if (!context.hasWaterBucket()) { return COST_INF; } @@ -88,7 +89,14 @@ public class MovementFall extends Movement { // And falling through signs is possible, but they do have a mining duration, right? if (MovementHelper.getMiningDurationTicks(context, positionsToBreak[i], false) > 0) { //can't break while falling - return COST_INF; + + if (i != positionsToBreak.length - 1 || !destIsWater) { + // if we're checking the very last block to mine + // and it's water (so this is a water fall) + // don't consider the cost of "mining" it + // (if assumeWalkOnWater is true, water isn't canWalkThrough) + return COST_INF; + } } } return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontThree; From 0b30e822c269e40f622b43ce6e81fb5eb5b9eafb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 08:00:24 -0700 Subject: [PATCH 148/329] fix flowing water detection for assumeWalkOnWater --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 8f886f7e..d602fdad 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -250,7 +250,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (up instanceof BlockLilyPad) { return true; } - if (BlockStateInterface.isFlowing(state)) { + if (BlockStateInterface.isFlowing(state) || 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 BlockStateInterface.isWater(up) && !Baritone.settings().assumeWalkOnWater.get(); } From 20ecab7d538cdfe3ce7f6ea42e9aa88f3e924156 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 08:14:57 -0700 Subject: [PATCH 149/329] fix breaking movementfall last block with assumeWalkOnWater --- README.md | 4 ++++ .../baritone/pathing/movement/movements/MovementFall.java | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9204c4b9..f280d18a 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,7 @@ Sure! (As long as usage is in compliance with the GPL 3 License) ## How is it so fast? Magic + +## Why is it called Baritone? + +It's named for FitMC's deep sultry voice. \ No newline at end of file diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index ccdae099..7875a937 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -162,4 +162,9 @@ public class MovementFall extends Movement { } return toBreak; } + + @Override + protected boolean prepared(MovementState state) { + return true; + } } From 67c5a9caa02fc18b048d8dc419c16fa7b0f721f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 09:29:03 -0700 Subject: [PATCH 150/329] fix failure to break on fall --- .../pathing/movement/movements/MovementFall.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 7875a937..60a5a0a5 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -165,6 +165,16 @@ public class MovementFall extends Movement { @Override protected boolean prepared(MovementState state) { + if (state.getStatus() == MovementStatus.WAITING) { + return true; + } + // only break if one of the first three needs to be broken + // specifically ignore the last one which might be water + for (int i = 0; i < 4 && i < positionsToBreak.length; i++) { + if (!MovementHelper.canWalkThrough(positionsToBreak[i])) { + return super.prepared(state); + } + } return true; } } From b5a512963da3dfb506d703d7533d28aa58ba48af Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 10:04:48 -0700 Subject: [PATCH 151/329] don't get stuck on ascend, fixes #171 --- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 23c82e83..4f955611 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -83,7 +83,7 @@ public class PathExecutor implements Helper { BetterBlockPos whereAmI = playerFeet(); if (!whereShouldIBe.equals(whereAmI)) { - if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1) { + if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1 && !(path.movements().get(0) instanceof MovementAscend) && !(path.movements().get(0) instanceof MovementPillar)) { // avoid the Wrong Y coordinate bug new MovementDownward(whereAmI, whereShouldIBe).update(); return false; From a978ddec08c36192fbccc55a81f67b87b9b9b70d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 10:34:02 -0700 Subject: [PATCH 152/329] mineGoalUpdateInterval and cancelOnGoalInvalidation --- src/main/java/baritone/Settings.java | 11 +++++++++++ src/main/java/baritone/behavior/MineBehavior.java | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index cb2f4632..d14d75ee 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -327,6 +327,17 @@ public class Settings { */ public Setting walkWhileBreaking = new Setting<>(true); + /** + * Rescan for the goal once every 5 ticks. + * Set to 0 to disable. + */ + public Setting mineGoalUpdateInterval = new Setting<>(5); + + /** + * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore + */ + public Setting cancelOnGoalInvalidation = new Setting<>(true); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 6d9564bd..9a03b156 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -17,6 +17,7 @@ package baritone.behavior; +import baritone.Baritone; import baritone.api.behavior.Behavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.TickEvent; @@ -56,8 +57,14 @@ public final class MineBehavior extends Behavior implements Helper { if (mining == null) { return; } - if (event.getCount() % 5 == 0) { - updateGoal(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + if (mineGoalUpdateInterval != 0) { + if (event.getCount() % mineGoalUpdateInterval == 0) { + updateGoal(); + } + } + if (!Baritone.settings().cancelOnGoalInvalidation.get()) { + return; } Optional path = PathingBehavior.INSTANCE.getPath(); if (!path.isPresent()) { From 27b9324cf14813552228ca74a2664a52f20ad499 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 12:51:37 -0700 Subject: [PATCH 153/329] add goal axis and fix movement fall path detection --- src/main/java/baritone/Settings.java | 5 ++ .../java/baritone/pathing/goals/GoalAxis.java | 54 +++++++++++++++++++ .../baritone/pathing/goals/GoalBlock.java | 4 +- .../pathing/goals/GoalGetToBlock.java | 5 ++ .../baritone/pathing/goals/GoalRunAway.java | 6 ++- .../java/baritone/pathing/goals/GoalXZ.java | 2 +- .../baritone/pathing/goals/GoalYLevel.java | 14 +++-- .../movement/movements/MovementFall.java | 19 ++++--- .../baritone/pathing/path/PathExecutor.java | 2 +- .../utils/ExampleBaritoneControl.java | 6 +++ 10 files changed, 100 insertions(+), 17 deletions(-) create mode 100644 src/main/java/baritone/pathing/goals/GoalAxis.java diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index d14d75ee..67ac6ab5 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -338,6 +338,11 @@ public class Settings { */ public Setting cancelOnGoalInvalidation = new Setting<>(true); + /** + * The "axis" command (aka GoalAxis) will go to a axis, or diagonal axis, at this Y level. + */ + public Setting axisHeight = new Setting<>(120); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/pathing/goals/GoalAxis.java b/src/main/java/baritone/pathing/goals/GoalAxis.java new file mode 100644 index 00000000..9e6dc697 --- /dev/null +++ b/src/main/java/baritone/pathing/goals/GoalAxis.java @@ -0,0 +1,54 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.pathing.goals; + +import baritone.Baritone; +import net.minecraft.util.math.BlockPos; + +public class GoalAxis implements Goal { + + private static final double SQRT_2_OVER_2 = Math.sqrt(2) / 2; + + @Override + public boolean isInGoal(BlockPos pos) { + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + return y == Baritone.settings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); + } + + @Override + public double heuristic(BlockPos pos) { + int x = Math.abs(pos.getX()); + int y = pos.getY(); + int z = Math.abs(pos.getZ()); + + int shrt = Math.min(x, z); + int lng = Math.max(x, z); + int diff = lng - shrt; + + double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2)); + + return flatAxisDistance * Baritone.settings().costHeuristic.get() + GoalYLevel.calculate(Baritone.settings().axisHeight.get(), y); + } + + @Override + public String toString() { + return "GoalAxis"; + } +} diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 9e6ea556..124740a3 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -77,7 +77,7 @@ public class GoalBlock implements Goal, IGoalRenderPos { @Override public String toString() { - return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}"; + return "GoalBlock{x=" + x + ",y=" + y + ",z=" + z + "}"; } /** @@ -92,7 +92,7 @@ public class GoalBlock implements Goal, IGoalRenderPos { // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be // therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate - heuristic += new GoalYLevel(yDiff).heuristic(new BlockPos(0, 0, 0)); + heuristic += GoalYLevel.calculate(yDiff, 0); //use the pythagorean and manhattan mixture from GoalXZ heuristic += GoalXZ.calculate(xDiff, zDiff); diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 4e81018b..16cf9f4b 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -61,4 +61,9 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { int zDiff = pos.getZ() - this.z; return GoalBlock.calculate(xDiff, yDiff, zDiff); } + + @Override + public String toString() { + return "GoalGetToBlock{x=" + x + ",y=" + y + ",z=" + z + "}"; + } } diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/main/java/baritone/pathing/goals/GoalRunAway.java index 620794d2..90e2f68e 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/main/java/baritone/pathing/goals/GoalRunAway.java @@ -17,11 +17,13 @@ package baritone.pathing.goals; -import java.util.Arrays; import net.minecraft.util.math.BlockPos; +import java.util.Arrays; + /** * Useful for automated combat (retreating specifically) + * * @author leijurv */ public class GoalRunAway implements Goal { @@ -65,6 +67,6 @@ public class GoalRunAway implements Goal { @Override public String toString() { - return "GoalRunAwayFrom[" + Arrays.asList(from) + "]"; + return "GoalRunAwayFrom" + Arrays.asList(from); } } diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index 71808222..7b876665 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -61,7 +61,7 @@ public class GoalXZ implements Goal { @Override public String toString() { - return "Goal{x=" + x + ",z=" + z + "}"; + return "GoalXZ{x=" + x + ",z=" + z + "}"; } public static double calculate(double xDiff, double zDiff) { diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/main/java/baritone/pathing/goals/GoalYLevel.java index 89cef250..445a450b 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/main/java/baritone/pathing/goals/GoalYLevel.java @@ -42,19 +42,23 @@ public class GoalYLevel implements Goal { @Override public double heuristic(BlockPos pos) { - if (pos.getY() > level) { + return calculate(level, pos.getY()); + } + + static double calculate(int goalY, int currentY) { + if (currentY > goalY) { // need to descend - return FALL_N_BLOCKS_COST[2] / 2 * (pos.getY() - level); + return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); } - if (pos.getY() < level) { + if (currentY < goalY) { // need to ascend - return (level - pos.getY()) * JUMP_ONE_BLOCK_COST; + return (goalY - currentY) * JUMP_ONE_BLOCK_COST; } return 0; } @Override public String toString() { - return "Goal{y=" + level + "}"; + return "GoalYLevel{y=" + level + "}"; } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 60a5a0a5..e0356444 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -134,15 +134,22 @@ public class MovementFall extends Movement { state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), false)); } if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 || BlockStateInterface.isWater(dest))) { // 0.094 because lilypads - if (BlockStateInterface.isWater(dest) && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { - player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); - if (player().motionY >= 0) { - return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); + if (BlockStateInterface.isWater(dest)) { + if (InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { + player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY); + if (player().motionY >= 0) { + return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); + } else { + return state; + } } else { - return state; + if (player().motionY >= 0) { + return state.setStatus(MovementStatus.SUCCESS); + } // don't else return state; we need to stay centered because this water might be flowing under the surface } + } else { + return state.setStatus(MovementStatus.SUCCESS); } - return state.setStatus(MovementStatus.SUCCESS); } Vec3d destCenter = Utils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder) if (Math.abs(player().posX - destCenter.x) > 0.2 || Math.abs(player().posZ - destCenter.z) > 0.2) { diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 4f955611..0e2750e0 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -264,7 +264,7 @@ public class PathExecutor implements Helper { // when we're midair in the middle of a fall, we're very far from both the beginning and the end, but we aren't actually off path if (path.movements().get(pathPosition) instanceof MovementFall) { BlockPos fallDest = path.positions().get(pathPosition + 1); // .get(pathPosition) is the block we fell off of - if (Utils.playerFlatDistanceToCenter(fallDest) < 0.5) { + if (Utils.playerFlatDistanceToCenter(fallDest) < leniency) { // ignore Y by using flat distance return false; } return true; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 65208d76..cb6f1382 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -119,6 +119,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } + if (msg.equals("axis")) { + PathingBehavior.INSTANCE.setGoal(new GoalAxis()); + PathingBehavior.INSTANCE.path(); + event.cancel(); + return; + } if (msg.toLowerCase().equals("cancel")) { MineBehavior.INSTANCE.cancel(); FollowBehavior.INSTANCE.cancel(); From 43cf2062bc8b36890086c9997bf76c16d5132543 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 12:56:35 -0700 Subject: [PATCH 154/329] locations cache --- src/main/java/baritone/behavior/MineBehavior.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 9a03b156..3b0e4ec8 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -51,6 +51,7 @@ public final class MineBehavior extends Behavior implements Helper { } private List mining; + private List locationsCache; @Override public void onTick(TickEvent event) { @@ -92,12 +93,18 @@ public final class MineBehavior extends Behavior implements Helper { if (mining == null) { return; } + if (!locationsCache.isEmpty()) { + locationsCache = prune(new ArrayList<>(locationsCache), mining, 64); + PathingBehavior.INSTANCE.setGoal(new GoalComposite(locationsCache.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.path(); + } List locs = scanFor(mining, 64); if (locs.isEmpty()) { logDebug("No locations for " + mining + " known, cancelling"); cancel(); return; } + locationsCache = locs; PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); PathingBehavior.INSTANCE.path(); } @@ -119,6 +126,10 @@ public final class MineBehavior extends Behavior implements Helper { locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } + return prune(locs, mining, max); + } + + public static List prune(List locs, List mining, int max) { BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet(); locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); @@ -135,11 +146,13 @@ public final class MineBehavior extends Behavior implements Helper { public void mine(String... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList()); + this.locationsCache = new ArrayList<>(); updateGoal(); } public void mine(Block... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks); + this.locationsCache = new ArrayList<>(); updateGoal(); } From e54ea6c5711929918581bde4874f51ee164f0ca0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 15:22:34 -0700 Subject: [PATCH 155/329] pathingbehavior must emit canceled event for mining to recalc --- src/main/java/baritone/behavior/PathingBehavior.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 944af0d2..205e5001 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -18,11 +18,11 @@ package baritone.behavior; import baritone.Baritone; +import baritone.api.behavior.Behavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RenderEvent; import baritone.api.event.events.TickEvent; -import baritone.api.behavior.Behavior; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; @@ -194,6 +194,7 @@ public final class PathingBehavior extends Behavior implements Helper { } public void cancel() { + dispatchPathEvent(PathEvent.CANCELED); current = null; next = null; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); From eca41a046a03a93af8db26f951d87680593d0cf2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 19:35:35 -0700 Subject: [PATCH 156/329] more accurate name --- .../java/baritone/pathing/path/PathExecutor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 0e2750e0..8783ceb8 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -49,7 +49,7 @@ public class PathExecutor implements Helper { private int pathPosition; private int ticksAway; private int ticksOnCurrent; - private Double currentMovementInitialCostEstimate; + private Double currentMovementOriginalCostEstimate; private Integer costEstimateIndex; private boolean failed; private boolean recalcBP = true; @@ -209,7 +209,7 @@ public class PathExecutor implements Helper { if (costEstimateIndex == null || costEstimateIndex != pathPosition) { 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 - currentMovementInitialCostEstimate = movement.getCost(null); + currentMovementOriginalCostEstimate = movement.getCost(null); for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) { logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); @@ -224,8 +224,8 @@ public class PathExecutor implements Helper { cancel(); return true; } - if (!movement.calculatedWhileLoaded() && currentCost - currentMovementInitialCostEstimate > Baritone.settings().maxCostIncrease.get()) { - logDebug("Original cost " + currentMovementInitialCostEstimate + " current cost " + currentCost + ". Cancelling."); + if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.get()) { + logDebug("Original cost " + currentMovementOriginalCostEstimate + " current cost " + currentCost + ". Cancelling."); cancel(); return true; } @@ -245,12 +245,12 @@ public class PathExecutor implements Helper { } else { sprintIfRequested(); ticksOnCurrent++; - if (ticksOnCurrent > currentMovementInitialCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { + if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { // 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 // this is why we cache cost at the beginning, and don't recalculate for this comparison every tick - logDebug("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling."); + logDebug("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementOriginalCostEstimate + "). Cancelling."); cancel(); return true; } From 9937739518713fc4b10629408edfcc46d45733f7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 13:00:44 -0700 Subject: [PATCH 157/329] force internal mining --- src/main/java/baritone/Settings.java | 13 ++++++++ .../java/baritone/behavior/MineBehavior.java | 30 +++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 67ac6ab5..6502b9bd 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -343,6 +343,19 @@ public class Settings { */ public Setting axisHeight = new Setting<>(120); + /** + * When mining block of a certain type, try to mine two at once instead of one. + * If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks + * If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks + */ + public Setting forceInternalMining = new Setting<>(true); + + /** + * Modification to the previous setting, only has effect if forceInternalMining is true + * If true, only apply the previous setting if the block adjacent to the goal isn't air. + */ + public Setting internalMiningAirException = new Setting<>(true); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 3b0e4ec8..64c6c732 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -26,12 +26,14 @@ import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; import baritone.cache.WorldScanner; import baritone.pathing.goals.Goal; +import baritone.pathing.goals.GoalBlock; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -95,7 +97,7 @@ public final class MineBehavior extends Behavior implements Helper { } if (!locationsCache.isEmpty()) { locationsCache = prune(new ArrayList<>(locationsCache), mining, 64); - PathingBehavior.INSTANCE.setGoal(new GoalComposite(locationsCache.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.setGoal(coalesce(locationsCache)); PathingBehavior.INSTANCE.path(); } List locs = scanFor(mining, 64); @@ -105,10 +107,34 @@ public final class MineBehavior extends Behavior implements Helper { return; } locationsCache = locs; - PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.setGoal(coalesce(locs)); PathingBehavior.INSTANCE.path(); } + public static GoalComposite coalesce(List locs) { + return new GoalComposite(locs.stream().map(loc -> { + if (!Baritone.settings().forceInternalMining.get()) { + return new GoalTwoBlocks(loc); + } + + boolean noUp = locs.contains(loc.up()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + boolean noDown = locs.contains(loc.down()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + if (noUp) { + if (noDown) { + return new GoalTwoBlocks(loc); + } else { + return new GoalBlock(loc.down()); + } + } else { + if (noDown) { + return new GoalBlock(loc); + } else { + return new GoalTwoBlocks(loc); + } + } + }).toArray(Goal[]::new)); + } + public static List scanFor(List mining, int max) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>(); From 5492dc59e2c9e142a9d98030e0d81bbaca899b2c Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 15:05:05 -0500 Subject: [PATCH 158/329] Replace Setting usages with their actual number types --- src/main/java/baritone/Settings.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 6502b9bd..bfbbec61 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -129,7 +129,7 @@ public class Settings { *

* Finding the optimal path is worth it, so it's the default. */ - public Setting costHeuristic = this.new Setting(3.5D); + public Setting costHeuristic = new Setting<>(3.5D); // a bunch of obscure internal A* settings that you probably don't want to change /** @@ -222,12 +222,12 @@ public class Settings { /** * Pathing can never take longer than this */ - public Setting pathTimeoutMS = new Setting<>(2000L); + public Setting pathTimeoutMS = new Setting<>(2000L); /** * Planning ahead while executing a segment can never take longer than this */ - public Setting planAheadTimeoutMS = new Setting<>(4000L); + public Setting planAheadTimeoutMS = new Setting<>(4000L); /** * For debugging, consider nodes much much slower @@ -237,12 +237,12 @@ public class Settings { /** * Milliseconds between each node */ - public Setting slowPathTimeDelayMS = new Setting<>(100L); + public Setting slowPathTimeDelayMS = new Setting<>(100L); /** * The alternative timeout number when slowPath is on */ - public Setting slowPathTimeoutMS = new Setting<>(40000L); + public Setting slowPathTimeoutMS = new Setting<>(40000L); /** * The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing. From 30fc72a34c317ed78494a42a44c2293e591eac3b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 13:28:16 -0700 Subject: [PATCH 159/329] scan loaded if not cached --- src/main/java/baritone/behavior/MineBehavior.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 64c6c732..e272a310 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -147,6 +147,9 @@ public final class MineBehavior extends Behavior implements Helper { } } //System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms"); + if (locs.isEmpty()) { + uninteresting = mining; + } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); From 0ce68ee21f744d6c5ccf4339f0643c18b4b1576a Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 15:28:23 -0500 Subject: [PATCH 160/329] Replace some issue references with proper javadocs where applicable --- src/main/java/baritone/Settings.java | 6 ++++-- .../baritone/pathing/calc/AbstractNodeCostSearch.java | 8 ++++++-- src/main/java/baritone/pathing/path/PathExecutor.java | 11 ++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index bfbbec61..48dd17d8 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -139,8 +139,9 @@ public class Settings { public Setting pathingMaxChunkBorderFetch = new Setting<>(50); /** - * See issue #18 * Set to 1.0 to effectively disable this feature + * + * @see Issue #18 */ public Setting backtrackCostFavoringCoefficient = new Setting<>(0.9); @@ -153,7 +154,8 @@ public class Settings { /** * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is * entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified. - * See issue #114 for why this is disabled. + * + * @see Issue #144 */ public Setting cutoffAtLoadBoundary = new Setting<>(false); diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 3b8bfade..f4d90986 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -42,7 +42,10 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { protected final Goal goal; - private final Long2ObjectOpenHashMap map; // see issue #107 + /** + * @see Issue #107 + */ + private final Long2ObjectOpenHashMap map; protected PathNode startNode; @@ -119,11 +122,12 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * for the node mapped to the specified pos. If no node is found, * a new node is created. * + * @see Issue #107 + * * @param pos The pos to lookup * @return The associated node */ protected PathNode getNodeAtPosition(BetterBlockPos pos) { - // see issue #107 long hashCode = pos.hashCode; PathNode node = map.get(hashCode); if (node == null) { diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 8783ceb8..9db754ae 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -44,7 +44,16 @@ import static baritone.pathing.movement.MovementState.MovementStatus.*; public class PathExecutor implements Helper { private static final double MAX_MAX_DIST_FROM_PATH = 3; private static final double MAX_DIST_FROM_PATH = 2; - private static final double MAX_TICKS_AWAY = 200; // ten seconds. ok to decrease this, but it must be at least 110, see issue #102 + + /** + * Default value is equal to 10 seconds. It's find to decrease it, but it must be at least 5.5s (110 ticks). + * For more information, see issue #102. + * + * @see Issue #102 + * @see Anime + */ + private static final double MAX_TICKS_AWAY = 200; + private final IPath path; private int pathPosition; private int ticksAway; From 3f15451e8878766d58cee1166f9400dc6c3d11af Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 13:43:54 -0700 Subject: [PATCH 161/329] command to rescan and repack all loaded chunks --- .../utils/ExampleBaritoneControl.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index cb6f1382..546dc36a 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -36,8 +36,10 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; +import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.Chunk; import java.util.*; @@ -119,6 +121,24 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } + if (msg.equals("repack") || msg.equals("rescan")) { + ChunkProviderClient cli = world().getChunkProvider(); + int playerChunkX = playerFeet().getX() >> 4; + int playerChunkZ = playerFeet().getZ() >> 4; + int count = 0; + for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) { + for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) { + Chunk chunk = cli.getLoadedChunk(x, z); + if (chunk != null) { + count++; + WorldProvider.INSTANCE.getCurrentWorld().cache.queueForPacking(chunk); + } + } + } + logDirect("Queued " + count + " chunks for repacking"); + event.cancel(); + return; + } if (msg.equals("axis")) { PathingBehavior.INSTANCE.setGoal(new GoalAxis()); PathingBehavior.INSTANCE.path(); From 23779329a90ba35b4457e45b919d77eb9905a3d6 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 15:59:40 -0500 Subject: [PATCH 162/329] Expose registerEventListener in Baritone class --- src/main/java/baritone/Baritone.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index fb373c6e..ed69acda 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -114,7 +114,11 @@ public enum Baritone { public void registerBehavior(Behavior behavior) { this.behaviors.add(behavior); - this.gameEventHandler.registerEventListener(behavior); + this.registerEventListener(behavior); + } + + public void registerEventListener(IGameEventListener listener) { + this.gameEventHandler.registerEventListener(listener); } public final boolean isActive() { From 8dac838fe001d4033ea341e9387c47e896ff591d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 14:14:50 -0700 Subject: [PATCH 163/329] thread pool executor --- src/main/java/baritone/Baritone.java | 29 +++++++++++++------ .../baritone/behavior/PathingBehavior.java | 6 ++-- src/main/java/baritone/cache/CachedWorld.java | 8 ++--- src/main/java/baritone/cache/WorldData.java | 12 ++++---- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index ed69acda..0d89b730 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -17,8 +17,8 @@ package baritone; -import baritone.api.event.listener.IGameEventListener; import baritone.api.behavior.Behavior; +import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; import baritone.event.GameEventHandler; import baritone.utils.InputOverrideHandler; @@ -29,6 +29,10 @@ import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Executor; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; /** @@ -52,6 +56,8 @@ public enum Baritone { private Settings settings; private List behaviors; private File dir; + private ThreadPoolExecutor threadPool; + /** * List of consumers to be called after Baritone has initialized @@ -71,6 +77,7 @@ public enum Baritone { if (initialized) { return; } + this.threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); this.gameEventHandler = new GameEventHandler(); this.inputOverrideHandler = new InputOverrideHandler(); this.settings = new Settings(); @@ -96,22 +103,26 @@ public enum Baritone { this.onInitConsumers.forEach(consumer -> consumer.accept(this)); } - public final boolean isInitialized() { + public boolean isInitialized() { return this.initialized; } - public final IGameEventListener getGameEventHandler() { + public IGameEventListener getGameEventHandler() { return this.gameEventHandler; } - public final InputOverrideHandler getInputOverrideHandler() { + public InputOverrideHandler getInputOverrideHandler() { return this.inputOverrideHandler; } - public final List getBehaviors() { + public List getBehaviors() { return this.behaviors; } + public Executor getExecutor() { + return threadPool; + } + public void registerBehavior(Behavior behavior) { this.behaviors.add(behavior); this.registerEventListener(behavior); @@ -121,11 +132,11 @@ public enum Baritone { this.gameEventHandler.registerEventListener(listener); } - public final boolean isActive() { + public boolean isActive() { return this.active; } - public final Settings getSettings() { + public Settings getSettings() { return this.settings; } @@ -133,11 +144,11 @@ public enum Baritone { return Baritone.INSTANCE.settings; // yolo } - public final File getDir() { + public File getDir() { return this.dir; } - public final void registerInitListener(Consumer runnable) { + public void registerInitListener(Consumer runnable) { this.onInitConsumers.add(runnable); } } diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 205e5001..99d7f5e2 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -61,7 +61,7 @@ public final class PathingBehavior extends Behavior implements Helper { private boolean lastAutoJump; private void dispatchPathEvent(PathEvent event) { - new Thread(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event)).start(); + Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event)); } @Override @@ -249,7 +249,7 @@ public final class PathingBehavior extends Behavior implements Helper { } isPathCalcInProgress = true; } - new Thread(() -> { + Baritone.INSTANCE.getExecutor().execute(() -> { if (talkAboutIt) { logDebug("Starting to search for path from " + start + " to " + goal); } @@ -292,7 +292,7 @@ public final class PathingBehavior extends Behavior implements Helper { synchronized (pathCalcLock) { isPathCalcInProgress = false; } - }).start(); + }); } /** diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index d903c2cd..f866989a 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -66,8 +66,8 @@ public final class CachedWorld implements Helper { System.out.println("Cached world directory: " + directory); // Insert an invalid region element cachedRegions.put(0, null); - new PackerThread().start(); - new Thread(() -> { + Baritone.INSTANCE.getExecutor().execute(new PackerThread()); + Baritone.INSTANCE.getExecutor().execute(() -> { try { Thread.sleep(30000); while (true) { @@ -80,7 +80,7 @@ public final class CachedWorld implements Helper { } catch (InterruptedException e) { e.printStackTrace(); } - }).start(); + }); } public final void queueForPacking(Chunk chunk) { @@ -221,7 +221,7 @@ public final class CachedWorld implements Helper { return regionX <= REGION_MAX && regionX >= -REGION_MAX && regionZ <= REGION_MAX && regionZ >= -REGION_MAX; } - private class PackerThread extends Thread { + private class PackerThread implements Runnable { public void run() { while (true) { LinkedBlockingQueue queue = toPack; diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index a7d0b72a..6637d7b1 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -17,6 +17,8 @@ package baritone.cache; +import baritone.Baritone; + import java.nio.file.Path; /** @@ -37,11 +39,9 @@ public class WorldData { } void onClose() { - new Thread() { - public void run() { - System.out.println("Started saving the world in a new thread"); - cache.save(); - } - }.start(); + Baritone.INSTANCE.getExecutor().execute(() -> { + System.out.println("Started saving the world in a new thread"); + cache.save(); + }); } } From a92465a5f991960b6c0159d18924278f7d2e3309 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 16:46:41 -0500 Subject: [PATCH 164/329] Exceedingly beautiful --- src/main/java/baritone/cache/ChunkPacker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 5c2374ce..46d0f175 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -111,14 +111,14 @@ public final class ChunkPacker implements Helper { //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); String[] blockNames = new String[256]; for (int z = 0; z < 16; z++) { - outerLoop: + 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); if (bitSet.get(index) || bitSet.get(index + 1)) { String name = blockToString(chunk.getBlockState(x, y, z).getBlock()); blockNames[z << 4 | x] = name; - continue outerLoop; + continue https; } } blockNames[z << 4 | x] = "air"; From 7fd0d2d038d5fe02e266f1031e750ffa8884e0ae Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 16:45:56 -0700 Subject: [PATCH 165/329] clean up toLowerCase --- .../utils/ExampleBaritoneControl.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 546dc36a..98964315 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -62,16 +62,16 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } } - String msg = event.getMessage(); + String msg = event.getMessage().toLowerCase(Locale.US); if (Baritone.settings().prefix.get()) { if (!msg.startsWith("#")) { return; } msg = msg.substring(1); } - if (msg.toLowerCase().startsWith("goal")) { + if (msg.startsWith("goal")) { event.cancel(); - String[] params = msg.toLowerCase().substring(4).trim().split(" "); + String[] params = msg.substring(4).trim().split(" "); if (params[0].equals("")) { params = new String[]{}; } @@ -145,7 +145,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("cancel")) { + if (msg.equals("cancel")) { MineBehavior.INSTANCE.cancel(); FollowBehavior.INSTANCE.cancel(); PathingBehavior.INSTANCE.cancel(); @@ -153,13 +153,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("ok canceled"); return; } - if (msg.toLowerCase().equals("forcecancel")) { + if (msg.equals("forcecancel")) { AbstractNodeCostSearch.forceCancel(); event.cancel(); logDirect("ok force canceled"); return; } - if (msg.toLowerCase().equals("invert")) { + if (msg.equals("invert")) { Goal goal = PathingBehavior.INSTANCE.getGoal(); BlockPos runAwayFrom; if (goal instanceof GoalXZ) { @@ -183,7 +183,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("follow")) { + if (msg.equals("follow")) { Optional entity = MovementHelper.whatEntityAmILookingAt(); if (!entity.isPresent()) { logDirect("You aren't looking at an entity bruh"); @@ -195,20 +195,20 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("reloadall")) { + if (msg.equals("reloadall")) { WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk(); logDirect("ok"); event.cancel(); return; } - if (msg.toLowerCase().equals("saveall")) { + if (msg.equals("saveall")) { WorldProvider.INSTANCE.getCurrentWorld().cache.save(); logDirect("ok"); event.cancel(); return; } - if (msg.toLowerCase().startsWith("find")) { - String blockType = msg.toLowerCase().substring(4).trim(); + if (msg.startsWith("find")) { + String blockType = msg.substring(4).trim(); LinkedList locs = WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(blockType, 1, 4); logDirect("Have " + locs.size() + " locations"); for (BlockPos pos : locs) { @@ -220,8 +220,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().startsWith("mine")) { - String[] blockTypes = msg.toLowerCase().substring(4).trim().split(" "); + if (msg.startsWith("mine")) { + String[] blockTypes = msg.substring(4).trim().split(" "); for (String s : blockTypes) { if (ChunkPacker.stringToBlock(s) == null) { logDirect(s + " isn't a valid block name"); @@ -234,7 +234,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().startsWith("thisway")) { + if (msg.startsWith("thisway")) { try { Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim())); PathingBehavior.INSTANCE.setGoal(goal); @@ -245,8 +245,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().startsWith("list") || msg.toLowerCase().startsWith("get ") || msg.toLowerCase().startsWith("show")) { - String waypointType = msg.toLowerCase().substring(4).trim(); + if (msg.startsWith("list") || msg.startsWith("get ") || msg.startsWith("show")) { + String waypointType = msg.substring(4).trim(); if (waypointType.endsWith("s")) { // for example, "show deaths" waypointType = waypointType.substring(0, waypointType.length() - 1); @@ -268,15 +268,15 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().startsWith("save")) { + if (msg.startsWith("save")) { String name = msg.substring(4).trim(); WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.USER, playerFeet())); logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); event.cancel(); return; } - if (msg.toLowerCase().startsWith("goto")) { - String waypointType = msg.toLowerCase().substring(4).trim(); + if (msg.startsWith("goto")) { + String waypointType = msg.substring(4).trim(); if (waypointType.endsWith("s") && Waypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) { // for example, "show deaths" waypointType = waypointType.substring(0, waypointType.length() - 1); @@ -316,7 +316,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("spawn") || msg.toLowerCase().equals("bed")) { + if (msg.equals("spawn") || msg.equals("bed")) { Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.BED); if (waypoint == null) { BlockPos spawnPoint = player().getBedLocation(); @@ -332,13 +332,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("sethome")) { + if (msg.equals("sethome")) { WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet())); logDirect("Saved. Say home to set goal."); event.cancel(); return; } - if (msg.toLowerCase().equals("home")) { + if (msg.equals("home")) { Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME); if (waypoint == null) { logDirect("home not saved"); @@ -350,7 +350,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.toLowerCase().equals("costs")) { + if (msg.equals("costs")) { Movement[] movements = AStarPathFinder.getConnectedPositions(new BetterBlockPos(playerFeet()), new CalculationContext()); List moves = new ArrayList<>(Arrays.asList(movements)); while (moves.contains(null)) { @@ -378,7 +378,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } } - if (msg.toLowerCase().equals("baritone") || msg.toLowerCase().equals("settings")) { + if (msg.equals("baritone") || msg.equals("settings")) { for (Settings.Setting setting : Baritone.settings().allSettings) { logDirect(setting.toString()); } @@ -388,7 +388,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { if (msg.contains(" ")) { String[] data = msg.split(" "); if (data.length == 2) { - Settings.Setting setting = Baritone.settings().byLowerName.get(data[0].toLowerCase()); + Settings.Setting setting = Baritone.settings().byLowerName.get(data[0]); if (setting != null) { try { if (setting.value.getClass() == Long.class) { @@ -411,8 +411,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } } } - if (Baritone.settings().byLowerName.containsKey(msg.toLowerCase())) { - Settings.Setting setting = Baritone.settings().byLowerName.get(msg.toLowerCase()); + if (Baritone.settings().byLowerName.containsKey(msg)) { + Settings.Setting setting = Baritone.settings().byLowerName.get(msg); logDirect(setting.toString()); event.cancel(); return; From 51f1cadbb8abaa3a51ed6edff61f4c48dcaadb66 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 16:50:56 -0700 Subject: [PATCH 166/329] now unused --- src/main/java/baritone/pathing/goals/GoalBlock.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 124740a3..0c96787c 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -57,16 +57,6 @@ public class GoalBlock implements Goal, IGoalRenderPos { return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z; } - /** - * The min range value over which to begin considering Y coordinate in the heuristic - */ - private static final double MIN = 20; - - /** - * The max range value over which to begin considering Y coordinate in the heuristic - */ - private static final double MAX = 150; - @Override public double heuristic(BlockPos pos) { int xDiff = pos.getX() - this.x; From fb7d729b11a02c996436f3a85bc4e485ae40f446 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:11:04 -0700 Subject: [PATCH 167/329] misc cleanup --- .../movement/movements/MovementTraverse.java | 3 +- .../baritone/pathing/path/PathExecutor.java | 2 +- .../pathing/calc/openset/OpenSetsTest.java | 34 +++++++++++++------ .../utils/pathing/BetterBlockPosTest.java | 4 +++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 36c0cfc9..f28f29fb 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -263,9 +263,8 @@ public class MovementTraverse extends Movement { if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) { if (LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionToPlace)) { return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - } else { - // Out.gui("Wrong. " + side + " " + LookBehaviorUtils.getSelectedBlock().get().offset(side) + " " + positionsToPlace[0], Out.Mode.Debug); } + // wrong side? } System.out.println("Trying to look at " + against1 + ", actually looking at" + LookBehaviorUtils.getSelectedBlock()); return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 9db754ae..02435502 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -212,7 +212,7 @@ public class PathExecutor implements Helper { } long end = System.nanoTime() / 1000000L; if (end - start > 0) { - //logDebug("Recalculating break and place took " + (end - start) + "ms"); + System.out.println("Recalculating break and place took " + (end - start) + "ms"); } Movement movement = path.movements().get(pathPosition); if (costEstimateIndex == null || costEstimateIndex != pathPosition) { diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 6812f90d..5ab10d24 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -22,24 +22,37 @@ import baritone.pathing.goals.Goal; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import java.util.*; import static org.junit.Assert.*; +@RunWith(Parameterized.class) public class OpenSetsTest { - @Test - public void testOpenSets() { - for (int size = 1; size < 100; size++) { - testSize(size); - } - for (int size = 100; size < 10000; size += 100) { - testSize(size); - } + private final int size; + + public OpenSetsTest(int size) { + this.size = size; } - public void removeAndTest(int amount, IOpenSet[] test, Optional> mustContain) { + @Parameterized.Parameters + public static Collection data() { + ArrayList testSizes = new ArrayList<>(); + for (int size = 1; size < 20; size++) { + testSizes.add(new Object[]{size}); + } + for (int size = 100; size <= 1000; size += 100) { + testSizes.add(new Object[]{size}); + } + testSizes.add(new Object[]{5000}); + testSizes.add(new Object[]{10000}); + return testSizes; + } + + private static void removeAndTest(int amount, IOpenSet[] test, Optional> mustContain) { double[][] results = new double[test.length][amount]; for (int i = 0; i < test.length; i++) { long before = System.nanoTime() / 1000000L; @@ -62,7 +75,8 @@ public class OpenSetsTest { } } - public void testSize(int size) { + @Test + public void testSize() { System.out.println("Testing size " + size); // Include LinkedListOpenSet even though it's not performant because I absolutely trust that it behaves properly // I'm really testing the heap implementations against it as the ground truth diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index 758812f2..ff54579b 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -20,6 +20,8 @@ package baritone.utils.pathing; import net.minecraft.util.math.BlockPos; import org.junit.Test; +import static org.junit.Assert.assertTrue; + public class BetterBlockPosTest { @Test @@ -33,7 +35,9 @@ public class BetterBlockPosTest { for (int i = 0; i < 10; i++) { // eliminate any advantage to going first benchN(); + assertTrue(i<10); } + } public void benchOne() { From dbd1fb2aa2abd514bc7866b4c702ba8e9514b22f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:15:33 -0700 Subject: [PATCH 168/329] misc cleanup 2 --- .../event/listener/IGameEventListener.java | 5 ++++ .../baritone/behavior/PathingBehavior.java | 6 ++--- src/main/java/baritone/cache/ChunkPacker.java | 27 +++---------------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/api/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java index c63cbfbc..9587376a 100644 --- a/src/api/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/IGameEventListener.java @@ -109,6 +109,8 @@ public interface IGameEventListener { * Runs before a outbound packet is sent * * @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[]) + * @see Packet + * @see GenericFutureListener */ void onSendPacket(PacketEvent event); @@ -116,6 +118,8 @@ public interface IGameEventListener { * Runs before an inbound packet is processed * * @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[]) + * @see Packet + * @see GenericFutureListener */ void onReceivePacket(PacketEvent event); @@ -140,6 +144,7 @@ public interface IGameEventListener { * Called when the local player dies, as indicated by the creation of the {@link GuiGameOver} screen. * * @see GuiGameOver(ITextComponent) + * @see ITextComponent */ void onPlayerDeath(); diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 99d7f5e2..22440af4 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -355,7 +355,7 @@ public final class PathingBehavior extends Behavior implements Helper { return; } - long start = System.nanoTime(); + //long start = System.nanoTime(); PathExecutor current = this.current; // this should prevent most race conditions? @@ -372,7 +372,7 @@ public final class PathingBehavior extends Behavior implements Helper { PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.MAGENTA, Baritone.settings().fadePath.get(), 10, 20); } - long split = System.nanoTime(); + //long split = System.nanoTime(); if (current != null) { PathRenderer.drawManySelectionBoxes(player(), current.toBreak(), partialTicks, Color.RED); PathRenderer.drawManySelectionBoxes(player(), current.toPlace(), partialTicks, Color.GREEN); @@ -390,7 +390,7 @@ public final class PathingBehavior extends Behavior implements Helper { }); }); }); - long end = System.nanoTime(); + //long end = System.nanoTime(); //System.out.println((end - split) + " " + (split - start)); // if (end - start > 0) { // System.out.println("Frame took " + (split - start) + " " + (end - split)); diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 46d0f175..c73a0212 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -42,24 +42,8 @@ public final class ChunkPacker implements Helper { private ChunkPacker() {} - private static BitSet originalPacker(Chunk chunk) { - BitSet bitSet = new BitSet(CachedChunk.SIZE); - for (int y = 0; y < 256; y++) { - for (int z = 0; z < 16; z++) { - for (int x = 0; x < 16; x++) { - int index = CachedChunk.getPositionIndex(x, y, z); - IBlockState state = chunk.getBlockState(x, y, z); - boolean[] bits = getPathingBlockType(state).getBits(); - bitSet.set(index, bits[0]); - bitSet.set(index + 1, bits[1]); - } - } - } - return bitSet; - } - public static CachedChunk pack(Chunk chunk) { - long start = System.nanoTime() / 1000000L; + //long start = System.nanoTime() / 1000000L; Map> specialBlocks = new HashMap<>(); BitSet bitSet = new BitSet(CachedChunk.SIZE); @@ -100,18 +84,15 @@ public final class ChunkPacker implements Helper { } } } - /*if (!bitSet.equals(originalPacker(chunk))) { - throw new IllegalStateException(); - }*/ } catch (Exception e) { e.printStackTrace(); } - //System.out.println("Packed special blocks: " + specialBlocks); - long end = System.nanoTime() / 1000000L; + //long end = System.nanoTime() / 1000000L; //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); String[] blockNames = new String[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); From e75d0ff102635d0479e8d0557f33eff60cd06e62 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:25:14 -0700 Subject: [PATCH 169/329] huh thats neat --- .../baritone/pathing/calc/AbstractNodeCostSearch.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index f4d90986..6e8220e1 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -89,14 +89,10 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { path.ifPresent(IPath::postprocess); isFinished = true; return path; - } catch (Exception e) { + } finally { + // this is run regardless of what exception may or may not be raised by calculate0 currentlyRunning = null; isFinished = true; - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException(e); - } } } @@ -122,10 +118,9 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * for the node mapped to the specified pos. If no node is found, * a new node is created. * - * @see Issue #107 - * * @param pos The pos to lookup * @return The associated node + * @see Issue #107 */ protected PathNode getNodeAtPosition(BetterBlockPos pos) { long hashCode = pos.hashCode; From af58304b3836a4edfadcf1ee3c65e56e96275bcf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:49:19 -0700 Subject: [PATCH 170/329] misc cleanup 3 --- .../baritone/api/event/events/TickEvent.java | 9 +++++++-- .../java/baritone/behavior/MineBehavior.java | 2 +- src/main/java/baritone/cache/ChunkPacker.java | 10 +++------- src/main/java/baritone/pathing/calc/Path.java | 10 +++++----- .../baritone/pathing/goals/GoalComposite.java | 5 +++-- .../java/baritone/pathing/goals/GoalNear.java | 8 ++++---- .../java/baritone/pathing/goals/GoalRunAway.java | 4 ++-- .../java/baritone/pathing/goals/GoalYLevel.java | 2 +- ...stsButOnlyTheOnesThatMakeMickeyDieInside.java | 9 ++++----- .../java/baritone/pathing/movement/Movement.java | 5 +---- .../pathing/movement/MovementHelper.java | 16 ++++++++-------- .../movement/movements/MovementDescend.java | 4 ++-- .../movement/movements/MovementParkour.java | 7 +++---- .../java/baritone/pathing/path/CutoffPath.java | 6 +++--- .../baritone/utils/InputOverrideHandler.java | 2 -- src/main/java/baritone/utils/ToolSet.java | 5 ----- 16 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/api/java/baritone/api/event/events/TickEvent.java b/src/api/java/baritone/api/event/events/TickEvent.java index 362a88cc..c765daa9 100644 --- a/src/api/java/baritone/api/event/events/TickEvent.java +++ b/src/api/java/baritone/api/event/events/TickEvent.java @@ -23,13 +23,18 @@ public final class TickEvent { private final EventState state; private final Type type; + private final int count; - private static int count; + private static int overallTickCount; public TickEvent(EventState state, Type type) { this.state = state; this.type = type; - count++; + this.count = incrementCount(); + } + + private static synchronized int incrementCount() { + return overallTickCount++; } public int getCount() { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index e272a310..4c542c47 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -168,7 +168,7 @@ public final class MineBehavior extends Behavior implements Helper { .filter(pos -> !mining.contains(BlockStateInterface.get(pos).getBlock())) .collect(Collectors.toList())); if (locs.size() > max) { - locs = locs.subList(0, max); + return locs.subList(0, max); } return locs; } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index c73a0212..3055553b 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -91,8 +91,7 @@ public final class ChunkPacker implements Helper { //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); String[] blockNames = new String[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); @@ -119,10 +118,7 @@ public final class ChunkPacker implements Helper { } public static Block stringToBlock(String name) { - if (!name.contains(":")) { - name = "minecraft:" + name; - } - return Block.getBlockFromName(name); + return Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name); } private static PathingBlockType getPathingBlockType(IBlockState state) { @@ -146,7 +142,7 @@ public final class ChunkPacker implements Helper { return PathingBlockType.SOLID; } - static IBlockState pathingTypeToBlock(PathingBlockType type) { + public static IBlockState pathingTypeToBlock(PathingBlockType type) { if (type != null) { switch (type) { case AIR: diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index bec1e3a0..1910927c 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -38,22 +38,22 @@ class Path implements IPath { /** * The start position of this path */ - final BetterBlockPos start; + private final BetterBlockPos start; /** * The end position of this path */ - final BetterBlockPos end; + private final BetterBlockPos end; /** * The blocks on the path. Guaranteed that path.get(0) equals start and * path.get(path.size()-1) equals end */ - final List path; + private final List path; - final List movements; + private final List movements; - final Goal goal; + private final Goal goal; private final int numNodes; diff --git a/src/main/java/baritone/pathing/goals/GoalComposite.java b/src/main/java/baritone/pathing/goals/GoalComposite.java index 558e124e..bd1e0905 100644 --- a/src/main/java/baritone/pathing/goals/GoalComposite.java +++ b/src/main/java/baritone/pathing/goals/GoalComposite.java @@ -17,9 +17,10 @@ package baritone.pathing.goals; +import net.minecraft.util.math.BlockPos; + import java.util.Arrays; import java.util.Collection; -import net.minecraft.util.math.BlockPos; /** * A composite of many goals, any one of which satisfies the composite. @@ -33,7 +34,7 @@ public class GoalComposite implements Goal { /** * An array of goals that any one of must be satisfied */ - public final Goal[] goals; + private final Goal[] goals; public GoalComposite(Goal... goals) { this.goals = goals; diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index e78788ac..7786c4f1 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -21,10 +21,10 @@ import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; public class GoalNear implements Goal, IGoalRenderPos { - final int x; - final int y; - final int z; - final int rangeSq; + private final int x; + private final int y; + private final int z; + private final int rangeSq; public GoalNear(BlockPos pos, int range) { this.x = pos.getX(); diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/main/java/baritone/pathing/goals/GoalRunAway.java index 90e2f68e..15cd2489 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/main/java/baritone/pathing/goals/GoalRunAway.java @@ -28,9 +28,9 @@ import java.util.Arrays; */ public class GoalRunAway implements Goal { - public final BlockPos[] from; + private final BlockPos[] from; - final double distanceSq; + private final double distanceSq; public GoalRunAway(double distance, BlockPos... from) { if (from.length == 0) { diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/main/java/baritone/pathing/goals/GoalYLevel.java index 445a450b..97d63311 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/main/java/baritone/pathing/goals/GoalYLevel.java @@ -45,7 +45,7 @@ public class GoalYLevel implements Goal { return calculate(level, pos.getY()); } - static double calculate(int goalY, int currentY) { + public static double calculate(int goalY, int currentY) { if (currentY > goalY) { // need to descend return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); diff --git a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java b/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java index c2481cda..e955c41e 100644 --- a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java +++ b/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java @@ -57,16 +57,15 @@ public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { if (distance == 0) { return 0; // Avoid 0/0 NaN } + double tmpDistance = distance; int tickCount = 0; while (true) { double fallDistance = velocity(tickCount); - if (distance <= fallDistance) { - return tickCount + distance / fallDistance; + if (tmpDistance <= fallDistance) { + return tickCount + tmpDistance / fallDistance; } - distance -= fallDistance; + tmpDistance -= fallDistance; tickCount++; } } - - } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 5c7aae36..4f31d1a0 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -72,10 +72,7 @@ public abstract class Movement implements Helper, MovementHelper { public double getCost(CalculationContext context) { if (cost == null) { - if (context == null) { - context = new CalculationContext(); - } - cost = calculateCost(context); + cost = calculateCost(context != null ? context : new CalculationContext()); } return cost; } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index d602fdad..1d7ca673 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -438,15 +438,15 @@ public interface MovementHelper extends ActionCosts, Helper { if (canWalkThrough(onto, ontoBlock)) { continue; } - if (canWalkOn(onto, ontoBlock)) { - if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) { - // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new MovementFall(pos, onto.up()); - } else { - return null; - } + if (!canWalkOn(onto, ontoBlock)) { + break; + } + if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) { + // fallHeight = 4 means onto.up() is 3 blocks down, which is the max + return new MovementFall(pos, onto.up()); + } else { + return null; } - break; } return null; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 593c410a..b033b6fc 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -31,6 +31,8 @@ import net.minecraft.util.math.BlockPos; public class MovementDescend extends Movement { + private int numTicks = 0; + public MovementDescend(BetterBlockPos start, BetterBlockPos end) { super(start, end, new BlockPos[]{end.up(2), end.up(), end}, end.down()); } @@ -63,8 +65,6 @@ public class MovementDescend extends Movement { return walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST) + getTotalHardnessOfBlocksToBreak(context); } - int numTicks = 0; - @Override public MovementState updateState(MovementState state) { super.updateState(state); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 1d0dcdd4..ca116342 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -38,11 +38,10 @@ import net.minecraft.util.math.Vec3d; import java.util.Objects; public class MovementParkour extends Movement { - protected static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; + private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; - - final EnumFacing direction; - final int dist; + private final EnumFacing direction; + private final int dist; private MovementParkour(BetterBlockPos src, int dist, EnumFacing dir) { super(src, src.offset(dir, dist), new BlockPos[]{}); diff --git a/src/main/java/baritone/pathing/path/CutoffPath.java b/src/main/java/baritone/pathing/path/CutoffPath.java index ea10e8c5..d55d8652 100644 --- a/src/main/java/baritone/pathing/path/CutoffPath.java +++ b/src/main/java/baritone/pathing/path/CutoffPath.java @@ -26,13 +26,13 @@ import java.util.List; public class CutoffPath implements IPath { - final List path; + private final List path; - final List movements; + private final List movements; private final int numNodes; - final Goal goal; + private final Goal goal; public CutoffPath(IPath prev, int lastPositionToInclude) { path = prev.positions().subList(0, lastPositionToInclude + 1); diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index 6024df63..eba6b9c0 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -49,8 +49,6 @@ import java.util.Map; */ public final class InputOverrideHandler implements Helper { - public InputOverrideHandler() {} - /** * Maps keybinds to whether or not we are forcing their state down. */ diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 9a6ca4d7..1415d9e2 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -41,11 +41,6 @@ public class ToolSet implements Helper { */ private Map breakStrengthCache = new HashMap<>(); - /** - * Create a toolset from the current player's inventory (but don't calculate any hardness values just yet) - */ - public ToolSet() {} - /** * Calculate which tool on the hotbar is best for mining * From 543c0d0a3357187ab024d6b3ac158214cc6d98d3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:51:39 -0700 Subject: [PATCH 171/329] dont modify arguments --- src/main/java/baritone/utils/PathRenderer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index ae078268..ee9a585c 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -56,7 +56,7 @@ public final class PathRenderer implements Helper { private static final Tessellator TESSELLATOR = Tessellator.getInstance(); private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer(); - public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart, int fadeEnd) { + public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) { 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); @@ -66,8 +66,8 @@ public final class PathRenderer implements Helper { List positions = path.positions(); int next; Tessellator tessellator = Tessellator.getInstance(); - fadeStart += startIndex; - fadeEnd += startIndex; + int fadeStart = fadeStart0 + startIndex; + int fadeEnd = fadeEnd0 + startIndex; for (int i = startIndex; i < positions.size() - 1; i = next) { BlockPos start = positions.get(i); From b7cc707737fa12998e7b3fb96844c300628b48f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:58:35 -0700 Subject: [PATCH 172/329] misc cleanup 4 --- src/main/java/baritone/Settings.java | 2 +- src/main/java/baritone/cache/CachedRegion.java | 2 +- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 2 +- .../java/baritone/pathing/calc/openset/LinkedListOpenSet.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 48dd17d8..d9c2ff40 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -414,7 +414,7 @@ public class Settings { } } } catch (IllegalAccessException e) { - throw new RuntimeException(e); + throw new IllegalStateException(e); } byLowerName = Collections.unmodifiableMap(tmpByName); allSettings = Collections.unmodifiableList(tmpAll); diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 1e5e8ea5..1805f5ea 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -100,7 +100,7 @@ public final class CachedRegion implements IBlockTypeAccess { return res; } - final synchronized void updateCachedChunk(int chunkX, int chunkZ, CachedChunk chunk) { + public final synchronized void updateCachedChunk(int chunkX, int chunkZ, CachedChunk chunk) { this.chunks[chunkX][chunkZ] = chunk; hasUnsavedChanges = true; } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index ddf61b7a..8868e1fe 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -116,7 +116,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { int chunkZ = currentNodePos.z >> 4; if (dest.x >> 4 != chunkX || dest.z >> 4 != chunkZ) { // only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement - if (chunkProvider.getLoadedChunk(chunkX, chunkZ) == null) { + if (chunkProvider.isChunkGeneratedAt(chunkX, chunkZ)) { // see issue #106 if (cachedWorld == null || !cachedWorld.isCached(dest)) { numEmptyChunk++; diff --git a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java index 8ff5a674..e06a9850 100644 --- a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java @@ -83,7 +83,7 @@ class LinkedListOpenSet implements IOpenSet { } public static class Node { //wrapper with next - Node nextOpen; - PathNode val; + private Node nextOpen; + private PathNode val; } } From bc82276e62b26f664f016f4a73a9a8c8d9f5a03b Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 20:14:51 -0500 Subject: [PATCH 173/329] Why null check when you can default null --- src/main/java/baritone/cache/ChunkPacker.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 3055553b..042c37f4 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -143,29 +143,28 @@ public final class ChunkPacker implements Helper { } public static IBlockState pathingTypeToBlock(PathingBlockType type) { - if (type != null) { - switch (type) { - case AIR: - return Blocks.AIR.getDefaultState(); - case WATER: - return Blocks.WATER.getDefaultState(); - case AVOID: - return Blocks.LAVA.getDefaultState(); - case SOLID: - // Dimension solid types - switch (mc.player.dimension) { - case -1: - return Blocks.NETHERRACK.getDefaultState(); - case 0: - return Blocks.STONE.getDefaultState(); - case 1: - return Blocks.END_STONE.getDefaultState(); - } + switch (type) { + case AIR: + return Blocks.AIR.getDefaultState(); + case WATER: + return Blocks.WATER.getDefaultState(); + case AVOID: + return Blocks.LAVA.getDefaultState(); + case SOLID: + // Dimension solid types + switch (mc.player.dimension) { + case -1: + return Blocks.NETHERRACK.getDefaultState(); + case 0: + return Blocks.STONE.getDefaultState(); + case 1: + return Blocks.END_STONE.getDefaultState(); + } - // The fallback solid type - return Blocks.STONE.getDefaultState(); - } + // The fallback solid type + return Blocks.STONE.getDefaultState(); + default: + return null; } - return null; } } From aa2caf63d3389bc9c2b5c021c426a40a9aa3c106 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 21:18:39 -0500 Subject: [PATCH 174/329] Clean up PathingBehavior#findPath --- .../java/baritone/behavior/PathingBehavior.java | 16 ++++------------ .../java/baritone/pathing/goals/GoalBlock.java | 1 + .../baritone/pathing/goals/GoalGetToBlock.java | 1 + .../java/baritone/pathing/goals/GoalNear.java | 1 + .../baritone/pathing/goals/GoalTwoBlocks.java | 1 + 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 22440af4..b42075d6 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -33,6 +33,7 @@ import baritone.pathing.path.PathExecutor; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.PathRenderer; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -309,18 +310,9 @@ public final class PathingBehavior extends Behavior implements Helper { } if (Baritone.settings().simplifyUnloadedYCoord.get()) { BlockPos pos = null; - if (goal instanceof GoalBlock) { - pos = ((GoalBlock) goal).getGoalPos(); - } - if (goal instanceof GoalTwoBlocks) { - pos = ((GoalTwoBlocks) goal).getGoalPos(); - } - if (goal instanceof GoalNear) { - pos = ((GoalNear) goal).getGoalPos(); - } - if (goal instanceof GoalGetToBlock) { - pos = ((GoalGetToBlock) goal).getGoalPos(); - } + if (goal instanceof IGoalRenderPos) + pos = ((IGoalRenderPos) goal).getGoalPos(); + // TODO simplify each individual goal in a GoalComposite if (pos != null && world().getChunk(pos) instanceof EmptyChunk) { logDebug("Simplifying " + goal.getClass() + " to GoalXZ due to distance"); diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 0c96787c..b85f468a 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -73,6 +73,7 @@ public class GoalBlock implements Goal, IGoalRenderPos { /** * @return The position of this goal as a {@link BlockPos} */ + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 16cf9f4b..cefed91a 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -39,6 +39,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { this.z = pos.getZ(); } + @Override public BlockPos getGoalPos() { return new BetterBlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 7786c4f1..1b214c10 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -49,6 +49,7 @@ public class GoalNear implements Goal, IGoalRenderPos { return GoalBlock.calculate(diffX, diffY, diffZ); } + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index dcd8d17d..edc70483 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -69,6 +69,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { return GoalBlock.calculate(xDiff, yDiff, zDiff); } + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); } From b4ddd98bcbe4ec2c0fc0e6ca032de8fb77c5375e Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 21:24:13 -0500 Subject: [PATCH 175/329] cUrLy BrAcKeT --- src/main/java/baritone/behavior/PathingBehavior.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index b42075d6..6dee8b46 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -310,8 +310,9 @@ public final class PathingBehavior extends Behavior implements Helper { } if (Baritone.settings().simplifyUnloadedYCoord.get()) { BlockPos pos = null; - if (goal instanceof IGoalRenderPos) + if (goal instanceof IGoalRenderPos) { pos = ((IGoalRenderPos) goal).getGoalPos(); + } // TODO simplify each individual goal in a GoalComposite if (pos != null && world().getChunk(pos) instanceof EmptyChunk) { From 5f0009a060d8c8f96d42259fe013ab884942f838 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:24:21 -0700 Subject: [PATCH 176/329] fuming --- src/api/java/baritone/api/behavior/Behavior.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java index 67d3c25b..0ee05429 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -50,8 +50,9 @@ public class Behavior implements AbstractGameEventListener, Toggleable { */ @Override public final boolean setEnabled(boolean enabled) { - if (enabled == this.enabled) + if (enabled == this.enabled) { return this.enabled; + } if (this.enabled = enabled) { this.onEnable(); From eac5184d4db30313f8f947a24ba6d57dbf1a681a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:30:47 -0700 Subject: [PATCH 177/329] nit --- src/api/java/baritone/api/behavior/Behavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java index 0ee05429..b231465f 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -40,7 +40,7 @@ public class Behavior implements AbstractGameEventListener, Toggleable { */ @Override public final boolean toggle() { - return this.setEnabled(!this.enabled); + return this.setEnabled(!this.isEnabled()); } /** From 71473ab17d54965a5b0c576420c29550648d2ab5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:34:18 -0700 Subject: [PATCH 178/329] nit 2 --- src/api/java/baritone/api/behavior/Behavior.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java index b231465f..68ca580f 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -53,13 +53,11 @@ public class Behavior implements AbstractGameEventListener, Toggleable { if (enabled == this.enabled) { return this.enabled; } - if (this.enabled = enabled) { this.onEnable(); } else { this.onDisable(); } - return this.enabled; } From f25f264fd33d5263049b975ae23d76a2c5a29cbe Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:43:48 -0700 Subject: [PATCH 179/329] epicer default --- src/main/java/baritone/cache/ChunkPacker.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 042c37f4..2ed6d596 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -156,13 +156,11 @@ public final class ChunkPacker implements Helper { case -1: return Blocks.NETHERRACK.getDefaultState(); case 0: + default: // The fallback solid type return Blocks.STONE.getDefaultState(); case 1: return Blocks.END_STONE.getDefaultState(); } - - // The fallback solid type - return Blocks.STONE.getDefaultState(); default: return null; } From 3011b85aee5f9a0a44004eac443668b006337cf0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:50:07 -0700 Subject: [PATCH 180/329] add defaults to switches --- .../java/baritone/behavior/LookBehavior.java | 4 +- .../baritone/behavior/MemoryBehavior.java | 41 +++++++++---------- .../baritone/behavior/PathingBehavior.java | 5 ++- .../java/baritone/event/GameEventHandler.java | 16 +++----- .../movement/movements/MovementParkour.java | 3 +- 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index fa10d27d..53f8132f 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -19,9 +19,9 @@ package baritone.behavior; import baritone.Baritone; import baritone.Settings; +import baritone.api.behavior.Behavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; -import baritone.api.behavior.Behavior; import baritone.utils.Helper; import baritone.utils.Rotation; @@ -89,6 +89,8 @@ public final class LookBehavior extends Behavior implements Helper { } break; } + default: + break; } } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index ee89ebbf..4c73e33d 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -17,10 +17,10 @@ package baritone.behavior; +import baritone.api.behavior.Behavior; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; -import baritone.api.behavior.Behavior; import baritone.utils.Helper; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; @@ -94,31 +94,28 @@ public final class MemoryBehavior extends Behavior implements Helper { public void onReceivePacket(PacketEvent event) { Packet p = event.getPacket(); - switch (event.getState()) { - case PRE: { - if (p instanceof SPacketOpenWindow) { - SPacketOpenWindow packet = event.cast(); + if (event.getState() == EventState.PRE) { + if (p instanceof SPacketOpenWindow) { + SPacketOpenWindow packet = event.cast(); - // Remove any entries that were created over a second ago, this should make up for INSANE latency - this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000); + // Remove any entries that were created over a second ago, this should make up for INSANE latency + this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000); - this.futureInventories.stream() - .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) - .findFirst().ifPresent(matched -> { - // Remove the future inventory - this.futureInventories.remove(matched); + this.futureInventories.stream() + .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) + .findFirst().ifPresent(matched -> { + // Remove the future inventory + this.futureInventories.remove(matched); - // Setup the remembered inventory - RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); - inventory.windowId = packet.getWindowId(); - inventory.size = packet.getSlotCount(); - }); - } + // Setup the remembered inventory + RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory()); + inventory.windowId = packet.getWindowId(); + inventory.size = packet.getSlotCount(); + }); + } - if (p instanceof SPacketCloseWindow) { - updateInventory(); - } - break; + if (p instanceof SPacketCloseWindow) { + updateInventory(); } } } diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 6dee8b46..34358b5d 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -26,7 +26,8 @@ import baritone.api.event.events.TickEvent; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; -import baritone.pathing.goals.*; +import baritone.pathing.goals.Goal; +import baritone.pathing.goals.GoalXZ; import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; import baritone.pathing.path.PathExecutor; @@ -163,6 +164,8 @@ public final class PathingBehavior extends Behavior implements Helper { case POST: mc.gameSettings.autoJump = lastAutoJump; break; + default: + break; } } } diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 5d2c6558..7f29968d 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -21,11 +21,11 @@ import baritone.Baritone; import baritone.api.event.events.*; import baritone.api.event.events.type.EventState; import baritone.api.event.listener.IGameEventListener; +import baritone.api.utils.interfaces.Toggleable; import baritone.cache.WorldProvider; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.InputOverrideHandler; -import baritone.api.utils.interfaces.Toggleable; import net.minecraft.client.settings.KeyBinding; import net.minecraft.world.chunk.Chunk; import org.lwjgl.input.Keyboard; @@ -136,15 +136,11 @@ public final class GameEventHandler implements IGameEventListener, Helper { BlockStateInterface.clearCachedChunk(); - switch (event.getState()) { - case PRE: - break; - case POST: - cache.closeWorld(); - if (event.getWorld() != null) { - cache.initWorld(event.getWorld()); - } - break; + if (event.getState() == EventState.POST) { + cache.closeWorld(); + if (event.getWorld() != null) { + cache.initWorld(event.getWorld()); + } } listeners.forEach(l -> { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index ca116342..ab7a32cc 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -130,8 +130,9 @@ public class MovementParkour extends Movement { return WALK_ONE_BLOCK_COST * 3; case 4: return SPRINT_ONE_BLOCK_COST * 4; + default: + throw new IllegalStateException("LOL"); } - throw new IllegalStateException("LOL"); } From 0b640199efabb43353ff517d3bdbf1be1eabad0c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:56:33 -0700 Subject: [PATCH 181/329] add defaults to more switches --- .../java/baritone/behavior/LookBehavior.java | 3 +++ .../baritone/behavior/MemoryBehavior.java | 27 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 53f8132f..ef5b6b7d 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -92,6 +92,7 @@ public final class LookBehavior extends Behavior implements Helper { default: break; } + new Thread().start(); } @Override @@ -111,6 +112,8 @@ public final class LookBehavior extends Behavior implements Helper { this.target = null; } break; + default: + break; } } } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 4c73e33d..d8794a66 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -65,27 +65,24 @@ public final class MemoryBehavior extends Behavior implements Helper { public void onSendPacket(PacketEvent event) { Packet p = event.getPacket(); - switch (event.getState()) { - case PRE: { - if (p instanceof CPacketPlayerTryUseItemOnBlock) { - CPacketPlayerTryUseItemOnBlock packet = event.cast(); + if (event.getState() == EventState.PRE) { + if (p instanceof CPacketPlayerTryUseItemOnBlock) { + CPacketPlayerTryUseItemOnBlock packet = event.cast(); - TileEntity tileEntity = world().getTileEntity(packet.getPos()); + TileEntity tileEntity = world().getTileEntity(packet.getPos()); - // Ensure the TileEntity is a container of some sort - if (tileEntity instanceof TileEntityLockable) { + // Ensure the TileEntity is a container of some sort + if (tileEntity instanceof TileEntityLockable) { - TileEntityLockable lockable = (TileEntityLockable) tileEntity; - int size = lockable.getSizeInventory(); + TileEntityLockable lockable = (TileEntityLockable) tileEntity; + int size = lockable.getSizeInventory(); - this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), tileEntity.getPos())); - } + this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), tileEntity.getPos())); } + } - if (p instanceof CPacketCloseWindow) { - updateInventory(); - } - break; + if (p instanceof CPacketCloseWindow) { + updateInventory(); } } } From 74dc8d4118c41a651ab7fe737aa15808e5a460f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 19:58:44 -0700 Subject: [PATCH 182/329] unneeded --- src/main/java/baritone/utils/BlockStateInterface.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index bb4d094d..6db9a66e 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -39,10 +39,6 @@ public class BlockStateInterface implements Helper { private static CachedRegion prevCached = null; private static IBlockState AIR = Blocks.AIR.getDefaultState(); - public static final Block waterFlowing = Blocks.FLOWING_WATER; - public static final Block waterStill = Blocks.WATER; - public static final Block lavaFlowing = Blocks.FLOWING_LAVA; - public static final Block lavaStill = Blocks.LAVA; public static IBlockState get(BlockPos pos) { return get(pos.getX(), pos.getY(), pos.getZ()); @@ -111,7 +107,7 @@ public class BlockStateInterface implements Helper { * @return Whether or not the block is water */ public static boolean isWater(Block b) { - return b == waterFlowing || b == waterStill; + return b == Blocks.FLOWING_WATER || b == Blocks.WATER; } /** @@ -126,7 +122,7 @@ public class BlockStateInterface implements Helper { } public static boolean isLava(Block b) { - return b == lavaFlowing || b == lavaStill; + return b == Blocks.FLOWING_LAVA || b == Blocks.LAVA; } /** From a589cb0d9ec37dbdac7e790dba417b089a545d6e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 20:16:05 -0700 Subject: [PATCH 183/329] rearranged constructors --- src/main/java/baritone/behavior/FollowBehavior.java | 7 +++---- src/main/java/baritone/behavior/LookBehavior.java | 4 ++-- src/main/java/baritone/behavior/MemoryBehavior.java | 4 ++-- src/main/java/baritone/behavior/MineBehavior.java | 5 ++--- src/main/java/baritone/behavior/PathingBehavior.java | 6 ++---- .../java/baritone/pathing/calc/AStarPathFinder.java | 4 ++-- .../java/baritone/pathing/movement/Movement.java | 12 ++++++------ src/main/java/baritone/utils/BlockBreakHelper.java | 6 +++--- src/main/java/baritone/utils/PathRenderer.java | 7 +++---- 9 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 0a7fff6b..8eb51708 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -17,8 +17,8 @@ package baritone.behavior; -import baritone.api.event.events.TickEvent; import baritone.api.behavior.Behavior; +import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; @@ -32,11 +32,10 @@ public final class FollowBehavior extends Behavior { public static final FollowBehavior INSTANCE = new FollowBehavior(); - private FollowBehavior() { - } - private Entity following; + private FollowBehavior() {} + @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index ef5b6b7d..c577588f 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -29,8 +29,6 @@ public final class LookBehavior extends Behavior implements Helper { public static final LookBehavior INSTANCE = new LookBehavior(); - private LookBehavior() {} - /** * Target's values are as follows: *

@@ -51,6 +49,8 @@ public final class LookBehavior extends Behavior implements Helper { */ private float lastYaw; + private LookBehavior() {} + public void updateTarget(Rotation target, boolean force) { this.target = target; this.force = force || !Baritone.settings().freeLook.get(); diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index d8794a66..716dfaee 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -42,8 +42,6 @@ public final class MemoryBehavior extends Behavior implements Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); - private MemoryBehavior() {} - /** * Possible future inventories that we will be able to remember */ @@ -54,6 +52,8 @@ public final class MemoryBehavior extends Behavior implements Helper { */ private final Map rememberedInventories = new HashMap<>(); + private MemoryBehavior() {} + @Override public void onPlayerUpdate(PlayerUpdateEvent event) { if (event.getState() == EventState.PRE) { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 4c542c47..33a8e96d 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -49,12 +49,11 @@ public final class MineBehavior extends Behavior implements Helper { public static final MineBehavior INSTANCE = new MineBehavior(); - private MineBehavior() { - } - private List mining; private List locationsCache; + private MineBehavior() {} + @Override public void onTick(TickEvent event) { if (mining == null) { diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 34358b5d..8d962bd6 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -47,9 +47,6 @@ public final class PathingBehavior extends Behavior implements Helper { public static final PathingBehavior INSTANCE = new PathingBehavior(); - private PathingBehavior() { - } - private PathExecutor current; private PathExecutor next; @@ -62,6 +59,8 @@ public final class PathingBehavior extends Behavior implements Helper { private boolean lastAutoJump; + private PathingBehavior() {} + private void dispatchPathEvent(PathEvent event) { Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event)); } @@ -391,6 +390,5 @@ public final class PathingBehavior extends Behavior implements Helper { // if (end - start > 0) { // System.out.println("Frame took " + (split - start) + " " + (end - split)); //} - } } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 8868e1fe..4c47639e 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -50,6 +50,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { private final Optional> favoredPositions; + private final Random random = new Random(); + public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { super(start, goal); this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic @@ -250,8 +252,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { }; } - private final Random random = new Random(); - private void shuffle(T[] list) { int len = list.length; for (int i = 0; i < len; i++) { diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 4f31d1a0..7b1bce61 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -59,6 +59,12 @@ public abstract class Movement implements Helper, MovementHelper { private Double cost; + public List toBreakCached = null; + public List toPlaceCached = null; + public List toWalkIntoCached = null; + + private Boolean calculatedWhileLoaded; + protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) { this.src = src; this.dest = dest; @@ -290,8 +296,6 @@ public abstract class Movement implements Helper, MovementHelper { return getDest().subtract(getSrc()); } - private Boolean calculatedWhileLoaded; - public void checkLoadedChunk() { calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk); } @@ -300,10 +304,6 @@ public abstract class Movement implements Helper, MovementHelper { return calculatedWhileLoaded; } - public List toBreakCached = null; - public List toPlaceCached = null; - public List toWalkIntoCached = null; - public List toBreak() { if (toBreakCached != null) { return toBreakCached; diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 8c224a2b..b293f01e 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -26,15 +26,15 @@ import net.minecraft.util.math.BlockPos; * @since 8/25/2018 */ public final class BlockBreakHelper implements Helper { - - private BlockBreakHelper() {} - + /** * The last block that we tried to break, if this value changes * between attempts, then we re-initialize the breaking process. */ private static BlockPos lastBlock; + private BlockBreakHelper() {} + public static void tryBreakBlock(BlockPos pos, EnumFacing side) { if (!pos.equals(lastBlock)) { mc.playerController.clickBlock(pos, side); diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index ee9a585c..a05e89bf 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -49,13 +49,12 @@ import static org.lwjgl.opengl.GL11.*; * @since 8/9/2018 4:39 PM */ public final class PathRenderer implements Helper { - - private PathRenderer() { - } - + private static final Tessellator TESSELLATOR = Tessellator.getInstance(); private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer(); + private PathRenderer() {} + public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); From f36b11016ead93fe12ebab9cb1205e9724564adc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 20:19:41 -0700 Subject: [PATCH 184/329] codacy badge --- README.md | 2 +- src/main/java/baritone/utils/BlockBreakHelper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f280d18a..10e0c46c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Baritone -[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) +[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) A Minecraft bot. 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. diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index b293f01e..ef12fff2 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -26,7 +26,7 @@ import net.minecraft.util.math.BlockPos; * @since 8/25/2018 */ public final class BlockBreakHelper implements Helper { - + /** * The last block that we tried to break, if this value changes * between attempts, then we re-initialize the breaking process. From d2be54f138db91b6f3f9b9fd3a0287e84906c82e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 20:23:08 -0700 Subject: [PATCH 185/329] license badge --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10e0c46c..30754ed6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Baritone -[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) +[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) +[![License](https://img.shields.io/github/license/ImpactDevelopment/ClientAPI.svg)](LICENSE) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) A Minecraft bot. 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. From 583a5046ef241c26924134cc4f56bb4d987c408d Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 17 Sep 2018 12:17:42 -0500 Subject: [PATCH 186/329] Utilize the fact that all MovementState methods return "this" --- .../movement/movements/MovementDescend.java | 3 +-- .../movement/movements/MovementDownward.java | 3 +-- .../movement/movements/MovementFall.java | 3 +-- .../movement/movements/MovementPillar.java | 3 +-- .../movement/movements/MovementTraverse.java | 21 +++++++------------ 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index b033b6fc..99e6872b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -76,8 +76,7 @@ public class MovementDescend extends Movement { if (playerFeet.equals(dest)) { if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094) { // lilypads // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately - state.setStatus(MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementStatus.SUCCESS); } else { System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY())); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 48d26161..2ceb3c16 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -66,8 +66,7 @@ public class MovementDownward extends Movement { } if (playerFeet().equals(dest)) { - state.setStatus(MovementState.MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementState.MovementStatus.SUCCESS); } double diffX = player().posX - (dest.getX() + 0.5); double diffZ = player().posZ - (dest.getZ() + 0.5); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index e0356444..a82826eb 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -113,8 +113,7 @@ public class MovementFall extends Movement { Rotation targetRotation = null; if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) { if (!InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) || world().provider.isNether()) { - state.setStatus(MovementStatus.UNREACHABLE); - return state; + return state.setStatus(MovementStatus.UNREACHABLE); } if (player().posY - dest.getY() < mc.playerController.getBlockReachDistance()) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index db5bbf49..1885f48b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -160,8 +160,7 @@ public class MovementPillar extends Movement { } else { // Get ready to place a throwaway block if (!MovementHelper.throwaway(true)) { - state.setStatus(MovementState.MovementStatus.UNREACHABLE); - return state; + return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } numTicks++; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index f28f29fb..b0efeb79 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -180,9 +180,8 @@ public class MovementTraverse extends Movement { } if (isDoorActuallyBlockingUs) { if (!(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { - state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())), true)); - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - return state; + return state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())), true)) + .setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } } } @@ -196,9 +195,8 @@ public class MovementTraverse extends Movement { } if (blocked != null) { - state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(blocked, world())), true)); - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - return state; + return state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(blocked, world())), true)) + .setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } } @@ -214,8 +212,7 @@ public class MovementTraverse extends Movement { if (isTheBridgeBlockThere) { if (playerFeet().equals(dest)) { - state.setStatus(MovementState.MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementState.MovementStatus.SUCCESS); } if (wasTheBridgeBlockAlwaysThere && !BlockStateInterface.isLiquid(playerFeet())) { state.setInput(InputOverrideHandler.Input.SPRINT, true); @@ -248,9 +245,8 @@ public class MovementTraverse extends Movement { double dist = Math.max(Math.abs(dest.getX() + 0.5 - player().posX), Math.abs(dest.getZ() + 0.5 - player().posZ)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon MovementHelper.moveTowards(state, dest); - state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false); - state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); - return state; + return state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false) + .setInput(InputOverrideHandler.Input.MOVE_BACK, true); } } state.setInput(InputOverrideHandler.Input.MOVE_BACK, false); @@ -290,8 +286,7 @@ public class MovementTraverse extends Movement { state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true); if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), goalLook)) { - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); // wait to right click until we are able to place - return state; + return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); // wait to right click until we are able to place } // Out.log("Trying to look at " + goalLook + ", actually looking at" + Baritone.whatAreYouLookingAt()); return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); From b3654492beeff3e49dfa09fb40558ec3cc39a4f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 10:36:39 -0700 Subject: [PATCH 187/329] follow offset distance and direction --- src/main/java/baritone/Settings.java | 17 +++++++++++++++++ .../java/baritone/behavior/FollowBehavior.java | 8 ++++++-- .../baritone/utils/ExampleBaritoneControl.java | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index d9c2ff40..a3fb2b4f 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -358,6 +358,23 @@ public class Settings { */ public Setting internalMiningAirException = new Setting<>(true); + /** + * The actual GoalNear is set this distance away from the entity you're following + *

+ * For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target. + */ + public Setting followOffsetDistance = new Setting<>(0D); + + /** + * The actual GoalNear is set in this direction from the entity you're following + */ + public Setting followOffsetDirection = new Setting<>(0F); + + /** + * The radius (for the GoalNear) of how close to your target position you actually have to be + */ + public Setting followRadius = new Setting<>(3); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 8eb51708..0dd9893d 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -17,9 +17,12 @@ package baritone.behavior; +import baritone.Baritone; import baritone.api.behavior.Behavior; import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; +import baritone.pathing.goals.GoalXZ; +import baritone.utils.Helper; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; @@ -28,7 +31,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public final class FollowBehavior extends Behavior { +public final class FollowBehavior extends Behavior implements Helper { public static final FollowBehavior INSTANCE = new FollowBehavior(); @@ -45,7 +48,8 @@ public final class FollowBehavior extends Behavior { return; } // lol this is trashy but it works - PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(following), 3)); + GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); + PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(g.getX(), following.posY, g.getZ()), Baritone.settings().followRadius.get())); PathingBehavior.INSTANCE.path(); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 98964315..016b44f5 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -400,6 +400,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper { if (setting.value.getClass() == Double.class) { setting.value = Double.parseDouble(data[1]); } + if (setting.value.getClass() == Float.class) { + setting.value = Float.parseFloat(data[1]); + } } catch (NumberFormatException e) { logDirect("Unable to parse " + data[1]); event.cancel(); From 043dd80e285fde5dd2c76b1defcef2fd9e2c72d2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 10:38:37 -0700 Subject: [PATCH 188/329] higher priority --- .../utils/ExampleBaritoneControl.java | 104 +++++++++--------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 016b44f5..a3301cd2 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -69,6 +69,59 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } msg = msg.substring(1); } + + List> toggleable = Baritone.settings().getAllValuesByType(Boolean.class); + for (Settings.Setting setting : toggleable) { + if (msg.equalsIgnoreCase(setting.getName())) { + setting.value ^= true; + event.cancel(); + logDirect("Toggled " + setting.getName() + " to " + setting.value); + return; + } + } + if (msg.equals("baritone") || msg.equals("settings")) { + for (Settings.Setting setting : Baritone.settings().allSettings) { + logDirect(setting.toString()); + } + event.cancel(); + return; + } + if (msg.contains(" ")) { + String[] data = msg.split(" "); + if (data.length == 2) { + Settings.Setting setting = Baritone.settings().byLowerName.get(data[0]); + if (setting != null) { + try { + if (setting.value.getClass() == Long.class) { + setting.value = Long.parseLong(data[1]); + } + if (setting.value.getClass() == Integer.class) { + setting.value = Integer.parseInt(data[1]); + } + if (setting.value.getClass() == Double.class) { + setting.value = Double.parseDouble(data[1]); + } + if (setting.value.getClass() == Float.class) { + setting.value = Float.parseFloat(data[1]); + } + } catch (NumberFormatException e) { + logDirect("Unable to parse " + data[1]); + event.cancel(); + return; + } + logDirect(setting.toString()); + event.cancel(); + return; + } + } + } + if (Baritone.settings().byLowerName.containsKey(msg)) { + Settings.Setting setting = Baritone.settings().byLowerName.get(msg); + logDirect(setting.toString()); + event.cancel(); + return; + } + if (msg.startsWith("goal")) { event.cancel(); String[] params = msg.substring(4).trim().split(" "); @@ -369,56 +422,5 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - List> toggleable = Baritone.settings().getAllValuesByType(Boolean.class); - for (Settings.Setting setting : toggleable) { - if (msg.equalsIgnoreCase(setting.getName())) { - setting.value ^= true; - event.cancel(); - logDirect("Toggled " + setting.getName() + " to " + setting.value); - return; - } - } - if (msg.equals("baritone") || msg.equals("settings")) { - for (Settings.Setting setting : Baritone.settings().allSettings) { - logDirect(setting.toString()); - } - event.cancel(); - return; - } - if (msg.contains(" ")) { - String[] data = msg.split(" "); - if (data.length == 2) { - Settings.Setting setting = Baritone.settings().byLowerName.get(data[0]); - if (setting != null) { - try { - if (setting.value.getClass() == Long.class) { - setting.value = Long.parseLong(data[1]); - } - if (setting.value.getClass() == Integer.class) { - setting.value = Integer.parseInt(data[1]); - } - if (setting.value.getClass() == Double.class) { - setting.value = Double.parseDouble(data[1]); - } - if (setting.value.getClass() == Float.class) { - setting.value = Float.parseFloat(data[1]); - } - } catch (NumberFormatException e) { - logDirect("Unable to parse " + data[1]); - event.cancel(); - return; - } - logDirect(setting.toString()); - event.cancel(); - return; - } - } - } - if (Baritone.settings().byLowerName.containsKey(msg)) { - Settings.Setting setting = Baritone.settings().byLowerName.get(msg); - logDirect(setting.toString()); - event.cancel(); - return; - } } } From e981bfa34668cba88a7a9c25070f04b698ff40ce Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 10:56:37 -0700 Subject: [PATCH 189/329] follow player by name --- .../baritone/behavior/FollowBehavior.java | 1 + .../java/baritone/behavior/MineBehavior.java | 25 ++++-------------- .../baritone/behavior/PathingBehavior.java | 16 ++++++++++++ .../utils/ExampleBaritoneControl.java | 26 ++++++++++++++----- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 0dd9893d..2ef25c1a 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -50,6 +50,7 @@ public final class FollowBehavior extends Behavior implements Helper { // lol this is trashy but it works GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(g.getX(), following.posY, g.getZ()), Baritone.settings().followRadius.get())); + PathingBehavior.INSTANCE.revalidateGoal(); PathingBehavior.INSTANCE.path(); } diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 33a8e96d..8b6fa2a1 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -29,7 +29,6 @@ import baritone.pathing.goals.Goal; import baritone.pathing.goals.GoalBlock; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; -import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; @@ -37,7 +36,10 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; import java.util.stream.Collectors; /** @@ -65,24 +67,7 @@ public final class MineBehavior extends Behavior implements Helper { updateGoal(); } } - if (!Baritone.settings().cancelOnGoalInvalidation.get()) { - return; - } - Optional path = PathingBehavior.INSTANCE.getPath(); - if (!path.isPresent()) { - return; - } - Goal currentGoal = PathingBehavior.INSTANCE.getGoal(); - if (currentGoal == null) { - return; - } - Goal intended = path.get().getGoal(); - BlockPos end = path.get().getDest(); - if (intended.isInGoal(end) && !currentGoal.isInGoal(end)) { - // this path used to end in the goal - // but the goal has changed, so there's no reason to continue... - PathingBehavior.INSTANCE.cancel(); - } + PathingBehavior.INSTANCE.revalidateGoal(); } @Override diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 8d962bd6..3037c4e7 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -338,6 +338,22 @@ public final class PathingBehavior extends Behavior implements Helper { } } + public void revalidateGoal() { + if (!Baritone.settings().cancelOnGoalInvalidation.get()) { + return; + } + if (current == null || goal == null) { + return; + } + Goal intended = current.getPath().getGoal(); + BlockPos end = current.getPath().getDest(); + if (intended.isInGoal(end) && !goal.isInGoal(end)) { + // this path used to end in the goal + // but the goal has changed, so there's no reason to continue... + cancel(); + } + } + @Override public void onRenderPass(RenderEvent event) { // System.out.println("Render passing"); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index a3301cd2..7bbd8c82 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -38,6 +38,7 @@ import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; @@ -236,15 +237,28 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.equals("follow")) { - Optional entity = MovementHelper.whatEntityAmILookingAt(); - if (!entity.isPresent()) { - logDirect("You aren't looking at an entity bruh"); + if (msg.startsWith("follow")) { + String name = msg.substring(6).trim(); + Optional toFollow = Optional.empty(); + if (name.length() == 0) { + toFollow = MovementHelper.whatEntityAmILookingAt(); + } else { + for (EntityPlayer pl : world().playerEntities) { + String theirName = pl.getName().trim().toLowerCase(); + if (!theirName.equals(player().getName().trim().toLowerCase())) { // don't follow ourselves lol + if (theirName.contains(name) || name.contains(theirName)) { + toFollow = Optional.of(pl); + } + } + } + } + if (!toFollow.isPresent()) { + logDirect("Not found"); event.cancel(); return; } - FollowBehavior.INSTANCE.follow(entity.get()); - logDirect("Following " + entity.get()); + FollowBehavior.INSTANCE.follow(toFollow.get()); + logDirect("Following " + toFollow.get()); event.cancel(); return; } From 42e179c4ce43eed4a138dd4a6d46693fe6940ac3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 13:44:27 -0700 Subject: [PATCH 190/329] loL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30754ed6..577a6418 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Baritone [![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) -[![License](https://img.shields.io/github/license/ImpactDevelopment/ClientAPI.svg)](LICENSE) +[![License](https://img.shields.io/github/license/cabaletta/baritone.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) A Minecraft bot. This project is an updated version of [Minebot](https://github.com/leijurv/MineBot/), From 71952410eb072a8dea888b7391de832d472e8b52 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 14:22:45 -0700 Subject: [PATCH 191/329] mine quantity --- .../java/baritone/behavior/MineBehavior.java | 25 ++++++++++++++----- .../utils/ExampleBaritoneControl.java | 11 +++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 8b6fa2a1..115232b6 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -33,13 +33,12 @@ import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -53,6 +52,7 @@ public final class MineBehavior extends Behavior implements Helper { private List mining; private List locationsCache; + private int quantity; private MineBehavior() {} @@ -61,6 +61,16 @@ public final class MineBehavior extends Behavior implements Helper { if (mining == null) { return; } + if (quantity > 0) { + Item item = mining.get(0).getItemDropped(mining.get(0).getDefaultState(), new Random(), 0); + int curr = player().inventory.mainInventory.stream().filter(stack -> item.equals(stack.getItem())).mapToInt(ItemStack::getCount).sum(); + System.out.println("Currently have " + curr + " " + item); + if (curr >= quantity) { + logDirect("Have " + curr + " " + item.getItemStackDisplayName(new ItemStack(item, 1))); + cancel(); + return; + } + } int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); if (mineGoalUpdateInterval != 0) { if (event.getCount() % mineGoalUpdateInterval == 0) { @@ -93,6 +103,8 @@ public final class MineBehavior extends Behavior implements Helper { locationsCache = locs; PathingBehavior.INSTANCE.setGoal(coalesce(locs)); PathingBehavior.INSTANCE.path(); + + Blocks.DIAMOND_ORE.getItemDropped(Blocks.DIAMOND_ORE.getDefaultState(), new Random(), 0); } public static GoalComposite coalesce(List locs) { @@ -157,8 +169,9 @@ public final class MineBehavior extends Behavior implements Helper { return locs; } - public void mine(String... blocks) { + public void mine(int quantity, String... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList()); + this.quantity = quantity; this.locationsCache = new ArrayList<>(); updateGoal(); } @@ -170,7 +183,7 @@ public final class MineBehavior extends Behavior implements Helper { } public void cancel() { - mine((String[]) null); + mine(0, (String[]) null); PathingBehavior.INSTANCE.cancel(); } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 7bbd8c82..47660631 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -289,14 +289,23 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } if (msg.startsWith("mine")) { String[] blockTypes = msg.substring(4).trim().split(" "); + try { + int quantity = Integer.parseInt(blockTypes[1]); + ChunkPacker.stringToBlock(blockTypes[0]).hashCode(); + MineBehavior.INSTANCE.mine(quantity, blockTypes[0]); + logDirect("Will mine " + quantity + " " + blockTypes[0]); + event.cancel(); + return; + } catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {} for (String s : blockTypes) { if (ChunkPacker.stringToBlock(s) == null) { logDirect(s + " isn't a valid block name"); event.cancel(); return; } + } - MineBehavior.INSTANCE.mine(blockTypes); + MineBehavior.INSTANCE.mine(0, blockTypes); logDirect("Started mining blocks of type " + Arrays.toString(blockTypes)); event.cancel(); return; From bfdf8d6c8759be25abc1517ef8bd8023f02dc892 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 14:33:14 -0700 Subject: [PATCH 192/329] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 577a6418..edd68950 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,15 @@ [![License](https://img.shields.io/github/license/cabaletta/baritone.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) -A Minecraft bot. This project is an updated version of [Minebot](https://github.com/leijurv/MineBot/), +A Minecraft pathfinder bot. 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. Features Baritone + Impact +Unofficial Jenkins: [![Build Status](http://24.202.239.85:8080/job/baritone/badge/icon)](http://24.202.239.85:8080/job/baritone/lastSuccessfulBuild/) + # Setup ## IntelliJ's Gradle UI From 6b61a00bedaac2704980f1971b4285d2ad2080cb Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 17 Sep 2018 17:11:40 -0500 Subject: [PATCH 193/329] Change License to GNU Lesser General Public License v3 --- .idea/copyright/Baritone.xml | 2 +- LICENSE | 165 +++++ LICENSE.txt | 674 ------------------ build.gradle | 6 +- settings.gradle | 6 +- .../java/baritone/api/behavior/Behavior.java | 6 +- .../api/event/events/BlockInteractEvent.java | 6 +- .../baritone/api/event/events/ChatEvent.java | 6 +- .../baritone/api/event/events/ChunkEvent.java | 6 +- .../api/event/events/PacketEvent.java | 6 +- .../baritone/api/event/events/PathEvent.java | 6 +- .../api/event/events/PlayerUpdateEvent.java | 6 +- .../api/event/events/RenderEvent.java | 6 +- .../api/event/events/RotationMoveEvent.java | 6 +- .../baritone/api/event/events/TickEvent.java | 6 +- .../baritone/api/event/events/WorldEvent.java | 6 +- .../api/event/events/type/Cancellable.java | 6 +- .../api/event/events/type/EventState.java | 6 +- .../listener/AbstractGameEventListener.java | 23 +- .../event/listener/IGameEventListener.java | 23 +- .../api/utils/interfaces/Toggleable.java | 6 +- .../java/baritone/launch/BaritoneTweaker.java | 6 +- .../baritone/launch/BaritoneTweakerForge.java | 6 +- .../launch/BaritoneTweakerOptifine.java | 6 +- .../launch/mixins/MixinAnvilChunkLoader.java | 23 +- .../baritone/launch/mixins/MixinBlockPos.java | 6 +- .../mixins/MixinChunkProviderServer.java | 23 +- .../baritone/launch/mixins/MixinEntity.java | 6 +- .../launch/mixins/MixinEntityLivingBase.java | 6 +- .../launch/mixins/MixinEntityPlayerSP.java | 6 +- .../launch/mixins/MixinEntityRenderer.java | 6 +- .../launch/mixins/MixinKeyBinding.java | 6 +- .../launch/mixins/MixinMinecraft.java | 6 +- .../mixins/MixinNetHandlerPlayClient.java | 6 +- .../launch/mixins/MixinNetworkManager.java | 6 +- .../launch/mixins/MixinWorldClient.java | 6 +- src/main/java/baritone/Baritone.java | 6 +- src/main/java/baritone/Settings.java | 6 +- .../baritone/behavior/FollowBehavior.java | 6 +- .../behavior/LocationTrackingBehavior.java | 6 +- .../java/baritone/behavior/LookBehavior.java | 6 +- .../baritone/behavior/LookBehaviorUtils.java | 6 +- .../baritone/behavior/MemoryBehavior.java | 6 +- .../java/baritone/behavior/MineBehavior.java | 6 +- .../baritone/behavior/PathingBehavior.java | 6 +- src/main/java/baritone/cache/CachedChunk.java | 6 +- .../java/baritone/cache/CachedRegion.java | 6 +- src/main/java/baritone/cache/CachedWorld.java | 6 +- src/main/java/baritone/cache/ChunkPacker.java | 6 +- src/main/java/baritone/cache/Waypoint.java | 6 +- src/main/java/baritone/cache/Waypoints.java | 6 +- src/main/java/baritone/cache/WorldData.java | 6 +- .../java/baritone/cache/WorldProvider.java | 6 +- .../java/baritone/cache/WorldScanner.java | 6 +- .../java/baritone/event/GameEventHandler.java | 6 +- .../pathing/calc/AStarPathFinder.java | 6 +- .../pathing/calc/AbstractNodeCostSearch.java | 6 +- .../baritone/pathing/calc/IPathFinder.java | 6 +- src/main/java/baritone/pathing/calc/Path.java | 6 +- .../java/baritone/pathing/calc/PathNode.java | 6 +- .../calc/openset/BinaryHeapOpenSet.java | 6 +- .../pathing/calc/openset/IOpenSet.java | 6 +- .../calc/openset/LinkedListOpenSet.java | 6 +- .../java/baritone/pathing/goals/Goal.java | 6 +- .../java/baritone/pathing/goals/GoalAxis.java | 6 +- .../baritone/pathing/goals/GoalBlock.java | 6 +- .../baritone/pathing/goals/GoalComposite.java | 6 +- .../pathing/goals/GoalGetToBlock.java | 6 +- .../java/baritone/pathing/goals/GoalNear.java | 6 +- .../baritone/pathing/goals/GoalRunAway.java | 6 +- .../baritone/pathing/goals/GoalTwoBlocks.java | 6 +- .../java/baritone/pathing/goals/GoalXZ.java | 6 +- .../baritone/pathing/goals/GoalYLevel.java | 6 +- .../pathing/movement/ActionCosts.java | 6 +- ...ButOnlyTheOnesThatMakeMickeyDieInside.java | 6 +- .../pathing/movement/CalculationContext.java | 6 +- .../baritone/pathing/movement/Movement.java | 6 +- .../pathing/movement/MovementHelper.java | 6 +- .../pathing/movement/MovementState.java | 6 +- .../movement/movements/MovementAscend.java | 6 +- .../movement/movements/MovementDescend.java | 6 +- .../movement/movements/MovementDiagonal.java | 6 +- .../movement/movements/MovementDownward.java | 6 +- .../movement/movements/MovementFall.java | 6 +- .../movement/movements/MovementParkour.java | 6 +- .../movement/movements/MovementPillar.java | 6 +- .../movement/movements/MovementTraverse.java | 6 +- .../baritone/pathing/path/CutoffPath.java | 6 +- .../java/baritone/pathing/path/IPath.java | 6 +- .../baritone/pathing/path/PathExecutor.java | 6 +- .../java/baritone/utils/BlockBreakHelper.java | 6 +- .../baritone/utils/BlockStateInterface.java | 6 +- .../utils/ExampleBaritoneControl.java | 6 +- src/main/java/baritone/utils/Helper.java | 6 +- .../baritone/utils/InputOverrideHandler.java | 23 +- .../java/baritone/utils/PathRenderer.java | 6 +- .../java/baritone/utils/RayTraceUtils.java | 6 +- src/main/java/baritone/utils/Rotation.java | 6 +- src/main/java/baritone/utils/ToolSet.java | 6 +- src/main/java/baritone/utils/Utils.java | 6 +- .../utils/accessor/IAnvilChunkLoader.java | 6 +- .../utils/accessor/IChunkProviderServer.java | 6 +- .../utils/interfaces/IGoalRenderPos.java | 6 +- .../utils/pathing/BetterBlockPos.java | 6 +- .../utils/pathing/IBlockTypeAccess.java | 6 +- .../utils/pathing/PathingBlockType.java | 6 +- .../java/baritone/cache/CachedRegionTest.java | 6 +- .../pathing/calc/openset/OpenSetsTest.java | 6 +- .../pathing/goals/GoalGetToBlockTest.java | 6 +- ...nlyTheOnesThatMakeMickeyDieInsideTest.java | 6 +- .../utils/pathing/BetterBlockPosTest.java | 6 +- 111 files changed, 490 insertions(+), 1084 deletions(-) create mode 100644 LICENSE delete mode 100644 LICENSE.txt diff --git a/.idea/copyright/Baritone.xml b/.idea/copyright/Baritone.xml index aaaf59bb..77f2d5b1 100644 --- a/.idea/copyright/Baritone.xml +++ b/.idea/copyright/Baritone.xml @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..153d416d --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index da125cc9..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Baritone Copyright (C) 2018 Cabaletta - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/build.gradle b/build.gradle index 1ab9fe8d..1b31aae8 100755 --- a/build.gradle +++ b/build.gradle @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/settings.gradle b/settings.gradle index c627d750..baa9dfc9 100755 --- a/settings.gradle +++ b/settings.gradle @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java index 68ca580f..872ce1bd 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/BlockInteractEvent.java b/src/api/java/baritone/api/event/events/BlockInteractEvent.java index 2c57952c..cc98a6ba 100644 --- a/src/api/java/baritone/api/event/events/BlockInteractEvent.java +++ b/src/api/java/baritone/api/event/events/BlockInteractEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/ChatEvent.java b/src/api/java/baritone/api/event/events/ChatEvent.java index 87a81e70..e103377f 100644 --- a/src/api/java/baritone/api/event/events/ChatEvent.java +++ b/src/api/java/baritone/api/event/events/ChatEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/ChunkEvent.java b/src/api/java/baritone/api/event/events/ChunkEvent.java index 1f8c6c39..5c22d830 100644 --- a/src/api/java/baritone/api/event/events/ChunkEvent.java +++ b/src/api/java/baritone/api/event/events/ChunkEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/PacketEvent.java b/src/api/java/baritone/api/event/events/PacketEvent.java index 77310994..9516db4b 100644 --- a/src/api/java/baritone/api/event/events/PacketEvent.java +++ b/src/api/java/baritone/api/event/events/PacketEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/PathEvent.java b/src/api/java/baritone/api/event/events/PathEvent.java index c134ba96..0eef0665 100644 --- a/src/api/java/baritone/api/event/events/PathEvent.java +++ b/src/api/java/baritone/api/event/events/PathEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java b/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java index 59bdf702..6ac08bdd 100644 --- a/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java +++ b/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/RenderEvent.java b/src/api/java/baritone/api/event/events/RenderEvent.java index ef693e2a..b5a77276 100644 --- a/src/api/java/baritone/api/event/events/RenderEvent.java +++ b/src/api/java/baritone/api/event/events/RenderEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java index 7bedf857..ef6d9b7e 100644 --- a/src/api/java/baritone/api/event/events/RotationMoveEvent.java +++ b/src/api/java/baritone/api/event/events/RotationMoveEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/TickEvent.java b/src/api/java/baritone/api/event/events/TickEvent.java index c765daa9..da8f8878 100644 --- a/src/api/java/baritone/api/event/events/TickEvent.java +++ b/src/api/java/baritone/api/event/events/TickEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/WorldEvent.java b/src/api/java/baritone/api/event/events/WorldEvent.java index 454755fe..c7c7e102 100644 --- a/src/api/java/baritone/api/event/events/WorldEvent.java +++ b/src/api/java/baritone/api/event/events/WorldEvent.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/type/Cancellable.java b/src/api/java/baritone/api/event/events/type/Cancellable.java index 4c26f8f8..331870c6 100644 --- a/src/api/java/baritone/api/event/events/type/Cancellable.java +++ b/src/api/java/baritone/api/event/events/type/Cancellable.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/events/type/EventState.java b/src/api/java/baritone/api/event/events/type/EventState.java index bba516a6..10b633bd 100644 --- a/src/api/java/baritone/api/event/events/type/EventState.java +++ b/src/api/java/baritone/api/event/events/type/EventState.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java index 5839e6d5..6af8e402 100644 --- a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java @@ -2,33 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java index 9587376a..b1dda0de 100644 --- a/src/api/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/IGameEventListener.java @@ -2,33 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/api/java/baritone/api/utils/interfaces/Toggleable.java b/src/api/java/baritone/api/utils/interfaces/Toggleable.java index bf43220a..359d6ee1 100644 --- a/src/api/java/baritone/api/utils/interfaces/Toggleable.java +++ b/src/api/java/baritone/api/utils/interfaces/Toggleable.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java index 9638214c..536ecf95 100644 --- a/src/launch/java/baritone/launch/BaritoneTweaker.java +++ b/src/launch/java/baritone/launch/BaritoneTweaker.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/BaritoneTweakerForge.java b/src/launch/java/baritone/launch/BaritoneTweakerForge.java index c1699058..7623eed5 100644 --- a/src/launch/java/baritone/launch/BaritoneTweakerForge.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerForge.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java index 8d0872aa..9f4f8380 100644 --- a/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java index 3133c9cd..4ffb5abc 100644 --- a/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java +++ b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java @@ -2,33 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinBlockPos.java b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java index 49e01c96..013980a9 100644 --- a/src/launch/java/baritone/launch/mixins/MixinBlockPos.java +++ b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java index 41f90481..246c368e 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java @@ -2,33 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java index 22be4154..b96b5b41 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java index 61f6db7a..e840576e 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 9a45659e..e9a575c5 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java b/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java index 55adfc83..0fc1b246 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 4285c14d..c776d228 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 2bcc54b9..d5d41f44 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java index bd4cbb97..498b5aff 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index d1e6a2d5..f79e007f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/launch/java/baritone/launch/mixins/MixinWorldClient.java b/src/launch/java/baritone/launch/mixins/MixinWorldClient.java index 005dbe16..322239b7 100644 --- a/src/launch/java/baritone/launch/mixins/MixinWorldClient.java +++ b/src/launch/java/baritone/launch/mixins/MixinWorldClient.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 0d89b730..06bf365a 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index a3fb2b4f..286c06e7 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 2ef25c1a..a9a829c3 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/LocationTrackingBehavior.java index cf41543c..e48e482e 100644 --- a/src/main/java/baritone/behavior/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/LocationTrackingBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index c577588f..d45ad585 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java index bbab90bf..ed7f730e 100644 --- a/src/main/java/baritone/behavior/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 716dfaee..c850c8e5 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 115232b6..71674363 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 3037c4e7..98653b24 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 6705ffa5..fbdd42f7 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 1805f5ea..f036f264 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index f866989a..91a70d48 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 2ed6d596..1df1e9c0 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/Waypoint.java b/src/main/java/baritone/cache/Waypoint.java index a8f162a5..4fd6c57a 100644 --- a/src/main/java/baritone/cache/Waypoint.java +++ b/src/main/java/baritone/cache/Waypoint.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/Waypoints.java b/src/main/java/baritone/cache/Waypoints.java index 82cf893f..be76e34e 100644 --- a/src/main/java/baritone/cache/Waypoints.java +++ b/src/main/java/baritone/cache/Waypoints.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index 6637d7b1..7866e9e8 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 0275301d..2cd0b6dc 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 76118093..bd2690a6 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 7f29968d..934dd532 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 4c47639e..f8b6eeb6 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 6e8220e1..4a8fe752 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/IPathFinder.java b/src/main/java/baritone/pathing/calc/IPathFinder.java index dceee65d..3723865d 100644 --- a/src/main/java/baritone/pathing/calc/IPathFinder.java +++ b/src/main/java/baritone/pathing/calc/IPathFinder.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 1910927c..e94f2fb3 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 3d984548..8f9895d8 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java b/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java index 47d370c6..6758a30a 100644 --- a/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/openset/IOpenSet.java b/src/main/java/baritone/pathing/calc/openset/IOpenSet.java index e43664c8..4d362139 100644 --- a/src/main/java/baritone/pathing/calc/openset/IOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/IOpenSet.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java index e06a9850..6de8290d 100644 --- a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/Goal.java b/src/main/java/baritone/pathing/goals/Goal.java index 4057a733..7f44d3d5 100644 --- a/src/main/java/baritone/pathing/goals/Goal.java +++ b/src/main/java/baritone/pathing/goals/Goal.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalAxis.java b/src/main/java/baritone/pathing/goals/GoalAxis.java index 9e6dc697..bd8f7c69 100644 --- a/src/main/java/baritone/pathing/goals/GoalAxis.java +++ b/src/main/java/baritone/pathing/goals/GoalAxis.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index b85f468a..82515758 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalComposite.java b/src/main/java/baritone/pathing/goals/GoalComposite.java index bd1e0905..12de4d93 100644 --- a/src/main/java/baritone/pathing/goals/GoalComposite.java +++ b/src/main/java/baritone/pathing/goals/GoalComposite.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index cefed91a..5acca96c 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 1b214c10..11c6cd3f 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/main/java/baritone/pathing/goals/GoalRunAway.java index 15cd2489..0ad49faf 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/main/java/baritone/pathing/goals/GoalRunAway.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index edc70483..44a33425 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index 7b876665..3362149c 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/main/java/baritone/pathing/goals/GoalYLevel.java index 97d63311..f90161d2 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/main/java/baritone/pathing/goals/GoalYLevel.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/ActionCosts.java b/src/main/java/baritone/pathing/movement/ActionCosts.java index 3be99c9f..cbfcd810 100644 --- a/src/main/java/baritone/pathing/movement/ActionCosts.java +++ b/src/main/java/baritone/pathing/movement/ActionCosts.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java b/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java index e955c41e..fe589d6f 100644 --- a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java +++ b/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index bd05ec5e..3149cfe9 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 7b1bce61..3e0a2f62 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1d7ca673..27b1b57e 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/MovementState.java b/src/main/java/baritone/pathing/movement/MovementState.java index 057d22bb..0017c438 100644 --- a/src/main/java/baritone/pathing/movement/MovementState.java +++ b/src/main/java/baritone/pathing/movement/MovementState.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index b802b53a..6f666a71 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 99e6872b..27a3c96d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 121ea7c7..58ba2ae2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 2ceb3c16..aa5df237 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index a82826eb..5e2556fe 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index ab7a32cc..d113fa0f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 1885f48b..99b3aa50 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index b0efeb79..05f73e58 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/path/CutoffPath.java b/src/main/java/baritone/pathing/path/CutoffPath.java index d55d8652..295f3830 100644 --- a/src/main/java/baritone/pathing/path/CutoffPath.java +++ b/src/main/java/baritone/pathing/path/CutoffPath.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index f007f899..59cb8cac 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 02435502..815d6d1b 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index ef12fff2..3ccc56f9 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 6db9a66e..6e0c7297 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 47660631..b6ef2a45 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index 0b729014..d808e632 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index eba6b9c0..9cf7d1da 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -2,33 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index a05e89bf..86f49e5e 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java index 02ae52df..d859ae4c 100644 --- a/src/main/java/baritone/utils/RayTraceUtils.java +++ b/src/main/java/baritone/utils/RayTraceUtils.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/Rotation.java b/src/main/java/baritone/utils/Rotation.java index 762d9cab..ce92d009 100644 --- a/src/main/java/baritone/utils/Rotation.java +++ b/src/main/java/baritone/utils/Rotation.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 1415d9e2..62115f24 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 4aedce6a..8a63347a 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java b/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java index 900e3fb4..c243ae0e 100644 --- a/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java +++ b/src/main/java/baritone/utils/accessor/IAnvilChunkLoader.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/accessor/IChunkProviderServer.java b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java index bb3dcb5e..78a471b2 100644 --- a/src/main/java/baritone/utils/accessor/IChunkProviderServer.java +++ b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java index 0aed1ea4..aa4ffa78 100644 --- a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java +++ b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index f908dd78..e46b27dc 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java b/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java index 2bd29cfd..4e34596a 100644 --- a/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java +++ b/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/main/java/baritone/utils/pathing/PathingBlockType.java b/src/main/java/baritone/utils/pathing/PathingBlockType.java index 61dbf2fc..80c92dcb 100644 --- a/src/main/java/baritone/utils/pathing/PathingBlockType.java +++ b/src/main/java/baritone/utils/pathing/PathingBlockType.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/test/java/baritone/cache/CachedRegionTest.java b/src/test/java/baritone/cache/CachedRegionTest.java index dc595e2e..19874990 100644 --- a/src/test/java/baritone/cache/CachedRegionTest.java +++ b/src/test/java/baritone/cache/CachedRegionTest.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 5ab10d24..aebff976 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java index a908a8dd..2fa7f954 100644 --- a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java +++ b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java index 50ba6245..15291bbe 100644 --- a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java +++ b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index ff54579b..2f0ab688 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -2,16 +2,16 @@ * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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 General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License + * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ From 63a1083e1970db5c5c75c26940ad154dea14e424 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 17 Sep 2018 17:46:23 -0500 Subject: [PATCH 194/329] Let's talk about doors --- .../java/baritone/pathing/movement/MovementHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 27b1b57e..1a442fa6 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -81,10 +81,10 @@ public interface MovementHelper extends ActionCosts, Helper { return false; } if (block instanceof BlockDoor || block instanceof BlockFenceGate) { - if (block == Blocks.IRON_DOOR) { - return false; - } - return true; // we can just open the door + // Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume + // that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't + // be opened by just interacting. + return block != Blocks.IRON_DOOR; } if (block instanceof BlockSnow || block instanceof BlockTrapDoor) { // we've already checked doors From 66e6216b71a372deba7a397e69a022500aadeb7e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 16:11:54 -0700 Subject: [PATCH 195/329] l --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index edd68950..18031bdd 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ PathingBehavior.INSTANCE.path(); ## Can I use Baritone as a library in my hacked client? -Sure! (As long as usage is in compliance with the GPL 3 License) +Sure! (As long as usage is in compliance with the LGPL 3 License) ## How is it so fast? From dc5514b5b7bc23c0539bdd21393bb8db046aa79e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 16:15:21 -0700 Subject: [PATCH 196/329] update prebuilt jar --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 369dc664..cec0ed1a 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -2,7 +2,7 @@ Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. -You can either build Baritone yourself, or download the "official" jar (as of commit 7d0914b, built on September 13) from here. If you really want the cutting edge latest release, and you trust @Plutie#9079, commits are automatically built on their Jenkins here. +You can either build Baritone yourself, or download the "official" jar (as of commit 66e6216, built on September 17) from here. If you really want the cutting edge latest release, and you trust @Plutie#9079, commits are automatically built on their Jenkins here. To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. From f13bcbd49f16e0f29d93f89a2267e1bc2280c93c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Sep 2018 20:25:52 -0700 Subject: [PATCH 197/329] no more flowing water --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1a442fa6..0ac4d7d8 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -432,7 +432,7 @@ public interface MovementHelper extends ActionCosts, Helper { break; } IBlockState ontoBlock = BlockStateInterface.get(onto); - if (BlockStateInterface.isWater(ontoBlock.getBlock())) { + if (ontoBlock.getBlock() == Blocks.WATER) { return new MovementFall(pos, onto); } if (canWalkThrough(onto, ontoBlock)) { From b47b8134629da054287c8eb99927ac53a8aa7070 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 18 Sep 2018 12:23:03 -0700 Subject: [PATCH 198/329] deal with fence gate properly, fixes #172 --- .../pathing/movement/movements/MovementPillar.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 99b3aa50..512ff937 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -67,20 +67,25 @@ public class MovementPillar extends Movement { return COST_INF; } } - double hardness = getTotalHardnessOfBlocksToBreak(context); + BlockPos toBreakPos = src.up(2); + IBlockState toBreak = BlockStateInterface.get(toBreakPos); + Block toBreakBlock = toBreak.getBlock(); + if (toBreakBlock instanceof BlockFenceGate) { + return COST_INF; + } + double hardness = MovementHelper.getMiningDurationTicks(context, toBreakPos, toBreak, true); if (hardness >= COST_INF) { return COST_INF; } if (hardness != 0) { - Block tmp = BlockStateInterface.get(src.up(2)).getBlock(); - if (tmp instanceof BlockLadder || tmp instanceof BlockVine) { + if (toBreakBlock instanceof BlockLadder || toBreakBlock instanceof BlockVine) { hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it } else { BlockPos chkPos = src.up(3); IBlockState check = BlockStateInterface.get(chkPos); if (check.getBlock() instanceof BlockFalling) { // see MovementAscend's identical check for breaking a falling block above our head - if (!(tmp instanceof BlockFalling) || !(BlockStateInterface.get(src.up(1)).getBlock() instanceof BlockFalling)) { + if (!(toBreakBlock instanceof BlockFalling) || !(BlockStateInterface.get(src.up(1)).getBlock() instanceof BlockFalling)) { return COST_INF; } } From 28ebf065ee4d178d3f7ed80cbe64bb7c64f7db21 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 18 Sep 2018 13:14:22 -0700 Subject: [PATCH 199/329] 5x harder to break while sneaking --- .../pathing/movement/movements/MovementPillar.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 512ff937..ccb5c280 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -29,6 +29,7 @@ import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; public class MovementPillar extends Movement { @@ -102,7 +103,7 @@ public class MovementPillar extends Movement { return COST_INF; } if (ladder) { - return LADDER_UP_ONE_COST + hardness; + return LADDER_UP_ONE_COST + hardness * 5; } else { return JUMP_ONE_BLOCK_COST + context.placeBlockCost() + hardness; } @@ -205,4 +206,15 @@ public class MovementPillar extends Movement { return state; } + + @Override + protected boolean prepared(MovementState state) { + if (playerFeet().equals(src) || playerFeet().equals(src.down())) { + Block block = BlockStateInterface.getBlock(src.down()); + if (block == Blocks.LADDER || block == Blocks.VINE) { + state.setInput(InputOverrideHandler.Input.SNEAK, true); + } + } + return super.prepared(state); + } } \ No newline at end of file From ef55d869136310684275eae40e4bc8690fe5a894 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 18 Sep 2018 20:59:48 -0700 Subject: [PATCH 200/329] fix follow offset while at large x and z coordinates --- src/main/java/baritone/behavior/FollowBehavior.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index a9a829c3..21ebbbea 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -48,8 +48,14 @@ public final class FollowBehavior extends Behavior implements Helper { return; } // lol this is trashy but it works - GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); - PathingBehavior.INSTANCE.setGoal(new GoalNear(new BlockPos(g.getX(), following.posY, g.getZ()), Baritone.settings().followRadius.get())); + BlockPos pos; + if (Baritone.settings().followOffsetDistance.get() == 0) { + pos = following.getPosition(); + } else { + GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); + pos = new BlockPos(g.getX(), following.posY, g.getZ()); + } + PathingBehavior.INSTANCE.setGoal(new GoalNear(pos, Baritone.settings().followRadius.get())); PathingBehavior.INSTANCE.revalidateGoal(); PathingBehavior.INSTANCE.path(); } From 2375f1a408be0effb4c271271b62e786d825cfb3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 14:39:57 -0700 Subject: [PATCH 201/329] better encapsulation of currentlyRunning --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 5 ----- .../java/baritone/pathing/calc/AbstractNodeCostSearch.java | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index f8b6eeb6..6c5865ca 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -72,7 +72,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { } CalculationContext calcContext = new CalculationContext(); HashSet favored = favoredPositions.orElse(null); - currentlyRunning = this; CachedWorld cachedWorld = Optional.ofNullable(WorldProvider.INSTANCE.getCurrentWorld()).map(w -> w.cache).orElse(null); ChunkProviderClient chunkProvider = Minecraft.getMinecraft().world.getChunkProvider(); BlockStateInterface.clearCachedChunk(); @@ -103,7 +102,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { BetterBlockPos currentNodePos = currentNode.pos; numNodes++; if (goal.isInGoal(currentNodePos)) { - currentlyRunning = null; logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); return Optional.of(new Path(startNode, currentNode, numNodes, goal)); } @@ -177,7 +175,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { } } if (cancelRequested) { - currentlyRunning = null; return Optional.empty(); } System.out.println(numMovementsConsidered + " movements considered"); @@ -200,13 +197,11 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { System.out.println("But I'm going to do it anyway, because yolo"); } System.out.println("Path goes for " + Math.sqrt(dist) + " blocks"); - currentlyRunning = null; return Optional.of(new Path(startNode, bestSoFar[i], numNodes, goal)); } } logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); logDebug("No path found =("); - currentlyRunning = null; return Optional.empty(); } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 4a8fe752..20dce981 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -36,7 +36,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { /** * The currently running search task */ - protected static AbstractNodeCostSearch currentlyRunning = null; + private static AbstractNodeCostSearch currentlyRunning = null; protected final BetterBlockPos start; @@ -55,7 +55,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { private volatile boolean isFinished; - protected boolean cancelRequested; + protected volatile boolean cancelRequested; /** * This is really complicated and hard to explain. I wrote a comment in the old version of MineBot but it was so @@ -85,6 +85,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { } this.cancelRequested = false; try { + currentlyRunning = this; Optional path = calculate0(timeout); path.ifPresent(IPath::postprocess); isFinished = true; From 179053442140696433befa0bf254b766276eb287 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 17:16:42 -0700 Subject: [PATCH 202/329] allow swimming up a water column, fixes #174, fixes #129 --- .../movement/movements/MovementPillar.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index ccb5c280..f87ff302 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -31,6 +31,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; public class MovementPillar extends Movement { private int numTicks = 0; @@ -74,6 +75,13 @@ public class MovementPillar extends Movement { if (toBreakBlock instanceof BlockFenceGate) { return COST_INF; } + Block srcUp = null; + if (BlockStateInterface.isWater(toBreakBlock) && BlockStateInterface.isWater(fromDown)) { + srcUp = BlockStateInterface.get(dest).getBlock(); + if (BlockStateInterface.isWater(srcUp)) { + return LADDER_UP_ONE_COST; + } + } double hardness = MovementHelper.getMiningDurationTicks(context, toBreakPos, toBreak, true); if (hardness >= COST_INF) { return COST_INF; @@ -86,7 +94,10 @@ public class MovementPillar extends Movement { IBlockState check = BlockStateInterface.get(chkPos); if (check.getBlock() instanceof BlockFalling) { // see MovementAscend's identical check for breaking a falling block above our head - if (!(toBreakBlock instanceof BlockFalling) || !(BlockStateInterface.get(src.up(1)).getBlock() instanceof BlockFalling)) { + if (srcUp == null) { + srcUp = BlockStateInterface.get(dest).getBlock(); + } + if (!(toBreakBlock instanceof BlockFalling) || !(srcUp instanceof BlockFalling)) { return COST_INF; } } @@ -133,6 +144,18 @@ public class MovementPillar extends Movement { } IBlockState fromDown = BlockStateInterface.get(src); + if (BlockStateInterface.isWater(fromDown.getBlock()) && BlockStateInterface.isWater(dest)) { + // stay centered while swimming up a water column + state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), false)); + Vec3d destCenter = Utils.getBlockPosCenter(dest); + if (Math.abs(player().posX - destCenter.x) > 0.2 || Math.abs(player().posZ - destCenter.z) > 0.2) { + state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + } + if (playerFeet().equals(dest)) { + return state.setStatus(MovementState.MovementStatus.SUCCESS); + } + return state; + } boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine; boolean vine = fromDown.getBlock() instanceof BlockVine; if (!ladder) { @@ -215,6 +238,9 @@ public class MovementPillar extends Movement { state.setInput(InputOverrideHandler.Input.SNEAK, true); } } + if (BlockStateInterface.isWater(dest.up())) { + return true; + } return super.prepared(state); } } \ No newline at end of file From 2e63ac41d9b22e4ee0a62f2bd29974e43e2071a1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 19:34:05 -0700 Subject: [PATCH 203/329] possibly fix oscillation problem with a large goal composite --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 6c5865ca..73ca28f6 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -68,7 +68,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { bestSoFar = new PathNode[COEFFICIENTS.length];//keep track of the best node by the metric of (estimatedCostToGoal + cost / COEFFICIENTS[i]) double[] bestHeuristicSoFar = new double[COEFFICIENTS.length]; for (int i = 0; i < bestHeuristicSoFar.length; i++) { - bestHeuristicSoFar[i] = Double.MAX_VALUE; + bestHeuristicSoFar[i] = startNode.estimatedCostToGoal; + bestSoFar[i] = startNode; } CalculationContext calcContext = new CalculationContext(); HashSet favored = favoredPositions.orElse(null); From 139d05d93fcd5c5fdbf993a3fbfb9ebeff8ec5ec Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 20:12:27 -0700 Subject: [PATCH 204/329] disable mergeinterfacesaggressively for jit performance --- proguard.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 86ddc1a2..8880de6e 100644 --- a/proguard.pro +++ b/proguard.pro @@ -9,7 +9,6 @@ -verbose -allowaccessmodification # anything not kept can be changed from public to private and inlined etc --mergeinterfacesaggressively -overloadaggressively -dontusemixedcaseclassnames From caccc3001e1dc7e526b23b0701b1104b5332fb79 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:23:26 -0500 Subject: [PATCH 205/329] Better Impact Install Instructions --- IMPACT.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index cec0ed1a..88daeb66 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -1,16 +1,82 @@ # Integration between Baritone and Impact -Baritone will be in Impact 4.4 with nice integrations with its utility modules, but if you're impatient you can run Baritone on top of Impact 4.3 right now. +## An Introduction +There are some basic steps to getting Baritone setup with Impact. +- Acquiring a build of Baritone +- Placing Baritone in the libraries directory +- Modifying the Impact Profile JSON to run baritone +- How to use Baritone -You can either build Baritone yourself, or download the "official" jar (as of commit 66e6216, built on September 17) from here. If you really want the cutting edge latest release, and you trust @Plutie#9079, commits are automatically built on their Jenkins here. +## Acquiring a build of Baritone +There are 3 methods of acquiring a build of Baritone (While it is still in development) -To build it yourself, clone and setup Baritone (instructions in main README.md). Then, build the jar. From the command line, it's `./gradlew build` (or `gradlew build` on Windows). In IntelliJ, you can just start the `build` task in the Gradle menu. +### Official Build (Not always up to date) +Download the "official" jar (as of commit 2e63ac4, +built on September 19) from here. -Copy the jar into place. If you built it yourself, it should be at `build/libs/baritone-1.0.0.jar` in baritone (otherwise, if you downloaded it, it's in your Downloads). Copy it to your libraries in your Minecraft install. For example, on Mac I do `cp Documents/baritone/build/libs/baritone-1.0.0.jar Library/Application\ Support/minecraft/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`. The first time you'll need to make the directory `cabaletta/baritone/1.0.0` in libraries first. +### Building Baritone yourself +There are a few steps to this +- Clone this repository +- Setup the project as instructed in the README +- Run the ``build`` gradle task. You can either do this using IntelliJ's gradle UI or through a +command line + - Windows: ``gradlew build`` + - Mac/Linux: ``./gradlew build`` +- The build should be exported into ``/build/libs/baritone-1.0.0.jar`` -Then, we'll need to modify the Impact launch json. Open `minecraft/versions/1.12.2-Impact_4.3/1.12.2-Impact_4.3.json`. Alternatively, copy your existing installation and rename the version folder, json, and id in the json if you want to be able to choose from the Minecraft launcher whether you want Impact or Impact+Baritone. +### Cutting Edge Release +If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit +from his Jenkins server, found here. -- Add the Baritone tweak class to line 7 "minecraftArguments" like so: `"minecraftArguments": " ... --tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine",`. You need the Optifine tweaker even though there is no Optifine involved, for reasons I don't quite understand. -- Add the Baritone library. Insert `{ "name": "cabaletta:baritone:1.0.0" },` between Impact and ClientAPI, which should be between lines 15 and 16. +## Placing Baritone in the libraries directory +``/libraries`` is a neat directory in your Minecraft Installation Directory +that contains all of the dependencies that are required from the game and some mods. This is where we will be +putting baritone. +- Locate the ``libraries`` folder, it should be in the Minecraft Installation Directory +- Create 3 new subdirectories starting from ``libraries`` + - ``cabaletta`` + - ``baritone`` + - ``1.0.0`` + - Copy the build of Baritone that was acquired earlier, and place it into the ``1.0.0`` folder + - The full path should look like ``/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`` -Restart the Minecraft launcher, then load Impact 4.3 as normal, and it should now include Baritone. +## Modifying the Impact Profile JSON to run baritone +The final step is "registering" the Baritone library with Impact, so that it loads on launch. +- Ensure your Minecraft launcher is closed +- Navigate back to the Minecraft Installation Directory +- Find the ``profiles`` directory, and open in +- In here there should be a ``1.12.2-Impact_4.3`` folder. + - If you don't have any Impact folder or have a version older than 4.3, you can download Impact here. +- Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json`` +- Open the JSON file with a text editor that supports your system's line endings + - For example, Notepad on Windows likely will NOT work for this. You should instead use a Text Editor like + Notepad++ if you're on Windows. (For other systems, I'm not sure + what would work the best so you may have to do some research.) +- Find the ``libraries`` array in the JSON. It should look something like this. + ``` + "libraries": [ + { + "name": "net.minecraft:launchwrapper:1.12" + }, + { + "name": "com.github.ImpactDevelopment:Impact:4.3-1.12.2", + "url": "https://impactdevelopment.github.io/maven/" + }, + { + "name": "com.github.ImpactDeveloment:ClientAPI:3.0.2", + "url": "https://impactdevelopment.github.io/maven/" + }, + ... + ``` +- Create a new object in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably. + ``` + { + "name": "cabaletta:baritone:1.0.0" + }, + ``` +- If you didn't close your launcher for this step, restart it now. +- You can now launch Impact 4.3 as normal, and Baritone should start up + + ## How to use Baritone + Instructions on how to use Baritone are limited, and you may have to read a little bit of code (Really nothing much + just plain English), you can view that here. From ecd8da553bd96d815acb566b2c4429600d174e77 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:28:53 -0500 Subject: [PATCH 206/329] Can't forget the tweaker --- IMPACT.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/IMPACT.md b/IMPACT.md index 88daeb66..40711c0d 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -74,6 +74,10 @@ The final step is "registering" the Baritone library with Impact, so that it loa "name": "cabaletta:baritone:1.0.0" }, ``` +- Now find the ``"minecraftArguments": "..."`` text near the top. +- At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like: + - ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"`` + - It should now read something like - If you didn't close your launcher for this step, restart it now. - You can now launch Impact 4.3 as normal, and Baritone should start up From d4f1a127d7a8e7576403c49f759754ee33bcbbd1 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:29:42 -0500 Subject: [PATCH 207/329] iMpAtIeNt --- IMPACT.md | 1 + 1 file changed, 1 insertion(+) diff --git a/IMPACT.md b/IMPACT.md index 40711c0d..7244b98b 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -1,4 +1,5 @@ # Integration between Baritone and Impact +Impact 4.4 will have Baritone included on release, however, if you're impatient, you can install Baritone into Impact 4.3 right now! ## An Introduction There are some basic steps to getting Baritone setup with Impact. From 28a8e7ea634e04bff113f1321518e7ef96d6a28a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 20:30:17 -0700 Subject: [PATCH 208/329] home should path, not just set goal --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index b6ef2a45..a4fea03b 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -421,7 +421,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } else { Goal goal = new GoalBlock(waypoint.location); PathingBehavior.INSTANCE.setGoal(goal); - logDirect("Set goal to saved home " + goal); + PathingBehavior.INSTANCE.path(); + logDirect("Going to saved home " + goal); } event.cancel(); return; From d3c194c74676e63269e9bfac913b3e860a42084c Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:30:21 -0500 Subject: [PATCH 209/329] Brady doesn't know how to remove things that he didn't want to add --- IMPACT.md | 1 - 1 file changed, 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 7244b98b..e7473e7e 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -78,7 +78,6 @@ The final step is "registering" the Baritone library with Impact, so that it loa - Now find the ``"minecraftArguments": "..."`` text near the top. - At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like: - ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"`` - - It should now read something like - If you didn't close your launcher for this step, restart it now. - You can now launch Impact 4.3 as normal, and Baritone should start up From 8a03428635cf2d2b54e064778444a5de7ebc8163 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 20:32:06 -0700 Subject: [PATCH 210/329] change url --- IMPACT.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index e7473e7e..e55bf743 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -27,7 +27,7 @@ command line ### Cutting Edge Release If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit -from his Jenkins server, found here. +from his Jenkins server, found here. ## Placing Baritone in the libraries directory ``/libraries`` is a neat directory in your Minecraft Installation Directory diff --git a/README.md b/README.md index 18031bdd..c2c82200 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone + Impact -Unofficial Jenkins: [![Build Status](http://24.202.239.85:8080/job/baritone/badge/icon)](http://24.202.239.85:8080/job/baritone/lastSuccessfulBuild/) +Unofficial Jenkins: [![Build Status](https://plutiejenkins.leijurv.com/job/baritone/badge/icon)](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/) # Setup From 01b88caa93b127e16d5965dc958b386505700e0d Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:32:19 -0500 Subject: [PATCH 211/329] Consistent Indentation --- IMPACT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index e55bf743..c7f167aa 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -27,7 +27,7 @@ command line ### Cutting Edge Release If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit -from his Jenkins server, found here. +from his Jenkins server, found here. ## Placing Baritone in the libraries directory ``/libraries`` is a neat directory in your Minecraft Installation Directory @@ -72,7 +72,7 @@ The final step is "registering" the Baritone library with Impact, so that it loa - Create a new object in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably. ``` { - "name": "cabaletta:baritone:1.0.0" + "name": "cabaletta:baritone:1.0.0" }, ``` - Now find the ``"minecraftArguments": "..."`` text near the top. From 5bd4dcadf803ef3ce3c2a5d1fda396a059b85e34 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 19 Sep 2018 22:35:52 -0500 Subject: [PATCH 212/329] gitHUB --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index c7f167aa..3b2d61c6 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -27,7 +27,7 @@ command line ### Cutting Edge Release If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit -from his Jenkins server, found here. +from his Jenkins server, found here. ## Placing Baritone in the libraries directory ``/libraries`` is a neat directory in your Minecraft Installation Directory From 454bc9c6286b517727740cc80f466bb64d1e39c7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Sep 2018 21:22:57 -0700 Subject: [PATCH 213/329] versions, not profiles --- IMPACT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IMPACT.md b/IMPACT.md index 3b2d61c6..357119a1 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -45,7 +45,7 @@ putting baritone. The final step is "registering" the Baritone library with Impact, so that it loads on launch. - Ensure your Minecraft launcher is closed - Navigate back to the Minecraft Installation Directory -- Find the ``profiles`` directory, and open in +- Find the ``versions`` directory, and open in - In here there should be a ``1.12.2-Impact_4.3`` folder. - If you don't have any Impact folder or have a version older than 4.3, you can download Impact here. - Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json`` From d0fd370d53b11af181742ecf8d22d8300d4b9d04 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 11:35:36 -0500 Subject: [PATCH 214/329] Fix issue with WorldScanner where no chunks match exact dist squared --- src/main/java/baritone/cache/WorldScanner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index bd2690a6..db457744 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -50,12 +50,14 @@ public enum WorldScanner implements Helper { boolean foundWithinY = false; while (true) { boolean allUnloaded = true; + boolean foundChunks = false; for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) { for (int zoff = -searchRadiusSq; zoff <= searchRadiusSq; zoff++) { int distance = xoff * xoff + zoff * zoff; if (distance != searchRadiusSq) { continue; } + foundChunks = true; int chunkX = xoff + playerChunkX; int chunkZ = zoff + playerChunkZ; Chunk chunk = chunkProvider.getLoadedChunk(chunkX, chunkZ); @@ -92,7 +94,7 @@ public enum WorldScanner implements Helper { } } } - if (allUnloaded) { + if (allUnloaded && foundChunks) { return res; } if (res.size() >= max && (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY))) { From 37f00f3e14de378ad58c91d7265672bdc5dd0f55 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 12:21:23 -0500 Subject: [PATCH 215/329] Made foundWithinY in WorldScanner an "option" --- src/main/java/baritone/behavior/MineBehavior.java | 2 +- src/main/java/baritone/cache/WorldScanner.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 71674363..84169ea8 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -148,7 +148,7 @@ public final class MineBehavior extends Behavior implements Helper { } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max, 10)); //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } return prune(locs, mining, max); diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index db457744..512661b0 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -32,7 +32,16 @@ import java.util.List; public enum WorldScanner implements Helper { INSTANCE; - public List scanLoadedChunks(List blocks, int max) { + /** + * Scans the world, up to your render distance, for the specified blocks. + * + * @param blocks The blocks to scan for + * @param max The maximum number of blocks to scan before cutoff + * @param yLevelThreshold If a block is found within this Y level, the current result will be + * returned, if the value is negative, then this condition doesn't apply. + * @return The matching block positions + */ + public List scanLoadedChunks(List blocks, int max, int yLevelThreshold) { if (blocks.contains(null)) { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString()); } @@ -84,7 +93,7 @@ public enum WorldScanner implements Helper { if (blocks.contains(state.getBlock())) { int yy = yReal | y; res.add(new BlockPos(chunkX | x, yy, chunkZ | z)); - if (Math.abs(yy - playerY) < 10) { + if (Math.abs(yy - playerY) < yLevelThreshold) { foundWithinY = true; } } From 0575e2d6675f5e6dd323cc92ac662665f8009f2d Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 13:52:29 -0500 Subject: [PATCH 216/329] Fix size parameter not being properly recognized by WorldScanner --- src/main/java/baritone/cache/WorldScanner.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 512661b0..106161f8 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -103,10 +103,10 @@ public enum WorldScanner implements Helper { } } } - if (allUnloaded && foundChunks) { - return res; - } - if (res.size() >= max && (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY))) { + if ((allUnloaded && foundChunks) + || res.size() >= max + || (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY)) + ) { return res; } searchRadiusSq++; From 1c2e47c39af8d6085bbbd3e936cddec3924b1161 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 14:14:59 -0500 Subject: [PATCH 217/329] Add maxSearchRadius parameter to WorldScanner --- src/main/java/baritone/cache/WorldScanner.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 106161f8..48cb59ba 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -39,9 +39,10 @@ public enum WorldScanner implements Helper { * @param max The maximum number of blocks to scan before cutoff * @param yLevelThreshold If a block is found within this Y level, the current result will be * returned, if the value is negative, then this condition doesn't apply. + * @param maxSearchRadius The maximum chunk search radius * @return The matching block positions */ - public List scanLoadedChunks(List blocks, int max, int yLevelThreshold) { + public List scanLoadedChunks(List blocks, int max, int yLevelThreshold, int maxSearchRadius) { if (blocks.contains(null)) { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString()); } @@ -51,6 +52,7 @@ public enum WorldScanner implements Helper { } ChunkProviderClient chunkProvider = world().getChunkProvider(); + int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius; int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; int playerY = playerFeet().getY(); @@ -105,7 +107,7 @@ public enum WorldScanner implements Helper { } if ((allUnloaded && foundChunks) || res.size() >= max - || (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY)) + || (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY)) ) { return res; } From ddf7b3739a1d43df5ba265cb5da69e304cea8851 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 14:29:37 -0500 Subject: [PATCH 218/329] Fix compiler error --- src/main/java/baritone/behavior/MineBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 84169ea8..f7271966 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -148,7 +148,7 @@ public final class MineBehavior extends Behavior implements Helper { } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max, 10)); + locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max, 10, 26)); //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } return prune(locs, mining, max); From e3434115acfa2bd17538dd38856957251cb07519 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 20 Sep 2018 13:29:26 -0700 Subject: [PATCH 219/329] logger --- src/main/java/baritone/Settings.java | 8 ++++++++ src/main/java/baritone/utils/Helper.java | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 286c06e7..4545faa8 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -17,11 +17,14 @@ package baritone; +import baritone.utils.Helper; import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraft.util.text.ITextComponent; import java.lang.reflect.Field; import java.util.*; +import java.util.function.Consumer; /** * Baritone's settings @@ -375,6 +378,11 @@ public class Settings { */ public Setting followRadius = new Setting<>(3); + /** + * Instead of Baritone logging to chat, set a custom consumer. + */ + public Setting> logger = new Setting<>(new Helper() {}::addToChat); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index d808e632..9924d0bf 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -96,6 +96,11 @@ public interface Helper { ITextComponent component = MESSAGE_PREFIX.createCopy(); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(new TextComponentString(" " + message)); - mc.ingameGUI.getChatGUI().printChatMessage(component); + Baritone.settings().logger.get().accept(component); } + + default void addToChat(ITextComponent msg) { + mc.ingameGUI.getChatGUI().printChatMessage(msg); + } + } From 4513a537dbf732048026b8f1402c4b1fe9d473a0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 20 Sep 2018 14:08:56 -0700 Subject: [PATCH 220/329] fix logic in minebehavior --- src/main/java/baritone/behavior/MineBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index f7271966..56aa5738 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -119,11 +119,11 @@ public final class MineBehavior extends Behavior implements Helper { if (noDown) { return new GoalTwoBlocks(loc); } else { - return new GoalBlock(loc.down()); + return new GoalBlock(loc); } } else { if (noDown) { - return new GoalBlock(loc); + return new GoalBlock(loc.down()); } else { return new GoalTwoBlocks(loc); } From 2cac115211eed57f206e6cf9e5a20818adbdd3d0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 20 Sep 2018 14:09:13 -0700 Subject: [PATCH 221/329] fix scan logic --- src/main/java/baritone/cache/WorldScanner.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 48cb59ba..d6b466ef 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -35,8 +35,8 @@ public enum WorldScanner implements Helper { /** * Scans the world, up to your render distance, for the specified blocks. * - * @param blocks The blocks to scan for - * @param max The maximum number of blocks to scan before cutoff + * @param blocks The blocks to scan for + * @param max The maximum number of blocks to scan before cutoff * @param yLevelThreshold If a block is found within this Y level, the current result will be * returned, if the value is negative, then this condition doesn't apply. * @param maxSearchRadius The maximum chunk search radius @@ -106,8 +106,8 @@ public enum WorldScanner implements Helper { } } if ((allUnloaded && foundChunks) - || res.size() >= max - || (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY)) + || (res.size() >= max + && (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY))) ) { return res; } From 21568f593a41a0da191d5f3eb2cb3a6e30bdf67d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 20 Sep 2018 21:27:25 -0700 Subject: [PATCH 222/329] fix goal offset logic --- src/main/java/baritone/behavior/MineBehavior.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 56aa5738..c5fd1534 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -113,16 +113,16 @@ public final class MineBehavior extends Behavior implements Helper { return new GoalTwoBlocks(loc); } - boolean noUp = locs.contains(loc.up()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); - boolean noDown = locs.contains(loc.down()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); - if (noUp) { - if (noDown) { + boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + if (upwardGoal) { + if (downwardGoal) { return new GoalTwoBlocks(loc); } else { return new GoalBlock(loc); } } else { - if (noDown) { + if (downwardGoal) { return new GoalBlock(loc.down()); } else { return new GoalTwoBlocks(loc); From ae59e94a6c807661853d27bf2f2d06759bc08b2c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 21 Sep 2018 08:49:49 -0700 Subject: [PATCH 223/329] lmao wtf --- src/main/java/baritone/behavior/MineBehavior.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index c5fd1534..3073c0f8 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -103,8 +103,6 @@ public final class MineBehavior extends Behavior implements Helper { locationsCache = locs; PathingBehavior.INSTANCE.setGoal(coalesce(locs)); PathingBehavior.INSTANCE.path(); - - Blocks.DIAMOND_ORE.getItemDropped(Blocks.DIAMOND_ORE.getDefaultState(), new Random(), 0); } public static GoalComposite coalesce(List locs) { From 9661ab3b4215c3cfbe97938b52ad7a0e677ce8d1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 21 Sep 2018 09:30:37 -0700 Subject: [PATCH 224/329] more info on cancelOnGoalInvalidation --- src/main/java/baritone/Settings.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 4545faa8..87bd1812 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -339,7 +339,17 @@ public class Settings { public Setting mineGoalUpdateInterval = new Setting<>(5); /** - * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore + * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore. + *

+ * Currently only runs when either MineBehavior or FollowBehavior is active. + *

+ * For example, if Baritone is doing "mine iron_ore", the instant it breaks the ore (and it becomes air), that location + * is no longer a goal. This means that if this setting is true, it will stop there. If this setting were off, it would + * continue with its path, and walk into that location. The tradeoff is if this setting is true, it mines ores much faster + * since it doesn't waste any time getting into locations that no longer contain ores, but on the other hand, it misses + * some drops, and continues on without ever picking them up. + *

+ * Also on cosmic prisons this should be set to true since you don't actually mine the ore it just gets replaced with stone. */ public Setting cancelOnGoalInvalidation = new Setting<>(true); From 8b307f296a4e063ab9f2b82d8e824fa08ffa69b7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 21 Sep 2018 22:14:18 -0700 Subject: [PATCH 225/329] fix very rare null pointer exception --- .../java/baritone/pathing/calc/AStarPathFinder.java | 2 ++ .../pathing/calc/AbstractNodeCostSearch.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 73ca28f6..d9f3ba1a 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -90,6 +90,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { 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 favorCoeff = Baritone.settings().backtrackCostFavoringCoefficient.get(); boolean minimumImprovementRepropagation = Baritone.settings().minimumImprovementRepropagation.get(); + loopBegin(); while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && System.nanoTime() / 1000000L - timeoutTime < 0 && !cancelRequested) { if (slowPath) { try { @@ -180,6 +181,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { } System.out.println(numMovementsConsidered + " movements considered"); System.out.println("Open set size: " + openSet.size()); + System.out.println("PathNode map size: " + mapSize()); System.out.println((int) (numNodes * 1.0 / ((System.nanoTime() / 1000000L - startTime) / 1000F)) + " nodes per second"); double bestDist = 0; for (int i = 0; i < bestSoFar.length; i++) { diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 20dce981..ee2d0e24 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -85,7 +85,6 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { } this.cancelRequested = false; try { - currentlyRunning = this; Optional path = calculate0(timeout); path.ifPresent(IPath::postprocess); isFinished = true; @@ -97,6 +96,14 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { } } + /** + * Don't set currentlyRunning to this until everything is all ready to go, and we're about to enter the main loop. + * For example, bestSoFar is null so bestPathSoFar (which gets bestSoFar[0]) could NPE if we set currentlyRunning before calculate0 + */ + protected void loopBegin() { + currentlyRunning = this; + } + protected abstract Optional calculate0(long timeout); /** @@ -143,6 +150,10 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); } + protected int mapSize() { + return map.size(); + } + @Override public Optional bestPathSoFar() { if (startNode == null || bestSoFar[0] == null) { From e16bc5eca4dad52efbdf1367474f6d5bb41c3454 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 08:47:02 -0700 Subject: [PATCH 226/329] more better block pos --- .../java/baritone/behavior/PathingBehavior.java | 3 ++- .../java/baritone/pathing/calc/AStarPathFinder.java | 1 - .../pathing/calc/AbstractNodeCostSearch.java | 2 +- .../java/baritone/pathing/movement/Movement.java | 8 ++++---- .../baritone/pathing/movement/MovementHelper.java | 13 ++++++++----- .../pathing/movement/movements/MovementAscend.java | 2 +- .../pathing/movement/movements/MovementDescend.java | 2 +- .../movement/movements/MovementDiagonal.java | 4 ++-- .../movement/movements/MovementDownward.java | 3 +-- .../pathing/movement/movements/MovementFall.java | 8 ++++---- .../pathing/movement/movements/MovementParkour.java | 7 ++++--- .../pathing/movement/movements/MovementPillar.java | 2 +- .../movement/movements/MovementTraverse.java | 2 +- .../java/baritone/utils/ExampleBaritoneControl.java | 6 ++++++ 14 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 98653b24..4a36ce73 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.PathRenderer; import baritone.utils.interfaces.IGoalRenderPos; +import baritone.utils.pathing.BetterBlockPos; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -232,7 +233,7 @@ public final class PathingBehavior extends Behavior implements Helper { } public BlockPos pathStart() { - BlockPos feet = playerFeet(); + BetterBlockPos feet = playerFeet(); if (BlockStateInterface.get(feet.down()).getBlock().equals(Blocks.AIR) && MovementHelper.canWalkOn(feet.down().down())) { return feet.down(); } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index d9f3ba1a..8e5801df 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -240,7 +240,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.EAST), new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.WEST), new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.EAST), - new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), MovementParkour.generate(pos, EnumFacing.EAST, calcContext), diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index ee2d0e24..012c257c 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -55,7 +55,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { private volatile boolean isFinished; - protected volatile boolean cancelRequested; + protected boolean cancelRequested; /** * This is really complicated and hard to explain. I wrote a comment in the old version of MineBot but it was so diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 3e0a2f62..4fbc17f0 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -48,12 +48,12 @@ public abstract class Movement implements Helper, MovementHelper { /** * The positions that need to be broken before this movement can ensue */ - protected final BlockPos[] positionsToBreak; + protected final BetterBlockPos[] positionsToBreak; /** * The position where we need to place a block before this movement can ensue */ - protected final BlockPos positionToPlace; + protected final BetterBlockPos positionToPlace; private boolean didBreakLastTick; @@ -65,14 +65,14 @@ public abstract class Movement implements Helper, MovementHelper { private Boolean calculatedWhileLoaded; - protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) { + protected Movement(BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) { this.src = src; this.dest = dest; this.positionsToBreak = toBreak; this.positionToPlace = toPlace; } - protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak) { + protected Movement(BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak) { this(src, dest, toBreak, null); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 0ac4d7d8..421f3150 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -106,8 +106,9 @@ public interface MovementHelper extends ActionCosts, Helper { if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) { return false; } + return block == Blocks.WATER || block == Blocks.FLOWING_WATER; } - return block.isPassable(mc.world, pos); + return block.isPassable(mc.world, pos); // only blocks that can get here and actually that use world and pos for this call are snow and trapdoor } /** @@ -225,7 +226,7 @@ public interface MovementHelper extends ActionCosts, Helper { * * @return */ - static boolean canWalkOn(BlockPos pos, IBlockState state) { + static boolean canWalkOn(BetterBlockPos pos, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR || block == Blocks.MAGMA) { return false; @@ -246,8 +247,10 @@ public interface MovementHelper extends ActionCosts, Helper { return true; } if (BlockStateInterface.isWater(block)) { - Block up = BlockStateInterface.get(pos.up()).getBlock(); - if (up instanceof BlockLilyPad) { + // since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()" + // BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability + Block up = BlockStateInterface.get(pos.x, pos.y + 1, pos.z).getBlock(); + if (up == Blocks.WATERLILY) { return true; } if (BlockStateInterface.isFlowing(state) || block == Blocks.FLOWING_WATER) { @@ -276,7 +279,7 @@ public interface MovementHelper extends ActionCosts, Helper { return false; } - static boolean canWalkOn(BlockPos pos) { + static boolean canWalkOn(BetterBlockPos pos) { return canWalkOn(pos, BlockStateInterface.get(pos)); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 6f666a71..745b8a89 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -44,7 +44,7 @@ public class MovementAscend extends Movement { private int ticksWithoutPlacement = 0; public MovementAscend(BetterBlockPos src, BetterBlockPos dest) { - super(src, dest, new BlockPos[]{dest, src.up(2), dest.up()}, dest.down()); + super(src, dest, new BetterBlockPos[]{dest, src.up(2), dest.up()}, dest.down()); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 27a3c96d..85f7f110 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -34,7 +34,7 @@ public class MovementDescend extends Movement { private int numTicks = 0; public MovementDescend(BetterBlockPos start, BetterBlockPos end) { - super(start, end, new BlockPos[]{end.up(2), end.up(), end}, end.down()); + super(start, end, new BetterBlockPos[]{end.up(2), end.up(), end}, end.down()); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 58ba2ae2..d092b66e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -48,7 +48,7 @@ public class MovementDiagonal extends Movement { } private MovementDiagonal(BetterBlockPos start, BetterBlockPos end, BetterBlockPos dir1, BetterBlockPos dir2) { - super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); + super(start, end, new BetterBlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); } @Override @@ -60,7 +60,7 @@ public class MovementDiagonal extends Movement { if (!MovementHelper.canWalkThrough(positionsToBreak[4]) || !MovementHelper.canWalkThrough(positionsToBreak[5])) { return COST_INF; } - BlockPos destDown = dest.down(); + BetterBlockPos destDown = dest.down(); IBlockState destWalkOn = BlockStateInterface.get(destDown); if (!MovementHelper.canWalkOn(destDown, destWalkOn)) { return COST_INF; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index aa5df237..b265ddd7 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -26,14 +26,13 @@ import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; public class MovementDownward extends Movement { private int numTicks = 0; public MovementDownward(BetterBlockPos start, BetterBlockPos end) { - super(start, end, new BlockPos[]{end}); + super(start, end, new BetterBlockPos[]{end}); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 5e2556fe..a6a9e9f6 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -157,14 +157,14 @@ public class MovementFall extends Movement { return state; } - private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) { - BlockPos[] toBreak; + private static BetterBlockPos[] buildPositionsToBreak(BetterBlockPos src, BetterBlockPos dest) { + BetterBlockPos[] toBreak; int diffX = src.getX() - dest.getX(); int diffZ = src.getZ() - dest.getZ(); int diffY = src.getY() - dest.getY(); - toBreak = new BlockPos[diffY + 2]; + toBreak = new BetterBlockPos[diffY + 2]; for (int i = 0; i < toBreak.length; i++) { - toBreak[i] = new BlockPos(src.getX() - diffX, src.getY() + 1 - i, src.getZ() - diffZ); + toBreak[i] = new BetterBlockPos(src.getX() - diffX, src.getY() + 1 - i, src.getZ() - diffZ); } return toBreak; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index d113fa0f..0093539f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -39,12 +39,13 @@ import java.util.Objects; public class MovementParkour extends Movement { private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; + private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{}; private final EnumFacing direction; private final int dist; private MovementParkour(BetterBlockPos src, int dist, EnumFacing dir) { - super(src, src.offset(dir, dist), new BlockPos[]{}); + super(src, src.offset(dir, dist), EMPTY); this.direction = dir; this.dist = dist; super.override(costFromJumpDistance(dist)); @@ -59,7 +60,7 @@ public class MovementParkour extends Movement { if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || MovementHelper.isBottomSlab(standingOn)) { return null; } - BlockPos adjBlock = src.down().offset(dir); + BetterBlockPos adjBlock = src.down().offset(dir); IBlockState adj = BlockStateInterface.get(adjBlock); if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks return null; @@ -81,7 +82,7 @@ public class MovementParkour extends Movement { return null; } for (int i = 2; i <= (context.canSprint() ? 4 : 3); i++) { - BlockPos dest = src.offset(dir, i); + BetterBlockPos dest = src.offset(dir, i); // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? for (int y = 0; y < 4; y++) { if (!MovementHelper.fullyPassable(dest.up(y))) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index f87ff302..4cdc2f05 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -37,7 +37,7 @@ public class MovementPillar extends Movement { private int numTicks = 0; public MovementPillar(BetterBlockPos start, BetterBlockPos end) { - super(start, end, new BlockPos[]{start.up(2)}, start); + super(start, end, new BetterBlockPos[]{start.up(2)}, start); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 05f73e58..a2d64377 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -46,7 +46,7 @@ public class MovementTraverse extends Movement { private boolean wasTheBridgeBlockAlwaysThere = true; public MovementTraverse(BetterBlockPos from, BetterBlockPos to) { - super(from, to, new BlockPos[]{to.up(), to}, to.down()); + super(from, to, new BetterBlockPos[]{to.up(), to}, to.down()); } @Override diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index a4fea03b..6cd2655a 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -213,6 +213,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("ok force canceled"); return; } + if (msg.equals("gc")) { + System.gc(); + event.cancel(); + logDirect("Called System.gc();"); + return; + } if (msg.equals("invert")) { Goal goal = PathingBehavior.INSTANCE.getGoal(); BlockPos runAwayFrom; From 15fa12fe08515ff1e2b5f45c3abf16445b60d204 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 09:04:10 -0700 Subject: [PATCH 227/329] end of an era. stop randomizing movements --- .../baritone/pathing/calc/AStarPathFinder.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 8e5801df..f5c3eacd 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -39,7 +39,6 @@ import net.minecraft.util.math.BlockPos; import java.util.Collection; import java.util.HashSet; import java.util.Optional; -import java.util.Random; /** * The actual A* pathfinding @@ -50,8 +49,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { private final Optional> favoredPositions; - private final Random random = new Random(); - public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { super(start, goal); this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic @@ -107,8 +104,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); return Optional.of(new Path(startNode, currentNode, numNodes, goal)); } - Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order - shuffle(possibleMovements); + Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos for (Movement movementToGetToNeighbor : possibleMovements) { if (movementToGetToNeighbor == null) { continue; @@ -248,14 +244,4 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { MovementParkour.generate(pos, EnumFacing.SOUTH, calcContext), }; } - - private void shuffle(T[] list) { - int len = list.length; - for (int i = 0; i < len; i++) { - int j = random.nextInt(len); - T t = list[j]; - list[j] = list[i]; - list[i] = t; - } - } } From c508fb2cb783abe71dfe094222e5c910eb5e7aba Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 09:17:28 -0700 Subject: [PATCH 228/329] optimized checks --- .../baritone/pathing/movement/Movement.java | 4 +- .../pathing/movement/MovementHelper.java | 47 +++++++++++++------ .../movement/movements/MovementAscend.java | 4 +- .../movement/movements/MovementPillar.java | 2 +- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 4fbc17f0..82418574 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -158,7 +158,7 @@ public abstract class Movement implements Helper, MovementHelper { return true; } boolean somethingInTheWay = false; - for (BlockPos blockPos : positionsToBreak) { + for (BetterBlockPos blockPos : positionsToBreak) { if (!MovementHelper.canWalkThrough(blockPos)) { somethingInTheWay = true; Optional reachable = LookBehaviorUtils.reachable(blockPos); @@ -309,7 +309,7 @@ public abstract class Movement implements Helper, MovementHelper { return toBreakCached; } List result = new ArrayList<>(); - for (BlockPos positionToBreak : positionsToBreak) { + for (BetterBlockPos positionToBreak : positionsToBreak) { if (!MovementHelper.canWalkThrough(positionToBreak)) { result.add(positionToBreak); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 421f3150..2059a5a3 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -68,11 +68,15 @@ public interface MovementHelper extends ActionCosts, Helper { * @param pos * @return */ - static boolean canWalkThrough(BlockPos pos) { - return canWalkThrough(pos, BlockStateInterface.get(pos)); + static boolean canWalkThrough(BetterBlockPos pos) { + return canWalkThrough(pos.x, pos.y, pos.z, BlockStateInterface.get(pos)); } - static boolean canWalkThrough(BlockPos pos, IBlockState state) { + static boolean canWalkThrough(BetterBlockPos pos, IBlockState state) { + return canWalkThrough(pos.x, pos.y, pos.z, state); + } + + static boolean canWalkThrough(int x, int y, int z, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR) { return true; @@ -86,14 +90,23 @@ public interface MovementHelper extends ActionCosts, Helper { // be opened by just interacting. return block != Blocks.IRON_DOOR; } - if (block instanceof BlockSnow || block instanceof BlockTrapDoor) { - // we've already checked doors - // so the only remaining dynamic isPassables are snow, fence gate, and trapdoor + boolean snow = block instanceof BlockSnow; + boolean trapdoor = block instanceof BlockTrapDoor; + if (snow || trapdoor) { + // we've already checked doors and fence gates + // so the only remaining dynamic isPassables are snow and trapdoor // if they're cached as a top block, we don't know their metadata // default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible) - if (mc.world.getChunk(pos) instanceof EmptyChunk) { + if (mc.world.getChunk(x >> 4, z >> 4) instanceof EmptyChunk) { return true; } + if (snow) { + return state.getValue(BlockSnow.LAYERS) < 5; // see BlockSnow.isPassable + } + if (trapdoor) { + return !state.getValue(BlockTrapDoor.OPEN); // see BlockTrapDoor.isPassable + } + throw new IllegalStateException(); } if (BlockStateInterface.isFlowing(state)) { return false; // Don't walk through flowing liquids @@ -102,13 +115,16 @@ public interface MovementHelper extends ActionCosts, Helper { if (Baritone.settings().assumeWalkOnWater.get()) { return false; } - IBlockState up = BlockStateInterface.get(pos.up()); + IBlockState up = BlockStateInterface.get(x, y + 1, z); if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) { return false; } return block == Blocks.WATER || block == Blocks.FLOWING_WATER; } - return block.isPassable(mc.world, pos); // only blocks that can get here and actually that use world and pos for this call are snow and trapdoor + // every block that overrides isPassable with anything more complicated than a "return true;" or "return false;" + // has already been accounted for above + // therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null + return block.isPassable(null, null); } /** @@ -118,10 +134,10 @@ public interface MovementHelper extends ActionCosts, Helper { * @return */ static boolean fullyPassable(BlockPos pos) { - return fullyPassable(pos, BlockStateInterface.get(pos)); + return fullyPassable(BlockStateInterface.get(pos)); } - static boolean fullyPassable(BlockPos pos, IBlockState state) { + static boolean fullyPassable(IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR) { return true; @@ -140,7 +156,8 @@ public interface MovementHelper extends ActionCosts, Helper { || block instanceof BlockEndPortal) { return false; } - return block.isPassable(mc.world, pos); + // door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters + return block.isPassable(null, null); } static boolean isReplacable(BlockPos pos, IBlockState state) { @@ -289,12 +306,12 @@ public interface MovementHelper extends ActionCosts, Helper { return state.isBlockNormalCube(); } - static double getMiningDurationTicks(CalculationContext context, BlockPos position, boolean includeFalling) { + static double getMiningDurationTicks(CalculationContext context, BetterBlockPos position, boolean includeFalling) { IBlockState state = BlockStateInterface.get(position); return getMiningDurationTicks(context, position, state, includeFalling); } - static double getMiningDurationTicks(CalculationContext context, BlockPos position, IBlockState state, boolean includeFalling) { + static double getMiningDurationTicks(CalculationContext context, BetterBlockPos position, IBlockState state, boolean includeFalling) { Block block = state.getBlock(); if (!canWalkThrough(position, state)) { if (!context.allowBreak()) { @@ -311,7 +328,7 @@ public interface MovementHelper extends ActionCosts, Helper { double result = m / strVsBlock; if (includeFalling) { - BlockPos up = position.up(); + BetterBlockPos up = position.up(); IBlockState above = BlockStateInterface.get(up); if (above.getBlock() instanceof BlockFalling) { result += getMiningDurationTicks(context, up, above, true); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 745b8a89..9d3398a2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -202,9 +202,9 @@ public class MovementAscend extends Movement { } private boolean headBonkClear() { - BlockPos startUp = src.up(2); + BetterBlockPos startUp = src.up(2); for (int i = 0; i < 4; i++) { - BlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i)); + BetterBlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i)); if (!MovementHelper.canWalkThrough(check)) { // We might bonk our head return false; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 4cdc2f05..15e7d52c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -69,7 +69,7 @@ public class MovementPillar extends Movement { return COST_INF; } } - BlockPos toBreakPos = src.up(2); + BetterBlockPos toBreakPos = src.up(2); IBlockState toBreak = BlockStateInterface.get(toBreakPos); Block toBreakBlock = toBreak.getBlock(); if (toBreakBlock instanceof BlockFenceGate) { From d471bfa94816706e690c286d25a8453d8e4904cf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 09:28:59 -0700 Subject: [PATCH 229/329] fewer blockpos --- .../pathing/movement/MovementHelper.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 2059a5a3..20a81b00 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -76,6 +76,10 @@ public interface MovementHelper extends ActionCosts, Helper { return canWalkThrough(pos.x, pos.y, pos.z, state); } + static boolean canWalkThrough(int x, int y, int z) { + return canWalkThrough(x, y, z, BlockStateInterface.get(x, y, z)); + } + static boolean canWalkThrough(int x, int y, int z, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR) { @@ -243,7 +247,7 @@ public interface MovementHelper extends ActionCosts, Helper { * * @return */ - static boolean canWalkOn(BetterBlockPos pos, IBlockState state) { + static boolean canWalkOn(int x, int y, int z, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR || block == Blocks.MAGMA) { return false; @@ -266,7 +270,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (BlockStateInterface.isWater(block)) { // since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()" // BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability - Block up = BlockStateInterface.get(pos.x, pos.y + 1, pos.z).getBlock(); + Block up = BlockStateInterface.get(x, y + 1, z).getBlock(); if (up == Blocks.WATERLILY) { return true; } @@ -296,8 +300,16 @@ public interface MovementHelper extends ActionCosts, Helper { return false; } + static boolean canWalkOn(BetterBlockPos pos, IBlockState state) { + return canWalkOn(pos.x, pos.y, pos.z, state); + } + static boolean canWalkOn(BetterBlockPos pos) { - return canWalkOn(pos, BlockStateInterface.get(pos)); + return canWalkOn(pos.x, pos.y, pos.z, BlockStateInterface.get(pos)); + } + + static boolean canWalkOn(int x, int y, int z) { + return canWalkOn(x, y, z, BlockStateInterface.get(x, y, z)); } static boolean canPlaceAgainst(BlockPos pos) { @@ -433,7 +445,10 @@ public interface MovementHelper extends ActionCosts, Helper { //A is plausibly breakable by either descend or fall //C, D, etc determine the length of the fall - if (!canWalkThrough(dest.down(2))) { + int x = dest.x; + int y = dest.y; + int z = dest.z; + if (!canWalkThrough(x, y - 2, z)) { //if B in the diagram aren't air //have to do a descend, because fall is impossible @@ -445,25 +460,25 @@ public interface MovementHelper extends ActionCosts, Helper { // we're clear for a fall 2 // let's see how far we can fall for (int fallHeight = 3; true; fallHeight++) { - BetterBlockPos onto = dest.down(fallHeight); - if (onto.getY() < 0) { + int newY = y - fallHeight; + if (newY < 0) { // when pathing in the end, where you could plausibly fall into the void // this check prevents it from getting the block at y=-1 and crashing break; } - IBlockState ontoBlock = BlockStateInterface.get(onto); + IBlockState ontoBlock = BlockStateInterface.get(x, newY, z); if (ontoBlock.getBlock() == Blocks.WATER) { - return new MovementFall(pos, onto); + return new MovementFall(pos, new BetterBlockPos(x, newY, z)); } - if (canWalkThrough(onto, ontoBlock)) { + if (canWalkThrough(x, newY, z, ontoBlock)) { continue; } - if (!canWalkOn(onto, ontoBlock)) { + if (!canWalkOn(x, newY, z, ontoBlock)) { break; } if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) { // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new MovementFall(pos, onto.up()); + return new MovementFall(pos, new BetterBlockPos(x, newY + 1, z)); } else { return null; } From c64785f0ce9c51a892076975cfddb4bb72cd58b8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 09:34:42 -0700 Subject: [PATCH 230/329] don't let a NaN slip through --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 2059a5a3..0bde1674 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -322,7 +322,7 @@ public interface MovementHelper extends ActionCosts, Helper { } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table double strVsBlock = context.getToolSet().getStrVsBlock(state); - if (strVsBlock < 0) { + if (strVsBlock <= 0) { return COST_INF; } From 7888dd24e5ae388b8c4dea046fe221e1f0cfb071 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 11:23:26 -0700 Subject: [PATCH 231/329] comments --- src/main/java/baritone/pathing/movement/MovementHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 8e0f4651..8c3ad4f4 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -82,7 +82,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkThrough(int x, int y, int z, IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR) { + if (block == Blocks.AIR) { // early return for most common case return true; } if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL) { @@ -143,7 +143,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean fullyPassable(IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR) { + if (block == Blocks.AIR) { // early return for most common case return true; } // exceptions - blocks that are isPassable true, but we can't actually jump through @@ -250,6 +250,8 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkOn(int x, int y, int z, IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR || block == Blocks.MAGMA) { + // early return for most common case (air) + // plus magma, which is a normal cube but it hurts you return false; } if (state.isBlockNormalCube()) { From e33564f1eb5db7ea4d2cdc185e00f8382f88ce05 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:13:59 -0700 Subject: [PATCH 232/329] MovementPillar --- .../pathing/movement/MovementHelper.java | 24 ++++++++------- .../movement/movements/MovementPillar.java | 29 ++++++++++++------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 8c3ad4f4..dc9bcfa8 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -47,11 +47,12 @@ import java.util.Optional; */ public interface MovementHelper extends ActionCosts, Helper { - static boolean avoidBreaking(BlockPos pos, IBlockState state) { + static boolean avoidBreaking(BetterBlockPos pos, IBlockState state) { + return avoidBreaking(pos.x, pos.y, pos.z, state); + } + + static boolean avoidBreaking(int x, int y, int z, IBlockState state) { Block b = state.getBlock(); - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); return b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call BlockStateInterface.get directly with x,y,z. no need to make 5 new BlockPos for no reason @@ -322,16 +323,20 @@ public interface MovementHelper extends ActionCosts, Helper { static double getMiningDurationTicks(CalculationContext context, BetterBlockPos position, boolean includeFalling) { IBlockState state = BlockStateInterface.get(position); - return getMiningDurationTicks(context, position, state, includeFalling); + return getMiningDurationTicks(context, position.x, position.y, position.z, state, includeFalling); } static double getMiningDurationTicks(CalculationContext context, BetterBlockPos position, IBlockState state, boolean includeFalling) { + return getMiningDurationTicks(context, position.x, position.y, position.z, state, includeFalling); + } + + static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) { Block block = state.getBlock(); - if (!canWalkThrough(position, state)) { + if (!canWalkThrough(x, y, z, state)) { if (!context.allowBreak()) { return COST_INF; } - if (avoidBreaking(position, state)) { + if (avoidBreaking(x, y, z, state)) { return COST_INF; } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table @@ -342,10 +347,9 @@ public interface MovementHelper extends ActionCosts, Helper { double result = m / strVsBlock; if (includeFalling) { - BetterBlockPos up = position.up(); - IBlockState above = BlockStateInterface.get(up); + IBlockState above = BlockStateInterface.get(x, y + 1, z); if (above.getBlock() instanceof BlockFalling) { - result += getMiningDurationTicks(context, up, above, true); + result += getMiningDurationTicks(context, x, y + 1, z, above, true); } } return result; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 15e7d52c..bf77855d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -48,9 +48,13 @@ public class MovementPillar extends Movement { @Override protected double calculateCost(CalculationContext context) { - Block fromDown = BlockStateInterface.get(src).getBlock(); + return cost(context, src.x, src.y, src.z); + } + + public static double cost(CalculationContext context, int x, int y, int z) { + Block fromDown = BlockStateInterface.get(x, y, z).getBlock(); boolean ladder = fromDown instanceof BlockLadder || fromDown instanceof BlockVine; - IBlockState fromDownDown = BlockStateInterface.get(src.down()); + IBlockState fromDownDown = BlockStateInterface.get(x, y - 1, z); if (!ladder) { if (fromDownDown.getBlock() instanceof BlockLadder || fromDownDown.getBlock() instanceof BlockVine) { return COST_INF; @@ -65,24 +69,23 @@ public class MovementPillar extends Movement { return COST_INF; } if (fromDown instanceof BlockVine) { - if (getAgainst(src) == null) { + if (!hasAgainst(x, y, z)) { return COST_INF; } } - BetterBlockPos toBreakPos = src.up(2); - IBlockState toBreak = BlockStateInterface.get(toBreakPos); + IBlockState toBreak = BlockStateInterface.get(x, y + 2, z); Block toBreakBlock = toBreak.getBlock(); if (toBreakBlock instanceof BlockFenceGate) { return COST_INF; } Block srcUp = null; if (BlockStateInterface.isWater(toBreakBlock) && BlockStateInterface.isWater(fromDown)) { - srcUp = BlockStateInterface.get(dest).getBlock(); + srcUp = BlockStateInterface.get(x, y + 1, z).getBlock(); if (BlockStateInterface.isWater(srcUp)) { return LADDER_UP_ONE_COST; } } - double hardness = MovementHelper.getMiningDurationTicks(context, toBreakPos, toBreak, true); + double hardness = MovementHelper.getMiningDurationTicks(context, x, y + 2, z, toBreak, true); if (hardness >= COST_INF) { return COST_INF; } @@ -90,12 +93,11 @@ public class MovementPillar extends Movement { if (toBreakBlock instanceof BlockLadder || toBreakBlock instanceof BlockVine) { hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it } else { - BlockPos chkPos = src.up(3); - IBlockState check = BlockStateInterface.get(chkPos); + IBlockState check = BlockStateInterface.get(x, y + 3, z); if (check.getBlock() instanceof BlockFalling) { // see MovementAscend's identical check for breaking a falling block above our head if (srcUp == null) { - srcUp = BlockStateInterface.get(dest).getBlock(); + srcUp = BlockStateInterface.get(x, y + 1, z).getBlock(); } if (!(toBreakBlock instanceof BlockFalling) || !(srcUp instanceof BlockFalling)) { return COST_INF; @@ -120,6 +122,13 @@ public class MovementPillar extends Movement { } } + public static boolean hasAgainst(int x, int y, int z) { + return BlockStateInterface.get(x + 1, y, z).isBlockNormalCube() || + BlockStateInterface.get(x - 1, y, z).isBlockNormalCube() || + BlockStateInterface.get(x, y, z + 1).isBlockNormalCube() || + BlockStateInterface.get(x, y, z - 1).isBlockNormalCube(); + } + public static BlockPos getAgainst(BlockPos vine) { if (BlockStateInterface.get(vine.north()).isBlockNormalCube()) { return vine.north(); From eaa44c90f30d19da38ee53cd0df1173e57ff3816 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:46:10 -0700 Subject: [PATCH 233/329] MovementAscend --- .../pathing/movement/MovementHelper.java | 29 ++++++-- .../movement/movements/MovementAscend.java | 71 +++++++++++++------ .../baritone/utils/BlockStateInterface.java | 3 + 3 files changed, 78 insertions(+), 25 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index dc9bcfa8..1f8b9d49 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -166,6 +166,10 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean isReplacable(BlockPos pos, IBlockState state) { + return isReplacable(pos.getX(), pos.getY(), pos.getZ(), state); + } + + static boolean isReplacable(int x, int y, int z, IBlockState state) { // for MovementTraverse and MovementAscend // block double plant defaults to true when the block doesn't match, so don't need to check that case // all other overrides just return true or false @@ -176,13 +180,19 @@ public interface MovementHelper extends ActionCosts, Helper { * return ((Integer)worldIn.getBlockState(pos).getValue(LAYERS)).intValue() == 1; * } */ - if (state.getBlock() instanceof BlockSnow) { + Block block = state.getBlock(); + if (block instanceof BlockSnow) { // as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible) - if (mc.world.getChunk(pos) instanceof EmptyChunk) { + if (mc.world.getChunk(x >> 4, z >> 4) instanceof EmptyChunk) { return true; } + return state.getValue(BlockSnow.LAYERS) == 1; } - return state.getBlock().isReplaceable(mc.world, pos); + if (block instanceof BlockDoublePlant) { + BlockDoublePlant.EnumPlantType kek = state.getValue(BlockDoublePlant.VARIANT); + return kek == BlockDoublePlant.EnumPlantType.FERN || kek == BlockDoublePlant.EnumPlantType.GRASS; + } + return state.getBlock().isReplaceable(null, null); } static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) { @@ -315,8 +325,15 @@ public interface MovementHelper extends ActionCosts, Helper { return canWalkOn(x, y, z, BlockStateInterface.get(x, y, z)); } + static boolean canPlaceAgainst(int x, int y, int z) { + return canPlaceAgainst(BlockStateInterface.get(x, y, z)); + } + static boolean canPlaceAgainst(BlockPos pos) { - IBlockState state = BlockStateInterface.get(pos); + return canPlaceAgainst(BlockStateInterface.get(pos)); + } + + static boolean canPlaceAgainst(IBlockState state) { // TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it return state.isBlockNormalCube(); } @@ -330,6 +347,10 @@ public interface MovementHelper extends ActionCosts, Helper { return getMiningDurationTicks(context, position.x, position.y, position.z, state, includeFalling); } + static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) { + return getMiningDurationTicks(context, x, y, z, BlockStateInterface.get(x, y, z), includeFalling); + } + static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) { Block block = state.getBlock(); if (!canWalkThrough(x, y, z, state)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 9d3398a2..9549fe04 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -28,7 +28,6 @@ import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; -import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -55,46 +54,53 @@ public class MovementAscend extends Movement { @Override protected double calculateCost(CalculationContext context) { - IBlockState srcDown = BlockStateInterface.get(src.down()); + return cost(context, src.x, src.y, src.z, dest.x, dest.z); + } + + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + IBlockState srcDown = BlockStateInterface.get(x, y - 1, z); if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) { return COST_INF; } // we can jump from soul sand, but not from a bottom slab boolean jumpingFromBottomSlab = MovementHelper.isBottomSlab(srcDown); - IBlockState toPlace = BlockStateInterface.get(positionToPlace); + IBlockState toPlace = BlockStateInterface.get(destX, y, destZ); boolean jumpingToBottomSlab = MovementHelper.isBottomSlab(toPlace); if (jumpingFromBottomSlab && !jumpingToBottomSlab) { return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab } - if (!MovementHelper.canWalkOn(positionToPlace, toPlace)) { + boolean hasToPlace = false; + if (!MovementHelper.canWalkOn(destX, y, z, toPlace)) { if (!context.hasThrowaway()) { return COST_INF; } - if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { + if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y, destZ, toPlace)) { return COST_INF; } // TODO: add ability to place against .down() as well as the cardinal directions // useful for when you are starting a staircase without anything to place against // Counterpoint to the above TODO ^ you should move then pillar instead of ascend for (int i = 0; i < 4; i++) { - BlockPos against1 = positionToPlace.offset(HORIZONTALS[i]); - if (against1.equals(src)) { + int againstX = destX + HORIZONTALS[i].getXOffset(); + int againstZ = destZ + HORIZONTALS[i].getZOffset(); + if (againstX == x && againstZ == z) { continue; } - if (MovementHelper.canPlaceAgainst(against1)) { - return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); + if (MovementHelper.canPlaceAgainst(againstX, y, againstZ)) { + hasToPlace = true; + break; } } - return COST_INF; + if (!hasToPlace) { // didn't find a valid place =( + return COST_INF; + } } - if (BlockStateInterface.get(src.up(3)).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us + if (BlockStateInterface.get(x, y + 3, z).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us // HOWEVER, we assume that we're standing in the start position // that means that src and src.up(1) are both air // maybe they aren't now, but they will be by the time this starts - Block srcUp = BlockStateInterface.get(src.up(1)).getBlock(); - Block srcUp2 = BlockStateInterface.get(src.up(2)).getBlock(); - if (!(srcUp instanceof BlockFalling) || !(srcUp2 instanceof BlockFalling)) { + if (!(BlockStateInterface.getBlock(x, y + 1, z) instanceof BlockFalling) || !(BlockStateInterface.getBlock(x, y + 2, z) instanceof BlockFalling)) { // if both of those are BlockFalling, that means that by standing on src // (the presupposition of this Movement) // we have necessarily already cleared the entire BlockFalling stack @@ -109,15 +115,38 @@ public class MovementAscend extends Movement { // it's possible srcUp is AIR from the start, and srcUp2 is falling // and in that scenario, when we arrive and break srcUp2, that lets srcUp3 fall on us and suffocate us } - double walk = WALK_ONE_BLOCK_COST; - if (jumpingToBottomSlab && !jumpingFromBottomSlab) { - return walk + getTotalHardnessOfBlocksToBreak(context); // we don't hit space we just walk into the slab + double walk; + if (jumpingToBottomSlab) { + if (jumpingFromBottomSlab) { + walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST); // we hit space immediately on entering this action + } else { + walk = WALK_ONE_BLOCK_COST; // we don't hit space we just walk into the slab + } + } else { + if (toPlace.getBlock() == Blocks.SOUL_SAND) { + walk = WALK_ONE_OVER_SOUL_SAND_COST; + } else { + walk = WALK_ONE_BLOCK_COST; + } } - if (!jumpingToBottomSlab && toPlace.getBlock().equals(Blocks.SOUL_SAND)) { - walk *= WALK_ONE_OVER_SOUL_SAND_COST / WALK_ONE_BLOCK_COST; + + // cracks knuckles + + double totalCost = 0; + totalCost += walk; + if (hasToPlace) { + totalCost += context.placeBlockCost(); } - // we hit space immediately on entering this action - return Math.max(JUMP_ONE_BLOCK_COST, walk) + getTotalHardnessOfBlocksToBreak(context); + totalCost += MovementHelper.getMiningDurationTicks(context, x, y + 2, z, false); // TODO MAKE ABSOLUTELY SURE we don't need includeFalling here, from the falling check above + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, false); + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 2, destZ, true); + return totalCost; } @Override diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 6e0c7297..ff55c7d8 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -98,6 +98,9 @@ public class BlockStateInterface implements Helper { return get(pos).getBlock(); } + public static Block getBlock(int x, int y, int z) { + return get(x, y, z).getBlock(); + } /** * Returns whether or not the specified block is From 3c4708fef769d328a66f643a91d94201c47c37ba Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:46:18 -0700 Subject: [PATCH 234/329] performance is key --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2c82200..f0e17d21 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![License](https://img.shields.io/github/license/cabaletta/baritone.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) -A Minecraft pathfinder bot. 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. +A Minecraft pathfinder bot. 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 20x faster than MineBot at calculating paths). Features From 2d3cdddc511a9e17ea908e88f8896b7ab6ddd7a4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:48:33 -0700 Subject: [PATCH 235/329] why do i even do this --- .../pathing/movement/movements/MovementAscend.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 9549fe04..6d313c48 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -96,11 +96,12 @@ public class MovementAscend extends Movement { return COST_INF; } } + IBlockState srcUp2 = null; if (BlockStateInterface.get(x, y + 3, z).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us // HOWEVER, we assume that we're standing in the start position // that means that src and src.up(1) are both air // maybe they aren't now, but they will be by the time this starts - if (!(BlockStateInterface.getBlock(x, y + 1, z) instanceof BlockFalling) || !(BlockStateInterface.getBlock(x, y + 2, z) instanceof BlockFalling)) { + if (!(BlockStateInterface.getBlock(x, y + 1, z) instanceof BlockFalling) || !((srcUp2 = BlockStateInterface.get(x, y + 2, z)).getBlock() instanceof BlockFalling)) { // if both of those are BlockFalling, that means that by standing on src // (the presupposition of this Movement) // we have necessarily already cleared the entire BlockFalling stack @@ -137,7 +138,10 @@ public class MovementAscend extends Movement { if (hasToPlace) { totalCost += context.placeBlockCost(); } - totalCost += MovementHelper.getMiningDurationTicks(context, x, y + 2, z, false); // TODO MAKE ABSOLUTELY SURE we don't need includeFalling here, from the falling check above + if (srcUp2 == null) { + srcUp2 = BlockStateInterface.get(x, y + 2, z); + } + totalCost += MovementHelper.getMiningDurationTicks(context, x, y + 2, z, srcUp2, false); // TODO MAKE ABSOLUTELY SURE we don't need includeFalling here, from the falling check above if (totalCost >= COST_INF) { return COST_INF; } From 1b576eca2850e080f1c84d4c078bee4f9d20bfb5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 19:58:03 -0700 Subject: [PATCH 236/329] MovementDescend --- .../movement/movements/MovementDescend.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 85f7f110..dc0f2e0a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -45,14 +45,18 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + return cost(context, src.x, src.y, src.z, dest.x, dest.z); + } + + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return COST_INF; } - if (!MovementHelper.canWalkOn(positionToPlace)) { + if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) { return COST_INF; } - Block tmp1 = BlockStateInterface.get(dest).getBlock(); + Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock(); if (tmp1 == Blocks.LADDER || tmp1 == Blocks.VINE) { return COST_INF; } @@ -62,7 +66,17 @@ public class MovementDescend extends Movement { // use this ratio to apply the soul sand speed penalty to our 0.8 block distance walk = WALK_ONE_OVER_SOUL_SAND_COST; } - return walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST) + getTotalHardnessOfBlocksToBreak(context); + double totalCost = walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, false); + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y, destZ, false); + if (totalCost >= COST_INF) { + return COST_INF; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, true); // only the top block in the 3 we need to mine needs to consider the falling blocks above + return totalCost; } @Override From 0d0eefec9c82e1d0e4f00b71cccfe45342c15f04 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Sep 2018 22:00:28 -0700 Subject: [PATCH 237/329] s a n i k --- .../pathing/calc/AStarPathFinder.java | 65 +---- .../baritone/pathing/calc/MoveResult.java | 32 ++ .../java/baritone/pathing/calc/Moves.java | 274 ++++++++++++++++++ src/main/java/baritone/pathing/calc/Path.java | 12 +- .../java/baritone/pathing/calc/PathNode.java | 8 - .../pathing/movement/MovementHelper.java | 10 +- .../movement/movements/MovementDescend.java | 99 ++++++- .../movement/movements/MovementDiagonal.java | 33 ++- .../movement/movements/MovementDownward.java | 10 +- .../movement/movements/MovementFall.java | 60 +--- .../movement/movements/MovementTraverse.java | 38 ++- .../utils/ExampleBaritoneControl.java | 10 +- .../utils/pathing/BetterBlockPos.java | 20 ++ 13 files changed, 489 insertions(+), 182 deletions(-) create mode 100644 src/main/java/baritone/pathing/calc/MoveResult.java create mode 100644 src/main/java/baritone/pathing/calc/Moves.java diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index f5c3eacd..410b5a3f 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -24,16 +24,12 @@ import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; -import baritone.pathing.movement.Movement; -import baritone.pathing.movement.MovementHelper; -import baritone.pathing.movement.movements.*; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ChunkProviderClient; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import java.util.Collection; @@ -45,7 +41,7 @@ import java.util.Optional; * * @author leijurv */ -public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { +public final class AStarPathFinder extends AbstractNodeCostSearch implements Helper { private final Optional> favoredPositions; @@ -104,12 +100,14 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); return Optional.of(new Path(startNode, currentNode, numNodes, goal)); } - Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos - for (Movement movementToGetToNeighbor : possibleMovements) { - if (movementToGetToNeighbor == null) { + for (Moves moves : Moves.values()) { + MoveResult res = moves.apply(calcContext, currentNodePos.x, currentNodePos.y, currentNodePos.z); + numMovementsConsidered++; + double actionCost = res.cost; + if (actionCost >= ActionCosts.COST_INF) { continue; } - BetterBlockPos dest = movementToGetToNeighbor.getDest(); + BetterBlockPos dest = new BetterBlockPos(res.destX, res.destY, res.destZ); int chunkX = currentNodePos.x >> 4; int chunkZ = currentNodePos.z >> 4; if (dest.x >> 4 != chunkX || dest.z >> 4 != chunkZ) { @@ -122,14 +120,11 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { } } } - // TODO cache cost - double actionCost = movementToGetToNeighbor.getCost(calcContext); - numMovementsConsidered++; if (actionCost >= ActionCosts.COST_INF) { continue; } if (actionCost <= 0) { - throw new IllegalStateException(movementToGetToNeighbor.getClass() + " " + movementToGetToNeighbor + " calculated implausible cost " + actionCost); + throw new IllegalStateException(moves + " calculated implausible cost " + actionCost); } if (favoring && favored.contains(dest)) { // see issue #18 @@ -139,7 +134,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { double tentativeCost = currentNode.cost + actionCost; if (tentativeCost < neighbor.cost) { if (tentativeCost < 0) { - throw new IllegalStateException(movementToGetToNeighbor.getClass() + " " + movementToGetToNeighbor + " overflowed into negative " + actionCost + " " + neighbor.cost + " " + tentativeCost); + throw new IllegalStateException(moves + " overflowed into negative " + actionCost + " " + neighbor.cost + " " + tentativeCost); } double improvementBy = neighbor.cost - tentativeCost; // there are floating point errors caused by random combinations of traverse and diagonal over a flat area @@ -150,7 +145,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { continue; } neighbor.previous = currentNode; - neighbor.previousMovement = movementToGetToNeighbor; neighbor.cost = tentativeCost; neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal; if (neighbor.isOpen) { @@ -203,45 +197,4 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { logDebug("No path found =("); return Optional.empty(); } - - - public static Movement[] getConnectedPositions(BetterBlockPos pos, CalculationContext calcContext) { - int x = pos.x; - int y = pos.y; - int z = pos.z; - BetterBlockPos east = new BetterBlockPos(x + 1, y, z); - BetterBlockPos west = new BetterBlockPos(x - 1, y, z); - BetterBlockPos south = new BetterBlockPos(x, y, z + 1); - BetterBlockPos north = new BetterBlockPos(x, y, z - 1); - return new Movement[]{ - new MovementDownward(pos, new BetterBlockPos(x, y - 1, z)), - - new MovementPillar(pos, new BetterBlockPos(x, y + 1, z)), - - new MovementTraverse(pos, east), - new MovementTraverse(pos, west), - new MovementTraverse(pos, north), - new MovementTraverse(pos, south), - - new MovementAscend(pos, new BetterBlockPos(x + 1, y + 1, z)), - new MovementAscend(pos, new BetterBlockPos(x - 1, y + 1, z)), - new MovementAscend(pos, new BetterBlockPos(x, y + 1, z + 1)), - new MovementAscend(pos, new BetterBlockPos(x, y + 1, z - 1)), - - MovementHelper.generateMovementFallOrDescend(pos, east, calcContext), - MovementHelper.generateMovementFallOrDescend(pos, west, calcContext), - MovementHelper.generateMovementFallOrDescend(pos, north, calcContext), - MovementHelper.generateMovementFallOrDescend(pos, south, calcContext), - - new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.EAST), - new MovementDiagonal(pos, EnumFacing.NORTH, EnumFacing.WEST), - new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.EAST), - new MovementDiagonal(pos, EnumFacing.SOUTH, EnumFacing.WEST), - - MovementParkour.generate(pos, EnumFacing.EAST, calcContext), - MovementParkour.generate(pos, EnumFacing.WEST, calcContext), - MovementParkour.generate(pos, EnumFacing.NORTH, calcContext), - MovementParkour.generate(pos, EnumFacing.SOUTH, calcContext), - }; - } } diff --git a/src/main/java/baritone/pathing/calc/MoveResult.java b/src/main/java/baritone/pathing/calc/MoveResult.java new file mode 100644 index 00000000..e9c6caa9 --- /dev/null +++ b/src/main/java/baritone/pathing/calc/MoveResult.java @@ -0,0 +1,32 @@ +/* + * 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.pathing.calc; + +public final class MoveResult { + public final int destX; + public final int destY; + public final int destZ; + public final double cost; + + public MoveResult(int x, int y, int z, double cost) { + this.destX = x; + this.destY = y; + this.destZ = z; + this.cost = cost; + } +} diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/calc/Moves.java new file mode 100644 index 00000000..dd949610 --- /dev/null +++ b/src/main/java/baritone/pathing/calc/Moves.java @@ -0,0 +1,274 @@ +/* + * 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.pathing.calc; + +import baritone.pathing.movement.CalculationContext; +import baritone.pathing.movement.Movement; +import baritone.pathing.movement.movements.*; +import baritone.utils.pathing.BetterBlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Tuple; + +public enum Moves { + DOWNWARD() { + @Override + protected Movement apply0(BetterBlockPos src) { // TODO specific return types + return new MovementDownward(src, src.down()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y - 1, z, MovementDownward.cost(context, x, y, z)); + } + }, + + PILLAR() { + @Override + protected Movement apply0(BetterBlockPos src) { // TODO specific return types + return new MovementPillar(src, src.up()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y + 1, z, MovementPillar.cost(context, x, y, z)); + } + }, + + TRAVERSE_NORTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementTraverse(src, src.north()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y, z - 1, MovementTraverse.cost(context, x, y, z, x, z - 1)); + } + }, + + TRAVERSE_SOUTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementTraverse(src, src.south()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y, z + 1, MovementTraverse.cost(context, x, y, z, x, z + 1)); + } + }, + + TRAVERSE_EAST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementTraverse(src, src.east()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x + 1, y, z, MovementTraverse.cost(context, x, y, z, x + 1, z)); + } + }, + + TRAVERSE_WEST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementTraverse(src, src.west()); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x - 1, y, z, MovementTraverse.cost(context, x, y, z, x - 1, z)); + } + }, + + ASCEND_NORTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z - 1)); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y + 1, z - 1, MovementAscend.cost(context, x, y, z, x, z - 1)); + } + }, + + ASCEND_SOUTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z + 1)); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y + 1, z + 1, MovementAscend.cost(context, x, y, z, x, z + 1)); + } + }, + + ASCEND_EAST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementAscend(src, new BetterBlockPos(src.x + 1, src.y + 1, src.z)); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y + 1, z + 1, MovementAscend.cost(context, x, y, z, x + 1, z)); + } + }, + + ASCEND_WEST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementAscend(src, new BetterBlockPos(src.x - 1, src.y + 1, src.z)); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x, y + 1, z - 1, MovementAscend.cost(context, x, y, z, x - 1, z)); + } + }, + + DESCEND_EAST() { + @Override + protected Movement apply0(BetterBlockPos src) { + MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); + if (res.destY == src.y - 1) { + return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } else { + return new MovementFall(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple res = MovementDescend.cost(context, x, y, z, x + 1, z); + return new MoveResult(x + 1, res.getFirst(), z, res.getSecond()); + } + }, + + DESCEND_WEST() { + @Override + protected Movement apply0(BetterBlockPos src) { + MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); + if (res.destY == src.y - 1) { + return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } else { + return new MovementFall(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple res = MovementDescend.cost(context, x, y, z, x - 1, z); + return new MoveResult(x - 1, res.getFirst(), z, res.getSecond()); + } + }, + + DESCEND_NORTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); + if (res.destY == src.y - 1) { + return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } else { + return new MovementFall(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple res = MovementDescend.cost(context, x, y, z, x, z - 1); + return new MoveResult(x, res.getFirst(), z - 1, res.getSecond()); + } + }, + + DESCEND_SOUTH() { + @Override + protected Movement apply0(BetterBlockPos src) { + MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); + if (res.destY == src.y - 1) { + return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } else { + return new MovementFall(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); + } + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple res = MovementDescend.cost(context, x, y, z, x, z + 1); + return new MoveResult(x, res.getFirst(), z + 1, res.getSecond()); + } + }, + + DIAGONAL_NORTHEAST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.EAST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x + 1, y, z - 1, MovementDiagonal.cost(context, x, y, z, x + 1, z - 1)); + } + }, + + DIAGONAL_NORTHWEST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.WEST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x - 1, y, z - 1, MovementDiagonal.cost(context, x, y, z, x - 1, z - 1)); + } + }, + + DIAGONAL_SOUTHEAST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.EAST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x + 1, y, z + 1, MovementDiagonal.cost(context, x, y, z, x + 1, z + 1)); + } + }, + + DIAGONAL_SOUTHWEST() { + @Override + protected Movement apply0(BetterBlockPos src) { + return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.WEST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + return new MoveResult(x - 1, y, z + 1, MovementDiagonal.cost(context, x, y, z, x - 1, z + 1)); + } + }, + // TODO parkour + ; + + protected abstract Movement apply0(BetterBlockPos src); + + + public abstract MoveResult apply(CalculationContext context, int x, int y, int z); +} diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index e94f2fb3..50dd49d7 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -89,7 +89,7 @@ class Path implements IPath { LinkedList tempMovements = new LinkedList<>(); // Instead, do it into a linked list, then convert at the end while (!current.equals(start)) { tempPath.addFirst(current.pos); - tempMovements.addFirst(current.previousMovement); + tempMovements.addFirst(runBackwards(current.previous.pos, current.pos)); current = current.previous; } tempPath.addFirst(start.pos); @@ -100,6 +100,16 @@ class Path implements IPath { movements.addAll(tempMovements); } + private static Movement runBackwards(BetterBlockPos src, BetterBlockPos dest) { // TODO this is horrifying + for (Moves moves : Moves.values()) { + Movement move = moves.apply0(src); + if (move.getDest().equals(dest)) { + return move; + } + } + throw new IllegalStateException("Movement became impossible during calculation " + src + " " + dest + " " + dest.subtract(src)); + } + /** * Performs a series of checks to ensure that the assembly of the path went as expected. */ diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 8f9895d8..50283cf9 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -19,7 +19,6 @@ package baritone.pathing.calc; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; -import baritone.pathing.movement.Movement; import baritone.utils.pathing.BetterBlockPos; /** @@ -62,12 +61,6 @@ public final class PathNode { */ PathNode previous; - /** - * In the graph search, what previous movement (edge) was taken to get to here - * Mutable and changed by PathFinder - */ - Movement previousMovement; - /** * Is this a member of the open set in A*? (only used during pathfinding) * Instead of doing a costly member check in the open set, cache membership in each node individually too. @@ -85,7 +78,6 @@ public final class PathNode { this.cost = ActionCosts.COST_INF; this.goal = goal; this.estimatedCostToGoal = goal.heuristic(pos); - this.previousMovement = null; this.isOpen = false; } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1f8b9d49..b1be71fd 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -462,15 +462,7 @@ public interface MovementHelper extends ActionCosts, Helper { } static Movement generateMovementFallOrDescend(BetterBlockPos pos, BetterBlockPos dest, CalculationContext calcContext) { - // A - //SA - // A - // B - // C - // D - //if S is where you start, B needs to be air for a movementfall - //A is plausibly breakable by either descend or fall - //C, D, etc determine the length of the fall + int x = dest.x; int y = dest.y; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index dc0f2e0a..275344e4 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -17,6 +17,7 @@ package baritone.pathing.movement.movements; +import baritone.Baritone; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; @@ -26,11 +27,16 @@ import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; public class MovementDescend extends Movement { + private static final Tuple IMPOSSIBLE = new Tuple<>(0, COST_INF); + private int numTicks = 0; public MovementDescend(BetterBlockPos start, BetterBlockPos end) { @@ -45,38 +51,103 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - return cost(context, src.x, src.y, src.z, dest.x, dest.z); + Tuple result = cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.getFirst() != dest.y) { + return COST_INF; // doesn't apply to us, this position is a fall not a descend + } + return result.getSecond(); } - public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + public static Tuple cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { - return COST_INF; + return IMPOSSIBLE; } + + double totalCost = 0; + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, false); + if (totalCost >= COST_INF) { + return IMPOSSIBLE; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y, destZ, false); + if (totalCost >= COST_INF) { + return IMPOSSIBLE; + } + totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, true); // only the top block in the 3 we need to mine needs to consider the falling blocks above + if (totalCost >= COST_INF) { + return IMPOSSIBLE; + } + + // A + //SA + // A + // B + // C + // D + //if S is where you start, B needs to be air for a movementfall + //A is plausibly breakable by either descend or fall + //C, D, etc determine the length of the fall if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) { - return COST_INF; + return dynamicFallCost(context, x, y, z, destX, destZ, totalCost); } + Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock(); if (tmp1 == Blocks.LADDER || tmp1 == Blocks.VINE) { - return COST_INF; + return IMPOSSIBLE; } + // we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel) double walk = WALK_OFF_BLOCK_COST; if (fromDown == Blocks.SOUL_SAND) { // use this ratio to apply the soul sand speed penalty to our 0.8 block distance walk = WALK_ONE_OVER_SOUL_SAND_COST; } - double totalCost = walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); - totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, false); - if (totalCost >= COST_INF) { - return COST_INF; + totalCost += walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); + return new Tuple<>(y - 1, totalCost); + } + + public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak) { + if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { + // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall + // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, + // and potentially replace the water we're going to fall into + return IMPOSSIBLE; } - totalCost += MovementHelper.getMiningDurationTicks(context, destX, y, destZ, false); - if (totalCost >= COST_INF) { - return COST_INF; + for (int fallHeight = 3; true; fallHeight++) { + int newY = y - fallHeight; + if (newY < 0) { + // when pathing in the end, where you could plausibly fall into the void + // this check prevents it from getting the block at y=-1 and crashing + return IMPOSSIBLE; + } + IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ); + double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak; + if (ontoBlock.getBlock() == Blocks.WATER) { // TODO flowing check required here? + if (Baritone.settings().assumeWalkOnWater.get()) { + return IMPOSSIBLE; // TODO fix + } + // found a fall into water + return new Tuple<>(newY, tentativeCost); // TODO incorporate water swim up cost? + } + if (MovementHelper.canWalkThrough(destX, newY, destZ, ontoBlock)) { + continue; + } + if (!MovementHelper.canWalkOn(destX, newY, destZ, ontoBlock)) { + return IMPOSSIBLE; + } + if (MovementHelper.isBottomSlab(ontoBlock)) { + return IMPOSSIBLE; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect + } + if (context.hasWaterBucket() && fallHeight <= context.maxFallHeightBucket() + 1) { + return new Tuple<>(newY + 1, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 + } + if (fallHeight <= context.maxFallHeightNoWater() + 1) { + // fallHeight = 4 means onto.up() is 3 blocks down, which is the max + return new Tuple<>(newY + 1, tentativeCost); + } else { + return IMPOSSIBLE; + } } - totalCost += MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, true); // only the top block in the 3 we need to mine needs to consider the falling blocks above - return totalCost; } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index d092b66e..5a5b736a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -53,40 +53,43 @@ public class MovementDiagonal extends Movement { @Override protected double calculateCost(CalculationContext context) { - Block fromDown = BlockStateInterface.get(src.down()).getBlock(); + return cost(context, src.x, src.y, src.z, dest.x, dest.z); + } + + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return COST_INF; } - if (!MovementHelper.canWalkThrough(positionsToBreak[4]) || !MovementHelper.canWalkThrough(positionsToBreak[5])) { + if (!MovementHelper.canWalkThrough(destX, y, destZ) || !MovementHelper.canWalkThrough(destX, y + 1, destZ)) { return COST_INF; } - BetterBlockPos destDown = dest.down(); - IBlockState destWalkOn = BlockStateInterface.get(destDown); - if (!MovementHelper.canWalkOn(destDown, destWalkOn)) { + IBlockState destWalkOn = BlockStateInterface.get(destX, y - 1, destZ); + if (!MovementHelper.canWalkOn(destX, y - 1, destZ, destWalkOn)) { return COST_INF; } double multiplier = WALK_ONE_BLOCK_COST; // For either possible soul sand, that affects half of our walking - if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) { + if (destWalkOn.getBlock() == Blocks.SOUL_SAND) { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } if (fromDown == Blocks.SOUL_SAND) { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } - Block cuttingOver1 = BlockStateInterface.get(positionsToBreak[2].down()).getBlock(); + Block cuttingOver1 = BlockStateInterface.get(x, y - 1, destZ).getBlock(); if (cuttingOver1 instanceof BlockMagma || BlockStateInterface.isLava(cuttingOver1)) { return COST_INF; } - Block cuttingOver2 = BlockStateInterface.get(positionsToBreak[4].down()).getBlock(); + Block cuttingOver2 = BlockStateInterface.get(destX, y - 1, z).getBlock(); if (cuttingOver2 instanceof BlockMagma || BlockStateInterface.isLava(cuttingOver2)) { return COST_INF; } - IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); - IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); - IBlockState pb2 = BlockStateInterface.get(positionsToBreak[2]); - IBlockState pb3 = BlockStateInterface.get(positionsToBreak[3]); - double optionA = MovementHelper.getMiningDurationTicks(context, positionsToBreak[0], pb0, false) + MovementHelper.getMiningDurationTicks(context, positionsToBreak[1], pb1, true); - double optionB = MovementHelper.getMiningDurationTicks(context, positionsToBreak[2], pb2, false) + MovementHelper.getMiningDurationTicks(context, positionsToBreak[3], pb3, true); + IBlockState pb0 = BlockStateInterface.get(x, y, destZ); + IBlockState pb1 = BlockStateInterface.get(x, y + 1, destZ); + IBlockState pb2 = BlockStateInterface.get(destX, y, z); + IBlockState pb3 = BlockStateInterface.get(destX, y + 1, z); + double optionA = MovementHelper.getMiningDurationTicks(context, x, y, destZ, pb0, false) + MovementHelper.getMiningDurationTicks(context, x, y + 1, destZ, pb1, true); + double optionB = MovementHelper.getMiningDurationTicks(context, destX, y, z, pb2, false) + MovementHelper.getMiningDurationTicks(context, destX, y + 1, z, pb3, true); if (optionA != 0 && optionB != 0) { return COST_INF; } @@ -100,7 +103,7 @@ public class MovementDiagonal extends Movement { return COST_INF; } } - if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) { + if (BlockStateInterface.isWater(BlockStateInterface.getBlock(x, y, z)) || BlockStateInterface.isWater(BlockStateInterface.getBlock(destX, y, destZ))) { // Ignore previous multiplier // Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water // Not even touching the blocks below diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index b265ddd7..148dc3b3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -43,17 +43,21 @@ public class MovementDownward extends Movement { @Override protected double calculateCost(CalculationContext context) { - if (!MovementHelper.canWalkOn(dest.down())) { + return cost(context, src.x, src.y, src.z); + } + + public static double cost(CalculationContext context, int x, int y, int z) { + if (!MovementHelper.canWalkOn(x, y - 2, z)) { return COST_INF; } - IBlockState d = BlockStateInterface.get(dest); + IBlockState d = BlockStateInterface.get(x, y - 1, z); Block td = d.getBlock(); boolean ladder = td == Blocks.LADDER || td == Blocks.VINE; if (ladder) { return LADDER_DOWN_ONE_COST; } else { // we're standing on it, while it might be block falling, it'll be air by the time we get here in the movement - return FALL_N_BLOCKS_COST[1] + MovementHelper.getMiningDurationTicks(context, dest, d, false); + return FALL_N_BLOCKS_COST[1] + MovementHelper.getMiningDurationTicks(context, x, y - 1, z, d, false); } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index a6a9e9f6..8ff11591 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -26,13 +26,10 @@ import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; @@ -48,58 +45,11 @@ public class MovementFall extends Movement { @Override protected double calculateCost(CalculationContext context) { - Block fromDown = BlockStateInterface.get(src.down()).getBlock(); - if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { - return COST_INF; + Tuple result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.getFirst() != dest.y) { + return COST_INF; // doesn't apply to us, this position is a descend not a fall } - IBlockState fallOnto = BlockStateInterface.get(dest.down()); - if (!MovementHelper.canWalkOn(dest.down(), fallOnto)) { - return COST_INF; - } - if (MovementHelper.isBottomSlab(fallOnto)) { - return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect - } - double placeBucketCost = 0.0; - boolean destIsWater = BlockStateInterface.isWater(dest); - if (!destIsWater && src.getY() - dest.getY() > context.maxFallHeightNoWater()) { - if (!context.hasWaterBucket()) { - return COST_INF; - } - if (src.getY() - dest.getY() > context.maxFallHeightBucket()) { - return COST_INF; - } - placeBucketCost = context.placeBlockCost(); - } - double frontThree = 0; - for (int i = 0; i < 3; i++) { - frontThree += MovementHelper.getMiningDurationTicks(context, positionsToBreak[i], false); - // don't include falling because we will check falling right after this, and if it's there it's COST_INF - if (frontThree >= COST_INF) { - return COST_INF; - } - } - if (BlockStateInterface.get(positionsToBreak[0].up()).getBlock() instanceof BlockFalling) { - return COST_INF; - } - for (int i = 3; i < positionsToBreak.length; i++) { - // TODO is this the right check here? - // MiningDurationTicks is all right, but shouldn't it be canWalkThrough instead? - // Lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage - // Same thing for falling through water... we can't actually do that - // And falling through signs is possible, but they do have a mining duration, right? - if (MovementHelper.getMiningDurationTicks(context, positionsToBreak[i], false) > 0) { - //can't break while falling - - if (i != positionsToBreak.length - 1 || !destIsWater) { - // if we're checking the very last block to mine - // and it's water (so this is a water fall) - // don't consider the cost of "mining" it - // (if assumeWalkOnWater is true, water isn't canWalkThrough) - return COST_INF; - } - } - } - return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontThree; + return result.getSecond(); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index a2d64377..232a8376 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -57,11 +57,15 @@ public class MovementTraverse extends Movement { @Override protected double calculateCost(CalculationContext context) { - IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); - IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); - IBlockState destOn = BlockStateInterface.get(positionToPlace); - Block srcDown = BlockStateInterface.getBlock(src.down()); - if (MovementHelper.canWalkOn(positionToPlace, destOn)) {//this is a walk, not a bridge + return cost(context, src.x, src.y, src.z, dest.x, dest.z); + } + + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + IBlockState pb0 = BlockStateInterface.get(destX, y + 1, destZ); + IBlockState pb1 = BlockStateInterface.get(destX, y, destZ); + IBlockState destOn = BlockStateInterface.get(destX, y - 1, destZ); + Block srcDown = BlockStateInterface.getBlock(x, y - 1, z); + if (MovementHelper.canWalkOn(destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge double WC = WALK_ONE_BLOCK_COST; if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) { WC = WALK_ONE_IN_WATER_COST; @@ -73,11 +77,11 @@ public class MovementTraverse extends Movement { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } } - double hardness1 = MovementHelper.getMiningDurationTicks(context, positionsToBreak[0], pb0, true); + double hardness1 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true); if (hardness1 >= COST_INF) { return COST_INF; } - double hardness2 = MovementHelper.getMiningDurationTicks(context, positionsToBreak[1], pb1, false); + double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y, destZ, pb1, false); if (hardness1 == 0 && hardness2 == 0) { if (WC == WALK_ONE_BLOCK_COST && context.canSprint()) { // If there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing @@ -95,7 +99,7 @@ public class MovementTraverse extends Movement { if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) { return COST_INF; } - if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(positionToPlace, destOn)) { + if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(destX, y - 1, destZ, destOn)) { boolean throughWater = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()); if (BlockStateInterface.isWater(destOn.getBlock()) && throughWater) { return COST_INF; @@ -103,15 +107,21 @@ public class MovementTraverse extends Movement { if (!context.hasThrowaway()) { return COST_INF; } + double hardness1 = MovementHelper.getMiningDurationTicks(context, destX, y, destZ, pb0, false); + if (hardness1 >= COST_INF) { + return COST_INF; + } + double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb1, true); + double WC = throughWater ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST; for (int i = 0; i < 4; i++) { - BlockPos against1 = dest.offset(HORIZONTALS[i]); - if (against1.equals(src)) { + int againstX = destX + HORIZONTALS[i].getXOffset(); + int againstZ = destZ + HORIZONTALS[i].getZOffset(); + if (againstX == x && againstZ == z) { continue; } - against1 = against1.down(); - if (MovementHelper.canPlaceAgainst(against1)) { - return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); + if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) { + return WC + context.placeBlockCost() + hardness1 + hardness2; } } if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) { @@ -121,7 +131,7 @@ public class MovementTraverse extends Movement { return COST_INF; // this is obviously impossible } WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are placing, we are sneaking - return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context); + return WC + context.placeBlockCost() + hardness1 + hardness2; } return COST_INF; // Out.log("Can't walk on " + Baritone.get(positionsToPlace[0]).getBlock()); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 6cd2655a..19a33f32 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -27,14 +27,9 @@ import baritone.behavior.PathingBehavior; import baritone.cache.ChunkPacker; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; -import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.goals.*; -import baritone.pathing.movement.ActionCosts; -import baritone.pathing.movement.CalculationContext; -import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; -import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.entity.Entity; @@ -433,7 +428,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - if (msg.equals("costs")) { + // TODO + /*if (msg.equals("costs")) { Movement[] movements = AStarPathFinder.getConnectedPositions(new BetterBlockPos(playerFeet()), new CalculationContext()); List moves = new ArrayList<>(Arrays.asList(movements)); while (moves.contains(null)) { @@ -451,6 +447,6 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } event.cancel(); return; - } + }*/ } } diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index e46b27dc..09727b84 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -134,4 +134,24 @@ public final class BetterBlockPos extends BlockPos { Vec3i vec = dir.getDirectionVec(); return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); } + + @Override + public BetterBlockPos north() { + return new BetterBlockPos(x, y, z - 1); + } + + @Override + public BetterBlockPos south() { + return new BetterBlockPos(x, y, z + 1); + } + + @Override + public BetterBlockPos east() { + return new BetterBlockPos(x + 1, y, z); + } + + @Override + public BetterBlockPos west() { + return new BetterBlockPos(x - 1, y, z); + } } From 65a59cb73921e2bbcf02cca0b75be20f1f66ce73 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 08:05:59 -0700 Subject: [PATCH 238/329] add bench link --- src/main/java/baritone/utils/BlockStateInterface.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index ff55c7d8..c5d076ea 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -58,6 +58,7 @@ public class BlockStateInterface implements Helper { // if it's the same chunk as last time // we can just skip the mc.world.getChunk lookup // which is a Long2ObjectOpenHashMap.get + // see issue #113 if (cached != null && cached.x == x >> 4 && cached.z == z >> 4) { return cached.getBlockState(x, y, z); } From 7fa6e001e61060576b3890bc8c9114fa7878eaf2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 08:13:21 -0700 Subject: [PATCH 239/329] don't cause exception on main thread if a movement becomes impossible --- .../pathing/calc/AbstractNodeCostSearch.java | 14 ++++++++++++-- src/main/java/baritone/pathing/calc/Path.java | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 012c257c..3b8108d8 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -147,7 +147,12 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { @Override public Optional pathToMostRecentNodeConsidered() { - return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); + try { + return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal)); + } catch (IllegalStateException ex) { + System.out.println("Unable to construct path to render"); + return Optional.empty(); + } } protected int mapSize() { @@ -164,7 +169,12 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { continue; } if (getDistFromStartSq(bestSoFar[i]) > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - return Optional.of(new Path(startNode, bestSoFar[i], 0, goal)); + try { + return Optional.of(new Path(startNode, bestSoFar[i], 0, goal)); + } catch (IllegalStateException ex) { + System.out.println("Unable to construct path to render"); + return Optional.empty(); + } } } // instead of returning bestSoFar[0], be less misleading diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 50dd49d7..c429970b 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -107,6 +107,7 @@ class Path implements IPath { return move; } } + // leave this as IllegalStateException; it's caught in AbstractNodeCostSearch throw new IllegalStateException("Movement became impossible during calculation " + src + " " + dest + " " + dest.subtract(src)); } From 23c11a5170912c37255467984e98b2cf57ea787a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 08:52:03 -0700 Subject: [PATCH 240/329] finish moving away from betterblockpos in path calculation --- src/main/java/baritone/cache/CachedWorld.java | 8 ++-- .../pathing/calc/AStarPathFinder.java | 40 ++++++++-------- .../pathing/calc/AbstractNodeCostSearch.java | 32 ++++++++++--- .../java/baritone/pathing/calc/Moves.java | 48 +++++++++++-------- src/main/java/baritone/pathing/calc/Path.java | 14 +++--- .../java/baritone/pathing/calc/PathNode.java | 26 +++++----- .../java/baritone/pathing/goals/Goal.java | 14 ++++-- .../java/baritone/pathing/goals/GoalAxis.java | 13 ++--- .../baritone/pathing/goals/GoalBlock.java | 12 ++--- .../baritone/pathing/goals/GoalComposite.java | 14 ++++-- .../pathing/goals/GoalGetToBlock.java | 16 +++---- .../java/baritone/pathing/goals/GoalNear.java | 20 ++++---- .../baritone/pathing/goals/GoalRunAway.java | 10 ++-- .../baritone/pathing/goals/GoalTwoBlocks.java | 12 ++--- .../java/baritone/pathing/goals/GoalXZ.java | 11 ++--- .../baritone/pathing/goals/GoalYLevel.java | 10 ++-- .../utils/pathing/BetterBlockPos.java | 18 +------ 17 files changed, 166 insertions(+), 152 deletions(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 91a70d48..393c93fb 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -91,14 +91,12 @@ public final class CachedWorld implements Helper { } } - public final boolean isCached(BlockPos pos) { - int x = pos.getX(); - int z = pos.getZ(); - CachedRegion region = getRegion(x >> 9, z >> 9); + public final boolean isCached(int blockX, int blockZ) { + CachedRegion region = getRegion(blockX >> 9, blockZ >> 9); if (region == null) { return false; } - return region.isCached(x & 511, z & 511); + return region.isCached(blockX & 511, blockZ & 511); } public final LinkedList getLocationsOf(String block, int minimum, int maxRegionDistanceSq) { diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 410b5a3f..ef44793d 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -35,6 +35,7 @@ import net.minecraft.util.math.BlockPos; import java.util.Collection; import java.util.HashSet; import java.util.Optional; +import java.util.stream.Collectors; /** * The actual A* pathfinding @@ -43,16 +44,16 @@ import java.util.Optional; */ public final class AStarPathFinder extends AbstractNodeCostSearch implements Helper { - private final Optional> favoredPositions; + private final Optional> favoredPositions; public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { super(start, goal); - this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic + this.favoredPositions = favoredPositions.map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC } @Override protected Optional calculate0(long timeout) { - startNode = getNodeAtPosition(start); + startNode = getNodeAtPosition(start.x, start.y, start.z); startNode.cost = 0; startNode.combinedCost = startNode.estimatedCostToGoal; BinaryHeapOpenSet openSet = new BinaryHeapOpenSet(); @@ -65,7 +66,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel bestSoFar[i] = startNode; } CalculationContext calcContext = new CalculationContext(); - HashSet favored = favoredPositions.orElse(null); + HashSet favored = favoredPositions.orElse(null); CachedWorld cachedWorld = Optional.ofNullable(WorldProvider.INSTANCE.getCurrentWorld()).map(w -> w.cache).orElse(null); ChunkProviderClient chunkProvider = Minecraft.getMinecraft().world.getChunkProvider(); BlockStateInterface.clearCachedChunk(); @@ -94,43 +95,42 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel PathNode currentNode = openSet.removeLowest(); currentNode.isOpen = false; mostRecentConsidered = currentNode; - BetterBlockPos currentNodePos = currentNode.pos; numNodes++; - if (goal.isInGoal(currentNodePos)) { + if (goal.isInGoal(currentNode.x, currentNode.y, currentNode.z)) { logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered"); return Optional.of(new Path(startNode, currentNode, numNodes, goal)); } for (Moves moves : Moves.values()) { - MoveResult res = moves.apply(calcContext, currentNodePos.x, currentNodePos.y, currentNodePos.z); - numMovementsConsidered++; - double actionCost = res.cost; - if (actionCost >= ActionCosts.COST_INF) { - continue; - } - BetterBlockPos dest = new BetterBlockPos(res.destX, res.destY, res.destZ); - int chunkX = currentNodePos.x >> 4; - int chunkZ = currentNodePos.z >> 4; - if (dest.x >> 4 != chunkX || dest.z >> 4 != chunkZ) { + int newX = currentNode.x + moves.xOffset; + int newZ = currentNode.z + moves.zOffset; + if (newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) { // only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement - if (chunkProvider.isChunkGeneratedAt(chunkX, chunkZ)) { + if (chunkProvider.isChunkGeneratedAt(newX >> 4, newZ >> 4)) { // TODO could also call BlockStateInterface here // see issue #106 - if (cachedWorld == null || !cachedWorld.isCached(dest)) { + if (cachedWorld == null || !cachedWorld.isCached(newX, newZ)) { // TODO isCached could call BlockStateInterface to skip a hashmap lookup numEmptyChunk++; continue; } } } + MoveResult res = moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z); + if (res.destX != newX || res.destZ != newZ) { + throw new IllegalStateException(moves + " " + res.destX + " " + newX + " " + res.destZ + " " + newZ); + } + numMovementsConsidered++; + double actionCost = res.cost; if (actionCost >= ActionCosts.COST_INF) { continue; } + if (actionCost <= 0) { throw new IllegalStateException(moves + " calculated implausible cost " + actionCost); } - if (favoring && favored.contains(dest)) { + if (favoring && favored.contains(posHash(res.destX, res.destY, res.destZ))) { // see issue #18 actionCost *= favorCoeff; } - PathNode neighbor = getNodeAtPosition(dest); + PathNode neighbor = getNodeAtPosition(res.destX, res.destY, res.destZ); double tentativeCost = currentNode.cost + actionCost; if (tentativeCost < neighbor.cost) { if (tentativeCost < 0) { diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 3b8108d8..5c8d0da9 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -115,9 +115,9 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * @return The distance, squared */ protected double getDistFromStartSq(PathNode n) { - int xDiff = n.pos.x - start.x; - int yDiff = n.pos.y - start.y; - int zDiff = n.pos.z - start.z; + int xDiff = n.x - start.x; + int yDiff = n.y - start.y; + int zDiff = n.z - start.z; return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff; } @@ -126,20 +126,38 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * for the node mapped to the specified pos. If no node is found, * a new node is created. * - * @param pos The pos to lookup * @return The associated node * @see Issue #107 */ - protected PathNode getNodeAtPosition(BetterBlockPos pos) { - long hashCode = pos.hashCode; + protected PathNode getNodeAtPosition(int x, int y, int z) { + long hashCode = posHash(x, y, z); PathNode node = map.get(hashCode); if (node == null) { - node = new PathNode(pos, goal); + node = new PathNode(x, y, z, goal); map.put(hashCode, node); } return node; } + public static long posHash(int x, int y, int z) { + /* + * This is the hashcode implementation of Vec3i, the superclass of BlockPos + * + * public int hashCode() { + * return (this.getY() + this.getZ() * 31) * 31 + this.getX(); + * } + * + * That is terrible and has tons of collisions and makes the HashMap terribly inefficient. + * + * That's why we grab out the X, Y, Z and calculate our own hashcode + */ + long hash = 3241; + hash = 3457689L * hash + x; + hash = 8734625L * hash + y; + hash = 2873465L * hash + z; + return hash; + } + public static void forceCancel() { PathingBehavior.INSTANCE.cancel(); currentlyRunning = null; diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/calc/Moves.java index dd949610..2eca0913 100644 --- a/src/main/java/baritone/pathing/calc/Moves.java +++ b/src/main/java/baritone/pathing/calc/Moves.java @@ -25,7 +25,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.Tuple; public enum Moves { - DOWNWARD() { + DOWNWARD(0, 0) { @Override protected Movement apply0(BetterBlockPos src) { // TODO specific return types return new MovementDownward(src, src.down()); @@ -37,7 +37,7 @@ public enum Moves { } }, - PILLAR() { + PILLAR(0, 0) { @Override protected Movement apply0(BetterBlockPos src) { // TODO specific return types return new MovementPillar(src, src.up()); @@ -49,7 +49,7 @@ public enum Moves { } }, - TRAVERSE_NORTH() { + TRAVERSE_NORTH(0, -1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.north()); @@ -61,7 +61,7 @@ public enum Moves { } }, - TRAVERSE_SOUTH() { + TRAVERSE_SOUTH(0, +1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.south()); @@ -73,7 +73,7 @@ public enum Moves { } }, - TRAVERSE_EAST() { + TRAVERSE_EAST(+1, 0) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.east()); @@ -85,7 +85,7 @@ public enum Moves { } }, - TRAVERSE_WEST() { + TRAVERSE_WEST(-1, 0) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.west()); @@ -97,7 +97,7 @@ public enum Moves { } }, - ASCEND_NORTH() { + ASCEND_NORTH(0, -1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z - 1)); @@ -109,7 +109,7 @@ public enum Moves { } }, - ASCEND_SOUTH() { + ASCEND_SOUTH(0, +1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z + 1)); @@ -121,7 +121,7 @@ public enum Moves { } }, - ASCEND_EAST() { + ASCEND_EAST(+1, 0) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x + 1, src.y + 1, src.z)); @@ -129,11 +129,11 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - return new MoveResult(x, y + 1, z + 1, MovementAscend.cost(context, x, y, z, x + 1, z)); + return new MoveResult(x + 1, y + 1, z, MovementAscend.cost(context, x, y, z, x + 1, z)); } }, - ASCEND_WEST() { + ASCEND_WEST(-1, 0) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x - 1, src.y + 1, src.z)); @@ -141,11 +141,11 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - return new MoveResult(x, y + 1, z - 1, MovementAscend.cost(context, x, y, z, x - 1, z)); + return new MoveResult(x - 1, y + 1, z, MovementAscend.cost(context, x, y, z, x - 1, z)); } }, - DESCEND_EAST() { + DESCEND_EAST(+1, 0) { @Override protected Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); @@ -163,7 +163,7 @@ public enum Moves { } }, - DESCEND_WEST() { + DESCEND_WEST(-1, 0) { @Override protected Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); @@ -181,7 +181,7 @@ public enum Moves { } }, - DESCEND_NORTH() { + DESCEND_NORTH(0, -1) { @Override protected Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); @@ -199,7 +199,7 @@ public enum Moves { } }, - DESCEND_SOUTH() { + DESCEND_SOUTH(0, +1) { @Override protected Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); @@ -217,7 +217,7 @@ public enum Moves { } }, - DIAGONAL_NORTHEAST() { + DIAGONAL_NORTHEAST(+1, -1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.EAST); @@ -229,7 +229,7 @@ public enum Moves { } }, - DIAGONAL_NORTHWEST() { + DIAGONAL_NORTHWEST(-1, -1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.WEST); @@ -241,7 +241,7 @@ public enum Moves { } }, - DIAGONAL_SOUTHEAST() { + DIAGONAL_SOUTHEAST(+1, +1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.EAST); @@ -253,7 +253,7 @@ public enum Moves { } }, - DIAGONAL_SOUTHWEST() { + DIAGONAL_SOUTHWEST(-1, +1) { @Override protected Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.WEST); @@ -271,4 +271,12 @@ public enum Moves { public abstract MoveResult apply(CalculationContext context, int x, int y, int z); + + public final int xOffset; + public final int zOffset; + + Moves(int x, int z) { + this.xOffset = x; + this.zOffset = z; + } } diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index c429970b..2ebe4c09 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -60,8 +60,8 @@ class Path implements IPath { private volatile boolean verified; Path(PathNode start, PathNode end, int numNodes, Goal goal) { - this.start = start.pos; - this.end = end.pos; + this.start = new BetterBlockPos(start.x, start.y, start.z); + this.end = new BetterBlockPos(end.x, end.y, end.z); this.numNodes = numNodes; this.path = new ArrayList<>(); this.movements = new ArrayList<>(); @@ -88,11 +88,11 @@ class Path implements IPath { LinkedList tempPath = new LinkedList<>(); // Repeatedly inserting to the beginning of an arraylist is O(n^2) LinkedList tempMovements = new LinkedList<>(); // Instead, do it into a linked list, then convert at the end while (!current.equals(start)) { - tempPath.addFirst(current.pos); - tempMovements.addFirst(runBackwards(current.previous.pos, current.pos)); + tempPath.addFirst(new BetterBlockPos(current.x, current.y, current.z)); + tempMovements.addFirst(runBackwards(current.previous, current)); current = current.previous; } - tempPath.addFirst(start.pos); + tempPath.addFirst(this.start); // Can't directly convert from the PathNode pseudo linked list to an array because we don't know how long it is // inserting into a LinkedList keeps track of length, then when we addall (which calls .toArray) it's able // to performantly do that conversion since it knows the length. @@ -100,7 +100,9 @@ class Path implements IPath { movements.addAll(tempMovements); } - private static Movement runBackwards(BetterBlockPos src, BetterBlockPos dest) { // TODO this is horrifying + private static Movement runBackwards(PathNode src0, PathNode dest0) { // TODO this is horrifying + BetterBlockPos src = new BetterBlockPos(src0.x, src0.y, src0.z); + BetterBlockPos dest = new BetterBlockPos(dest0.x, dest0.y, dest0.z); for (Moves moves : Moves.values()) { Movement move = moves.apply0(src); if (move.getDest().equals(dest)) { diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 50283cf9..48c52ab1 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -19,7 +19,6 @@ package baritone.pathing.calc; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; -import baritone.utils.pathing.BetterBlockPos; /** * A node in the path, containing the cost and steps to get to it. @@ -31,12 +30,9 @@ public final class PathNode { /** * The position of this node */ - final BetterBlockPos pos; - - /** - * The goal it's going towards - */ - final Goal goal; + final int x; + final int y; + final int z; /** * Cached, should always be equal to goal.heuristic(pos) @@ -72,13 +68,14 @@ public final class PathNode { */ public int heapPosition; - public PathNode(BetterBlockPos pos, Goal goal) { - this.pos = pos; + public PathNode(int x, int y, int z, Goal goal) { this.previous = null; this.cost = ActionCosts.COST_INF; - this.goal = goal; - this.estimatedCostToGoal = goal.heuristic(pos); + this.estimatedCostToGoal = goal.heuristic(x, y, z); this.isOpen = false; + this.x = x; + this.y = y; + this.z = z; } /** @@ -88,7 +85,7 @@ public final class PathNode { */ @Override public int hashCode() { - return pos.hashCode() * 7 + 3; + return (x * 935847 + y) * 239761 + z; } @Override @@ -100,8 +97,9 @@ public final class PathNode { // return false; //} - //final PathNode other = (PathNode) obj; + final PathNode other = (PathNode) obj; //return Objects.equals(this.pos, other.pos) && Objects.equals(this.goal, other.goal); - return this.pos.equals(((PathNode) obj).pos); + + return x == other.x && y == other.y && z == other.z; } } diff --git a/src/main/java/baritone/pathing/goals/Goal.java b/src/main/java/baritone/pathing/goals/Goal.java index 7f44d3d5..0f01ca92 100644 --- a/src/main/java/baritone/pathing/goals/Goal.java +++ b/src/main/java/baritone/pathing/goals/Goal.java @@ -31,16 +31,22 @@ public interface Goal extends ActionCosts { * Returns whether or not the specified position * meets the requirement for this goal based. * - * @param pos The position * @return Whether or not it satisfies this goal */ - boolean isInGoal(BlockPos pos); + boolean isInGoal(int x, int y, int z); /** * Estimate the number of ticks it will take to get to the goal * - * @param pos The * @return The estimate number of ticks to satisfy the goal */ - double heuristic(BlockPos pos); + double heuristic(int x, int y, int z); + + default boolean isInGoal(BlockPos pos) { + return isInGoal(pos.getX(), pos.getY(), pos.getZ()); + } + + default double heuristic(BlockPos pos) { + return heuristic(pos.getX(), pos.getY(), pos.getZ()); + } } diff --git a/src/main/java/baritone/pathing/goals/GoalAxis.java b/src/main/java/baritone/pathing/goals/GoalAxis.java index bd8f7c69..a75d2bb7 100644 --- a/src/main/java/baritone/pathing/goals/GoalAxis.java +++ b/src/main/java/baritone/pathing/goals/GoalAxis.java @@ -18,25 +18,20 @@ package baritone.pathing.goals; import baritone.Baritone; -import net.minecraft.util.math.BlockPos; public class GoalAxis implements Goal { private static final double SQRT_2_OVER_2 = Math.sqrt(2) / 2; @Override - public boolean isInGoal(BlockPos pos) { - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); + public boolean isInGoal(int x, int y, int z) { return y == Baritone.settings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); } @Override - public double heuristic(BlockPos pos) { - int x = Math.abs(pos.getX()); - int y = pos.getY(); - int z = Math.abs(pos.getZ()); + public double heuristic(int x0, int y, int z0) { + int x = Math.abs(x0); + int z = Math.abs(z0); int shrt = Math.min(x, z); int lng = Math.max(x, z); diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 82515758..f5cd2dfb 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -53,15 +53,15 @@ public class GoalBlock implements Goal, IGoalRenderPos { } @Override - public boolean isInGoal(BlockPos pos) { - return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z; + public boolean isInGoal(int x, int y, int z) { + return x == this.x && y == this.y && z == this.z; } @Override - public double heuristic(BlockPos pos) { - int xDiff = pos.getX() - this.x; - int yDiff = pos.getY() - this.y; - int zDiff = pos.getZ() - this.z; + public double heuristic(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; return calculate(xDiff, yDiff, zDiff); } diff --git a/src/main/java/baritone/pathing/goals/GoalComposite.java b/src/main/java/baritone/pathing/goals/GoalComposite.java index 12de4d93..b7bb9e6e 100644 --- a/src/main/java/baritone/pathing/goals/GoalComposite.java +++ b/src/main/java/baritone/pathing/goals/GoalComposite.java @@ -49,15 +49,21 @@ public class GoalComposite implements Goal { } @Override - public boolean isInGoal(BlockPos pos) { - return Arrays.stream(this.goals).anyMatch(goal -> goal.isInGoal(pos)); + public boolean isInGoal(int x, int y, int z) { + for (Goal goal : goals) { + if (goal.isInGoal(x, y, z)) { + return true; + } + } + return false; } @Override - public double heuristic(BlockPos pos) { + public double heuristic(int x, int y, int z) { double min = Double.MAX_VALUE; for (Goal g : goals) { - min = Math.min(min, g.heuristic(pos)); // whichever is closest + // TODO technically this isn't admissible...? + min = Math.min(min, g.heuristic(x, y, z)); // whichever is closest } return min; } diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 5acca96c..3ade972f 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -45,10 +45,10 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { } @Override - public boolean isInGoal(BlockPos pos) { - int xDiff = pos.getX() - this.x; - int yDiff = pos.getY() - this.y; - int zDiff = pos.getZ() - this.z; + public boolean isInGoal(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; if (yDiff < 0) { yDiff++; } @@ -56,10 +56,10 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { } @Override - public double heuristic(BlockPos pos) { - int xDiff = pos.getX() - this.x; - int yDiff = pos.getY() - this.y; - int zDiff = pos.getZ() - this.z; + public double heuristic(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; return GoalBlock.calculate(xDiff, yDiff, zDiff); } diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 11c6cd3f..0d0c9c75 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -34,19 +34,19 @@ public class GoalNear implements Goal, IGoalRenderPos { } @Override - public boolean isInGoal(BlockPos pos) { - int diffX = x - pos.getX(); - int diffY = y - pos.getY(); - int diffZ = z - pos.getZ(); - return diffX * diffX + diffY * diffY + diffZ * diffZ <= rangeSq; + public boolean isInGoal(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; + return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff <= rangeSq; } @Override - public double heuristic(BlockPos pos) { - int diffX = x - pos.getX(); - int diffY = y - pos.getY(); - int diffZ = z - pos.getZ(); - return GoalBlock.calculate(diffX, diffY, diffZ); + public double heuristic(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; + return GoalBlock.calculate(xDiff, yDiff, zDiff); } @Override diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/main/java/baritone/pathing/goals/GoalRunAway.java index 0ad49faf..d0702640 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/main/java/baritone/pathing/goals/GoalRunAway.java @@ -41,10 +41,10 @@ public class GoalRunAway implements Goal { } @Override - public boolean isInGoal(BlockPos pos) { + public boolean isInGoal(int x, int y, int z) { for (BlockPos p : from) { - int diffX = pos.getX() - p.getX(); - int diffZ = pos.getZ() - p.getZ(); + int diffX = x - p.getX(); + int diffZ = z - p.getZ(); double distSq = diffX * diffX + diffZ * diffZ; if (distSq < distanceSq) { return false; @@ -54,10 +54,10 @@ public class GoalRunAway implements Goal { } @Override - public double heuristic(BlockPos pos) {//mostly copied from GoalBlock + public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock double min = Double.MAX_VALUE; for (BlockPos p : from) { - double h = GoalXZ.calculate(p.getX() - pos.getX(), p.getZ() - pos.getZ()); + double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z); if (h < min) { min = h; } diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 44a33425..428279a1 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -54,18 +54,18 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { } @Override - public boolean isInGoal(BlockPos pos) { - return pos.getX() == this.x && (pos.getY() == this.y || pos.getY() == this.y - 1) && pos.getZ() == this.z; + public boolean isInGoal(int x, int y, int z) { + return x == this.x && (y == this.y || y == this.y - 1) && z == this.z; } @Override - public double heuristic(BlockPos pos) { - double xDiff = pos.getX() - this.x; - int yDiff = pos.getY() - this.y; + public double heuristic(int x, int y, int z) { + int xDiff = x - this.x; + int yDiff = y - this.y; + int zDiff = z - this.z; if (yDiff < 0) { yDiff++; } - double zDiff = pos.getZ() - this.z; return GoalBlock.calculate(xDiff, yDiff, zDiff); } diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index 3362149c..7f200e64 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -19,7 +19,6 @@ package baritone.pathing.goals; import baritone.Baritone; import baritone.utils.Utils; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -48,14 +47,14 @@ public class GoalXZ implements Goal { } @Override - public boolean isInGoal(BlockPos pos) { - return pos.getX() == x && pos.getZ() == z; + public boolean isInGoal(int x, int y, int z) { + return x == this.x && z == this.z; } @Override - public double heuristic(BlockPos pos) {//mostly copied from GoalBlock - double xDiff = pos.getX() - this.x; - double zDiff = pos.getZ() - this.z; + public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock + int xDiff = x - this.x; + int zDiff = z - this.z; return calculate(xDiff, zDiff); } diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/main/java/baritone/pathing/goals/GoalYLevel.java index f90161d2..2ac46981 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/main/java/baritone/pathing/goals/GoalYLevel.java @@ -17,8 +17,6 @@ package baritone.pathing.goals; -import net.minecraft.util.math.BlockPos; - /** * Useful for mining (getting to diamond / iron level) * @@ -36,13 +34,13 @@ public class GoalYLevel implements Goal { } @Override - public boolean isInGoal(BlockPos pos) { - return pos.getY() == level; + public boolean isInGoal(int x, int y, int z) { + return y == level; } @Override - public double heuristic(BlockPos pos) { - return calculate(level, pos.getY()); + public double heuristic(int x, int y, int z) { + return calculate(level, y); } public static double calculate(int goalY, int currentY) { diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 09727b84..eb85e6bf 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -17,6 +17,7 @@ package baritone.utils.pathing; +import baritone.pathing.calc.AbstractNodeCostSearch; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -42,22 +43,7 @@ public final class BetterBlockPos extends BlockPos { this.x = x; this.y = y; this.z = z; - /* - * This is the hashcode implementation of Vec3i, the superclass of BlockPos - * - * public int hashCode() { - * return (this.getY() + this.getZ() * 31) * 31 + this.getX(); - * } - * - * That is terrible and has tons of collisions and makes the HashMap terribly inefficient. - * - * That's why we grab out the X, Y, Z and calculate our own hashcode - */ - long hash = 3241; - hash = 3457689L * hash + x; - hash = 8734625L * hash + y; - hash = 2873465L * hash + z; - this.hashCode = hash; + this.hashCode = AbstractNodeCostSearch.posHash(x, y, z); } public BetterBlockPos(double x, double y, double z) { From cc01c88dbd4eddcf7c34afd8148b71c3ce73b7a6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 08:54:26 -0700 Subject: [PATCH 241/329] begone betterblockpos --- src/main/java/baritone/behavior/PathingBehavior.java | 6 +++++- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 7 ++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 4a36ce73..d9bb92ba 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -41,8 +41,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; import java.awt.*; +import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Optional; +import java.util.stream.Collectors; public final class PathingBehavior extends Behavior implements Helper { @@ -329,8 +332,9 @@ public final class PathingBehavior extends Behavior implements Helper { } else { timeout = Baritone.settings().planAheadTimeoutMS.get(); } + Optional> favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC try { - IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions)); + IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions); return pf.calculate(timeout); } catch (Exception e) { logDebug("Pathing exception: " + e); diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index ef44793d..37378397 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -27,15 +27,12 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; -import baritone.utils.pathing.BetterBlockPos; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.util.math.BlockPos; -import java.util.Collection; import java.util.HashSet; import java.util.Optional; -import java.util.stream.Collectors; /** * The actual A* pathfinding @@ -46,9 +43,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel private final Optional> favoredPositions; - public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { + public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { super(start, goal); - this.favoredPositions = favoredPositions.map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC + this.favoredPositions = favoredPositions; } @Override From b20f148fa6df8cef7c928604f23335a0ad01411c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 08:58:45 -0700 Subject: [PATCH 242/329] might as well --- src/main/java/baritone/pathing/calc/PathNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 48c52ab1..9b960a83 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -85,7 +85,7 @@ public final class PathNode { */ @Override public int hashCode() { - return (x * 935847 + y) * 239761 + z; + return (int) AbstractNodeCostSearch.posHash(x, y, z); } @Override From 289637a370430e049938848f364f02c15a4a4896 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 09:42:20 -0700 Subject: [PATCH 243/329] what is testing :S --- .../java/baritone/pathing/calc/openset/OpenSetsTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index aebff976..5f7b98d0 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -19,8 +19,6 @@ package baritone.pathing.calc.openset; import baritone.pathing.calc.PathNode; import baritone.pathing.goals.Goal; -import baritone.utils.pathing.BetterBlockPos; -import net.minecraft.util.math.BlockPos; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -91,14 +89,14 @@ public class OpenSetsTest { // can't use an existing goal // because they use Baritone.settings() // and we can't do that because Minecraft itself isn't initted - PathNode pn = new PathNode(new BetterBlockPos(0, 0, 0), new Goal() { + PathNode pn = new PathNode(0, 0, 0, new Goal() { @Override - public boolean isInGoal(BlockPos pos) { + public boolean isInGoal(int x, int y, int z) { return false; } @Override - public double heuristic(BlockPos pos) { + public double heuristic(int x, int y, int z) { return 0; } }); From c623250387eaa2dd21149151270c1ebe405f675b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 10:13:09 -0700 Subject: [PATCH 244/329] no reason to do that actually --- src/main/java/baritone/pathing/calc/Moves.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/calc/Moves.java index 2eca0913..1ff78351 100644 --- a/src/main/java/baritone/pathing/calc/Moves.java +++ b/src/main/java/baritone/pathing/calc/Moves.java @@ -39,7 +39,7 @@ public enum Moves { PILLAR(0, 0) { @Override - protected Movement apply0(BetterBlockPos src) { // TODO specific return types + protected Movement apply0(BetterBlockPos src) { return new MovementPillar(src, src.up()); } From 1a6b7d184ae33b78e376ca6ca464f8054c30f3d0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 10:20:19 -0700 Subject: [PATCH 245/329] cache chunk load check through block state interface --- .../pathing/calc/AStarPathFinder.java | 16 +++---------- .../baritone/utils/BlockStateInterface.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 37378397..d733931f 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -18,8 +18,6 @@ package baritone.pathing.calc; import baritone.Baritone; -import baritone.cache.CachedWorld; -import baritone.cache.WorldProvider; import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; @@ -27,8 +25,6 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.util.math.BlockPos; import java.util.HashSet; @@ -64,8 +60,6 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel } CalculationContext calcContext = new CalculationContext(); HashSet favored = favoredPositions.orElse(null); - CachedWorld cachedWorld = Optional.ofNullable(WorldProvider.INSTANCE.getCurrentWorld()).map(w -> w.cache).orElse(null); - ChunkProviderClient chunkProvider = Minecraft.getMinecraft().world.getChunkProvider(); BlockStateInterface.clearCachedChunk(); long startTime = System.nanoTime() / 1000000L; boolean slowPath = Baritone.settings().slowPath.get(); @@ -102,12 +96,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel int newZ = currentNode.z + moves.zOffset; if (newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) { // only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement - if (chunkProvider.isChunkGeneratedAt(newX >> 4, newZ >> 4)) { // TODO could also call BlockStateInterface here - // see issue #106 - if (cachedWorld == null || !cachedWorld.isCached(newX, newZ)) { // TODO isCached could call BlockStateInterface to skip a hashmap lookup - numEmptyChunk++; - continue; - } + if (!BlockStateInterface.isLoaded(newX, newZ)) { + numEmptyChunk++; + continue; } } MoveResult res = moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z); @@ -119,7 +110,6 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel if (actionCost >= ActionCosts.COST_INF) { continue; } - if (actionCost <= 0) { throw new IllegalStateException(moves + " calculated implausible cost " + actionCost); } diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index c5d076ea..fda465f4 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -90,6 +90,29 @@ public class BlockStateInterface implements Helper { return type; } + public static boolean isLoaded(int x, int z) { + Chunk prevChunk = prev; + if (prevChunk != null && prevChunk.x == x >> 4 && prevChunk.z == z >> 4) { + return true; + } + if (mc.world.getChunk(x >> 4, z >> 4).isLoaded()) { + return true; + } + CachedRegion prevRegion = prevCached; + if (prevRegion != null && prevRegion.getX() == x >> 9 && prevRegion.getZ() == z >> 9) { + return prevRegion.isCached(x & 511, z & 511); + } + WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); + if (world == null) { + return false; + } + CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); + if (region == null) { + return false; + } + return region.isCached(x & 511, z & 511); + } + public static void clearCachedChunk() { prev = null; prevCached = null; From 53590a96b94529ab554afbeb1c128faa68535274 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 11:17:31 -0700 Subject: [PATCH 246/329] you are no longer being poisoned by a toxic cloud --- .../baritone/pathing/movement/Movement.java | 57 +------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 82418574..1e049a2e 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -29,7 +29,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.chunk.EmptyChunk; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -217,61 +216,7 @@ public abstract class Movement implements Helper, MovementHelper { public void reset() { currentState = new MovementState().setStatus(MovementStatus.PREPPING); } - - public double getTotalHardnessOfBlocksToBreak(CalculationContext ctx) { - if (positionsToBreak.length == 0) { - return 0; - } - if (positionsToBreak.length == 1) { - return MovementHelper.getMiningDurationTicks(ctx, positionsToBreak[0], true); - } - int firstColumnX = positionsToBreak[0].getX(); - int firstColumnZ = positionsToBreak[0].getZ(); - int firstColumnMaxY = positionsToBreak[0].getY(); - int firstColumnMaximalIndex = 0; - boolean hasSecondColumn = false; - int secondColumnX = -1; - int secondColumnZ = -1; - int secondColumnMaxY = -1; - int secondColumnMaximalIndex = -1; - for (int i = 0; i < positionsToBreak.length; i++) { - BlockPos pos = positionsToBreak[i]; - if (pos.getX() == firstColumnX && pos.getZ() == firstColumnZ) { - if (pos.getY() > firstColumnMaxY) { - firstColumnMaxY = pos.getY(); - firstColumnMaximalIndex = i; - } - } else { - if (!hasSecondColumn || (pos.getX() == secondColumnX && pos.getZ() == secondColumnZ)) { - if (hasSecondColumn) { - if (pos.getY() > secondColumnMaxY) { - secondColumnMaxY = pos.getY(); - secondColumnMaximalIndex = i; - } - } else { - hasSecondColumn = true; - secondColumnX = pos.getX(); - secondColumnZ = pos.getZ(); - secondColumnMaxY = pos.getY(); - secondColumnMaximalIndex = i; - } - } else { - throw new IllegalStateException("I literally have no idea " + Arrays.asList(positionsToBreak)); - } - } - } - - double sum = 0; - for (int i = 0; i < positionsToBreak.length; i++) { - sum += MovementHelper.getMiningDurationTicks(ctx, positionsToBreak[i], firstColumnMaximalIndex == i || secondColumnMaximalIndex == i); - if (sum >= COST_INF) { - break; - } - } - return sum; - } - - + /** * Calculate latest movement state. * Gets called once a tick. From 5ca5fdf777b5f250212bfe657bb91ad1b2c86165 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 11:37:39 -0700 Subject: [PATCH 247/329] misc fixes --- .../java/baritone/behavior/FollowBehavior.java | 1 + .../java/baritone/behavior/MineBehavior.java | 4 ++++ .../java/baritone/pathing/movement/Movement.java | 5 +++-- .../pathing/movement/MovementHelper.java | 3 +++ .../movement/movements/MovementDescend.java | 16 ++++++++++++---- .../java/baritone/pathing/path/PathExecutor.java | 1 + 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 21ebbbea..a007a6b5 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -42,6 +42,7 @@ public final class FollowBehavior extends Behavior implements Helper { @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { + following = null; return; } if (following == null) { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 3073c0f8..853ef9cb 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -58,6 +58,10 @@ public final class MineBehavior extends Behavior implements Helper { @Override public void onTick(TickEvent event) { + if (event.getType() == TickEvent.Type.OUT) { + cancel(); + return; + } if (mining == null) { return; } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 1e049a2e..11237005 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -23,6 +23,7 @@ import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; +import net.minecraft.block.BlockLiquid; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -158,7 +159,7 @@ public abstract class Movement implements Helper, MovementHelper { } boolean somethingInTheWay = false; for (BetterBlockPos blockPos : positionsToBreak) { - if (!MovementHelper.canWalkThrough(blockPos)) { + if (!MovementHelper.canWalkThrough(blockPos) && !(BlockStateInterface.getBlock(blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try somethingInTheWay = true; Optional reachable = LookBehaviorUtils.reachable(blockPos); if (reachable.isPresent()) { @@ -216,7 +217,7 @@ public abstract class Movement implements Helper, MovementHelper { public void reset() { currentState = new MovementState().setStatus(MovementStatus.PREPPING); } - + /** * Calculate latest movement state. * Gets called once a tick. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index b1be71fd..fea40a02 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -360,6 +360,9 @@ public interface MovementHelper extends ActionCosts, Helper { if (avoidBreaking(x, y, z, state)) { return COST_INF; } + if (block instanceof BlockLiquid) { + return COST_INF; + } double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table double strVsBlock = context.getToolSet().getStrVsBlock(state); if (strVsBlock <= 0) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 275344e4..d5a7e7a2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -87,8 +87,10 @@ public class MovementDescend extends Movement { //if S is where you start, B needs to be air for a movementfall //A is plausibly breakable by either descend or fall //C, D, etc determine the length of the fall - if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) { - return dynamicFallCost(context, x, y, z, destX, destZ, totalCost); + + IBlockState below = BlockStateInterface.get(destX, y - 2, destZ); + if (!MovementHelper.canWalkOn(destX, y - 2, destZ, below)) { + return dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below); } Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock(); @@ -106,13 +108,16 @@ public class MovementDescend extends Movement { return new Tuple<>(y - 1, totalCost); } - public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak) { + public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, // and potentially replace the water we're going to fall into return IMPOSSIBLE; } + if (!MovementHelper.canWalkThrough(destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) { + return IMPOSSIBLE; + } for (int fallHeight = 3; true; fallHeight++) { int newY = y - fallHeight; if (newY < 0) { @@ -122,13 +127,16 @@ public class MovementDescend extends Movement { } IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ); double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak; - if (ontoBlock.getBlock() == Blocks.WATER) { // TODO flowing check required here? + if (ontoBlock.getBlock() == Blocks.WATER && !BlockStateInterface.isFlowing(ontoBlock)) { // TODO flowing check required here? if (Baritone.settings().assumeWalkOnWater.get()) { return IMPOSSIBLE; // TODO fix } // found a fall into water return new Tuple<>(newY, tentativeCost); // TODO incorporate water swim up cost? } + if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) { + return IMPOSSIBLE; + } if (MovementHelper.canWalkThrough(destX, newY, destZ, ontoBlock)) { continue; } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 815d6d1b..144b787f 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -94,6 +94,7 @@ public class PathExecutor implements Helper { if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1 && !(path.movements().get(0) instanceof MovementAscend) && !(path.movements().get(0) instanceof MovementPillar)) { // avoid the Wrong Y coordinate bug + // TODO add a timer here new MovementDownward(whereAmI, whereShouldIBe).update(); return false; } From a05d3269a3ae8380a617047b3d9370c801a63e85 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 11:48:16 -0700 Subject: [PATCH 248/329] link to back up that claim --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0e17d21..0118d56d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) A Minecraft pathfinder bot. 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 20x faster than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Features From 59b4e1a993095165e4060afb9d0fe35afa8831f9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 12:24:07 -0700 Subject: [PATCH 249/329] parkour --- .../pathing/calc/AStarPathFinder.java | 2 +- .../java/baritone/pathing/calc/Moves.java | 63 +++++++- .../pathing/movement/MovementHelper.java | 50 +------ .../movement/movements/MovementParkour.java | 140 +++++++----------- .../pathing/calc/openset/OpenSetsTest.java | 2 +- 5 files changed, 116 insertions(+), 141 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index d733931f..6ca58e6b 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -102,7 +102,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel } } MoveResult res = moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z); - if (res.destX != newX || res.destZ != newZ) { + if (!moves.dynamicXZ && (res.destX != newX || res.destZ != newZ)) { throw new IllegalStateException(moves + " " + res.destX + " " + newX + " " + res.destZ + " " + newZ); } numMovementsConsidered++; diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/calc/Moves.java index 1ff78351..0a30199a 100644 --- a/src/main/java/baritone/pathing/calc/Moves.java +++ b/src/main/java/baritone/pathing/calc/Moves.java @@ -264,19 +264,76 @@ public enum Moves { return new MoveResult(x - 1, y, z + 1, MovementDiagonal.cost(context, x, y, z, x - 1, z + 1)); } }, - // TODO parkour - ; + + PARKOUR_NORTH(0, -4, true) { + @Override + protected Movement apply0(BetterBlockPos src) { + return MovementParkour.cost(new CalculationContext(), src, EnumFacing.NORTH); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.NORTH); + return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + } + }, + + PARKOUR_SOUTH(0, +4, true) { + @Override + protected Movement apply0(BetterBlockPos src) { + return MovementParkour.cost(new CalculationContext(), src, EnumFacing.SOUTH); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH); + return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + } + }, + + PARKOUR_EAST(+4, 0, true) { + @Override + protected Movement apply0(BetterBlockPos src) { + return MovementParkour.cost(new CalculationContext(), src, EnumFacing.EAST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.EAST); + return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + } + }, + + PARKOUR_WEST(-4, 0, true) { + @Override + protected Movement apply0(BetterBlockPos src) { + return MovementParkour.cost(new CalculationContext(), src, EnumFacing.WEST); + } + + @Override + public MoveResult apply(CalculationContext context, int x, int y, int z) { + Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.WEST); + return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + } + }; protected abstract Movement apply0(BetterBlockPos src); public abstract MoveResult apply(CalculationContext context, int x, int y, int z); + public final boolean dynamicXZ; + public final int xOffset; public final int zOffset; - Moves(int x, int z) { + Moves(int x, int z, boolean dynamicXZ) { this.xOffset = x; this.zOffset = z; + this.dynamicXZ = dynamicXZ; + } + + Moves(int x, int z) { + this(x, z, false); } } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index fea40a02..df16879c 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -20,8 +20,6 @@ package baritone.pathing.movement; import baritone.Baritone; import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementTarget; -import baritone.pathing.movement.movements.MovementDescend; -import baritone.pathing.movement.movements.MovementFall; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; @@ -142,6 +140,10 @@ public interface MovementHelper extends ActionCosts, Helper { return fullyPassable(BlockStateInterface.get(pos)); } + static boolean fullyPassable(int x, int y, int z) { + return fullyPassable(BlockStateInterface.get(x, y, z)); + } + static boolean fullyPassable(IBlockState state) { Block block = state.getBlock(); if (block == Blocks.AIR) { // early return for most common case @@ -463,48 +465,4 @@ public interface MovementHelper extends ActionCosts, Helper { false )).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); } - - static Movement generateMovementFallOrDescend(BetterBlockPos pos, BetterBlockPos dest, CalculationContext calcContext) { - - - int x = dest.x; - int y = dest.y; - int z = dest.z; - if (!canWalkThrough(x, y - 2, z)) { - //if B in the diagram aren't air - //have to do a descend, because fall is impossible - - //this doesn't guarantee descend is possible, it just guarantees fall is impossible - return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1 - // we can't cost shortcut descend because !canWalkThrough doesn't mean canWalkOn - } - - // we're clear for a fall 2 - // let's see how far we can fall - for (int fallHeight = 3; true; fallHeight++) { - int newY = y - fallHeight; - if (newY < 0) { - // when pathing in the end, where you could plausibly fall into the void - // this check prevents it from getting the block at y=-1 and crashing - break; - } - IBlockState ontoBlock = BlockStateInterface.get(x, newY, z); - if (ontoBlock.getBlock() == Blocks.WATER) { - return new MovementFall(pos, new BetterBlockPos(x, newY, z)); - } - if (canWalkThrough(x, newY, z, ontoBlock)) { - continue; - } - if (!canWalkOn(x, newY, z, ontoBlock)) { - break; - } - if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) { - // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new MovementFall(pos, new BetterBlockPos(x, newY + 1, z)); - } else { - return null; - } - } - return null; - } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 0093539f..4d4cef08 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -27,19 +27,20 @@ import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; +import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import java.util.Objects; public class MovementParkour extends Movement { - private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; + private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{}; + private static final Tuple, Double> IMPOSSIBLE = new Tuple<>(new Tuple<>(0, 0), COST_INF); private final EnumFacing direction; private final int dist; @@ -48,79 +49,81 @@ public class MovementParkour extends Movement { super(src, src.offset(dir, dist), EMPTY); this.direction = dir; this.dist = dist; - super.override(costFromJumpDistance(dist)); } - public static MovementParkour generate(BetterBlockPos src, EnumFacing dir, CalculationContext context) { - // MUST BE KEPT IN SYNC WITH calculateCost + public static MovementParkour cost(CalculationContext context, BetterBlockPos src, EnumFacing direction) { + Tuple, Double> res = cost(context, src.x, src.y, src.z, direction); + int dist = Math.abs(res.getFirst().getFirst() - src.x) + Math.abs(res.getFirst().getSecond() - src.z); + return new MovementParkour(src, dist, direction); + } + + public static Tuple, Double> cost(CalculationContext context, int x, int y, int z, EnumFacing dir) { if (!Baritone.settings().allowParkour.get()) { - return null; + return IMPOSSIBLE; } - IBlockState standingOn = BlockStateInterface.get(src.down()); + IBlockState standingOn = BlockStateInterface.get(x, y - 1, z); if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || MovementHelper.isBottomSlab(standingOn)) { - return null; + return IMPOSSIBLE; } - BetterBlockPos adjBlock = src.down().offset(dir); - IBlockState adj = BlockStateInterface.get(adjBlock); + int xDiff = dir.getXOffset(); + int zDiff = dir.getZOffset(); + IBlockState adj = BlockStateInterface.get(x + xDiff, y - 1, z + zDiff); if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks - return null; + return IMPOSSIBLE; } - if (MovementHelper.canWalkOn(adjBlock, adj)) { // don't parkour if we could just traverse (for now) - return null; + if (MovementHelper.canWalkOn(x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now) + return IMPOSSIBLE; } - if (!MovementHelper.fullyPassable(src.offset(dir))) { - return null; + if (!MovementHelper.fullyPassable(x + xDiff, y, z + zDiff)) { + return IMPOSSIBLE; } - if (!MovementHelper.fullyPassable(src.up().offset(dir))) { - return null; + if (!MovementHelper.fullyPassable(x + xDiff, y + 1, z + zDiff)) { + return IMPOSSIBLE; } - if (!MovementHelper.fullyPassable(src.up(2).offset(dir))) { - return null; + if (!MovementHelper.fullyPassable(x + xDiff, y + 2, z + zDiff)) { + return IMPOSSIBLE; } - if (!MovementHelper.fullyPassable(src.up(2))) { - return null; + if (!MovementHelper.fullyPassable(x, y + 2, z)) { + return IMPOSSIBLE; } for (int i = 2; i <= (context.canSprint() ? 4 : 3); i++) { - BetterBlockPos dest = src.offset(dir, i); // TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly? - for (int y = 0; y < 4; y++) { - if (!MovementHelper.fullyPassable(dest.up(y))) { - return null; + for (int y2 = 0; y2 < 4; y2++) { + if (!MovementHelper.fullyPassable(x + xDiff * i, y + y2, z + zDiff * i)) { + return IMPOSSIBLE; } } - if (MovementHelper.canWalkOn(dest.down())) { - return new MovementParkour(src, i, dir); + if (MovementHelper.canWalkOn(x + xDiff * i, y - 1, z + zDiff * i)) { + return new Tuple<>(new Tuple<>(x + xDiff * i, z + zDiff * i), costFromJumpDistance(i)); } } if (!context.canSprint()) { - return null; + return IMPOSSIBLE; } if (!Baritone.settings().allowParkourPlace.get()) { - return null; + return IMPOSSIBLE; } - BlockPos dest = src.offset(dir, 4); - BlockPos positionToPlace = dest.down(); - IBlockState toPlace = BlockStateInterface.get(positionToPlace); + int destX = x + 4 * xDiff; + int destZ = z + 4 * zDiff; + IBlockState toPlace = BlockStateInterface.get(destX, y - 1, destZ); if (!context.hasThrowaway()) { - return null; + return IMPOSSIBLE; } - if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { - return null; + if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y - 1, destZ, toPlace)) { + return IMPOSSIBLE; } for (int i = 0; i < 5; i++) { - BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); - if (against1.up().equals(src.offset(dir, 3))) { // we can't turn around that fast + int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); + int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); + if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast continue; } - if (MovementHelper.canPlaceAgainst(against1)) { - // holy jesus we gonna do it - MovementParkour ret = new MovementParkour(src, 4, dir); - ret.override(costFromJumpDistance(4) + context.placeBlockCost()); - return ret; + if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) { + return new Tuple<>(new Tuple<>(destX, destZ), costFromJumpDistance(i) + context.placeBlockCost()); } } - return null; + return IMPOSSIBLE; } private static double costFromJumpDistance(int dist) { @@ -139,54 +142,11 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { - // MUST BE KEPT IN SYNC WITH generate - if (!context.canSprint() && dist >= 4) { + Tuple, Double> res = cost(context, src.x, src.y, src.z, direction); + if (res.getFirst().getFirst() != dest.x || res.getFirst().getSecond() != dest.z) { return COST_INF; } - boolean placing = false; - if (!MovementHelper.canWalkOn(dest.down())) { - if (dist != 4) { - return COST_INF; - } - if (!Baritone.settings().allowParkourPlace.get()) { - return COST_INF; - } - BlockPos positionToPlace = dest.down(); - IBlockState toPlace = BlockStateInterface.get(positionToPlace); - if (!context.hasThrowaway()) { - return COST_INF; - } - if (toPlace.getBlock() != Blocks.AIR && !BlockStateInterface.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(positionToPlace, toPlace)) { - return COST_INF; - } - for (int i = 0; i < 5; i++) { - BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); - if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast - continue; - } - if (MovementHelper.canPlaceAgainst(against1)) { - // holy jesus we gonna do it - placing = true; - break; - } - } - } - Block walkOff = BlockStateInterface.get(src.down().offset(direction)).getBlock(); - if (MovementHelper.avoidWalkingInto(walkOff) && walkOff != Blocks.WATER && walkOff != Blocks.FLOWING_WATER) { - return COST_INF; - } - for (int i = 1; i <= 4; i++) { - BlockPos d = src.offset(direction, i); - for (int y = 0; y < (i == 1 ? 3 : 4); y++) { - if (!MovementHelper.fullyPassable(d.up(y))) { - return COST_INF; - } - } - if (d.equals(dest)) { - return costFromJumpDistance(i) + (placing ? context.placeBlockCost() : 0); - } - } - throw new IllegalStateException("invalid jump distance?"); + return res.getSecond(); } @Override @@ -209,7 +169,7 @@ public class MovementParkour extends Movement { if (!MovementHelper.canWalkOn(dest.down())) { BlockPos positionToPlace = dest.down(); for (int i = 0; i < 5; i++) { - BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP[i]); + BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]); if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast continue; } diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 5f7b98d0..4fa88735 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -83,7 +83,7 @@ public class OpenSetsTest { assertTrue(set.isEmpty()); } - // generate the pathnodes that we'll be testing the sets on + // cost the pathnodes that we'll be testing the sets on PathNode[] toInsert = new PathNode[size]; for (int i = 0; i < size; i++) { // can't use an existing goal From 943794726aec64891166ab9ff583c26dce2cdc11 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 12:24:56 -0700 Subject: [PATCH 250/329] wtf intellij --- src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 4fa88735..5f7b98d0 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -83,7 +83,7 @@ public class OpenSetsTest { assertTrue(set.isEmpty()); } - // cost the pathnodes that we'll be testing the sets on + // generate the pathnodes that we'll be testing the sets on PathNode[] toInsert = new PathNode[size]; for (int i = 0; i < size; i++) { // can't use an existing goal From 6770985b3ab4bcbac488921baa399c65b312edd0 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 15:26:57 -0500 Subject: [PATCH 251/329] Ew TUPLE --- .../java/baritone/pathing/calc/Moves.java | 36 +++++++++--------- .../movement/movements/MovementDescend.java | 24 ++++++------ .../movement/movements/MovementFall.java | 8 ++-- .../movement/movements/MovementParkour.java | 22 ++++++----- .../movements/result/DescendResult.java | 36 ++++++++++++++++++ .../movements/result/ParkourResult.java | 37 +++++++++++++++++++ .../movement/movements/result/Result.java | 33 +++++++++++++++++ 7 files changed, 152 insertions(+), 44 deletions(-) create mode 100644 src/main/java/baritone/pathing/movement/movements/result/DescendResult.java create mode 100644 src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java create mode 100644 src/main/java/baritone/pathing/movement/movements/result/Result.java diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/calc/Moves.java index 0a30199a..2f33feab 100644 --- a/src/main/java/baritone/pathing/calc/Moves.java +++ b/src/main/java/baritone/pathing/calc/Moves.java @@ -20,9 +20,10 @@ package baritone.pathing.calc; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.movements.*; +import baritone.pathing.movement.movements.result.DescendResult; +import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Tuple; public enum Moves { DOWNWARD(0, 0) { @@ -158,8 +159,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple res = MovementDescend.cost(context, x, y, z, x + 1, z); - return new MoveResult(x + 1, res.getFirst(), z, res.getSecond()); + DescendResult res = MovementDescend.cost(context, x, y, z, x + 1, z); + return new MoveResult(x + 1, res.y, z, res.cost); } }, @@ -176,8 +177,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple res = MovementDescend.cost(context, x, y, z, x - 1, z); - return new MoveResult(x - 1, res.getFirst(), z, res.getSecond()); + DescendResult res = MovementDescend.cost(context, x, y, z, x - 1, z); + return new MoveResult(x - 1, res.y, z, res.cost); } }, @@ -194,8 +195,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple res = MovementDescend.cost(context, x, y, z, x, z - 1); - return new MoveResult(x, res.getFirst(), z - 1, res.getSecond()); + DescendResult res = MovementDescend.cost(context, x, y, z, x, z - 1); + return new MoveResult(x, res.y, z - 1, res.cost); } }, @@ -212,8 +213,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple res = MovementDescend.cost(context, x, y, z, x, z + 1); - return new MoveResult(x, res.getFirst(), z + 1, res.getSecond()); + DescendResult res = MovementDescend.cost(context, x, y, z, x, z + 1); + return new MoveResult(x, res.y, z + 1, res.cost); } }, @@ -273,8 +274,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.NORTH); - return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.NORTH); + return new MoveResult(res.x, y, res.z, res.cost); } }, @@ -286,8 +287,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH); - return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH); + return new MoveResult(res.x, y, res.z, res.cost); } }, @@ -299,8 +300,8 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.EAST); - return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.EAST); + return new MoveResult(res.x, y, res.z, res.cost); } }, @@ -312,14 +313,13 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - Tuple, Double> res = MovementParkour.cost(context, x, y, z, EnumFacing.WEST); - return new MoveResult(res.getFirst().getFirst(), y, res.getFirst().getSecond(), res.getSecond()); + ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.WEST); + return new MoveResult(res.x, y, res.z, res.cost); } }; protected abstract Movement apply0(BetterBlockPos src); - public abstract MoveResult apply(CalculationContext context, int x, int y, int z); public final boolean dynamicXZ; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index d5a7e7a2..8da86a37 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -23,6 +23,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; +import baritone.pathing.movement.movements.result.DescendResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; @@ -30,12 +31,11 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; -public class MovementDescend extends Movement { +import static baritone.pathing.movement.movements.result.DescendResult.IMPOSSIBLE; - private static final Tuple IMPOSSIBLE = new Tuple<>(0, COST_INF); +public class MovementDescend extends Movement { private int numTicks = 0; @@ -51,14 +51,14 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - Tuple result = cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.getFirst() != dest.y) { + DescendResult result = cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.y != dest.y) { return COST_INF; // doesn't apply to us, this position is a fall not a descend } - return result.getSecond(); + return result.cost; } - public static Tuple cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + public static DescendResult cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return IMPOSSIBLE; @@ -105,10 +105,10 @@ public class MovementDescend extends Movement { walk = WALK_ONE_OVER_SOUL_SAND_COST; } totalCost += walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); - return new Tuple<>(y - 1, totalCost); + return new DescendResult(y - 1, totalCost); } - public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { + public static DescendResult dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, @@ -132,7 +132,7 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // TODO fix } // found a fall into water - return new Tuple<>(newY, tentativeCost); // TODO incorporate water swim up cost? + return new DescendResult(newY, tentativeCost); // TODO incorporate water swim up cost? } if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) { return IMPOSSIBLE; @@ -147,11 +147,11 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } if (context.hasWaterBucket() && fallHeight <= context.maxFallHeightBucket() + 1) { - return new Tuple<>(newY + 1, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 + return new DescendResult(newY + 1, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 } if (fallHeight <= context.maxFallHeightNoWater() + 1) { // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new Tuple<>(newY + 1, tentativeCost); + return new DescendResult(newY + 1, tentativeCost); } else { return IMPOSSIBLE; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 8ff11591..335cdc25 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -24,12 +24,12 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; +import baritone.pathing.movement.movements.result.DescendResult; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; @@ -45,11 +45,11 @@ public class MovementFall extends Movement { @Override protected double calculateCost(CalculationContext context) { - Tuple result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.getFirst() != dest.y) { + DescendResult result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.y != dest.y) { return COST_INF; // doesn't apply to us, this position is a descend not a fall } - return result.getSecond(); + return result.cost; } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 4d4cef08..73a812fd 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -23,6 +23,7 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; +import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; @@ -31,16 +32,17 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import java.util.Objects; +import static baritone.pathing.movement.movements.result.ParkourResult.IMPOSSIBLE; + public class MovementParkour extends Movement { + private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{}; - private static final Tuple, Double> IMPOSSIBLE = new Tuple<>(new Tuple<>(0, 0), COST_INF); private final EnumFacing direction; private final int dist; @@ -52,12 +54,12 @@ public class MovementParkour extends Movement { } public static MovementParkour cost(CalculationContext context, BetterBlockPos src, EnumFacing direction) { - Tuple, Double> res = cost(context, src.x, src.y, src.z, direction); - int dist = Math.abs(res.getFirst().getFirst() - src.x) + Math.abs(res.getFirst().getSecond() - src.z); + ParkourResult res = cost(context, src.x, src.y, src.z, direction); + int dist = Math.abs(res.x - src.x) + Math.abs(res.z - src.z); return new MovementParkour(src, dist, direction); } - public static Tuple, Double> cost(CalculationContext context, int x, int y, int z, EnumFacing dir) { + public static ParkourResult cost(CalculationContext context, int x, int y, int z, EnumFacing dir) { if (!Baritone.settings().allowParkour.get()) { return IMPOSSIBLE; } @@ -95,7 +97,7 @@ public class MovementParkour extends Movement { } } if (MovementHelper.canWalkOn(x + xDiff * i, y - 1, z + zDiff * i)) { - return new Tuple<>(new Tuple<>(x + xDiff * i, z + zDiff * i), costFromJumpDistance(i)); + return new ParkourResult(x + xDiff * i, z + zDiff * i, costFromJumpDistance(i)); } } if (!context.canSprint()) { @@ -120,7 +122,7 @@ public class MovementParkour extends Movement { continue; } if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) { - return new Tuple<>(new Tuple<>(destX, destZ), costFromJumpDistance(i) + context.placeBlockCost()); + return new ParkourResult(destX, destZ, costFromJumpDistance(i) + context.placeBlockCost()); } } return IMPOSSIBLE; @@ -142,11 +144,11 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { - Tuple, Double> res = cost(context, src.x, src.y, src.z, direction); - if (res.getFirst().getFirst() != dest.x || res.getFirst().getSecond() != dest.z) { + ParkourResult res = cost(context, src.x, src.y, src.z, direction); + if (res.x != dest.x || res.z != dest.z) { return COST_INF; } - return res.getSecond(); + return res.cost; } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java b/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java new file mode 100644 index 00000000..c136fbb1 --- /dev/null +++ b/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java @@ -0,0 +1,36 @@ +/* + * 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.pathing.movement.movements.result; + +import static baritone.pathing.movement.ActionCosts.COST_INF; + +/** + * @author Brady + * @since 9/23/2018 + */ +public final class DescendResult extends Result { + + public static final DescendResult IMPOSSIBLE = new DescendResult(0, COST_INF); + + public final int y; + + public DescendResult(int y, double cost) { + super(cost); + this.y = y; + } +} diff --git a/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java b/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java new file mode 100644 index 00000000..e30c77c1 --- /dev/null +++ b/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java @@ -0,0 +1,37 @@ +/* + * 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.pathing.movement.movements.result; + +import static baritone.pathing.movement.ActionCosts.COST_INF; + +/** + * @author Brady + * @since 9/23/2018 + */ +public final class ParkourResult extends Result { + + public static final ParkourResult IMPOSSIBLE = new ParkourResult(0, 0, COST_INF); + + public final int x, z; + + public ParkourResult(int x, int z, double cost) { + super(cost); + this.x = x; + this.z = z; + } +} diff --git a/src/main/java/baritone/pathing/movement/movements/result/Result.java b/src/main/java/baritone/pathing/movement/movements/result/Result.java new file mode 100644 index 00000000..a56c5f89 --- /dev/null +++ b/src/main/java/baritone/pathing/movement/movements/result/Result.java @@ -0,0 +1,33 @@ +/* + * 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.pathing.movement.movements.result; + +/** + * Generic class for special movement results. Only contains a single "cost" field. + * + * @author Brady + * @since 9/23/2018 + */ +public class Result { + + public final double cost; + + public Result(double cost) { + this.cost = cost; + } +} From 182c1e6ff5b4ae70706a2a5f90b19739c96644a4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 14:23:23 -0700 Subject: [PATCH 252/329] refactor --- .../pathing/calc/AStarPathFinder.java | 6 +- src/main/java/baritone/pathing/calc/Path.java | 1 + .../pathing/{calc => movement}/Moves.java | 62 ++++++++++--------- .../movements/result}/MoveResult.java | 2 +- 4 files changed, 40 insertions(+), 31 deletions(-) rename src/main/java/baritone/pathing/{calc => movement}/Moves.java (88%) rename src/main/java/baritone/pathing/{calc => movement/movements/result}/MoveResult.java (95%) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 6ca58e6b..515f4b16 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -22,6 +22,8 @@ import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; +import baritone.pathing.movement.Moves; +import baritone.pathing.movement.movements.result.MoveResult; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; @@ -97,7 +99,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel if (newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) { // only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement if (!BlockStateInterface.isLoaded(newX, newZ)) { - numEmptyChunk++; + if (!moves.dynamicXZ) { // only increment the counter if the movement would have gone out of bounds guaranteed + numEmptyChunk++; + } continue; } } diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 2ebe4c09..85450f27 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -19,6 +19,7 @@ package baritone.pathing.calc; import baritone.pathing.goals.Goal; import baritone.pathing.movement.Movement; +import baritone.pathing.movement.Moves; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/calc/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java similarity index 88% rename from src/main/java/baritone/pathing/calc/Moves.java rename to src/main/java/baritone/pathing/movement/Moves.java index 2f33feab..7855c04a 100644 --- a/src/main/java/baritone/pathing/calc/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -15,20 +15,24 @@ * along with Baritone. If not, see . */ -package baritone.pathing.calc; +package baritone.pathing.movement; -import baritone.pathing.movement.CalculationContext; -import baritone.pathing.movement.Movement; import baritone.pathing.movement.movements.*; import baritone.pathing.movement.movements.result.DescendResult; +import baritone.pathing.movement.movements.result.MoveResult; import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; +/** + * An enum of all possible movements attached to all possible directions they could be taken in + * + * @author leijurv + */ public enum Moves { DOWNWARD(0, 0) { @Override - protected Movement apply0(BetterBlockPos src) { // TODO specific return types + public Movement apply0(BetterBlockPos src) { return new MovementDownward(src, src.down()); } @@ -40,7 +44,7 @@ public enum Moves { PILLAR(0, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementPillar(src, src.up()); } @@ -52,7 +56,7 @@ public enum Moves { TRAVERSE_NORTH(0, -1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.north()); } @@ -64,7 +68,7 @@ public enum Moves { TRAVERSE_SOUTH(0, +1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.south()); } @@ -76,7 +80,7 @@ public enum Moves { TRAVERSE_EAST(+1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.east()); } @@ -88,7 +92,7 @@ public enum Moves { TRAVERSE_WEST(-1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementTraverse(src, src.west()); } @@ -100,7 +104,7 @@ public enum Moves { ASCEND_NORTH(0, -1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z - 1)); } @@ -112,7 +116,7 @@ public enum Moves { ASCEND_SOUTH(0, +1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x, src.y + 1, src.z + 1)); } @@ -124,7 +128,7 @@ public enum Moves { ASCEND_EAST(+1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x + 1, src.y + 1, src.z)); } @@ -136,7 +140,7 @@ public enum Moves { ASCEND_WEST(-1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementAscend(src, new BetterBlockPos(src.x - 1, src.y + 1, src.z)); } @@ -148,7 +152,7 @@ public enum Moves { DESCEND_EAST(+1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); if (res.destY == src.y - 1) { return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); @@ -166,7 +170,7 @@ public enum Moves { DESCEND_WEST(-1, 0) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); if (res.destY == src.y - 1) { return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); @@ -184,7 +188,7 @@ public enum Moves { DESCEND_NORTH(0, -1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); if (res.destY == src.y - 1) { return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); @@ -202,7 +206,7 @@ public enum Moves { DESCEND_SOUTH(0, +1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { MoveResult res = apply(new CalculationContext(), src.x, src.y, src.z); if (res.destY == src.y - 1) { return new MovementDescend(src, new BetterBlockPos(res.destX, res.destY, res.destZ)); @@ -220,7 +224,7 @@ public enum Moves { DIAGONAL_NORTHEAST(+1, -1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.EAST); } @@ -232,7 +236,7 @@ public enum Moves { DIAGONAL_NORTHWEST(-1, -1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.NORTH, EnumFacing.WEST); } @@ -244,7 +248,7 @@ public enum Moves { DIAGONAL_SOUTHEAST(+1, +1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.EAST); } @@ -256,7 +260,7 @@ public enum Moves { DIAGONAL_SOUTHWEST(-1, +1) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return new MovementDiagonal(src, EnumFacing.SOUTH, EnumFacing.WEST); } @@ -268,7 +272,7 @@ public enum Moves { PARKOUR_NORTH(0, -4, true) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return MovementParkour.cost(new CalculationContext(), src, EnumFacing.NORTH); } @@ -281,7 +285,7 @@ public enum Moves { PARKOUR_SOUTH(0, +4, true) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return MovementParkour.cost(new CalculationContext(), src, EnumFacing.SOUTH); } @@ -294,7 +298,7 @@ public enum Moves { PARKOUR_EAST(+4, 0, true) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return MovementParkour.cost(new CalculationContext(), src, EnumFacing.EAST); } @@ -307,7 +311,7 @@ public enum Moves { PARKOUR_WEST(-4, 0, true) { @Override - protected Movement apply0(BetterBlockPos src) { + public Movement apply0(BetterBlockPos src) { return MovementParkour.cost(new CalculationContext(), src, EnumFacing.WEST); } @@ -318,10 +322,6 @@ public enum Moves { } }; - protected abstract Movement apply0(BetterBlockPos src); - - public abstract MoveResult apply(CalculationContext context, int x, int y, int z); - public final boolean dynamicXZ; public final int xOffset; @@ -336,4 +336,8 @@ public enum Moves { Moves(int x, int z) { this(x, z, false); } + + public abstract Movement apply0(BetterBlockPos src); + + public abstract MoveResult apply(CalculationContext context, int x, int y, int z); } diff --git a/src/main/java/baritone/pathing/calc/MoveResult.java b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java similarity index 95% rename from src/main/java/baritone/pathing/calc/MoveResult.java rename to src/main/java/baritone/pathing/movement/movements/result/MoveResult.java index e9c6caa9..a0419a2b 100644 --- a/src/main/java/baritone/pathing/calc/MoveResult.java +++ b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.pathing.calc; +package baritone.pathing.movement.movements.result; public final class MoveResult { public final int destX; From a6aa65962948b4c8618efe4c63023c5d127ab898 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 16:44:35 -0500 Subject: [PATCH 253/329] Begin to create default behavior exposing interfaces in api --- .../java/baritone/api/behavior/Behavior.java | 5 +- .../java/baritone/api/behavior/IBehavior.java | 27 +++++++ .../api/behavior/IFollowBehavior.java | 44 ++++++++++++ .../baritone/api/behavior/ILookBehavior.java | 39 +++++++++++ .../baritone/api/behavior/IMineBehavior.java | 70 +++++++++++++++++++ .../java/baritone/api}/utils/Rotation.java | 2 +- .../baritone/behavior/FollowBehavior.java | 6 +- .../java/baritone/behavior/LookBehavior.java | 6 +- .../baritone/behavior/LookBehaviorUtils.java | 1 + .../java/baritone/behavior/MineBehavior.java | 15 ++-- .../baritone/pathing/movement/Movement.java | 1 + .../pathing/movement/MovementHelper.java | 1 + .../pathing/movement/MovementState.java | 2 +- .../movement/movements/MovementFall.java | 1 + .../movement/movements/MovementPillar.java | 2 +- .../movement/movements/MovementTraverse.java | 2 +- .../utils/ExampleBaritoneControl.java | 2 +- src/main/java/baritone/utils/Helper.java | 1 + .../java/baritone/utils/RayTraceUtils.java | 1 + src/main/java/baritone/utils/Utils.java | 1 + 20 files changed, 212 insertions(+), 17 deletions(-) create mode 100644 src/api/java/baritone/api/behavior/IBehavior.java create mode 100644 src/api/java/baritone/api/behavior/IFollowBehavior.java create mode 100644 src/api/java/baritone/api/behavior/ILookBehavior.java create mode 100644 src/api/java/baritone/api/behavior/IMineBehavior.java rename src/{main/java/baritone => api/java/baritone/api}/utils/Rotation.java (96%) diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java index 872ce1bd..52b83258 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/api/java/baritone/api/behavior/Behavior.java @@ -17,16 +17,13 @@ package baritone.api.behavior; -import baritone.api.event.listener.AbstractGameEventListener; -import baritone.api.utils.interfaces.Toggleable; - /** * A type of game event listener that can be toggled. * * @author Brady * @since 8/1/2018 6:29 PM */ -public class Behavior implements AbstractGameEventListener, Toggleable { +public class Behavior implements IBehavior { /** * Whether or not this behavior is enabled diff --git a/src/api/java/baritone/api/behavior/IBehavior.java b/src/api/java/baritone/api/behavior/IBehavior.java new file mode 100644 index 00000000..aee144e2 --- /dev/null +++ b/src/api/java/baritone/api/behavior/IBehavior.java @@ -0,0 +1,27 @@ +/* + * 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.api.behavior; + +import baritone.api.event.listener.AbstractGameEventListener; +import baritone.api.utils.interfaces.Toggleable; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IBehavior extends AbstractGameEventListener, Toggleable {} diff --git a/src/api/java/baritone/api/behavior/IFollowBehavior.java b/src/api/java/baritone/api/behavior/IFollowBehavior.java new file mode 100644 index 00000000..c960fab3 --- /dev/null +++ b/src/api/java/baritone/api/behavior/IFollowBehavior.java @@ -0,0 +1,44 @@ +/* + * 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.api.behavior; + +import net.minecraft.entity.Entity; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IFollowBehavior extends IBehavior { + + /** + * Set the follow target to the specified entity; + * + * @param entity The entity to follow + */ + void follow(Entity entity); + + /** + * @return The entity that is currently being followed + */ + Entity following(); + + /** + * Cancels the follow behavior, this will clear the current follow target. + */ + void cancel(); +} diff --git a/src/api/java/baritone/api/behavior/ILookBehavior.java b/src/api/java/baritone/api/behavior/ILookBehavior.java new file mode 100644 index 00000000..b5b5d63b --- /dev/null +++ b/src/api/java/baritone/api/behavior/ILookBehavior.java @@ -0,0 +1,39 @@ +/* + * 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.api.behavior; + +import baritone.api.utils.Rotation; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface ILookBehavior extends IBehavior { + + /** + * Updates the current {@link ILookBehavior} target to target + * the specified rotations on the next tick. If force is {@code true}, + * then freeLook will be overriden and angles will be set regardless. + * If any sort of block interaction is required, force should be {@code true}, + * otherwise, it should be {@code false}; + * + * @param rotation The target rotations + * @param force Whether or not to "force" the rotations + */ + void updateTarget(Rotation rotation, boolean force); +} diff --git a/src/api/java/baritone/api/behavior/IMineBehavior.java b/src/api/java/baritone/api/behavior/IMineBehavior.java new file mode 100644 index 00000000..394fcaf0 --- /dev/null +++ b/src/api/java/baritone/api/behavior/IMineBehavior.java @@ -0,0 +1,70 @@ +/* + * 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.api.behavior; + +import net.minecraft.block.Block; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IMineBehavior { + + /** + * Begin to search for and mine the specified blocks until + * the number of specified items to get from the blocks that + * are mined. This is based on the first target block to mine. + * + * @param quantity The number of items to get from blocks mined + * @param blocks The blocks to mine + */ + void mine(int quantity, String... blocks); + + /** + * Begin to search for and mine the specified blocks until + * the number of specified items to get from the blocks that + * are mined. This is based on the first target block to mine. + * + * @param quantity The number of items to get from blocks mined + * @param blocks The blocks to mine + */ + void mine(int quantity, Block... blocks); + + /** + * Begin to search for and mine the specified blocks. + * + * @param blocks The blocks to mine + */ + default void mine(String... blocks) { + this.mine(0, blocks); + } + + /** + * Begin to search for and mine the specified blocks. + * + * @param blocks The blocks to mine + */ + default void mine(Block... blocks) { + this.mine(0, blocks); + } + + /** + * Cancels the current mining task + */ + void cancel(); +} diff --git a/src/main/java/baritone/utils/Rotation.java b/src/api/java/baritone/api/utils/Rotation.java similarity index 96% rename from src/main/java/baritone/utils/Rotation.java rename to src/api/java/baritone/api/utils/Rotation.java index ce92d009..ca8cb66f 100644 --- a/src/main/java/baritone/utils/Rotation.java +++ b/src/api/java/baritone/api/utils/Rotation.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.utils; +package baritone.api.utils; import net.minecraft.util.Tuple; diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index a007a6b5..5b2323cc 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -19,6 +19,7 @@ package baritone.behavior; import baritone.Baritone; import baritone.api.behavior.Behavior; +import baritone.api.behavior.IFollowBehavior; import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; import baritone.pathing.goals.GoalXZ; @@ -31,7 +32,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public final class FollowBehavior extends Behavior implements Helper { +public final class FollowBehavior extends Behavior implements IFollowBehavior, Helper { public static final FollowBehavior INSTANCE = new FollowBehavior(); @@ -61,14 +62,17 @@ public final class FollowBehavior extends Behavior implements Helper { PathingBehavior.INSTANCE.path(); } + @Override public void follow(Entity entity) { this.following = entity; } + @Override public Entity following() { return this.following; } + @Override public void cancel() { PathingBehavior.INSTANCE.cancel(); follow(null); diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index d45ad585..c1dfa94a 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -20,12 +20,13 @@ package baritone.behavior; import baritone.Baritone; import baritone.Settings; import baritone.api.behavior.Behavior; +import baritone.api.behavior.ILookBehavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; import baritone.utils.Helper; -import baritone.utils.Rotation; +import baritone.api.utils.Rotation; -public final class LookBehavior extends Behavior implements Helper { +public final class LookBehavior extends Behavior implements ILookBehavior, Helper { public static final LookBehavior INSTANCE = new LookBehavior(); @@ -51,6 +52,7 @@ public final class LookBehavior extends Behavior implements Helper { private LookBehavior() {} + @Override public void updateTarget(Rotation target, boolean force) { this.target = target; this.force = force || !Baritone.settings().freeLook.get(); diff --git a/src/main/java/baritone/behavior/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java index ed7f730e..451d83a1 100644 --- a/src/main/java/baritone/behavior/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java @@ -17,6 +17,7 @@ package baritone.behavior; +import baritone.api.utils.Rotation; import baritone.utils.*; import net.minecraft.block.BlockFire; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 853ef9cb..4a793f0a 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -19,6 +19,7 @@ package baritone.behavior; import baritone.Baritone; import baritone.api.behavior.Behavior; +import baritone.api.behavior.IMineBehavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.TickEvent; import baritone.cache.CachedChunk; @@ -46,7 +47,7 @@ import java.util.stream.Collectors; * * @author leijurv */ -public final class MineBehavior extends Behavior implements Helper { +public final class MineBehavior extends Behavior implements IMineBehavior, Helper { public static final MineBehavior INSTANCE = new MineBehavior(); @@ -109,7 +110,7 @@ public final class MineBehavior extends Behavior implements Helper { PathingBehavior.INSTANCE.path(); } - public static GoalComposite coalesce(List locs) { + public GoalComposite coalesce(List locs) { return new GoalComposite(locs.stream().map(loc -> { if (!Baritone.settings().forceInternalMining.get()) { return new GoalTwoBlocks(loc); @@ -133,7 +134,7 @@ public final class MineBehavior extends Behavior implements Helper { }).toArray(Goal[]::new)); } - public static List scanFor(List mining, int max) { + public List scanFor(List mining, int max) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>(); //long b = System.currentTimeMillis(); @@ -156,7 +157,7 @@ public final class MineBehavior extends Behavior implements Helper { return prune(locs, mining, max); } - public static List prune(List locs, List mining, int max) { + public List prune(List locs, List mining, int max) { BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet(); locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); @@ -171,6 +172,7 @@ public final class MineBehavior extends Behavior implements Helper { return locs; } + @Override public void mine(int quantity, String... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList()); this.quantity = quantity; @@ -178,12 +180,15 @@ public final class MineBehavior extends Behavior implements Helper { updateGoal(); } - public void mine(Block... blocks) { + @Override + public void mine(int quantity, Block... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks); + this.quantity = quantity; this.locationsCache = new ArrayList<>(); updateGoal(); } + @Override public void cancel() { mine(0, (String[]) null); PathingBehavior.INSTANCE.cancel(); diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 11237005..21341fa4 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -18,6 +18,7 @@ package baritone.pathing.movement; import baritone.Baritone; +import baritone.api.utils.Rotation; import baritone.behavior.LookBehavior; import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index df16879c..e173e766 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -18,6 +18,7 @@ package baritone.pathing.movement; import baritone.Baritone; +import baritone.api.utils.Rotation; import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.*; diff --git a/src/main/java/baritone/pathing/movement/MovementState.java b/src/main/java/baritone/pathing/movement/MovementState.java index 0017c438..a611b8f2 100644 --- a/src/main/java/baritone/pathing/movement/MovementState.java +++ b/src/main/java/baritone/pathing/movement/MovementState.java @@ -18,7 +18,7 @@ package baritone.pathing.movement; import baritone.utils.InputOverrideHandler.Input; -import baritone.utils.Rotation; +import baritone.api.utils.Rotation; import net.minecraft.util.math.Vec3d; import java.util.HashMap; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 335cdc25..980371a9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -18,6 +18,7 @@ package baritone.pathing.movement.movements; import baritone.Baritone; +import baritone.api.utils.Rotation; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index bf77855d..59085909 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; -import baritone.utils.Rotation; +import baritone.api.utils.Rotation; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 232a8376..721e78a1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -25,7 +25,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; -import baritone.utils.Rotation; +import baritone.api.utils.Rotation; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 19a33f32..ff727c51 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -368,7 +368,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("No locations for " + mining + " known, cancelling"); return; } - List locs = MineBehavior.scanFor(Collections.singletonList(block), 64); + List locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64); if (locs.isEmpty()) { logDirect("No locations for " + mining + " known, cancelling"); return; diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index 9924d0bf..b9b3f0eb 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.api.utils.Rotation; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.BlockSlab; import net.minecraft.client.Minecraft; diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java index d859ae4c..1c8115a5 100644 --- a/src/main/java/baritone/utils/RayTraceUtils.java +++ b/src/main/java/baritone/utils/RayTraceUtils.java @@ -17,6 +17,7 @@ package baritone.utils; +import baritone.api.utils.Rotation; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 8a63347a..49f6b49d 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -17,6 +17,7 @@ package baritone.utils; +import baritone.api.utils.Rotation; import net.minecraft.block.BlockFire; import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; From e99fc5d9b7b67aedbae1ee992564a332b62a71bb Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 16:45:00 -0500 Subject: [PATCH 254/329] Make IMineBehavior extend IBehavior --- src/api/java/baritone/api/behavior/IMineBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/behavior/IMineBehavior.java b/src/api/java/baritone/api/behavior/IMineBehavior.java index 394fcaf0..78ab6d6a 100644 --- a/src/api/java/baritone/api/behavior/IMineBehavior.java +++ b/src/api/java/baritone/api/behavior/IMineBehavior.java @@ -23,7 +23,7 @@ import net.minecraft.block.Block; * @author Brady * @since 9/23/2018 */ -public interface IMineBehavior { +public interface IMineBehavior extends IBehavior { /** * Begin to search for and mine the specified blocks until From 7edf581c6a62f7f982a1a58951d12124de739a3b Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 16:50:18 -0500 Subject: [PATCH 255/329] Move Behavior back to main sourceSet --- src/main/java/baritone/Baritone.java | 2 +- .../api => main/java/baritone}/behavior/Behavior.java | 4 +++- src/main/java/baritone/behavior/FollowBehavior.java | 1 - src/main/java/baritone/behavior/LocationTrackingBehavior.java | 1 - src/main/java/baritone/behavior/LookBehavior.java | 1 - src/main/java/baritone/behavior/MemoryBehavior.java | 1 - src/main/java/baritone/behavior/MineBehavior.java | 1 - src/main/java/baritone/behavior/PathingBehavior.java | 1 - src/main/java/baritone/utils/ExampleBaritoneControl.java | 2 +- 9 files changed, 5 insertions(+), 9 deletions(-) rename src/{api/java/baritone/api => main/java/baritone}/behavior/Behavior.java (96%) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 06bf365a..61b2982a 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -17,7 +17,7 @@ package baritone; -import baritone.api.behavior.Behavior; +import baritone.behavior.Behavior; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; import baritone.event.GameEventHandler; diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/main/java/baritone/behavior/Behavior.java similarity index 96% rename from src/api/java/baritone/api/behavior/Behavior.java rename to src/main/java/baritone/behavior/Behavior.java index 52b83258..b856e423 100644 --- a/src/api/java/baritone/api/behavior/Behavior.java +++ b/src/main/java/baritone/behavior/Behavior.java @@ -15,7 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.api.behavior; +package baritone.behavior; + +import baritone.api.behavior.IBehavior; /** * A type of game event listener that can be toggled. diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 5b2323cc..7fd76675 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -18,7 +18,6 @@ package baritone.behavior; import baritone.Baritone; -import baritone.api.behavior.Behavior; import baritone.api.behavior.IFollowBehavior; import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; diff --git a/src/main/java/baritone/behavior/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/LocationTrackingBehavior.java index e48e482e..86badc06 100644 --- a/src/main/java/baritone/behavior/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/LocationTrackingBehavior.java @@ -17,7 +17,6 @@ package baritone.behavior; -import baritone.api.behavior.Behavior; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; import baritone.api.event.events.BlockInteractEvent; diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index c1dfa94a..9d1a2e58 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -19,7 +19,6 @@ package baritone.behavior; import baritone.Baritone; import baritone.Settings; -import baritone.api.behavior.Behavior; import baritone.api.behavior.ILookBehavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index c850c8e5..20ffa163 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -17,7 +17,6 @@ package baritone.behavior; -import baritone.api.behavior.Behavior; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 4a793f0a..2dde364b 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -18,7 +18,6 @@ package baritone.behavior; import baritone.Baritone; -import baritone.api.behavior.Behavior; import baritone.api.behavior.IMineBehavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.TickEvent; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index d9bb92ba..7820066c 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -18,7 +18,6 @@ package baritone.behavior; import baritone.Baritone; -import baritone.api.behavior.Behavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RenderEvent; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index ff727c51..5d0fcdaf 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -19,7 +19,7 @@ package baritone.utils; import baritone.Baritone; import baritone.Settings; -import baritone.api.behavior.Behavior; +import baritone.behavior.Behavior; import baritone.api.event.events.ChatEvent; import baritone.behavior.FollowBehavior; import baritone.behavior.MineBehavior; From 62b8bc0f47d4e0efccb7f4f2abe1cf338aa4a799 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 17:07:53 -0500 Subject: [PATCH 256/329] Create IMemoryBehavior interface --- .../api/behavior/IMemoryBehavior.java | 36 +++++++++++++++++ .../behavior/memory/IRememberedInventory.java | 39 +++++++++++++++++++ .../baritone/behavior/MemoryBehavior.java | 18 ++++++--- 3 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 src/api/java/baritone/api/behavior/IMemoryBehavior.java create mode 100644 src/api/java/baritone/api/behavior/memory/IRememberedInventory.java diff --git a/src/api/java/baritone/api/behavior/IMemoryBehavior.java b/src/api/java/baritone/api/behavior/IMemoryBehavior.java new file mode 100644 index 00000000..ea5e9007 --- /dev/null +++ b/src/api/java/baritone/api/behavior/IMemoryBehavior.java @@ -0,0 +1,36 @@ +/* + * 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.api.behavior; + +import baritone.api.behavior.memory.IRememberedInventory; +import net.minecraft.util.math.BlockPos; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IMemoryBehavior extends IBehavior { + + /** + * Gets a remembered inventory by its block position. + * + * @param pos The position of the container block + * @return The remembered inventory + */ + IRememberedInventory getInventoryByPos(BlockPos pos); +} diff --git a/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java b/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java new file mode 100644 index 00000000..c57ded91 --- /dev/null +++ b/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java @@ -0,0 +1,39 @@ +/* + * 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.api.behavior.memory; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IRememberedInventory { + + /** + * @return The contents of this inventory + */ + List getContents(); + + /** + * @return The number of slots in this inventory + */ + int getSize(); +} diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 20ffa163..b0980322 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -17,6 +17,8 @@ package baritone.behavior; +import baritone.api.behavior.IMemoryBehavior; +import baritone.api.behavior.memory.IRememberedInventory; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; @@ -37,7 +39,7 @@ import java.util.*; * @author Brady * @since 8/6/2018 9:47 PM */ -public final class MemoryBehavior extends Behavior implements Helper { +public final class MemoryBehavior extends Behavior implements IMemoryBehavior, Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); @@ -127,6 +129,7 @@ public final class MemoryBehavior extends Behavior implements Helper { }); } + @Override public final RememberedInventory getInventoryByPos(BlockPos pos) { return this.rememberedInventories.get(pos); } @@ -169,7 +172,7 @@ public final class MemoryBehavior extends Behavior implements Helper { *

* Associated with a {@link BlockPos} in {@link MemoryBehavior#rememberedInventories}. */ - public static class RememberedInventory { + public static class RememberedInventory implements IRememberedInventory { /** * The list of items in the inventory @@ -190,11 +193,14 @@ public final class MemoryBehavior extends Behavior implements Helper { this.items = new ArrayList<>(); } - /** - * @return The list of items in the inventory - */ - public final List getItems() { + @Override + public final List getContents() { return this.items; } + + @Override + public final int getSize() { + return this.size; + } } } From 4ac2ade7c6de597f1ecdb09060c1ae668438ea87 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 18:29:03 -0500 Subject: [PATCH 257/329] Create IPathingBehavior and expose all behaviors This is still a biiiiiig WIP --- src/api/java/baritone/api/BaritoneAPI.java | 76 +++++++++++++++++++ .../api/behavior/IPathingBehavior.java | 68 +++++++++++++++++ .../baritone/api}/pathing/goals/Goal.java | 5 +- src/main/java/baritone/Baritone.java | 11 +++ .../java/baritone/behavior/MineBehavior.java | 2 +- .../baritone/behavior/PathingBehavior.java | 23 +++++- .../pathing/calc/AStarPathFinder.java | 2 +- .../pathing/calc/AbstractNodeCostSearch.java | 2 +- .../baritone/pathing/calc/IPathFinder.java | 2 +- src/main/java/baritone/pathing/calc/Path.java | 2 +- .../java/baritone/pathing/calc/PathNode.java | 2 +- .../java/baritone/pathing/goals/GoalAxis.java | 1 + .../baritone/pathing/goals/GoalBlock.java | 1 + .../baritone/pathing/goals/GoalComposite.java | 1 + .../pathing/goals/GoalGetToBlock.java | 1 + .../java/baritone/pathing/goals/GoalNear.java | 1 + .../baritone/pathing/goals/GoalRunAway.java | 1 + .../baritone/pathing/goals/GoalTwoBlocks.java | 1 + .../java/baritone/pathing/goals/GoalXZ.java | 1 + .../baritone/pathing/goals/GoalYLevel.java | 5 +- .../baritone/pathing/path/CutoffPath.java | 2 +- .../java/baritone/pathing/path/IPath.java | 2 +- .../utils/ExampleBaritoneControl.java | 1 + .../java/baritone/utils/PathRenderer.java | 2 +- .../pathing/calc/openset/OpenSetsTest.java | 2 +- 25 files changed, 200 insertions(+), 17 deletions(-) create mode 100644 src/api/java/baritone/api/BaritoneAPI.java create mode 100644 src/api/java/baritone/api/behavior/IPathingBehavior.java rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/Goal.java (92%) diff --git a/src/api/java/baritone/api/BaritoneAPI.java b/src/api/java/baritone/api/BaritoneAPI.java new file mode 100644 index 00000000..56a26745 --- /dev/null +++ b/src/api/java/baritone/api/BaritoneAPI.java @@ -0,0 +1,76 @@ +/* + * 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.api; + +import baritone.api.behavior.*; + +/** + * API exposure for various things implemented in Baritone. + *

+ * W.I.P + * + * @author Brady + * @since 9/23/2018 + */ +public class BaritoneAPI { + + private static IFollowBehavior followBehavior; + private static ILookBehavior lookBehavior; + private static IMemoryBehavior memoryBehavior; + private static IMineBehavior mineBehavior; + private static IPathingBehavior pathingBehavior; + + public static IFollowBehavior getFollowBehavior() { + return followBehavior; + } + + public static ILookBehavior getLookBehavior() { + return lookBehavior; + } + + public static IMemoryBehavior getMemoryBehavior() { + return memoryBehavior; + } + + public static IMineBehavior getMineBehavior() { + return mineBehavior; + } + + public static IPathingBehavior getPathingBehavior() { + return pathingBehavior; + } + + /** + * FOR INTERNAL USE ONLY + */ + // @formatter:off + public static void registerDefaultBehaviors( + IFollowBehavior followBehavior, + ILookBehavior lookBehavior, + IMemoryBehavior memoryBehavior, + IMineBehavior mineBehavior, + IPathingBehavior pathingBehavior + ) { + BaritoneAPI.followBehavior = followBehavior; + BaritoneAPI.lookBehavior = lookBehavior; + BaritoneAPI.memoryBehavior = memoryBehavior; + BaritoneAPI.mineBehavior = mineBehavior; + BaritoneAPI.pathingBehavior = pathingBehavior; + } + // @formatter:on +} diff --git a/src/api/java/baritone/api/behavior/IPathingBehavior.java b/src/api/java/baritone/api/behavior/IPathingBehavior.java new file mode 100644 index 00000000..e21d999d --- /dev/null +++ b/src/api/java/baritone/api/behavior/IPathingBehavior.java @@ -0,0 +1,68 @@ +/* + * 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.api.behavior; + +import baritone.api.pathing.goals.Goal; + +import java.util.Optional; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IPathingBehavior extends IBehavior { + + /** + * Returns the estimated remaining ticks in the current pathing + * segment. Given that the return type is an optional, {@link Optional#empty()} + * will be returned in the case that there is no current segment being pathed. + * + * @return The estimated remaining ticks in the current segment. + */ + Optional ticksRemainingInSegment(); + + /** + * Sets the pathing goal. + * + * @param goal The pathing goal + */ + void setGoal(Goal goal); + + /** + * @return The current pathing goal + */ + Goal getGoal(); + + /** + * Begins pathing. Calculation will start in a new thread, and once completed, + * movement will commence. Returns whether or not the operation was successful. + * + * @return Whether or not the operation was successful + */ + boolean path(); + + /** + * @return Whether or not a path is currently being executed. + */ + boolean isPathing(); + + /** + * Cancels the pathing behavior or the current path calculation. + */ + void cancel(); +} diff --git a/src/main/java/baritone/pathing/goals/Goal.java b/src/api/java/baritone/api/pathing/goals/Goal.java similarity index 92% rename from src/main/java/baritone/pathing/goals/Goal.java rename to src/api/java/baritone/api/pathing/goals/Goal.java index 0f01ca92..38cfb9d7 100644 --- a/src/main/java/baritone/pathing/goals/Goal.java +++ b/src/api/java/baritone/api/pathing/goals/Goal.java @@ -15,9 +15,8 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.pathing.movement.ActionCosts; import net.minecraft.util.math.BlockPos; /** @@ -25,7 +24,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public interface Goal extends ActionCosts { +public interface Goal { /** * Returns whether or not the specified position diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 61b2982a..d3db4918 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -17,6 +17,7 @@ package baritone; +import baritone.api.BaritoneAPI; import baritone.behavior.Behavior; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; @@ -89,6 +90,16 @@ public enum Baritone { registerBehavior(LocationTrackingBehavior.INSTANCE); registerBehavior(FollowBehavior.INSTANCE); registerBehavior(MineBehavior.INSTANCE); + + // TODO: Clean this up + // Maybe combine this call in someway with the registerBehavior calls? + BaritoneAPI.registerDefaultBehaviors( + FollowBehavior.INSTANCE, + LookBehavior.INSTANCE, + MemoryBehavior.INSTANCE, + MineBehavior.INSTANCE, + PathingBehavior.INSTANCE + ); } this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone"); if (!Files.exists(dir.toPath())) { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 2dde364b..ccee818f 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -25,7 +25,7 @@ import baritone.cache.CachedChunk; import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; import baritone.cache.WorldScanner; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.goals.GoalBlock; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 7820066c..ecf28b94 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -18,6 +18,7 @@ package baritone.behavior; import baritone.Baritone; +import baritone.api.behavior.IPathingBehavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RenderEvent; @@ -25,7 +26,7 @@ import baritone.api.event.events.TickEvent; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.goals.GoalXZ; import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; @@ -46,7 +47,7 @@ import java.util.HashSet; import java.util.Optional; import java.util.stream.Collectors; -public final class PathingBehavior extends Behavior implements Helper { +public final class PathingBehavior extends Behavior implements IPathingBehavior, Helper { public static final PathingBehavior INSTANCE = new PathingBehavior(); @@ -172,6 +173,7 @@ public final class PathingBehavior extends Behavior implements Helper { } } + @Override public Optional ticksRemainingInSegment() { if (current == null) { return Optional.empty(); @@ -179,10 +181,12 @@ public final class PathingBehavior extends Behavior implements Helper { return Optional.of(current.getPath().ticksRemainingFrom(current.getPosition())); } + @Override public void setGoal(Goal goal) { this.goal = goal; } + @Override public Goal getGoal() { return goal; } @@ -195,10 +199,19 @@ public final class PathingBehavior extends Behavior implements Helper { return next; } + // TODO: Expose this method in the API? + // In order to do so, we'd need to move over IPath which has a whole lot of references to other + // things that may not need to be exposed necessarily, so we'll need to figure that out. public Optional getPath() { return Optional.ofNullable(current).map(PathExecutor::getPath); } + @Override + public boolean isPathing() { + return this.current != null; + } + + @Override public void cancel() { dispatchPathEvent(PathEvent.CANCELED); current = null; @@ -212,6 +225,7 @@ public final class PathingBehavior extends Behavior implements Helper { * * @return true if this call started path calculation, false if it was already calculating or executing a path */ + @Override public boolean path() { if (goal == null) { return false; @@ -234,7 +248,10 @@ public final class PathingBehavior extends Behavior implements Helper { } } - public BlockPos pathStart() { + /** + * @return The starting {@link BlockPos} for a new path + */ + private BlockPos pathStart() { BetterBlockPos feet = playerFeet(); if (BlockStateInterface.get(feet.down()).getBlock().equals(Blocks.AIR) && MovementHelper.canWalkOn(feet.down().down())) { return feet.down(); diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 515f4b16..ddee9582 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -19,7 +19,7 @@ package baritone.pathing.calc; import baritone.Baritone; import baritone.pathing.calc.openset.BinaryHeapOpenSet; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 5c8d0da9..587a3b7d 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -18,7 +18,7 @@ package baritone.pathing.calc; import baritone.behavior.PathingBehavior; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; diff --git a/src/main/java/baritone/pathing/calc/IPathFinder.java b/src/main/java/baritone/pathing/calc/IPathFinder.java index 3723865d..6ed2b3a7 100644 --- a/src/main/java/baritone/pathing/calc/IPathFinder.java +++ b/src/main/java/baritone/pathing/calc/IPathFinder.java @@ -17,7 +17,7 @@ package baritone.pathing.calc; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.path.IPath; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 85450f27..7f8cf085 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -17,7 +17,7 @@ package baritone.pathing.calc; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.Movement; import baritone.pathing.movement.Moves; import baritone.pathing.path.IPath; diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 9b960a83..6d4142aa 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -17,7 +17,7 @@ package baritone.pathing.calc; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; /** diff --git a/src/main/java/baritone/pathing/goals/GoalAxis.java b/src/main/java/baritone/pathing/goals/GoalAxis.java index a75d2bb7..1882a7e3 100644 --- a/src/main/java/baritone/pathing/goals/GoalAxis.java +++ b/src/main/java/baritone/pathing/goals/GoalAxis.java @@ -18,6 +18,7 @@ package baritone.pathing.goals; import baritone.Baritone; +import baritone.api.pathing.goals.Goal; public class GoalAxis implements Goal { diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index f5cd2dfb..ea28c057 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/goals/GoalComposite.java b/src/main/java/baritone/pathing/goals/GoalComposite.java index b7bb9e6e..a4dafa45 100644 --- a/src/main/java/baritone/pathing/goals/GoalComposite.java +++ b/src/main/java/baritone/pathing/goals/GoalComposite.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import net.minecraft.util.math.BlockPos; import java.util.Arrays; diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 3ade972f..8f249ed0 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 0d0c9c75..f312c9ee 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/main/java/baritone/pathing/goals/GoalRunAway.java index d0702640..9ca74711 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/main/java/baritone/pathing/goals/GoalRunAway.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import net.minecraft.util.math.BlockPos; import java.util.Arrays; diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 428279a1..c5036c35 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/main/java/baritone/pathing/goals/GoalXZ.java index 7f200e64..8053ee04 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/main/java/baritone/pathing/goals/GoalXZ.java @@ -18,6 +18,7 @@ package baritone.pathing.goals; import baritone.Baritone; +import baritone.api.pathing.goals.Goal; import baritone.utils.Utils; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/main/java/baritone/pathing/goals/GoalYLevel.java index 2ac46981..fa4af522 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/main/java/baritone/pathing/goals/GoalYLevel.java @@ -17,12 +17,15 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.Goal; +import baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; + /** * Useful for mining (getting to diamond / iron level) * * @author leijurv */ -public class GoalYLevel implements Goal { +public class GoalYLevel implements Goal, ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { /** * The target Y level diff --git a/src/main/java/baritone/pathing/path/CutoffPath.java b/src/main/java/baritone/pathing/path/CutoffPath.java index 295f3830..e517452e 100644 --- a/src/main/java/baritone/pathing/path/CutoffPath.java +++ b/src/main/java/baritone/pathing/path/CutoffPath.java @@ -17,7 +17,7 @@ package baritone.pathing.path; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.Movement; import baritone.utils.pathing.BetterBlockPos; diff --git a/src/main/java/baritone/pathing/path/IPath.java b/src/main/java/baritone/pathing/path/IPath.java index 59cb8cac..0701abf6 100644 --- a/src/main/java/baritone/pathing/path/IPath.java +++ b/src/main/java/baritone/pathing/path/IPath.java @@ -18,7 +18,7 @@ package baritone.pathing.path; import baritone.Baritone; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.Movement; import baritone.utils.Helper; import baritone.utils.Utils; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 5d0fcdaf..1bcfd3a2 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -19,6 +19,7 @@ package baritone.utils; import baritone.Baritone; import baritone.Settings; +import baritone.api.pathing.goals.Goal; import baritone.behavior.Behavior; import baritone.api.event.events.ChatEvent; import baritone.behavior.FollowBehavior; diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 86f49e5e..e5c35650 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -18,7 +18,7 @@ package baritone.utils; import baritone.Baritone; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.goals.GoalXZ; diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 5f7b98d0..c15e1747 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -18,7 +18,7 @@ package baritone.pathing.calc.openset; import baritone.pathing.calc.PathNode; -import baritone.pathing.goals.Goal; +import baritone.api.pathing.goals.Goal; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; From eeea07ed2b48dac472c2d1f40e90602817050e9d Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 18:35:55 -0500 Subject: [PATCH 258/329] Move Settings to api --- src/api/java/baritone/api/BaritoneAPI.java | 8 ++++++ .../java/baritone/api}/Settings.java | 11 +++++--- src/api/java/baritone/api/utils/Logger.java | 27 +++++++++++++++++++ src/main/java/baritone/Baritone.java | 7 ++++- .../java/baritone/behavior/LookBehavior.java | 2 +- .../utils/ExampleBaritoneControl.java | 2 +- src/main/java/baritone/utils/Helper.java | 5 ---- 7 files changed, 50 insertions(+), 12 deletions(-) rename src/{main/java/baritone => api/java/baritone/api}/Settings.java (98%) create mode 100644 src/api/java/baritone/api/utils/Logger.java diff --git a/src/api/java/baritone/api/BaritoneAPI.java b/src/api/java/baritone/api/BaritoneAPI.java index 56a26745..bfdf60ff 100644 --- a/src/api/java/baritone/api/BaritoneAPI.java +++ b/src/api/java/baritone/api/BaritoneAPI.java @@ -29,6 +29,10 @@ import baritone.api.behavior.*; */ public class BaritoneAPI { + // General + private static final Settings settings = new Settings(); + + // Behaviors private static IFollowBehavior followBehavior; private static ILookBehavior lookBehavior; private static IMemoryBehavior memoryBehavior; @@ -55,6 +59,10 @@ public class BaritoneAPI { return pathingBehavior; } + public static Settings getSettings() { + return settings; + } + /** * FOR INTERNAL USE ONLY */ diff --git a/src/main/java/baritone/Settings.java b/src/api/java/baritone/api/Settings.java similarity index 98% rename from src/main/java/baritone/Settings.java rename to src/api/java/baritone/api/Settings.java index 87bd1812..6f0d668b 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -15,9 +15,9 @@ * along with Baritone. If not, see . */ -package baritone; +package baritone.api; -import baritone.utils.Helper; +import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.text.ITextComponent; @@ -32,6 +32,7 @@ import java.util.function.Consumer; * @author leijurv */ public class Settings { + /** * Allow Baritone to break blocks */ @@ -389,9 +390,11 @@ public class Settings { public Setting followRadius = new Setting<>(3); /** - * Instead of Baritone logging to chat, set a custom consumer. + * The function that is called when Baritone will log to chat. This function can be added to + * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting + * {@link Setting#value}; */ - public Setting> logger = new Setting<>(new Helper() {}::addToChat); + public Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); public final Map> byLowerName; public final List> allSettings; diff --git a/src/api/java/baritone/api/utils/Logger.java b/src/api/java/baritone/api/utils/Logger.java new file mode 100644 index 00000000..c2f6c99a --- /dev/null +++ b/src/api/java/baritone/api/utils/Logger.java @@ -0,0 +1,27 @@ +/* + * 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.api.utils; + +/** + * @author Brady + * @since 9/23/2018 + */ +public class Logger { + + +} diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index d3db4918..4f3e52f2 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -18,6 +18,7 @@ package baritone; import baritone.api.BaritoneAPI; +import baritone.api.Settings; import baritone.behavior.Behavior; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; @@ -81,7 +82,11 @@ public enum Baritone { this.threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); this.gameEventHandler = new GameEventHandler(); this.inputOverrideHandler = new InputOverrideHandler(); - this.settings = new Settings(); + + // Acquire the "singleton" instance of the settings directly from the API + // We might want to change this... + this.settings = BaritoneAPI.getSettings(); + this.behaviors = new ArrayList<>(); { registerBehavior(PathingBehavior.INSTANCE); diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 9d1a2e58..6086c536 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -18,7 +18,7 @@ package baritone.behavior; import baritone.Baritone; -import baritone.Settings; +import baritone.api.Settings; import baritone.api.behavior.ILookBehavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 1bcfd3a2..be9f6d3f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -18,7 +18,7 @@ package baritone.utils; import baritone.Baritone; -import baritone.Settings; +import baritone.api.Settings; import baritone.api.pathing.goals.Goal; import baritone.behavior.Behavior; import baritone.api.event.events.ChatEvent; diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index b9b3f0eb..f4c8ae2d 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -99,9 +99,4 @@ public interface Helper { component.appendSibling(new TextComponentString(" " + message)); Baritone.settings().logger.get().accept(component); } - - default void addToChat(ITextComponent msg) { - mc.ingameGUI.getChatGUI().printChatMessage(msg); - } - } From e3b777d2ef2b029d05054bd84342d8b73b4a3328 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 19:23:57 -0500 Subject: [PATCH 259/329] Update the API usage --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0118d56d..9ad6a5df 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,12 @@ Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actu # API example ``` -Baritone.settings().allowSprint.value = true; -Baritone.settings().pathTimeoutMS.value = 2000L; +BaritoneAPI.getSettings().allowSprint.value = true; +BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L; -PathingBehavior.INSTANCE.setGoal(new GoalXZ(10000, 20000)); -PathingBehavior.INSTANCE.path(); +// Note that at this moment in time the Goal implementations are not exposed in the API +BaritoneAPI.getPathingBehavior().setGoal(new GoalXZ(10000, 20000)); +BaritoneAPI.getPathingBehavior().path(); ``` # FAQ From 4d5446ddbdc55a09b8148a5ed46e4f2b7a489b51 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 19:34:04 -0500 Subject: [PATCH 260/329] We don't keep secrets here --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ad6a5df..2bc1ca34 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Sure! (As long as usage is in compliance with the LGPL 3 License) ## How is it so fast? -Magic +Magic. (Hours of [Leijurv](https://github.com/leijurv) enduring excruciating pain) ## Why is it called Baritone? From aa6bdd7f332b701fae3f6dac8e27c85633799a90 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 19:39:04 -0500 Subject: [PATCH 261/329] Minor changes to the README --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bc1ca34..193d723e 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,18 @@ [![License](https://img.shields.io/github/license/cabaletta/baritone.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) +Unofficial Jenkins: [![Build Status](https://plutiejenkins.leijurv.com/job/baritone/badge/icon)](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/) + A Minecraft pathfinder bot. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). -Features +Here are some links to help to get started: -Baritone + Impact +- [Features](FEATURES.md) -Unofficial Jenkins: [![Build Status](https://plutiejenkins.leijurv.com/job/baritone/badge/icon)](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/) +- [Baritone + Impact](IMPACT.md) + +There's also some useful information down below # Setup From 5edd4e06bb453526eca1a2af9f90a071f6217a2c Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 19:39:37 -0500 Subject: [PATCH 262/329] Utilize another relative link in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 193d723e..ef13bcdf 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ $ gradlew genIntellijRuns ``` # Chat control -Defined here +[Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel. From 23e1ea002033103e92793a20b3b5b13fd1d51cf9 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 19:48:17 -0500 Subject: [PATCH 263/329] Plutie's Jenkins is dead rn --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef13bcdf..7668981c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,12 @@ [![License](https://img.shields.io/github/license/cabaletta/baritone.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7150d8ccf6094057b1782aa7a8f92d7d)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) -Unofficial Jenkins: [![Build Status](https://plutiejenkins.leijurv.com/job/baritone/badge/icon)](https://plutiejenkins.leijurv.com/job/baritone/lastSuccessfulBuild/) + + +Unofficial Jenkins: [![Jenkins Status](https://img.shields.io/badge/jenkins-offline-red.svg)]() A Minecraft pathfinder bot. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From fa7a0b3c45815595a1edbd8a02eb3dcfaf56f675 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 18:00:54 -0700 Subject: [PATCH 264/329] readd costs --- .../baritone/utils/ExampleBaritoneControl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index be9f6d3f..26881699 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -19,9 +19,9 @@ package baritone.utils; import baritone.Baritone; import baritone.api.Settings; +import baritone.api.event.events.ChatEvent; import baritone.api.pathing.goals.Goal; import baritone.behavior.Behavior; -import baritone.api.event.events.ChatEvent; import baritone.behavior.FollowBehavior; import baritone.behavior.MineBehavior; import baritone.behavior.PathingBehavior; @@ -30,7 +30,7 @@ import baritone.cache.Waypoint; import baritone.cache.WorldProvider; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.goals.*; -import baritone.pathing.movement.MovementHelper; +import baritone.pathing.movement.*; import net.minecraft.block.Block; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.entity.Entity; @@ -39,6 +39,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class ExampleBaritoneControl extends Behavior implements Helper { @@ -429,10 +431,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - // TODO - /*if (msg.equals("costs")) { - Movement[] movements = AStarPathFinder.getConnectedPositions(new BetterBlockPos(playerFeet()), new CalculationContext()); - List moves = new ArrayList<>(Arrays.asList(movements)); + if (msg.equals("costs")) { + List moves = Stream.of(Moves.values()).map(x -> x.apply0(playerFeet())).collect(Collectors.toCollection(ArrayList::new)); while (moves.contains(null)) { moves.remove(null); } @@ -448,6 +448,6 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } event.cancel(); return; - }*/ + } } } From 89ad673ae375716ad59315a64bc15367798cd958 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Sep 2018 18:44:54 -0700 Subject: [PATCH 265/329] convenience methods --- .../pathing/calc/AbstractNodeCostSearch.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 587a3b7d..f579f236 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -17,8 +17,8 @@ package baritone.pathing.calc; -import baritone.behavior.PathingBehavior; import baritone.api.pathing.goals.Goal; +import baritone.behavior.PathingBehavior; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -163,6 +163,18 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { currentlyRunning = null; } + public PathNode mostRecentNodeConsidered() { + return mostRecentConsidered; + } + + public PathNode bestNodeSoFar() { + return bestSoFar[0]; + } + + public PathNode startNode() { + return startNode; + } + @Override public Optional pathToMostRecentNodeConsidered() { try { From c3a21b928ea42e318cd30647c2b364ebea0dff4a Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 21:35:36 -0500 Subject: [PATCH 266/329] When PathingBehavior is disabled, clear all of the key override states --- src/main/java/baritone/behavior/PathingBehavior.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index ecf28b94..2d62a0f1 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -428,4 +428,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // System.out.println("Frame took " + (split - start) + " " + (end - split)); //} } + + @Override + public void onDisable() { + Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + } } From 7b0f14a0e5978cc9a5381517a82a3037a94db437 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Sep 2018 21:47:19 -0500 Subject: [PATCH 267/329] Configurable colors for path rendering --- src/api/java/baritone/api/Settings.java | 37 +++++++++++++++++++ .../baritone/behavior/PathingBehavior.java | 16 ++++---- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 6f0d668b..dd4867b6 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -22,8 +22,10 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.text.ITextComponent; +import java.awt.*; import java.lang.reflect.Field; import java.util.*; +import java.util.List; import java.util.function.Consumer; /** @@ -396,6 +398,41 @@ public class Settings { */ public Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); + /** + * The color of the current path + */ + public Setting colorCurrentPath = new Setting<>(Color.RED); + + /** + * The color of the next path + */ + public Setting colorNextPath = new Setting<>(Color.MAGENTA); + + /** + * The color of the blocks to break + */ + public Setting colorBlocksToBreak = new Setting<>(Color.RED); + + /** + * The color of the blocks to place + */ + public Setting colorBlocksToPlace = new Setting<>(Color.GREEN); + + /** + * The color of the blocks to walk into + */ + public Setting colorBlocksToWalkInto = new Setting<>(Color.MAGENTA); + + /** + * The color of the best path so far + */ + public Setting colorBestPathSoFar = new Setting<>(Color.BLUE); + + /** + * The color of the path to the most recent considered node + */ + public Setting colorMostRecentConsidered = new Setting<>(Color.CYAN); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 2d62a0f1..2ed2ffc5 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -398,27 +398,27 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // Render the current path, if there is one if (current != null && current.getPath() != null) { int renderBegin = Math.max(current.getPosition() - 3, 0); - PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Color.RED, Baritone.settings().fadePath.get(), 10, 20); + PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Baritone.settings().colorCurrentPath.get(), Baritone.settings().fadePath.get(), 10, 20); } if (next != null && next.getPath() != null) { - PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.MAGENTA, Baritone.settings().fadePath.get(), 10, 20); + PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Baritone.settings().colorNextPath.get(), Baritone.settings().fadePath.get(), 10, 20); } //long split = System.nanoTime(); if (current != null) { - PathRenderer.drawManySelectionBoxes(player(), current.toBreak(), partialTicks, Color.RED); - PathRenderer.drawManySelectionBoxes(player(), current.toPlace(), partialTicks, Color.GREEN); - PathRenderer.drawManySelectionBoxes(player(), current.toWalkInto(), partialTicks, Color.MAGENTA); + PathRenderer.drawManySelectionBoxes(player(), current.toBreak(), partialTicks, Baritone.settings().colorBlocksToBreak.get()); + PathRenderer.drawManySelectionBoxes(player(), current.toPlace(), partialTicks, Baritone.settings().colorBlocksToPlace.get()); + PathRenderer.drawManySelectionBoxes(player(), current.toWalkInto(), partialTicks, Baritone.settings().colorBlocksToWalkInto.get()); } // If there is a path calculation currently running, render the path calculation process AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(currentlyRunning -> { currentlyRunning.bestPathSoFar().ifPresent(p -> { - PathRenderer.drawPath(p, 0, player(), partialTicks, Color.BLUE, Baritone.settings().fadePath.get(), 10, 20); + PathRenderer.drawPath(p, 0, player(), partialTicks, Baritone.settings().colorBestPathSoFar.get(), Baritone.settings().fadePath.get(), 10, 20); currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> { - PathRenderer.drawPath(mr, 0, player(), partialTicks, Color.CYAN, Baritone.settings().fadePath.get(), 10, 20); - PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Color.CYAN); + PathRenderer.drawPath(mr, 0, player(), partialTicks, Baritone.settings().colorMostRecentConsidered.get(), Baritone.settings().fadePath.get(), 10, 20); + PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Baritone.settings().colorMostRecentConsidered.get()); }); }); }); From 4ec9a4fc5bdb3f47c29b1e19d996d8242675b041 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 09:57:06 -0700 Subject: [PATCH 268/329] really cancel, fixes #178 --- src/main/java/baritone/behavior/PathingBehavior.java | 6 +++++- .../java/baritone/pathing/calc/AbstractNodeCostSearch.java | 2 -- src/main/java/baritone/utils/ExampleBaritoneControl.java | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 2ed2ffc5..9848bb6d 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -23,10 +23,10 @@ import baritone.api.event.events.PathEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RenderEvent; import baritone.api.event.events.TickEvent; +import baritone.api.pathing.goals.Goal; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; -import baritone.api.pathing.goals.Goal; import baritone.pathing.goals.GoalXZ; import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; @@ -220,6 +220,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel); } + public void forceCancel() { // NOT exposed on public api + isPathCalcInProgress = false; + } + /** * Start calculating a path if we aren't already * diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index f579f236..21f6d848 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -18,7 +18,6 @@ package baritone.pathing.calc; import baritone.api.pathing.goals.Goal; -import baritone.behavior.PathingBehavior; import baritone.pathing.path.IPath; import baritone.utils.pathing.BetterBlockPos; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -159,7 +158,6 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { } public static void forceCancel() { - PathingBehavior.INSTANCE.cancel(); currentlyRunning = null; } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 26881699..0b5e03d1 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -206,7 +206,11 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("forcecancel")) { + MineBehavior.INSTANCE.cancel(); + FollowBehavior.INSTANCE.cancel(); + PathingBehavior.INSTANCE.cancel(); AbstractNodeCostSearch.forceCancel(); + PathingBehavior.INSTANCE.forceCancel(); event.cancel(); logDirect("ok force canceled"); return; From 5650c86a7d52f510ed36637850b92ceb21588e54 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 10:17:01 -0700 Subject: [PATCH 269/329] update goal in new thread --- src/main/java/baritone/behavior/MineBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index ccee818f..e429f956 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -21,11 +21,11 @@ import baritone.Baritone; import baritone.api.behavior.IMineBehavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.TickEvent; +import baritone.api.pathing.goals.Goal; import baritone.cache.CachedChunk; import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; import baritone.cache.WorldScanner; -import baritone.api.pathing.goals.Goal; import baritone.pathing.goals.GoalBlock; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; @@ -78,7 +78,7 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); if (mineGoalUpdateInterval != 0) { if (event.getCount() % mineGoalUpdateInterval == 0) { - updateGoal(); + Baritone.INSTANCE.getExecutor().execute(this::updateGoal); } } PathingBehavior.INSTANCE.revalidateGoal(); From d6c2c053db01e18bb223ab808b629fb62bfca9a1 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 12:36:03 -0500 Subject: [PATCH 270/329] Create IWaypoint interface in api --- .../java/baritone/api/cache/IWaypoint.java | 111 ++++++++++++++++++ src/main/java/baritone/cache/Waypoint.java | 81 +++++++------ src/main/java/baritone/cache/Waypoints.java | 16 +-- .../utils/ExampleBaritoneControl.java | 8 +- 4 files changed, 166 insertions(+), 50 deletions(-) create mode 100644 src/api/java/baritone/api/cache/IWaypoint.java diff --git a/src/api/java/baritone/api/cache/IWaypoint.java b/src/api/java/baritone/api/cache/IWaypoint.java new file mode 100644 index 00000000..01df2a48 --- /dev/null +++ b/src/api/java/baritone/api/cache/IWaypoint.java @@ -0,0 +1,111 @@ +/* + * 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.api.cache; + +import net.minecraft.util.math.BlockPos; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * A marker for a position in the world. + * + * @author Brady + * @since 9/24/2018 + */ +public interface IWaypoint { + + /** + * @return The label for this waypoint + */ + String getName(); + + /** + * Returns the tag for this waypoint. The tag is a category + * for the waypoint in a sense, it describes the source of + * the waypoint. + * + * @return The waypoint tag + */ + Tag getTag(); + + /** + * Returns the unix epoch time in milliseconds that this waypoint + * was created. This value should only be set once, when the waypoint + * is initially created, and not when it is being loaded from file. + * + * @return The unix epoch milliseconds that this waypoint was created + */ + long getCreationTimestamp(); + + /** + * Returns the actual block position of this waypoint. + * + * @return The block position of this waypoint + */ + BlockPos getLocation(); + + enum Tag { + + /** + * Tag indicating a position explictly marked as a home base + */ + HOME("home", "base"), + + /** + * Tag indicating a position that the local player has died at + */ + DEATH("death"), + + /** + * Tag indicating a bed position + */ + BED("bed", "spawn"), + + /** + * Tag indicating that the waypoint was user-created + */ + USER("user"); + + /** + * A list of all of the + */ + private static final List TAG_LIST = Collections.unmodifiableList(Arrays.asList(Tag.values())); + + /** + * The names for the tag, anything that the tag can be referred to as. + */ + private final String[] names; + + Tag(String... names) { + this.names = names; + } + + /** + * Finds a tag from one of the names that could be used to identify said tag. + * + * @param name The name of the tag + * @return The tag, if one is found, otherwise, {@code null} + */ + public static Tag fromString(String name) { + return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null); + } + } +} diff --git a/src/main/java/baritone/cache/Waypoint.java b/src/main/java/baritone/cache/Waypoint.java index 4fd6c57a..00f4410a 100644 --- a/src/main/java/baritone/cache/Waypoint.java +++ b/src/main/java/baritone/cache/Waypoint.java @@ -17,77 +17,82 @@ package baritone.cache; -import com.google.common.collect.ImmutableList; +import baritone.api.cache.IWaypoint; import net.minecraft.util.math.BlockPos; -import org.apache.commons.lang3.ArrayUtils; import java.util.Date; -import java.util.List; /** - * A single waypoint + * Basic implementation of {@link IWaypoint} * * @author leijurv */ -public class Waypoint { +public class Waypoint implements IWaypoint { - public final String name; - public final Tag tag; + private final String name; + private final Tag tag; private final long creationTimestamp; - public final BlockPos location; + private final BlockPos location; public Waypoint(String name, Tag tag, BlockPos location) { this(name, tag, location, System.currentTimeMillis()); } - Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) { // read from disk + /** + * Constructor called when a Waypoint is read from disk, adds the creationTimestamp + * as a parameter so that it is reserved after a waypoint is wrote to the disk. + * + * @param name The waypoint name + * @param tag The waypoint tag + * @param location The waypoint location + * @param creationTimestamp When the waypoint was created + */ + Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) { this.name = name; this.tag = tag; this.location = location; this.creationTimestamp = creationTimestamp; } - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - if (!(o instanceof Waypoint)) { - return false; - } - Waypoint w = (Waypoint) o; - return name.equals(w.name) && tag == w.tag && location.equals(w.location); - } - @Override public int hashCode() { return name.hashCode() + tag.hashCode() + location.hashCode(); //lol } - public long creationTimestamp() { - return creationTimestamp; + @Override + public String getName() { + return this.name; } + @Override + public Tag getTag() { + return this.tag; + } + + @Override + public long getCreationTimestamp() { + return this.creationTimestamp; + } + + @Override + public BlockPos getLocation() { + return this.location; + } + + @Override public String toString() { return name + " " + location.toString() + " " + new Date(creationTimestamp).toString(); } - public enum Tag { - HOME("home", "base"), - DEATH("death"), - BED("bed", "spawn"), - USER("user"); - - private static final List TAG_LIST = ImmutableList.builder().add(Tag.values()).build(); - - private final String[] names; - - Tag(String... names) { - this.names = names; + @Override + public boolean equals(Object o) { + if (o == null) { + return false; } - - public static Tag fromString(String name) { - return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null); + if (!(o instanceof IWaypoint)) { + return false; } + IWaypoint w = (IWaypoint) o; + return name.equals(w.getName()) && tag == w.getTag() && location.equals(w.getLocation()); } } diff --git a/src/main/java/baritone/cache/Waypoints.java b/src/main/java/baritone/cache/Waypoints.java index be76e34e..f0483025 100644 --- a/src/main/java/baritone/cache/Waypoints.java +++ b/src/main/java/baritone/cache/Waypoints.java @@ -97,11 +97,11 @@ public class Waypoints { out.writeLong(WAYPOINT_MAGIC_VALUE); out.writeLong(waypoints.get(tag).size()); for (Waypoint waypoint : waypoints.get(tag)) { - out.writeUTF(waypoint.name); - out.writeLong(waypoint.creationTimestamp()); - out.writeInt(waypoint.location.getX()); - out.writeInt(waypoint.location.getY()); - out.writeInt(waypoint.location.getZ()); + out.writeUTF(waypoint.getName()); + out.writeLong(waypoint.getCreationTimestamp()); + out.writeInt(waypoint.getLocation().getX()); + out.writeInt(waypoint.getLocation().getY()); + out.writeInt(waypoint.getLocation().getZ()); } } catch (IOException ex) { ex.printStackTrace(); @@ -114,12 +114,12 @@ public class Waypoints { public Waypoint getMostRecentByTag(Waypoint.Tag tag) { // Find a waypoint of the given tag which has the greatest timestamp value, indicating the most recent - return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.creationTimestamp())).orElse(null); + return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.getCreationTimestamp())).orElse(null); } public void addWaypoint(Waypoint waypoint) { // no need to check for duplicate, because it's a Set not a List - waypoints.get(waypoint.tag).add(waypoint); - save(waypoint.tag); + waypoints.get(waypoint.getTag()).add(waypoint); + save(waypoint.getTag()); } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 0b5e03d1..6e24f1e8 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -344,7 +344,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { Set waypoints = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getByTag(tag); // might as well show them from oldest to newest List sorted = new ArrayList<>(waypoints); - sorted.sort(Comparator.comparingLong(Waypoint::creationTimestamp)); + sorted.sort(Comparator.comparingLong(Waypoint::getCreationTimestamp)); logDirect("Waypoints under tag " + tag + ":"); for (Waypoint waypoint : sorted) { logDirect(waypoint.toString()); @@ -390,7 +390,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - Goal goal = new GoalBlock(waypoint.location); + Goal goal = new GoalBlock(waypoint.getLocation()); PathingBehavior.INSTANCE.setGoal(goal); if (!PathingBehavior.INSTANCE.path()) { if (!goal.isInGoal(playerFeet())) { @@ -409,7 +409,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("spawn not saved, defaulting to world spawn. set goal to " + goal); PathingBehavior.INSTANCE.setGoal(goal); } else { - Goal goal = new GoalBlock(waypoint.location); + Goal goal = new GoalBlock(waypoint.getLocation()); PathingBehavior.INSTANCE.setGoal(goal); logDirect("Set goal to most recent bed " + goal); } @@ -427,7 +427,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { if (waypoint == null) { logDirect("home not saved"); } else { - Goal goal = new GoalBlock(waypoint.location); + Goal goal = new GoalBlock(waypoint.getLocation()); PathingBehavior.INSTANCE.setGoal(goal); PathingBehavior.INSTANCE.path(); logDirect("Going to saved home " + goal); From df88b02ed50b9685400174d56d443fa77bb14944 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 12:48:00 -0500 Subject: [PATCH 271/329] Create IWaypointCollection interface in api --- .../api/cache/IWaypointCollection.java | 37 ++++++++++++++ src/main/java/baritone/cache/Waypoints.java | 49 +++++++++++++------ .../utils/ExampleBaritoneControl.java | 15 +++--- 3 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 src/api/java/baritone/api/cache/IWaypointCollection.java diff --git a/src/api/java/baritone/api/cache/IWaypointCollection.java b/src/api/java/baritone/api/cache/IWaypointCollection.java new file mode 100644 index 00000000..23450eeb --- /dev/null +++ b/src/api/java/baritone/api/cache/IWaypointCollection.java @@ -0,0 +1,37 @@ +/* + * 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.api.cache; + +import java.util.Set; + +/** + * @author Brady + * @since 9/24/2018 + */ +public interface IWaypointCollection { + + void addWaypoint(IWaypoint waypoint); + + void removeWaypoint(IWaypoint waypoint); + + IWaypoint getMostRecentByTag(IWaypoint.Tag tag); + + Set getByTag(IWaypoint.Tag tag); + + Set getAllWaypoints(); +} diff --git a/src/main/java/baritone/cache/Waypoints.java b/src/main/java/baritone/cache/Waypoints.java index f0483025..2122ddaf 100644 --- a/src/main/java/baritone/cache/Waypoints.java +++ b/src/main/java/baritone/cache/Waypoints.java @@ -17,19 +17,22 @@ package baritone.cache; +import baritone.api.cache.IWaypoint; +import baritone.api.cache.IWaypointCollection; import net.minecraft.util.math.BlockPos; import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; +import java.util.stream.Collectors; /** * Waypoints for a world * * @author leijurv */ -public class Waypoints { +public class Waypoints implements IWaypointCollection { /** * Magic value to detect invalid waypoint files @@ -37,7 +40,7 @@ public class Waypoints { private static final long WAYPOINT_MAGIC_VALUE = 121977993584L; // good value private final Path directory; - private final Map> waypoints; + private final Map> waypoints; Waypoints(Path directory) { this.directory = directory; @@ -58,9 +61,9 @@ public class Waypoints { } private synchronized void load(Waypoint.Tag tag) { - waypoints.put(tag, new HashSet<>()); + this.waypoints.put(tag, new HashSet<>()); - Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4"); + Path fileName = this.directory.resolve(tag.name().toLowerCase() + ".mp4"); if (!Files.exists(fileName)) { return; } @@ -82,21 +85,21 @@ public class Waypoints { int x = in.readInt(); int y = in.readInt(); int z = in.readInt(); - waypoints.get(tag).add(new Waypoint(name, tag, new BlockPos(x, y, z), creationTimestamp)); + this.waypoints.get(tag).add(new Waypoint(name, tag, new BlockPos(x, y, z), creationTimestamp)); } } catch (IOException ignored) {} } private synchronized void save(Waypoint.Tag tag) { - Path fileName = directory.resolve(tag.name().toLowerCase() + ".mp4"); + Path fileName = this.directory.resolve(tag.name().toLowerCase() + ".mp4"); try ( FileOutputStream fileOut = new FileOutputStream(fileName.toFile()); BufferedOutputStream bufOut = new BufferedOutputStream(fileOut); DataOutputStream out = new DataOutputStream(bufOut) ) { out.writeLong(WAYPOINT_MAGIC_VALUE); - out.writeLong(waypoints.get(tag).size()); - for (Waypoint waypoint : waypoints.get(tag)) { + out.writeLong(this.waypoints.get(tag).size()); + for (IWaypoint waypoint : this.waypoints.get(tag)) { out.writeUTF(waypoint.getName()); out.writeLong(waypoint.getCreationTimestamp()); out.writeInt(waypoint.getLocation().getX()); @@ -108,18 +111,34 @@ public class Waypoints { } } - public Set getByTag(Waypoint.Tag tag) { - return Collections.unmodifiableSet(waypoints.get(tag)); + @Override + public void addWaypoint(IWaypoint waypoint) { + // no need to check for duplicate, because it's a Set not a List + if (waypoints.get(waypoint.getTag()).add(waypoint)) { + save(waypoint.getTag()); + } } - public Waypoint getMostRecentByTag(Waypoint.Tag tag) { + @Override + public void removeWaypoint(IWaypoint waypoint) { + if (waypoints.get(waypoint.getTag()).remove(waypoint)) { + save(waypoint.getTag()); + } + } + + @Override + public IWaypoint getMostRecentByTag(IWaypoint.Tag tag) { // Find a waypoint of the given tag which has the greatest timestamp value, indicating the most recent return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.getCreationTimestamp())).orElse(null); } - public void addWaypoint(Waypoint waypoint) { - // no need to check for duplicate, because it's a Set not a List - waypoints.get(waypoint.getTag()).add(waypoint); - save(waypoint.getTag()); + @Override + public Set getByTag(IWaypoint.Tag tag) { + return Collections.unmodifiableSet(this.waypoints.get(tag)); + } + + @Override + public Set getAllWaypoints() { + return this.waypoints.values().stream().flatMap(Collection::stream).collect(Collectors.toSet()); } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 6e24f1e8..beaa61dd 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -19,6 +19,7 @@ package baritone.utils; import baritone.Baritone; import baritone.api.Settings; +import baritone.api.cache.IWaypoint; import baritone.api.event.events.ChatEvent; import baritone.api.pathing.goals.Goal; import baritone.behavior.Behavior; @@ -341,12 +342,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - Set waypoints = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getByTag(tag); + Set waypoints = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getByTag(tag); // might as well show them from oldest to newest - List sorted = new ArrayList<>(waypoints); - sorted.sort(Comparator.comparingLong(Waypoint::getCreationTimestamp)); + List sorted = new ArrayList<>(waypoints); + sorted.sort(Comparator.comparingLong(IWaypoint::getCreationTimestamp)); logDirect("Waypoints under tag " + tag + ":"); - for (Waypoint waypoint : sorted) { + for (IWaypoint waypoint : sorted) { logDirect(waypoint.toString()); } event.cancel(); @@ -384,7 +385,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { PathingBehavior.INSTANCE.path(); return; } - Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag); if (waypoint == null) { logDirect("None saved for tag " + tag); event.cancel(); @@ -401,7 +402,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("spawn") || msg.equals("bed")) { - Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.BED); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.BED); if (waypoint == null) { BlockPos spawnPoint = player().getBedLocation(); // for some reason the default spawnpoint is underground sometimes @@ -423,7 +424,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("home")) { - Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME); if (waypoint == null) { logDirect("home not saved"); } else { From ba7e9a56e362be6f913e37de6a1b4b06bb384b04 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 10:50:25 -0700 Subject: [PATCH 272/329] remove intermediate object --- .../java/baritone/pathing/movement/Moves.java | 13 +++---- .../movement/movements/MovementDescend.java | 20 +++++------ .../movement/movements/MovementFall.java | 11 +++--- .../movements/result/DescendResult.java | 36 ------------------- .../movement/movements/result/MoveResult.java | 3 ++ 5 files changed, 24 insertions(+), 59 deletions(-) delete mode 100644 src/main/java/baritone/pathing/movement/movements/result/DescendResult.java diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index 7855c04a..dd79cd89 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -18,7 +18,6 @@ package baritone.pathing.movement; import baritone.pathing.movement.movements.*; -import baritone.pathing.movement.movements.result.DescendResult; import baritone.pathing.movement.movements.result.MoveResult; import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.pathing.BetterBlockPos; @@ -163,8 +162,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x + 1, z); - return new MoveResult(x + 1, res.y, z, res.cost); + return MovementDescend.cost(context, x, y, z, x + 1, z); } }, @@ -181,8 +179,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x - 1, z); - return new MoveResult(x - 1, res.y, z, res.cost); + return MovementDescend.cost(context, x, y, z, x - 1, z); } }, @@ -199,8 +196,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x, z - 1); - return new MoveResult(x, res.y, z - 1, res.cost); + return MovementDescend.cost(context, x, y, z, x, z - 1); } }, @@ -217,8 +213,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x, z + 1); - return new MoveResult(x, res.y, z + 1, res.cost); + return MovementDescend.cost(context, x, y, z, x, z + 1); } }, diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 8da86a37..2a90f31a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; -import baritone.pathing.movement.movements.result.DescendResult; +import baritone.pathing.movement.movements.result.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; @@ -33,7 +33,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; -import static baritone.pathing.movement.movements.result.DescendResult.IMPOSSIBLE; +import static baritone.pathing.movement.movements.result.MoveResult.IMPOSSIBLE; public class MovementDescend extends Movement { @@ -51,14 +51,14 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - DescendResult result = cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.y != dest.y) { + MoveResult result = cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.destY != dest.y) { return COST_INF; // doesn't apply to us, this position is a fall not a descend } return result.cost; } - public static DescendResult cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + public static MoveResult cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return IMPOSSIBLE; @@ -105,10 +105,10 @@ public class MovementDescend extends Movement { walk = WALK_ONE_OVER_SOUL_SAND_COST; } totalCost += walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); - return new DescendResult(y - 1, totalCost); + return new MoveResult(destX, y - 1, destZ, totalCost); } - public static DescendResult dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { + public static MoveResult dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, @@ -132,7 +132,7 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // TODO fix } // found a fall into water - return new DescendResult(newY, tentativeCost); // TODO incorporate water swim up cost? + return new MoveResult(destX, newY, destZ, tentativeCost); // TODO incorporate water swim up cost? } if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) { return IMPOSSIBLE; @@ -147,11 +147,11 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } if (context.hasWaterBucket() && fallHeight <= context.maxFallHeightBucket() + 1) { - return new DescendResult(newY + 1, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 + return new MoveResult(destX, newY + 1, destZ, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 } if (fallHeight <= context.maxFallHeightNoWater() + 1) { // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new DescendResult(newY + 1, tentativeCost); + return new MoveResult(destX, newY + 1, destZ, tentativeCost); } else { return IMPOSSIBLE; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 980371a9..1e6a36ac 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,8 +25,11 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; -import baritone.pathing.movement.movements.result.DescendResult; -import baritone.utils.*; +import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.BlockStateInterface; +import baritone.utils.InputOverrideHandler; +import baritone.utils.RayTraceUtils; +import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; @@ -46,8 +49,8 @@ public class MovementFall extends Movement { @Override protected double calculateCost(CalculationContext context) { - DescendResult result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.y != dest.y) { + MoveResult result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.destY != dest.y) { return COST_INF; // doesn't apply to us, this position is a descend not a fall } return result.cost; diff --git a/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java b/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java deleted file mode 100644 index c136fbb1..00000000 --- a/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.pathing.movement.movements.result; - -import static baritone.pathing.movement.ActionCosts.COST_INF; - -/** - * @author Brady - * @since 9/23/2018 - */ -public final class DescendResult extends Result { - - public static final DescendResult IMPOSSIBLE = new DescendResult(0, COST_INF); - - public final int y; - - public DescendResult(int y, double cost) { - super(cost); - this.y = y; - } -} diff --git a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java index a0419a2b..2b3ed0b7 100644 --- a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java +++ b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java @@ -17,7 +17,10 @@ package baritone.pathing.movement.movements.result; +import static baritone.pathing.movement.ActionCosts.COST_INF; + public final class MoveResult { + public static final MoveResult IMPOSSIBLE = new MoveResult(0, 0, 0, COST_INF); public final int destX; public final int destY; public final int destZ; From 0ed6bc966ef0d89e1ffe05c9f60b6309f4fc4047 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 10:55:35 -0700 Subject: [PATCH 273/329] standardize on moveresult --- .../java/baritone/pathing/movement/Moves.java | 13 ++----- .../movement/movements/MovementParkour.java | 18 ++++----- .../movement/movements/result/MoveResult.java | 5 +++ .../movements/result/ParkourResult.java | 37 ------------------- .../movement/movements/result/Result.java | 33 ----------------- 5 files changed, 18 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java delete mode 100644 src/main/java/baritone/pathing/movement/movements/result/Result.java diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index dd79cd89..e81aaf3e 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -19,7 +19,6 @@ package baritone.pathing.movement; import baritone.pathing.movement.movements.*; import baritone.pathing.movement.movements.result.MoveResult; -import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; @@ -273,8 +272,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.NORTH); - return new MoveResult(res.x, y, res.z, res.cost); + return MovementParkour.cost(context, x, y, z, EnumFacing.NORTH); } }, @@ -286,8 +284,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH); - return new MoveResult(res.x, y, res.z, res.cost); + return MovementParkour.cost(context, x, y, z, EnumFacing.SOUTH); } }, @@ -299,8 +296,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.EAST); - return new MoveResult(res.x, y, res.z, res.cost); + return MovementParkour.cost(context, x, y, z, EnumFacing.EAST); } }, @@ -312,8 +308,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - ParkourResult res = MovementParkour.cost(context, x, y, z, EnumFacing.WEST); - return new MoveResult(res.x, y, res.z, res.cost); + return MovementParkour.cost(context, x, y, z, EnumFacing.WEST); } }; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 73a812fd..7c04dfff 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; -import baritone.pathing.movement.movements.result.ParkourResult; +import baritone.pathing.movement.movements.result.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; @@ -37,7 +37,7 @@ import net.minecraft.util.math.Vec3d; import java.util.Objects; -import static baritone.pathing.movement.movements.result.ParkourResult.IMPOSSIBLE; +import static baritone.pathing.movement.movements.result.MoveResult.IMPOSSIBLE; public class MovementParkour extends Movement { @@ -54,12 +54,12 @@ public class MovementParkour extends Movement { } public static MovementParkour cost(CalculationContext context, BetterBlockPos src, EnumFacing direction) { - ParkourResult res = cost(context, src.x, src.y, src.z, direction); - int dist = Math.abs(res.x - src.x) + Math.abs(res.z - src.z); + MoveResult res = cost(context, src.x, src.y, src.z, direction); + int dist = Math.abs(res.destX - src.x) + Math.abs(res.destZ - src.z); return new MovementParkour(src, dist, direction); } - public static ParkourResult cost(CalculationContext context, int x, int y, int z, EnumFacing dir) { + public static MoveResult cost(CalculationContext context, int x, int y, int z, EnumFacing dir) { if (!Baritone.settings().allowParkour.get()) { return IMPOSSIBLE; } @@ -97,7 +97,7 @@ public class MovementParkour extends Movement { } } if (MovementHelper.canWalkOn(x + xDiff * i, y - 1, z + zDiff * i)) { - return new ParkourResult(x + xDiff * i, z + zDiff * i, costFromJumpDistance(i)); + return new MoveResult(x + xDiff * i, y, z + zDiff * i, costFromJumpDistance(i)); } } if (!context.canSprint()) { @@ -122,7 +122,7 @@ public class MovementParkour extends Movement { continue; } if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) { - return new ParkourResult(destX, destZ, costFromJumpDistance(i) + context.placeBlockCost()); + return new MoveResult(destX, y, destZ, costFromJumpDistance(i) + context.placeBlockCost()); } } return IMPOSSIBLE; @@ -144,8 +144,8 @@ public class MovementParkour extends Movement { @Override protected double calculateCost(CalculationContext context) { - ParkourResult res = cost(context, src.x, src.y, src.z, direction); - if (res.x != dest.x || res.z != dest.z) { + MoveResult res = cost(context, src.x, src.y, src.z, direction); + if (res.destX != dest.x || res.destZ != dest.z) { return COST_INF; } return res.cost; diff --git a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java index 2b3ed0b7..95edb665 100644 --- a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java +++ b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java @@ -19,6 +19,11 @@ package baritone.pathing.movement.movements.result; import static baritone.pathing.movement.ActionCosts.COST_INF; +/** + * The result of a calculated movement, with destination x, y, z, and the cost of performing the movement + * + * @author leijurv + */ public final class MoveResult { public static final MoveResult IMPOSSIBLE = new MoveResult(0, 0, 0, COST_INF); public final int destX; diff --git a/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java b/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java deleted file mode 100644 index e30c77c1..00000000 --- a/src/main/java/baritone/pathing/movement/movements/result/ParkourResult.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.pathing.movement.movements.result; - -import static baritone.pathing.movement.ActionCosts.COST_INF; - -/** - * @author Brady - * @since 9/23/2018 - */ -public final class ParkourResult extends Result { - - public static final ParkourResult IMPOSSIBLE = new ParkourResult(0, 0, COST_INF); - - public final int x, z; - - public ParkourResult(int x, int z, double cost) { - super(cost); - this.x = x; - this.z = z; - } -} diff --git a/src/main/java/baritone/pathing/movement/movements/result/Result.java b/src/main/java/baritone/pathing/movement/movements/result/Result.java deleted file mode 100644 index a56c5f89..00000000 --- a/src/main/java/baritone/pathing/movement/movements/result/Result.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.pathing.movement.movements.result; - -/** - * Generic class for special movement results. Only contains a single "cost" field. - * - * @author Brady - * @since 9/23/2018 - */ -public class Result { - - public final double cost; - - public Result(double cost) { - this.cost = cost; - } -} From 111e03c5b8e82ced452c375d08ab6ea9df0fc612 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 13:39:23 -0500 Subject: [PATCH 274/329] i agree --- src/api/java/baritone/api/Settings.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index dd4867b6..e6238db4 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -323,8 +323,9 @@ public class Settings { public Setting prefix = new Setting<>(false); /** - * true: can mine blocks when in inventory, chat, or tabbed away in ESC menu - * false: works on cosmic prisons + * {@code true}: can mine blocks when in inventory, chat, or tabbed away in ESC menu + *

+ * {@code false}: works on cosmic prisons *

* LOL */ From 1cf4c9419f06512cf5c9a736a667e6d32a59b3c0 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 14:17:02 -0500 Subject: [PATCH 275/329] Add setting for goal box color --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index e6238db4..ab758f40 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -434,6 +434,11 @@ public class Settings { */ public Setting colorMostRecentConsidered = new Setting<>(Color.CYAN); + /** + * The color of the goal box + */ + public Setting colorGoalBox = new Setting<>(Color.GREEN); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 9848bb6d..a13d1015 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -385,7 +385,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // System.out.println(event.getPartialTicks()); float partialTicks = event.getPartialTicks(); if (goal != null && Baritone.settings().renderGoal.value) { - PathRenderer.drawLitDankGoalBox(player(), goal, partialTicks, Color.GREEN); + PathRenderer.drawLitDankGoalBox(player(), goal, partialTicks, Baritone.settings().colorGoalBox.get()); } if (!Baritone.settings().renderPath.get()) { return; From 35c8b03122e37d9c05b35a634a8e98d2b78a3144 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 14:42:22 -0500 Subject: [PATCH 276/329] Create IWorldData and IWorldProvider interfaces in api This fully exposes waypoints in the api, next step is cached worlds! --- src/api/java/baritone/api/BaritoneAPI.java | 11 +++++++ .../api/cache/IWaypointCollection.java | 31 ++++++++++++++++++ .../java/baritone/api/cache/IWorldData.java | 32 +++++++++++++++++++ .../baritone/api/cache/IWorldProvider.java | 32 +++++++++++++++++++ src/main/java/baritone/Baritone.java | 3 ++ .../behavior/LocationTrackingBehavior.java | 4 +-- src/main/java/baritone/cache/CachedWorld.java | 4 +-- src/main/java/baritone/cache/WorldData.java | 12 +++++-- .../java/baritone/cache/WorldProvider.java | 7 ++-- .../utils/ExampleBaritoneControl.java | 12 +++---- 10 files changed, 133 insertions(+), 15 deletions(-) create mode 100644 src/api/java/baritone/api/cache/IWorldData.java create mode 100644 src/api/java/baritone/api/cache/IWorldProvider.java diff --git a/src/api/java/baritone/api/BaritoneAPI.java b/src/api/java/baritone/api/BaritoneAPI.java index bfdf60ff..75acf6d1 100644 --- a/src/api/java/baritone/api/BaritoneAPI.java +++ b/src/api/java/baritone/api/BaritoneAPI.java @@ -18,6 +18,7 @@ package baritone.api; import baritone.api.behavior.*; +import baritone.api.cache.IWorldProvider; /** * API exposure for various things implemented in Baritone. @@ -31,6 +32,7 @@ public class BaritoneAPI { // General private static final Settings settings = new Settings(); + private static IWorldProvider worldProvider; // Behaviors private static IFollowBehavior followBehavior; @@ -63,6 +65,15 @@ public class BaritoneAPI { return settings; } + /** + * FOR INTERNAL USE ONLY + */ + public static void registerProviders( + IWorldProvider worldProvider + ) { + BaritoneAPI.worldProvider = worldProvider; + } + /** * FOR INTERNAL USE ONLY */ diff --git a/src/api/java/baritone/api/cache/IWaypointCollection.java b/src/api/java/baritone/api/cache/IWaypointCollection.java index 23450eeb..051b199e 100644 --- a/src/api/java/baritone/api/cache/IWaypointCollection.java +++ b/src/api/java/baritone/api/cache/IWaypointCollection.java @@ -25,13 +25,44 @@ import java.util.Set; */ public interface IWaypointCollection { + /** + * Adds a waypoint to this collection + * + * @param waypoint The waypoint + */ void addWaypoint(IWaypoint waypoint); + /** + * Removes a waypoint from this collection + * + * @param waypoint The waypoint + */ void removeWaypoint(IWaypoint waypoint); + /** + * Gets the most recently created waypoint by the specified {@link IWaypoint.Tag} + * + * @param tag The tag + * @return The most recently created waypoint with the specified tag + */ IWaypoint getMostRecentByTag(IWaypoint.Tag tag); + /** + * Gets all of the waypoints that have the specified tag + * + * @see IWaypointCollection#getAllWaypoints() + * + * @param tag The tag + * @return All of the waypoints with the specified tag + */ Set getByTag(IWaypoint.Tag tag); + /** + * Gets all of the waypoints in this collection, regardless of the tag. + * + * @see IWaypointCollection#getByTag(IWaypoint.Tag) + * + * @return All of the waypoints in this collection + */ Set getAllWaypoints(); } diff --git a/src/api/java/baritone/api/cache/IWorldData.java b/src/api/java/baritone/api/cache/IWorldData.java new file mode 100644 index 00000000..c7ca580a --- /dev/null +++ b/src/api/java/baritone/api/cache/IWorldData.java @@ -0,0 +1,32 @@ +/* + * 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.api.cache; + +/** + * @author Brady + * @since 9/24/2018 + */ +public interface IWorldData { + + /** + * Returns the waypoint collection for this world. + * + * @return The waypoint collection for this world + */ + IWaypointCollection getWaypoints(); +} diff --git a/src/api/java/baritone/api/cache/IWorldProvider.java b/src/api/java/baritone/api/cache/IWorldProvider.java new file mode 100644 index 00000000..0e54ef46 --- /dev/null +++ b/src/api/java/baritone/api/cache/IWorldProvider.java @@ -0,0 +1,32 @@ +/* + * 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.api.cache; + +/** + * @author Brady + * @since 9/24/2018 + */ +public interface IWorldProvider { + + /** + * Returns the data of the currently loaded world + * + * @return The current world data + */ + IWorldData getCurrentWorld(); +} diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 4f3e52f2..933b8954 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -22,6 +22,7 @@ import baritone.api.Settings; import baritone.behavior.Behavior; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; +import baritone.cache.WorldProvider; import baritone.event.GameEventHandler; import baritone.utils.InputOverrideHandler; import net.minecraft.client.Minecraft; @@ -87,6 +88,8 @@ public enum Baritone { // We might want to change this... this.settings = BaritoneAPI.getSettings(); + BaritoneAPI.registerProviders(WorldProvider.INSTANCE); + this.behaviors = new ArrayList<>(); { registerBehavior(PathingBehavior.INSTANCE); diff --git a/src/main/java/baritone/behavior/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/LocationTrackingBehavior.java index 86badc06..6828d825 100644 --- a/src/main/java/baritone/behavior/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/LocationTrackingBehavior.java @@ -42,12 +42,12 @@ public final class LocationTrackingBehavior extends Behavior implements Helper { @Override public void onBlockInteract(BlockInteractEvent event) { if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) { - WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos())); + WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos())); } } @Override public void onPlayerDeath() { - WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet())); + WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet())); } } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 393c93fb..6973bdb1 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -116,9 +116,7 @@ public final class CachedWorld implements Helper { int regionZ = zoff + playerRegionZ; CachedRegion region = getOrCreateRegion(regionX, regionZ); if (region != null) { - for (BlockPos pos : region.getLocationsOf(block)) { - res.add(pos); - } + res.addAll(region.getLocationsOf(block)); } } } diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index 7866e9e8..ce228f90 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -18,6 +18,8 @@ package baritone.cache; import baritone.Baritone; +import baritone.api.cache.IWaypointCollection; +import baritone.api.cache.IWorldData; import java.nio.file.Path; @@ -26,9 +28,10 @@ import java.nio.file.Path; * * @author leijurv */ -public class WorldData { +public class WorldData implements IWorldData { + public final CachedWorld cache; - public final Waypoints waypoints; + private final Waypoints waypoints; //public final MapData map; public final Path directory; @@ -44,4 +47,9 @@ public class WorldData { cache.save(); }); } + + @Override + public IWaypointCollection getWaypoints() { + return this.waypoints; + } } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 2cd0b6dc..786bda96 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -18,6 +18,8 @@ package baritone.cache; import baritone.Baritone; +import baritone.api.cache.IWorldData; +import baritone.api.cache.IWorldProvider; import baritone.utils.Helper; import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; @@ -38,7 +40,7 @@ import java.util.function.Consumer; * @author Brady * @since 8/4/2018 11:06 AM */ -public enum WorldProvider implements Helper { +public enum WorldProvider implements IWorldProvider, Helper { INSTANCE; @@ -46,7 +48,8 @@ public enum WorldProvider implements Helper { private WorldData currentWorld; - public final WorldData getCurrentWorld() { + @Override + public final IWorldData getCurrentWorld() { return this.currentWorld; } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index beaa61dd..43e3f052 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -342,7 +342,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { event.cancel(); return; } - Set waypoints = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getByTag(tag); + Set waypoints = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getByTag(tag); // might as well show them from oldest to newest List sorted = new ArrayList<>(waypoints); sorted.sort(Comparator.comparingLong(IWaypoint::getCreationTimestamp)); @@ -355,7 +355,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } if (msg.startsWith("save")) { String name = msg.substring(4).trim(); - WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, Waypoint.Tag.USER, playerFeet())); + WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, playerFeet())); logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); event.cancel(); return; @@ -385,7 +385,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { PathingBehavior.INSTANCE.path(); return; } - IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag); if (waypoint == null) { logDirect("None saved for tag " + tag); event.cancel(); @@ -402,7 +402,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("spawn") || msg.equals("bed")) { - IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.BED); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.BED); if (waypoint == null) { BlockPos spawnPoint = player().getBedLocation(); // for some reason the default spawnpoint is underground sometimes @@ -418,13 +418,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("sethome")) { - WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet())); + WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet())); logDirect("Saved. Say home to set goal."); event.cancel(); return; } if (msg.equals("home")) { - IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME); + IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.HOME); if (waypoint == null) { logDirect("home not saved"); } else { From 787665ae08b40e14010239b9b133f1b22bcdecc8 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 14:43:02 -0500 Subject: [PATCH 277/329] Actually add getter for the world provider instance in api --- src/api/java/baritone/api/BaritoneAPI.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/java/baritone/api/BaritoneAPI.java b/src/api/java/baritone/api/BaritoneAPI.java index 75acf6d1..aa9491db 100644 --- a/src/api/java/baritone/api/BaritoneAPI.java +++ b/src/api/java/baritone/api/BaritoneAPI.java @@ -65,6 +65,10 @@ public class BaritoneAPI { return settings; } + public static IWorldProvider getWorldProvider() { + return worldProvider; + } + /** * FOR INTERNAL USE ONLY */ From 9e27a59d7f576e459e91d506bcd705dfaf3519c0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 12:44:34 -0700 Subject: [PATCH 278/329] cache on load check --- src/main/java/baritone/utils/BlockStateInterface.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index fda465f4..068721cd 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -95,7 +95,9 @@ public class BlockStateInterface implements Helper { if (prevChunk != null && prevChunk.x == x >> 4 && prevChunk.z == z >> 4) { return true; } - if (mc.world.getChunk(x >> 4, z >> 4).isLoaded()) { + prevChunk = mc.world.getChunk(x >> 4, z >> 4); + if (prevChunk.isLoaded()) { + prev = prevChunk; return true; } CachedRegion prevRegion = prevCached; @@ -106,11 +108,12 @@ public class BlockStateInterface implements Helper { if (world == null) { return false; } - CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); - if (region == null) { + prevRegion = world.cache.getRegion(x >> 9, z >> 9); + if (prevRegion == null) { return false; } - return region.isCached(x & 511, z & 511); + prevCached = prevRegion; + return prevRegion.isCached(x & 511, z & 511); } public static void clearCachedChunk() { From 812c23e1cae8181aa92f652f166c671623cfc61b Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 14:47:48 -0500 Subject: [PATCH 279/329] Fix compiler error and revert addAll meme --- src/main/java/baritone/cache/CachedWorld.java | 4 +++- src/main/java/baritone/cache/WorldProvider.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 6973bdb1..393c93fb 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -116,7 +116,9 @@ public final class CachedWorld implements Helper { int regionZ = zoff + playerRegionZ; CachedRegion region = getOrCreateRegion(regionX, regionZ); if (region != null) { - res.addAll(region.getLocationsOf(block)); + for (BlockPos pos : region.getLocationsOf(block)) { + res.add(pos); + } } } } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 786bda96..1ccbfe53 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -49,7 +49,7 @@ public enum WorldProvider implements IWorldProvider, Helper { private WorldData currentWorld; @Override - public final IWorldData getCurrentWorld() { + public final WorldData getCurrentWorld() { return this.currentWorld; } From 758e9c511a459cc4eabe653148647ab1137ab62a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 13:13:24 -0700 Subject: [PATCH 280/329] tiny optimization --- .../pathing/movement/movements/MovementDiagonal.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 5a5b736a..83491506 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -61,7 +61,8 @@ public class MovementDiagonal extends Movement { if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return COST_INF; } - if (!MovementHelper.canWalkThrough(destX, y, destZ) || !MovementHelper.canWalkThrough(destX, y + 1, destZ)) { + IBlockState destInto = BlockStateInterface.get(destX, y, destZ); + if (!MovementHelper.canWalkThrough(destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(destX, y + 1, destZ)) { return COST_INF; } IBlockState destWalkOn = BlockStateInterface.get(destX, y - 1, destZ); @@ -103,7 +104,7 @@ public class MovementDiagonal extends Movement { return COST_INF; } } - if (BlockStateInterface.isWater(BlockStateInterface.getBlock(x, y, z)) || BlockStateInterface.isWater(BlockStateInterface.getBlock(destX, y, destZ))) { + if (BlockStateInterface.isWater(BlockStateInterface.getBlock(x, y, z)) || BlockStateInterface.isWater(destInto.getBlock())) { // Ignore previous multiplier // Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water // Not even touching the blocks below From 65672b5564119dff410fc8b28ccc5f3455b757bb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 13:14:36 -0700 Subject: [PATCH 281/329] gotta go fast lol --- .../pathing/movement/movements/MovementDiagonal.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 83491506..d1fe89a4 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -25,7 +25,6 @@ import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.Block; -import net.minecraft.block.BlockMagma; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; @@ -78,11 +77,11 @@ public class MovementDiagonal extends Movement { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; } Block cuttingOver1 = BlockStateInterface.get(x, y - 1, destZ).getBlock(); - if (cuttingOver1 instanceof BlockMagma || BlockStateInterface.isLava(cuttingOver1)) { + if (cuttingOver1 == Blocks.MAGMA || BlockStateInterface.isLava(cuttingOver1)) { return COST_INF; } Block cuttingOver2 = BlockStateInterface.get(destX, y - 1, z).getBlock(); - if (cuttingOver2 instanceof BlockMagma || BlockStateInterface.isLava(cuttingOver2)) { + if (cuttingOver2 == Blocks.MAGMA || BlockStateInterface.isLava(cuttingOver2)) { return COST_INF; } IBlockState pb0 = BlockStateInterface.get(x, y, destZ); From 2c4384970c97da74c9f1697908643c55e062b9e7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 14:33:41 -0700 Subject: [PATCH 282/329] that class has moved --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 8880de6e..03a3ed3f 100644 --- a/proguard.pro +++ b/proguard.pro @@ -22,7 +22,7 @@ #-keep class baritone.pathing.goals.** { *; } # setting names are reflected from field names, so keep field names --keepclassmembers class baritone.Settings { +-keepclassmembers class baritone.api.Settings { public ; } From 1553f991298a71fb057430b15207d8457e7f7538 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 14:35:14 -0700 Subject: [PATCH 283/329] unneeded --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 03a3ed3f..b25c6a12 100644 --- a/proguard.pro +++ b/proguard.pro @@ -5,7 +5,7 @@ -keepattributes Signature -keepattributes *Annotation* --optimizationpasses 20 +-optimizationpasses 10 -verbose -allowaccessmodification # anything not kept can be changed from public to private and inlined etc From 5087e65c612b84b4d117e67fa9c10de81662b10c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 15:27:37 -0700 Subject: [PATCH 284/329] what --- proguard.pro | 2 +- src/main/java/baritone/behavior/LookBehavior.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/proguard.pro b/proguard.pro index b25c6a12..721cd42b 100644 --- a/proguard.pro +++ b/proguard.pro @@ -17,7 +17,7 @@ -repackageclasses 'baritone' #-keep class baritone.behavior.** { *; } -#-keep class baritone.api.** { *; } +-keep class baritone.api.** { *; } #-keep class baritone.* { *; } #-keep class baritone.pathing.goals.** { *; } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 6086c536..a02ffa51 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -22,8 +22,8 @@ import baritone.api.Settings; import baritone.api.behavior.ILookBehavior; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.RotationMoveEvent; -import baritone.utils.Helper; import baritone.api.utils.Rotation; +import baritone.utils.Helper; public final class LookBehavior extends Behavior implements ILookBehavior, Helper { @@ -93,7 +93,6 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe default: break; } - new Thread().start(); } @Override From fc591eafd306846ad6de96608e8b33be6ea3d7bf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 17:31:52 -0500 Subject: [PATCH 285/329] We must preserve it --- src/main/java/baritone/cache/ChunkPacker.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 1df1e9c0..59a56f0e 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -91,7 +91,9 @@ public final class ChunkPacker implements Helper { //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); String[] blockNames = new String[256]; for (int z = 0; z < 16; z++) { + // @formatter:off https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html + // @formatter:on for (int x = 0; x < 16; x++) { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); From da3f5251b57c09e3f6bea9f40803c1407c7f1d40 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 15:36:59 -0700 Subject: [PATCH 286/329] refactor --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 2 +- src/main/java/baritone/pathing/movement/Moves.java | 2 +- .../baritone/pathing/movement/movements/MovementDescend.java | 4 ++-- .../baritone/pathing/movement/movements/MovementFall.java | 2 +- .../baritone/pathing/movement/movements/MovementParkour.java | 4 ++-- .../movements/result => utils/pathing}/MoveResult.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/baritone/{pathing/movement/movements/result => utils/pathing}/MoveResult.java (96%) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index ddee9582..b1f83bde 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -23,7 +23,7 @@ import baritone.api.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; -import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.pathing.MoveResult; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index e81aaf3e..bf4ce890 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -18,7 +18,7 @@ package baritone.pathing.movement; import baritone.pathing.movement.movements.*; -import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.pathing.MoveResult; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 2a90f31a..4966b41e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; -import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; @@ -33,7 +33,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; -import static baritone.pathing.movement.movements.result.MoveResult.IMPOSSIBLE; +import static baritone.utils.pathing.MoveResult.IMPOSSIBLE; public class MovementDescend extends Movement { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 1e6a36ac..3dc327d3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,7 +25,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; -import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.RayTraceUtils; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 7c04dfff..9d61ac5e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; -import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; @@ -37,7 +37,7 @@ import net.minecraft.util.math.Vec3d; import java.util.Objects; -import static baritone.pathing.movement.movements.result.MoveResult.IMPOSSIBLE; +import static baritone.utils.pathing.MoveResult.IMPOSSIBLE; public class MovementParkour extends Movement { diff --git a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java b/src/main/java/baritone/utils/pathing/MoveResult.java similarity index 96% rename from src/main/java/baritone/pathing/movement/movements/result/MoveResult.java rename to src/main/java/baritone/utils/pathing/MoveResult.java index 95edb665..1ec96f76 100644 --- a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java +++ b/src/main/java/baritone/utils/pathing/MoveResult.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.pathing.movement.movements.result; +package baritone.utils.pathing; import static baritone.pathing.movement.ActionCosts.COST_INF; From cef4fb0f509af4251a3a5a6c6f2be732527a9c38 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 15:45:12 -0700 Subject: [PATCH 287/329] convert blocks to strings and back less --- src/main/java/baritone/cache/CachedChunk.java | 9 ++++----- src/main/java/baritone/cache/CachedRegion.java | 6 +++--- src/main/java/baritone/cache/ChunkPacker.java | 10 +++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index fbdd42f7..f9a7d96b 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -99,13 +99,13 @@ public final class CachedChunk implements IBlockTypeAccess { /** * The block names of each surface level block for generating an overview */ - private final String[] overview; + private final IBlockState[] overview; private final int[] heightMap; private final Map> specialBlockLocations; - CachedChunk(int x, int z, BitSet data, String[] overview, Map> specialBlockLocations) { + CachedChunk(int x, int z, BitSet data, IBlockState[] overview, Map> specialBlockLocations) { validateSize(data); this.x = x; @@ -122,12 +122,11 @@ public final class CachedChunk implements IBlockTypeAccess { int internalPos = z << 4 | x; if (heightMap[internalPos] == y) { // we have this exact block, it's a surface block - IBlockState state = ChunkPacker.stringToBlock(overview[internalPos]).getDefaultState(); /*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())) { throw new IllegalStateException("failed " + Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16)); }*/ - return state; + return overview[internalPos]; } PathingBlockType type = getType(x, y, z); if (type == PathingBlockType.SOLID && y == 127 && mc.player.dimension == -1) { @@ -157,7 +156,7 @@ public final class CachedChunk implements IBlockTypeAccess { } } - public final String[] getOverview() { + public final IBlockState[] getOverview() { return overview; } diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index f036f264..7409ff38 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -145,7 +145,7 @@ public final class CachedRegion implements IBlockTypeAccess { for (int x = 0; x < 32; x++) { if (chunks[x][z] != null) { for (int i = 0; i < 256; i++) { - out.writeUTF(chunks[x][z].getOverview()[i]); + out.writeUTF(ChunkPacker.blockToString(chunks[x][z].getOverview()[i].getBlock())); } } } @@ -215,7 +215,7 @@ public final class CachedRegion implements IBlockTypeAccess { int regionZ = this.z; int chunkX = x + 32 * regionX; int chunkZ = z + 32 * regionZ; - tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new String[256], location[x][z]); + tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new IBlockState[256], location[x][z]); break; case CHUNK_NOT_PRESENT: tmpCached[x][z] = null; @@ -229,7 +229,7 @@ public final class CachedRegion implements IBlockTypeAccess { for (int x = 0; x < 32; x++) { if (tmpCached[x][z] != null) { for (int i = 0; i < 256; i++) { - tmpCached[x][z].getOverview()[i] = in.readUTF(); + tmpCached[x][z].getOverview()[i] = ChunkPacker.stringToBlock(in.readUTF()).getDefaultState(); } } } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 59a56f0e..4164be3c 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -89,7 +89,8 @@ public final class ChunkPacker implements Helper { } //long end = System.nanoTime() / 1000000L; //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); - String[] blockNames = new String[256]; + IBlockState[] blocks = new IBlockState[256]; + for (int z = 0; z < 16; z++) { // @formatter:off https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html @@ -98,15 +99,14 @@ public final class ChunkPacker implements Helper { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); if (bitSet.get(index) || bitSet.get(index + 1)) { - String name = blockToString(chunk.getBlockState(x, y, z).getBlock()); - blockNames[z << 4 | x] = name; + blocks[z << 4 | x] = chunk.getBlockState(x, y, z); continue https; } } - blockNames[z << 4 | x] = "air"; + blocks[z << 4 | x] = Blocks.AIR.getDefaultState(); } } - return new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks); + return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks); } public static String blockToString(Block block) { From 3e189510d49c2e528009034024e5d2df614795b7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 15:50:09 -0700 Subject: [PATCH 288/329] bits test --- .../utils/pathing/PathingBlockTypeTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/java/baritone/utils/pathing/PathingBlockTypeTest.java diff --git a/src/test/java/baritone/utils/pathing/PathingBlockTypeTest.java b/src/test/java/baritone/utils/pathing/PathingBlockTypeTest.java new file mode 100644 index 00000000..1582b66f --- /dev/null +++ b/src/test/java/baritone/utils/pathing/PathingBlockTypeTest.java @@ -0,0 +1,32 @@ +/* + * 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.utils.pathing; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class PathingBlockTypeTest { + @Test + public void testBits() { + for (PathingBlockType type : PathingBlockType.values()) { + boolean[] bits = type.getBits(); + assertTrue(type == PathingBlockType.fromBits(bits[0], bits[1])); + } + } +} \ No newline at end of file From 239a95961e1de882b0b4861b5d5b74477449f878 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 17:56:13 -0500 Subject: [PATCH 289/329] Replace for loop with forEach --- src/main/java/baritone/cache/CachedWorld.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 393c93fb..775d2849 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -116,9 +116,8 @@ public final class CachedWorld implements Helper { int regionZ = zoff + playerRegionZ; CachedRegion region = getOrCreateRegion(regionX, regionZ); if (region != null) { - for (BlockPos pos : region.getLocationsOf(block)) { - res.add(pos); - } + // TODO: 100% verify if this or addAll is faster. + region.getLocationsOf(block).forEach(res::add); } } } From 76f287582e2f7bf38c74f4a0e9382870475417b5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 15:58:02 -0700 Subject: [PATCH 290/329] overhaul betterblockpostest --- .../utils/pathing/BetterBlockPosTest.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index 2f0ab688..459593b0 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -17,14 +17,16 @@ package baritone.utils.pathing; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import org.junit.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; public class BetterBlockPosTest { - @Test + // disabled since this is a benchmark, not really a test. also including it makes the tests take 50 seconds for no reason + /*@Test public void benchMulti() { System.out.println("Benching up()"); for (int i = 0; i < 10; i++) { @@ -37,7 +39,30 @@ public class BetterBlockPosTest { benchN(); assertTrue(i<10); } + }*/ + /** + * Make sure BetterBlockPos behaves just like BlockPos + */ + @Test + public void testSimple() { + BlockPos pos = new BlockPos(1, 2, 3); + BetterBlockPos better = new BetterBlockPos(1, 2, 3); + assertEquals(pos, better); + assertEquals(pos.up(), better.up()); + assertEquals(pos.down(), better.down()); + assertEquals(pos.north(), better.north()); + assertEquals(pos.south(), better.south()); + assertEquals(pos.east(), better.east()); + assertEquals(pos.west(), better.west()); + for (EnumFacing dir : EnumFacing.values()) { + assertEquals(pos.offset(dir), better.offset(dir)); + assertEquals(pos.offset(dir, 0), pos); + assertEquals(better.offset(dir, 0), better); + for (int i = -10; i < 10; i++) { + assertEquals(pos.offset(dir, i), better.offset(dir, i)); + } + } } public void benchOne() { From 7d27509e63f4acca6a75327bd7ce14ad490f899c Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:01:17 -0500 Subject: [PATCH 291/329] Don't forget --- src/main/java/baritone/cache/CachedWorld.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 775d2849..eff9391e 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -221,6 +221,7 @@ public final class CachedWorld implements Helper { private class PackerThread implements Runnable { public void run() { while (true) { + // TODO: Add CachedWorld unloading to remove the redundancy of having this LinkedBlockingQueue queue = toPack; if (queue == null) { break; From 750da2f1a6ca0ea189eec1e9bf1350ec250a495d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 16:05:02 -0700 Subject: [PATCH 292/329] stop breaking on cancel, hopefully fixes #127 --- src/main/java/baritone/behavior/PathingBehavior.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index a13d1015..660ddca1 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -31,6 +31,7 @@ import baritone.pathing.goals.GoalXZ; import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; import baritone.pathing.path.PathExecutor; +import baritone.utils.BlockBreakHelper; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.PathRenderer; @@ -40,7 +41,6 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; -import java.awt.*; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -218,6 +218,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, next = null; Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(AbstractNodeCostSearch::cancel); + BlockBreakHelper.stopBreakingBlock(); } public void forceCancel() { // NOT exposed on public api From 559f575db5228be7f796b001b33cd984014f31c1 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:08:57 -0500 Subject: [PATCH 293/329] Add javadocs to RayTraceUtils --- .../java/baritone/utils/RayTraceUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java index 1c8115a5..b313f1fe 100644 --- a/src/main/java/baritone/utils/RayTraceUtils.java +++ b/src/main/java/baritone/utils/RayTraceUtils.java @@ -31,6 +31,18 @@ public final class RayTraceUtils implements Helper { private RayTraceUtils() {} + /** + * Simulates a "vanilla" raytrace. A RayTraceResult returned by this method + * will be that of the next render pass given that the local player's yaw and + * pitch match the specified yaw and pitch values. This is particularly useful + * when you would like to simulate a "legit" raytrace with certainty that the only + * thing to achieve the desired outcome (whether it is hitting and entity or placing + * a block) can be done just by modifying user input. + * + * @param yaw The yaw to raytrace with + * @param pitch The pitch to raytrace with + * @return The calculated raytrace result + */ public static RayTraceResult simulateRayTrace(float yaw, float pitch) { RayTraceResult oldTrace = mc.objectMouseOver; float oldYaw = mc.player.rotationYaw; @@ -49,6 +61,14 @@ public final class RayTraceUtils implements Helper { return result; } + /** + * Performs a block raytrace with the specified rotations. This should only be used when + * any entity collisions can be ignored, because this method will not recognize if an + * entity is in the way or not. The local player's block reach distance will be used. + * + * @param rotation The rotation to raytrace towards + * @return The calculated raytrace result + */ public static RayTraceResult rayTraceTowards(Rotation rotation) { double blockReachDistance = mc.playerController.getBlockReachDistance(); Vec3d start = mc.player.getPositionEyes(1.0F); From 8ee7446517266041488b3458c32b1b3af01d3f0f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 16:15:59 -0700 Subject: [PATCH 294/329] save by coordinate, fixes #175 --- .../utils/ExampleBaritoneControl.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 43e3f052..5c8172a7 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -354,10 +354,26 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.startsWith("save")) { - String name = msg.substring(4).trim(); - WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, playerFeet())); - logDirect("Saved user defined tag under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); event.cancel(); + String name = msg.substring(4).trim(); + BlockPos pos = playerFeet(); + if (name.contains(" ")) { + logDirect("Name contains a space, assuming it's in the format 'save waypointName X Y Z'"); + String[] parts = name.split(" "); + if (parts.length != 4) { + logDirect("Unable to parse, expected four things"); + return; + } + try { + pos = new BlockPos(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3])); + } catch (NumberFormatException ex) { + logDirect("Unable to parse coordinate integers"); + return; + } + name = parts[0]; + } + WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, pos)); + logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto user' to set goal, say 'list user' to list."); return; } if (msg.startsWith("goto")) { From 6829bc920e36e76b219aa9349aed47201546e392 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 16:21:14 -0700 Subject: [PATCH 295/329] demolish goto, fixes #182 --- .../utils/ExampleBaritoneControl.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 5c8172a7..13879d52 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -383,29 +383,35 @@ public class ExampleBaritoneControl extends Behavior implements Helper { waypointType = waypointType.substring(0, waypointType.length() - 1); } Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType); + IWaypoint waypoint; if (tag == null) { String mining = waypointType; Block block = ChunkPacker.stringToBlock(mining); //logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase()); event.cancel(); if (block == null) { - logDirect("No locations for " + mining + " known, cancelling"); + waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null); + if (waypoint == null) { + logDirect("No locations for " + mining + " known, cancelling"); + return; + } + } else { + List locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64); + if (locs.isEmpty()) { + logDirect("No locations for " + mining + " known, cancelling"); + return; + } + PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.path(); return; } - List locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64); - if (locs.isEmpty()) { - logDirect("No locations for " + mining + " known, cancelling"); + } else { + waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag); + if (waypoint == null) { + logDirect("None saved for tag " + tag); + event.cancel(); return; } - PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new))); - PathingBehavior.INSTANCE.path(); - return; - } - IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag); - if (waypoint == null) { - logDirect("None saved for tag " + tag); - event.cancel(); - return; } Goal goal = new GoalBlock(waypoint.getLocation()); PathingBehavior.INSTANCE.setGoal(goal); From 2a8575caa88f97d3c468cde622a0d59f10f6905c Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:45:41 -0500 Subject: [PATCH 296/329] Begin to create interfaces in api for cached World and Region --- .../baritone/api/cache}/IBlockTypeAccess.java | 5 +- .../baritone/api/cache/ICachedRegion.java | 49 +++++++++++ .../java/baritone/api/cache/ICachedWorld.java | 82 +++++++++++++++++++ .../java/baritone/api/cache/IWorldData.java | 7 ++ .../java/baritone/behavior/MineBehavior.java | 2 +- src/main/java/baritone/cache/CachedChunk.java | 5 +- .../java/baritone/cache/CachedRegion.java | 8 +- src/main/java/baritone/cache/CachedWorld.java | 20 ++--- src/main/java/baritone/cache/WorldData.java | 8 +- .../java/baritone/event/GameEventHandler.java | 2 +- .../baritone/utils/BlockStateInterface.java | 11 +-- .../utils/ExampleBaritoneControl.java | 8 +- 12 files changed, 178 insertions(+), 29 deletions(-) rename src/{main/java/baritone/utils/pathing => api/java/baritone/api/cache}/IBlockTypeAccess.java (89%) create mode 100644 src/api/java/baritone/api/cache/ICachedRegion.java create mode 100644 src/api/java/baritone/api/cache/ICachedWorld.java diff --git a/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java b/src/api/java/baritone/api/cache/IBlockTypeAccess.java similarity index 89% rename from src/main/java/baritone/utils/pathing/IBlockTypeAccess.java rename to src/api/java/baritone/api/cache/IBlockTypeAccess.java index 4e34596a..242ff154 100644 --- a/src/main/java/baritone/utils/pathing/IBlockTypeAccess.java +++ b/src/api/java/baritone/api/cache/IBlockTypeAccess.java @@ -15,9 +15,8 @@ * along with Baritone. If not, see . */ -package baritone.utils.pathing; +package baritone.api.cache; -import baritone.utils.Helper; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -25,7 +24,7 @@ import net.minecraft.util.math.BlockPos; * @author Brady * @since 8/4/2018 2:01 AM */ -public interface IBlockTypeAccess extends Helper { +public interface IBlockTypeAccess { IBlockState getBlock(int x, int y, int z); diff --git a/src/api/java/baritone/api/cache/ICachedRegion.java b/src/api/java/baritone/api/cache/ICachedRegion.java new file mode 100644 index 00000000..5f9199fa --- /dev/null +++ b/src/api/java/baritone/api/cache/ICachedRegion.java @@ -0,0 +1,49 @@ +/* + * 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.api.cache; + +/** + * @author Brady + * @since 9/24/2018 + */ +public interface ICachedRegion extends IBlockTypeAccess { + + /** + * Returns whether or not the block at the specified X and Z coordinates + * is cached in this world. Similar to {@link ICachedWorld#isCached(int, int)}, + * however, the block coordinates should in on a scale from 0 to 511 (inclusive) + * because region sizes are 512x512 blocks. + * + * @see ICachedWorld#isCached(int, int) + * + * @param blockX The block X coordinate + * @param blockZ The block Z coordinate + * @return Whether or not the specified XZ location is cached + */ + boolean isCached(int blockX, int blockZ); + + /** + * The X coordinate of this region + */ + int getX(); + + /** + * The Z coordinate of this region + */ + int getZ(); +} diff --git a/src/api/java/baritone/api/cache/ICachedWorld.java b/src/api/java/baritone/api/cache/ICachedWorld.java new file mode 100644 index 00000000..f8196ebb --- /dev/null +++ b/src/api/java/baritone/api/cache/ICachedWorld.java @@ -0,0 +1,82 @@ +/* + * 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.api.cache; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.Chunk; + +import java.util.LinkedList; + +/** + * @author Brady + * @since 9/24/2018 + */ +public interface ICachedWorld { + + /** + * Returns the region at the specified region coordinates + * + * @param regionX The region X coordinate + * @param regionZ The region Z coordinate + * @return The region located at the specified coordinates + */ + ICachedRegion getRegion(int regionX, int regionZ); + + /** + * Queues the specified chunk for packing. This entails reading the contents + * of the chunk, then packing the data into the 2-bit format, and storing that + * in this cached world. + * + * @param chunk The chunk to pack and store + */ + void queueForPacking(Chunk chunk); + + /** + * Returns whether or not the block at the specified X and Z coordinates + * is cached in this world. + * + * @param blockX The block X coordinate + * @param blockZ The block Z coordinate + * @return Whether or not the specified XZ location is cached + */ + boolean isCached(int blockX, int blockZ); + + /** + * Scans the cached chunks for location of the specified special block. The + * information that is returned by this method may not be up to date, because + * older cached chunks can contain data that is much more likely to have changed. + * + * @param block The special block to search for + * @param maximum The maximum number of position results to receive + * @param maxRegionDistanceSq The maximum region distance, squared + * @return The locations found that match the special block + */ + LinkedList getLocationsOf(String block, int maximum, int maxRegionDistanceSq); + + /** + * Reloads all of the cached regions in this world from disk. Anything that is not saved + * will be lost. This operation does not execute in a new thread by default. + */ + void reloadAllFromDisk(); + + /** + * Saves all of the cached regions in this world to disk. This operation does not execute + * in a new thread by default. + */ + void save(); +} diff --git a/src/api/java/baritone/api/cache/IWorldData.java b/src/api/java/baritone/api/cache/IWorldData.java index c7ca580a..1031ba92 100644 --- a/src/api/java/baritone/api/cache/IWorldData.java +++ b/src/api/java/baritone/api/cache/IWorldData.java @@ -23,6 +23,13 @@ package baritone.api.cache; */ public interface IWorldData { + /** + * Returns the cached world for this world. A cached world is a simplified format + * of a regular world, intended for use on multiplayer servers where chunks are not + * traditionally stored to disk, allowing for long distance pathing with minimal disk usage. + */ + ICachedWorld getCachedWorld(); + /** * Returns the waypoint collection for this world. * diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index e429f956..2de6167a 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -139,7 +139,7 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe //long b = System.currentTimeMillis(); for (Block m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { - locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(ChunkPacker.blockToString(m), 1, 1)); + locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, 1)); } else { uninteresting.add(m); } diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index f9a7d96b..b8d88a49 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -17,7 +17,8 @@ package baritone.cache; -import baritone.utils.pathing.IBlockTypeAccess; +import baritone.api.cache.IBlockTypeAccess; +import baritone.utils.Helper; import baritone.utils.pathing.PathingBlockType; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -30,7 +31,7 @@ import java.util.*; * @author Brady * @since 8/3/2018 1:04 AM */ -public final class CachedChunk implements IBlockTypeAccess { +public final class CachedChunk implements IBlockTypeAccess, Helper { public static final Set BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(new HashSet() {{ add(Blocks.DIAMOND_ORE); diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 7409ff38..e9402bd5 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -17,7 +17,7 @@ package baritone.cache; -import baritone.utils.pathing.IBlockTypeAccess; +import baritone.api.cache.ICachedRegion; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -33,7 +33,8 @@ import java.util.zip.GZIPOutputStream; * @author Brady * @since 8/3/2018 9:35 PM */ -public final class CachedRegion implements IBlockTypeAccess { +public final class CachedRegion implements ICachedRegion { + private static final byte CHUNK_NOT_PRESENT = 0; private static final byte CHUNK_PRESENT = 1; @@ -77,6 +78,7 @@ public final class CachedRegion implements IBlockTypeAccess { return null; } + @Override public final boolean isCached(int x, int z) { return chunks[x >> 4][z >> 4] != null; } @@ -280,6 +282,7 @@ public final class CachedRegion implements IBlockTypeAccess { /** * @return The region x coordinate */ + @Override public final int getX() { return this.x; } @@ -287,6 +290,7 @@ public final class CachedRegion implements IBlockTypeAccess { /** * @return The region z coordinate */ + @Override public final int getZ() { return this.z; } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index eff9391e..3901303d 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -18,6 +18,7 @@ package baritone.cache; import baritone.Baritone; +import baritone.api.cache.ICachedWorld; import baritone.utils.Helper; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -36,7 +37,7 @@ import java.util.concurrent.LinkedBlockingQueue; * @author Brady * @since 8/4/2018 12:02 AM */ -public final class CachedWorld implements Helper { +public final class CachedWorld implements ICachedWorld, Helper { /** * The maximum number of regions in any direction from (0,0) @@ -83,6 +84,7 @@ public final class CachedWorld implements Helper { }); } + @Override public final void queueForPacking(Chunk chunk) { try { toPack.put(chunk); @@ -91,6 +93,7 @@ public final class CachedWorld implements Helper { } } + @Override public final boolean isCached(int blockX, int blockZ) { CachedRegion region = getRegion(blockX >> 9, blockZ >> 9); if (region == null) { @@ -99,7 +102,8 @@ public final class CachedWorld implements Helper { return region.isCached(blockX & 511, blockZ & 511); } - public final LinkedList getLocationsOf(String block, int minimum, int maxRegionDistanceSq) { + @Override + public final LinkedList getLocationsOf(String block, int maximum, int maxRegionDistanceSq) { LinkedList res = new LinkedList<>(); int playerRegionX = playerFeet().getX() >> 9; int playerRegionZ = playerFeet().getZ() >> 9; @@ -121,7 +125,7 @@ public final class CachedWorld implements Helper { } } } - if (res.size() >= minimum) { + if (res.size() >= maximum) { return res; } searchRadius++; @@ -134,6 +138,7 @@ public final class CachedWorld implements Helper { region.updateCachedChunk(chunk.x & 31, chunk.z & 31, chunk); } + @Override public final void save() { if (!Baritone.settings().chunkCaching.get()) { System.out.println("Not saving to disk; chunk caching is disabled."); @@ -153,6 +158,7 @@ public final class CachedWorld implements Helper { return new ArrayList<>(this.cachedRegions.values()); } + @Override public final void reloadAllFromDisk() { long start = System.nanoTime() / 1000000L; allRegions().forEach(region -> { @@ -164,13 +170,7 @@ public final class CachedWorld implements Helper { System.out.println("World load took " + (now - start) + "ms"); } - /** - * Returns the region at the specified region coordinates - * - * @param regionX The region X coordinate - * @param regionZ The region Z coordinate - * @return The region located at the specified coordinates - */ + @Override public final synchronized CachedRegion getRegion(int regionX, int regionZ) { return cachedRegions.get(getRegionID(regionX, regionZ)); } diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index ce228f90..6899284c 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -18,6 +18,7 @@ package baritone.cache; import baritone.Baritone; +import baritone.api.cache.ICachedWorld; import baritone.api.cache.IWaypointCollection; import baritone.api.cache.IWorldData; @@ -30,7 +31,7 @@ import java.nio.file.Path; */ public class WorldData implements IWorldData { - public final CachedWorld cache; + private final CachedWorld cache; private final Waypoints waypoints; //public final MapData map; public final Path directory; @@ -48,6 +49,11 @@ public class WorldData implements IWorldData { }); } + @Override + public ICachedWorld getCachedWorld() { + return this.cache; + } + @Override public IWaypointCollection getWaypoints() { return this.waypoints; diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 934dd532..61756e33 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -109,7 +109,7 @@ public final class GameEventHandler implements IGameEventListener, Helper { if (isPostPopulate || isPreUnload) { WorldProvider.INSTANCE.ifWorldLoaded(world -> { Chunk chunk = mc.world.getChunk(event.getX(), event.getZ()); - world.cache.queueForPacking(chunk); + world.getCachedWorld().queueForPacking(chunk); }); } diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 068721cd..1d8f5b5c 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.api.cache.ICachedRegion; import baritone.cache.CachedRegion; import baritone.cache.WorldData; import baritone.cache.WorldProvider; @@ -36,7 +37,7 @@ import net.minecraft.world.chunk.Chunk; public class BlockStateInterface implements Helper { private static Chunk prev = null; - private static CachedRegion prevCached = null; + private static ICachedRegion prevCached = null; private static IBlockState AIR = Blocks.AIR.getDefaultState(); @@ -70,13 +71,13 @@ public class BlockStateInterface implements Helper { } // same idea here, skip the Long2ObjectOpenHashMap.get if at all possible // except here, it's 512x512 tiles instead of 16x16, so even better repetition - CachedRegion cached = prevCached; + ICachedRegion cached = prevCached; if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) { WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); if (world == null) { return AIR; } - CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); + ICachedRegion region = world.getCachedWorld().getRegion(x >> 9, z >> 9); if (region == null) { return AIR; } @@ -100,7 +101,7 @@ public class BlockStateInterface implements Helper { prev = prevChunk; return true; } - CachedRegion prevRegion = prevCached; + ICachedRegion prevRegion = prevCached; if (prevRegion != null && prevRegion.getX() == x >> 9 && prevRegion.getZ() == z >> 9) { return prevRegion.isCached(x & 511, z & 511); } @@ -108,7 +109,7 @@ public class BlockStateInterface implements Helper { if (world == null) { return false; } - prevRegion = world.cache.getRegion(x >> 9, z >> 9); + prevRegion = world.getCachedWorld().getRegion(x >> 9, z >> 9); if (prevRegion == null) { return false; } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 13879d52..4bbef7e2 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -184,7 +184,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { Chunk chunk = cli.getLoadedChunk(x, z); if (chunk != null) { count++; - WorldProvider.INSTANCE.getCurrentWorld().cache.queueForPacking(chunk); + WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().queueForPacking(chunk); } } } @@ -272,20 +272,20 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } if (msg.equals("reloadall")) { - WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk(); + WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().reloadAllFromDisk(); logDirect("ok"); event.cancel(); return; } if (msg.equals("saveall")) { - WorldProvider.INSTANCE.getCurrentWorld().cache.save(); + WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().save(); logDirect("ok"); event.cancel(); return; } if (msg.startsWith("find")) { String blockType = msg.substring(4).trim(); - LinkedList locs = WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(blockType, 1, 4); + LinkedList locs = WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, 4); logDirect("Have " + locs.size() + " locations"); for (BlockPos pos : locs) { Block actually = BlockStateInterface.get(pos).getBlock(); From 30b63abb73134e5f794e5e7cbdc0fa80359f3c0b Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:50:29 -0500 Subject: [PATCH 297/329] Replace creation of new Helper instances in Utils --- src/main/java/baritone/utils/Helper.java | 5 +++++ src/main/java/baritone/utils/Utils.java | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index f4c8ae2d..a0ffdb96 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -35,6 +35,11 @@ import net.minecraft.util.text.TextFormatting; */ public interface Helper { + /** + * Instance of {@link Helper}. Used for static-context reference. + */ + Helper HELPER = new Helper() {}; + ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format( "%s[%sBaritone%s]%s", TextFormatting.DARK_PURPLE, diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 49f6b49d..12be404b 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -27,6 +27,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import static baritone.utils.Helper.HELPER; + /** * @author Brady * @since 8/1/2018 12:56 AM @@ -115,12 +117,12 @@ public final class Utils { } public static double playerDistanceToCenter(BlockPos pos) { - EntityPlayerSP player = (new Helper() {}).player(); + EntityPlayerSP player = HELPER.player(); return distanceToCenter(pos, player.posX, player.posY, player.posZ); } public static double playerFlatDistanceToCenter(BlockPos pos) { - EntityPlayerSP player = (new Helper() {}).player(); + EntityPlayerSP player = HELPER.player(); return distanceToCenter(pos, player.posX, pos.getY() + 0.5, player.posZ); } From 6ec6ff4596ffeda20ea777ffb8dd92fb14a2af05 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:51:10 -0500 Subject: [PATCH 298/329] Clean all imports --- src/main/java/baritone/Baritone.java | 1 - .../java/baritone/behavior/LocationTrackingBehavior.java | 2 +- src/main/java/baritone/behavior/LookBehaviorUtils.java | 5 ++++- src/main/java/baritone/cache/WorldProvider.java | 1 - src/main/java/baritone/pathing/calc/AStarPathFinder.java | 4 ++-- src/main/java/baritone/pathing/movement/MovementState.java | 2 +- src/main/java/baritone/pathing/movement/Moves.java | 2 +- .../baritone/pathing/movement/movements/MovementDescend.java | 2 +- .../baritone/pathing/movement/movements/MovementFall.java | 2 +- .../baritone/pathing/movement/movements/MovementParkour.java | 2 +- .../baritone/pathing/movement/movements/MovementPillar.java | 2 +- .../pathing/movement/movements/MovementTraverse.java | 2 +- src/main/java/baritone/utils/BlockStateInterface.java | 1 - .../java/baritone/pathing/calc/openset/OpenSetsTest.java | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 933b8954..14c35319 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -19,7 +19,6 @@ package baritone; import baritone.api.BaritoneAPI; import baritone.api.Settings; -import baritone.behavior.Behavior; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; import baritone.cache.WorldProvider; diff --git a/src/main/java/baritone/behavior/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/LocationTrackingBehavior.java index 6828d825..dee74e79 100644 --- a/src/main/java/baritone/behavior/LocationTrackingBehavior.java +++ b/src/main/java/baritone/behavior/LocationTrackingBehavior.java @@ -17,9 +17,9 @@ package baritone.behavior; +import baritone.api.event.events.BlockInteractEvent; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; -import baritone.api.event.events.BlockInteractEvent; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.BlockBed; diff --git a/src/main/java/baritone/behavior/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java index 451d83a1..c94f2a1f 100644 --- a/src/main/java/baritone/behavior/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java @@ -18,7 +18,10 @@ package baritone.behavior; import baritone.api.utils.Rotation; -import baritone.utils.*; +import baritone.utils.BlockStateInterface; +import baritone.utils.Helper; +import baritone.utils.RayTraceUtils; +import baritone.utils.Utils; import net.minecraft.block.BlockFire; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.*; diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 1ccbfe53..2aef54c6 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -18,7 +18,6 @@ package baritone.cache; import baritone.Baritone; -import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldProvider; import baritone.utils.Helper; import baritone.utils.accessor.IAnvilChunkLoader; diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index b1f83bde..43207ee3 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -18,15 +18,15 @@ package baritone.pathing.calc; import baritone.Baritone; -import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.api.pathing.goals.Goal; +import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; -import baritone.utils.pathing.MoveResult; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; +import baritone.utils.pathing.MoveResult; import net.minecraft.util.math.BlockPos; import java.util.HashSet; diff --git a/src/main/java/baritone/pathing/movement/MovementState.java b/src/main/java/baritone/pathing/movement/MovementState.java index a611b8f2..6d0262e6 100644 --- a/src/main/java/baritone/pathing/movement/MovementState.java +++ b/src/main/java/baritone/pathing/movement/MovementState.java @@ -17,8 +17,8 @@ package baritone.pathing.movement; -import baritone.utils.InputOverrideHandler.Input; import baritone.api.utils.Rotation; +import baritone.utils.InputOverrideHandler.Input; import net.minecraft.util.math.Vec3d; import java.util.HashMap; diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index bf4ce890..6f49dfbd 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -18,8 +18,8 @@ package baritone.pathing.movement; import baritone.pathing.movement.movements.*; -import baritone.utils.pathing.MoveResult; import baritone.utils.pathing.BetterBlockPos; +import baritone.utils.pathing.MoveResult; import net.minecraft.util.EnumFacing; /** diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 4966b41e..b8c6bc43 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -23,10 +23,10 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; -import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; +import baritone.utils.pathing.MoveResult; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 3dc327d3..0f165f6f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,12 +25,12 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; -import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.RayTraceUtils; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; +import baritone.utils.pathing.MoveResult; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 9d61ac5e..43391b01 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -23,11 +23,11 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; -import baritone.utils.pathing.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; +import baritone.utils.pathing.MoveResult; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 59085909..227a9162 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -17,13 +17,13 @@ package baritone.pathing.movement.movements; +import baritone.api.utils.Rotation; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; -import baritone.api.utils.Rotation; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 721e78a1..34bcfef3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -18,6 +18,7 @@ package baritone.pathing.movement.movements; import baritone.Baritone; +import baritone.api.utils.Rotation; import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; @@ -25,7 +26,6 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; -import baritone.api.utils.Rotation; import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.*; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 1d8f5b5c..f0ee8d3f 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -19,7 +19,6 @@ package baritone.utils; import baritone.Baritone; import baritone.api.cache.ICachedRegion; -import baritone.cache.CachedRegion; import baritone.cache.WorldData; import baritone.cache.WorldProvider; import net.minecraft.block.Block; diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index c15e1747..8cc0bec7 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -17,8 +17,8 @@ package baritone.pathing.calc.openset; -import baritone.pathing.calc.PathNode; import baritone.api.pathing.goals.Goal; +import baritone.pathing.calc.PathNode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; From b575f54977cc00783f2d2a1f14048bfe5faf637f Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:55:57 -0500 Subject: [PATCH 299/329] Revert BlockStateInterface changes because jurv wurv sad --- src/main/java/baritone/cache/WorldData.java | 2 +- .../java/baritone/utils/BlockStateInterface.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index 6899284c..19461d22 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -31,7 +31,7 @@ import java.nio.file.Path; */ public class WorldData implements IWorldData { - private final CachedWorld cache; + public final CachedWorld cache; private final Waypoints waypoints; //public final MapData map; public final Path directory; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index f0ee8d3f..068721cd 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -18,7 +18,7 @@ package baritone.utils; import baritone.Baritone; -import baritone.api.cache.ICachedRegion; +import baritone.cache.CachedRegion; import baritone.cache.WorldData; import baritone.cache.WorldProvider; import net.minecraft.block.Block; @@ -36,7 +36,7 @@ import net.minecraft.world.chunk.Chunk; public class BlockStateInterface implements Helper { private static Chunk prev = null; - private static ICachedRegion prevCached = null; + private static CachedRegion prevCached = null; private static IBlockState AIR = Blocks.AIR.getDefaultState(); @@ -70,13 +70,13 @@ public class BlockStateInterface implements Helper { } // same idea here, skip the Long2ObjectOpenHashMap.get if at all possible // except here, it's 512x512 tiles instead of 16x16, so even better repetition - ICachedRegion cached = prevCached; + CachedRegion cached = prevCached; if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) { WorldData world = WorldProvider.INSTANCE.getCurrentWorld(); if (world == null) { return AIR; } - ICachedRegion region = world.getCachedWorld().getRegion(x >> 9, z >> 9); + CachedRegion region = world.cache.getRegion(x >> 9, z >> 9); if (region == null) { return AIR; } @@ -100,7 +100,7 @@ public class BlockStateInterface implements Helper { prev = prevChunk; return true; } - ICachedRegion prevRegion = prevCached; + CachedRegion prevRegion = prevCached; if (prevRegion != null && prevRegion.getX() == x >> 9 && prevRegion.getZ() == z >> 9) { return prevRegion.isCached(x & 511, z & 511); } @@ -108,7 +108,7 @@ public class BlockStateInterface implements Helper { if (world == null) { return false; } - prevRegion = world.getCachedWorld().getRegion(x >> 9, z >> 9); + prevRegion = world.cache.getRegion(x >> 9, z >> 9); if (prevRegion == null) { return false; } From 529f8dae47533724c57399445cce1be3487fc777 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 18:58:08 -0500 Subject: [PATCH 300/329] Remove ignored hashCode call --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 4bbef7e2..66088cdb 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -300,7 +300,6 @@ public class ExampleBaritoneControl extends Behavior implements Helper { String[] blockTypes = msg.substring(4).trim().split(" "); try { int quantity = Integer.parseInt(blockTypes[1]); - ChunkPacker.stringToBlock(blockTypes[0]).hashCode(); MineBehavior.INSTANCE.mine(quantity, blockTypes[0]); logDirect("Will mine " + quantity + " " + blockTypes[0]); event.cancel(); From ce39183482f7f37ea878c4a880081ed28b05064b Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 19:03:19 -0500 Subject: [PATCH 301/329] Add more fast methods to BetterBlockPos --- .../utils/pathing/BetterBlockPos.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index eb85e6bf..7763b64e 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -126,18 +126,38 @@ public final class BetterBlockPos extends BlockPos { return new BetterBlockPos(x, y, z - 1); } + @Override + public BetterBlockPos north(int amt) { + return amt == 0 ? this : new BetterBlockPos(x, y, z - amt); + } + @Override public BetterBlockPos south() { return new BetterBlockPos(x, y, z + 1); } + @Override + public BetterBlockPos south(int amt) { + return amt == 0 ? this : new BetterBlockPos(x, y, z + amt); + } + @Override public BetterBlockPos east() { return new BetterBlockPos(x + 1, y, z); } + @Override + public BetterBlockPos east(int amt) { + return amt == 0 ? this : new BetterBlockPos(x + amt, y, z); + } + @Override public BetterBlockPos west() { return new BetterBlockPos(x - 1, y, z); } + + @Override + public BetterBlockPos west(int amt) { + return amt == 0 ? this : new BetterBlockPos(x - amt, y, z); + } } From 34e5811613ab32ff437a0317cd22063bd05e37e3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 17:15:22 -0700 Subject: [PATCH 302/329] and a couple more --- src/main/java/baritone/utils/pathing/BetterBlockPos.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/pathing/BetterBlockPos.java b/src/main/java/baritone/utils/pathing/BetterBlockPos.java index 7763b64e..7aed17c6 100644 --- a/src/main/java/baritone/utils/pathing/BetterBlockPos.java +++ b/src/main/java/baritone/utils/pathing/BetterBlockPos.java @@ -106,7 +106,7 @@ public final class BetterBlockPos extends BlockPos { @Override public BetterBlockPos down(int amt) { // see comment in up() - return new BetterBlockPos(x, y - amt, z); + return amt == 0 ? this : new BetterBlockPos(x, y - amt, z); } @Override @@ -117,6 +117,9 @@ public final class BetterBlockPos extends BlockPos { @Override public BetterBlockPos offset(EnumFacing dir, int dist) { + if (dist == 0) { + return this; + } Vec3i vec = dir.getDirectionVec(); return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); } From b9cba93d338bc67e8b35ed10f7b574cafcfd5919 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 19:18:46 -0500 Subject: [PATCH 303/329] Jurv's absolutely autistic practices made me have to do this shit --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 66088cdb..bd1ac0f1 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -300,7 +300,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper { String[] blockTypes = msg.substring(4).trim().split(" "); try { int quantity = Integer.parseInt(blockTypes[1]); - MineBehavior.INSTANCE.mine(quantity, blockTypes[0]); + Block block = ChunkPacker.stringToBlock(blockTypes[0]); + Objects.requireNonNull(block); + MineBehavior.INSTANCE.mine(quantity, block); logDirect("Will mine " + quantity + " " + blockTypes[0]); event.cancel(); return; From 8c397d1454418fe71738537136051d110703fb07 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 17:19:47 -0700 Subject: [PATCH 304/329] t e s t --- .../baritone/utils/pathing/BetterBlockPosTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index 459593b0..13b76c73 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -22,6 +22,7 @@ import net.minecraft.util.math.BlockPos; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class BetterBlockPosTest { @@ -62,7 +63,17 @@ public class BetterBlockPosTest { for (int i = -10; i < 10; i++) { assertEquals(pos.offset(dir, i), better.offset(dir, i)); } + assertTrue(better.offset(dir, 0) == better); } + for (int i = -10; i < 10; i++) { + assertEquals(pos.up(i), better.up(i)); + assertEquals(pos.down(i), better.down(i)); + assertEquals(pos.north(i), better.north(i)); + assertEquals(pos.south(i), better.south(i)); + assertEquals(pos.east(i), better.east(i)); + assertEquals(pos.west(i), better.west(i)); + } + assertTrue(better.offset(null, 0) == better); } public void benchOne() { From 1b74c8c8bee4f526fbbfa8cb8ff687d39046ce32 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 18:16:13 -0700 Subject: [PATCH 305/329] Update BlockBreakHelper.java --- src/main/java/baritone/utils/BlockBreakHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 3ccc56f9..1bc4a44a 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -46,7 +46,9 @@ public final class BlockBreakHelper implements Helper { } public static void stopBreakingBlock() { - mc.playerController.resetBlockRemoving(); + if (mc.playerController != null) { + mc.playerController.resetBlockRemoving(); + } lastBlock = null; } } From 0f7743263e2d815ebdd8f9866cbeff9c9ef05a63 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 20:32:39 -0500 Subject: [PATCH 306/329] Move goals to api --- README.md | 1 - .../java/baritone/api}/pathing/goals/GoalAxis.java | 9 ++++----- .../java/baritone/api}/pathing/goals/GoalBlock.java | 5 ++--- .../baritone/api}/pathing/goals/GoalComposite.java | 3 +-- .../baritone/api}/pathing/goals/GoalGetToBlock.java | 8 +++----- .../java/baritone/api}/pathing/goals/GoalNear.java | 5 ++--- .../java/baritone/api}/pathing/goals/GoalRunAway.java | 3 +-- .../baritone/api}/pathing/goals/GoalTwoBlocks.java | 5 ++--- .../java/baritone/api}/pathing/goals/GoalXZ.java | 10 ++++------ .../java/baritone/api}/pathing/goals/GoalYLevel.java | 9 ++++----- .../baritone/api}/pathing/movement/ActionCosts.java | 4 +++- ...tionCostsButOnlyTheOnesThatMakeMickeyDieInside.java | 2 +- .../baritone/api}/utils/interfaces/IGoalRenderPos.java | 2 +- src/main/java/baritone/behavior/FollowBehavior.java | 4 ++-- src/main/java/baritone/behavior/MineBehavior.java | 6 +++--- src/main/java/baritone/behavior/PathingBehavior.java | 4 ++-- .../java/baritone/pathing/calc/AStarPathFinder.java | 2 +- src/main/java/baritone/pathing/calc/PathNode.java | 2 +- .../java/baritone/pathing/movement/MovementHelper.java | 1 + src/main/java/baritone/pathing/path/PathExecutor.java | 1 + .../java/baritone/utils/ExampleBaritoneControl.java | 4 ++-- src/main/java/baritone/utils/PathRenderer.java | 8 ++++---- src/main/java/baritone/utils/pathing/MoveResult.java | 2 +- .../baritone/pathing/goals/GoalGetToBlockTest.java | 1 + ...CostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java | 2 +- 25 files changed, 48 insertions(+), 55 deletions(-) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalAxis.java (78%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalBlock.java (95%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalComposite.java (96%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalGetToBlock.java (89%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalNear.java (93%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalRunAway.java (96%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalTwoBlocks.java (94%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalXZ.java (90%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/goals/GoalYLevel.java (81%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/movement/ActionCosts.java (93%) rename src/{main/java/baritone => api/java/baritone/api}/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java (98%) rename src/{main/java/baritone => api/java/baritone/api}/utils/interfaces/IGoalRenderPos.java (95%) diff --git a/README.md b/README.md index 7668981c..2a198c40 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actu BaritoneAPI.getSettings().allowSprint.value = true; BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L; -// Note that at this moment in time the Goal implementations are not exposed in the API BaritoneAPI.getPathingBehavior().setGoal(new GoalXZ(10000, 20000)); BaritoneAPI.getPathingBehavior().path(); ``` diff --git a/src/main/java/baritone/pathing/goals/GoalAxis.java b/src/api/java/baritone/api/pathing/goals/GoalAxis.java similarity index 78% rename from src/main/java/baritone/pathing/goals/GoalAxis.java rename to src/api/java/baritone/api/pathing/goals/GoalAxis.java index 1882a7e3..d8811cf9 100644 --- a/src/main/java/baritone/pathing/goals/GoalAxis.java +++ b/src/api/java/baritone/api/pathing/goals/GoalAxis.java @@ -15,10 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.Baritone; -import baritone.api.pathing.goals.Goal; +import baritone.api.BaritoneAPI; public class GoalAxis implements Goal { @@ -26,7 +25,7 @@ public class GoalAxis implements Goal { @Override public boolean isInGoal(int x, int y, int z) { - return y == Baritone.settings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); + return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); } @Override @@ -40,7 +39,7 @@ public class GoalAxis implements Goal { double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2)); - return flatAxisDistance * Baritone.settings().costHeuristic.get() + GoalYLevel.calculate(Baritone.settings().axisHeight.get(), y); + return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y); } @Override diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/api/java/baritone/api/pathing/goals/GoalBlock.java similarity index 95% rename from src/main/java/baritone/pathing/goals/GoalBlock.java rename to src/api/java/baritone/api/pathing/goals/GoalBlock.java index ea28c057..e0a60b59 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalBlock.java @@ -15,10 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; -import baritone.utils.interfaces.IGoalRenderPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** diff --git a/src/main/java/baritone/pathing/goals/GoalComposite.java b/src/api/java/baritone/api/pathing/goals/GoalComposite.java similarity index 96% rename from src/main/java/baritone/pathing/goals/GoalComposite.java rename to src/api/java/baritone/api/pathing/goals/GoalComposite.java index a4dafa45..2926b852 100644 --- a/src/main/java/baritone/pathing/goals/GoalComposite.java +++ b/src/api/java/baritone/api/pathing/goals/GoalComposite.java @@ -15,9 +15,8 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; import net.minecraft.util.math.BlockPos; import java.util.Arrays; diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java similarity index 89% rename from src/main/java/baritone/pathing/goals/GoalGetToBlock.java rename to src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java index 8f249ed0..959b6fcc 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java @@ -15,11 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; -import baritone.utils.interfaces.IGoalRenderPos; -import baritone.utils.pathing.BetterBlockPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; @@ -42,7 +40,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { @Override public BlockPos getGoalPos() { - return new BetterBlockPos(x, y, z); + return new BlockPos(x, y, z); } @Override diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java similarity index 93% rename from src/main/java/baritone/pathing/goals/GoalNear.java rename to src/api/java/baritone/api/pathing/goals/GoalNear.java index f312c9ee..6befda6b 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -15,10 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; -import baritone.utils.interfaces.IGoalRenderPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; public class GoalNear implements Goal, IGoalRenderPos { diff --git a/src/main/java/baritone/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java similarity index 96% rename from src/main/java/baritone/pathing/goals/GoalRunAway.java rename to src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 9ca74711..cb7a000e 100644 --- a/src/main/java/baritone/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -15,9 +15,8 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; import net.minecraft.util.math.BlockPos; import java.util.Arrays; diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java similarity index 94% rename from src/main/java/baritone/pathing/goals/GoalTwoBlocks.java rename to src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java index c5036c35..4ed1bf5e 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java @@ -15,10 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; -import baritone.utils.interfaces.IGoalRenderPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** diff --git a/src/main/java/baritone/pathing/goals/GoalXZ.java b/src/api/java/baritone/api/pathing/goals/GoalXZ.java similarity index 90% rename from src/main/java/baritone/pathing/goals/GoalXZ.java rename to src/api/java/baritone/api/pathing/goals/GoalXZ.java index 8053ee04..636c649f 100644 --- a/src/main/java/baritone/pathing/goals/GoalXZ.java +++ b/src/api/java/baritone/api/pathing/goals/GoalXZ.java @@ -15,11 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.Baritone; -import baritone.api.pathing.goals.Goal; -import baritone.utils.Utils; +import baritone.api.BaritoneAPI; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -82,11 +80,11 @@ public class GoalXZ implements Goal { diagonal = z; } diagonal *= SQRT_2; - return (diagonal + straight) * Baritone.settings().costHeuristic.get(); // big TODO tune + return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune } public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) { - float theta = (float) Utils.degToRad(yaw); + float theta = (float) Math.toRadians(yaw); double x = origin.x - MathHelper.sin(theta) * distance; double z = origin.z + MathHelper.cos(theta) * distance; return new GoalXZ((int) x, (int) z); diff --git a/src/main/java/baritone/pathing/goals/GoalYLevel.java b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java similarity index 81% rename from src/main/java/baritone/pathing/goals/GoalYLevel.java rename to src/api/java/baritone/api/pathing/goals/GoalYLevel.java index fa4af522..d9ae4597 100644 --- a/src/main/java/baritone/pathing/goals/GoalYLevel.java +++ b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java @@ -15,10 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.goals; +package baritone.api.pathing.goals; -import baritone.api.pathing.goals.Goal; -import baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; +import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; /** * Useful for mining (getting to diamond / iron level) @@ -49,11 +48,11 @@ public class GoalYLevel implements Goal, ActionCostsButOnlyTheOnesThatMakeMickey public static double calculate(int goalY, int currentY) { if (currentY > goalY) { // need to descend - return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); + return ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); } if (currentY < goalY) { // need to ascend - return (goalY - currentY) * JUMP_ONE_BLOCK_COST; + return (goalY - currentY) * ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.JUMP_ONE_BLOCK_COST; } return 0; } diff --git a/src/main/java/baritone/pathing/movement/ActionCosts.java b/src/api/java/baritone/api/pathing/movement/ActionCosts.java similarity index 93% rename from src/main/java/baritone/pathing/movement/ActionCosts.java rename to src/api/java/baritone/api/pathing/movement/ActionCosts.java index cbfcd810..e31682aa 100644 --- a/src/main/java/baritone/pathing/movement/ActionCosts.java +++ b/src/api/java/baritone/api/pathing/movement/ActionCosts.java @@ -15,7 +15,9 @@ * along with Baritone. If not, see . */ -package baritone.pathing.movement; +package baritone.api.pathing.movement; + +import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { diff --git a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java b/src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java similarity index 98% rename from src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java rename to src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java index fe589d6f..e492b21c 100644 --- a/src/main/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java +++ b/src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.pathing.movement; +package baritone.api.pathing.movement; public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost(); diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/api/java/baritone/api/utils/interfaces/IGoalRenderPos.java similarity index 95% rename from src/main/java/baritone/utils/interfaces/IGoalRenderPos.java rename to src/api/java/baritone/api/utils/interfaces/IGoalRenderPos.java index aa4ffa78..5bbbc007 100644 --- a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java +++ b/src/api/java/baritone/api/utils/interfaces/IGoalRenderPos.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.utils.interfaces; +package baritone.api.utils.interfaces; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 7fd76675..83ca5135 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -20,8 +20,8 @@ package baritone.behavior; import baritone.Baritone; import baritone.api.behavior.IFollowBehavior; import baritone.api.event.events.TickEvent; -import baritone.pathing.goals.GoalNear; -import baritone.pathing.goals.GoalXZ; +import baritone.api.pathing.goals.GoalNear; +import baritone.api.pathing.goals.GoalXZ; import baritone.utils.Helper; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 2de6167a..0f1a6b34 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -26,9 +26,9 @@ import baritone.cache.CachedChunk; import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; import baritone.cache.WorldScanner; -import baritone.pathing.goals.GoalBlock; -import baritone.pathing.goals.GoalComposite; -import baritone.pathing.goals.GoalTwoBlocks; +import baritone.api.pathing.goals.GoalBlock; +import baritone.api.pathing.goals.GoalComposite; +import baritone.api.pathing.goals.GoalTwoBlocks; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 660ddca1..377af7f3 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -27,7 +27,7 @@ import baritone.api.pathing.goals.Goal; import baritone.pathing.calc.AStarPathFinder; import baritone.pathing.calc.AbstractNodeCostSearch; import baritone.pathing.calc.IPathFinder; -import baritone.pathing.goals.GoalXZ; +import baritone.api.pathing.goals.GoalXZ; import baritone.pathing.movement.MovementHelper; import baritone.pathing.path.IPath; import baritone.pathing.path.PathExecutor; @@ -35,7 +35,7 @@ import baritone.utils.BlockBreakHelper; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.PathRenderer; -import baritone.utils.interfaces.IGoalRenderPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 43207ee3..bdeb2563 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -20,7 +20,7 @@ package baritone.pathing.calc; import baritone.Baritone; import baritone.api.pathing.goals.Goal; import baritone.pathing.calc.openset.BinaryHeapOpenSet; -import baritone.pathing.movement.ActionCosts; +import baritone.api.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; import baritone.pathing.path.IPath; diff --git a/src/main/java/baritone/pathing/calc/PathNode.java b/src/main/java/baritone/pathing/calc/PathNode.java index 6d4142aa..8e42d564 100644 --- a/src/main/java/baritone/pathing/calc/PathNode.java +++ b/src/main/java/baritone/pathing/calc/PathNode.java @@ -18,7 +18,7 @@ package baritone.pathing.calc; import baritone.api.pathing.goals.Goal; -import baritone.pathing.movement.ActionCosts; +import baritone.api.pathing.movement.ActionCosts; /** * A node in the path, containing the cost and steps to get to it. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index e173e766..1b53011a 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -18,6 +18,7 @@ package baritone.pathing.movement; import baritone.Baritone; +import baritone.api.pathing.movement.ActionCosts; import baritone.api.utils.Rotation; import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementTarget; diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 144b787f..e8e74c7d 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -19,6 +19,7 @@ package baritone.pathing.path; import baritone.Baritone; import baritone.api.event.events.TickEvent; +import baritone.api.pathing.movement.ActionCosts; import baritone.pathing.movement.*; import baritone.pathing.movement.movements.*; import baritone.utils.BlockStateInterface; diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index bd1ac0f1..ee58fd60 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -21,7 +21,8 @@ import baritone.Baritone; import baritone.api.Settings; import baritone.api.cache.IWaypoint; import baritone.api.event.events.ChatEvent; -import baritone.api.pathing.goals.Goal; +import baritone.api.pathing.goals.*; +import baritone.api.pathing.movement.ActionCosts; import baritone.behavior.Behavior; import baritone.behavior.FollowBehavior; import baritone.behavior.MineBehavior; @@ -30,7 +31,6 @@ import baritone.cache.ChunkPacker; import baritone.cache.Waypoint; import baritone.cache.WorldProvider; import baritone.pathing.calc.AbstractNodeCostSearch; -import baritone.pathing.goals.*; import baritone.pathing.movement.*; import net.minecraft.block.Block; import net.minecraft.client.multiplayer.ChunkProviderClient; diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index e5c35650..a66bc0ae 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -19,11 +19,11 @@ package baritone.utils; import baritone.Baritone; import baritone.api.pathing.goals.Goal; -import baritone.pathing.goals.GoalComposite; -import baritone.pathing.goals.GoalTwoBlocks; -import baritone.pathing.goals.GoalXZ; +import baritone.api.pathing.goals.GoalComposite; +import baritone.api.pathing.goals.GoalTwoBlocks; +import baritone.api.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; -import baritone.utils.interfaces.IGoalRenderPos; +import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/baritone/utils/pathing/MoveResult.java b/src/main/java/baritone/utils/pathing/MoveResult.java index 1ec96f76..8478a617 100644 --- a/src/main/java/baritone/utils/pathing/MoveResult.java +++ b/src/main/java/baritone/utils/pathing/MoveResult.java @@ -17,7 +17,7 @@ package baritone.utils.pathing; -import static baritone.pathing.movement.ActionCosts.COST_INF; +import static baritone.api.pathing.movement.ActionCosts.COST_INF; /** * The result of a calculated movement, with destination x, y, z, and the cost of performing the movement diff --git a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java index 2fa7f954..6234e050 100644 --- a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java +++ b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.api.pathing.goals.GoalGetToBlock; import net.minecraft.util.math.BlockPos; import org.junit.Test; diff --git a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java index 15291bbe..bbc640fb 100644 --- a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java +++ b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java @@ -19,7 +19,7 @@ package baritone.pathing.movement; import org.junit.Test; -import static baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*; +import static baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*; import static org.junit.Assert.assertEquals; public class ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest { From 40bea503c3f13029f11ce30af87d4a4b7b53a07f Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 20:40:04 -0500 Subject: [PATCH 307/329] Merge ActionCosts with ActionCostsButOnlyTheOnesThatMakeMickeyDieInside --- .../api/pathing/goals/GoalYLevel.java | 8 +-- .../api/pathing/movement/ActionCosts.java | 55 +++++++++++++- ...ButOnlyTheOnesThatMakeMickeyDieInside.java | 71 ------------------- 3 files changed, 56 insertions(+), 78 deletions(-) delete mode 100644 src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java diff --git a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java index d9ae4597..ce54eebb 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java +++ b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java @@ -17,14 +17,14 @@ package baritone.api.pathing.goals; -import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; +import baritone.api.pathing.movement.ActionCosts; /** * Useful for mining (getting to diamond / iron level) * * @author leijurv */ -public class GoalYLevel implements Goal, ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { +public class GoalYLevel implements Goal, ActionCosts { /** * The target Y level @@ -48,11 +48,11 @@ public class GoalYLevel implements Goal, ActionCostsButOnlyTheOnesThatMakeMickey public static double calculate(int goalY, int currentY) { if (currentY > goalY) { // need to descend - return ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); + return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); } if (currentY < goalY) { // need to ascend - return (goalY - currentY) * ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.JUMP_ONE_BLOCK_COST; + return (goalY - currentY) * JUMP_ONE_BLOCK_COST; } return 0; } diff --git a/src/api/java/baritone/api/pathing/movement/ActionCosts.java b/src/api/java/baritone/api/pathing/movement/ActionCosts.java index e31682aa..e1f72dfa 100644 --- a/src/api/java/baritone/api/pathing/movement/ActionCosts.java +++ b/src/api/java/baritone/api/pathing/movement/ActionCosts.java @@ -17,9 +17,7 @@ package baritone.api.pathing.movement; -import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; - -public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { +public interface ActionCosts { /** * These costs are measured roughly in ticks btw @@ -46,4 +44,55 @@ public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieI * and that would make it overflow to negative */ double COST_INF = 1000000; + + double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost(); + + double FALL_1_25_BLOCKS_COST = distanceToTicks(1.25); + double FALL_0_25_BLOCKS_COST = distanceToTicks(0.25); + /** + * When you hit space, you get enough upward velocity to go 1.25 blocks + * Then, you fall the remaining 0.25 to get on the surface, on block higher. + * Since parabolas are symmetric, the amount of time it takes to ascend up from 1 to 1.25 + * will be the same amount of time that it takes to fall back down from 1.25 to 1. + * And the same applies to the overall shape, if it takes X ticks to fall back down 1.25 blocks, + * it will take X ticks to reach the peak of your 1.25 block leap. + * Therefore, the part of your jump from y=0 to y=1.25 takes distanceToTicks(1.25) ticks, + * and the sub-part from y=1 to y=1.25 takes distanceToTicks(0.25) ticks. + * Therefore, the other sub-part, from y=0 to y-1, takes distanceToTicks(1.25)-distanceToTicks(0.25) ticks. + * That's why JUMP_ONE_BLOCK_COST = FALL_1_25_BLOCKS_COST - FALL_0_25_BLOCKS_COST + */ + double JUMP_ONE_BLOCK_COST = FALL_1_25_BLOCKS_COST - FALL_0_25_BLOCKS_COST; + + + static double[] generateFallNBlocksCost() { + double[] costs = new double[257]; + for (int i = 0; i < 257; i++) { + costs[i] = distanceToTicks(i); + } + return costs; + } + + static double velocity(int ticks) { + return (Math.pow(0.98, ticks) - 1) * -3.92; + } + + static double oldFormula(double ticks) { + return -3.92 * (99 - 49.5 * (Math.pow(0.98, ticks) + 1) - ticks); + } + + static double distanceToTicks(double distance) { + if (distance == 0) { + return 0; // Avoid 0/0 NaN + } + double tmpDistance = distance; + int tickCount = 0; + while (true) { + double fallDistance = velocity(tickCount); + if (tmpDistance <= fallDistance) { + return tickCount + tmpDistance / fallDistance; + } + tmpDistance -= fallDistance; + tickCount++; + } + } } diff --git a/src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java b/src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java deleted file mode 100644 index e492b21c..00000000 --- a/src/api/java/baritone/api/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.api.pathing.movement; - -public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { - double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost(); - - double FALL_1_25_BLOCKS_COST = distanceToTicks(1.25); - double FALL_0_25_BLOCKS_COST = distanceToTicks(0.25); - /** - * When you hit space, you get enough upward velocity to go 1.25 blocks - * Then, you fall the remaining 0.25 to get on the surface, on block higher. - * Since parabolas are symmetric, the amount of time it takes to ascend up from 1 to 1.25 - * will be the same amount of time that it takes to fall back down from 1.25 to 1. - * And the same applies to the overall shape, if it takes X ticks to fall back down 1.25 blocks, - * it will take X ticks to reach the peak of your 1.25 block leap. - * Therefore, the part of your jump from y=0 to y=1.25 takes distanceToTicks(1.25) ticks, - * and the sub-part from y=1 to y=1.25 takes distanceToTicks(0.25) ticks. - * Therefore, the other sub-part, from y=0 to y-1, takes distanceToTicks(1.25)-distanceToTicks(0.25) ticks. - * That's why JUMP_ONE_BLOCK_COST = FALL_1_25_BLOCKS_COST - FALL_0_25_BLOCKS_COST - */ - double JUMP_ONE_BLOCK_COST = FALL_1_25_BLOCKS_COST - FALL_0_25_BLOCKS_COST; - - - static double[] generateFallNBlocksCost() { - double[] costs = new double[257]; - for (int i = 0; i < 257; i++) { - costs[i] = distanceToTicks(i); - } - return costs; - } - - static double velocity(int ticks) { - return (Math.pow(0.98, ticks) - 1) * -3.92; - } - - static double oldFormula(double ticks) { - return -3.92 * (99 - 49.5 * (Math.pow(0.98, ticks) + 1) - ticks); - } - - static double distanceToTicks(double distance) { - if (distance == 0) { - return 0; // Avoid 0/0 NaN - } - double tmpDistance = distance; - int tickCount = 0; - while (true) { - double fallDistance = velocity(tickCount); - if (tmpDistance <= fallDistance) { - return tickCount + tmpDistance / fallDistance; - } - tmpDistance -= fallDistance; - tickCount++; - } - } -} From 80a734141c3ee58114646a6ff822ff121664891d Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 24 Sep 2018 20:45:16 -0500 Subject: [PATCH 308/329] Fix compiler error --- .../ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java index bbc640fb..c1ce1471 100644 --- a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java +++ b/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java @@ -19,7 +19,7 @@ package baritone.pathing.movement; import org.junit.Test; -import static baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*; +import static baritone.api.pathing.movement.ActionCosts.*; import static org.junit.Assert.assertEquals; public class ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest { From 61cf103df451a5aafa6bfbe5ed089043212f0b42 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 18:56:49 -0700 Subject: [PATCH 309/329] fix pathing --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index bdeb2563..933bb7d4 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -19,8 +19,8 @@ package baritone.pathing.calc; import baritone.Baritone; import baritone.api.pathing.goals.Goal; -import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.api.pathing.movement.ActionCosts; +import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; import baritone.pathing.path.IPath; @@ -106,14 +106,15 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel } } MoveResult res = moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z); - if (!moves.dynamicXZ && (res.destX != newX || res.destZ != newZ)) { - throw new IllegalStateException(moves + " " + res.destX + " " + newX + " " + res.destZ + " " + newZ); - } numMovementsConsidered++; double actionCost = res.cost; if (actionCost >= ActionCosts.COST_INF) { continue; } + // check destination after verifying it's not COST_INF -- some movements return a static IMPOSSIBLE object with COST_INF and destination being 0,0,0 to avoid allocating a new result for every failed calculation + if (!moves.dynamicXZ && (res.destX != newX || res.destZ != newZ)) { + throw new IllegalStateException(moves + " " + res.destX + " " + newX + " " + res.destZ + " " + newZ); + } if (actionCost <= 0) { throw new IllegalStateException(moves + " calculated implausible cost " + actionCost); } From 780d967d41c34849e3b0e073dc1ebdc03987e12a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 19:05:42 -0700 Subject: [PATCH 310/329] update prebuilt jar --- IMPACT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IMPACT.md b/IMPACT.md index 357119a1..95dab925 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -12,8 +12,8 @@ There are some basic steps to getting Baritone setup with Impact. There are 3 methods of acquiring a build of Baritone (While it is still in development) ### Official Build (Not always up to date) -Download the "official" jar (as of commit 2e63ac4, -built on September 19) from here. +Download the "official" jar (as of commit 61cf103, +built on September 24) from here. ### Building Baritone yourself There are a few steps to this From 67f0a3d73fd0458893a587246b6d3efa0e0b83e8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Sep 2018 21:46:26 -0700 Subject: [PATCH 311/329] automatic release builds --- .travis.yml | 30 ++++++++++++++++++++++++++++++ proguard.pro | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dff5f3a5..0f6dee68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,31 @@ language: java + +install: +- ./gradlew test +- ./gradlew build + +script: +- wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip +- unzip proguard6.0.3.zip 2>&1 > /dev/null +- cd build/libs +- cat ../../proguard.pro | grep -v "this is the rt jar" > proguard.pro +- echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> proguard.pro +- tail proguard.pro +- wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 +- mv tempLibraries.zip?dl=1 tempLibraries.zip +- unzip tempLibraries.zip +- java -jar ../../proguard6.0.3/lib/proguard.jar @proguard.pro +- mv Obfuscated/baritone-1.0.0.jar ../../baritone.jar +- cd ../.. +- shasum baritone.jar + +deploy: + provider: releases + api_key: + secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s= + all_branches: true + file: baritone.jar + skip_cleanup: true + on: + tags: true + repo: cabaletta/baritone diff --git a/proguard.pro b/proguard.pro index 721cd42b..aba04fec 100644 --- a/proguard.pro +++ b/proguard.pro @@ -30,7 +30,7 @@ -keep class baritone.launch.** { *; } # copy all necessary libraries into tempLibraries to build --libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' +-libraryjars '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/rt.jar' # this is the rt jar -libraryjars 'tempLibraries/1.12.2.jar' From a74c1531dbc80c606463551d7c077ed4710fe52e Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 07:19:26 -0500 Subject: [PATCH 312/329] Change version to 0.0.1 in build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1b31aae8..3e5ecf59 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.0.0' +version '0.0.1' buildscript { repositories { From cd379c18525d1d8abf1ebe98d9819e47e8edda0f Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 07:32:32 -0500 Subject: [PATCH 313/329] Fix version to 0.0.2 and update references --- .travis.yml | 2 +- IMPACT.md | 10 +++++----- build.gradle | 2 +- proguard.pro | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f6dee68..baf952c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ script: - mv tempLibraries.zip?dl=1 tempLibraries.zip - unzip tempLibraries.zip - java -jar ../../proguard6.0.3/lib/proguard.jar @proguard.pro -- mv Obfuscated/baritone-1.0.0.jar ../../baritone.jar +- mv Obfuscated/baritone-0.0.2.jar ../../baritone.jar - cd ../.. - shasum baritone.jar diff --git a/IMPACT.md b/IMPACT.md index 95dab925..3ae9a790 100644 --- a/IMPACT.md +++ b/IMPACT.md @@ -23,7 +23,7 @@ There are a few steps to this command line - Windows: ``gradlew build`` - Mac/Linux: ``./gradlew build`` -- The build should be exported into ``/build/libs/baritone-1.0.0.jar`` +- The build should be exported into ``/build/libs/baritone-X.Y.Z.jar`` ### Cutting Edge Release If you want to trust @Plutie#9079, you can download an automatically generated build of the latest commit @@ -37,9 +37,9 @@ putting baritone. - Create 3 new subdirectories starting from ``libraries`` - ``cabaletta`` - ``baritone`` - - ``1.0.0`` - - Copy the build of Baritone that was acquired earlier, and place it into the ``1.0.0`` folder - - The full path should look like ``/libraries/cabaletta/baritone/1.0.0/baritone-1.0.0.jar`` + - ``X.Y.Z`` + - Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder + - The full path should look like ``/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar`` ## Modifying the Impact Profile JSON to run baritone The final step is "registering" the Baritone library with Impact, so that it loads on launch. @@ -72,7 +72,7 @@ The final step is "registering" the Baritone library with Impact, so that it loa - Create a new object in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably. ``` { - "name": "cabaletta:baritone:1.0.0" + "name": "cabaletta:baritone:X.Y.Z" }, ``` - Now find the ``"minecraftArguments": "..."`` text near the top. diff --git a/build.gradle b/build.gradle index 3e5ecf59..e5d27891 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '0.0.1' +version '0.0.2' buildscript { repositories { diff --git a/proguard.pro b/proguard.pro index aba04fec..12ea2337 100644 --- a/proguard.pro +++ b/proguard.pro @@ -1,4 +1,4 @@ --injars baritone-1.0.0.jar +-injars baritone-0.0.2.jar # idk if a wildcard would work here -outjars Obfuscated From 56717b83a8351e147b6e338c761ae4b4eafe1046 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 07:39:47 -0500 Subject: [PATCH 314/329] Deploy optimized and regular jars to release --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index baf952c8..c8603752 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,8 @@ script: - mv tempLibraries.zip?dl=1 tempLibraries.zip - unzip tempLibraries.zip - java -jar ../../proguard6.0.3/lib/proguard.jar @proguard.pro -- mv Obfuscated/baritone-0.0.2.jar ../../baritone.jar +- mv Obfuscated/baritone-0.0.2.jar ../../baritone-optimized-0.0.2.jar +- mv baritone-0.0.2.jar ../baritone-0.0.2.jar - cd ../.. - shasum baritone.jar @@ -24,7 +25,9 @@ deploy: api_key: secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s= all_branches: true - file: baritone.jar + file: + - baritone-0.0.2.jar + - baritone-optimized-0.0.2.jar skip_cleanup: true on: tags: true From 0a451dc15e244e131d745940ddcc246ecf048774 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 07:40:13 -0500 Subject: [PATCH 315/329] Fix checksums --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c8603752..da6caabd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,8 @@ script: - mv Obfuscated/baritone-0.0.2.jar ../../baritone-optimized-0.0.2.jar - mv baritone-0.0.2.jar ../baritone-0.0.2.jar - cd ../.. -- shasum baritone.jar +- shasum baritone-0.0.2.jar +- shasum baritone-optimized-0.0.2.jar deploy: provider: releases From 7632f0184c286e7f6445b454e4766a729eeafaa8 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 07:52:56 -0500 Subject: [PATCH 316/329] I'm kind of dumb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da6caabd..9b1a5881 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ script: - unzip tempLibraries.zip - java -jar ../../proguard6.0.3/lib/proguard.jar @proguard.pro - mv Obfuscated/baritone-0.0.2.jar ../../baritone-optimized-0.0.2.jar -- mv baritone-0.0.2.jar ../baritone-0.0.2.jar +- mv baritone-0.0.2.jar ../../baritone-0.0.2.jar - cd ../.. - shasum baritone-0.0.2.jar - shasum baritone-optimized-0.0.2.jar From bb5b1a7a91a787188814b34037e1af85e22124d7 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 09:08:29 -0500 Subject: [PATCH 317/329] Rename ActionCosts...Test that one --- ...nesThatMakeMickeyDieInsideTest.java => ActionCostsTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/test/java/baritone/pathing/movement/{ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java => ActionCostsTest.java} (96%) diff --git a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java b/src/test/java/baritone/pathing/movement/ActionCostsTest.java similarity index 96% rename from src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java rename to src/test/java/baritone/pathing/movement/ActionCostsTest.java index c1ce1471..a3108c59 100644 --- a/src/test/java/baritone/pathing/movement/ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest.java +++ b/src/test/java/baritone/pathing/movement/ActionCostsTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import static baritone.api.pathing.movement.ActionCosts.*; import static org.junit.Assert.assertEquals; -public class ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest { +public class ActionCostsTest { @Test public void testFallNBlocksCost() { assertEquals(FALL_N_BLOCKS_COST.length, 257); // Fall 0 blocks through fall 256 blocks From 17591736c4630f6d9ad34d5e5d5347dd0c55df8c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:33:16 -0700 Subject: [PATCH 318/329] version only in build.gradle --- .travis.yml | 27 ++++++++++++++++----------- proguard.pro | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b1a5881..32c19128 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,30 +5,35 @@ install: - ./gradlew build script: +- VERSION = $(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) - wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip - unzip proguard6.0.3.zip 2>&1 > /dev/null - cd build/libs -- cat ../../proguard.pro | grep -v "this is the rt jar" > proguard.pro -- echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> proguard.pro -- tail proguard.pro -- wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 +- cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" > api.pro # remove default rt jar and injar lines +- echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location +- echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version +- tail api.pro # debug, print out what the previous two commands generated +- cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api +- wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry - mv tempLibraries.zip?dl=1 tempLibraries.zip - unzip tempLibraries.zip -- java -jar ../../proguard6.0.3/lib/proguard.jar @proguard.pro -- mv Obfuscated/baritone-0.0.2.jar ../../baritone-optimized-0.0.2.jar -- mv baritone-0.0.2.jar ../../baritone-0.0.2.jar +- mkdir ../../dist +- java -jar ../../proguard6.0.3/lib/proguard.jar @api.pro +- mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-api-$VERSION.jar +- java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro +- mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar +- mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar - cd ../.. -- shasum baritone-0.0.2.jar -- shasum baritone-optimized-0.0.2.jar +- shasum dist/* deploy: provider: releases api_key: secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s= all_branches: true + file_glob: true file: - - baritone-0.0.2.jar - - baritone-optimized-0.0.2.jar + - dist/* skip_cleanup: true on: tags: true diff --git a/proguard.pro b/proguard.pro index 12ea2337..bafdfc90 100644 --- a/proguard.pro +++ b/proguard.pro @@ -1,4 +1,4 @@ --injars baritone-0.0.2.jar # idk if a wildcard would work here +-injars baritone-0.0.2.jar -outjars Obfuscated From 50ea3d7b9337da0577a83698c7016bae58764b20 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:37:08 -0700 Subject: [PATCH 319/329] maybe it needs to be in env --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32c19128..4a226391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,13 @@ language: java +env: +- VERSION = $(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) + install: - ./gradlew test - ./gradlew build script: -- VERSION = $(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) - wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip - unzip proguard6.0.3.zip 2>&1 > /dev/null - cd build/libs From 9d3392c25cff9ab495094b640f6b1c378c7ae447 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:40:00 -0700 Subject: [PATCH 320/329] maybe it needs to be exported --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a226391..86cdd729 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,11 @@ language: java -env: -- VERSION = $(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) - install: - ./gradlew test - ./gradlew build script: +- export VERSION=$(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) - wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip - unzip proguard6.0.3.zip 2>&1 > /dev/null - cd build/libs From c94ac6e26c40fffd04e6b1d7d9ef30e30f1b2434 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 25 Sep 2018 09:39:59 -0500 Subject: [PATCH 321/329] Better Rotation --- src/api/java/baritone/api/utils/Rotation.java | 93 ++++++++++++++++++- .../baritone/api/utils/RotationUtils.java | 54 +++++++++++ .../java/baritone/behavior/LookBehavior.java | 8 +- .../baritone/behavior/LookBehaviorUtils.java | 8 +- .../pathing/movement/MovementHelper.java | 2 +- .../movement/movements/MovementTraverse.java | 4 +- src/main/java/baritone/utils/Utils.java | 5 +- 7 files changed, 155 insertions(+), 19 deletions(-) create mode 100644 src/api/java/baritone/api/utils/RotationUtils.java diff --git a/src/api/java/baritone/api/utils/Rotation.java b/src/api/java/baritone/api/utils/Rotation.java index ca8cb66f..dc697169 100644 --- a/src/api/java/baritone/api/utils/Rotation.java +++ b/src/api/java/baritone/api/utils/Rotation.java @@ -17,11 +17,96 @@ package baritone.api.utils; -import net.minecraft.util.Tuple; +/** + * @author Brady + * @since 9/25/2018 + */ +public class Rotation { -public class Rotation extends Tuple { + /** + * The yaw angle of this Rotation + */ + private float yaw; - public Rotation(Float yaw, Float pitch) { - super(yaw, pitch); + /** + * The pitch angle of this Rotation + */ + private float pitch; + + public Rotation(float yaw, float pitch) { + this.yaw = yaw; + this.pitch = pitch; + } + + /** + * @return The yaw of this rotation + */ + public float getYaw() { + return this.yaw; + } + + /** + * @return The pitch of this rotation + */ + public float getPitch() { + return this.pitch; + } + + /** + * Adds the yaw/pitch of the specified rotations to this + * rotation's yaw/pitch, and returns the result. + * + * @param other Another rotation + * @return The result from adding the other rotation to this rotation + */ + public Rotation add(Rotation other) { + return new Rotation( + this.yaw + other.yaw, + this.pitch + other.pitch + ); + } + + /** + * Subtracts the yaw/pitch of the specified rotations from this + * rotation's yaw/pitch, and returns the result. + * + * @param other Another rotation + * @return The result from subtracting the other rotation from this rotation + */ + public Rotation subtract(Rotation other) { + return new Rotation( + this.yaw - other.yaw, + this.pitch - other.pitch + ); + } + + /** + * @return A copy of this rotation with the pitch clamped + */ + public Rotation clamp() { + return new Rotation( + this.yaw, + RotationUtils.clampPitch(this.pitch) + ); + } + + /** + * @return A copy of this rotation with the yaw normalized + */ + public Rotation normalize() { + return new Rotation( + RotationUtils.normalizeYaw(this.yaw), + this.pitch + ); + } + + /** + * @return A copy of this rotation with the pitch clamped and the yaw normalized + */ + public Rotation normalizeAndClamp() { + return new Rotation( + RotationUtils.normalizeYaw(this.yaw), + RotationUtils.clampPitch(this.pitch) + ); } } diff --git a/src/api/java/baritone/api/utils/RotationUtils.java b/src/api/java/baritone/api/utils/RotationUtils.java new file mode 100644 index 00000000..0df4b38d --- /dev/null +++ b/src/api/java/baritone/api/utils/RotationUtils.java @@ -0,0 +1,54 @@ +/* + * 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.api.utils; + +/** + * @author Brady + * @since 9/25/2018 + */ +public final class RotationUtils { + + private RotationUtils() {} + + /** + * Clamps the specified pitch value between -90 and 90. + * + * @param pitch The input pitch + * @return The clamped pitch + */ + public static float clampPitch(float pitch) { + return Math.max(-90, Math.min(90, pitch)); + } + + /** + * Normalizes the specified yaw value between -180 and 180. + * + * @param yaw The input yaw + * @return The normalized yaw + */ + public static float normalizeYaw(float yaw) { + float newYaw = yaw % 360F; + if (newYaw < -180F) { + newYaw += 360F; + } + if (newYaw >= 180F) { + newYaw -= 360F; + } + return newYaw; + } +} diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index a02ffa51..a42a1e50 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -69,9 +69,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe switch (event.getState()) { case PRE: { if (this.force) { - player().rotationYaw = this.target.getFirst(); + player().rotationYaw = this.target.getYaw(); float oldPitch = player().rotationPitch; - float desiredPitch = this.target.getSecond(); + float desiredPitch = this.target.getPitch(); player().rotationPitch = desiredPitch; if (desiredPitch == oldPitch) { nudgeToLevel(); @@ -79,7 +79,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe this.target = null; } else if (silent) { this.lastYaw = player().rotationYaw; - player().rotationYaw = this.target.getFirst(); + player().rotationYaw = this.target.getYaw(); } break; } @@ -101,7 +101,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior, Helpe switch (event.getState()) { case PRE: this.lastYaw = player().rotationYaw; - player().rotationYaw = this.target.getFirst(); + player().rotationYaw = this.target.getYaw(); break; case POST: player().rotationYaw = this.lastYaw; diff --git a/src/main/java/baritone/behavior/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java index c94f2a1f..8cbe01ab 100644 --- a/src/main/java/baritone/behavior/LookBehaviorUtils.java +++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java @@ -51,10 +51,10 @@ public final class LookBehaviorUtils implements Helper { * @return vector of the rotation */ public static Vec3d calcVec3dFromRotation(Rotation rotation) { - float f = MathHelper.cos(-rotation.getFirst() * (float) DEG_TO_RAD - (float) Math.PI); - float f1 = MathHelper.sin(-rotation.getFirst() * (float) DEG_TO_RAD - (float) Math.PI); - float f2 = -MathHelper.cos(-rotation.getSecond() * (float) DEG_TO_RAD); - float f3 = MathHelper.sin(-rotation.getSecond() * (float) DEG_TO_RAD); + float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI); + float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI); + float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD); + float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD); return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2)); } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1b53011a..d614e544 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -463,7 +463,7 @@ public interface MovementHelper extends ActionCosts, Helper { state.setTarget(new MovementTarget( new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), Utils.getBlockPosCenter(pos), - new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getFirst(), mc.player.rotationPitch), + new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getYaw(), mc.player.rotationPitch), false )).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 34bcfef3..a16a50a1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -165,8 +165,8 @@ public class MovementTraverse extends Movement { // combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break // it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw - float yawToDest = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())).getFirst(); - float pitchToBreak = state.getTarget().getRotation().get().getSecond(); + float yawToDest = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())).getYaw(); + float pitchToBreak = state.getTarget().getRotation().get().getPitch(); state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true)); return state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java index 12be404b..0de61461 100755 --- a/src/main/java/baritone/utils/Utils.java +++ b/src/main/java/baritone/utils/Utils.java @@ -99,10 +99,7 @@ public final class Utils { } public static Rotation wrapAnglesToRelative(Rotation current, Rotation target) { - return new Rotation( - MathHelper.wrapDegrees(target.getFirst() - current.getFirst()) + current.getFirst(), - MathHelper.wrapDegrees(target.getSecond() - current.getSecond()) + current.getSecond() - ); + return target.subtract(current).normalize().add(current); } public static Vec3d vec3dFromBlockPos(BlockPos orig) { From 09f0eca7cb4b8f83c530374c37d57a4b2a106e94 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:46:32 -0700 Subject: [PATCH 322/329] script it --- .travis.yml | 22 +--------------------- scripts/build.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 scripts/build.sh diff --git a/.travis.yml b/.travis.yml index 86cdd729..4f7133ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,29 +2,9 @@ language: java install: - ./gradlew test -- ./gradlew build script: -- export VERSION=$(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) -- wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip -- unzip proguard6.0.3.zip 2>&1 > /dev/null -- cd build/libs -- cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" > api.pro # remove default rt jar and injar lines -- echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location -- echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version -- tail api.pro # debug, print out what the previous two commands generated -- cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api -- wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry -- mv tempLibraries.zip?dl=1 tempLibraries.zip -- unzip tempLibraries.zip -- mkdir ../../dist -- java -jar ../../proguard6.0.3/lib/proguard.jar @api.pro -- mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-api-$VERSION.jar -- java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro -- mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar -- mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar -- cd ../.. -- shasum dist/* +- sh scripts/build.sh deploy: provider: releases diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000..b5971c24 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,22 @@ +set -e # this makes the whole script fail immediately if any one of these commands fails +./gradlew build +export VERSION=$(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) +wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip +unzip proguard6.0.3.zip 2>&1 > /dev/null +cd build/libs +cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" > api.pro # remove default rt jar and injar lines +echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location +echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version +tail api.pro # debug, print out what the previous two commands generated +cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api +wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry +mv tempLibraries.zip?dl=1 tempLibraries.zip +unzip tempLibraries.zip +mkdir ../../dist +java -jar ../../proguard6.0.3/lib/proguard.jar @api.pro +mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-api-$VERSION.jar +java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro +mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar +mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar +cd ../.. +shasum dist/* \ No newline at end of file From 3e606e83b580e54fef6274974c45167ee1a09b85 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:49:46 -0700 Subject: [PATCH 323/329] lol --- scripts/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index b5971c24..00e3b993 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,9 +4,9 @@ export VERSION=$(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip unzip proguard6.0.3.zip 2>&1 > /dev/null cd build/libs -cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" > api.pro # remove default rt jar and injar lines -echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version +cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" >> api.pro # remove default rt jar and injar lines +echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location tail api.pro # debug, print out what the previous two commands generated cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api wget https://www.dropbox.com/s/zmc2l3jnwdvzvak/tempLibraries.zip?dl=1 # i'm sorry From 35710103cdc3c37d9ae652a8a31fe250afae279d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 07:52:39 -0700 Subject: [PATCH 324/329] me, an idiot --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 00e3b993..6b948e5c 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,6 @@ set -e # this makes the whole script fail immediately if any one of these commands fails ./gradlew build -export VERSION=$(cat ../../build.gradle| grep "version '" | cut -d "'" -f 2-2) +export VERSION=$(cat build.gradle| grep "version '" | cut -d "'" -f 2-2) wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip unzip proguard6.0.3.zip 2>&1 > /dev/null cd build/libs From c165070c5edfb5d8ceca33bfd2e1ad344ba89c30 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 08:01:10 -0700 Subject: [PATCH 325/329] release checksums --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 6b948e5c..f3e46b28 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,4 +19,4 @@ java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar cd ../.. -shasum dist/* \ No newline at end of file +shasum dist/* | tee dist/checksums.txt \ No newline at end of file From 1b1670427b702929fd9ac5e8cfce55521ae9a19a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 08:06:39 -0700 Subject: [PATCH 326/329] bump version and move proguard to scripts --- build.gradle | 2 +- scripts/build.sh | 4 ++-- proguard.pro => scripts/proguard.pro | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename proguard.pro => scripts/proguard.pro (100%) diff --git a/build.gradle b/build.gradle index e5d27891..0a1bb804 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '0.0.2' +version '0.0.3' buildscript { repositories { diff --git a/scripts/build.sh b/scripts/build.sh index f3e46b28..ae2d1ff9 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,11 +1,11 @@ set -e # this makes the whole script fail immediately if any one of these commands fails ./gradlew build -export VERSION=$(cat build.gradle| grep "version '" | cut -d "'" -f 2-2) +export VERSION=$(cat build.gradle | grep "version '" | cut -d "'" -f 2-2) wget https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip unzip proguard6.0.3.zip 2>&1 > /dev/null cd build/libs echo "-injars 'baritone-$VERSION.jar'" >> api.pro # insert current version -cat ../../proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" >> api.pro # remove default rt jar and injar lines +cat ../../scripts/proguard.pro | grep -v "this is the rt jar" | grep -v "\-injars" >> api.pro # remove default rt jar and injar lines echo "-libraryjars '$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')'" >> api.pro # insert correct rt.jar location tail api.pro # debug, print out what the previous two commands generated cat api.pro | grep -v "\-keep class baritone.api" > standalone.pro # standalone doesn't keep baritone api diff --git a/proguard.pro b/scripts/proguard.pro similarity index 100% rename from proguard.pro rename to scripts/proguard.pro From 5a82b2b3223426e4e9686ad3adefb2c228b0a99c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 09:08:35 -0700 Subject: [PATCH 327/329] deploy checksums to body --- .travis.yml | 5 +++++ scripts/build.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f7133ea..041d0fc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,10 @@ install: script: - sh scripts/build.sh +before_deploy: +- sudo apt-get update +- sudo apt-get install jshon + deploy: provider: releases api_key: @@ -14,6 +18,7 @@ deploy: file_glob: true file: - dist/* + body: $(jshon -s "$(cat checksums.txt)")) skip_cleanup: true on: tags: true diff --git a/scripts/build.sh b/scripts/build.sh index ae2d1ff9..cd8d2c31 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,4 +19,4 @@ java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar cd ../.. -shasum dist/* | tee dist/checksums.txt \ No newline at end of file +shasum dist/* | tee checksums.txt \ No newline at end of file From 353f2c7d9fb70fa86873628f0ea0a835548cd53c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 09:53:19 -0700 Subject: [PATCH 328/329] extra end paren --- .travis.yml | 2 +- scripts/build.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 041d0fc4..5ef5c133 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ deploy: file_glob: true file: - dist/* - body: $(jshon -s "$(cat checksums.txt)")) + body: $(jshon -s "$(cat dist/checksums.txt)") skip_cleanup: true on: tags: true diff --git a/scripts/build.sh b/scripts/build.sh index cd8d2c31..c5131692 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,4 +19,5 @@ java -jar ../../proguard6.0.3/lib/proguard.jar @standalone.pro mv Obfuscated/baritone-$VERSION.jar ../../dist/baritone-standalone-$VERSION.jar mv baritone-$VERSION.jar ../../dist/baritone-unoptimized-$VERSION.jar cd ../.. -shasum dist/* | tee checksums.txt \ No newline at end of file +shasum dist/* | tee dist/checksums.txt +jshon -s "$(cat dist/checksums.txt)" \ No newline at end of file From 6b810c570ba93033b44066f593ca5a0a78303861 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Sep 2018 09:58:11 -0700 Subject: [PATCH 329/329] install jshon earlier --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ef5c133..20a83a68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,13 @@ language: java install: +- sudo apt-get update +- sudo apt-get install jshon - ./gradlew test script: - sh scripts/build.sh -before_deploy: -- sudo apt-get update -- sudo apt-get install jshon - deploy: provider: releases api_key: