Fix OOB and check for direction and include parkour

This commit is contained in:
ZacSharp 2022-09-01 00:56:34 +02:00
parent 78f1c45e13
commit af95f77134
No known key found for this signature in database
GPG Key ID: 9453647B005083A3
2 changed files with 14 additions and 6 deletions

View File

@ -148,7 +148,7 @@ public class MovementTraverse extends Movement {
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) {
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
}
if (srcDown == Blocks.FLOWING_WATER || srcDown == Blocks.WATER) {
if (!standingOnABlock) { // standing on water / swimming
return COST_INF; // this is obviously impossible
}
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol

View File

@ -380,12 +380,19 @@ public class PathExecutor implements IPathExecutor, Helper {
// however, descend and ascend don't request sprinting, because they don't know the context of what movement comes after it
if (current instanceof MovementDescend) {
IMovement next = path.movements().get(pathPosition + 1);
if (next instanceof MovementTraverse) {
if (pathPosition < path.length() - 2) {
// keep this out of onTick, even if that means a tick of delay before it has an effect
IMovement next = path.movements().get(pathPosition + 1);
if (MovementHelper.canUseFrostWalker(ctx, next.getDest().down())) {
// if we are going to continue straight onto the water with frostwalker feet.equals(dest) must hold, otherwise we don't want to waste time
// Since MovementDescend can't know the direction of the next movement we have to tell it
((MovementDescend) current).forceSafeMode(); // keep this out of onTick, even if that means a tick of delay before it has an effect
// frostwalker only works if you cross the edge of the block on ground so in some cases we may not overshoot
// Since MovementDescend can't know the next movement we have to tell it
if (next instanceof MovementTraverse || next instanceof MovementParkour) {
boolean couldPlaceInstead = Baritone.settings().allowPlace.value && behavior.baritone.getInventoryBehavior().hasGenericThrowaway() && next instanceof MovementParkour; // traverse doesn't react fast enough
boolean sameFlatDirection = current.getDirection().up().crossProduct(next.getDirection()).equals(BlockPos.ORIGIN); // here's why you learn maths in school
if (sameFlatDirection && !couldPlaceInstead) {
((MovementDescend) current).forceSafeMode();
}
}
}
}
if (((MovementDescend) current).safeMode() && !((MovementDescend) current).skipToAscend()) {
@ -394,6 +401,7 @@ public class PathExecutor implements IPathExecutor, Helper {
}
if (pathPosition < path.length() - 2) {
IMovement next = path.movements().get(pathPosition + 1);
if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) {
// a descend then an ascend in the same direction
pathPosition++;