From 532d4d1f31fc9f534d8a213b65701f0eda5e2d5a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 13 Aug 2018 13:40:50 -0700 Subject: [PATCH] sprinting yay --- .../movement/movements/MovementDiagonal.java | 14 +++++++++++--- .../movement/movements/MovementTraverse.java | 12 +++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java index 83c3bd715..5254d4158 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDiagonal.java @@ -81,10 +81,10 @@ public class MovementDiagonal extends Movement { if (!MovementHelper.canWalkOn(positionsToPlace[0], destWalkOn)) { return COST_INF; } - double multiplier = 1; + double multiplier = WALK_ONE_BLOCK_COST; if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) { multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; - } else if (BlockStateInterface.get(src).getBlock().equals(Blocks.SOUL_SAND)) { + } else if (BlockStateInterface.get(src.down()).getBlock().equals(Blocks.SOUL_SAND)) { multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; } if (BlockStateInterface.get(positionsToBreak[2].down()).getBlock() instanceof BlockMagma) { @@ -117,7 +117,15 @@ public class MovementDiagonal extends Movement { if (optionA != 0 || optionB != 0) { multiplier *= SQRT_2 - 0.001; // TODO tune } - return multiplier * SQRT_2 * (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST); + if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) { + multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; + } + if (multiplier == WALK_ONE_BLOCK_COST) { + // if we aren't edging around anything, and we aren't in water or soul sand + // we can sprint =D + multiplier = SPRINT_ONE_BLOCK_COST; + } + return multiplier * SQRT_2; } @Override 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 d29f0f217..fb2cba39a 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -68,13 +68,18 @@ public class MovementTraverse extends Movement { protected double calculateCost(CalculationContext context) { IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); - double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST; IBlockState destOn = BlockStateInterface.get(positionsToPlace[0]); if (MovementHelper.canWalkOn(positionsToPlace[0], destOn)) {//this is a walk, not a bridge + double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST; if (destOn.getBlock().equals(Blocks.SOUL_SAND)) { - WC *= SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST; + WC *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; } if (MovementHelper.canWalkThrough(positionsToBreak[0]) && MovementHelper.canWalkThrough(positionsToBreak[1])) { + if (WC == WALK_ONE_BLOCK_COST) { + // if there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing + // we can sprint =D + WC = SPRINT_ONE_BLOCK_COST; + } return WC; } //double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]); @@ -92,12 +97,13 @@ public class MovementTraverse extends Movement { if (!context.hasThrowaway()) { return COST_INF; } + double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST; for (BlockPos against1 : against) { if (BlockStateInterface.get(against1).isBlockNormalCube()) { return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet()); } } - if(BlockStateInterface.get(src).getBlock().equals(Blocks.SOUL_SAND)){ + if (BlockStateInterface.get(src).getBlock().equals(Blocks.SOUL_SAND)) { return COST_INF; // can't sneak and backplace against soul sand =/ } WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are placing, we are sneaking