Search in sources :

Example 11 with BetterBlockPos

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

the class SurfaceCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    final BetterBlockPos playerPos = baritone.getPlayerContext().playerFeet();
    final int surfaceLevel = baritone.getPlayerContext().world().getSeaLevel();
    final int worldHeight = baritone.getPlayerContext().world().getActualHeight();
    // As this would imply that your are already on the open surface
    if (playerPos.getY() > surfaceLevel && mc.world.getBlockState(playerPos.up()).getBlock() instanceof BlockAir) {
        logDirect("Already at surface");
        return;
    }
    final int startingYPos = Math.max(playerPos.getY(), surfaceLevel);
    for (int currentIteratedY = startingYPos; currentIteratedY < worldHeight; currentIteratedY++) {
        final BetterBlockPos newPos = new BetterBlockPos(playerPos.getX(), currentIteratedY, playerPos.getZ());
        if (!(mc.world.getBlockState(newPos).getBlock() instanceof BlockAir) && newPos.getY() > playerPos.getY()) {
            Goal goal = new GoalBlock(newPos.up());
            logDirect(String.format("Going to: %s", goal.toString()));
            baritone.getCustomGoalProcess().setGoalAndPath(goal);
            return;
        }
    }
    logDirect("No higher location found");
}
Also used : BlockAir(net.minecraft.block.BlockAir) Goal(baritone.api.pathing.goals.Goal) GoalBlock(baritone.api.pathing.goals.GoalBlock) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 12 with BetterBlockPos

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

the class PathRenderer method drawPath.

public static void drawPath(IPath path, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
    IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
    int fadeStart = fadeStart0 + startIndex;
    int fadeEnd = fadeEnd0 + startIndex;
    List<BetterBlockPos> positions = path.positions();
    for (int i = startIndex, next; i < positions.size() - 1; i = next) {
        BetterBlockPos start = positions.get(i);
        BetterBlockPos end = positions.get(next = i + 1);
        int dirX = end.x - start.x;
        int dirY = end.y - start.y;
        int dirZ = end.z - start.z;
        while (next + 1 < positions.size() && (!fadeOut || next + 1 < fadeStart) && (dirX == positions.get(next + 1).x - end.x && dirY == positions.get(next + 1).y - end.y && dirZ == positions.get(next + 1).z - end.z)) {
            end = positions.get(++next);
        }
        if (fadeOut) {
            float alpha;
            if (i <= fadeStart) {
                alpha = 0.4F;
            } else {
                if (i > fadeEnd) {
                    break;
                }
                alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
            }
            IRenderer.glColor(color, alpha);
        }
        drawLine(start.x, start.y, start.z, end.x, end.y, end.z);
        tessellator.draw();
    }
    IRenderer.endLines(settings.renderPathIgnoreDepth.value);
}
Also used : BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 13 with BetterBlockPos

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

the class GoalCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
    if (args.hasAny() && Arrays.asList("reset", "clear", "none").contains(args.peekString())) {
        args.requireMax(1);
        if (goalProcess.getGoal() != null) {
            goalProcess.setGoal(null);
            logDirect("Cleared goal");
        } else {
            logDirect("There was no goal to clear");
        }
    } else {
        args.requireMax(3);
        BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
        Goal goal = args.getDatatypePost(RelativeGoal.INSTANCE, origin);
        goalProcess.setGoal(goal);
        logDirect(String.format("Goal: %s", goal.toString()));
    }
}
Also used : RelativeGoal(baritone.api.command.datatypes.RelativeGoal) Goal(baritone.api.pathing.goals.Goal) ICustomGoalProcess(baritone.api.process.ICustomGoalProcess) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 14 with BetterBlockPos

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

the class GotoCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    // is no need to handle the case of empty arguments.
    if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) {
        args.requireMax(3);
        BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
        Goal goal = args.getDatatypePost(RelativeGoal.INSTANCE, origin);
        logDirect(String.format("Going to: %s", goal.toString()));
        baritone.getCustomGoalProcess().setGoalAndPath(goal);
        return;
    }
    args.requireMax(1);
    BlockOptionalMeta destination = args.getDatatypeFor(ForBlockOptionalMeta.INSTANCE);
    baritone.getGetToBlockProcess().getToBlock(destination);
}
Also used : RelativeGoal(baritone.api.command.datatypes.RelativeGoal) Goal(baritone.api.pathing.goals.Goal) ForBlockOptionalMeta(baritone.api.command.datatypes.ForBlockOptionalMeta) BlockOptionalMeta(baritone.api.utils.BlockOptionalMeta) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 15 with BetterBlockPos

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

the class RenderCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    BetterBlockPos origin = ctx.playerFeet();
    int renderDistance = (mc.gameSettings.renderDistanceChunks + 1) * 16;
    mc.renderGlobal.markBlockRangeForRenderUpdate(origin.x - renderDistance, 0, origin.z - renderDistance, origin.x + renderDistance, 255, origin.z + renderDistance);
    logDirect("Done");
}
Also used : BetterBlockPos(baritone.api.utils.BetterBlockPos)

Aggregations

BetterBlockPos (baritone.api.utils.BetterBlockPos)57 IBlockState (net.minecraft.block.state.IBlockState)15 Goal (baritone.api.pathing.goals.Goal)14 BlockPos (net.minecraft.util.math.BlockPos)10 CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)9 IWaypoint (baritone.api.cache.IWaypoint)6 GoalBlock (baritone.api.pathing.goals.GoalBlock)6 Waypoint (baritone.api.cache.Waypoint)5 Rotation (baritone.api.utils.Rotation)5 EnumFacing (net.minecraft.util.EnumFacing)5 IBaritone (baritone.api.IBaritone)4 Command (baritone.api.command.Command)4 IArgConsumer (baritone.api.command.argument.IArgConsumer)4 ForBlockOptionalMeta (baritone.api.command.datatypes.ForBlockOptionalMeta)4 RelativeBlockPos (baritone.api.command.datatypes.RelativeBlockPos)4 RelativeGoal (baritone.api.command.datatypes.RelativeGoal)4 CommandException (baritone.api.command.exception.CommandException)4 CommandInvalidTypeException (baritone.api.command.exception.CommandInvalidTypeException)4 IPath (baritone.api.pathing.calc.IPath)4 PathingCommand (baritone.api.process.PathingCommand)4