From 292eaef25e8949411b6f5399ff4a72fc0d59b592 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:52:53 +0100 Subject: [PATCH] Add support for nether vines --- .../movement/movements/MovementPillar.java | 15 ++++++++++++--- .../movement/movements/MovementTraverse.java | 8 ++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index a11086d5b..6256c2260 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -65,7 +65,7 @@ protected Set calculateValidPositions() { public static double cost(CalculationContext context, int x, int y, int z) { BlockState fromState = context.get(x, y, z); Block from = fromState.getBlock(); - boolean ladder = from == Blocks.LADDER || from == Blocks.VINE; + boolean ladder = from == Blocks.LADDER || from == Blocks.VINE || from == Blocks.WEEPING_VINES || from == Blocks.TWISTING_VINES || from == Blocks.WEEPING_VINES_PLANT || from == Blocks.TWISTING_VINES_PLANT; BlockState fromDown = context.get(x, y - 1, z); if (!ladder) { if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) { @@ -116,7 +116,7 @@ public static double cost(CalculationContext context, int x, int y, int z) { return COST_INF; } if (hardness != 0) { - if (toBreakBlock == Blocks.LADDER || toBreakBlock == Blocks.VINE) { + if (toBreakBlock == Blocks.LADDER || toBreakBlock == Blocks.VINE || toBreakBlock == Blocks.WEEPING_VINES || toBreakBlock == Blocks.TWISTING_VINES) { hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it } else { BlockState check = context.get(x, y + 3, z); // the block on top of the one we're going to break, could it fall on us? @@ -194,10 +194,12 @@ public MovementState updateState(MovementState state) { } boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE; boolean vine = fromDown.getBlock() == Blocks.VINE; + boolean nether_vine = fromDown.getBlock() == Blocks.WEEPING_VINES || fromDown.getBlock() == Blocks.TWISTING_VINES || fromDown.getBlock() == Blocks.WEEPING_VINES_PLANT || fromDown.getBlock() == Blocks.TWISTING_VINES_PLANT; + Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(positionToPlace), ctx.playerRotations()); - if (!ladder) { + if (!(ladder || nether_vine)) { state.setTarget(new MovementState.MovementTarget(ctx.playerRotations().withPitch(rotation.getPitch()), true)); } @@ -223,6 +225,13 @@ public MovementState updateState(MovementState state) { MovementHelper.moveTowards(ctx, state, against); return state; + } else if (nether_vine) { + if (ctx.playerFeet().equals(dest)) { + return state.setStatus(MovementStatus.SUCCESS); + } + MovementHelper.moveTowards(ctx, state, dest); + state.setInput(Input.JUMP, true); + return state; } else { // Get ready to place a throwaway block if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, src.x, src.y, src.z)) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index cec3ca39a..3a2d25171 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -114,13 +114,13 @@ public static double cost(CalculationContext context, int x, int y, int z, int d } return WC; } - if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) { + if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE || srcDownBlock == Blocks.WEEPING_VINES || srcDownBlock == Blocks.TWISTING_VINES || srcDownBlock == Blocks.WEEPING_VINES_PLANT || srcDownBlock == Blocks.TWISTING_VINES_PLANT) { hardness1 *= 5; hardness2 *= 5; } return WC + hardness1 + hardness2; } else {//this is a bridge, so we need to place a block - if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) { + if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE || srcDownBlock == Blocks.WEEPING_VINES || srcDownBlock == Blocks.TWISTING_VINES || srcDownBlock == Blocks.WEEPING_VINES_PLANT || srcDownBlock == Blocks.TWISTING_VINES_PLANT) { return COST_INF; } if (MovementHelper.isReplaceable(destX, y - 1, destZ, destOn, context.bsi)) { @@ -217,7 +217,7 @@ public MovementState updateState(MovementState state) { state.setInput(Input.SNEAK, false); Block fd = BlockStateInterface.get(ctx, src.below()).getBlock(); - boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; + boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE || fd == Blocks.WEEPING_VINES || fd == Blocks.TWISTING_VINES || fd == Blocks.WEEPING_VINES_PLANT || fd == Blocks.TWISTING_VINES_PLANT; if (pb0.getBlock() instanceof DoorBlock || pb1.getBlock() instanceof DoorBlock) { boolean notPassable = pb0.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, dest, src); @@ -370,7 +370,7 @@ public boolean safeToCancel(MovementState state) { protected boolean prepared(MovementState state) { if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.below())) { Block block = BlockStateInterface.getBlock(ctx, src.below()); - if (block == Blocks.LADDER || block == Blocks.VINE) { + if (block == Blocks.LADDER || block == Blocks.VINE || block == Blocks.WEEPING_VINES || block == Blocks.TWISTING_VINES || block == Blocks.WEEPING_VINES_PLANT || block == Blocks.TWISTING_VINES_PLANT) { state.setInput(Input.SNEAK, true); } }