Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

#goto x y z to a portal ignores #enterportal

xaengceilbiths opened this issue ยท 2 comments

commented

Some information

Operating system: Linux
Java version: 8
Minecraft version: 1.14.4
Baritone version: 1.4.2
SimpleTweaker version: 1.2
VANILLA without forge

How to reproduce

#goto a nether portal block with enterportal set to false still enters the nether portal.
#goto a chest with rightclickonarrival set to true will destroy the chest.

commented

If I use #goto nether_portal, will stay in front of the portal.
If I use #goto x y z, will go into the portal.

commented

I implemented this feature myself.
The command looks like #goto chest x y z.
The implementation is dirty. Some checks are not enough.

public void getToBlockWithGoal(BlockOptionalMeta block, BlockPos goalPos) {
    onLostControl();
    gettingTo = block;
    start = ctx.playerFeet();
    blacklist = new ArrayList<>();
    arrivalTickCount = 0;
    knownLocations = new ArrayList<>();
    knownLocations.add(goalPos);
}



@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) { // if we have a numeric first argument...
        BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
        Goal goal = args.getDatatypePostOrNull(RelativeGoal.INSTANCE, origin);
        logDirect(String.format("Going to: %s", goal.toString()));
        baritone.getCustomGoalProcess().setGoalAndPath(goal);
        return;
    }
    if (args.hasExactlyOne()) {
        args.requireMax(1);
        BlockOptionalMeta destination = args.getDatatypeFor(ForBlockOptionalMeta.INSTANCE);
        baritone.getGetToBlockProcess().getToBlock(destination);
    }
    // The check for arg number is not enough.
    args.requireMax(4);
    BlockOptionalMeta destination = args.getDatatypeFor(ForBlockOptionalMeta.INSTANCE);
    BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
    GoalBlock goalBlock = args.getDatatypePostOrNull(RelativeGoalBlock.INSTANCE, origin);
    baritone.getGetToBlockProcess().getToBlockWithGoal(destination, goalBlock.getGoalPos());
}