From ffc050668b84e01d205af8f978986f6519e19db8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 7 Nov 2018 10:01:58 -0800 Subject: [PATCH] fix cherry pick merge errors --- .../baritone/process/GetToBlockProcess.java | 99 ------------------- .../utils/ExampleBaritoneControl.java | 2 +- 2 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 src/main/java/baritone/process/GetToBlockProcess.java diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java deleted file mode 100644 index d35b4fb4..00000000 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.process; - -import baritone.Baritone; -import baritone.api.pathing.goals.Goal; -import baritone.api.pathing.goals.GoalComposite; -import baritone.api.pathing.goals.GoalGetToBlock; -import baritone.api.process.IGetToBlockProcess; -import baritone.api.process.PathingCommand; -import baritone.api.process.PathingCommandType; -import baritone.utils.BaritoneProcessHelper; -import net.minecraft.block.Block; -import net.minecraft.util.math.BlockPos; - -import java.util.Collections; -import java.util.List; - -public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { - private Block gettingTo; - private List knownLocations; - - private int tickCount = 0; - - public GetToBlockProcess(Baritone baritone) { - super(baritone, 2); - } - - @Override - public void getToBlock(Block block) { - gettingTo = block; - rescan(); - } - - @Override - public boolean isActive() { - return gettingTo != null; - } - - @Override - public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { - if (knownLocations == null) { - rescan(); - } - if (knownLocations.isEmpty()) { - logDirect("No known locations of " + gettingTo + ", canceling GetToBlock"); - if (isSafeToCancel) { - onLostControl(); - } - return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL); - } - if (calcFailed) { - logDirect("Unable to find any path to " + gettingTo + ", canceling GetToBlock"); - if (isSafeToCancel) { - onLostControl(); - } - return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL); - } - int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); - if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain - Baritone.INSTANCE.getExecutor().execute(this::rescan); - } - Goal goal = new GoalComposite(knownLocations.stream().map(GoalGetToBlock::new).toArray(Goal[]::new)); - if (goal.isInGoal(playerFeet())) { - onLostControl(); - } - return new PathingCommand(goal, PathingCommandType.REVALIDATE_GOAL_AND_PATH); - } - - @Override - public void onLostControl() { - gettingTo = null; - knownLocations = null; - } - - @Override - public String displayName() { - return "Get To Block " + gettingTo; - } - - private void rescan() { - knownLocations = MineProcess.searchWorld(Collections.singletonList(gettingTo), 64, world()); - } -} \ No newline at end of file diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index a620a86b..4999cf11 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -410,7 +410,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return true; } } else { - List locs = baritone.getMineBehavior().searchWorld(Collections.singletonList(block), 64); + List locs = baritone.getMineBehavior().searchWorld(Collections.singletonList(block), 64, world()); if (locs.isEmpty()) { logDirect("No locations for " + mining + " known, cancelling"); return true;