Search in sources :

Example 11 with Rotation

use of baritone.api.utils.Rotation in project Spark-Client by Spark-Client-Development.

the class FarmProcess method onTick.

@Override
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
    ArrayList<Block> scan = new ArrayList<>();
    for (Harvest harvest : Harvest.values()) {
        scan.add(harvest.block);
    }
    if (Baritone.settings().replantCrops.getValue()) {
        scan.add(Blocks.FARMLAND);
        if (Baritone.settings().replantNetherWart.getValue()) {
            scan.add(Blocks.SOUL_SAND);
        }
    }
    if (Baritone.settings().mineGoalUpdateInterval.getValue() != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.getValue() == 0) {
        Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10));
    }
    if (locations == null) {
        return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
    }
    List<BlockPos> toBreak = new ArrayList<>();
    List<BlockPos> openFarmland = new ArrayList<>();
    List<BlockPos> bonemealable = new ArrayList<>();
    List<BlockPos> openSoulsand = new ArrayList<>();
    for (BlockPos pos : locations) {
        // check if the target block is out of range.
        if (range != 0 && pos.getDistance(center.getX(), center.getY(), center.getZ()) > range) {
            continue;
        }
        IBlockState state = ctx.world().getBlockState(pos);
        boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir;
        if (state.getBlock() == Blocks.FARMLAND) {
            if (airAbove) {
                openFarmland.add(pos);
            }
            continue;
        }
        if (state.getBlock() == Blocks.SOUL_SAND) {
            if (airAbove) {
                openSoulsand.add(pos);
            }
            continue;
        }
        if (readyForHarvest(ctx.world(), pos, state)) {
            toBreak.add(pos);
            continue;
        }
        if (state.getBlock() instanceof IGrowable) {
            IGrowable ig = (IGrowable) state.getBlock();
            if (ig.canGrow(ctx.world(), pos, state, true) && ig.canUseBonemeal(ctx.world(), ctx.world().rand, pos, state)) {
                bonemealable.add(pos);
            }
        }
    }
    baritone.getInputOverrideHandler().clearAllKeys();
    for (BlockPos pos : toBreak) {
        Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
        if (rot.isPresent() && isSafeToCancel) {
            baritone.getLookBehavior().updateTarget(rot.get(), true);
            MovementHelper.switchToBestToolFor(ctx, ctx.world().getBlockState(pos));
            if (ctx.isLookingAt(pos)) {
                baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_LEFT, true);
            }
            return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
        }
    }
    ArrayList<BlockPos> both = new ArrayList<>(openFarmland);
    both.addAll(openSoulsand);
    for (BlockPos pos : both) {
        boolean soulsand = openSoulsand.contains(pos);
        Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false);
        if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
            RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
            if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) {
                baritone.getLookBehavior().updateTarget(rot.get(), true);
                if (ctx.isLookingAt(pos)) {
                    baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
                }
                return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
            }
        }
    }
    for (BlockPos pos : bonemealable) {
        Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
        if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, this::isBoneMeal)) {
            baritone.getLookBehavior().updateTarget(rot.get(), true);
            if (ctx.isLookingAt(pos)) {
                baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
            }
            return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
        }
    }
    if (calcFailed) {
        logDirect("Farm failed");
        if (Baritone.settings().desktopNotifications.getValue() && Baritone.settings().notificationOnFarmFail.getValue()) {
            NotificationHelper.notify("Farm failed", true);
        }
        onLostControl();
        return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
    }
    List<Goal> goalz = new ArrayList<>();
    for (BlockPos pos : toBreak) {
        goalz.add(new BuilderProcess.GoalBreak(pos));
    }
    if (baritone.getInventoryBehavior().throwaway(false, this::isPlantable)) {
        for (BlockPos pos : openFarmland) {
            goalz.add(new GoalBlock(pos.up()));
        }
    }
    if (baritone.getInventoryBehavior().throwaway(false, this::isNetherWart)) {
        for (BlockPos pos : openSoulsand) {
            goalz.add(new GoalBlock(pos.up()));
        }
    }
    if (baritone.getInventoryBehavior().throwaway(false, this::isBoneMeal)) {
        for (BlockPos pos : bonemealable) {
            goalz.add(new GoalBlock(pos));
        }
    }
    for (Entity entity : ctx.world().loadedEntityList) {
        if (entity instanceof EntityItem && entity.onGround) {
            EntityItem ei = (EntityItem) entity;
            if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
                // +0.1 because of farmland's 0.9375 dummy height lol
                goalz.add(new GoalBlock(new BlockPos(entity.posX, entity.posY + 0.1, entity.posZ)));
            }
        }
    }
    return new PathingCommand(new GoalComposite(goalz.toArray(new Goal[0])), PathingCommandType.SET_GOAL_AND_PATH);
}
Also used : Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) GoalBlock(baritone.api.pathing.goals.GoalBlock) ArrayList(java.util.ArrayList) RayTraceResult(net.minecraft.util.math.RayTraceResult) Rotation(baritone.api.utils.Rotation) Vec3d(net.minecraft.util.math.Vec3d) GoalComposite(baritone.api.pathing.goals.GoalComposite) Goal(baritone.api.pathing.goals.Goal) PathingCommand(baritone.api.process.PathingCommand) GoalBlock(baritone.api.pathing.goals.GoalBlock) BlockPos(net.minecraft.util.math.BlockPos) EntityItem(net.minecraft.entity.item.EntityItem)

