From a072fcd17a54b17858d5ac109c15cd6c03e4158c Mon Sep 17 00:00:00 2001 From: someaddons Date: Fri, 13 Dec 2024 23:05:55 +0100 Subject: [PATCH] Fix citizens not always using toggleables the pathfollow node already advanced Fix citizens not able to pass doors/gates at the end of stairs --- .../entity/ai/minimal/EntityAIInteractToggleAble.java | 7 ++++--- .../core/entity/pathfinding/SurfaceType.java | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minecolonies/core/entity/ai/minimal/EntityAIInteractToggleAble.java b/src/main/java/com/minecolonies/core/entity/ai/minimal/EntityAIInteractToggleAble.java index f7d1883d432..1e5a2e433a3 100644 --- a/src/main/java/com/minecolonies/core/entity/ai/minimal/EntityAIInteractToggleAble.java +++ b/src/main/java/com/minecolonies/core/entity/ai/minimal/EntityAIInteractToggleAble.java @@ -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) { @@ -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); @@ -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)); } diff --git a/src/main/java/com/minecolonies/core/entity/pathfinding/SurfaceType.java b/src/main/java/com/minecolonies/core/entity/pathfinding/SurfaceType.java index f7a80f98ce1..6ff23a51c62 100644 --- a/src/main/java/com/minecolonies/core/entity/pathfinding/SurfaceType.java +++ b/src/main/java/com/minecolonies/core/entity/pathfinding/SurfaceType.java @@ -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())))