diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index 7855c04a..dd79cd89 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -18,7 +18,6 @@ package baritone.pathing.movement; import baritone.pathing.movement.movements.*; -import baritone.pathing.movement.movements.result.DescendResult; import baritone.pathing.movement.movements.result.MoveResult; import baritone.pathing.movement.movements.result.ParkourResult; import baritone.utils.pathing.BetterBlockPos; @@ -163,8 +162,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x + 1, z); - return new MoveResult(x + 1, res.y, z, res.cost); + return MovementDescend.cost(context, x, y, z, x + 1, z); } }, @@ -181,8 +179,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x - 1, z); - return new MoveResult(x - 1, res.y, z, res.cost); + return MovementDescend.cost(context, x, y, z, x - 1, z); } }, @@ -199,8 +196,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x, z - 1); - return new MoveResult(x, res.y, z - 1, res.cost); + return MovementDescend.cost(context, x, y, z, x, z - 1); } }, @@ -217,8 +213,7 @@ public enum Moves { @Override public MoveResult apply(CalculationContext context, int x, int y, int z) { - DescendResult res = MovementDescend.cost(context, x, y, z, x, z + 1); - return new MoveResult(x, res.y, z + 1, res.cost); + return MovementDescend.cost(context, x, y, z, x, z + 1); } }, diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 8da86a37..2a90f31a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -23,7 +23,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; -import baritone.pathing.movement.movements.result.DescendResult; +import baritone.pathing.movement.movements.result.MoveResult; import baritone.utils.BlockStateInterface; import baritone.utils.InputOverrideHandler; import baritone.utils.pathing.BetterBlockPos; @@ -33,7 +33,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; -import static baritone.pathing.movement.movements.result.DescendResult.IMPOSSIBLE; +import static baritone.pathing.movement.movements.result.MoveResult.IMPOSSIBLE; public class MovementDescend extends Movement { @@ -51,14 +51,14 @@ public class MovementDescend extends Movement { @Override protected double calculateCost(CalculationContext context) { - DescendResult result = cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.y != dest.y) { + MoveResult result = cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.destY != dest.y) { return COST_INF; // doesn't apply to us, this position is a fall not a descend } return result.cost; } - public static DescendResult cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { + public static MoveResult cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { return IMPOSSIBLE; @@ -105,10 +105,10 @@ public class MovementDescend extends Movement { walk = WALK_ONE_OVER_SOUL_SAND_COST; } totalCost += walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST); - return new DescendResult(y - 1, totalCost); + return new MoveResult(destX, y - 1, destZ, totalCost); } - public static DescendResult dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { + public static MoveResult dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, @@ -132,7 +132,7 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // TODO fix } // found a fall into water - return new DescendResult(newY, tentativeCost); // TODO incorporate water swim up cost? + return new MoveResult(destX, newY, destZ, tentativeCost); // TODO incorporate water swim up cost? } if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) { return IMPOSSIBLE; @@ -147,11 +147,11 @@ public class MovementDescend extends Movement { return IMPOSSIBLE; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } if (context.hasWaterBucket() && fallHeight <= context.maxFallHeightBucket() + 1) { - return new DescendResult(newY + 1, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 + return new MoveResult(destX, newY + 1, destZ, tentativeCost + context.placeBlockCost()); // this is the block we're falling onto, so dest is +1 } if (fallHeight <= context.maxFallHeightNoWater() + 1) { // fallHeight = 4 means onto.up() is 3 blocks down, which is the max - return new DescendResult(newY + 1, tentativeCost); + return new MoveResult(destX, newY + 1, destZ, tentativeCost); } else { return IMPOSSIBLE; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 980371a9..1e6a36ac 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -25,8 +25,11 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.pathing.movement.MovementState.MovementTarget; -import baritone.pathing.movement.movements.result.DescendResult; -import baritone.utils.*; +import baritone.pathing.movement.movements.result.MoveResult; +import baritone.utils.BlockStateInterface; +import baritone.utils.InputOverrideHandler; +import baritone.utils.RayTraceUtils; +import baritone.utils.Utils; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; @@ -46,8 +49,8 @@ public class MovementFall extends Movement { @Override protected double calculateCost(CalculationContext context) { - DescendResult result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); - if (result.y != dest.y) { + MoveResult result = MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z); + if (result.destY != dest.y) { return COST_INF; // doesn't apply to us, this position is a descend not a fall } return result.cost; diff --git a/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java b/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java deleted file mode 100644 index c136fbb1..00000000 --- a/src/main/java/baritone/pathing/movement/movements/result/DescendResult.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.pathing.movement.movements.result; - -import static baritone.pathing.movement.ActionCosts.COST_INF; - -/** - * @author Brady - * @since 9/23/2018 - */ -public final class DescendResult extends Result { - - public static final DescendResult IMPOSSIBLE = new DescendResult(0, COST_INF); - - public final int y; - - public DescendResult(int y, double cost) { - super(cost); - this.y = y; - } -} diff --git a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java index a0419a2b..2b3ed0b7 100644 --- a/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java +++ b/src/main/java/baritone/pathing/movement/movements/result/MoveResult.java @@ -17,7 +17,10 @@ package baritone.pathing.movement.movements.result; +import static baritone.pathing.movement.ActionCosts.COST_INF; + public final class MoveResult { + public static final MoveResult IMPOSSIBLE = new MoveResult(0, 0, 0, COST_INF); public final int destX; public final int destY; public final int destZ;