From 14650f93c5af19148bf41e962c50b8d27b646f7f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 20 Nov 2018 08:19:27 -0800 Subject: [PATCH] walk into lava less --- .../movement/movements/MovementDescend.java | 29 +++++++++++++++++++ .../baritone/pathing/path/PathExecutor.java | 14 +++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 05c140e4..ea7177b4 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -21,17 +21,22 @@ import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.pathing.movement.MovementStatus; import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.Rotation; +import baritone.api.utils.RotationUtils; import baritone.api.utils.input.Input; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; +import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; public class MovementDescend extends Movement { @@ -190,6 +195,18 @@ public class MovementDescend extends Movement { // System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY())); }*/ } + if (safeMode()) { + double destX = (src.getX() + 0.5) * 0.25 + (dest.getX() + 0.5) * 0.75; + double destZ = (src.getZ() + 0.5) * 0.25 + (dest.getZ() + 0.5) * 0.75; + EntityPlayerSP player = ctx.player(); + state.setTarget(new MovementState.MovementTarget( + new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F), + new Vec3d(destX, dest.getY(), destZ), + new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch), + false + )).setInput(Input.MOVE_FORWARD, true); + return state; + } double diffX = ctx.player().posX - (dest.getX() + 0.5); double diffZ = ctx.player().posZ - (dest.getZ() + 0.5); double ab = Math.sqrt(diffX * diffX + diffZ * diffZ); @@ -210,4 +227,16 @@ public class MovementDescend extends Movement { } return state; } + + public boolean safeMode() { + // (dest - src) + dest is offset 1 more in the same direction + // so it's the block we'd need to worry about running into if we decide to sprint straight through this descend + BlockPos into = dest.subtract(src.down()).add(dest); + for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks + if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) { + return true; + } + } + return false; + } } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 5dfc420d..af0fe142 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -378,16 +378,10 @@ public class PathExecutor implements IPathExecutor, Helper { IMovement current = path.movements().get(pathPosition); if (current instanceof MovementDescend && pathPosition < path.length() - 2) { - // (dest - src) + dest is offset 1 more in the same direction - // so it's the block we'd need to worry about running into if we decide to sprint straight through this descend - - BlockPos into = current.getDest().subtract(current.getSrc().down()).add(current.getDest()); - for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks - if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) { - logDebug("Sprinting would be unsafe"); - ctx.player().setSprinting(false); - return; - } + if (((MovementDescend) current).safeMode()) { + logDebug("Sprinting would be unsafe"); + ctx.player().setSprinting(false); + return; } IMovement next = path.movements().get(pathPosition + 1);