Example 12 with Rotation

use of baritone.api.utils.Rotation in project baritone by cabaletta.

the class MovementTraverse method updateState.

@Override
public MovementState updateState(MovementState state) {
    super.updateState(state);
    IBlockState pb0 = BlockStateInterface.get(ctx, positionsToBreak[0]);
    IBlockState pb1 = BlockStateInterface.get(ctx, positionsToBreak[1]);
    if (state.getStatus() != MovementStatus.RUNNING) {
        // if the setting is enabled
        if (!Baritone.settings().walkWhileBreaking.value) {
            return state;
        }
        // and if we're prepping (aka mining the block in front)
        if (state.getStatus() != MovementStatus.PREPPING) {
            return state;
        }
        // and if it's fine to walk into the blocks in front
        if (MovementHelper.avoidWalkingInto(pb0.getBlock())) {
            return state;
        }
        if (MovementHelper.avoidWalkingInto(pb1.getBlock())) {
            return state;
        }
        // and we aren't already pressed up against the block
        double dist = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
        if (dist < 0.83) {
            return state;
        }
        if (!state.getTarget().getRotation().isPresent()) {
            // this can happen rarely when the server lags and doesn't send the falling sand entity until you've already walked through the block and are now mining the next one
            return state;
        }
        // combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break
        // it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw
        float yawToDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), dest), ctx.playerRotations()).getYaw();
        float pitchToBreak = state.getTarget().getRotation().get().getPitch();
        if ((pb0.isFullCube() || pb0.getBlock() instanceof BlockAir && (pb1.isFullCube() || pb1.getBlock() instanceof BlockAir))) {
            // in the meantime, before we're right up against the block, we can break efficiently at this angle
            pitchToBreak = 26;
        }
        return state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true)).setInput(Input.MOVE_FORWARD, true).setInput(Input.SPRINT, true);
    }
    // sneak may have been set to true in the PREPPING state while mining an adjacent block
    state.setInput(Input.SNEAK, false);
    Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
    boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
    if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) {
        boolean notPassable = pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src);
        boolean canOpen = !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()));
        if (notPassable && canOpen) {
            return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)).setInput(Input.CLICK_RIGHT, true);
        }
    }
    if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
        BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0] : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] : null;
        if (blocked != null) {
            Optional<Rotation> rotation = RotationUtils.reachable(ctx, blocked);
            if (rotation.isPresent()) {
                return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true);
            }
        }
    }
    boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
    BlockPos feet = ctx.playerFeet();
    if (feet.getY() != dest.getY() && !ladder) {
        logDebug("Wrong Y coordinate");
        if (feet.getY() < dest.getY()) {
            return state.setInput(Input.JUMP, true);
        }
        return state;
    }
    if (isTheBridgeBlockThere) {
        if (feet.equals(dest)) {
            return state.setStatus(MovementStatus.SUCCESS);
        }
        if (Baritone.settings().overshootTraverse.value && (feet.equals(dest.add(getDirection())) || feet.equals(dest.add(getDirection()).add(getDirection())))) {
            return state.setStatus(MovementStatus.SUCCESS);
        }
        Block low = BlockStateInterface.get(ctx, src).getBlock();
        Block high = BlockStateInterface.get(ctx, src.up()).getBlock();
        if (ctx.player().posY > src.y + 0.1D && !ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
            // wait until we're on the ground
            return state;
        }
        BlockPos into = dest.subtract(src).add(dest);
        Block intoBelow = BlockStateInterface.get(ctx, into).getBlock();
        Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock();
        if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
            state.setInput(Input.SPRINT, true);
        }
        IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
        BlockPos against = positionsToBreak[0];
        if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
            against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(BlockLadder.FACING).getOpposite());
            if (against == null) {
                logDirect("Unable to climb vines. Consider disabling allowVines.");
                return state.setStatus(MovementStatus.UNREACHABLE);
            }
        }
        MovementHelper.moveTowards(ctx, state, against);
        return state;
    } else {
        wasTheBridgeBlockAlwaysThere = false;
        Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock();
        if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) {
            // see issue #118
            double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ));
            if (dist < 0.85) {
                // 0.5 + 0.3 + epsilon
                MovementHelper.moveTowards(ctx, state, dest);
                return state.setInput(Input.MOVE_FORWARD, false).setInput(Input.MOVE_BACK, true);
            }
        }
        double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
        PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true);
        if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) {
            state.setInput(Input.SNEAK, true);
        }
        switch(p) {
            case READY_TO_PLACE:
                {
                    if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.value) {
                        state.setInput(Input.CLICK_RIGHT, true);
                    }
                    return state;
                }
            case ATTEMPTING:
                {
                    if (dist1 > 0.83) {
                        // might need to go forward a bit
                        float yaw = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()).getYaw();
                        if (Math.abs(state.getTarget().rotation.getYaw() - yaw) < 0.1) {
                            // but only if our attempted place is straight ahead
                            return state.setInput(Input.MOVE_FORWARD, true);
                        }
                    } else if (ctx.playerRotations().isReallyCloseTo(state.getTarget().rotation)) {
                        // well i guess theres something in the way
                        return state.setInput(Input.CLICK_LEFT, true);
                    }
                    return state;
                }
            default:
                break;
        }
        if (feet.equals(dest)) {
            // If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
            // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
            double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;
            double faceY = (dest.getY() + src.getY() - 1.0D) * 0.5D;
            double faceZ = (dest.getZ() + src.getZ() + 1.0D) * 0.5D;
            // faceX, faceY, faceZ is the middle of the face between from and to
            // this is the block we were just standing on, and the one we want to place against
            BlockPos goalLook = src.down();
            Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
            float pitch = backToFace.getPitch();
            double dist2 = Math.max(Math.abs(ctx.player().posX - faceX), Math.abs(ctx.player().posZ - faceZ));
            if (dist2 < 0.29) {
                // see issue #208
                float yaw = RotationUtils.calcRotationFromVec3d(VecUtils.getBlockPosCenter(dest), ctx.playerHead(), ctx.playerRotations()).getYaw();
                state.setTarget(new MovementState.MovementTarget(new Rotation(yaw, pitch), true));
                state.setInput(Input.MOVE_BACK, true);
            } else {
                state.setTarget(new MovementState.MovementTarget(backToFace, true));
            }
            if (ctx.isLookingAt(goalLook)) {
                // wait to right click until we are able to place
                return state.setInput(Input.CLICK_RIGHT, true);
            }
            // Out.log("Trying to look at " + goalLook + ", actually looking at" + Baritone.whatAreYouLookingAt());
            if (ctx.playerRotations().isReallyCloseTo(state.getTarget().rotation)) {
                state.setInput(Input.CLICK_LEFT, true);
            }
            return state;
        }
        MovementHelper.moveTowards(ctx, state, positionsToBreak[0]);
        return state;
    // TODO MovementManager.moveTowardsBlock(to); // move towards not look at because if we are bridging for a couple blocks in a row, it is faster if we dont spin around and walk forwards then spin around and place backwards for every block
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) CalculationContext(baritone.pathing.movement.CalculationContext) Rotation(baritone.api.utils.Rotation) Vec3d(net.minecraft.util.math.Vec3d) MovementState(baritone.pathing.movement.MovementState) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 13 with Rotation

