From d8a99f8459a25091a37321a37ae17c8dc741f336 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 6 Aug 2018 16:12:41 -0700 Subject: [PATCH] replaced --- .../baritone/bot/behavior/impl/PathingBehavior.java | 12 +++++++----- .../pathing/movement/movements/MovementAscend.java | 4 ++-- .../pathing/movement/movements/MovementDownward.java | 2 +- .../pathing/movement/movements/MovementTraverse.java | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java index 018fbfe7..2e4da52f 100644 --- a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java @@ -9,6 +9,7 @@ import baritone.bot.pathing.calc.AbstractNodeCostSearch; import baritone.bot.pathing.calc.IPathFinder; import baritone.bot.pathing.goals.Goal; import baritone.bot.pathing.goals.GoalBlock; +import baritone.bot.pathing.movement.Movement; import baritone.bot.pathing.path.IPath; import baritone.bot.pathing.path.PathExecutor; import baritone.bot.utils.BlockStateInterface; @@ -140,11 +141,12 @@ public class PathingBehavior extends Behavior { getPath().ifPresent(path -> drawPath(path, player(), partialTicks, Color.RED)); long split = System.currentTimeMillis(); getPath().ifPresent(path -> { - for (BlockPos pos : path.getBlocksToBreak()) { - drawSelectionBox(player(), pos, partialTicks, Color.RED); - } - for (BlockPos pos : path.getBlocksToPlace()) { - drawSelectionBox(player(), pos, partialTicks, Color.GREEN); + for (Movement m : path.movements()) { + for (BlockPos pos : m.toPlace()) + drawSelectionBox(player(), pos, partialTicks, Color.GREEN); + for (BlockPos pos : m.toBreak()) { + drawSelectionBox(player(), pos, partialTicks, Color.RED); + } } }); diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java index d27c5222..a1bdd772 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java @@ -52,7 +52,7 @@ public class MovementAscend extends Movement { } for (BlockPos against1 : against) { if (BlockStateInterface.get(against1).isBlockNormalCube()) { - return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts); + return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + PLACE_ONE_BLOCK_COST + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak); } } return COST_INF; @@ -60,7 +60,7 @@ public class MovementAscend extends Movement { if (BlockStateInterface.get(src.up(3)).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us return COST_INF; } - return WALK_ONE_BLOCK_COST / 2 + Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST / 2) + getTotalHardnessOfBlocksToBreak(ts);//we walk half the block to get to the edge, then we walk the other half while simultaneously jumping (math.max because of how it's in parallel) + return WALK_ONE_BLOCK_COST / 2 + Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST / 2) + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak);//we walk half the block to get to the edge, then we walk the other half while simultaneously jumping (math.max because of how it's in parallel) } @Override diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java index ccb0079c..b0bdc371 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java @@ -55,7 +55,7 @@ public class MovementDownward extends Movement { if (ladder) { return LADDER_DOWN_ONE_COST; } else { - return FALL_N_BLOCKS_COST[1] + getTotalHardnessOfBlocksToBreak(ts); + return FALL_N_BLOCKS_COST[1] + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak); } } } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index fa23eb4d..3d5b3e49 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -59,7 +59,7 @@ public class MovementTraverse extends Movement { //double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]); //double hardness2 = blocksToBreak[1].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[1]); //Out.log("Can't walk through " + blocksToBreak[0] + " (hardness" + hardness1 + ") or " + blocksToBreak[1] + " (hardness " + hardness2 + ")"); - return WC + getTotalHardnessOfBlocksToBreak(ts); + return WC + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak); } else {//this is a bridge, so we need to place a block //return 1000000; Block f = BlockStateInterface.get(src.down()).getBlock(); @@ -70,11 +70,11 @@ public class MovementTraverse extends Movement { if (pp0.getBlock().equals(Blocks.AIR) || (!BlockStateInterface.isWater(pp0.getBlock()) && pp0.getBlock().isReplaceable(Minecraft.getMinecraft().world, positionsToPlace[0]))) { for (BlockPos against1 : against) { if (BlockStateInterface.get(against1).isBlockNormalCube()) { - return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts); + return WC + PLACE_ONE_BLOCK_COST + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak); } } WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are placing, we are sneaking - return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts); + return WC + PLACE_ONE_BLOCK_COST + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak); } return COST_INF; //Out.log("Can't walk on " + Baritone.get(positionsToPlace[0]).getBlock());