Working MovementFall
This commit is contained in:
parent
a806eaaca7
commit
207947f7dd
@ -5,10 +5,7 @@ import baritone.bot.pathing.calc.openset.IOpenSet;
|
|||||||
import baritone.bot.pathing.goals.Goal;
|
import baritone.bot.pathing.goals.Goal;
|
||||||
import baritone.bot.pathing.movement.ActionCosts;
|
import baritone.bot.pathing.movement.ActionCosts;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
import baritone.bot.pathing.movement.movements.MovementAscend;
|
import baritone.bot.pathing.movement.movements.*;
|
||||||
import baritone.bot.pathing.movement.movements.MovementDescend;
|
|
||||||
import baritone.bot.pathing.movement.movements.MovementDownward;
|
|
||||||
import baritone.bot.pathing.movement.movements.MovementTraverse;
|
|
||||||
import baritone.bot.pathing.path.IPath;
|
import baritone.bot.pathing.path.IPath;
|
||||||
import baritone.bot.utils.ToolSet;
|
import baritone.bot.utils.ToolSet;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@ -150,7 +147,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
|||||||
int x = pos.getX();
|
int x = pos.getX();
|
||||||
int y = pos.getY();
|
int y = pos.getY();
|
||||||
int z = pos.getZ();
|
int z = pos.getZ();
|
||||||
Movement[] movements = new Movement[13];
|
Movement[] movements = new Movement[21];
|
||||||
movements[0] = new MovementTraverse(pos, new BlockPos(x + 1, y, z));
|
movements[0] = new MovementTraverse(pos, new BlockPos(x + 1, y, z));
|
||||||
movements[1] = new MovementTraverse(pos, new BlockPos(x - 1, y, z));
|
movements[1] = new MovementTraverse(pos, new BlockPos(x - 1, y, z));
|
||||||
movements[2] = new MovementTraverse(pos, new BlockPos(x, y, z + 1));
|
movements[2] = new MovementTraverse(pos, new BlockPos(x, y, z + 1));
|
||||||
@ -164,6 +161,14 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
|||||||
movements[10] = new MovementDescend(pos, new BlockPos(x, y - 1, z + 1));
|
movements[10] = new MovementDescend(pos, new BlockPos(x, y - 1, z + 1));
|
||||||
movements[11] = new MovementDescend(pos, new BlockPos(x, y - 1, z - 1));
|
movements[11] = new MovementDescend(pos, new BlockPos(x, y - 1, z - 1));
|
||||||
movements[12] = new MovementDownward(pos);
|
movements[12] = new MovementDownward(pos);
|
||||||
|
movements[13] = new MovementFall(pos, new BlockPos(x, y - 2, z - 1));
|
||||||
|
movements[14] = new MovementFall(pos, new BlockPos(x, y - 2, z + 1));
|
||||||
|
movements[15] = new MovementFall(pos, new BlockPos(x - 1, y - 2, z));
|
||||||
|
movements[16] = new MovementFall(pos, new BlockPos(x + 1, y - 2, z));
|
||||||
|
movements[17] = new MovementFall(pos, new BlockPos(x, y - 3, z - 1));
|
||||||
|
movements[18] = new MovementFall(pos, new BlockPos(x, y - 3, z + 1));
|
||||||
|
movements[19] = new MovementFall(pos, new BlockPos(x - 1, y - 3, z));
|
||||||
|
movements[20] = new MovementFall(pos, new BlockPos(x + 1, y - 3, z));
|
||||||
/*Action[] actions = new Action[26];
|
/*Action[] actions = new Action[26];
|
||||||
actions[0] = new ActionPillar(pos);
|
actions[0] = new ActionPillar(pos);
|
||||||
actions[1] = new ActionBridge(pos, new BlockPos(x + 1, y, z));
|
actions[1] = new ActionBridge(pos, new BlockPos(x + 1, y, z));
|
||||||
|
@ -1,28 +1,36 @@
|
|||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
|
import baritone.bot.InputOverrideHandler;
|
||||||
|
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
||||||
import baritone.bot.pathing.movement.ActionCosts;
|
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.pathing.movement.MovementState.MovementStatus;
|
||||||
|
import baritone.bot.pathing.movement.MovementState.MovementTarget;
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class MovementFall extends Movement {
|
public class MovementFall extends Movement {
|
||||||
|
|
||||||
private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) {
|
private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) {
|
||||||
BlockPos[] toBreak;
|
BlockPos[] toBreak;
|
||||||
int diffX = dest.getX() - src.getX();
|
int diffX = src.getX() - dest.getX();
|
||||||
int diffZ = dest.getZ() - src.getZ();
|
int diffZ = src.getZ() - dest.getZ();
|
||||||
int diffY = dest.getY() - src.getY();
|
int diffY = src.getY() - dest.getY();
|
||||||
toBreak = new BlockPos[diffY + 1];
|
toBreak = new BlockPos[diffY + 1];
|
||||||
for(int i = 0; i < toBreak.length; i++ ) {
|
for(int i = 0; i < toBreak.length; i++ ) {
|
||||||
toBreak[i] = new BlockPos(dest.getX() - diffX, dest.getY() + (toBreak.length - 1) - i, dest.getZ() - diffZ);
|
toBreak[i] = new BlockPos(src.getX() - diffX, src.getY() + 1 - i, src.getZ() - diffZ);
|
||||||
}
|
}
|
||||||
return toBreak;
|
return toBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected MovementFall(BlockPos src, BlockPos dest) {
|
public MovementFall(BlockPos src, BlockPos dest) {
|
||||||
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()});
|
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +40,43 @@ public class MovementFall extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
double placeBucketCost = 0.0;
|
double placeBucketCost = 0.0;
|
||||||
if(!BlockStateInterface.isWater(dest)) {
|
if(!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
|
||||||
placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST;
|
placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST;
|
||||||
}
|
}
|
||||||
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak) + placeBucketCost;
|
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + MovementHelper.getTotalHardnessOfBlocksToBreak(ts, positionsToBreak) + placeBucketCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MovementState updateState(MovementState state) {
|
||||||
|
super.updateState(state);
|
||||||
|
switch(state.getStatus()) {
|
||||||
|
case PREPPING:
|
||||||
|
case UNREACHABLE:
|
||||||
|
case FAILED:
|
||||||
|
return state;
|
||||||
|
case WAITING:
|
||||||
|
state.setStatus(MovementStatus.RUNNING);
|
||||||
|
case RUNNING:
|
||||||
|
BlockPos playerFeet = playerFeet();
|
||||||
|
if(playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01 || BlockStateInterface.isWater(dest)))
|
||||||
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
|
Vec3d destCenter = Utils.calcCenterFromCoords(dest, world());
|
||||||
|
if(Math.abs(player().posX - destCenter.x) > 0.2 || Math.abs(player().posZ - destCenter.z) > 0.2) {
|
||||||
|
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||||
|
}
|
||||||
|
if(!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
|
||||||
|
LookBehaviorUtils.reachable(dest).ifPresent(rotation ->
|
||||||
|
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
||||||
|
.setTarget(new MovementTarget(rotation))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world()));
|
||||||
|
state.setTarget(new MovementTarget(rotationToBlock));
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user