use of baritone.api.utils.Rotation in project baritone by cabaletta.

the class BuilderProcess method toBreakNearPlayer.

private Optional<Tuple<BetterBlockPos, Rotation>> toBreakNearPlayer(BuilderCalculationContext bcc) {
    BetterBlockPos center = ctx.playerFeet();
    BetterBlockPos pathStart = baritone.getPathingBehavior().pathStart();
    for (int dx = -5; dx <= 5; dx++) {
        for (int dy = Baritone.settings().breakFromAbove.value ? -1 : 0; dy <= 5; dy++) {
            for (int dz = -5; dz <= 5; dz++) {
                int x = center.x + dx;
                int y = center.y + dy;
                int z = center.z + dz;
                if (dy == -1 && x == pathStart.x && z == pathStart.z) {
                    // dont mine what we're supported by, but not directly standing on
                    continue;
                }
                IBlockState desired = bcc.getSchematic(x, y, z, bcc.bsi.get0(x, y, z));
                if (desired == null) {
                    // irrelevant
                    continue;
                }
                IBlockState curr = bcc.bsi.get0(x, y, z);
                if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !valid(curr, desired, false)) {
                    BetterBlockPos pos = new BetterBlockPos(x, y, z);
                    Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
                    if (rot.isPresent()) {
                        return Optional.of(new Tuple<>(pos, rot.get()));
                    }
                }
            }
        }
    }
    return Optional.empty();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BetterBlockPos(baritone.api.utils.BetterBlockPos) Rotation(baritone.api.utils.Rotation)

