diff --git a/src/api/java/baritone/api/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java
index 872ce1bd..52b83258 100644
--- a/src/api/java/baritone/api/behavior/Behavior.java
+++ b/src/api/java/baritone/api/behavior/Behavior.java
@@ -17,16 +17,13 @@
package baritone.api.behavior;
-import baritone.api.event.listener.AbstractGameEventListener;
-import baritone.api.utils.interfaces.Toggleable;
-
/**
* A type of game event listener that can be toggled.
*
* @author Brady
* @since 8/1/2018 6:29 PM
*/
-public class Behavior implements AbstractGameEventListener, Toggleable {
+public class Behavior implements IBehavior {
/**
* Whether or not this behavior is enabled
diff --git a/src/api/java/baritone/api/behavior/IBehavior.java b/src/api/java/baritone/api/behavior/IBehavior.java
new file mode 100644
index 00000000..aee144e2
--- /dev/null
+++ b/src/api/java/baritone/api/behavior/IBehavior.java
@@ -0,0 +1,27 @@
+/*
+ * 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.api.behavior;
+
+import baritone.api.event.listener.AbstractGameEventListener;
+import baritone.api.utils.interfaces.Toggleable;
+
+/**
+ * @author Brady
+ * @since 9/23/2018
+ */
+public interface IBehavior extends AbstractGameEventListener, Toggleable {}
diff --git a/src/api/java/baritone/api/behavior/IFollowBehavior.java b/src/api/java/baritone/api/behavior/IFollowBehavior.java
new file mode 100644
index 00000000..c960fab3
--- /dev/null
+++ b/src/api/java/baritone/api/behavior/IFollowBehavior.java
@@ -0,0 +1,44 @@
+/*
+ * 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.api.behavior;
+
+import net.minecraft.entity.Entity;
+
+/**
+ * @author Brady
+ * @since 9/23/2018
+ */
+public interface IFollowBehavior extends IBehavior {
+
+ /**
+ * Set the follow target to the specified entity;
+ *
+ * @param entity The entity to follow
+ */
+ void follow(Entity entity);
+
+ /**
+ * @return The entity that is currently being followed
+ */
+ Entity following();
+
+ /**
+ * Cancels the follow behavior, this will clear the current follow target.
+ */
+ void cancel();
+}
diff --git a/src/api/java/baritone/api/behavior/ILookBehavior.java b/src/api/java/baritone/api/behavior/ILookBehavior.java
new file mode 100644
index 00000000..b5b5d63b
--- /dev/null
+++ b/src/api/java/baritone/api/behavior/ILookBehavior.java
@@ -0,0 +1,39 @@
+/*
+ * 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.api.behavior;
+
+import baritone.api.utils.Rotation;
+
+/**
+ * @author Brady
+ * @since 9/23/2018
+ */
+public interface ILookBehavior extends IBehavior {
+
+ /**
+ * Updates the current {@link ILookBehavior} target to target
+ * the specified rotations on the next tick. If force is {@code true},
+ * then freeLook will be overriden and angles will be set regardless.
+ * If any sort of block interaction is required, force should be {@code true},
+ * otherwise, it should be {@code false};
+ *
+ * @param rotation The target rotations
+ * @param force Whether or not to "force" the rotations
+ */
+ void updateTarget(Rotation rotation, boolean force);
+}
diff --git a/src/api/java/baritone/api/behavior/IMineBehavior.java b/src/api/java/baritone/api/behavior/IMineBehavior.java
new file mode 100644
index 00000000..394fcaf0
--- /dev/null
+++ b/src/api/java/baritone/api/behavior/IMineBehavior.java
@@ -0,0 +1,70 @@
+/*
+ * 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.api.behavior;
+
+import net.minecraft.block.Block;
+
+/**
+ * @author Brady
+ * @since 9/23/2018
+ */
+public interface IMineBehavior {
+
+ /**
+ * Begin to search for and mine the specified blocks until
+ * the number of specified items to get from the blocks that
+ * are mined. This is based on the first target block to mine.
+ *
+ * @param quantity The number of items to get from blocks mined
+ * @param blocks The blocks to mine
+ */
+ void mine(int quantity, String... blocks);
+
+ /**
+ * Begin to search for and mine the specified blocks until
+ * the number of specified items to get from the blocks that
+ * are mined. This is based on the first target block to mine.
+ *
+ * @param quantity The number of items to get from blocks mined
+ * @param blocks The blocks to mine
+ */
+ void mine(int quantity, Block... blocks);
+
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param blocks The blocks to mine
+ */
+ default void mine(String... blocks) {
+ this.mine(0, blocks);
+ }
+
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param blocks The blocks to mine
+ */
+ default void mine(Block... blocks) {
+ this.mine(0, blocks);
+ }
+
+ /**
+ * Cancels the current mining task
+ */
+ void cancel();
+}
diff --git a/src/main/java/baritone/utils/Rotation.java b/src/api/java/baritone/api/utils/Rotation.java
similarity index 96%
rename from src/main/java/baritone/utils/Rotation.java
rename to src/api/java/baritone/api/utils/Rotation.java
index ce92d009..ca8cb66f 100644
--- a/src/main/java/baritone/utils/Rotation.java
+++ b/src/api/java/baritone/api/utils/Rotation.java
@@ -15,7 +15,7 @@
* along with Baritone. If not, see .
*/
-package baritone.utils;
+package baritone.api.utils;
import net.minecraft.util.Tuple;
diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java
index a007a6b5..5b2323cc 100644
--- a/src/main/java/baritone/behavior/FollowBehavior.java
+++ b/src/main/java/baritone/behavior/FollowBehavior.java
@@ -19,6 +19,7 @@ package baritone.behavior;
import baritone.Baritone;
import baritone.api.behavior.Behavior;
+import baritone.api.behavior.IFollowBehavior;
import baritone.api.event.events.TickEvent;
import baritone.pathing.goals.GoalNear;
import baritone.pathing.goals.GoalXZ;
@@ -31,7 +32,7 @@ import net.minecraft.util.math.BlockPos;
*
* @author leijurv
*/
-public final class FollowBehavior extends Behavior implements Helper {
+public final class FollowBehavior extends Behavior implements IFollowBehavior, Helper {
public static final FollowBehavior INSTANCE = new FollowBehavior();
@@ -61,14 +62,17 @@ public final class FollowBehavior extends Behavior implements Helper {
PathingBehavior.INSTANCE.path();
}
+ @Override
public void follow(Entity entity) {
this.following = entity;
}
+ @Override
public Entity following() {
return this.following;
}
+ @Override
public void cancel() {
PathingBehavior.INSTANCE.cancel();
follow(null);
diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java
index d45ad585..c1dfa94a 100644
--- a/src/main/java/baritone/behavior/LookBehavior.java
+++ b/src/main/java/baritone/behavior/LookBehavior.java
@@ -20,12 +20,13 @@ package baritone.behavior;
import baritone.Baritone;
import baritone.Settings;
import baritone.api.behavior.Behavior;
+import baritone.api.behavior.ILookBehavior;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RotationMoveEvent;
import baritone.utils.Helper;
-import baritone.utils.Rotation;
+import baritone.api.utils.Rotation;
-public final class LookBehavior extends Behavior implements Helper {
+public final class LookBehavior extends Behavior implements ILookBehavior, Helper {
public static final LookBehavior INSTANCE = new LookBehavior();
@@ -51,6 +52,7 @@ public final class LookBehavior extends Behavior implements Helper {
private LookBehavior() {}
+ @Override
public void updateTarget(Rotation target, boolean force) {
this.target = target;
this.force = force || !Baritone.settings().freeLook.get();
diff --git a/src/main/java/baritone/behavior/LookBehaviorUtils.java b/src/main/java/baritone/behavior/LookBehaviorUtils.java
index ed7f730e..451d83a1 100644
--- a/src/main/java/baritone/behavior/LookBehaviorUtils.java
+++ b/src/main/java/baritone/behavior/LookBehaviorUtils.java
@@ -17,6 +17,7 @@
package baritone.behavior;
+import baritone.api.utils.Rotation;
import baritone.utils.*;
import net.minecraft.block.BlockFire;
import net.minecraft.block.state.IBlockState;
diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java
index 853ef9cb..4a793f0a 100644
--- a/src/main/java/baritone/behavior/MineBehavior.java
+++ b/src/main/java/baritone/behavior/MineBehavior.java
@@ -19,6 +19,7 @@ package baritone.behavior;
import baritone.Baritone;
import baritone.api.behavior.Behavior;
+import baritone.api.behavior.IMineBehavior;
import baritone.api.event.events.PathEvent;
import baritone.api.event.events.TickEvent;
import baritone.cache.CachedChunk;
@@ -46,7 +47,7 @@ import java.util.stream.Collectors;
*
* @author leijurv
*/
-public final class MineBehavior extends Behavior implements Helper {
+public final class MineBehavior extends Behavior implements IMineBehavior, Helper {
public static final MineBehavior INSTANCE = new MineBehavior();
@@ -109,7 +110,7 @@ public final class MineBehavior extends Behavior implements Helper {
PathingBehavior.INSTANCE.path();
}
- public static GoalComposite coalesce(List locs) {
+ public GoalComposite coalesce(List locs) {
return new GoalComposite(locs.stream().map(loc -> {
if (!Baritone.settings().forceInternalMining.get()) {
return new GoalTwoBlocks(loc);
@@ -133,7 +134,7 @@ public final class MineBehavior extends Behavior implements Helper {
}).toArray(Goal[]::new));
}
- public static List scanFor(List mining, int max) {
+ public List scanFor(List mining, int max) {
List locs = new ArrayList<>();
List uninteresting = new ArrayList<>();
//long b = System.currentTimeMillis();
@@ -156,7 +157,7 @@ public final class MineBehavior extends Behavior implements Helper {
return prune(locs, mining, max);
}
- public static List prune(List locs, List mining, int max) {
+ public List prune(List locs, List mining, int max) {
BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet();
locs.sort(Comparator.comparingDouble(playerFeet::distanceSq));
@@ -171,6 +172,7 @@ public final class MineBehavior extends Behavior implements Helper {
return locs;
}
+ @Override
public void mine(int quantity, String... blocks) {
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).collect(Collectors.toList());
this.quantity = quantity;
@@ -178,12 +180,15 @@ public final class MineBehavior extends Behavior implements Helper {
updateGoal();
}
- public void mine(Block... blocks) {
+ @Override
+ public void mine(int quantity, Block... blocks) {
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
+ this.quantity = quantity;
this.locationsCache = new ArrayList<>();
updateGoal();
}
+ @Override
public void cancel() {
mine(0, (String[]) null);
PathingBehavior.INSTANCE.cancel();
diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java
index 11237005..21341fa4 100644
--- a/src/main/java/baritone/pathing/movement/Movement.java
+++ b/src/main/java/baritone/pathing/movement/Movement.java
@@ -18,6 +18,7 @@
package baritone.pathing.movement;
import baritone.Baritone;
+import baritone.api.utils.Rotation;
import baritone.behavior.LookBehavior;
import baritone.behavior.LookBehaviorUtils;
import baritone.pathing.movement.MovementState.MovementStatus;
diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java
index df16879c..e173e766 100644
--- a/src/main/java/baritone/pathing/movement/MovementHelper.java
+++ b/src/main/java/baritone/pathing/movement/MovementHelper.java
@@ -18,6 +18,7 @@
package baritone.pathing.movement;
import baritone.Baritone;
+import baritone.api.utils.Rotation;
import baritone.behavior.LookBehaviorUtils;
import baritone.pathing.movement.MovementState.MovementTarget;
import baritone.utils.*;
diff --git a/src/main/java/baritone/pathing/movement/MovementState.java b/src/main/java/baritone/pathing/movement/MovementState.java
index 0017c438..a611b8f2 100644
--- a/src/main/java/baritone/pathing/movement/MovementState.java
+++ b/src/main/java/baritone/pathing/movement/MovementState.java
@@ -18,7 +18,7 @@
package baritone.pathing.movement;
import baritone.utils.InputOverrideHandler.Input;
-import baritone.utils.Rotation;
+import baritone.api.utils.Rotation;
import net.minecraft.util.math.Vec3d;
import java.util.HashMap;
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java
index 335cdc25..980371a9 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java
@@ -18,6 +18,7 @@
package baritone.pathing.movement.movements;
import baritone.Baritone;
+import baritone.api.utils.Rotation;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java
index bf77855d..59085909 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java
@@ -23,7 +23,7 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import baritone.utils.InputOverrideHandler;
-import baritone.utils.Rotation;
+import baritone.api.utils.Rotation;
import baritone.utils.Utils;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.block.*;
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
index 232a8376..721e78a1 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
@@ -25,7 +25,7 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import baritone.utils.InputOverrideHandler;
-import baritone.utils.Rotation;
+import baritone.api.utils.Rotation;
import baritone.utils.Utils;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.block.*;
diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java
index 19a33f32..ff727c51 100644
--- a/src/main/java/baritone/utils/ExampleBaritoneControl.java
+++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java
@@ -368,7 +368,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
logDirect("No locations for " + mining + " known, cancelling");
return;
}
- List locs = MineBehavior.scanFor(Collections.singletonList(block), 64);
+ List locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64);
if (locs.isEmpty()) {
logDirect("No locations for " + mining + " known, cancelling");
return;
diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java
index 9924d0bf..b9b3f0eb 100755
--- a/src/main/java/baritone/utils/Helper.java
+++ b/src/main/java/baritone/utils/Helper.java
@@ -18,6 +18,7 @@
package baritone.utils;
import baritone.Baritone;
+import baritone.api.utils.Rotation;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.block.BlockSlab;
import net.minecraft.client.Minecraft;
diff --git a/src/main/java/baritone/utils/RayTraceUtils.java b/src/main/java/baritone/utils/RayTraceUtils.java
index d859ae4c..1c8115a5 100644
--- a/src/main/java/baritone/utils/RayTraceUtils.java
+++ b/src/main/java/baritone/utils/RayTraceUtils.java
@@ -17,6 +17,7 @@
package baritone.utils;
+import baritone.api.utils.Rotation;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
diff --git a/src/main/java/baritone/utils/Utils.java b/src/main/java/baritone/utils/Utils.java
index 8a63347a..49f6b49d 100755
--- a/src/main/java/baritone/utils/Utils.java
+++ b/src/main/java/baritone/utils/Utils.java
@@ -17,6 +17,7 @@
package baritone.utils;
+import baritone.api.utils.Rotation;
import net.minecraft.block.BlockFire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.entity.EntityPlayerSP;