diff --git a/src/main/java/baritone/behavior/Behavior.java b/src/api/java/baritone/api/behavior/Behavior.java
similarity index 59%
rename from src/main/java/baritone/behavior/Behavior.java
rename to src/api/java/baritone/api/behavior/Behavior.java
index 5bf6c5c6..67d3c25b 100644
--- a/src/main/java/baritone/behavior/Behavior.java
+++ b/src/api/java/baritone/api/behavior/Behavior.java
@@ -15,19 +15,18 @@
* along with Baritone. If not, see .
*/
-package baritone.behavior;
+package baritone.api.behavior;
import baritone.api.event.listener.AbstractGameEventListener;
-import baritone.utils.Helper;
-import baritone.utils.interfaces.Toggleable;
+import baritone.api.utils.interfaces.Toggleable;
/**
- * A generic bot behavior.
+ * 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, Helper {
+public class Behavior implements AbstractGameEventListener, Toggleable {
/**
* Whether or not this behavior is enabled
@@ -51,35 +50,18 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
*/
@Override
public final boolean setEnabled(boolean enabled) {
- boolean newState = getNewState(this.enabled, enabled);
- if (newState == this.enabled) {
+ if (enabled == this.enabled)
return this.enabled;
- }
- if (this.enabled = newState) {
- onStart();
+ if (this.enabled = enabled) {
+ this.onEnable();
} else {
- onCancel();
+ this.onDisable();
}
return this.enabled;
}
- /**
- * Function to determine what the new enabled state of this
- * {@link Behavior} should be given the old state, and the
- * proposed state. Intended to be overridden by behaviors
- * that should always be active, given that the bot itself is
- * active.
- *
- * @param oldState The old state
- * @param proposedState The proposed state
- * @return The new state
- */
- public boolean getNewState(boolean oldState, boolean proposedState) {
- return proposedState;
- }
-
/**
* @return Whether or not this {@link Behavior} is active.
*/
@@ -87,14 +69,4 @@ public class Behavior implements AbstractGameEventListener, Toggleable, Helper {
public final boolean isEnabled() {
return this.enabled;
}
-
- /**
- * Called when the state changes from disabled to enabled
- */
- public void onStart() {}
-
- /**
- * Called when the state changes from enabled to disabled
- */
- public void onCancel() {}
}
diff --git a/src/main/java/baritone/utils/interfaces/Toggleable.java b/src/api/java/baritone/api/utils/interfaces/Toggleable.java
similarity index 81%
rename from src/main/java/baritone/utils/interfaces/Toggleable.java
rename to src/api/java/baritone/api/utils/interfaces/Toggleable.java
index ba23bd34..bf43220a 100644
--- a/src/main/java/baritone/utils/interfaces/Toggleable.java
+++ b/src/api/java/baritone/api/utils/interfaces/Toggleable.java
@@ -15,7 +15,7 @@
* along with Baritone. If not, see .
*/
-package baritone.utils.interfaces;
+package baritone.api.utils.interfaces;
/**
* @author Brady
@@ -41,4 +41,14 @@ public interface Toggleable {
* @return Whether or not this {@link Toggleable} object is enabled
*/
boolean isEnabled();
+
+ /**
+ * Called when the state changes from disabled to enabled
+ */
+ default void onEnable() {}
+
+ /**
+ * Called when the state changes from enabled to disabled
+ */
+ default void onDisable() {}
}
diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java
index 3c7bf24c..6c7acc5f 100755
--- a/src/main/java/baritone/Baritone.java
+++ b/src/main/java/baritone/Baritone.java
@@ -18,7 +18,7 @@
package baritone;
import baritone.api.event.listener.IGameEventListener;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.behavior.impl.*;
import baritone.event.GameEventHandler;
import baritone.utils.InputOverrideHandler;
diff --git a/src/main/java/baritone/behavior/impl/FollowBehavior.java b/src/main/java/baritone/behavior/impl/FollowBehavior.java
index 8f9a8615..eb67dfa0 100644
--- a/src/main/java/baritone/behavior/impl/FollowBehavior.java
+++ b/src/main/java/baritone/behavior/impl/FollowBehavior.java
@@ -18,7 +18,7 @@
package baritone.behavior.impl;
import baritone.api.event.events.TickEvent;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.pathing.goals.GoalNear;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
diff --git a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java
index 47dfcd7c..fb7d9db8 100644
--- a/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java
+++ b/src/main/java/baritone/behavior/impl/LocationTrackingBehavior.java
@@ -17,11 +17,12 @@
package baritone.behavior.impl;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.cache.Waypoint;
import baritone.cache.WorldProvider;
import baritone.api.event.events.BlockInteractEvent;
import baritone.utils.BlockStateInterface;
+import baritone.utils.Helper;
import net.minecraft.block.BlockBed;
/**
@@ -33,7 +34,7 @@ import net.minecraft.block.BlockBed;
* @author Brady
* @since 8/22/2018
*/
-public final class LocationTrackingBehavior extends Behavior {
+public final class LocationTrackingBehavior extends Behavior implements Helper {
public static final LocationTrackingBehavior INSTANCE = new LocationTrackingBehavior();
diff --git a/src/main/java/baritone/behavior/impl/LookBehavior.java b/src/main/java/baritone/behavior/impl/LookBehavior.java
index 904087ab..ddf58619 100644
--- a/src/main/java/baritone/behavior/impl/LookBehavior.java
+++ b/src/main/java/baritone/behavior/impl/LookBehavior.java
@@ -21,10 +21,11 @@ import baritone.Baritone;
import baritone.Settings;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RotationMoveEvent;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
+import baritone.utils.Helper;
import baritone.utils.Rotation;
-public class LookBehavior extends Behavior {
+public class LookBehavior extends Behavior implements Helper {
public static final LookBehavior INSTANCE = new LookBehavior();
diff --git a/src/main/java/baritone/behavior/impl/MemoryBehavior.java b/src/main/java/baritone/behavior/impl/MemoryBehavior.java
index 93657988..5d99c2d1 100644
--- a/src/main/java/baritone/behavior/impl/MemoryBehavior.java
+++ b/src/main/java/baritone/behavior/impl/MemoryBehavior.java
@@ -3,7 +3,8 @@ package baritone.behavior.impl;
import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.type.EventState;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
+import baritone.utils.Helper;
import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.CPacketCloseWindow;
@@ -20,7 +21,7 @@ import java.util.*;
* @author Brady
* @since 8/6/2018 9:47 PM
*/
-public class MemoryBehavior extends Behavior {
+public class MemoryBehavior extends Behavior implements Helper {
public static MemoryBehavior INSTANCE = new MemoryBehavior();
diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java
index 9b220d01..a36aa02f 100644
--- a/src/main/java/baritone/behavior/impl/MineBehavior.java
+++ b/src/main/java/baritone/behavior/impl/MineBehavior.java
@@ -18,7 +18,7 @@
package baritone.behavior.impl;
import baritone.api.event.events.PathEvent;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.cache.CachedChunk;
import baritone.cache.ChunkPacker;
import baritone.cache.WorldProvider;
@@ -27,6 +27,7 @@ import baritone.pathing.goals.Goal;
import baritone.pathing.goals.GoalComposite;
import baritone.pathing.goals.GoalTwoBlocks;
import baritone.utils.BlockStateInterface;
+import baritone.utils.Helper;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk;
@@ -42,7 +43,8 @@ import java.util.stream.Collectors;
*
* @author leijurv
*/
-public class MineBehavior extends Behavior {
+public class MineBehavior extends Behavior implements Helper {
+
public static final MineBehavior INSTANCE = new MineBehavior();
private MineBehavior() {
diff --git a/src/main/java/baritone/behavior/impl/PathingBehavior.java b/src/main/java/baritone/behavior/impl/PathingBehavior.java
index 531741fe..d29ecd10 100644
--- a/src/main/java/baritone/behavior/impl/PathingBehavior.java
+++ b/src/main/java/baritone/behavior/impl/PathingBehavior.java
@@ -22,7 +22,7 @@ import baritone.api.event.events.PathEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.TickEvent;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.calc.IPathFinder;
@@ -31,6 +31,7 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.IPath;
import baritone.pathing.path.PathExecutor;
import baritone.utils.BlockStateInterface;
+import baritone.utils.Helper;
import baritone.utils.PathRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
@@ -40,7 +41,7 @@ import java.awt.*;
import java.util.Collections;
import java.util.Optional;
-public final class PathingBehavior extends Behavior {
+public final class PathingBehavior extends Behavior implements Helper {
public static final PathingBehavior INSTANCE = new PathingBehavior();
diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java
index c681bc29..5d2c6558 100644
--- a/src/main/java/baritone/event/GameEventHandler.java
+++ b/src/main/java/baritone/event/GameEventHandler.java
@@ -25,7 +25,7 @@ import baritone.cache.WorldProvider;
import baritone.utils.BlockStateInterface;
import baritone.utils.Helper;
import baritone.utils.InputOverrideHandler;
-import baritone.utils.interfaces.Toggleable;
+import baritone.api.utils.interfaces.Toggleable;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.world.chunk.Chunk;
import org.lwjgl.input.Keyboard;
diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java
index 3abd11b5..54c72ec0 100644
--- a/src/main/java/baritone/utils/ExampleBaritoneControl.java
+++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java
@@ -20,7 +20,7 @@ package baritone.utils;
import baritone.Baritone;
import baritone.Settings;
import baritone.api.event.events.ChatEvent;
-import baritone.behavior.Behavior;
+import baritone.api.behavior.Behavior;
import baritone.behavior.impl.FollowBehavior;
import baritone.behavior.impl.MineBehavior;
import baritone.behavior.impl.PathingBehavior;
@@ -41,7 +41,8 @@ import net.minecraft.util.math.BlockPos;
import java.util.*;
-public class ExampleBaritoneControl extends Behavior {
+public class ExampleBaritoneControl extends Behavior implements Helper {
+
public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl();
private ExampleBaritoneControl() {