2018-08-06 22:23:08 +00:00
|
|
|
package baritone.bot.pathing.movement.movements;
|
|
|
|
|
|
|
|
import baritone.bot.pathing.movement.Movement;
|
|
|
|
import baritone.bot.pathing.movement.MovementHelper;
|
|
|
|
import baritone.bot.pathing.movement.MovementState;
|
|
|
|
import baritone.bot.utils.BlockStateInterface;
|
|
|
|
import baritone.bot.utils.ToolSet;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockLadder;
|
|
|
|
import net.minecraft.block.BlockVine;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
|
|
|
public class MovementDownward extends Movement {
|
2018-08-07 21:14:36 +00:00
|
|
|
|
|
|
|
private int numTicks = 0;
|
|
|
|
|
2018-08-06 22:23:08 +00:00
|
|
|
public MovementDownward(BlockPos start) {
|
|
|
|
super(start, start.down(), new BlockPos[]{start.down()}, new BlockPos[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MovementState updateState(MovementState state) {
|
|
|
|
super.updateState(state);
|
|
|
|
System.out.println("Ticking with state " + state.getStatus());
|
|
|
|
switch (state.getStatus()) {
|
|
|
|
case PREPPING:
|
|
|
|
case UNREACHABLE:
|
|
|
|
case FAILED:
|
|
|
|
return state;
|
|
|
|
case WAITING:
|
|
|
|
case RUNNING:
|
|
|
|
if (playerFeet().equals(dest)) {
|
|
|
|
state.setStatus(MovementState.MovementStatus.SUCCESS);
|
|
|
|
return state;
|
|
|
|
}
|
2018-08-07 03:54:58 +00:00
|
|
|
double diffX = player().posX - (dest.getX() + 0.5);
|
|
|
|
double diffZ = player().posZ - (dest.getZ() + 0.5);
|
|
|
|
double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
|
|
|
|
|
|
|
if (numTicks++ < 10 && ab < 0.2) {
|
2018-08-06 22:23:08 +00:00
|
|
|
return state;
|
|
|
|
}
|
2018-08-06 23:58:06 +00:00
|
|
|
moveTowards(positionsToBreak[0]);
|
|
|
|
return state;
|
2018-08-06 22:23:08 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected double calculateCost(ToolSet ts) {
|
2018-08-07 01:18:16 +00:00
|
|
|
if (!MovementHelper.canWalkOn(dest.down())) {
|
2018-08-06 22:23:08 +00:00
|
|
|
return COST_INF;
|
|
|
|
}
|
|
|
|
Block td = BlockStateInterface.get(dest).getBlock();
|
|
|
|
boolean ladder = td instanceof BlockLadder || td instanceof BlockVine;
|
|
|
|
if (ladder) {
|
|
|
|
return LADDER_DOWN_ONE_COST;
|
|
|
|
} else {
|
2018-08-07 00:34:49 +00:00
|
|
|
return FALL_N_BLOCKS_COST[1] + getTotalHardnessOfBlocksToBreak(ts);
|
2018-08-06 22:23:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|