misc fixes #315
This commit is contained in:
parent
a87772c98c
commit
840b7e6987
@ -123,7 +123,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
baritone.getLookBehavior().updateTarget(
|
baritone.getLookBehavior().updateTarget(
|
||||||
rotation,
|
rotation,
|
||||||
currentState.getTarget().hasToForceRotations()));
|
currentState.getTarget().hasToForceRotations()));
|
||||||
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
currentState.getInputStates().forEach((input, forced) -> {
|
currentState.getInputStates().forEach((input, forced) -> {
|
||||||
baritone.getInputOverrideHandler().setInputForceState(input, forced);
|
baritone.getInputOverrideHandler().setInputForceState(input, forced);
|
||||||
});
|
});
|
||||||
|
@ -177,13 +177,6 @@ public class MovementDescend extends Movement {
|
|||||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||||
return false; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect
|
return false; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect
|
||||||
}
|
}
|
||||||
if (context.hasWaterBucket && unprotectedFallHeight <= context.maxFallHeightBucket + 1) {
|
|
||||||
res.x = destX;
|
|
||||||
res.y = newY + 1;// this is the block we're falling onto, so dest is +1
|
|
||||||
res.z = destZ;
|
|
||||||
res.cost = tentativeCost + context.placeBlockCost;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (unprotectedFallHeight <= context.maxFallHeightNoWater + 1) {
|
if (unprotectedFallHeight <= context.maxFallHeightNoWater + 1) {
|
||||||
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
|
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
|
||||||
res.x = destX;
|
res.x = destX;
|
||||||
@ -191,6 +184,13 @@ public class MovementDescend extends Movement {
|
|||||||
res.z = destZ;
|
res.z = destZ;
|
||||||
res.cost = tentativeCost;
|
res.cost = tentativeCost;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (context.hasWaterBucket && unprotectedFallHeight <= context.maxFallHeightBucket + 1) {
|
||||||
|
res.x = destX;
|
||||||
|
res.y = newY + 1;// this is the block we're falling onto, so dest is +1
|
||||||
|
res.z = destZ;
|
||||||
|
res.cost = tentativeCost + context.placeBlockCost;
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -235,8 +235,7 @@ public class MovementDescend extends Movement {
|
|||||||
if (numTicks++ < 20) {
|
if (numTicks++ < 20) {
|
||||||
MovementHelper.moveTowards(ctx, state, fakeDest);
|
MovementHelper.moveTowards(ctx, state, fakeDest);
|
||||||
if (fromStart > 1.25) {
|
if (fromStart > 1.25) {
|
||||||
state.setInput(Input.MOVE_FORWARD, false);
|
state.getTarget().rotation = new Rotation(state.getTarget().rotation.getYaw() + 180F, state.getTarget().rotation.getPitch());
|
||||||
state.setInput(Input.MOVE_BACK, true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MovementHelper.moveTowards(ctx, state, dest);
|
MovementHelper.moveTowards(ctx, state, dest);
|
||||||
|
@ -30,6 +30,7 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLadder;
|
import net.minecraft.block.BlockLadder;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
@ -79,7 +80,8 @@ public class MovementFall extends Movement {
|
|||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest));
|
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest));
|
||||||
Rotation targetRotation = null;
|
Rotation targetRotation = null;
|
||||||
if (!MovementHelper.isWater(ctx, dest) && willPlaceBucket() && !playerFeet.equals(dest)) {
|
Block destBlock = ctx.world().getBlockState(dest).getBlock();
|
||||||
|
if (destBlock != Blocks.WATER && destBlock != Blocks.FLOWING_WATER && willPlaceBucket() && !playerFeet.equals(dest)) {
|
||||||
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) {
|
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
@ -100,8 +102,8 @@ public class MovementFall extends Movement {
|
|||||||
} else {
|
} else {
|
||||||
state.setTarget(new MovementTarget(toDest, false));
|
state.setTarget(new MovementTarget(toDest, false));
|
||||||
}
|
}
|
||||||
if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || MovementHelper.isWater(ctx, dest))) { // 0.094 because lilypads
|
if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || destBlock == Blocks.WATER)) { // 0.094 because lilypads
|
||||||
if (MovementHelper.isWater(ctx, dest)) {
|
if (destBlock == Blocks.WATER) { // only match water, not flowing water (which we cannot pick up with a bucket)
|
||||||
if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
||||||
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
||||||
if (ctx.player().motionY >= 0) {
|
if (ctx.player().motionY >= 0) {
|
||||||
@ -132,7 +134,7 @@ public class MovementFall extends Movement {
|
|||||||
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().posX)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().posZ));
|
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().posX)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().posZ));
|
||||||
if (dist < 0.6) {
|
if (dist < 0.6) {
|
||||||
state.setInput(Input.MOVE_FORWARD, true);
|
state.setInput(Input.MOVE_FORWARD, true);
|
||||||
} else {
|
} else if (!ctx.player().onGround) {
|
||||||
state.setInput(Input.SNEAK, false);
|
state.setInput(Input.SNEAK, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,9 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sprintNextTick = shouldSprintNextTick();
|
sprintNextTick = shouldSprintNextTick();
|
||||||
|
if (!sprintNextTick) {
|
||||||
|
ctx.player().setSprinting(false); // letting go of control doesn't make you stop sprinting actually
|
||||||
|
}
|
||||||
ticksOnCurrent++;
|
ticksOnCurrent++;
|
||||||
if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) {
|
if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) {
|
||||||
// only cancel if the total time has exceeded the initial estimate
|
// only cancel if the total time has exceeded the initial estimate
|
||||||
@ -391,29 +394,33 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
|
|
||||||
// however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it
|
// however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it
|
||||||
IMovement current = path.movements().get(pathPosition);
|
IMovement current = path.movements().get(pathPosition);
|
||||||
if (current instanceof MovementDescend && pathPosition < path.length() - 2) {
|
if (current instanceof MovementDescend) {
|
||||||
|
|
||||||
if (((MovementDescend) current).safeMode()) {
|
if (((MovementDescend) current).safeMode()) {
|
||||||
logDebug("Sprinting would be unsafe");
|
logDebug("Sprinting would be unsafe");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMovement next = path.movements().get(pathPosition + 1);
|
if (pathPosition < path.length() - 2) {
|
||||||
if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) {
|
IMovement next = path.movements().get(pathPosition + 1);
|
||||||
// a descend then an ascend in the same direction
|
if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) {
|
||||||
pathPosition++;
|
// a descend then an ascend in the same direction
|
||||||
// okay to skip clearKeys and / or onChangeInPathPosition here since this isn't possible to repeat, since it's asymmetric
|
|
||||||
logDebug("Skipping descend to straight ascend");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (canSprintInto(ctx, current, next)) {
|
|
||||||
if (ctx.playerFeet().equals(current.getDest())) {
|
|
||||||
pathPosition++;
|
pathPosition++;
|
||||||
onChangeInPathPosition();
|
// okay to skip clearKeys and / or onChangeInPathPosition here since this isn't possible to repeat, since it's asymmetric
|
||||||
|
logDebug("Skipping descend to straight ascend");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
if (canSprintInto(ctx, current, next)) {
|
||||||
|
if (ctx.playerFeet().equals(current.getDest())) {
|
||||||
|
pathPosition++;
|
||||||
|
onChangeInPathPosition();
|
||||||
|
logDirect("skip lol");
|
||||||
|
onTick();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
||||||
}
|
}
|
||||||
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
|
||||||
}
|
}
|
||||||
if (current instanceof MovementAscend && pathPosition != 0) {
|
if (current instanceof MovementAscend && pathPosition != 0) {
|
||||||
IMovement prev = path.movements().get(pathPosition - 1);
|
IMovement prev = path.movements().get(pathPosition - 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user