IMovement
Hey would you look at that
This commit is contained in:
		| @@ -18,6 +18,7 @@ | |||||||
| package baritone.pathing.calc; | package baritone.pathing.calc; | ||||||
|  |  | ||||||
| import baritone.api.pathing.goals.Goal; | import baritone.api.pathing.goals.Goal; | ||||||
|  | import baritone.pathing.movement.IMovement; | ||||||
| import baritone.pathing.movement.Movement; | import baritone.pathing.movement.Movement; | ||||||
| import baritone.pathing.movement.Moves; | import baritone.pathing.movement.Moves; | ||||||
| import baritone.pathing.path.IPath; | import baritone.pathing.path.IPath; | ||||||
| @@ -161,7 +162,7 @@ class Path implements IPath { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<Movement> movements() { |     public List<IMovement> movements() { | ||||||
|         if (!verified) { |         if (!verified) { | ||||||
|             throw new IllegalStateException(); |             throw new IllegalStateException(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ | |||||||
|  |  | ||||||
| package baritone.pathing.movement; | package baritone.pathing.movement; | ||||||
|  |  | ||||||
| import baritone.Baritone; | import baritone.api.BaritoneAPI; | ||||||
| import baritone.api.pathing.movement.ActionCosts; | import baritone.api.pathing.movement.ActionCosts; | ||||||
| import baritone.utils.Helper; | import baritone.utils.Helper; | ||||||
| import baritone.utils.ToolSet; | import baritone.utils.ToolSet; | ||||||
| @@ -51,20 +51,20 @@ public class CalculationContext implements Helper { | |||||||
|  |  | ||||||
|     public CalculationContext(ToolSet toolSet) { |     public CalculationContext(ToolSet toolSet) { | ||||||
|         this.toolSet = toolSet; |         this.toolSet = toolSet; | ||||||
|         this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(false); |         this.hasThrowaway = BaritoneAPI.getSettings().allowPlace.get() && MovementHelper.throwaway(false); | ||||||
|         this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether(); |         this.hasWaterBucket = BaritoneAPI.getSettings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether(); | ||||||
|         this.canSprint = Baritone.settings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6; |         this.canSprint = BaritoneAPI.getSettings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6; | ||||||
|         this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get(); |         this.placeBlockCost = BaritoneAPI.getSettings().blockPlacementPenalty.get(); | ||||||
|         this.allowBreak = Baritone.settings().allowBreak.get(); |         this.allowBreak = BaritoneAPI.getSettings().allowBreak.get(); | ||||||
|         this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get(); |         this.maxFallHeightNoWater = BaritoneAPI.getSettings().maxFallHeightNoWater.get(); | ||||||
|         this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get(); |         this.maxFallHeightBucket = BaritoneAPI.getSettings().maxFallHeightBucket.get(); | ||||||
|         int depth = EnchantmentHelper.getDepthStriderModifier(player()); |         int depth = EnchantmentHelper.getDepthStriderModifier(player()); | ||||||
|         if (depth > 3) { |         if (depth > 3) { | ||||||
|             depth = 3; |             depth = 3; | ||||||
|         } |         } | ||||||
|         float mult = depth / 3.0F; |         float mult = depth / 3.0F; | ||||||
|         this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; |         this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; | ||||||
|         this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); |         this.breakBlockAdditionalCost = BaritoneAPI.getSettings().blockBreakAdditionalPenalty.get(); | ||||||
|         // why cache these things here, why not let the movements just get directly from settings? |         // why cache these things here, why not let the movements just get directly from settings? | ||||||
|         // because if some movements are calculated one way and others are calculated another way, |         // because if some movements are calculated one way and others are calculated another way, | ||||||
|         // then you get a wildly inconsistent path that isn't optimal for either scenario. |         // then you get a wildly inconsistent path that isn't optimal for either scenario. | ||||||
|   | |||||||
							
								
								
									
										67
									
								
								src/main/java/baritone/pathing/movement/IMovement.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/main/java/baritone/pathing/movement/IMovement.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | |||||||
|  | /* | ||||||
|  |  * 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 <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package baritone.pathing.movement; | ||||||
|  |  | ||||||
|  | import baritone.utils.pathing.BetterBlockPos; | ||||||
|  | import net.minecraft.util.math.BlockPos; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author Brady | ||||||
|  |  * @since 10/8/2018 | ||||||
|  |  */ | ||||||
|  | public interface IMovement { | ||||||
|  |  | ||||||
|  |     double getCost(); | ||||||
|  |  | ||||||
|  |     MovementStatus update(); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Resets the current state status to {@link MovementStatus#PREPPING} | ||||||
|  |      */ | ||||||
|  |     void reset(); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Resets the cache for special break, place, and walk into blocks | ||||||
|  |      */ | ||||||
|  |     void resetBlockCache(); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @return Whether or not it is safe to cancel the current movement state | ||||||
|  |      */ | ||||||
|  |     boolean safeToCancel(); | ||||||
|  |  | ||||||
|  |     double recalculateCost(); | ||||||
|  |  | ||||||
|  |     double calculateCostWithoutCaching(); | ||||||
|  |  | ||||||
|  |     boolean calculatedWhileLoaded(); | ||||||
|  |  | ||||||
|  |     BetterBlockPos getSrc(); | ||||||
|  |  | ||||||
|  |     BetterBlockPos getDest(); | ||||||
|  |  | ||||||
|  |     BlockPos getDirection(); | ||||||
|  |  | ||||||
|  |     List<BlockPos> toBreak(); | ||||||
|  |  | ||||||
|  |     List<BlockPos> toPlace(); | ||||||
|  |  | ||||||
|  |     List<BlockPos> toWalkInto(); | ||||||
|  | } | ||||||
| @@ -21,7 +21,6 @@ import baritone.Baritone; | |||||||
| import baritone.api.utils.Rotation; | import baritone.api.utils.Rotation; | ||||||
| import baritone.behavior.LookBehavior; | import baritone.behavior.LookBehavior; | ||||||
| import baritone.behavior.LookBehaviorUtils; | import baritone.behavior.LookBehaviorUtils; | ||||||
| import baritone.pathing.movement.MovementState.MovementStatus; |  | ||||||
| import baritone.utils.*; | import baritone.utils.*; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| import net.minecraft.block.BlockLiquid; | import net.minecraft.block.BlockLiquid; | ||||||
| @@ -36,7 +35,7 @@ import java.util.Optional; | |||||||
|  |  | ||||||
| import static baritone.utils.InputOverrideHandler.Input; | import static baritone.utils.InputOverrideHandler.Input; | ||||||
|  |  | ||||||
| public abstract class Movement implements Helper, MovementHelper { | public abstract class Movement implements IMovement, Helper, MovementHelper { | ||||||
|  |  | ||||||
|     protected static final EnumFacing[] HORIZONTALS = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST}; |     protected static final EnumFacing[] HORIZONTALS = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST}; | ||||||
|  |  | ||||||
| @@ -64,7 +63,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|     public List<BlockPos> toPlaceCached = null; |     public List<BlockPos> toPlaceCached = null; | ||||||
|     public List<BlockPos> toWalkIntoCached = null; |     public List<BlockPos> toWalkIntoCached = null; | ||||||
|  |  | ||||||
|     private Boolean calculatedWhileLoaded; |     private boolean calculatedWhileLoaded; | ||||||
|  |  | ||||||
|     protected Movement(BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) { |     protected Movement(BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) { | ||||||
|         this.src = src; |         this.src = src; | ||||||
| @@ -77,24 +76,27 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         this(src, dest, toBreak, null); |         this(src, dest, toBreak, null); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public double getCost(CalculationContext context) { |     @Override | ||||||
|  |     public double getCost() { | ||||||
|         if (cost == null) { |         if (cost == null) { | ||||||
|             cost = calculateCost(context != null ? context : new CalculationContext()); |             cost = calculateCost(new CalculationContext()); | ||||||
|         } |         } | ||||||
|         return cost; |         return cost; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected abstract double calculateCost(CalculationContext context); |     protected abstract double calculateCost(CalculationContext context); | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public double recalculateCost() { |     public double recalculateCost() { | ||||||
|         cost = null; |         cost = null; | ||||||
|         return getCost(null); |         return getCost(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void override(double cost) { |     protected void override(double cost) { | ||||||
|         this.cost = cost; |         this.cost = cost; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public double calculateCostWithoutCaching() { |     public double calculateCostWithoutCaching() { | ||||||
|         return calculateCost(new CalculationContext()); |         return calculateCost(new CalculationContext()); | ||||||
|     } |     } | ||||||
| @@ -105,6 +107,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|      * |      * | ||||||
|      * @return Status |      * @return Status | ||||||
|      */ |      */ | ||||||
|  |     @Override | ||||||
|     public MovementStatus update() { |     public MovementStatus update() { | ||||||
|         player().capabilities.allowFlying = false; |         player().capabilities.allowFlying = false; | ||||||
|         MovementState latestState = updateState(currentState); |         MovementState latestState = updateState(currentState); | ||||||
| @@ -187,6 +190,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public boolean safeToCancel() { |     public boolean safeToCancel() { | ||||||
|         return safeToCancel(currentState); |         return safeToCancel(currentState); | ||||||
|     } |     } | ||||||
| @@ -201,10 +205,12 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|                 && currentState.getStatus() != MovementStatus.WAITING); |                 && currentState.getStatus() != MovementStatus.WAITING); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public BetterBlockPos getSrc() { |     public BetterBlockPos getSrc() { | ||||||
|         return src; |         return src; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public BetterBlockPos getDest() { |     public BetterBlockPos getDest() { | ||||||
|         return dest; |         return dest; | ||||||
|     } |     } | ||||||
| @@ -223,6 +229,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         currentState.setStatus(MovementStatus.CANCELED); |         currentState.setStatus(MovementStatus.CANCELED); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public void reset() { |     public void reset() { | ||||||
|         currentState = new MovementState().setStatus(MovementStatus.PREPPING); |         currentState = new MovementState().setStatus(MovementStatus.PREPPING); | ||||||
|     } |     } | ||||||
| @@ -247,6 +254,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         return state; |         return state; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public BlockPos getDirection() { |     public BlockPos getDirection() { | ||||||
|         return getDest().subtract(getSrc()); |         return getDest().subtract(getSrc()); | ||||||
|     } |     } | ||||||
| @@ -255,10 +263,19 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk); |         calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public boolean calculatedWhileLoaded() { |     public boolean calculatedWhileLoaded() { | ||||||
|         return calculatedWhileLoaded; |         return calculatedWhileLoaded; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void resetBlockCache() { | ||||||
|  |         toBreakCached = null; | ||||||
|  |         toPlaceCached = null; | ||||||
|  |         toWalkIntoCached = null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public List<BlockPos> toBreak() { |     public List<BlockPos> toBreak() { | ||||||
|         if (toBreakCached != null) { |         if (toBreakCached != null) { | ||||||
|             return toBreakCached; |             return toBreakCached; | ||||||
| @@ -273,6 +290,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public List<BlockPos> toPlace() { |     public List<BlockPos> toPlace() { | ||||||
|         if (toPlaceCached != null) { |         if (toPlaceCached != null) { | ||||||
|             return toPlaceCached; |             return toPlaceCached; | ||||||
| @@ -285,6 +303,7 @@ public abstract class Movement implements Helper, MovementHelper { | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|     public List<BlockPos> toWalkInto() { // overridden by movementdiagonal |     public List<BlockPos> toWalkInto() { // overridden by movementdiagonal | ||||||
|         if (toWalkIntoCached == null) { |         if (toWalkIntoCached == null) { | ||||||
|             toWalkIntoCached = new ArrayList<>(); |             toWalkIntoCached = new ArrayList<>(); | ||||||
|   | |||||||
| @@ -72,10 +72,6 @@ public class MovementState { | |||||||
|         return this.inputState; |         return this.inputState; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public enum MovementStatus { |  | ||||||
|         PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED, CANCELED |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static class MovementTarget { |     public static class MovementTarget { | ||||||
|  |  | ||||||
|         /** |         /** | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								src/main/java/baritone/pathing/movement/MovementStatus.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/main/java/baritone/pathing/movement/MovementStatus.java
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package baritone.pathing.movement; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author Brady | ||||||
|  |  * @since 10/8/2018 | ||||||
|  |  */ | ||||||
|  | public enum MovementStatus { | ||||||
|  |  | ||||||
|  |     PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED, CANCELED | ||||||
|  | } | ||||||
| @@ -19,11 +19,7 @@ package baritone.pathing.movement.movements; | |||||||
|  |  | ||||||
| import baritone.Baritone; | import baritone.Baritone; | ||||||
| import baritone.behavior.LookBehaviorUtils; | import baritone.behavior.LookBehaviorUtils; | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.pathing.movement.MovementState.MovementStatus; |  | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
| import baritone.utils.Utils; | import baritone.utils.Utils; | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import baritone.pathing.movement.CalculationContext; | |||||||
| import baritone.pathing.movement.Movement; | import baritone.pathing.movement.Movement; | ||||||
| import baritone.pathing.movement.MovementHelper; | import baritone.pathing.movement.MovementHelper; | ||||||
| import baritone.pathing.movement.MovementState; | import baritone.pathing.movement.MovementState; | ||||||
| import baritone.pathing.movement.MovementState.MovementStatus; | import baritone.pathing.movement.MovementStatus; | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
|   | |||||||
| @@ -17,10 +17,7 @@ | |||||||
|  |  | ||||||
| package baritone.pathing.movement.movements; | package baritone.pathing.movement.movements; | ||||||
|  |  | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| @@ -140,12 +137,12 @@ public class MovementDiagonal extends Movement { | |||||||
|     @Override |     @Override | ||||||
|     public MovementState updateState(MovementState state) { |     public MovementState updateState(MovementState state) { | ||||||
|         super.updateState(state); |         super.updateState(state); | ||||||
|         if (state.getStatus() != MovementState.MovementStatus.RUNNING) { |         if (state.getStatus() != MovementStatus.RUNNING) { | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (playerFeet().equals(dest)) { |         if (playerFeet().equals(dest)) { | ||||||
|             state.setStatus(MovementState.MovementStatus.SUCCESS); |             state.setStatus(MovementStatus.SUCCESS); | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
|         if (!BlockStateInterface.isLiquid(playerFeet())) { |         if (!BlockStateInterface.isLiquid(playerFeet())) { | ||||||
|   | |||||||
| @@ -17,10 +17,7 @@ | |||||||
|  |  | ||||||
| package baritone.pathing.movement.movements; | package baritone.pathing.movement.movements; | ||||||
|  |  | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| @@ -64,12 +61,12 @@ public class MovementDownward extends Movement { | |||||||
|     @Override |     @Override | ||||||
|     public MovementState updateState(MovementState state) { |     public MovementState updateState(MovementState state) { | ||||||
|         super.updateState(state); |         super.updateState(state); | ||||||
|         if (state.getStatus() != MovementState.MovementStatus.RUNNING) { |         if (state.getStatus() != MovementStatus.RUNNING) { | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (playerFeet().equals(dest)) { |         if (playerFeet().equals(dest)) { | ||||||
|             return state.setStatus(MovementState.MovementStatus.SUCCESS); |             return state.setStatus(MovementStatus.SUCCESS); | ||||||
|         } |         } | ||||||
|         double diffX = player().posX - (dest.getX() + 0.5); |         double diffX = player().posX - (dest.getX() + 0.5); | ||||||
|         double diffZ = player().posZ - (dest.getZ() + 0.5); |         double diffZ = player().posZ - (dest.getZ() + 0.5); | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ import baritone.pathing.movement.CalculationContext; | |||||||
| import baritone.pathing.movement.Movement; | import baritone.pathing.movement.Movement; | ||||||
| import baritone.pathing.movement.MovementHelper; | import baritone.pathing.movement.MovementHelper; | ||||||
| import baritone.pathing.movement.MovementState; | import baritone.pathing.movement.MovementState; | ||||||
| import baritone.pathing.movement.MovementState.MovementStatus; | import baritone.pathing.movement.MovementStatus; | ||||||
| import baritone.pathing.movement.MovementState.MovementTarget; | import baritone.pathing.movement.MovementState.MovementTarget; | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
|   | |||||||
| @@ -20,10 +20,7 @@ package baritone.pathing.movement.movements; | |||||||
| import baritone.Baritone; | import baritone.Baritone; | ||||||
| import baritone.api.utils.Rotation; | import baritone.api.utils.Rotation; | ||||||
| import baritone.behavior.LookBehaviorUtils; | import baritone.behavior.LookBehaviorUtils; | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.utils.*; | import baritone.utils.*; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| import baritone.utils.pathing.MutableMoveResult; | import baritone.utils.pathing.MutableMoveResult; | ||||||
| @@ -168,13 +165,13 @@ public class MovementParkour extends Movement { | |||||||
|         // once this movement is instantiated, the state is default to PREPPING |         // once this movement is instantiated, the state is default to PREPPING | ||||||
|         // but once it's ticked for the first time it changes to RUNNING |         // but once it's ticked for the first time it changes to RUNNING | ||||||
|         // since we don't really know anything about momentum, it suffices to say Parkour can only be canceled on the 0th tick |         // since we don't really know anything about momentum, it suffices to say Parkour can only be canceled on the 0th tick | ||||||
|         return state.getStatus() != MovementState.MovementStatus.RUNNING; |         return state.getStatus() != MovementStatus.RUNNING; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public MovementState updateState(MovementState state) { |     public MovementState updateState(MovementState state) { | ||||||
|         super.updateState(state); |         super.updateState(state); | ||||||
|         if (state.getStatus() != MovementState.MovementStatus.RUNNING) { |         if (state.getStatus() != MovementStatus.RUNNING) { | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
|         if (dist >= 4) { |         if (dist >= 4) { | ||||||
| @@ -186,10 +183,10 @@ public class MovementParkour extends Movement { | |||||||
|             if (d == Blocks.VINE || d == Blocks.LADDER) { |             if (d == Blocks.VINE || d == Blocks.LADDER) { | ||||||
|                 // it physically hurt me to add support for parkour jumping onto a vine |                 // it physically hurt me to add support for parkour jumping onto a vine | ||||||
|                 // but i did it anyway |                 // but i did it anyway | ||||||
|                 return state.setStatus(MovementState.MovementStatus.SUCCESS); |                 return state.setStatus(MovementStatus.SUCCESS); | ||||||
|             } |             } | ||||||
|             if (player().posY - playerFeet().getY() < 0.094) { // lilypads |             if (player().posY - playerFeet().getY() < 0.094) { // lilypads | ||||||
|                 state.setStatus(MovementState.MovementStatus.SUCCESS); |                 state.setStatus(MovementStatus.SUCCESS); | ||||||
|             } |             } | ||||||
|         } else if (!playerFeet().equals(src)) { |         } else if (!playerFeet().equals(src)) { | ||||||
|             if (playerFeet().equals(src.offset(direction)) || player().posY - playerFeet().getY() > 0.0001) { |             if (playerFeet().equals(src.offset(direction)) || player().posY - playerFeet().getY() > 0.0001) { | ||||||
| @@ -203,7 +200,7 @@ public class MovementParkour extends Movement { | |||||||
|                         } |                         } | ||||||
|                         if (MovementHelper.canPlaceAgainst(against1)) { |                         if (MovementHelper.canPlaceAgainst(against1)) { | ||||||
|                             if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block |                             if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block | ||||||
|                                 return state.setStatus(MovementState.MovementStatus.UNREACHABLE); |                                 return state.setStatus(MovementStatus.UNREACHABLE); | ||||||
|                             } |                             } | ||||||
|                             double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D; |                             double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D; | ||||||
|                             double faceY = (dest.getY() + against1.getY()) * 0.5D; |                             double faceY = (dest.getY() + against1.getY()) * 0.5D; | ||||||
|   | |||||||
| @@ -18,10 +18,7 @@ | |||||||
| package baritone.pathing.movement.movements; | package baritone.pathing.movement.movements; | ||||||
|  |  | ||||||
| import baritone.api.utils.Rotation; | import baritone.api.utils.Rotation; | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
| import baritone.utils.Utils; | import baritone.utils.Utils; | ||||||
| @@ -148,7 +145,7 @@ public class MovementPillar extends Movement { | |||||||
|     @Override |     @Override | ||||||
|     public MovementState updateState(MovementState state) { |     public MovementState updateState(MovementState state) { | ||||||
|         super.updateState(state); |         super.updateState(state); | ||||||
|         if (state.getStatus() != MovementState.MovementStatus.RUNNING) { |         if (state.getStatus() != MovementStatus.RUNNING) { | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -161,7 +158,7 @@ public class MovementPillar extends Movement { | |||||||
|                 state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); |                 state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); | ||||||
|             } |             } | ||||||
|             if (playerFeet().equals(dest)) { |             if (playerFeet().equals(dest)) { | ||||||
|                 return state.setStatus(MovementState.MovementStatus.SUCCESS); |                 return state.setStatus(MovementStatus.SUCCESS); | ||||||
|             } |             } | ||||||
|             return state; |             return state; | ||||||
|         } |         } | ||||||
| @@ -178,11 +175,11 @@ public class MovementPillar extends Movement { | |||||||
|             BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite()); |             BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite()); | ||||||
|             if (against == null) { |             if (against == null) { | ||||||
|                 logDebug("Unable to climb vines"); |                 logDebug("Unable to climb vines"); | ||||||
|                 return state.setStatus(MovementState.MovementStatus.UNREACHABLE); |                 return state.setStatus(MovementStatus.UNREACHABLE); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) { |             if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) { | ||||||
|                 return state.setStatus(MovementState.MovementStatus.SUCCESS); |                 return state.setStatus(MovementStatus.SUCCESS); | ||||||
|             } |             } | ||||||
|             if (MovementHelper.isBottomSlab(src.down())) { |             if (MovementHelper.isBottomSlab(src.down())) { | ||||||
|                 state.setInput(InputOverrideHandler.Input.JUMP, true); |                 state.setInput(InputOverrideHandler.Input.JUMP, true); | ||||||
| @@ -198,7 +195,7 @@ public class MovementPillar extends Movement { | |||||||
|         } else { |         } else { | ||||||
|             // Get ready to place a throwaway block |             // Get ready to place a throwaway block | ||||||
|             if (!MovementHelper.throwaway(true)) { |             if (!MovementHelper.throwaway(true)) { | ||||||
|                 return state.setStatus(MovementState.MovementStatus.UNREACHABLE); |                 return state.setStatus(MovementStatus.UNREACHABLE); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             numTicks++; |             numTicks++; | ||||||
| @@ -233,7 +230,7 @@ public class MovementPillar extends Movement { | |||||||
|  |  | ||||||
|         // If we are at our goal and the block below us is placed |         // If we are at our goal and the block below us is placed | ||||||
|         if (playerFeet().equals(dest) && blockIsThere) { |         if (playerFeet().equals(dest) && blockIsThere) { | ||||||
|             return state.setStatus(MovementState.MovementStatus.SUCCESS); |             return state.setStatus(MovementStatus.SUCCESS); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return state; |         return state; | ||||||
|   | |||||||
| @@ -20,10 +20,7 @@ package baritone.pathing.movement.movements; | |||||||
| import baritone.Baritone; | import baritone.Baritone; | ||||||
| import baritone.api.utils.Rotation; | import baritone.api.utils.Rotation; | ||||||
| import baritone.behavior.LookBehaviorUtils; | import baritone.behavior.LookBehaviorUtils; | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.utils.BlockStateInterface; | import baritone.utils.BlockStateInterface; | ||||||
| import baritone.utils.InputOverrideHandler; | import baritone.utils.InputOverrideHandler; | ||||||
| import baritone.utils.Utils; | import baritone.utils.Utils; | ||||||
| @@ -144,13 +141,13 @@ public class MovementTraverse extends Movement { | |||||||
|     @Override |     @Override | ||||||
|     public MovementState updateState(MovementState state) { |     public MovementState updateState(MovementState state) { | ||||||
|         super.updateState(state); |         super.updateState(state); | ||||||
|         if (state.getStatus() != MovementState.MovementStatus.RUNNING) { |         if (state.getStatus() != MovementStatus.RUNNING) { | ||||||
|             // if the setting is enabled |             // if the setting is enabled | ||||||
|             if (!Baritone.settings().walkWhileBreaking.get()) { |             if (!Baritone.settings().walkWhileBreaking.get()) { | ||||||
|                 return state; |                 return state; | ||||||
|             } |             } | ||||||
|             // and if we're prepping (aka mining the block in front) |             // and if we're prepping (aka mining the block in front) | ||||||
|             if (state.getStatus() != MovementState.MovementStatus.PREPPING) { |             if (state.getStatus() != MovementStatus.PREPPING) { | ||||||
|                 return state; |                 return state; | ||||||
|             } |             } | ||||||
|             // and if it's fine to walk into the blocks in front |             // and if it's fine to walk into the blocks in front | ||||||
| @@ -225,7 +222,7 @@ public class MovementTraverse extends Movement { | |||||||
|  |  | ||||||
|         if (isTheBridgeBlockThere) { |         if (isTheBridgeBlockThere) { | ||||||
|             if (playerFeet().equals(dest)) { |             if (playerFeet().equals(dest)) { | ||||||
|                 return state.setStatus(MovementState.MovementStatus.SUCCESS); |                 return state.setStatus(MovementStatus.SUCCESS); | ||||||
|             } |             } | ||||||
|             if (wasTheBridgeBlockAlwaysThere && !BlockStateInterface.isLiquid(playerFeet())) { |             if (wasTheBridgeBlockAlwaysThere && !BlockStateInterface.isLiquid(playerFeet())) { | ||||||
|                 state.setInput(InputOverrideHandler.Input.SPRINT, true); |                 state.setInput(InputOverrideHandler.Input.SPRINT, true); | ||||||
| @@ -248,7 +245,7 @@ public class MovementTraverse extends Movement { | |||||||
|                 if (MovementHelper.canPlaceAgainst(against1)) { |                 if (MovementHelper.canPlaceAgainst(against1)) { | ||||||
|                     if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block |                     if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block | ||||||
|                         logDebug("bb pls get me some blocks. dirt or cobble"); |                         logDebug("bb pls get me some blocks. dirt or cobble"); | ||||||
|                         return state.setStatus(MovementState.MovementStatus.UNREACHABLE); |                         return state.setStatus(MovementStatus.UNREACHABLE); | ||||||
|                     } |                     } | ||||||
|                     if (!Baritone.settings().assumeSafeWalk.get()) { |                     if (!Baritone.settings().assumeSafeWalk.get()) { | ||||||
|                         state.setInput(InputOverrideHandler.Input.SNEAK, true); |                         state.setInput(InputOverrideHandler.Input.SNEAK, true); | ||||||
| @@ -287,7 +284,7 @@ public class MovementTraverse extends Movement { | |||||||
|                 // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); |                 // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); | ||||||
|                 if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block |                 if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block | ||||||
|                     logDebug("bb pls get me some blocks. dirt or cobble"); |                     logDebug("bb pls get me some blocks. dirt or cobble"); | ||||||
|                     return state.setStatus(MovementState.MovementStatus.UNREACHABLE); |                     return state.setStatus(MovementStatus.UNREACHABLE); | ||||||
|                 } |                 } | ||||||
|                 double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D; |                 double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D; | ||||||
|                 double faceY = (dest.getY() + src.getY() - 1.0D) * 0.5D; |                 double faceY = (dest.getY() + src.getY() - 1.0D) * 0.5D; | ||||||
| @@ -324,7 +321,7 @@ public class MovementTraverse extends Movement { | |||||||
|         // if we're in the process of breaking blocks before walking forwards |         // if we're in the process of breaking blocks before walking forwards | ||||||
|         // or if this isn't a sneak place (the block is already there) |         // or if this isn't a sneak place (the block is already there) | ||||||
|         // then it's safe to cancel this |         // then it's safe to cancel this | ||||||
|         return state.getStatus() != MovementState.MovementStatus.RUNNING || MovementHelper.canWalkOn(dest.down()); |         return state.getStatus() != MovementStatus.RUNNING || MovementHelper.canWalkOn(dest.down()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ | |||||||
| package baritone.pathing.path; | package baritone.pathing.path; | ||||||
|  |  | ||||||
| import baritone.api.pathing.goals.Goal; | import baritone.api.pathing.goals.Goal; | ||||||
| import baritone.pathing.movement.Movement; | import baritone.pathing.movement.IMovement; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
|  |  | ||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| @@ -28,7 +28,7 @@ public class CutoffPath implements IPath { | |||||||
|  |  | ||||||
|     private final List<BetterBlockPos> path; |     private final List<BetterBlockPos> path; | ||||||
|  |  | ||||||
|     private final List<Movement> movements; |     private final List<IMovement> movements; | ||||||
|  |  | ||||||
|     private final int numNodes; |     private final int numNodes; | ||||||
|  |  | ||||||
| @@ -47,7 +47,7 @@ public class CutoffPath implements IPath { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<Movement> movements() { |     public List<IMovement> movements() { | ||||||
|         return Collections.unmodifiableList(movements); |         return Collections.unmodifiableList(movements); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package baritone.pathing.path; | |||||||
|  |  | ||||||
| import baritone.api.BaritoneAPI; | import baritone.api.BaritoneAPI; | ||||||
| import baritone.api.pathing.goals.Goal; | import baritone.api.pathing.goals.Goal; | ||||||
| import baritone.pathing.movement.Movement; | import baritone.pathing.movement.IMovement; | ||||||
| import baritone.utils.Utils; | import baritone.utils.Utils; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||||||
| @@ -40,7 +40,7 @@ public interface IPath { | |||||||
|      * movements.get(i).getDest() should equal positions.get(i+1) |      * movements.get(i).getDest() should equal positions.get(i+1) | ||||||
|      * movements.size() should equal positions.size()-1 |      * movements.size() should equal positions.size()-1 | ||||||
|      */ |      */ | ||||||
|     List<Movement> movements(); |     List<IMovement> movements(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * All positions along the way. |      * All positions along the way. | ||||||
| @@ -86,7 +86,7 @@ public interface IPath { | |||||||
|     /** |     /** | ||||||
|      * Where does this path start |      * Where does this path start | ||||||
|      */ |      */ | ||||||
|     default BlockPos getSrc() { |     default BetterBlockPos getSrc() { | ||||||
|         return positions().get(0); |         return positions().get(0); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -102,7 +102,7 @@ public interface IPath { | |||||||
|         double sum = 0; |         double sum = 0; | ||||||
|         //this is fast because we aren't requesting recalculation, it's just cached |         //this is fast because we aren't requesting recalculation, it's just cached | ||||||
|         for (int i = pathPosition; i < movements().size(); i++) { |         for (int i = pathPosition; i < movements().size(); i++) { | ||||||
|             sum += movements().get(i).getCost(null); |             sum += movements().get(i).getCost(); | ||||||
|         } |         } | ||||||
|         return sum; |         return sum; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -21,10 +21,7 @@ import baritone.Baritone; | |||||||
| import baritone.api.event.events.TickEvent; | import baritone.api.event.events.TickEvent; | ||||||
| import baritone.api.pathing.movement.ActionCosts; | import baritone.api.pathing.movement.ActionCosts; | ||||||
| import baritone.pathing.calc.AbstractNodeCostSearch; | import baritone.pathing.calc.AbstractNodeCostSearch; | ||||||
| import baritone.pathing.movement.CalculationContext; | import baritone.pathing.movement.*; | ||||||
| import baritone.pathing.movement.Movement; |  | ||||||
| import baritone.pathing.movement.MovementHelper; |  | ||||||
| import baritone.pathing.movement.MovementState; |  | ||||||
| import baritone.pathing.movement.movements.*; | import baritone.pathing.movement.movements.*; | ||||||
| import baritone.utils.*; | import baritone.utils.*; | ||||||
| import baritone.utils.pathing.BetterBlockPos; | import baritone.utils.pathing.BetterBlockPos; | ||||||
| @@ -34,7 +31,7 @@ import net.minecraft.util.math.BlockPos; | |||||||
|  |  | ||||||
| import java.util.*; | import java.util.*; | ||||||
|  |  | ||||||
| import static baritone.pathing.movement.MovementState.MovementStatus.*; | import static baritone.pathing.movement.MovementStatus.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Behavior to execute a precomputed path. Does not (yet) deal with path segmentation or stitching |  * Behavior to execute a precomputed path. Does not (yet) deal with path segmentation or stitching | ||||||
| @@ -182,13 +179,11 @@ public class PathExecutor implements Helper { | |||||||
|             if (i < 0 || i >= path.movements().size()) { |             if (i < 0 || i >= path.movements().size()) { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             Movement m = path.movements().get(i); |             IMovement m = path.movements().get(i); | ||||||
|             HashSet<BlockPos> prevBreak = new HashSet<>(m.toBreak()); |             HashSet<BlockPos> prevBreak = new HashSet<>(m.toBreak()); | ||||||
|             HashSet<BlockPos> prevPlace = new HashSet<>(m.toPlace()); |             HashSet<BlockPos> prevPlace = new HashSet<>(m.toPlace()); | ||||||
|             HashSet<BlockPos> prevWalkInto = new HashSet<>(m.toWalkInto()); |             HashSet<BlockPos> prevWalkInto = new HashSet<>(m.toWalkInto()); | ||||||
|             m.toBreakCached = null; |             m.resetBlockCache(); | ||||||
|             m.toPlaceCached = null; |  | ||||||
|             m.toWalkIntoCached = null; |  | ||||||
|             if (!prevBreak.equals(new HashSet<>(m.toBreak()))) { |             if (!prevBreak.equals(new HashSet<>(m.toBreak()))) { | ||||||
|                 recalcBP = true; |                 recalcBP = true; | ||||||
|             } |             } | ||||||
| @@ -217,12 +212,12 @@ public class PathExecutor implements Helper { | |||||||
|         if (end - start > 0) { |         if (end - start > 0) { | ||||||
|             System.out.println("Recalculating break and place took " + (end - start) + "ms"); |             System.out.println("Recalculating break and place took " + (end - start) + "ms"); | ||||||
|         }*/ |         }*/ | ||||||
|         Movement movement = path.movements().get(pathPosition); |         IMovement movement = path.movements().get(pathPosition); | ||||||
|         boolean canCancel = movement.safeToCancel(); |         boolean canCancel = movement.safeToCancel(); | ||||||
|         if (costEstimateIndex == null || costEstimateIndex != pathPosition) { |         if (costEstimateIndex == null || costEstimateIndex != pathPosition) { | ||||||
|             costEstimateIndex = pathPosition; |             costEstimateIndex = pathPosition; | ||||||
|             // do this only once, when the movement starts, and deliberately get the cost as cached when this path was calculated, not the cost as it is right now |             // do this only once, when the movement starts, and deliberately get the cost as cached when this path was calculated, not the cost as it is right now | ||||||
|             currentMovementOriginalCostEstimate = movement.getCost(null); |             currentMovementOriginalCostEstimate = movement.getCost(); | ||||||
|             for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { |             for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { | ||||||
|                 if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF && canCancel) { |                 if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF && canCancel) { | ||||||
|                     logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); |                     logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); | ||||||
| @@ -246,7 +241,7 @@ public class PathExecutor implements Helper { | |||||||
|             logDebug("Pausing since current best path is a backtrack"); |             logDebug("Pausing since current best path is a backtrack"); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         MovementState.MovementStatus movementStatus = movement.update(); |         MovementStatus movementStatus = movement.update(); | ||||||
|         if (movementStatus == UNREACHABLE || movementStatus == FAILED) { |         if (movementStatus == UNREACHABLE || movementStatus == FAILED) { | ||||||
|             logDebug("Movement returns status " + movementStatus); |             logDebug("Movement returns status " + movementStatus); | ||||||
|             cancel(); |             cancel(); | ||||||
| @@ -346,7 +341,7 @@ public class PathExecutor implements Helper { | |||||||
|         Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(InputOverrideHandler.Input.SPRINT,false); |         Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(InputOverrideHandler.Input.SPRINT,false); | ||||||
|  |  | ||||||
|         // however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it |         // however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it | ||||||
|         Movement current = path.movements().get(pathPosition); |         IMovement current = path.movements().get(pathPosition); | ||||||
|         if (current instanceof MovementDescend && pathPosition < path.length() - 2) { |         if (current instanceof MovementDescend && pathPosition < path.length() - 2) { | ||||||
|  |  | ||||||
|             // (dest - src) + dest is offset 1 more in the same direction |             // (dest - src) + dest is offset 1 more in the same direction | ||||||
| @@ -361,7 +356,7 @@ public class PathExecutor implements Helper { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             Movement next = path.movements().get(pathPosition + 1); |             IMovement next = path.movements().get(pathPosition + 1); | ||||||
|             if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { |             if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { | ||||||
|                 // a descend then an ascend in the same direction |                 // a descend then an ascend in the same direction | ||||||
|                 if (!player().isSprinting()) { |                 if (!player().isSprinting()) { | ||||||
| @@ -385,7 +380,7 @@ public class PathExecutor implements Helper { | |||||||
|             //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); |             //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); | ||||||
|         } |         } | ||||||
|         if (current instanceof MovementAscend && pathPosition != 0) { |         if (current instanceof MovementAscend && pathPosition != 0) { | ||||||
|             Movement prev = path.movements().get(pathPosition - 1); |             IMovement prev = path.movements().get(pathPosition - 1); | ||||||
|             if (prev instanceof MovementDescend && prev.getDirection().up().equals(current.getDirection().down())) { |             if (prev instanceof MovementDescend && prev.getDirection().up().equals(current.getDirection().down())) { | ||||||
|                 BlockPos center = current.getSrc().up(); |                 BlockPos center = current.getSrc().up(); | ||||||
|                 if (player().posY >= center.getY()) { // playerFeet adds 0.1251 to account for soul sand |                 if (player().posY >= center.getY()) { // playerFeet adds 0.1251 to account for soul sand | ||||||
| @@ -400,7 +395,7 @@ public class PathExecutor implements Helper { | |||||||
|         player().setSprinting(false); |         player().setSprinting(false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static boolean canSprintInto(Movement current, Movement next) { |     private static boolean canSprintInto(IMovement current, IMovement next) { | ||||||
|         if (next instanceof MovementDescend) { |         if (next instanceof MovementDescend) { | ||||||
|             if (next.getDirection().equals(current.getDirection())) { |             if (next.getDirection().equals(current.getDirection())) { | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
| @@ -467,10 +467,10 @@ public class ExampleBaritoneControl extends Behavior implements Helper { | |||||||
|             while (moves.contains(null)) { |             while (moves.contains(null)) { | ||||||
|                 moves.remove(null); |                 moves.remove(null); | ||||||
|             } |             } | ||||||
|             moves.sort(Comparator.comparingDouble(movement -> movement.getCost(new CalculationContext()))); |             moves.sort(Comparator.comparingDouble(Movement::getCost)); | ||||||
|             for (Movement move : moves) { |             for (Movement move : moves) { | ||||||
|                 String[] parts = move.getClass().toString().split("\\."); |                 String[] parts = move.getClass().toString().split("\\."); | ||||||
|                 double cost = move.getCost(new CalculationContext()); |                 double cost = move.getCost(); | ||||||
|                 String strCost = cost + ""; |                 String strCost = cost + ""; | ||||||
|                 if (cost >= ActionCosts.COST_INF) { |                 if (cost >= ActionCosts.COST_INF) { | ||||||
|                     strCost = "IMPOSSIBLE"; |                     strCost = "IMPOSSIBLE"; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user