Add cost-only MovementFall
This commit is contained in:
@@ -1,61 +1,41 @@
|
|||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.pathing.movement.ActionCosts;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
import baritone.bot.pathing.movement.MovementHelper;
|
import baritone.bot.pathing.movement.MovementHelper;
|
||||||
import baritone.bot.pathing.movement.MovementState;
|
|
||||||
import baritone.bot.utils.BlockStateInterface;
|
import baritone.bot.utils.BlockStateInterface;
|
||||||
import baritone.bot.utils.Rotation;
|
|
||||||
import baritone.bot.utils.ToolSet;
|
import baritone.bot.utils.ToolSet;
|
||||||
import baritone.bot.utils.Utils;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockLadder;
|
|
||||||
import net.minecraft.block.BlockVine;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class MovementFall extends Movement {
|
public class MovementFall extends Movement {
|
||||||
public MovementFall(BlockPos start) {
|
|
||||||
super(start, start.down(), new BlockPos[]{start.down()}, new BlockPos[0]);
|
private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) {
|
||||||
|
BlockPos[] toBreak;
|
||||||
|
int diffX = dest.getX() - src.getX();
|
||||||
|
int diffZ = dest.getZ() - src.getZ();
|
||||||
|
int diffY = dest.getY() - src.getY();
|
||||||
|
toBreak = new BlockPos[diffY + 1];
|
||||||
|
for(int i = 0; i < toBreak.length; i++ ) {
|
||||||
|
toBreak[i] = new BlockPos(dest.getX() - diffX, dest.getY() + (toBreak.length - 1) - i, dest.getZ() - diffZ);
|
||||||
|
}
|
||||||
|
return toBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numTicks = 0;
|
|
||||||
|
|
||||||
@Override
|
protected MovementFall(BlockPos src, BlockPos dest) {
|
||||||
public MovementState updateState(MovementState state) {
|
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()});
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (numTicks++ < 10) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world()));
|
|
||||||
return state.setTarget(new MovementState.MovementTarget(rotationToBlock)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calculateCost(ToolSet ts) {
|
protected double calculateCost(ToolSet ts) {
|
||||||
if (!MovementHelper.canWalkOn(dest.down(), BlockStateInterface.get(dest.down()))) {
|
if(!MovementHelper.canWalkOn(positionsToPlace[0], BlockStateInterface.get(positionsToPlace[0]))) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
Block td = BlockStateInterface.get(dest).getBlock();
|
double placeBucketCost = 0.0;
|
||||||
boolean ladder = td instanceof BlockLadder || td instanceof BlockVine;
|
if(!BlockStateInterface.isWater(dest)) {
|
||||||
if (ladder) {
|
placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST;
|
||||||
return LADDER_DOWN_ONE_COST;
|
|
||||||
} else {
|
|
||||||
return FALL_N_BLOCKS_COST[1] + getTotalHardnessOfBlocksToBreak(ts);
|
|
||||||
}
|
}
|
||||||
|
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak) + placeBucketCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user