diff --git a/src/main/java/com/minecolonies/api/util/ShapeUtil.java b/src/main/java/com/minecolonies/api/util/ShapeUtil.java index dae6597db6a..85d14f39fad 100644 --- a/src/main/java/com/minecolonies/api/util/ShapeUtil.java +++ b/src/main/java/com/minecolonies/api/util/ShapeUtil.java @@ -23,6 +23,7 @@ public static double max(final VoxelShape shape, final Direction.Axis axis) return 1.0; } + // Note: in vanilla this is -infinity if (shape == Shapes.empty()) { return 0; @@ -45,6 +46,7 @@ public static double min(final VoxelShape shape, final Direction.Axis axis) return 0.0; } + // Note: in vanilla this is +infinity if (shape == Shapes.empty()) { return 0; diff --git a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java index 1b905ce716b..7e7df618649 100644 --- a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java +++ b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java @@ -371,7 +371,7 @@ else if (this.path != null && !this.path.isDone()) if (!this.isDone()) { Vec3 vector3d2 = path.getNextEntityPos(mob); - tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y) - 1, Mth.floor(vector3d2.z)); + tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y), Mth.floor(vector3d2.z)); if (ChunkPos.asLong(tempPos) == mob.chunkPosition().toLong() || WorldUtil.isEntityBlockLoaded(level, tempPos)) { mob.getMoveControl() @@ -401,21 +401,32 @@ else if (this.path != null && !this.path.isDone()) * @param y * @return the next y level to go to. */ - public static double getSmartGroundY(final BlockGetter world, final BlockPos pos, final double orgY) + public static double getSmartGroundY(final BlockGetter world, final BlockPos.MutableBlockPos pos, final double orgY) { - final BlockState state = world.getBlockState(pos); - if (state.isAir()) + BlockState state = world.getBlockState(pos); + + if (!state.isAir()) { - return orgY; + final VoxelShape voxelshape = state.getCollisionShape(world, pos); + if (!ShapeUtil.isEmpty(voxelshape)) + { + return pos.getY() + ShapeUtil.max(voxelshape, Direction.Axis.Y); + } } - final VoxelShape voxelshape = state.getCollisionShape(world, pos); - final double maxY = ShapeUtil.max(voxelshape, Direction.Axis.Y); - if (maxY < 1.0) + pos.set(pos.getX(), pos.getY() - 1, pos.getZ()); + + state = world.getBlockState(pos); + if (!state.isAir()) { - return pos.getY(); + final VoxelShape voxelshape = state.getCollisionShape(world, pos); + if (!ShapeUtil.isEmpty(voxelshape)) + { + return pos.getY() + ShapeUtil.max(voxelshape, Direction.Axis.Y); + } } - return pos.getY() + maxY; + + return orgY; } @Nullable