This commit is contained in:
Leijurv 2018-08-06 16:12:41 -07:00
parent 34bedb58c7
commit d8a99f8459
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 13 additions and 11 deletions

View File

@ -9,6 +9,7 @@ import baritone.bot.pathing.calc.AbstractNodeCostSearch;
import baritone.bot.pathing.calc.IPathFinder; import baritone.bot.pathing.calc.IPathFinder;
import baritone.bot.pathing.goals.Goal; import baritone.bot.pathing.goals.Goal;
import baritone.bot.pathing.goals.GoalBlock; import baritone.bot.pathing.goals.GoalBlock;
import baritone.bot.pathing.movement.Movement;
import baritone.bot.pathing.path.IPath; import baritone.bot.pathing.path.IPath;
import baritone.bot.pathing.path.PathExecutor; import baritone.bot.pathing.path.PathExecutor;
import baritone.bot.utils.BlockStateInterface; import baritone.bot.utils.BlockStateInterface;
@ -140,11 +141,12 @@ public class PathingBehavior extends Behavior {
getPath().ifPresent(path -> drawPath(path, player(), partialTicks, Color.RED)); getPath().ifPresent(path -> drawPath(path, player(), partialTicks, Color.RED));
long split = System.currentTimeMillis(); long split = System.currentTimeMillis();
getPath().ifPresent(path -> { getPath().ifPresent(path -> {
for (BlockPos pos : path.getBlocksToBreak()) { 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); drawSelectionBox(player(), pos, partialTicks, Color.RED);
} }
for (BlockPos pos : path.getBlocksToPlace()) {
drawSelectionBox(player(), pos, partialTicks, Color.GREEN);
} }
}); });

View File

@ -52,7 +52,7 @@ public class MovementAscend extends Movement {
} }
for (BlockPos against1 : against) { for (BlockPos against1 : against) {
if (BlockStateInterface.get(against1).isBlockNormalCube()) { 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; 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 if (BlockStateInterface.get(src.up(3)).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us
return COST_INF; 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 @Override

View File

@ -55,7 +55,7 @@ public class MovementDownward extends Movement {
if (ladder) { if (ladder) {
return LADDER_DOWN_ONE_COST; return LADDER_DOWN_ONE_COST;
} else { } else {
return FALL_N_BLOCKS_COST[1] + getTotalHardnessOfBlocksToBreak(ts); return FALL_N_BLOCKS_COST[1] + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak);
} }
} }
} }

View File

@ -59,7 +59,7 @@ public class MovementTraverse extends Movement {
//double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]); //double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]);
//double hardness2 = blocksToBreak[1].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[1]); //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 + ")"); //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 } else {//this is a bridge, so we need to place a block
//return 1000000; //return 1000000;
Block f = BlockStateInterface.get(src.down()).getBlock(); 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]))) { if (pp0.getBlock().equals(Blocks.AIR) || (!BlockStateInterface.isWater(pp0.getBlock()) && pp0.getBlock().isReplaceable(Minecraft.getMinecraft().world, positionsToPlace[0]))) {
for (BlockPos against1 : against) { for (BlockPos against1 : against) {
if (BlockStateInterface.get(against1).isBlockNormalCube()) { 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 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; return COST_INF;
//Out.log("Can't walk on " + Baritone.get(positionsToPlace[0]).getBlock()); //Out.log("Can't walk on " + Baritone.get(positionsToPlace[0]).getBlock());