Example 14 with Rotation

use of baritone.api.utils.Rotation in project baritone by cabaletta.

the class BuilderProcess method possibleToPlace.

private Optional<Placement> possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) {
    for (EnumFacing against : EnumFacing.values()) {
        BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against);
        IBlockState placeAgainstState = bsi.get0(placeAgainstPos);
        if (MovementHelper.isReplaceable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) {
            continue;
        }
        if (!ctx.world().mayPlace(toPlace.getBlock(), new BetterBlockPos(x, y, z), false, against, null)) {
            continue;
        }
        AxisAlignedBB aabb = placeAgainstState.getBoundingBox(ctx.world(), placeAgainstPos);
        for (Vec3d placementMultiplier : aabbSideMultipliers(against)) {
            double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x);
            double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
            double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
            Rotation rot = RotationUtils.calcRotationFromVec3d(RayTraceUtils.inferSneakingEyePosition(ctx.player()), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
            RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance(), true);
            if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) {
                OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
                if (hotbar.isPresent()) {
                    return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot));
                }
            }
        }
    }
    return Optional.empty();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BetterBlockPos(baritone.api.utils.BetterBlockPos) Rotation(baritone.api.utils.Rotation)

Example 15 with Rotation

use of baritone.api.utils.Rotation in project baritone by cabaletta.

the class MovementDescend method updateState.

@Override
public MovementState updateState(MovementState state) {
    super.updateState(state);
    if (state.getStatus() != MovementStatus.RUNNING) {
        return state;
    }
    BlockPos playerFeet = ctx.playerFeet();
    BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
    if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().posY - dest.getY() < 0.5)) {
        // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
        return state.setStatus(MovementStatus.SUCCESS);
    /* else {
                // System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY()));
            }*/
    }
    if (safeMode()) {
        double destX = (src.getX() + 0.5) * 0.17 + (dest.getX() + 0.5) * 0.83;
        double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
        EntityPlayerSP player = ctx.player();
        state.setTarget(new MovementState.MovementTarget(new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(destX, dest.getY(), destZ), new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch), false)).setInput(Input.MOVE_FORWARD, true);
        return state;
    }
    double diffX = ctx.player().posX - (dest.getX() + 0.5);
    double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
    double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
    double x = ctx.player().posX - (src.getX() + 0.5);
    double z = ctx.player().posZ - (src.getZ() + 0.5);
    double fromStart = Math.sqrt(x * x + z * z);
    if (!playerFeet.equals(dest) || ab > 0.25) {
        if (numTicks++ < 20 && fromStart < 1.25) {
            MovementHelper.moveTowards(ctx, state, fakeDest);
        } else {
            MovementHelper.moveTowards(ctx, state, dest);
        }
    }
    return state;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Rotation(baritone.api.utils.Rotation) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Rotation (baritone.api.utils.Rotation)18 BetterBlockPos (baritone.api.utils.BetterBlockPos)14 IBlockState (net.minecraft.block.state.IBlockState)12 BlockPos (net.minecraft.util.math.BlockPos)12 Vec3d (net.minecraft.util.math.Vec3d)10 Goal (baritone.api.pathing.goals.Goal)4 PathingCommand (baritone.api.process.PathingCommand)4 CalculationContext (baritone.pathing.movement.CalculationContext)4 MovementState (baritone.pathing.movement.MovementState)4 Baritone (baritone.Baritone)2 IBaritone (baritone.api.IBaritone)2 GoalBlock (baritone.api.pathing.goals.GoalBlock)2 GoalComposite (baritone.api.pathing.goals.GoalComposite)2 MovementStatus (baritone.api.pathing.movement.MovementStatus)2 ISchematic (baritone.api.schematic.ISchematic)2 RotationUtils (baritone.api.utils.RotationUtils)2 VecUtils (baritone.api.utils.VecUtils)2 Input (baritone.api.utils.input.Input)2 Movement (baritone.pathing.movement.Movement)2 MovementHelper (baritone.pathing.movement.MovementHelper)2