take depth strider into acocunt for water speed, fixes #101

This commit is contained in:
Leijurv 2018-10-01 14:26:55 -07:00
parent f338cdd2e5
commit b55a102d37
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 17 additions and 4 deletions

View File

@ -18,8 +18,10 @@
package baritone.pathing.movement;
import baritone.Baritone;
import baritone.api.pathing.movement.ActionCosts;
import baritone.utils.Helper;
import baritone.utils.ToolSet;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -40,6 +42,7 @@ public class CalculationContext implements Helper {
private final boolean allowBreak;
private final int maxFallHeightNoWater;
private final int maxFallHeightBucket;
private final double waterWalkSpeed;
public CalculationContext() {
this(new ToolSet());
@ -54,13 +57,19 @@ public class CalculationContext implements Helper {
this.allowBreak = Baritone.settings().allowBreak.get();
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get();
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get();
int depth = EnchantmentHelper.getDepthStriderModifier(player());
if (depth > 3) {
depth = 3;
}
float mult = depth / 3.0F;
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
// why cache these things here, why not let the movements just get directly from settings?
// because if some movements are calculated one way and others are calculated another way,
// then you get a wildly inconsistent path that isn't optimal for either scenario.
}
public ToolSet getToolSet() {
return this.toolSet;
return toolSet;
}
public boolean hasWaterBucket() {
@ -91,4 +100,8 @@ public class CalculationContext implements Helper {
return maxFallHeightBucket;
}
public double waterWalkSpeed() {
return waterWalkSpeed;
}
}

View File

@ -122,7 +122,7 @@ public class MovementDiagonal extends Movement {
// 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
multiplier = WALK_ONE_IN_WATER_COST;
multiplier = context.waterWalkSpeed();
water = true;
}
if (optionA != 0 || optionB != 0) {

View File

@ -69,7 +69,7 @@ public class MovementTraverse extends Movement {
double WC = WALK_ONE_BLOCK_COST;
boolean water = false;
if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) {
WC = WALK_ONE_IN_WATER_COST;
WC = context.waterWalkSpeed();
water = true;
} else {
if (destOn.getBlock() == Blocks.SOUL_SAND) {
@ -116,7 +116,7 @@ public class MovementTraverse extends Movement {
}
double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb1, true);
double WC = throughWater ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST;
double WC = throughWater ? context.waterWalkSpeed() : WALK_ONE_BLOCK_COST;
for (int i = 0; i < 4; i++) {
int againstX = destX + HORIZONTALS[i].getXOffset();
int againstZ = destZ + HORIZONTALS[i].getZOffset();