Skip to content

Commit

Permalink
Fix citizens not always using toggleables the pathfollow node already…
Browse files Browse the repository at this point in the history
… advanced (#10532)

Fix citizens not always using toggleables when the pathfollow node already advanced
Fix citizens not able to pass doors/gates at the end of stairs
  • Loading branch information
someaddons authored and Raycoms committed Dec 22, 2024
1 parent a7ffbcf commit d6b96c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void checkPathBlocksCollided(final Path path)
}

final int maxLengthToCheck = Math.min(path.getNextNodeIndex() + LENGTH_TO_CHECK, path.getNodeCount());
for (int i = Math.max(0, path.getNextNodeIndex() - 1); i < maxLengthToCheck; i++)
for (int i = Math.max(0, path.getNextNodeIndex() - 2); i < maxLengthToCheck; i++)
{
if (i == path.getNodeCount() - 1)
{
Expand Down Expand Up @@ -249,7 +249,7 @@ private boolean checkPathBlocksBelow()
}

final int maxLengthToCheck = Math.min(path.getNextNodeIndex() + LENGTH_TO_CHECK, path.getNodeCount());
for (int i = Math.max(0, path.getNextNodeIndex() - 1); i < maxLengthToCheck; ++i)
for (int i = Math.max(0, path.getNextNodeIndex() - 2); i < maxLengthToCheck; ++i)
{
final Node pathpoint = path.getNode(i);

Expand All @@ -275,7 +275,8 @@ else if (i < path.getNodeCount() - 1)
{
// Check if the next pathing node is below
final Node nextPoint = path.getNode(i + 1);
if (pos.getX() == nextPoint.x && pos.getY() > nextPoint.y && pos.getZ() == nextPoint.z)
if ((pos.getX() == nextPoint.x && pos.getY() > nextPoint.y && pos.getZ() == nextPoint.z) ||
entity.getY() - pos.getY() > 1)
{
toggleAblePositions.put(pos, entity.level().getBlockState(pos).getValue(BlockStateProperties.OPEN));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ public static SurfaceType getSurfaceType(final BlockGetter world, final BlockSta
}

if (block instanceof FenceBlock
|| block instanceof FenceGateBlock
|| block instanceof WallBlock
|| block instanceof AbstractBlockMinecoloniesDefault
|| block instanceof BambooStalkBlock
|| block instanceof BambooSaplingBlock
|| block instanceof DoorBlock)
|| block instanceof BambooSaplingBlock)
{
return SurfaceType.NOT_PASSABLE;
}

if (block instanceof FenceGateBlock || block instanceof DoorBlock)
{
return SurfaceType.DROPABLE;
}

final VoxelShape shape = blockState.getCollisionShape(world, pos);
final double maxShapeY = ShapeUtil.max(shape, Direction.Axis.Y);
if (maxShapeY < 0.5 && PathfindingUtils.isDangerous(world.getBlockState(pos.below())))
Expand Down

0 comments on commit d6b96c4

Please sign in to comment.