Skip to content

Commit

Permalink
Make parkour even over non-air gaps
Browse files Browse the repository at this point in the history
This will make parkour happen a lot more frequently over "dangerous" gaps, but it'll help make parkour more often when needed. This allows movement that wasn't possible before.
  • Loading branch information
AlexProgrammerDE committed Oct 18, 2023
1 parent ad1ba41 commit dcc2ffe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ public GraphInstructions[] getActions(BotEntityState node) {

parkourMovement.setImpossible(true);
}
// We only want to jump over dangerous blocks/gaps
// So either a non-full-block like water or lava or magma
// since it hurts to stand on.
case PARKOUR_UNSAFE_TO_STAND_ON -> {
if (BlockTypeHelper.isSafeBlockToStandOn(blockState)) {
parkourMovement.setImpossible(true);
}
}
case MOVEMENT_SOLID -> {
// Block is safe to walk on, no need to check for more
if (blockState.blockShapeType().isFullBlock()) {
Expand Down Expand Up @@ -380,6 +388,11 @@ private static ParkourMovement registerParkourMovement(Object2ObjectMap<Vector3i
}
}

{
blockSubscribers.computeIfAbsent(movement.requiredUnsafeBlock(), CREATE_MISSING_FUNCTION)
.add(new BlockSubscription(movementIndex, SubscriptionType.PARKOUR_UNSAFE_TO_STAND_ON));
}

{
blockSubscribers.computeIfAbsent(movement.requiredSolidBlock(), CREATE_MISSING_FUNCTION)
.add(new BlockSubscription(movementIndex, SubscriptionType.MOVEMENT_SOLID));
Expand Down Expand Up @@ -411,7 +424,8 @@ enum SubscriptionType {
MOVEMENT_SOLID,
MOVEMENT_ADD_CORNER_COST_IF_SOLID,
MOVEMENT_AGAINST_PLACE_SOLID,
DOWN_SAFETY_CHECK
DOWN_SAFETY_CHECK,
PARKOUR_UNSAFE_TO_STAND_ON
}

record BlockSubscription(int movementIndex, SubscriptionType type, int blockArrayIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ public List<Vector3i> listRequiredFreeBlocks() {

var oneFurther = direction.offset(FEET_POSITION_RELATIVE_BLOCK);

// The gap to jump over
requiredFreeBlocks.add(oneFurther.sub(0, 1, 0));

// Room for jumping
requiredFreeBlocks.add(oneFurther);
requiredFreeBlocks.add(oneFurther.add(0, 1, 0));
Expand All @@ -80,6 +77,11 @@ public List<Vector3i> listRequiredFreeBlocks() {
return requiredFreeBlocks;
}

public Vector3i requiredUnsafeBlock() {
// The gap to jump over, needs to be unsafe for this movement to be possible
return direction.offset(FEET_POSITION_RELATIVE_BLOCK).sub(0, 1, 0);
}

public Vector3i requiredSolidBlock() {
// Floor block
return targetFeetBlock.sub(0, 1, 0);
Expand Down

0 comments on commit dcc2ffe

Please sign in to comment.