Move goals to api
This commit is contained in:
		| @@ -57,7 +57,6 @@ Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actu | ||||
| BaritoneAPI.getSettings().allowSprint.value = true; | ||||
| BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L; | ||||
|  | ||||
| // Note that at this moment in time the Goal implementations are not exposed in the API | ||||
| BaritoneAPI.getPathingBehavior().setGoal(new GoalXZ(10000, 20000)); | ||||
| BaritoneAPI.getPathingBehavior().path(); | ||||
| ``` | ||||
|   | ||||
| @@ -15,10 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.Baritone; | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.api.BaritoneAPI; | ||||
| 
 | ||||
| public class GoalAxis implements Goal { | ||||
| 
 | ||||
| @@ -26,7 +25,7 @@ public class GoalAxis implements Goal { | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean isInGoal(int x, int y, int z) { | ||||
|         return y == Baritone.settings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); | ||||
|         return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @@ -40,7 +39,7 @@ public class GoalAxis implements Goal { | ||||
| 
 | ||||
|         double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2)); | ||||
| 
 | ||||
|         return flatAxisDistance * Baritone.settings().costHeuristic.get() + GoalYLevel.calculate(Baritone.settings().axisHeight.get(), y); | ||||
|         return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @@ -15,10 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| /** | ||||
| @@ -15,9 +15,8 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| @@ -15,11 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.utils.pathing.BetterBlockPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| 
 | ||||
| @@ -42,7 +40,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { | ||||
| 
 | ||||
|     @Override | ||||
|     public BlockPos getGoalPos() { | ||||
|         return new BetterBlockPos(x, y, z); | ||||
|         return new BlockPos(x, y, z); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @@ -15,10 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| public class GoalNear implements Goal, IGoalRenderPos { | ||||
| @@ -15,9 +15,8 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| @@ -15,10 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| /** | ||||
| @@ -15,11 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.Baritone; | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.utils.Utils; | ||||
| import baritone.api.BaritoneAPI; | ||||
| import net.minecraft.util.math.MathHelper; | ||||
| import net.minecraft.util.math.Vec3d; | ||||
| 
 | ||||
| @@ -82,11 +80,11 @@ public class GoalXZ implements Goal { | ||||
|             diagonal = z; | ||||
|         } | ||||
|         diagonal *= SQRT_2; | ||||
|         return (diagonal + straight) * Baritone.settings().costHeuristic.get(); // big TODO tune | ||||
|         return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune | ||||
|     } | ||||
| 
 | ||||
|     public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) { | ||||
|         float theta = (float) Utils.degToRad(yaw); | ||||
|         float theta = (float) Math.toRadians(yaw); | ||||
|         double x = origin.x - MathHelper.sin(theta) * distance; | ||||
|         double z = origin.z + MathHelper.cos(theta) * distance; | ||||
|         return new GoalXZ((int) x, (int) z); | ||||
| @@ -15,10 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.goals; | ||||
| package baritone.api.pathing.goals; | ||||
| 
 | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; | ||||
| import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; | ||||
| 
 | ||||
| /** | ||||
|  * Useful for mining (getting to diamond / iron level) | ||||
| @@ -49,11 +48,11 @@ public class GoalYLevel implements Goal, ActionCostsButOnlyTheOnesThatMakeMickey | ||||
|     public static double calculate(int goalY, int currentY) { | ||||
|         if (currentY > goalY) { | ||||
|             // need to descend | ||||
|             return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); | ||||
|             return ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY); | ||||
|         } | ||||
|         if (currentY < goalY) { | ||||
|             // need to ascend | ||||
|             return (goalY - currentY) * JUMP_ONE_BLOCK_COST; | ||||
|             return (goalY - currentY) * ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.JUMP_ONE_BLOCK_COST; | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| @@ -15,7 +15,9 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.movement; | ||||
| package baritone.api.pathing.movement; | ||||
| 
 | ||||
| import baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside; | ||||
| 
 | ||||
| public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { | ||||
| 
 | ||||
| @@ -15,7 +15,7 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.pathing.movement; | ||||
| package baritone.api.pathing.movement; | ||||
| 
 | ||||
| public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside { | ||||
|     double[] FALL_N_BLOCKS_COST = generateFallNBlocksCost(); | ||||
| @@ -15,7 +15,7 @@ | ||||
|  * along with Baritone.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package baritone.utils.interfaces; | ||||
| package baritone.api.utils.interfaces; | ||||
| 
 | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| 
 | ||||
| @@ -20,8 +20,8 @@ package baritone.behavior; | ||||
| import baritone.Baritone; | ||||
| import baritone.api.behavior.IFollowBehavior; | ||||
| import baritone.api.event.events.TickEvent; | ||||
| import baritone.pathing.goals.GoalNear; | ||||
| import baritone.pathing.goals.GoalXZ; | ||||
| import baritone.api.pathing.goals.GoalNear; | ||||
| import baritone.api.pathing.goals.GoalXZ; | ||||
| import baritone.utils.Helper; | ||||
| import net.minecraft.entity.Entity; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
|   | ||||
| @@ -26,9 +26,9 @@ import baritone.cache.CachedChunk; | ||||
| import baritone.cache.ChunkPacker; | ||||
| import baritone.cache.WorldProvider; | ||||
| import baritone.cache.WorldScanner; | ||||
| import baritone.pathing.goals.GoalBlock; | ||||
| import baritone.pathing.goals.GoalComposite; | ||||
| import baritone.pathing.goals.GoalTwoBlocks; | ||||
| import baritone.api.pathing.goals.GoalBlock; | ||||
| import baritone.api.pathing.goals.GoalComposite; | ||||
| import baritone.api.pathing.goals.GoalTwoBlocks; | ||||
| import baritone.utils.BlockStateInterface; | ||||
| import baritone.utils.Helper; | ||||
| import net.minecraft.block.Block; | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import baritone.api.pathing.goals.Goal; | ||||
| import baritone.pathing.calc.AStarPathFinder; | ||||
| import baritone.pathing.calc.AbstractNodeCostSearch; | ||||
| import baritone.pathing.calc.IPathFinder; | ||||
| import baritone.pathing.goals.GoalXZ; | ||||
| import baritone.api.pathing.goals.GoalXZ; | ||||
| import baritone.pathing.movement.MovementHelper; | ||||
| import baritone.pathing.path.IPath; | ||||
| import baritone.pathing.path.PathExecutor; | ||||
| @@ -35,7 +35,7 @@ import baritone.utils.BlockBreakHelper; | ||||
| import baritone.utils.BlockStateInterface; | ||||
| import baritone.utils.Helper; | ||||
| import baritone.utils.PathRenderer; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.utils.pathing.BetterBlockPos; | ||||
| import net.minecraft.init.Blocks; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
|   | ||||
| @@ -20,7 +20,7 @@ package baritone.pathing.calc; | ||||
| import baritone.Baritone; | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.pathing.calc.openset.BinaryHeapOpenSet; | ||||
| import baritone.pathing.movement.ActionCosts; | ||||
| import baritone.api.pathing.movement.ActionCosts; | ||||
| import baritone.pathing.movement.CalculationContext; | ||||
| import baritone.pathing.movement.Moves; | ||||
| import baritone.pathing.path.IPath; | ||||
|   | ||||
| @@ -18,7 +18,7 @@ | ||||
| package baritone.pathing.calc; | ||||
|  | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.pathing.movement.ActionCosts; | ||||
| import baritone.api.pathing.movement.ActionCosts; | ||||
|  | ||||
| /** | ||||
|  * A node in the path, containing the cost and steps to get to it. | ||||
|   | ||||
| @@ -18,6 +18,7 @@ | ||||
| package baritone.pathing.movement; | ||||
|  | ||||
| import baritone.Baritone; | ||||
| import baritone.api.pathing.movement.ActionCosts; | ||||
| import baritone.api.utils.Rotation; | ||||
| import baritone.behavior.LookBehaviorUtils; | ||||
| import baritone.pathing.movement.MovementState.MovementTarget; | ||||
|   | ||||
| @@ -19,6 +19,7 @@ package baritone.pathing.path; | ||||
|  | ||||
| import baritone.Baritone; | ||||
| import baritone.api.event.events.TickEvent; | ||||
| import baritone.api.pathing.movement.ActionCosts; | ||||
| import baritone.pathing.movement.*; | ||||
| import baritone.pathing.movement.movements.*; | ||||
| import baritone.utils.BlockStateInterface; | ||||
|   | ||||
| @@ -21,7 +21,8 @@ import baritone.Baritone; | ||||
| import baritone.api.Settings; | ||||
| import baritone.api.cache.IWaypoint; | ||||
| import baritone.api.event.events.ChatEvent; | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.api.pathing.goals.*; | ||||
| import baritone.api.pathing.movement.ActionCosts; | ||||
| import baritone.behavior.Behavior; | ||||
| import baritone.behavior.FollowBehavior; | ||||
| import baritone.behavior.MineBehavior; | ||||
| @@ -30,7 +31,6 @@ import baritone.cache.ChunkPacker; | ||||
| import baritone.cache.Waypoint; | ||||
| import baritone.cache.WorldProvider; | ||||
| import baritone.pathing.calc.AbstractNodeCostSearch; | ||||
| import baritone.pathing.goals.*; | ||||
| import baritone.pathing.movement.*; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.client.multiplayer.ChunkProviderClient; | ||||
|   | ||||
| @@ -19,11 +19,11 @@ package baritone.utils; | ||||
|  | ||||
| import baritone.Baritone; | ||||
| import baritone.api.pathing.goals.Goal; | ||||
| import baritone.pathing.goals.GoalComposite; | ||||
| import baritone.pathing.goals.GoalTwoBlocks; | ||||
| import baritone.pathing.goals.GoalXZ; | ||||
| import baritone.api.pathing.goals.GoalComposite; | ||||
| import baritone.api.pathing.goals.GoalTwoBlocks; | ||||
| import baritone.api.pathing.goals.GoalXZ; | ||||
| import baritone.pathing.path.IPath; | ||||
| import baritone.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.api.utils.interfaces.IGoalRenderPos; | ||||
| import baritone.utils.pathing.BetterBlockPos; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.client.Minecraft; | ||||
|   | ||||
| @@ -17,7 +17,7 @@ | ||||
|  | ||||
| package baritone.utils.pathing; | ||||
|  | ||||
| import static baritone.pathing.movement.ActionCosts.COST_INF; | ||||
| import static baritone.api.pathing.movement.ActionCosts.COST_INF; | ||||
|  | ||||
| /** | ||||
|  * The result of a calculated movement, with destination x, y, z, and the cost of performing the movement | ||||
|   | ||||
| @@ -17,6 +17,7 @@ | ||||
|  | ||||
| package baritone.pathing.goals; | ||||
|  | ||||
| import baritone.api.pathing.goals.GoalGetToBlock; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import org.junit.Test; | ||||
|  | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package baritone.pathing.movement; | ||||
|  | ||||
| import org.junit.Test; | ||||
|  | ||||
| import static baritone.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*; | ||||
| import static baritone.api.pathing.movement.ActionCostsButOnlyTheOnesThatMakeMickeyDieInside.*; | ||||
| import static org.junit.Assert.assertEquals; | ||||
|  | ||||
| public class ActionCostsButOnlyTheOnesThatMakeMickeyDieInsideTest { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user