Mostly working usage of frostwalker
* Sometimes overshoots Descend-Traverse chains onto water * Unwanted interactions with assumeWalkOnWater
This commit is contained in:
parent
17a2aa42e9
commit
e75a4b95cc
@ -29,6 +29,7 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.init.Enchantments;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -64,6 +65,7 @@ public class CalculationContext {
|
|||||||
public final boolean allowJumpAt256;
|
public final boolean allowJumpAt256;
|
||||||
public final boolean allowParkourAscend;
|
public final boolean allowParkourAscend;
|
||||||
public final boolean assumeWalkOnWater;
|
public final boolean assumeWalkOnWater;
|
||||||
|
public final int frostWalker;
|
||||||
public final boolean allowDiagonalDescend;
|
public final boolean allowDiagonalDescend;
|
||||||
public final boolean allowDiagonalAscend;
|
public final boolean allowDiagonalAscend;
|
||||||
public final boolean allowDownward;
|
public final boolean allowDownward;
|
||||||
@ -99,6 +101,7 @@ public class CalculationContext {
|
|||||||
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
|
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
|
||||||
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
||||||
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
||||||
|
this.frostWalker = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
|
||||||
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
||||||
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
||||||
this.allowDownward = Baritone.settings().allowDownward.value;
|
this.allowDownward = Baritone.settings().allowDownward.value;
|
||||||
|
@ -360,6 +360,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return canWalkOn(bsi, x, y, z, bsi.get0(x, y, z));
|
return canWalkOn(bsi, x, y, z, bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean canUseFrostWalker(CalculationContext context, IBlockState state) {
|
||||||
|
return context.frostWalker != 0
|
||||||
|
&& (state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER)
|
||||||
|
&& ((Integer) state.getValue(BlockLiquid.LEVEL)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
||||||
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
|
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import baritone.utils.pathing.MutableMoveResult;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@ -109,6 +110,9 @@ public class MovementDescend extends Movement {
|
|||||||
if (destDown.getBlock() == Blocks.LADDER || destDown.getBlock() == Blocks.VINE) {
|
if (destDown.getBlock() == Blocks.LADDER || destDown.getBlock() == Blocks.VINE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (MovementHelper.canUseFrostWalker(context, destDown)) {
|
||||||
|
return; // the water will freeze when we try to walk into it
|
||||||
|
}
|
||||||
|
|
||||||
// we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel)
|
// we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel)
|
||||||
double walk = WALK_OFF_BLOCK_COST;
|
double walk = WALK_OFF_BLOCK_COST;
|
||||||
|
@ -125,7 +125,9 @@ public class MovementDiagonal extends Movement {
|
|||||||
destWalkOn = destInto;
|
destWalkOn = destInto;
|
||||||
} else {
|
} else {
|
||||||
destWalkOn = context.get(destX, y - 1, destZ);
|
destWalkOn = context.get(destX, y - 1, destZ);
|
||||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)
|
||||||
|
&& !MovementHelper.canUseFrostWalker(context, destWalkOn)
|
||||||
|
) {
|
||||||
descend = true;
|
descend = true;
|
||||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||||
return;
|
return;
|
||||||
@ -136,6 +138,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 (!ascend && !descend && MovementHelper.canUseFrostWalker(context, destWalkOn)) {
|
||||||
|
// frostwalker lets us walk on water without the penalty, but only works if we don't ascend or descend
|
||||||
} else if (destWalkOn.getBlock() == Blocks.WATER) {
|
} else if (destWalkOn.getBlock() == Blocks.WATER) {
|
||||||
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
|
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,10 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState standingOn = context.get(x, y - 1, z);
|
IBlockState standingOn = context.get(x, y - 1, z);
|
||||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getBlock() instanceof BlockLiquid) {
|
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (standingOn.getBlock() instanceof BlockLiquid && !MovementHelper.canUseFrostWalker(context, standingOn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int maxJump;
|
int maxJump;
|
||||||
@ -135,7 +138,9 @@ public class MovementParkour extends Movement {
|
|||||||
// check for flat landing position
|
// check for flat landing position
|
||||||
IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
|
IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
|
||||||
// farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
|
// farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
|
||||||
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) {
|
if ((landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn))
|
||||||
|
|| (Math.min(16, context.frostWalker + 2) >= i && MovementHelper.canUseFrostWalker(context, landingOn))
|
||||||
|
) {
|
||||||
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
|
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
|
||||||
res.x = destX;
|
res.x = destX;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
|
@ -33,6 +33,7 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@ -72,7 +73,7 @@ public class MovementTraverse extends Movement {
|
|||||||
IBlockState pb1 = context.get(destX, y, destZ);
|
IBlockState pb1 = context.get(destX, y, destZ);
|
||||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||||
Block srcDown = context.getBlock(x, y - 1, z);
|
Block srcDown = context.getBlock(x, y - 1, z);
|
||||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn) || MovementHelper.canUseFrostWalker(context, destOn)) { //this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||||
@ -81,7 +82,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) {
|
} else if (destOn.getBlock() == Blocks.WATER && !MovementHelper.canUseFrostWalker(context, destOn)) {
|
||||||
|
// with frostwalker we can walk on water without the penalty
|
||||||
WC += context.walkOnWaterOnePenalty;
|
WC += context.walkOnWaterOnePenalty;
|
||||||
}
|
}
|
||||||
if (srcDown == Blocks.SOUL_SAND) {
|
if (srcDown == Blocks.SOUL_SAND) {
|
||||||
@ -226,7 +228,7 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder || EnchantmentHelper.hasFrostWalkerEnchantment(ctx.player());
|
||||||
BlockPos feet = ctx.playerFeet();
|
BlockPos feet = ctx.playerFeet();
|
||||||
if (feet.getY() != dest.getY() && !ladder) {
|
if (feet.getY() != dest.getY() && !ladder) {
|
||||||
logDebug("Wrong Y coordinate");
|
logDebug("Wrong Y coordinate");
|
||||||
|
Loading…
Reference in New Issue
Block a user