Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nether vines #4111

Open
wants to merge 1 commit into
base: 1.19.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected Set<BetterBlockPos> 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) {
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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));
}

Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down