Search in sources :

Example 1 with GoalBlock

use of baritone.api.pathing.goals.GoalBlock in project baritone by cabaletta.

the class ComeCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    Entity entity = mc.getRenderViewEntity();
    if (entity == null) {
        throw new CommandInvalidStateException("render view entity is null");
    }
    baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
    logDirect("Coming");
}
Also used : Entity(net.minecraft.entity.Entity) GoalBlock(baritone.api.pathing.goals.GoalBlock) BlockPos(net.minecraft.util.math.BlockPos) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException)

Example 2 with GoalBlock

use of baritone.api.pathing.goals.GoalBlock in project baritone by cabaletta.

the class BuilderProcess method assemble.

private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlaceable, boolean logMissing) {
    List<BetterBlockPos> placeable = new ArrayList<>();
    List<BetterBlockPos> breakable = new ArrayList<>();
    List<BetterBlockPos> sourceLiquids = new ArrayList<>();
    List<BetterBlockPos> flowingLiquids = new ArrayList<>();
    Map<IBlockState, Integer> missing = new HashMap<>();
    incorrectPositions.forEach(pos -> {
        IBlockState state = bcc.bsi.get0(pos);
        if (state.getBlock() instanceof BlockAir) {
            if (approxPlaceable.contains(bcc.getSchematic(pos.x, pos.y, pos.z, state))) {
                placeable.add(pos);
            } else {
                IBlockState desired = bcc.getSchematic(pos.x, pos.y, pos.z, state);
                missing.put(desired, 1 + missing.getOrDefault(desired, 0));
            }
        } else {
            if (state.getBlock() instanceof BlockLiquid) {
                // TODO for 1.13 make sure that this only matches pure water, not waterlogged blocks
                if (!MovementHelper.possiblyFlowing(state)) {
                    // if it's a source block then we want to replace it with a throwaway
                    sourceLiquids.add(pos);
                } else {
                    flowingLiquids.add(pos);
                }
            } else {
                breakable.add(pos);
            }
        }
    });
    List<Goal> toBreak = new ArrayList<>();
    breakable.forEach(pos -> toBreak.add(breakGoal(pos, bcc)));
    List<Goal> toPlace = new ArrayList<>();
    placeable.forEach(pos -> {
        if (!placeable.contains(pos.down()) && !placeable.contains(pos.down(2))) {
            toPlace.add(placementGoal(pos, bcc));
        }
    });
    sourceLiquids.forEach(pos -> toPlace.add(new GoalBlock(pos.up())));
    if (!toPlace.isEmpty()) {
        return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0])));
    }
    if (toBreak.isEmpty()) {
        if (logMissing && !missing.isEmpty()) {
            logDirect("Missing materials for at least:");
            logDirect(missing.entrySet().stream().map(e -> String.format("%sx %s", e.getValue(), e.getKey())).collect(Collectors.joining("\n")));
        }
        if (logMissing && !flowingLiquids.isEmpty()) {
            logDirect("Unreplaceable liquids at at least:");
            logDirect(flowingLiquids.stream().map(p -> String.format("%s %s %s", p.x, p.y, p.z)).collect(Collectors.joining("\n")));
        }
        return null;
    }
    return new GoalComposite(toBreak.toArray(new Goal[0]));
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GoalBlock(baritone.api.pathing.goals.GoalBlock) GoalComposite(baritone.api.pathing.goals.GoalComposite) Goal(baritone.api.pathing.goals.Goal) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 3 with GoalBlock

use of baritone.api.pathing.goals.GoalBlock 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 4 with GoalBlock

use of baritone.api.pathing.goals.GoalBlock in project baritone by cabaletta.

the class GuiClick method mouseReleased.

@Override
protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
    if (currentMouseOver != null) {
        // Catch this, or else a click into void will result in a crash
        if (mouseButton == 0) {
            if (clickStart != null && !clickStart.equals(currentMouseOver)) {
                BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
                BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
                ITextComponent component = new TextComponentString("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
                component.getStyle().setColor(TextFormatting.WHITE).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + "help sel"));
                Helper.HELPER.logDirect(component);
                clickStart = null;
            } else {
                BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver));
            }
        } else if (mouseButton == 1) {
            BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up()));
        }
    }
    clickStart = null;
}
Also used : GoalBlock(baritone.api.pathing.goals.GoalBlock) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with GoalBlock

use of baritone.api.pathing.goals.GoalBlock in project Spark-Client by Spark-Client-Development.

the class ComeCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    Entity entity = mc.getRenderViewEntity();
    if (entity == null) {
        throw new CommandInvalidStateException("render view entity is null");
    }
    baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
    logDirect("Coming");
}
Also used : Entity(net.minecraft.entity.Entity) GoalBlock(baritone.api.pathing.goals.GoalBlock) BlockPos(net.minecraft.util.math.BlockPos) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException)

Aggregations

GoalBlock (baritone.api.pathing.goals.GoalBlock)17 Goal (baritone.api.pathing.goals.Goal)8 BetterBlockPos (baritone.api.utils.BetterBlockPos)6 BlockPos (net.minecraft.util.math.BlockPos)5 CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)4 GoalComposite (baritone.api.pathing.goals.GoalComposite)4 IBlockState (net.minecraft.block.state.IBlockState)4 Entity (net.minecraft.entity.Entity)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 TextComponentString (net.minecraft.util.text.TextComponentString)4 ClickEvent (net.minecraft.util.text.event.ClickEvent)4 ArrayList (java.util.ArrayList)3 IBaritone (baritone.api.IBaritone)2 IWaypoint (baritone.api.cache.IWaypoint)2 Waypoint (baritone.api.cache.Waypoint)2 Command (baritone.api.command.Command)2 FORCE_COMMAND_PREFIX (baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX)2 IArgConsumer (baritone.api.command.argument.IArgConsumer)2 ForWaypoints (baritone.api.command.datatypes.ForWaypoints)2 RelativeBlockPos (baritone.api.command.datatypes.RelativeBlockPos)2