misc fixes
This commit is contained in:
parent
53590a96b9
commit
5ca5fdf777
@ -42,6 +42,7 @@ public final class FollowBehavior extends Behavior implements Helper {
|
||||
@Override
|
||||
public void onTick(TickEvent event) {
|
||||
if (event.getType() == TickEvent.Type.OUT) {
|
||||
following = null;
|
||||
return;
|
||||
}
|
||||
if (following == null) {
|
||||
|
@ -58,6 +58,10 @@ public final class MineBehavior extends Behavior implements Helper {
|
||||
|
||||
@Override
|
||||
public void onTick(TickEvent event) {
|
||||
if (event.getType() == TickEvent.Type.OUT) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (mining == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import baritone.behavior.LookBehaviorUtils;
|
||||
import baritone.pathing.movement.MovementState.MovementStatus;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.pathing.BetterBlockPos;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@ -158,7 +159,7 @@ public abstract class Movement implements Helper, MovementHelper {
|
||||
}
|
||||
boolean somethingInTheWay = false;
|
||||
for (BetterBlockPos blockPos : positionsToBreak) {
|
||||
if (!MovementHelper.canWalkThrough(blockPos)) {
|
||||
if (!MovementHelper.canWalkThrough(blockPos) && !(BlockStateInterface.getBlock(blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
|
||||
somethingInTheWay = true;
|
||||
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
|
||||
if (reachable.isPresent()) {
|
||||
|
@ -360,6 +360,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (avoidBreaking(x, y, z, state)) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (block instanceof BlockLiquid) {
|
||||
return COST_INF;
|
||||
}
|
||||
double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table
|
||||
double strVsBlock = context.getToolSet().getStrVsBlock(state);
|
||||
if (strVsBlock <= 0) {
|
||||
|
@ -87,8 +87,10 @@ public class MovementDescend extends Movement {
|
||||
//if S is where you start, B needs to be air for a movementfall
|
||||
//A is plausibly breakable by either descend or fall
|
||||
//C, D, etc determine the length of the fall
|
||||
if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) {
|
||||
return dynamicFallCost(context, x, y, z, destX, destZ, totalCost);
|
||||
|
||||
IBlockState below = BlockStateInterface.get(destX, y - 2, destZ);
|
||||
if (!MovementHelper.canWalkOn(destX, y - 2, destZ, below)) {
|
||||
return dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below);
|
||||
}
|
||||
|
||||
Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock();
|
||||
@ -106,13 +108,16 @@ public class MovementDescend extends Movement {
|
||||
return new Tuple<>(y - 1, totalCost);
|
||||
}
|
||||
|
||||
public static Tuple<Integer, Double> dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak) {
|
||||
public static Tuple<Integer, Double> dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) {
|
||||
if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) {
|
||||
// if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall
|
||||
// but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column,
|
||||
// and potentially replace the water we're going to fall into
|
||||
return IMPOSSIBLE;
|
||||
}
|
||||
if (!MovementHelper.canWalkThrough(destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
||||
return IMPOSSIBLE;
|
||||
}
|
||||
for (int fallHeight = 3; true; fallHeight++) {
|
||||
int newY = y - fallHeight;
|
||||
if (newY < 0) {
|
||||
@ -122,13 +127,16 @@ public class MovementDescend extends Movement {
|
||||
}
|
||||
IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ);
|
||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak;
|
||||
if (ontoBlock.getBlock() == Blocks.WATER) { // TODO flowing check required here?
|
||||
if (ontoBlock.getBlock() == Blocks.WATER && !BlockStateInterface.isFlowing(ontoBlock)) { // TODO flowing check required here?
|
||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
||||
return IMPOSSIBLE; // TODO fix
|
||||
}
|
||||
// found a fall into water
|
||||
return new Tuple<>(newY, tentativeCost); // TODO incorporate water swim up cost?
|
||||
}
|
||||
if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) {
|
||||
return IMPOSSIBLE;
|
||||
}
|
||||
if (MovementHelper.canWalkThrough(destX, newY, destZ, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ public class PathExecutor implements Helper {
|
||||
|
||||
if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1 && !(path.movements().get(0) instanceof MovementAscend) && !(path.movements().get(0) instanceof MovementPillar)) {
|
||||
// avoid the Wrong Y coordinate bug
|
||||
// TODO add a timer here
|
||||
new MovementDownward(whereAmI, whereShouldIBe).update();
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user