Skip to content

Commit

Permalink
Reconsider walkable surfaces
Browse files Browse the repository at this point in the history
AlexProgrammerDE committed Dec 12, 2024
1 parent 86bdb35 commit 75d05b3
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ public static CompletableFuture<Void> executePathfinding(BotConnection bot, Goal
var start =
SFVec3i.fromDouble(clientEntity.pos());
var startBlockState = level.getBlockState(start);
if (SFBlockHelpers.isRoughlyFullBlock(startBlockState.collisionShape())) {
if (SFBlockHelpers.isTopFullBlock(startBlockState.collisionShape())) {
// If the player is inside a block, move them up
start = start.add(0, 1, 0);
}
Original file line number Diff line number Diff line change
@@ -53,20 +53,21 @@ public static boolean isHurtWhenStoodOn(BlockState blockState) {
}

public static boolean isSafeBlockToStandOn(BlockState state) {
return isRoughlyFullBlock(state.collisionShape()) && !isHurtWhenStoodOn(state);
return isTopFullBlock(state.collisionShape()) && !isHurtWhenStoodOn(state);
}

public static boolean isStairsBlockToStandOn(TagsState tagsState, BlockState state) {
return tagsState.is(state.blockType(), BlockTags.STAIRS) && !isHurtWhenStoodOn(state);
}

public static boolean isRoughlyFullBlock(BlockShapeGroup type) {
if (type.blockShapes().size() != 1) {
return false;
public static boolean isTopFullBlock(BlockShapeGroup type) {
for (var shape : type.blockShapes()) {
if (shape.isBlockXZCollision() && shape.maxY >= SAFE_BLOCK_MIN_HEIGHT) {
return true;
}
}

var shape = type.blockShapes().getFirst();
return shape.isBlockXZCollision() && shape.minY == 0 && shape.maxY >= SAFE_BLOCK_MIN_HEIGHT;
return false;
}

public static boolean isDiggable(BlockType type) {

0 comments on commit 75d05b3

Please sign in to comment.