walk on water hunger penalty

This commit is contained in:
Leijurv 2018-12-19 22:01:47 -08:00
parent 02478ee887
commit ae9ab03e51
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,11 @@ public class Settings {
*/ */
public Setting<Double> jumpPenalty = new Setting<>(2D); public Setting<Double> jumpPenalty = new Setting<>(2D);
/**
* Walking on water uses up hunger really quick, so penalize it
*/
public Setting<Double> walkOnWaterOnePenalty = new Setting<>(5D);
/** /**
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it. * Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
* Reliability: questionable. * Reliability: questionable.

View File

@ -62,6 +62,7 @@ public class CalculationContext {
private final double waterWalkSpeed; private final double waterWalkSpeed;
private final double breakBlockAdditionalCost; private final double breakBlockAdditionalCost;
private final double jumpPenalty; private final double jumpPenalty;
private final double walkOnWaterOnePenalty;
private final BetterWorldBorder worldBorder; private final BetterWorldBorder worldBorder;
public CalculationContext(IBaritone baritone) { public CalculationContext(IBaritone baritone) {
@ -95,6 +96,7 @@ public class CalculationContext {
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get();
this.jumpPenalty = Baritone.settings().jumpPenalty.get(); this.jumpPenalty = Baritone.settings().jumpPenalty.get();
this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.get();
// why cache these things here, why not let the movements just get directly from settings? // 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, // 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. // then you get a wildly inconsistent path that isn't optimal for either scenario.
@ -218,4 +220,8 @@ public class CalculationContext {
public double jumpPenalty() { public double jumpPenalty() {
return jumpPenalty; return jumpPenalty;
} }
public double walkOnWaterOnePenalty() {
return walkOnWaterOnePenalty;
}
} }

View File

@ -80,6 +80,8 @@ public class MovementDiagonal extends Movement {
// For either possible soul sand, that affects half of our walking // For either possible soul sand, that affects half of our walking
if (destWalkOn.getBlock() == Blocks.SOUL_SAND) { if (destWalkOn.getBlock() == Blocks.SOUL_SAND) {
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
} else if (destWalkOn.getBlock() == Blocks.WATER) {
multiplier += context.walkOnWaterOnePenalty() * SQRT_2;
} }
Block fromDown = context.get(x, y - 1, z).getBlock(); Block fromDown = context.get(x, y - 1, z).getBlock();
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {

View File

@ -75,6 +75,8 @@ public class MovementTraverse extends Movement {
} else { } else {
if (destOn.getBlock() == Blocks.SOUL_SAND) { if (destOn.getBlock() == Blocks.SOUL_SAND) {
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
} else if (destOn.getBlock() == Blocks.WATER) {
WC += context.walkOnWaterOnePenalty();
} }
if (srcDown == Blocks.SOUL_SAND) { if (srcDown == Blocks.SOUL_SAND) {
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;