Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gotta go fast, fixes #179, fixes #168 #180

Merged
merged 6 commits into from
Sep 23, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MovementDescend
  • Loading branch information
leijurv committed Sep 23, 2018
commit 1b576eca2850e080f1c84d4c078bee4f9d20bfb5
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ public void reset() {

@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;
}
Expand All @@ -62,7 +66,17 @@ protected double calculateCost(CalculationContext context) {
// 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
Expand Down